diff options
author | FlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-11-22 16:06:39 +0000 |
---|---|---|
committer | FlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-11-22 16:06:39 +0000 |
commit | e2ddbced3c35ca2d1c704c2b724234cc09a37418 (patch) | |
tree | 5c372ac886a2f4617939f36123e9a9f75176b5f7 /src/map/script.c | |
parent | bd953cebb864185e3f7f8ff5591ad02270bd19f0 (diff) | |
download | hercules-e2ddbced3c35ca2d1c704c2b724234cc09a37418.tar.gz hercules-e2ddbced3c35ca2d1c704c2b724234cc09a37418.tar.bz2 hercules-e2ddbced3c35ca2d1c704c2b724234cc09a37418.tar.xz hercules-e2ddbced3c35ca2d1c704c2b724234cc09a37418.zip |
* Renamed fakenpcname to setnpcdisplay, fixed and extended it.
- See doc/script_commands.txt for information on how to use it
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11779 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 60 |
1 files changed, 48 insertions, 12 deletions
diff --git a/src/map/script.c b/src/map/script.c index ff10c853a..14302250a 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -11391,20 +11391,56 @@ BUILDIN_FUNC(charisalpha) return 0; } -// [Lance] -BUILDIN_FUNC(fakenpcname) +/// Changes the display name and/or display class of the npc. +/// Returns 0 is successful, 1 if the npc does not exist. +/// +/// setnpcdisplay("<npc name>", "<new display name>", <new class id>) -> <int> +/// setnpcdisplay("<npc name>", "<new display name>") -> <int> +/// setnpcdisplay("<npc name>", <new class id>) -> <int> +BUILDIN_FUNC(setnpcdisplay) { - const char *name; - const char *newname; - int look; + const char* name; + const char* newname = NULL; + int class_ = -1; + struct script_data* data; + struct npc_data* nd; + name = script_getstr(st,2); - newname = script_getstr(st,3); - look = script_getnum(st,4); - if(look > 32767 || look < -32768) { - ShowError("buildin_fakenpcname: Invalid look value %d\n",look); - return 1; // Safety measure to prevent runtime errors + data = script_getdata(st,3); + get_val(st, data); + if( script_hasdata(st,4) ) + { + newname = conv_str(st,data); + class_ = script_getnum(st,4); } - npc_changename(name,newname,(short)look); + else if( data_isstring(data) ) + { + newname = conv_str(st,data); + } + else if( data_isint(data) ) + { + class_ = conv_num(st,data); + } + else + { + ShowError("script:setnpcdisplay: expected a string or number\n"); + script_reportdata(data); + return 1; + } + + nd = npc_name2id(name); + if( nd == NULL ) + {// not found + script_pushint(st,1); + return 0; + } + + // update npc + if( newname ) + npc_setdisplayname(nd, newname); + if( class_ != -1 ) + npc_setclass(nd, class_); + script_pushint(st,0); return 0; } @@ -13042,7 +13078,7 @@ struct script_function buildin_func[] = { BUILDIN_DEF(unequip,"i"), // unequip command [Spectre] BUILDIN_DEF(getstrlen,"s"), //strlen [Valaris] BUILDIN_DEF(charisalpha,"si"), //isalpha [Valaris] - BUILDIN_DEF(fakenpcname,"ssi"), // [Lance] + BUILDIN_DEF(setnpcdisplay,"sv?"), BUILDIN_DEF(compare,"ss"), // Lordalfa - To bring strstr to scripting Engine. BUILDIN_DEF(getiteminfo,"ii"), //[Lupus] returns Items Buy / sell Price, etc info BUILDIN_DEF(setiteminfo,"iii"), //[Lupus] set Items Buy / sell Price, etc info |