From 71392bc0305b06e18c99892d0a5b3fb4aaaf22c9 Mon Sep 17 00:00:00 2001 From: skotlex Date: Thu, 6 Dec 2007 12:59:12 +0000 Subject: - The default event script behaviour is to trigger on labels rather than NPCs now. - Removed several script config options which break NPC compatibility when you mess with them (event_script_type, event_requires_trigger, die_event_name, kill_pc_event_name, kill_mob_event_name, logout_event_name, login_event_name, loadmap_event_name, baselvup_event_name, joblvup_event_name) - LoadMap events no longer set the variable "@maploaded$" to the name of the new map. - Optimized/simplified the code now that the previous config options were removed. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11859 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/npc.c | 52 +++++++++++++++------------------------------------- 1 file changed, 15 insertions(+), 37 deletions(-) (limited to 'src/map/npc.c') diff --git a/src/map/npc.c b/src/map/npc.c index 7b44c4afa..26ce12757 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -67,7 +67,6 @@ static struct view_data npc_viewdb[MAX_NPC_CLASS]; static struct script_event_s { //Holds pointers to the commonly executed scripts for speedup. [Skotlex] - struct npc_data *nd; struct event_data *event[UCHAR_MAX]; const char *event_name[UCHAR_MAX]; uint8 event_count; @@ -2688,26 +2687,18 @@ void npc_parsesrcfile(const char* filepath) return; } -int npc_script_event(struct map_session_data* sd, int type) +int npc_script_event(struct map_session_data* sd, enum npce_event type) { int i; - if (type < 0 || type >= NPCE_MAX) + if (type == NPCE_MAX) return 0; if (!sd) { ShowError("npc_script_event: NULL sd. Event Type %d\n", type); return 0; } - if (script_event[type].nd) { - TBL_NPC *nd = script_event[type].nd; - run_script(nd->u.scr.script,0,sd->bl.id,nd->bl.id); - return 1; - } else if (script_event[type].event_count) { - for (i = 0; iforeach(ev_db,npc_read_event_script_sub,buf, - &script_event[i].event, - &script_event[i].event_name, - &script_event[i].event_count); - } + //Use an array of Events + strncpy(buf+2,config[i].event_name,62); + ev_db->foreach(ev_db,npc_read_event_script_sub,buf, + &script_event[i].event, + &script_event[i].event_name, + &script_event[i].event_count); } if (battle_config.etc_log) { //Print summary. - for (i = 0; i < NPCE_MAX; i++) { - if(!script_config.event_script_type) { - if (script_event[i].nd) - ShowInfo("%s: Using NPC named '%s'.\n", config[i].name, config[i].event_name); - else - ShowInfo("%s: No NPC found with name '%s'.\n", config[i].name, config[i].event_name); - } else - ShowInfo("%s: %d '%s' events.\n", config[i].name, script_event[i].event_count, config[i].event_name); - } + for (i = 0; i < NPCE_MAX; i++) + ShowInfo("%s: %d '%s' events.\n", config[i].name, script_event[i].event_count, config[i].event_name); } } -- cgit v1.2.3-70-g09d2