|
@@ -34,10 +34,10 @@
|
|
|
|
|
|
// Probability for mobs far from players from doing their IDLE skill. (rate of 1000 minute)
|
|
|
// in Aegis, this is 100% for mobs that have been activated by players and none otherwise.
|
|
|
-#define MOB_LAZYSKILLPERC(md) (md->state.spotted?1000:0)
|
|
|
+#define MOB_LAZYSKILLPERC(md) (mob_is_spotted(md)?1000:0)
|
|
|
// Move probability for mobs away from players (rate of 1000 minute)
|
|
|
// in Aegis, this is 100% for mobs that have been activated by players and none otherwise.
|
|
|
-#define MOB_LAZYMOVEPERC(md) (md->state.spotted?1000:0)
|
|
|
+#define MOB_LAZYMOVEPERC(md) (mob_is_spotted(md)?1000:0)
|
|
|
#define MOB_MAX_DELAY (24*3600*1000)
|
|
|
#define MAX_MINCHASE 30 //Max minimum chase value to use for mobs.
|
|
|
#define RUDE_ATTACKED_COUNT 1 //After how many rude-attacks should the skill be used?
|
|
@@ -139,6 +139,58 @@ static int mobdb_searchname_array_sub(struct mob_db* mob, const char *str)
|
|
|
return strcmpi(mob->jname,str);
|
|
|
}
|
|
|
|
|
|
+/*========================================== [Playtester]
|
|
|
+* Removes all characters that spotted the monster but are no longer online
|
|
|
+* @param md: Monster whose spotted log should be cleaned
|
|
|
+*------------------------------------------*/
|
|
|
+void mob_clean_spotted(struct mob_data *md) {
|
|
|
+ int i;
|
|
|
+ for (i = 0; i < DAMAGELOG_SIZE; i++) {
|
|
|
+ if (md->spotted_log[i] && !map_charid2sd(md->spotted_log[i]))
|
|
|
+ md->spotted_log[i] = 0;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*========================================== [Playtester]
|
|
|
+* Adds a char_id to the spotted log of a monster
|
|
|
+* @param md: Monster to whose spotted log char_id should be added
|
|
|
+* @param char_id: Char_id to add to the spotted log
|
|
|
+*------------------------------------------*/
|
|
|
+void mob_add_spotted(struct mob_data *md, uint32 char_id) {
|
|
|
+ int i;
|
|
|
+
|
|
|
+ //Check if char_id is already logged
|
|
|
+ for (i = 0; i < DAMAGELOG_SIZE; i++) {
|
|
|
+ if (md->spotted_log[i] == char_id)
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //Not logged, add char_id to first empty slot
|
|
|
+ for (i = 0; i < DAMAGELOG_SIZE; i++) {
|
|
|
+ if (md->spotted_log[i] == 0) {
|
|
|
+ md->spotted_log[i] = char_id;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*========================================== [Playtester]
|
|
|
+* Checks if a monster was spotted
|
|
|
+* @param md: Monster to check
|
|
|
+* @return Returns true if the monster is spotted, otherwise 0
|
|
|
+*------------------------------------------*/
|
|
|
+bool mob_is_spotted(struct mob_data *md) {
|
|
|
+ int i;
|
|
|
+
|
|
|
+ //Check if monster is spotted
|
|
|
+ for (i = 0; i < DAMAGELOG_SIZE; i++) {
|
|
|
+ if (md->spotted_log[i] != 0)
|
|
|
+ return true; //Spotted
|
|
|
+ }
|
|
|
+
|
|
|
+ return false; //Not spotted
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* Tomb spawn time calculations
|
|
|
* @param nd: NPC data
|
|
@@ -1033,6 +1085,8 @@ int mob_spawn (struct mob_data *md)
|
|
|
|
|
|
for (i = 0, c = tick-MOB_MAX_DELAY; i < MAX_MOBSKILL; i++)
|
|
|
md->skilldelay[i] = c;
|
|
|
+ for (i = 0; i < DAMAGELOG_SIZE; i++)
|
|
|
+ md->spotted_log[i] = 0;
|
|
|
|
|
|
memset(md->dmglog, 0, sizeof(md->dmglog));
|
|
|
md->tdmg = 0;
|
|
@@ -1834,11 +1888,11 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
|
|
|
static int mob_ai_sub_hard_timer(struct block_list *bl,va_list ap)
|
|
|
{
|
|
|
struct mob_data *md = (struct mob_data*)bl;
|
|
|
+ uint32 char_id = va_arg(ap, uint32);
|
|
|
unsigned int tick = va_arg(ap, unsigned int);
|
|
|
if (mob_ai_sub_hard(md, tick))
|
|
|
{ //Hard AI triggered.
|
|
|
- if(!md->state.spotted)
|
|
|
- md->state.spotted = 1;
|
|
|
+ mob_add_spotted(md, char_id);
|
|
|
md->last_pcneartime = tick;
|
|
|
}
|
|
|
return 0;
|
|
@@ -1851,7 +1905,7 @@ static int mob_ai_sub_foreachclient(struct map_session_data *sd,va_list ap)
|
|
|
{
|
|
|
unsigned int tick;
|
|
|
tick=va_arg(ap,unsigned int);
|
|
|
- map_foreachinrange(mob_ai_sub_hard_timer,&sd->bl, AREA_SIZE+ACTIVE_AI_RANGE, BL_MOB,tick);
|
|
|
+ map_foreachinrange(mob_ai_sub_hard_timer,&sd->bl, AREA_SIZE+ACTIVE_AI_RANGE, BL_MOB, sd->status.char_id, tick);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
@@ -1896,6 +1950,9 @@ static int mob_ai_sub_lazy(struct mob_data *md, va_list args)
|
|
|
md->last_pcneartime = 0;
|
|
|
}
|
|
|
|
|
|
+ //Clean the spotted log
|
|
|
+ mob_clean_spotted(md);
|
|
|
+
|
|
|
if(DIFF_TICK(tick,md->last_thinktime)< 10*MIN_MOBTHINKTIME)
|
|
|
return 0;
|
|
|
|