summaryrefslogtreecommitdiff
path: root/npc/042-3/jail.txt
blob: f13ad14f57a6bf7041e49c56d2a53d212dece1c4 (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
135
136
137
138
139
140
141
// TMW 2 Script
// Author:
//  Jesusalva
//  Micksha
// Description:
//  Controls jails and lockpicks
// TODO: Spawn slime as players are warped, so they always have the chance
// TODO: Stationary guards outside the cells (can be spawn with player)
// We can set their speed to nil, after all. Make them all archers :3

042-3,0,0,0	script	#KSlimeSpawn	NPC_HIDDEN,{
    end;

OnKillSlime:
    .@label$=instance_npcname(.name$)+"::OnKillSlime";
    if (!playerattached()) {
        debugmes "[ERROR] Player not Attached on Slime Death D:";
        debugmes "[ERROR] Cannot retrieve coordinates!!";
    }
    if (@lockpicks)
        end;
    if (rand2(10000) > 1000) {
        goto OnFirstSlime;
    }
    @lockpicks=true;
    getitem Lockpicks, 1;
    getitem TreasureKey, 1;
    end;

OnFirstSlime:
    if (!playerattached()) {
        debugmes "[ERROR] Player not Attached on Slime Spawn D:";
        debugmes "[ERROR] Cannot retrieve coordinates!!";
    }
    getmapxy(.@m$, .@x, .@y, 0);
    sleep2(1800);
    .@mob=monster(.@m$, .@x, .@y, strmobinfo(1, CopperSlime), CopperSlime, 1, .@label$);
    // This should wipe the monster experience value
    setunitdata(.@mob, UDT_LEVEL, 1);
    end;


// Spawn Siege Towers
OnInstanceInit:
    .@m$=instance_mapname("042-3");
    debugmes "Kamelot Init: Original %s Target %s", .map$, .@m$; // Fun fact
    monster(.@m$, 89, 133, strmobinfo(1, SiegeTower), SiegeTower, 1);
    monster(.@m$, 67, 114, strmobinfo(1, SiegeTower), SiegeTower, 1);
    monster(.@m$, 30, 121, strmobinfo(1, SiegeTower), SiegeTower, 1);
    monster(.@m$, 23, 137, strmobinfo(1, SiegeTower), SiegeTower, 1);
    monster(.@m$, 29, 103, strmobinfo(1, SiegeTower), SiegeTower, 1);
    monster(.@m$, 61, 91, strmobinfo(1, SiegeTower), SiegeTower, 1);
    monster(.@m$, 75, 69, strmobinfo(1, SiegeTower), SiegeTower, 1);
    monster(.@m$, 34, 72, strmobinfo(1, SiegeTower), SiegeTower, 1);
    monster(.@m$, 60, 59, strmobinfo(1, SiegeTower), SiegeTower, 1);
    monster(.@m$, 87, 32, strmobinfo(1, SiegeTower), SiegeTower, 1);
    monster(.@m$, 47, 32, strmobinfo(1, SiegeTower), SiegeTower, 1);
    monster(.@m$, 31, 35, strmobinfo(1, SiegeTower), SiegeTower, 1);
    end;
}

// Lockpicks functions
function	script	KamelotLockpick	{
    // Args: x, y, name. Needs player attached
    .@x=getarg(0);
    .@y=getarg(1);
    .@name$=getarg(2);
    mes l("A complex lock seems to be posing a threat to you.");
    next;
    mes l("But thanks to your %s skills, maybe you can pry this open.", thiefrank());
    next;

    .@s=LockPicking(5, 3, false);

    // You broke free!
    if (.@s) {
        .@label$=instance_npcname(.@name$)+"::OnKamelotSlide";
        addtimer 10, .@label$;
        areatimer getmap(), .@x-1, .@y-1, .@x+1, .@y, 10, .@label$;
        return;
    }
    mes l("What's this dark magic, the password has changed!");
    .@label$=instance_npcname("#KSlimeSpawn")+"::OnKillSlime";

    // Give player a easy way to get lockpicks for this
    // (Overrides original .@x/.@y variables)
    if (countitem(Lockpicks) <= 1) {
        @lockpicks=false;
        getmapxy(.@m$, .@x, .@y, 0);
        .@mob=monster(.@m$, .@x, .@y, strmobinfo(1, CopperSlime), CopperSlime, 1, .@label$);
        // This should wipe the monster experience value
        setunitdata(.@mob, UDT_LEVEL, 1);
    }
    return;
}

// Cell Doors
042-3,33,137,0	script	Cell Door#K01	NPC_NO_SPRITE,{
    KamelotLockpick(.x, .y, .name$);
    close;
OnInit:
OnInstanceInit:
    .distance=2;
    end;

OnKamelotSlide:
    .@label$=instance_npcname(.name$)+"::OnKamelotSlide";
    deltimer .@label$;
    dispbottom l("You're finally free!");
    slide .x, .y+1;
    @lockpicks=true;
    end;
}

// Duplication of doors
042-3,84,129,0	duplicate(Cell Door#K01)	Cell Door#K02	NPC_NO_SPRITE
042-3,41,121,0	duplicate(Cell Door#K01)	Cell Door#K03	NPC_NO_SPRITE
042-3,74,109,0	duplicate(Cell Door#K01)	Cell Door#K04	NPC_NO_SPRITE
042-3,36,98,0	duplicate(Cell Door#K01)	Cell Door#K05	NPC_NO_SPRITE
042-3,57,86,0	duplicate(Cell Door#K01)	Cell Door#K06	NPC_NO_SPRITE
042-3,79,65,0	duplicate(Cell Door#K01)	Cell Door#K07	NPC_NO_SPRITE
042-3,43,69,0	duplicate(Cell Door#K01)	Cell Door#K08	NPC_NO_SPRITE
042-3,24,69,0	duplicate(Cell Door#K01)	Cell Door#K09	NPC_NO_SPRITE
042-3,86,24,0	duplicate(Cell Door#K01)	Cell Door#K10	NPC_NO_SPRITE
042-3,59,51,0	duplicate(Cell Door#K01)	Cell Door#K11	NPC_NO_SPRITE
042-3,38,29,0	duplicate(Cell Door#K01)	Cell Door#K12	NPC_NO_SPRITE




// Required exit. This one has no conditions, so it is not really required
// But I do not trust Instancing System, so better safe than sorry!
042-3,58,140,0	script	#KDoor0423B	NPC_HIDDEN,0,0,{
    end;

OnTouch:
    .@g=getcharid(2);
    warp "042-2@"+.@g, 41, 23;
    end;
}