summaryrefslogtreecommitdiff
path: root/npc/functions/ghost.txt
blob: 1325525b5ac51e81773e2142c739f58c61fa0cad (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
function	script	SpawnGhost	{
    if ($GHOSTS_DISABLED)
        goto L_Return;

    if (BaseLevel >= 40 &&
       (getmapname() == "026-1" ||
        getmapname() == "027-1" ||
        getmapname() == "027-2" ||
        getmapname() == "027-3" ||
        getmapname() == "027-4" ||
        getmapname() == "027-5"))
        goto L_Spawn;
    return;

L_Spawn:
    .@x = POS_X;
    .@y = POS_Y;

    if   (!(iscollision(getmapname(), .@x, .@y - 1))) set .@y, .@y - 1; // up
    else if (!(iscollision(getmapname(), .@x, .@y + 1))) set .@y, .@y + 1; // down
    else if (!(iscollision(getmapname(), .@x - 1, .@y))) set .@x, .@x - 1; // left
    else if (!(iscollision(getmapname(), .@x + 1, .@y))) set .@x, .@x + 1; // right
    // else on the player

    // FIXME (Is this a valid event label??)
    if (@GHOST_MAP$ != "")
        killmonster @GHOST_MAP$, "~GH~" + getcharid(0);

    @GHOST_MAP$ = getmapname();
    specialeffect(39, SELF, getcharid(3));
    monster getmapname(), .@x, .@y, strcharinfo(0), 1136, 1, "~GH~" + getcharid(0);
    return;

L_Return:
    return;
}