Index: atcommand.c===================================================================--- atcommand.c (revision 15066)+++ atcommand.c (working copy)@@ -4432,6 +4432,8 @@ strcat(atcmd_output, "PartyLock | "); if (map->list[m_id].flag.guildlock) strcat(atcmd_output, "GuildLock | ");+ if (map->list[m_id].flag.resident)+ strcat(atcmd_output, "Resident | "); clif->message(fd, atcmd_output); switch (list) {Index: battle.c===================================================================--- battle.c (revision 15066)+++ battle.c (working copy)@@ -1013,6 +1013,11 @@ sd = BL_CAST(BL_PC, src); tsd = BL_CAST(BL_PC, target); + if( sd && map->list[sd->bl.m].flag.resident && sd->state.resident && tsd && tsd->state.resident )+ {+ wd.damage = 1;+ return wd;+ } if(sd) wd.blewcount += battle->blewcount_bonus(sd, skill_num); @@ -3458,6 +3463,10 @@ struct map_session_data *sd = BL_CAST(BL_PC, s_bl); if( s_bl != t_bl ) {+ if(map->list[sd->bl.m].flag.resident &&+ ((sd->state.resident == 1 ) || (sd->state.resident == 2 && ((TBL_PC*)t_bl)->state.resident == 2))+ || (!sd->state.resident && ((TBL_PC*)t_bl)->state.resident) || (sd->state.resident && !((TBL_PC*)t_bl)->state.resident))+ return 0; if( sd->state.killer ) { state |= BCT_ENEMY; // Can kill anything@@ -3483,6 +3492,8 @@ if( !((map->agit_flag || agit2_flag) && map->list[m].flag.gvg_castle) && md->guardian_data && md->guardian_data->guild_id ) return 0; // Disable guardians/emperium owned by Guilds on non-woe times. + if(((TBL_PC*)t_bl)->state.resident)+ return 0; if( !md->special_state.ai ) { //Normal mobs. if( t_bl->type == BL_MOB && !((TBL_MOB*)t_bl)->special_state.ai )Index: clif.c===================================================================--- clif.c (revision 15066)+++ clif.c (working copy)@@ -9150,6 +9150,12 @@ #ifndef TXT_ONLY mail->clear(sd); #endif+ status_calc_pc(sd, true);+ if(!map->list[sd->bl.m].flag.resident && sd->state.resident)+ {+ sd->state.resident = 0;+ pc->disguise(sd,0);+ } if(map->list[sd->bl.m].flag.loadevent) // Lance npc->script_event(sd, NPCE_LOADMAP);Index: map.h===================================================================--- map.h (revision 15066)+++ map.h (working copy)@@ -492,6 +492,8 @@ unsigned guildlock :1; unsigned src4instance : 1; // To flag this map when it's used as a src map for instances unsigned reset :1; // [Daegaladh]+ + unsigned resident :1; } flag; struct point save; struct npc_data *npc[MAX_NPC_PER_MAP];Index: npc.c===================================================================--- npc.c (revision 15066)+++ npc.c (working copy)@@ -3114,6 +3114,8 @@ map->list[m].flag.guildlock=state; else if (!strcmpi(w3,"reset")) map->list[m].flag.reset=state;+ else if(!strcmpi(w3,"resident"))+ map->list[m].flag.resident=state; else ShowError("npc->parse_mapflag: unrecognized mapflag '%s' (file '%s', line '%d').n", w3, filepath, strlib->strline(buffer,start-buffer)); @@ -3300,6 +3302,7 @@ {"Die Event",script_config.die_event_name}, {"Kill PC Event",script_config.kill_pc_event_name}, {"Kill NPC Event",script_config.kill_mob_event_name},+ {"Damage Event",script->config.damage_event_name}, }; for (i = 0; i < NPCE_MAX; i++)Index: npc.h===================================================================--- npc.h (revision 15066)+++ npc.h (working copy)@@ -97,6 +97,7 @@ NPCE_DIE, NPCE_KILLPC, NPCE_KILLNPC,+ NPCE_DAMAGE, NPCE_MAX }; struct view_data* npc->get_viewdata(int class_);Index: pc.c===================================================================--- pc.c (revision 15066)+++ pc.c (working copy)@@ -5661,7 +5661,9 @@ pc->setstand(sd); skill->sit(sd,0); }-+ if(map->list[sd->bl.m].flag.resident && sd->state.resident == 1)+ {+ npc->script_event(sd,NPCE_DAMAGE);+ pc_stop_attack((TBL_PC*)src);+ }+ if( sd->progressbar.npc_id ) clif->progressbar_abort(sd); @@ -7120,6 +7122,9 @@ nullpo_ret(sd); + if(map->list[sd->bl.m].flag.resident)+ return 0;+ if( n < 0 || n >= MAX_INVENTORY ) { clif->equipitemack(sd,0,0,0); return 0;Index: pc.h===================================================================--- pc.h (revision 15066)+++ pc.h (working copy)@@ -137,6 +137,7 @@ unsigned short autolootid; // [Zephyrus] unsigned short autobonus; //flag to indicate if an autobonus is activated. [Inkfish] struct guild *gmaster_flag;+ unsigned int resident :2; } state; struct { unsigned char no_weapon_damage, no_magic_damage, no_misc_damage;Index: script.c===================================================================--- script.c (revision 15066)+++ script.c (working copy)@@ -232,6 +232,7 @@ "OnPCLoadMapEvent", //loadmap_event_name "OnPCBaseLvUpEvent", //baselvup_event_name "OnPCJobLvUpEvent", //joblvup_event_name+ "OnPCDamage", "OnTouch_", //ontouch_name (runs on first visible char to enter area, picks another char if the first char leaves) "OnTouch", //ontouch2_name (run whenever a char walks into the OnTouch area) };@@ -357,7 +358,8 @@ MF_MONSTER_NOTELEPORT, MF_PVP_NOCALCRANK, //50 MF_BATTLEGROUND,- MF_RESET+ MF_RESET,+ MF_RESIDENT }; const char* script->op2name(int op)@@ -14963,7 +14965,25 @@ return 0; } +BUILDIN(resident)+{+ struct map_session_data* sd;+ int resident;+ const char * name;+ + name = script_getstr(st,2);+ sd = map->nick2sd(name);+ + if(sd)+ {+ resident = script_getnum(st,3);+ sd->state.resident = (resident > 2?0:resident);+ pc->disguise(sd,sd->state.resident == 2?1865:0);+ }+ return true;+} + // declarations that were supposed to be exported from npc_chat.c #ifdef PCRE_SUPPORT BUILDIN(defpattern);@@ -14976,6 +14996,8 @@ /// for an explanation on args, see add_BUILDIN struct script_function BUILDIN[] = { // NPC interaction+ BUILDIN_DEF(resident,"si"),+ BUILDIN_DEF(mes,"s"), BUILDIN_DEF(next,""), BUILDIN_DEF(close,""),Index: script.h===================================================================--- script.h (revision 15066)+++ script.h (working copy)@@ -26,6 +26,7 @@ const char *loadmap_event_name; const char *baselvup_event_name; const char *joblvup_event_name;+ const char *damage_event_name; const char* ontouch_name; const char* ontouch2_name;Index: status.c===================================================================--- status.c (revision 15066)+++ status.c (working copy)@@ -3905,6 +3905,9 @@ speed = speed * 100 / sc->data[SC_WALKSPEED]->val1; } + if(sd && map->list[sd->bl.m].flag.resident)+ speed = 200;+ return (short)cap_value(speed,10,USHRT_MAX); }