summaryrefslogtreecommitdiff
path: root/src/map/npc.c
diff options
context:
space:
mode:
authorpanikon <panikon@zoho.com>2014-05-06 21:14:46 -0300
committerpanikon <panikon@zoho.com>2014-05-06 21:14:46 -0300
commit9a425c11b61fb6f4e299013c7d8d9841129b8f45 (patch)
treeb8e8bc56c6e51679c23fe2de0e268f49b29f7288 /src/map/npc.c
parent9cf6b362a0d5e2f52c017d747c0fa8f69a1a273f (diff)
downloadhercules-9a425c11b61fb6f4e299013c7d8d9841129b8f45.tar.gz
hercules-9a425c11b61fb6f4e299013c7d8d9841129b8f45.tar.bz2
hercules-9a425c11b61fb6f4e299013c7d8d9841129b8f45.tar.xz
hercules-9a425c11b61fb6f4e299013c7d8d9841129b8f45.zip
Bug fixes and other changes
#Fixed issue where a corrupted map cache would lead to a crash *Moved Big-endian compatibility functions to common/utils.h #Fixed issue 8162 *http://hercules.ws/board/tracker/issue-8162-loadnpc-doesnt-trigger-oninit-of-duplicate-npcs/ *Added options to npc_parse_duplicate #Fixed issue 8169 *http://hercules.ws/board/tracker/issue-8169-script-command-guildskill-skill-idlevel-not-working-as-intended/ *Changed *guildskill behavior, now it behaves exactly as depicted in the documentation *Updated *guildskill documentation #Added missing GBI types to mapif_parse_GuildBasicInfoChange now it's possible to change guild exp, lv, skill point and skill information #GeoIP revamp *GeoIP module was partially rewritten *Added several data checks to prevent corruption and crashes *Updated GeoIP database *See https://github.com/maxmind/geoip-api-c/blob/master/libGeoIP/GeoIP.c for more information #Added packetver checks regarding NST_MARKET *Now *tradertype warns if user is trying to use this feature with older clients
Diffstat (limited to 'src/map/npc.c')
-rw-r--r--src/map/npc.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/map/npc.c b/src/map/npc.c
index ae374e961..43e4bcc88 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -2935,7 +2935,8 @@ const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char*
/// shop/cashshop/npc: <map name>,<x>,<y>,<facing>%TAB%duplicate(<name of target>)%TAB%<NPC Name>%TAB%<sprite id>
/// npc: -%TAB%duplicate(<name of target>)%TAB%<NPC Name>%TAB%<sprite id>,<triggerX>,<triggerY>
/// npc: <map name>,<x>,<y>,<facing>%TAB%duplicate(<name of target>)%TAB%<NPC Name>%TAB%<sprite id>,<triggerX>,<triggerY>
-const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath)
+/// !!Only NPO_ONINIT is available trough options!!
+const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath, int options)
{
int x, y, dir, m, xs = -1, ys = -1;
char mapname[32];
@@ -3074,6 +3075,20 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch
nd->u.scr.timerid = INVALID_TIMER;
+ if( type == SCRIPT && options&NPO_ONINIT ) {
+ // From npc_parse_script
+ char evname[EVENT_NAME_LENGTH];
+ struct event_data *ev;
+
+ snprintf(evname, ARRAYLENGTH(evname), "%s::OnInit", nd->exname);
+
+ if( ( ev = (struct event_data*)strdb_get(npc->ev_db, evname) ) ) {
+
+ //Execute OnInit
+ script->run(nd->u.scr.script,ev->pos,0,nd->bl.id);
+
+ }
+ }
return end;
}
@@ -3137,7 +3152,7 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) {
else
snprintf(w4, sizeof(w4), "%d", snd->class_);
- npc->parse_duplicate(w1, w2, w3, w4, stat_buf, stat_buf, "INSTANCING");
+ npc->parse_duplicate(w1, w2, w3, w4, stat_buf, stat_buf, "INSTANCING", NPO_NONE);
}
return 0;
@@ -4094,7 +4109,7 @@ int npc_parsesrcfile(const char* filepath, bool runOnInit) {
}
else if( (i=0, sscanf(w2,"duplicate%n",&i), (i > 0 && w2[i] == '(')) && count > 3 )
{
- p = npc->parse_duplicate(w1,w2,w3,w4, p, buffer, filepath);
+ p = npc->parse_duplicate(w1,w2,w3,w4, p, buffer, filepath, (runOnInit?NPO_ONINIT:NPO_NONE));
}
else if( (strcmp(w2,"monster") == 0 || strcmp(w2,"boss_monster") == 0) && count > 3 )
{