diff options
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 122 |
1 files changed, 80 insertions, 42 deletions
diff --git a/src/map/script.c b/src/map/script.c index eabf5d14c..f0a0b7f86 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -633,15 +633,8 @@ static void check_event(struct script_state *st, const char *evt) { if( evt && evt[0] && !stristr(evt, "::On") ) { - if( npc_event_isspecial(evt) ) - { - ; // portable small/large monsters or other attributes - } - else - { - ShowWarning("NPC event parameter deprecated! Please use 'NPCNAME::OnEVENT' instead of '%s'.\n", evt); - script_reportsrc(st); - } + ShowWarning("NPC event parameter deprecated! Please use 'NPCNAME::OnEVENT' instead of '%s'.\n", evt); + script_reportsrc(st); } } @@ -8663,38 +8656,61 @@ BUILDIN_FUNC(guildchangegm) *------------------------------------------*/ BUILDIN_FUNC(monster) { - const char* mapn = script_getstr(st,2); - int x = script_getnum(st,3); - int y = script_getnum(st,4); - const char* str = script_getstr(st,5); - int class_ = script_getnum(st,6); - int amount = script_getnum(st,7); - const char* event = ""; + const char* mapn = script_getstr(st,2); + int x = script_getnum(st,3); + int y = script_getnum(st,4); + const char* str = script_getstr(st,5); + int class_ = script_getnum(st,6); + int amount = script_getnum(st,7); + const char* event = ""; + unsigned int size = SZ_SMALL; + unsigned int ai = AI_NONE; struct map_session_data* sd; int m; - if( script_hasdata(st,8) ) + if (script_hasdata(st, 8)) { - event = script_getstr(st,8); + event = script_getstr(st, 8); check_event(st, event); } + + if (script_hasdata(st, 9)) + { + size = script_getnum(st, 9); + if (size > 3) + { + ShowWarning("buildin_monster: Attempted to spawn non-existing size %d for monster class %d\n", size, class_); + return 1; + } + } + + if (script_hasdata(st, 10)) + { + ai = script_getnum(st, 10); + if (ai > 4) + { + ShowWarning("buildin_monster: Attempted to spawn non-existing ai %d for monster class %d\n", ai, class_); + return 1; + } + } - if (class_ >= 0 && !mobdb_checkid(class_)) { + if (class_ >= 0 && !mobdb_checkid(class_)) + { ShowWarning("buildin_monster: Attempted to spawn non-existing monster class %d\n", class_); return 1; } sd = map_id2sd(st->rid); - if( sd && strcmp(mapn,"this") == 0 ) + if (sd && strcmp(mapn, "this") == 0) m = sd->bl.m; else { m = map_mapname2mapid(mapn); - if( map[m].flag.src4instance && st->instance_id ) + if (map[m].flag.src4instance && st->instance_id) { // Try to redirect to the instance map, not the src map - if( (m = instance_mapid2imapid(m, st->instance_id)) < 0 ) + if ((m = instance_mapid2imapid(m, st->instance_id)) < 0) { ShowError("buildin_monster: Trying to spawn monster (%d) on instance map (%s) without instance attached.\n", class_, mapn); return 1; @@ -8702,7 +8718,7 @@ BUILDIN_FUNC(monster) } } - mob_once_spawn(sd,m,x,y,str,class_,amount,event); + mob_once_spawn(sd, m, x, y, str, class_, amount, event, size, ai); return 0; } /*========================================== @@ -8745,35 +8761,57 @@ BUILDIN_FUNC(getmobdrops) *------------------------------------------*/ BUILDIN_FUNC(areamonster) { - const char* mapn = script_getstr(st,2); - int x0 = script_getnum(st,3); - int y0 = script_getnum(st,4); - int x1 = script_getnum(st,5); - int y1 = script_getnum(st,6); - const char* str = script_getstr(st,7); - int class_ = script_getnum(st,8); - int amount = script_getnum(st,9); - const char* event = ""; + const char* mapn = script_getstr(st,2); + int x0 = script_getnum(st,3); + int y0 = script_getnum(st,4); + int x1 = script_getnum(st,5); + int y1 = script_getnum(st,6); + const char* str = script_getstr(st,7); + int class_ = script_getnum(st,8); + int amount = script_getnum(st,9); + const char* event = ""; + unsigned int size = SZ_SMALL; + unsigned int ai = AI_NONE; struct map_session_data* sd; int m; - if( script_hasdata(st,10) ) + if (script_hasdata(st,10)) { - event = script_getstr(st,10); + event = script_getstr(st, 10); check_event(st, event); } + + if (script_hasdata(st, 11)) + { + size = script_getnum(st, 11); + if (size > 3) + { + ShowWarning("buildin_monster: Attempted to spawn non-existing size %d for monster class %d\n", size, class_); + return 1; + } + } + + if (script_hasdata(st, 12)) + { + ai = script_getnum(st, 12); + if (ai > 4) + { + ShowWarning("buildin_monster: Attempted to spawn non-existing ai %d for monster class %d\n", ai, class_); + return 1; + } + } sd = map_id2sd(st->rid); - if( sd && strcmp(mapn,"this") == 0 ) + if (sd && strcmp(mapn, "this") == 0) m = sd->bl.m; else { m = map_mapname2mapid(mapn); - if( map[m].flag.src4instance && st->instance_id ) + if (map[m].flag.src4instance && st->instance_id) { // Try to redirect to the instance map, not the src map - if( (m = instance_mapid2imapid(m, st->instance_id)) < 0 ) + if ((m = instance_mapid2imapid(m, st->instance_id)) < 0) { ShowError("buildin_areamonster: Trying to spawn monster (%d) on instance map (%s) without instance attached.\n", class_, mapn); return 1; @@ -8781,7 +8819,7 @@ BUILDIN_FUNC(areamonster) } } - mob_once_spawn_area(sd,m,x0,y0,x1,y1,str,class_,amount,event); + mob_once_spawn_area(sd, m, x0, y0, x1, y1, str, class_, amount, event, size, ai); return 0; } /*========================================== @@ -12983,10 +13021,10 @@ BUILDIN_FUNC(summon) clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,sd->bl.x,sd->bl.y,tick); - md = mob_once_spawn_sub(&sd->bl, sd->bl.m, sd->bl.x, sd->bl.y, str, _class, event); + md = mob_once_spawn_sub(&sd->bl, sd->bl.m, sd->bl.x, sd->bl.y, str, _class, event, SZ_SMALL, AI_NONE); if (md) { md->master_id=sd->bl.id; - md->special_state.ai=1; + md->special_state.ai = AI_ATTACK; if( md->deletetimer != INVALID_TIMER ) delete_timer(md->deletetimer, mob_timer_delete); md->deletetimer = add_timer(tick+(timeout>0?timeout*1000:60000),mob_timer_delete,md->bl.id,0); @@ -17112,9 +17150,9 @@ struct script_function buildin_func[] = { BUILDIN_DEF(itemskill,"vi"), BUILDIN_DEF(produce,"i"), BUILDIN_DEF(cooking,"i"), - BUILDIN_DEF(monster,"siisii?"), + BUILDIN_DEF(monster,"siisii???"), BUILDIN_DEF(getmobdrops,"i"), - BUILDIN_DEF(areamonster,"siiiisii?"), + BUILDIN_DEF(areamonster,"siiiisii???"), BUILDIN_DEF(killmonster,"ss?"), BUILDIN_DEF(killmonsterall,"s?"), BUILDIN_DEF(clone,"siisi????"), |