summaryrefslogtreecommitdiff
path: root/npc/026-3/ctrl.c
blob: 059b903b66240b30ae4497aa7803ec24c77f7e6b (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
// TMW2 scripts.
// Author:
//    Jesusalva
// Description:
//   The Impregnable Fortress Control Files
// Quest: General_Fortress
//  (MaxFloor+2, internal, internal)

// 0263Event(switchID)
function	script	0263Event	{
    // Terminate the script if you already flipped it (also to stop trolls)
    if (getq(General_Fortress) != 4) end;
    if (getq2(General_Fortress) & getarg(0)) {
        dispbottom l("I have already flipped this switch earlier.");
        end;
    }
    // Flip it for good
    setq2 General_Fortress, getq2(General_Fortress) | getarg(0);
    // And if all switches are flipped...!
    if (getq2(General_Fortress) == 15) {
        setq General_Fortress, 5, 0, 0;
        specialeffect(FX_MGWARP, SELF, getcharid(3));
    }
    return;
}

// The main entrance
026-3,55,128,0	script	Impregnable#B3F	NPC_HIDDEN,0,0,{
    end;

OnTouch:
    dispbottom l("From this point forward, you'll no longer be able to return to the previous floor.");
    if (getq(General_Fortress) > 4) goto L_Warp;
    mesc l(".:: Impregnable Fortress, %sF ::.", "B3"), 3;
    msObjective(getq(General_Fortress) == 5, l("* Flip all four switches"));
    msObjective($MK_TEMPVAR >= MKIF_LV_B4F, l("Minimum wins: %d/%d", $MK_TEMPVAR, MKIF_LV_B4F));
    mes "";
    mesc l("Hint: You cannot unflip a switch, but they unflip every 12 hours.");
    close;

L_Warp:
    // Not unlocked
    if ($GAME_STORYLINE >= 3 && $MK_TEMPVAR < MKIF_LV_B4F) {
        mesc l("The gate is sealed shut."), 1;
        mesc l("The monster army is still strong on this floor!"), 1;
        mesc l("Minimum wins: %d/%d", $MK_TEMPVAR, MKIF_LV_B4F), 1;
        close;
    }
    // This is a more complex warp
    .@e = 0;
    do {
        if (.@e >= 30) break;
        .@x = rand2(20, 40);
        .@y = rand2(20, 40);
        .@e+=1;
    } while (!checknpccell("026-4", .@x, .@y, cell_chkpass));
    warp "026-4", .@x, .@y;
    end;

// Reset the switches
OnClock0500:
OnClock1700:
	setnpcdisplay "#026-3_129_38", NPC_SWITCH_OFFLINE;
	setnpcdisplay "#026-3_59_86",  NPC_SWITCH_OFFLINE;
	setnpcdisplay "#026-3_94_80",  NPC_SWITCH_OFFLINE;
	setnpcdisplay "#026-3_53_59",  NPC_SWITCH_OFFLINE;
    end;

OnInit:
    setarray $@MKB3FX, 66, 60,  54,  95,  80, 90, 88, 61;
    setarray $@MKB3FY, 18, 87, 118, 122, 140, 88, 56, 51;
    end;
}


// Miller system (otherwise, you can't reach the switches & platforms)
026-3,21,69,0	script	#0263WA+	NPC_FANCY_CIRCLE,0,0,{
    end;
OnTouch:
    // All portals are the same, anyway
    if (compare(strnpcinfo(2), "+"))
        @state += 3;
    else
        @state -= 2;
    .@index = miller_rand(@state, getcharid(0), 7);
    slide $@MKB3FX[.@index], $@MKB3FY[.@index];
    end;
}

026-3,28,136,0	duplicate(#0263WA+)	#0263WA-	NPC_FANCY_CIRCLE,0,0
026-3,45,81,0	duplicate(#0263WA+)	#0263WB+	NPC_FANCY_CIRCLE,0,0
026-3,79,95,0	duplicate(#0263WA+)	#0263WB-	NPC_FANCY_CIRCLE,0,0
026-3,48,100,0	duplicate(#0263WA+)	#0263WC+	NPC_FANCY_CIRCLE,0,0
026-3,66,127,0	duplicate(#0263WA+)	#0263WC-	NPC_FANCY_CIRCLE,0,0
026-3,83,126,0	duplicate(#0263WA+)	#0263WD+	NPC_FANCY_CIRCLE,0,0
026-3,107,110,0	duplicate(#0263WA+)	#0263WD-	NPC_FANCY_CIRCLE,0,0
026-3,117,95,0	duplicate(#0263WA+)	#0263WE+	NPC_FANCY_CIRCLE,0,0
026-3,140,100,0	duplicate(#0263WA+)	#0263WE-	NPC_FANCY_CIRCLE,0,0
026-3,105,87,0	duplicate(#0263WA+)	#0263WF+	NPC_FANCY_CIRCLE,0,0
026-3,90,73,0	duplicate(#0263WA+)	#0263WF-	NPC_FANCY_CIRCLE,0,0
026-3,82,65,0	duplicate(#0263WA+)	#0263WG+	NPC_FANCY_CIRCLE,0,0
026-3,76,52,0	duplicate(#0263WA+)	#0263WG-	NPC_FANCY_CIRCLE,0,0
026-3,44,41,0	duplicate(#0263WA+)	#0263WH+	NPC_FANCY_CIRCLE,0,0
026-3,49,68,0	duplicate(#0263WA+)	#0263WH-	NPC_FANCY_CIRCLE,0,0