summaryrefslogtreecommitdiff
path: root/npc/008-0/master.txt
blob: 64fecbaee122762f0b29a477261fb821d23f029d (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
// TMW-2 Script
// Author:
//  Jesusalva
// Description:
//  This NPC is a work on progress. It measures all players equal.

008-0,47,63,0	script	Party Master	NPC_BRGUARD_SWORD,{
    mesn;
    if (getcharid(1) > 0) {
	    mesq l("You're in the \"@@\" party, very good!", getpartyname(getcharid(1)));
        next;
    } else {
        mesq l("I protect a dungeon for PARTIES. You're not on a party, get moving.");
        close;
    }

    mesn;
    mesq l("I protect a very dangerous dungeon, and it is so dangerous, that only parties can go in.");
    next;
    if (strcharinfo(0) != getpartyleader(getcharid(1))) goto L_NotYou;
    mesn;
    mesq l("There are five floors, and they're all very dangerous. But there are riches to be found.");
    next;
    mesn;
    mesq l("You also can't stay there forever! You will have about 20 minutes to entirely clear it out and defeat the last boss.");
    next;
    // Get info about your party, and backup it
    getpartymember(getcharid(1));
	.@count = $@partymembercount;
	copyarray(.@name$[0], $@partymembername$[0], $@partymembercount);
	copyarray(.@aid[0], $@partymemberaid[0], $@partymembercount);
	copyarray(.@cid[0], $@partymembercid[0], $@partymembercount);
    .@count_online=0;

    if (.@count < 3 && !$@GM_OVERRIDE) goto L_TooSmall;
    mesn;
    mesc l("Are you and your party ready?"), 1;
    if (askyesno() != ASK_YES)
        close;

    // Loop though party to see if you can start
	for (.@i = 0; .@i < .@count; ++.@i) {
        // Online?
		if (isloggedin(.@aid[.@i], .@cid[.@i])) {
            getmapxy(.@m$, .@x, .@y, 0, .@name$[.@i]);
            // Here?
            if (.@m$ == .map$)
    			.@count_online++;
        }
    }

    // How many are logged in and here?
    if (.@count_online < 3 && !$@GM_OVERRIDE) goto L_TooSmall;

    // TODO: Query if exp sharing is enabled
    // TODO: Instance for party

    // Warp everyone and add timers
    partytimer("008-0", 1000, "Party Master::OnStart", getcharid(1));
    warpparty("008-1", 176, 20, getcharid(1), "008-0", true);

    // TODO: Monsters
    monster("008-1", 90, 69, "Time Bonus", Scorpion, 1, "Party Master::OnAddTime");
    close;










// Only the party leader can start this. But you can rejoin, as long map leader is on 008-x
L_NotYou:
    getmapxy(.@m$, .@x, .@y, 0, getpartyleader(getcharid(1)));
    if (.@m$ ~= "008-*" && @pmloop) {
        mesn;
        mesq l("@@, your party leader, is inside, I'm not sure where.", getpartyleader(getcharid(1)));
        mesc l("Enter dungeons? You won't be able to join anymore when he dies."), 1;
        if (askyesno() != ASK_YES)
            close;
        // Double check
        getmapxy(.@m$, .@x, .@y, 0, getpartyleader(getcharid(1)));
        if (.@m$ ~= "008-*")
            warp "008-1", 176, 20;
    } else {
        mesn;
        mesq l("If you bring me @@, your party leader, I can let you in.", getpartyleader(getcharid(1)));
    }
    close;

// Minimum 3 players
L_TooSmall:
    mesn;
    mesq l("However, I need to see at least three volunteers here, to allow you in.");
    close;



// Main Loop
OnStart:
    @pmloop=0;
OnLoop:
    if (getmapname() ~= "008-*") {
        @pmloop+=1;
        if (@pmloop < 1200) {
            addtimer(1000, "Party Master::OnLoop");
        } else {
            warp "008-0", 47, 64;
            dispbottom l("You ran out of time...");
        }
    } else {
        @pmloop=0;
    }
    end;

// TODO: We must use areatimer() and grant time bonus to everyone who killed it
OnAddTime:
    @pmloop=60;
    end;

OnInit:
    .sex = G_MALE;
    .distance = 5;
    end;
}