diff options
Diffstat (limited to 'npc/functions')
-rw-r--r-- | npc/functions/doors.txt | 7 | ||||
-rw-r--r-- | npc/functions/game-rules.txt | 6 | ||||
-rw-r--r-- | npc/functions/goodbye.txt | 138 | ||||
-rw-r--r-- | npc/functions/openbook.txt | 18 | ||||
-rw-r--r-- | npc/functions/shops.txt | 11 | ||||
-rw-r--r-- | npc/functions/warp.txt | 48 |
6 files changed, 82 insertions, 146 deletions
diff --git a/npc/functions/doors.txt b/npc/functions/doors.txt index c1b6565e..4cca24e3 100644 --- a/npc/functions/doors.txt +++ b/npc/functions/doors.txt @@ -7,6 +7,10 @@ // none function script doorTouch { + getmapxy(.@pc_map$, .@pc_x, .@pc_y, UNITTYPE_PC); // get char location + if (.@pc_y < .y) + end; + if (getareausers() <= 1) { .dir = 2; @@ -17,6 +21,9 @@ function script doorTouch { } function script doorUnTouch { + if (.dir != 2 && .dir != 6) + end; + if (getareausers(.map$) == 0) { .dir = 4; 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/openbook.txt b/npc/functions/openbook.txt index 0278415c..cb1a0b11 100644 --- a/npc/functions/openbook.txt +++ b/npc/functions/openbook.txt @@ -3,26 +3,24 @@ // Reid // Description: // Narrator dialogue to show the selected book. -// Variables: -// @book_name$ = The name of the book to read. function script openbook { - .@book_name$ = "\"" + l(getarg(0, getvariableofnpc(.book_name$, strnpcinfo(0)))) + "\""; + .@book_name$ = getarg(0, getvariableofnpc(.book_name$, strnpcinfo(0))); - narrator S_LAST_NEXT, - l("You open a book named @@.", .@book_name$), - l("Do you want to read it?"); + narrator(S_LAST_NEXT, + l("You open a book named \"%s\".", .@book_name$), + l("Do you want to read it?")); return (select("Yes.", "No.") == 1); } function script openbookshelf { - .@book_name$ = "\"" + l(getarg(0, getvariableofnpc(.book_name$, strnpcinfo(0)))) + "\""; + .@book_name$ = getarg(0, getvariableofnpc(.book_name$, strnpcinfo(0))); - narrator S_LAST_NEXT, + narrator(S_LAST_NEXT, l("You see a dust covered book on the shelf..."), - l("The name of the book is @@.", .@book_name$), - l("Do you want to read it?"); + l("The name of the book is \"%s\".", .@book_name$), + l("Do you want to read it?")); return (select("Yes.", "No.") == 1); } diff --git a/npc/functions/shops.txt b/npc/functions/shops.txt index 79890e81..8962997e 100644 --- a/npc/functions/shops.txt +++ b/npc/functions/shops.txt @@ -1,13 +1,18 @@ // Evol functions. // Author: // 4144 +// Jesusalva // Description: // Shops utility functions -// Variables: -// none + + + +// restoreshopitem(<item nameid>, <amount>{, <price>}) +// adds back an item to the sell list if less than the specified amount +// returns true function script restoreshopitem { if (shopcount(getarg(0)) < getarg(1)) - sellitem getarg(0), -1, getarg(1); + sellitem(getarg(0), getarg(2, -1), getarg(1)); return; } diff --git a/npc/functions/warp.txt b/npc/functions/warp.txt new file mode 100644 index 00000000..dd09d713 --- /dev/null +++ b/npc/functions/warp.txt @@ -0,0 +1,48 @@ +// 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 + .@cid = getcharid(CHAR_ID_CHAR, strcharinfo(PC_NAME, .@aid)); // FIXME: [Hercules] make it so you can pass account id directly to getcharid + + if (getargcount() < 1) { + warpchar(.@pc_map$, .@pc_x, .@pc_y, .@cid); // 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, .@cid); // different map, warp to given location + } + return true; +} |