summaryrefslogtreecommitdiff
path: root/npc/functions/gmbot.txt
blob: 072f64fe4961264bd025bccb255d4fdd988f227d (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
130
131
132
133
134
// TMW-2 Script
// Author:
//  Jesusalva
// Description:
//  GM Bot for the Monster King.

000-0,0,0,0	script	Monster King	NPC_HIDDEN,{
OnSlaveDie:
    end;
OnBourneAgain:
    channelmes("#world", strcharinfo(0)+" did an act worth of notice.");
    dispbottom l("Oh well, this sucks, but that was only an illusion.");
    dispbottom l("The real Monster King is probably on his fortress. It'll take more than that to take him down.");
    getexp BaseLevel**3, 0;
    Mobpt = Mobpt + 165;
    // We need to start over
OnInit:
    $@MK=monster("boss", 45, 45, "The Monster King", MonsterKing, 1, "Monster King::OnBourneAgain");

    // Variables which other NPCs must take in account
    $@MK_AGGRO=0;
    $@MK_SCENE=0;

    // Variables only for this NPC
    .users=getusers(1);
    .nearby=getusers(8);
    .mp$="boss";
    .aid="200000";
    .cid="150002";
    // Constants

    // We should jump straight to loop (it runs every 62 seconds)
OnTimer62000:
    // Regenerate some data, and kill spurious mobs
    .users=getusers(1);
    if (mobcount(.mp$, "Monster King::OnSlaveDie")) {
        announce ("Monster King: Noobs, you are all a bunch of noobs!"), bc_map|bc_npc;
        killmonster(.mp$, "Monster King::OnSlaveDie");
    }

    // We are on an event, so skip this loop
    if ($@MK_SCENE || $@GM_EVENT)
        initnpctimer;

    // The Monster King is online. This loop is not needed
    if (isloggedin(.aid, .cid)) {
        if (!$@MK_SCENE)
            unitwarp($@MK, "boss", 45, 45);
        else
            rodex_sendmail(.cid, "MKBot", "Running Event", "An event is currently running by the MK Bot. Please logout and suppress it.");
        initnpctimer;
    }

    // Raise aggro
    $@MK_AGGRO+=.users;

    // Mana Stone
    if (.mp$ == "011-1")
        enablenpc "Mana Stone";

    // Select a random map. Never shows up at Candor and cities, nor indoors. Not all maps either.
    setarray .@m$,  "boss", "boss", "001-1", "001-3", "001-4", "001-5", "001-6", "001-7", "001-10",
                    "003-1", "003-1-3", "004-1", "004-2", "007-1", "010-1", "010-1-1", "010-2", "011-1",
                    "014-1", "014-2", "014-3", "014-4", "014-5", "015-1", "015-2", "015-3", "015-5",
                    "018-1-1", "018-2", "018-3", "018-4", "018-4-1",
                    "019-1", "019-2", "019-4", "021-1", "022-1", "023-1";
    .mp$=any_of(.@m$);

    // Try to warp randomly, up to 30 attempts
    .@e=0; .@x=0; .@y=0;
   while (!checknpccell(.mp$, .@x, .@y, cell_chkpass))
    {
        if (.@e == 30) {
            .mp$="boss";
            .@x=45;
            .@y=45;
            break;
        }
        .@x = rand(20, 300);
        .@y = rand(20, 300);
        ++.@e;
    }
    unitwarp($@MK, .mp$, .@x, .@y);
    .nearby=getusers(8);

    // Handle Mana Stone
    if (.mp$ == "011-1")
        disablenpc "Mana Stone";

    // Debug markers
    if ($@GM_OVERRIDE)
        debugmes "Monster King (bot): "+.mp$+" ("+.@x+", "+.@y+")";

    // If too few players are online, we don't need an event AT ALL!
    if (.users < rand(2,4)) {
        initnpctimer;
        end;
    }

    // Siege events
    if ($@MK_AGGRO >= 30 && rand(0,100) < 70) {
        // Tulimshar
        if (.mp$ ~= "003-*") {
            announce ("Monster King: I smell humans! Humans must die!"), bc_map|bc_npc;
            $@MK_SCENE=MK_SIEGE_TULIM;
            donpcevent("Lieutenant Dausen::OnMKSiege");
        }
        // Hurnscald (will never happen, MK doesn't visits 012-1)
        if (.mp$ ~= "012-*") {
            announce ("Monster King: I smell humans! Humans must die!"), bc_map|bc_npc;
            $@MK_SCENE=MK_SIEGE_HURNS;
            donpcevent("#HurnscaldSiege::OnMKSiege");
        }
    }
    // Decide if we should have an event here
    if (.nearby > 1 && $@MK_AGGRO >= rand(0,100)){
        // We should decide event kind, but that's NYI
        announce ("Monster King: I smell humans! Humans must die!"), bc_map|bc_npc;

        getmapxy(.@m$, .@x, .@y, UNITTYPE_MOB, $@MK);
        // 50% more monsters at night time
        if (is_night())
            $@MK_AGGRO=$@MK_AGGRO*3/2;

        // Spawn stuff
        areamonster(.@m$, .@x-20, .@y-20, .@x+20, .@y+20, "Monster", ManaGhost, ($@MK_AGGRO/10)+.nearby, "Monster King::OnSlaveDie");
        $@MK_AGGRO=$@MK_AGGRO/5;
    }

    // We're done, restart loop timer
    initnpctimer;
    end;
}