summaryrefslogtreecommitdiff
path: root/src/map/npc.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-12-06 12:59:12 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-12-06 12:59:12 +0000
commit71392bc0305b06e18c99892d0a5b3fb4aaaf22c9 (patch)
treebcc6bedfb729d9b4e20baaba984c674b4642b946 /src/map/npc.c
parent09a89593b983a9ade807175192fcf63971748f7c (diff)
downloadhercules-71392bc0305b06e18c99892d0a5b3fb4aaaf22c9.tar.gz
hercules-71392bc0305b06e18c99892d0a5b3fb4aaaf22c9.tar.bz2
hercules-71392bc0305b06e18c99892d0a5b3fb4aaaf22c9.tar.xz
hercules-71392bc0305b06e18c99892d0a5b3fb4aaaf22c9.zip
- 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
Diffstat (limited to 'src/map/npc.c')
-rw-r--r--src/map/npc.c52
1 files changed, 15 insertions, 37 deletions
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; i<script_event[type].event_count; i++) {
- npc_event_sub(sd,script_event[type].event[i],script_event[type].event_name[i]);
- }
- return i;
- }
- return 0;
+ for (i = 0; i<script_event[type].event_count; i++)
+ npc_event_sub(sd,script_event[type].event[i],script_event[type].event_name[i]);
+ return i;
}
static int npc_read_event_script_sub(DBKey key, void* data, va_list ap)
@@ -2735,7 +2726,7 @@ void npc_read_event_script(void)
int i;
struct {
char *name;
- char *event_name;
+ const char *event_name;
} config[] = {
{"Login Event",script_config.login_event_name},
{"Logout Event",script_config.logout_event_name},
@@ -2748,32 +2739,19 @@ void npc_read_event_script(void)
};
for (i = 0; i < NPCE_MAX; i++) {
- script_event[i].nd = NULL;
+ char buf[64]="::";
script_event[i].event_count = 0;
- if (!script_config.event_script_type) {
- //Use a single NPC as event source.
- script_event[i].nd = npc_name2id(config[i].event_name);
- } else {
- //Use an array of Events
- char buf[64]="::";
- 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);
- }
+ //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);
}
}