diff options
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 77 |
1 files changed, 68 insertions, 9 deletions
diff --git a/src/map/script.c b/src/map/script.c index 30af4d0f7..cbbf306d1 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -62,6 +62,7 @@ #endif struct script_interface script_s; +struct script_interface *script; static inline int GETVALUE(const unsigned char* buf, int i) { return (int)MakeDWord(MakeWord(buf[i], buf[i+1]), MakeWord(buf[i+2], 0)); @@ -4035,7 +4036,7 @@ int run_func(struct script_state *st) /*========================================== * script execution *------------------------------------------*/ -void run_script(struct script_code *rootscript,int pos,int rid,int oid) { +void run_script(struct script_code *rootscript, int pos, int rid, int oid) { struct script_state *st; if( rootscript == NULL || pos < 0 ) @@ -5763,6 +5764,7 @@ BUILDIN(warp) { int ret; int x,y; + int warp_clean = 1; const char* str; TBL_PC* sd; @@ -5774,6 +5776,11 @@ BUILDIN(warp) x = script_getnum(st,3); y = script_getnum(st,4); + if (script_hasdata(st, 5)) { + warp_clean = script_getnum(st, 5); + } + + sd->state.warp_clean = warp_clean; if(strcmp(str,"Random")==0) ret = pc->randomwarp(sd,CLR_TELEPORT); else if(strcmp(str,"SavePoint")==0 || strcmp(str,"Save")==0) @@ -10447,7 +10454,7 @@ BUILDIN(itemeffect) { } } - script->run( item_data->script, 0, sd->bl.id, nd->bl.id ); + script->run_use_script(sd, item_data, nd->bl.id); return true; } @@ -18259,22 +18266,22 @@ BUILDIN(getcharip) { } /* check for sd and IP */ - if (!sd || !session[sd->fd]->client_addr) + if (!sd || !sockt->session[sd->fd]->client_addr) { script_pushconststr(st, ""); return true; } /* return the client ip_addr converted for output */ - if (sd && sd->fd && session[sd->fd]) + if (sd && sd->fd && sockt->session[sd->fd]) { /* initiliaze */ const char *ip_addr = NULL; uint32 ip; /* set ip, ip_addr and convert to ip and push str */ - ip = session[sd->fd]->client_addr; - ip_addr = ip2str(ip, NULL); + ip = sockt->session[sd->fd]->client_addr; + ip_addr = sockt->ip2str(ip, NULL); script_pushstrcopy(st, ip_addr); } @@ -19828,6 +19835,54 @@ bool script_hp_add(char *name, char *args, bool (*func)(struct script_state *st) return script->add_builtin(&buildin, true); } +void script_run_use_script(struct map_session_data *sd, struct item_data *data, int oid) __attribute__((nonnull (1))); + +/** + * Run use script for item. + * + * @param sd player session data. Must be correct and checked before. + * @param n item index in inventory. Must be correct and checked before. + * @param oid npc id. Can be also 0 or fake npc id. + */ +void script_run_use_script(struct map_session_data *sd, struct item_data *data, int oid) +{ + script->current_item_id = data->nameid; + script->run(data->script, 0, sd->bl.id, oid); + script->current_item_id = 0; +} + +void script_run_item_equip_script(struct map_session_data *sd, struct item_data *data, int oid) __attribute__((nonnull (1, 2))); + +/** + * Run item equip script for item. + * + * @param sd player session data. Must be correct and checked before. + * @param data equipped item data. Must be correct and checked before. + * @param oid npc id. Can be also 0 or fake npc id. + */ +void script_run_item_equip_script(struct map_session_data *sd, struct item_data *data, int oid) +{ + script->current_item_id = data->nameid; + script->run(data->equip_script, 0, sd->bl.id, oid); + script->current_item_id = 0; +} + +void script_run_item_unequip_script(struct map_session_data *sd, struct item_data *data, int oid) __attribute__((nonnull (1, 2))); + +/** + * Run item unequip script for item. + * + * @param sd player session data. Must be correct and checked before. + * @param data unequipped item data. Must be correct and checked before. + * @param oid npc id. Can be also 0 or fake npc id. + */ +void script_run_item_unequip_script(struct map_session_data *sd, struct item_data *data, int oid) +{ + script->current_item_id = data->nameid; + script->run(data->unequip_script, 0, sd->bl.id, oid); + script->current_item_id = 0; +} + #define BUILDIN_DEF(x,args) { buildin_ ## x , #x , args, false } #define BUILDIN_DEF2(x,x2,args) { buildin_ ## x , x2 , args, false } #define BUILDIN_DEF_DEPRECATED(x,args) { buildin_ ## x , #x , args, true } @@ -19855,7 +19910,7 @@ void script_parse_builtin(void) { BUILDIN_DEF(jobchange,"i?"), BUILDIN_DEF(jobname,"i"), BUILDIN_DEF(input,"r??"), - BUILDIN_DEF(warp,"sii"), + BUILDIN_DEF(warp,"sii?"), BUILDIN_DEF(areawarp,"siiiisii??"), BUILDIN_DEF(warpchar,"siii"), // [LuzZza] BUILDIN_DEF(warpparty,"siii?"), // [Fredzilla] [Paradox924X] @@ -20271,7 +20326,6 @@ void script_parse_builtin(void) { BUILDIN_DEF(makerune,"i"), BUILDIN_DEF(hascashmount,""),//[Ind] BUILDIN_DEF(setcashmount,""),//[Ind] - BUILDIN_DEF_DEPRECATED(checkre,"i"), // Deprecated 2015-05-08 [Haru] /** * rAthena and beyond! **/ @@ -20608,6 +20662,8 @@ void script_defaults(void) { script->get_constant = script_get_constant; script->label_add = script_label_add; script->run = run_script; + script->run_npc = run_script; + script->run_pet = run_script; script->run_main = run_script_main; script->run_timer = run_script_timer; script->set_var = set_var; @@ -20773,5 +20829,8 @@ void script_defaults(void) { script->add_language = script_add_language; script->get_translation_file_name = script_get_translation_file_name; script->parser_clean_leftovers = script_parser_clean_leftovers; - + + script->run_use_script = script_run_use_script; + script->run_item_equip_script = script_run_item_equip_script; + script->run_item_unequip_script = script_run_item_unequip_script; } |