diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-05-05 00:20:01 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-05-05 00:20:46 +0300 |
commit | 45eeb456802331db4756fe5acf4a1cb13477fcec (patch) | |
tree | 8ecf7466f5212889fb4c16b5248324f3339b822a | |
parent | 479aac0b2e30c7bbc07870696658c1fda1efbb9d (diff) | |
download | serverdata-45eeb456802331db4756fe5acf4a1cb13477fcec.tar.gz serverdata-45eeb456802331db4756fe5acf4a1cb13477fcec.tar.bz2 serverdata-45eeb456802331db4756fe5acf4a1cb13477fcec.tar.xz serverdata-45eeb456802331db4756fe5acf4a1cb13477fcec.zip |
Add into npc moving program new commands: rmove, emote, warp, class, goto.
Also some commands here not waiting next tick for continue execution.
-rw-r--r-- | npc/functions/npcmove.txt | 50 | ||||
-rw-r--r-- | npc/test/npc4.txt | 11 |
2 files changed, 51 insertions, 10 deletions
diff --git a/npc/functions/npcmove.txt b/npc/functions/npcmove.txt index 783539a9..346549fc 100644 --- a/npc/functions/npcmove.txt +++ b/npc/functions/npcmove.txt @@ -39,17 +39,40 @@ function script domoveaction { else if (.@cmd$ == "dir") { setnpcdir getvariableofnpc(.movepathx[.@pos], strnpcinfo(3)); + return 2; } else if (.@cmd$ == "wait") { set getvariableofnpc(.waitticks, strnpcinfo(3)), getvariableofnpc(.movepathx[.@pos], strnpcinfo(3)); } + else if (.@cmd$ == "emote") + { + unitemote getnpcid(0), getvariableofnpc(.movepathx[.@pos], strnpcinfo(3)); + return 2; + } + else if (.@cmd$ == "class") + { + setnpcdisplay strnpcinfo(3), getvariableofnpc(.movepathx[.@pos], strnpcinfo(3)); + return 2; + } + else if (.@cmd$ == "warp") + { + movenpc strnpcinfo(3), getvariableofnpc(.movepathx[.@pos], strnpcinfo(3)), getvariableofnpc(.movepathy[.@pos], strnpcinfo(3)); + } + else if (.@cmd$ == "goto") + { + set getvariableofnpc(.movepos, strnpcinfo(3)), getvariableofnpc(.movepathx[.@pos], strnpcinfo(3)); + return 0; + } + else if (.@cmd$ == "rmove") + { + getmapxy(.@mapName$, .@x, .@y, 1); + npcwalkto .@x + getvariableofnpc(.movepathx[.@pos], strnpcinfo(3)), .@y + getvariableofnpc(.movepathy[.@pos], strnpcinfo(3)); + } return 1; } function script movetonextpos { - .@pos = getvariableofnpc(.movepos, strnpcinfo(3)); - //debugmes "movetonextpos: " + str(.@pos); .@wait = getvariableofnpc(.waitticks, strnpcinfo(3)); if (.@wait > 0) { @@ -58,13 +81,24 @@ function script movetonextpos { set getvariableofnpc(.waitticks, strnpcinfo(3)), .@wait; return; } - .@res = domoveaction(.@pos); - if (.@res) + .@true = 1; + while (.@true) { - .@pos++; - if (.@pos >= getarraysize(getvariableofnpc(.movepathx, strnpcinfo(3)))) - .@pos = 0; - set getvariableofnpc(.movepos, strnpcinfo(3)), .@pos; + .@true = 0; + .@pos = getvariableofnpc(.movepos, strnpcinfo(3)); + //debugmes "movetonextpos: " + str(.@pos); + .@res = domoveaction(.@pos); + if (.@res == 1 || .@res == 2) + { + .@pos++; + if (.@pos >= getarraysize(getvariableofnpc(.movepathx, strnpcinfo(3)))) + .@pos = 0; + set getvariableofnpc(.movepos, strnpcinfo(3)), .@pos; + } + if (.@res == 0 || .@res == 2) + { + .@true = 1; + } } return; } diff --git a/npc/test/npc4.txt b/npc/test/npc4.txt index 78103667..4d54532b 100644 --- a/npc/test/npc4.txt +++ b/npc/test/npc4.txt @@ -19,8 +19,15 @@ OnInit: initpath "move", 20, 20, "dir", 6, 0, "move", 25, 20, - "wait", 3, 0, - "move", 22, 10; + "emote", 3, 0, + "class", 104, 0, + "wait", 2, 0, + "move", 22, 10, + "rmove", 3, 3, + "class", 801, 0, + "wait", 1, 0, + "warp", 22, 30, + "goto", 0, 0; initialmove; initnpctimer; } |