summaryrefslogtreecommitdiff
path: root/npc/021-1/logic.txt
blob: 24fc6e465ca8c60db193f09dac47782fef7bb76c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// TMW2 scripts.
// Authors:
//    Jesusalva
// Description:
//    Cave logic. Controls also switchs and false warps. See soren/main for more info.

// Logic
function	script	CindySwitch_Check_211	{
    .@st1=getvariableofnpc(.lifetime, "#CindySwitch_01")-gettimetick(2);
    .@st2=getvariableofnpc(.lifetime, "#CindySwitch_02")-gettimetick(2);
    .@st3=getvariableofnpc(.lifetime, "#CindySwitch_03")-gettimetick(2);
    .@st4=getvariableofnpc(.lifetime, "#CindySwitch_04")-gettimetick(2);
    .@st5=getvariableofnpc(.lifetime, "#CindySwitch_05")-gettimetick(2);
    .@i=0;
    if (.@st1 > 0) .@i++;
    if (.@st2 > 0) .@i++;
    if (.@st3 > 0) .@i++;
    if (.@st4 > 0) .@i++;
    if (.@st5 > 0) .@i++;
    return .@i;
}

// Passages
021-1,155,196,0	script	#0211Logic	NPC_NO_SPRITE,0,0,{
    end;
OnTouch:
    .@q=getq(NivalisQuest_Cindy);
    if (.@q < 3) end;
    if ($@CINDY_STATE > gettimetick(2)) goto L_Safe;
    if ($@CINDY_STATE % 2 == 0) goto L_Blocked;
    if (CindySwitch_Check_211() == 5) {
        .@pos=rand(0,8);
        if (.@q == 4)
            warp "021-1", .xp[.@pos], .yp[.@pos];
        else
            warp "021-2", 80, 102;
    } else {
        switch (CindySwitch_Check_211()) {
            case 0:
            case 1:
                end;
            case 2:
            case 3:
                dispbottom l("A few switches aren't triggered yet."); break;
            case 4:
            case 5:
                dispbottom l("A single switch is not online - Cannot pass without all of them on."); break;
        }
    }
    end;

L_Blocked:
    dispbottom l("This place is reeking blood. We better come again later.");
    end;

L_Safe:
    dispbottom l("There's no reason to enter these caves now.");
    end;

OnInit:
    setarray .xp,  25,  43,  97, 142, 274,  52, 36, 52, 120;
    setarray .yp, 300, 300, 300, 300, 299, 176, 79, 77,  73;
    end;
}

021-1,136,29,0	script	#FrostiaGateway	NPC_NO_SPRITE,0,0,{
    end;
OnTouch:
    npctalkonce l("You need to be using a @@ because extremely cold temperatures.", getitemlink(RedknightArmor));
    end;

}

// Switches
021-1,282,34,0	script	#CindySwitch_01	NPC_SWITCH_OFFLINE,{
    .@q=getq(NivalisQuest_Cindy);
    if (.@q < 3) {
        mesn strcharinfo(0);
        mesq l("This is a strange switch...");
        close;
    }
    if (.lifetime-gettimetick(2) <= 0) {
        mesc l("Insert a key and pull the switch?");
        select
            rif(countitem(TreasureKey), l("Pull it")),
            l("Leave it");
        if (@menu == 1) {
            delitem TreasureKey, 1;
            getexp rand(55, 110), rand(5, 11);
            .lifetime=gettimetick(2)+rand(110, 150); // Something between 1m50s and 2m30s
            specialeffect(27);
            setnpcdisplay .name$, NPC_SWITCH_ONLINE;
            initnpctimer;
            .@r=rand(0,100);
            getmapxy(.@m$, .@x, .@y,0);
            if (.@r < 80)
                monster .@m$, .@x, .@y, "Yeti", Yeti, 1;
            else if (.@r > 99)
                makeitem(Candy, 1, .@m$, .@x, .@y);
            npctalk l("Automatic disarm in: @@", FuzzyTime(.lifetime));
            closedialog;
        }
        close;
    }
    npctalk l("Automatic disarm in: @@", FuzzyTime(.lifetime));
    end;

OnTimer1000:
    if (.lifetime-gettimetick(2) <= 0) {
        setnpcdisplay .name$, NPC_SWITCH_OFFLINE;
        stopnpctimer;
    } else {
        initnpctimer;
    }
    end;

OnInit:
    .sex = G_OTHER;
    .distance = 3;
    .lifetime=0;  // When will this switch turn off automatically
    end;

}

021-1,231,36,0	duplicate(#CindySwitch_01)	#CindySwitch_02	NPC_SWITCH_OFFLINE
021-1,34,29,0	duplicate(#CindySwitch_01)	#CindySwitch_03	NPC_SWITCH_OFFLINE
021-1,25,297,0	duplicate(#CindySwitch_01)	#CindySwitch_04	NPC_SWITCH_OFFLINE
021-1,30,168,0	duplicate(#CindySwitch_01)	#CindySwitch_05	NPC_SWITCH_OFFLINE