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

    set .@x, POS_X;
    set .@y, POS_Y;

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

    if (@GHOST_MAP$ != "")
        killmonster @GHOST_MAP$, "~GH~" + getcharid(0);

    set @GHOST_MAP$, getmap();
    specialeffect2 39;
    monster getmap(), .@x, .@y, strcharinfo(0), 1136, 1, "~GH~" + getcharid(0);
    return;

L_Return:
    return;
}