viewing paste Walkable and talkable NPC | Athena

Posted on the | Last edited on
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
// http://rathena.org/board/topic/74196-walkable-and-talkable-npc/
 
<header>,{
    function    Talk;
    end;
    
OnInit:
    // Talk("Your message");
    Talk("I'm talking.");
    Talk("Hello!");
    set .@interval, 5;
    set .@step, 5;
    while(1) {
        sleep .@interval*1000;
        getmapxy(.@m$,.@x,.@y,1);
        while (checkcell(.@m$, set(.@wx, .@x+(rand(-.@step,.@step))), set(.@wy, .@y+(rand(-.@step,.@step))), cell_walkable));
        npcwalkto .@wx, .@wy;
        npctalk Talk(); // Randomly returns a message
    }
    end;
    
    function    Talk    {
        if (!getstrlen(getarg(0,"")))
            return .talk$[rand(getarraysize(.talk$))];
        set .talk$[getarraysize(.talk$)], getarg(0);
        return;
    }
}
Viewed 814 times, submitted by jtkay.