summaryrefslogtreecommitdiff
path: root/npc/042-6/ctrl.txt
blob: bdb22c20aad0be8513fbde1f06f93701793857b6 (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
// TMW 2 Script
// Author:
//  Jesusalva
//  Micksha
// Description:
//  Controls sewers.
//  FIXME: The warps back should only work if treasure was found
//  Spawn monsters and respawns them.

// A simple random treasure chest - to be sure players were introduced to this
// awesome system. Same rules as any treasure box still applies.
042-6,65,89,0	script	#chest_0426	NPC_CHEST,{
    function monster0426;
	KamelotTreasure(8);
	specialeffect(.dir == 0 ? 24 : 25, AREA, getnpcid()); // closed ? opening : closing
	close;

OnInit:
	.distance = 2;
	end;

OnInstanceInit:
    // Yes, we just hope it works out of box
    explode(.@map$, .map$, "@");
    .@g=atoi(.@map$[1]);
    if (.@g < 1) {
        debugmes "[ERROR] [KAMELOT] Unable to spawn for Kamelot %s", .map$;
        debugmes "[ERROR] [KAMELOT] Using dummy data (returned: %d)", .@g;
        .@g=0;
    }
    debugmes "Spawning monsters for guild %d", .@g;
    .@mx=getguildavg(.@g);

    // Corritors
    monster0426(2, 21, 75,  50,  85, .@mx);
    monster0426(7, 45, 45,  74,  80, .@mx);
    monster0426(5, 52, 21,  90,  60, .@mx);
    monster0426(3, 54, 28,  82,  39, .@mx);

    // Boss Chamber
    monster0426(5, 59, 71, 82, 91, .@mx);
    KamelotBoss("042-6", 74, 80, .@mx+1, .name$);

    // Boss monster
    // TODO

    // Neutral monsters
    areamonster(.map$, 20, 20, 90, 90, strmobinfo(1, YellowSlime), YellowSlime, 5);
    areamonster(.map$, 20, 20, 90, 90, strmobinfo(1, ManaGhost), ManaGhost, max(1, .@mx/10));
    areamonster(.map$, 20, 20, 90, 90, strmobinfo(1, CaveMaggot), CaveMaggot, 30);

    // Bonus monsters
    if (!rand2(2))
        areamonster(.map$, 45, 20, 90, 90, strmobinfo(1, MagicBif), MagicBif, 2);
    if (!rand2(2))
        areamonster(.map$, 20, 20, 90, 90, strmobinfo(1, SilverChest), GoldenChest, 1);
    if (!rand2(2))
        areamonster(.map$, 20, 20, 90, 90, strmobinfo(1, SilverChest), SilverChest, 2);
    if (!rand2(2))
        areamonster(.map$, 20, 20, 90, 90, strmobinfo(1, BronzeChest), BronzeChest, 3);
    end;

OnKillMob:
    if (!playerattached())
        goto OnRespawn;
    // Maybe a reward is due
    .@g=getcharid(2);
    if (.@g < 1) percentheal -100, -100;
    getexp $KAMELOT_MX[.@g]*7, $KAMELOT_MX[.@g]*4;
    .@delay=max(3000, 21000-$KAMELOT_PC[.@g]*1000);
    // FALLTHROUGH

OnRespawn:
    .@delay=(.@delay ? .@delay : 3000);
    sleep(.@delay);
    // Yes, we just hope it works out of box
    explode(.@map$, .map$, "@");
    .@g=atoi(.@map$[1]);
    if (.@g < 1) {
        debugmes "[ERROR] [KAMELOT] Unable to respawn for Kamelot %s", .map$;
        .@g=0;
    }
    monster0426(1, 20, 20, 115, 100, $KAMELOT_MX[.@g]);
    end;

function monster0426 {
    .@label$=instance_npcname(.name$)+"::OnKillMob";
    .@gcount=getarg(0);
    .@x1=getarg(1);
    .@y1=getarg(2);
    .@x2=getarg(3);
    .@y2=getarg(4);
    .@avg=getarg(5);
    .@m$=instance_mapname("042-6");
    //debugmes "Total %d, map %s (power %d)", .@gcount, .@m$, .@avg;
    freeloop(true);
    for (.@i=0; .@i < .@gcount; .@i++) {
        .@mobId=any(CursedSoldier, CursedArcher); // 50-50 ratio
        .@mob=areamonster(.@m$, .@x1, .@y1, .@x2, .@y2, strmobinfo(1, .@mobId), .@mobId, 1, .@label$);
        // Reconfigure the monster
        setunitdata(.@mob, UDT_LEVEL, .@avg+1);
        setunitdata(.@mob, UDT_STR, 1+.@avg*6/10);
        setunitdata(.@mob, UDT_AGI, 1+.@avg*5/10);
        setunitdata(.@mob, UDT_VIT, 1+.@avg*5/10);
        setunitdata(.@mob, UDT_INT, 1+.@avg*6/10);
        setunitdata(.@mob, UDT_DEX, 1+.@avg*6/10);
        setunitdata(.@mob, UDT_LUK, 1+.@avg*5/10);
        setunitdata(.@mob, UDT_ADELAY, 1372);
        setunitdata(.@mob, UDT_ATKRANGE, (.@mobId == CursedArcher ? any(6,7) : any(1,2)));
        // Battle Status
        setunitdata(.@mob, UDT_MAXHP,    .@avg*40);
        setunitdata(.@mob, UDT_HP,       .@avg*40);
        setunitdata(.@mob, UDT_ATKMIN,   .@avg*52/10);
        setunitdata(.@mob, UDT_ATKMAX,   .@avg*72/10);
        setunitdata(.@mob, UDT_DEF,      1+.@avg*12/10);
        setunitdata(.@mob, UDT_MDEF,     1+.@avg*8/10);
        setunitdata(.@mob, UDT_HIT,      .@avg*6); // Advised: x3
        setunitdata(.@mob, UDT_FLEE,     .@avg*45/10); // Advised: x4
        // Critical calculation
        .@min=15;
        .@max=max(.@min, min(40, .@avg/3));
        setunitdata(.@mob, UDT_CRIT,     rand2(.@min, .@max));
        // Loop through
    }
    freeloop(false);
    return;
    }

}