diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index ef12276c7d..c3e1b4c2ca 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,11 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2006/06/23 + * [Optimized]: + - Setting of variables with defined scope in some frequently executed script + events. + [Added]: + - Missing script_require_trigger flags for some power hungry events. * Updated mob_db.sql and item_db.sql to latest. [Skotlex] * Modified pc_setoption so that it will correctly update sprite AND clothes color when mounting/unmounting changing into/from xmas/wedding sprites. diff --git a/src/map/clif.c b/src/map/clif.c index 324994d697..9994de65ed 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -8231,7 +8231,10 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) sc_start(&sd->bl,SC_NOCHAT,100,0,0); // Lance - npc_script_event(sd, NPCE_LOADMAP); + if(sd->state.event_loadmap){ + pc_setregstr(sd, add_str("@maploaded$"), map[sd->bl.m].name); + npc_script_event(sd, NPCE_LOADMAP); + } if (pc_checkskill(sd, SG_DEVIL) && !pc_nextjobexp(sd)) clif_status_load(&sd->bl, SI_DEVIL, 1); //blindness [Komurka] @@ -9273,10 +9276,12 @@ void clif_parse_NpcBuyListSend(int fd,struct map_session_data *sd) fail = 1; else{ if((nd = ((struct npc_data *)map_id2bl(sd->npc_shopid))->master_nd)){ + int regkey = add_str("@bought_nameid"); + int regkey2 = add_str("@bought_quantity"); sprintf(npc_ev, "%s::OnBuyItem", nd->exname); for(i=0;ind, 0); + // ------------------------------------------- if(md->callback_flag&action_type){ - setd_sub(NULL, NULL, ".ai_action", 0, (void *)(int)action_type, &md->nd->u.scr.script->script_vars); + int regkey = add_str(".ai_action"); + linkdb_replace(&md->nd->u.scr.script->script_vars,(void *)regkey, (void *)(int)action_type); if(target){ - setd_sub(NULL, NULL, ".ai_action", 1, (void *)(int)target->type, &md->nd->u.scr.script->script_vars); - setd_sub(NULL, NULL, ".ai_action", 2, (void *)target->id, &md->nd->u.scr.script->script_vars); + linkdb_replace(&md->nd->u.scr.script->script_vars,(void *)(regkey+(1<<24)), (void *)(int)target->type); + linkdb_replace(&md->nd->u.scr.script->script_vars,(void *)(regkey+(2<<24)), (void *)target->id); } - setd_sub(NULL, NULL, ".ai_action", 3, (void *)md->bl.id, &md->nd->u.scr.script->script_vars); + linkdb_replace(&md->nd->u.scr.script->script_vars,(void *)(regkey+(3<<24)), (void *)md->bl.id); run_script(md->nd->u.scr.script, 0, 0, md->nd->bl.id); return 1; } diff --git a/src/map/npc.c b/src/map/npc.c index 3d1557c1ac..26ab060a72 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1312,8 +1312,8 @@ int npc_selllist(struct map_session_data *sd,int n,unsigned short *item_list) log_pick(sd, "S", 0, nameid, qty, &sd->status.inventory[idx]); if(nd) { - setd_sub(NULL,sd, "@sold_nameid", i, (void *)(int)sd->status.inventory[idx].nameid,NULL); - setd_sub(NULL,sd, "@sold_quantity", i, (void *)(int)qty,NULL); + pc_setreg(sd,add_str("@sold_nameid")+(i<<24),(int)sd->status.inventory[idx].nameid); + pc_setreg(sd,add_str("@sold_quantity")+(i<<24),qty); } itemamount+=qty; pc_delitem(sd,idx,qty,0); diff --git a/src/map/pc.c b/src/map/pc.c index ee163433fa..030c174bc0 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -826,12 +826,18 @@ int pc_reg_received(struct map_session_data *sd) sd->state.event_kill_pc = pc_readglobalreg(sd, script_config.kill_pc_event_name); sd->state.event_kill_mob = pc_readglobalreg(sd, script_config.kill_mob_event_name); sd->state.event_disconnect = pc_readglobalreg(sd, script_config.logout_event_name); + sd->state.event_baselvup = pc_readglobalreg(sd, script_config.baselvup_event_name); + sd->state.event_joblvup = pc_readglobalreg(sd, script_config.joblvup_event_name); + sd->state.event_loadmap = pc_readglobalreg(sd, script_config.loadmap_event_name); // if script triggers are not required } else { sd->state.event_death = 1; sd->state.event_kill_pc = 1; sd->state.event_disconnect = 1; sd->state.event_kill_mob = 1; + sd->state.event_baselvup = 1; + sd->state.event_joblvup = 1; + sd->state.event_loadmap = 1; } npc_script_event(sd, NPCE_LOGIN); @@ -3917,7 +3923,8 @@ int pc_checkbaselevelup(struct map_session_data *sd) } clif_misceffect(&sd->bl,0); //LORDALFA - LVLUPEVENT - npc_script_event(sd, NPCE_BASELVUP); + if(sd->state.event_baselvup) + npc_script_event(sd, NPCE_BASELVUP); return 1; } @@ -3948,7 +3955,8 @@ int pc_checkjoblevelup(struct map_session_data *sd) if (pc_checkskill(sd, SG_DEVIL) && !pc_nextjobexp(sd)) clif_status_change(&sd->bl,SI_DEVIL, 1); //Permanent blind effect from SG_DEVIL. - npc_script_event(sd, NPCE_JOBLVUP); + if(sd->state.event_joblvup) + npc_script_event(sd, NPCE_JOBLVUP); return 1; } @@ -4700,8 +4708,10 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) case BL_PC: { struct map_session_data *ssd = (struct map_session_data *)src; - if (sd->state.event_death) + if (sd->state.event_death){ pc_setglobalreg(sd,"killerrid",(ssd->status.account_id)); + npc_script_event(sd,NPCE_DIE); + } if (ssd->state.event_kill_pc) { pc_setglobalreg(ssd, "killedrid", sd->bl.id); npc_script_event(ssd, NPCE_KILLPC); @@ -4736,9 +4746,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) } break; } - - if (sd->state.event_death) - npc_script_event(sd,NPCE_DIE); + // PK/Karma system code (not enabled yet) [celest] /* diff --git a/src/map/script.c b/src/map/script.c index 234a5a11b7..59fb02dc99 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -856,7 +856,7 @@ static int search_str(const unsigned char *p) *------------------------------------------ */ // 既存のであれば番号、無ければ登録して新規番号 -static int add_str(const unsigned char *p) +int add_str(const unsigned char *p) { int i; char *lowcase; diff --git a/src/map/script.h b/src/map/script.h index 47de38c5c0..d94348e437 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -83,6 +83,7 @@ int script_config_read(char *cfgName); void script_free_stack(struct script_stack*); int do_init_script(void); int do_final_script(void); +int add_str(const unsigned char *p); int script_reload(void); extern char mapreg_txt[];