summaryrefslogblamecommitdiff
path: root/npc/functions/ghost.txt
blob: 4c3b825a94131da268c6e1f7af8f52905b5c5fa7 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

                                         
               











                                  

                 






                                                                                   


                                                                              
 
                                          
                                                                                 

           
function	script	SpawnGhost	{
    if ($GHOSTS_DISABLED)
        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 = getx();
    .@y = gety();

    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 - verify if ghost GID is still alive, maybe add it an event label
    if (@GHOST_GID)
        unitkill(@GHOST_GID);

    specialeffect(39, SELF, getcharid(3));
    @GHOST_GID = monster(getmapname(), .@x, .@y, strcharinfo(0), LesserGhost, 1);
    return;
}