diff options
-rw-r--r-- | npc/001-1/manhole.txt | 16 | ||||
-rw-r--r-- | npc/001-1/xilaxa.txt | 28 | ||||
-rw-r--r-- | npc/001-2-19/lloyd.txt | 4 | ||||
-rw-r--r-- | npc/001-2-4/books.txt | 6 | ||||
-rw-r--r-- | npc/008-1/confused-tree.txt | 2 | ||||
-rw-r--r-- | npc/commands/warp.txt | 5 | ||||
-rw-r--r-- | npc/functions/game-rules.txt | 6 | ||||
-rw-r--r-- | npc/functions/goodbye.txt | 138 | ||||
-rw-r--r-- | npc/functions/warp.txt | 47 | ||||
-rw-r--r-- | npc/scripts.conf | 1 |
10 files changed, 81 insertions, 172 deletions
diff --git a/npc/001-1/manhole.txt b/npc/001-1/manhole.txt index f2bae5f0..77616cf1 100644 --- a/npc/001-1/manhole.txt +++ b/npc/001-1/manhole.txt @@ -20,11 +20,9 @@ l("..."), l("Do you want to enter in sewer?")); - if (askyesno() == 1) { - cwarp("001-3-0", 152, 56); - } - - bye; + closeclientdialog(); + if (askyesno() == 1) slide_or_warp("001-3-0", 152, 56); + close; OnInit: .sex = G_OTHER; @@ -43,11 +41,9 @@ OnInit: l("..."), l("Do you want to enter in sewer?")); - if (askyesno() == 1) { - cwarp("001-3-0", 196, 36); - } - - bye; + closeclientdialog(); + if (askyesno() == 1) slide_or_warp("001-3-0", 196, 36); + close; OnInit: .sex = G_OTHER; diff --git a/npc/001-1/xilaxa.txt b/npc/001-1/xilaxa.txt index 5b7ec398..f6f1189c 100644 --- a/npc/001-1/xilaxa.txt +++ b/npc/001-1/xilaxa.txt @@ -6,28 +6,12 @@ 001-1,52,44,0 script Xilaxa#001-1 NPC_UKAR_MALE_LEGION_ARTIS,{ - function face_to_PC { - getmapxy(.@map$, .@cx, .@cy, 0); - @Devis_old_dir = .dir; - npc_turntoxy(.@cx, .@cy); - - return; - } - - function local_close { - if (@Devis_old_dir != .dir) - { - .dir = @Devis_old_dir; - } - npc_resumemove; - - close; - } - - npc_pausemove; - face_to_PC; - npctalkonce goodbye_msg(); - local_close; + npc_pausemove(); + getmapxy(.@map$, .@cx, .@cy, 0); + npc_turntoxy(.@cx, .@cy); + npctalkonce("Hello."); + npc_resumemove(); + close; OnTimer1000: dographmovestep; diff --git a/npc/001-2-19/lloyd.txt b/npc/001-2-19/lloyd.txt index 20381d92..9dfd97de 100644 --- a/npc/001-2-19/lloyd.txt +++ b/npc/001-2-19/lloyd.txt @@ -194,8 +194,8 @@ enora_quest; break; case 2: - openstorage; - closeclientdialog; + closeclientdialog(); + openstorage(); close; break; case 3: diff --git a/npc/001-2-4/books.txt b/npc/001-2-4/books.txt index e0932405..f4282f67 100644 --- a/npc/001-2-4/books.txt +++ b/npc/001-2-4/books.txt @@ -87,12 +87,14 @@ OnInit: OnShelfUse: if (openbookshelf()) read_book; - bye; + closeclientdialog(); + close; OnUse: if (openbook()) read_book; - bye; + closeclientdialog(); + close; OnInit: .book_name$ = getitemname(FishingGuideVolI); diff --git a/npc/008-1/confused-tree.txt b/npc/008-1/confused-tree.txt index 202fb53c..eab5ee79 100644 --- a/npc/008-1/confused-tree.txt +++ b/npc/008-1/confused-tree.txt @@ -703,7 +703,7 @@ OnClick: tree_panel(); - bye; + end; OnTalkNearby: diff --git a/npc/commands/warp.txt b/npc/commands/warp.txt index e64b87db..397e621b 100644 --- a/npc/commands/warp.txt +++ b/npc/commands/warp.txt @@ -26,7 +26,7 @@ OnCall: { if (.@request$ ~= .aliases$[.@i]) { - sscanf .aliases$[.@i + 1], "%s %d %d", .@map$, .@x, .@y; + sscanf(.aliases$[.@i + 1], "%s %d %d", .@map$, .@x, .@y); break; } } @@ -57,7 +57,8 @@ OnCall: ++.@e; } - cwarp .@map$, .@x, .@y; // XXX: maybe here use a slide_or_warp function + slide_or_warp(.@map$, .@x, .@y); + end; OnInit: setarray .aliases$[0], diff --git a/npc/functions/game-rules.txt b/npc/functions/game-rules.txt index f633ee5f..0a9f6569 100644 --- a/npc/functions/game-rules.txt +++ b/npc/functions/game-rules.txt @@ -46,12 +46,14 @@ OnCall: OnUseBook: if (openbook()) read_book; - bye; + closeclientdialog(); + close; OnShelfUse: if (openbookshelf()) read_book; - bye; + closeclientdialog(); + close; OnInit: .book_name$ = "The Book of Laws"; diff --git a/npc/functions/goodbye.txt b/npc/functions/goodbye.txt index 0e8dfc2e..6c8879c5 100644 --- a/npc/functions/goodbye.txt +++ b/npc/functions/goodbye.txt @@ -1,19 +1,13 @@ // Evol functions. // Authors: -// gumi // Reid -// Description: -// script terminator functions +// goodbye +// displays a canned message and quits -// goodbye_msg -// Tell a random goodbye sentence. -// Variables: -// .@rand = Random number between the number of "goodbye" choice. - -function script goodbye_msg { - setarray .byemsg$[0], +function script goodbye { + setarray(.@byemsg$[0], l("See you!"), l("See you later!"), l("See you soon!"), @@ -26,127 +20,9 @@ function script goodbye_msg { l("Talk to you later!"), l("Have a good day!"), l("Cheers!"), - l("Take care!"); - - return .byemsg$[rand(getarraysize(.byemsg$))]; -} - - - -// cwarp -// Closes the dialog, then warps the player. -// You almost always want to use this instead of `warp`. -// usage: -// cwarp; -// cwarp x, y; -// cwarp map, x, y; - -function script cwarp { - .@map$ = getarg(0, ""); - .@x = getarg(1, 0); - .@y = getarg(2, 0); - - if (getargcount() > 0 && getargcount() < 3) - { - .@npc$ = strnpcinfo(0); - .@map$ = getvariableofnpc(.map$, .@npc$); - .@x = getarg(0); - .@y = getarg(1); - } - - getmapxy .@pc_map$, .@pc_x, .@pc_y, UNITTYPE_PC; // get char location - - closeclientdialog; - - if (getargcount() < 1) - { - warp .@pc_map$, .@pc_x, .@pc_y; // no arguments, just refresh - close; - } + l("Take care!")); - if (.@map$ == .@pc_map$) - { - if (.@pc_x == .@x && .@pc_y == .@y) - { - close; // same location, don't move - } - - else - { - slide .@x, .@y; // same map, slide instead of full warp - close; - } - } - - warp .@map$, .@x, .@y; // different map, warp to given location + closeclientdialog(); + npctalkonce(.@byemsg$[rand(getarraysize(.@byemsg$))]); close; } - - - -// cshop -// closes the dialog, then opens a shop -// if no npc is given, calls "#<npc> $" - -function script cshop { - closeclientdialog; - shop getarg(0, "#" + strnpcinfo(0) + " $"); - //close; => the shop buildin already sends close, and is a terminator itself -} - - - -// cstorage -// closes the dialog, then opens storage - -function script cstorage { - closeclientdialog; - openstorage; - close; -} - - - -// bye -// closes the dialog without waiting for the player to press close -// can also display an emote - -function script bye { - .@emote = getarg(0, -1); - closeclientdialog; - - if (.@emote >= 0) - emotion .@emote; - - close; -} - - - -// goodbye -// same as bye, but also displays a canned message -// can also display an emote - -function script goodbye { - npctalkonce(goodbye_msg()); - bye getarg(0, -1); -} - - - -// goodbye2 -// Waits for the player to press close, displays a canned message, -// ends execution. -// Can also display an emote - -function script goodbye2 { - .@emote = getarg(0, -1); - - close2; - npctalkonce(goodbye_msg()); - - if (.@emote >= 0) - emotion .@emote; - - end; -} diff --git a/npc/functions/warp.txt b/npc/functions/warp.txt new file mode 100644 index 00000000..844baf7d --- /dev/null +++ b/npc/functions/warp.txt @@ -0,0 +1,47 @@ +// Evol functions. +// Authors: +// gumi + + +// slide_or_warp +// Slides the player instead of warping, when possible. +// usage: +// slide_or_warp({<aid>}); +// slide_or_warp(<x>, <y>{, <aid>}); +// slide_or_warp("<map>", <x>, <y>{, <aid>}); + +function script slide_or_warp { + if (getargcount() <= 1) { + .@aid = getarg(1, 0); + } else { + if (getargcount() >= 3 && getdatatype(getarg(0)) & DATATYPE_STR) { + .@map$ = getarg(0); + .@x = getarg(1); + .@y = getarg(2); + .@aid = getarg(3, 0); + } else { + .@x = getarg(0); + .@y = getarg(1); + .@aid = getarg(2, 0); + } + } + + if (!isloggedin(.@aid)) { + if (.@aid = playerattached() == 0) { + debugmes("slide_or_warp: no player attached!"); + return false; + } + } + + getmapxy(.@pc_map$, .@pc_x, .@pc_y, UNITTYPE_PC, .@aid); // get char location + + if (getargcount() < 1) { + warpchar(.@pc_map$, .@pc_x, .@pc_y, .@aid); // no arguments, just refresh + } else if (.@map$ == .@pc_map$ && (.@pc_x != .@x || .@pc_y != .@y)) { + slide(.@x, .@y); // same map, slide instead of full warp + // FIXME: make slide take GID as optional arg + } else { + warpchar(.@map$, .@x, .@y, .@aid); // different map, warp to given location + } + return true; +} diff --git a/npc/scripts.conf b/npc/scripts.conf index 83fb0348..3bb929a9 100644 --- a/npc/scripts.conf +++ b/npc/scripts.conf @@ -11,6 +11,7 @@ "npc/functions/string.txt", "npc/functions/RNGesus.txt", "npc/functions/math.txt", +"npc/functions/warp.txt", // Misc functions "npc/functions/main.txt", |