summaryrefslogtreecommitdiff
path: root/src/map/mob.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-11-22 23:52:58 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-11-22 23:52:58 +0000
commit2b2dbf43f11aecf778ff118dd1da1af9726f36e6 (patch)
tree890231641c122da8ef8664471be4a008041c6349 /src/map/mob.c
parent78dcaf513236ab7736a84deff5820b71cf6a76fb (diff)
downloadhercules-2b2dbf43f11aecf778ff118dd1da1af9726f36e6.tar.gz
hercules-2b2dbf43f11aecf778ff118dd1da1af9726f36e6.tar.bz2
hercules-2b2dbf43f11aecf778ff118dd1da1af9726f36e6.tar.xz
hercules-2b2dbf43f11aecf778ff118dd1da1af9726f36e6.zip
- Changed the status_change structure to use dynamic rather than static memory to hold the individual status changes, this should have a noticeable impact on the server's memory consumption.
- Had to add a few 'ugly' flags to status_change since now you can't track SC related information while said SC is not active (happens only for Storm Gust, Joint Beat and Magic Power). - Since I am unable to fully test, watch out for any bugs~ git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11786 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/mob.c')
-rw-r--r--src/map/mob.c35
1 files changed, 15 insertions, 20 deletions
diff --git a/src/map/mob.c b/src/map/mob.c
index 00ef6f794..d38e4b098 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -1141,13 +1141,13 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap)
return 0;
// Abnormalities
- if((md->sc.opt1 > 0 && md->sc.opt1 != OPT1_STONEWAIT) || md->sc.data[SC_BLADESTOP].timer != -1)
+ if((md->sc.opt1 > 0 && md->sc.opt1 != OPT1_STONEWAIT) || md->sc.data[SC_BLADESTOP])
{ //Should reset targets.
md->target_id = md->attacked_id = 0;
return 0;
}
- if (md->sc.count && md->sc.data[SC_BLIND].timer != -1)
+ if (md->sc.count && md->sc.data[SC_BLIND])
view_range = 3;
else
view_range = md->db->range2;
@@ -1181,7 +1181,7 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap)
if (!battle_check_range(&md->bl, tbl, md->status.rhw.range) &&
( //Can't attack back and can't reach back.
(!can_move && DIFF_TICK(tick, md->ud.canmove_tick) > 0 &&
- (battle_config.mob_ai&0x2 || md->sc.data[SC_SPIDERWEB].timer != -1)) ||
+ (battle_config.mob_ai&0x2 || md->sc.data[SC_SPIDERWEB])) ||
(!mob_can_reach(md, tbl, md->min_chase, MSS_RUSH))
) &&
md->state.attacked_count++ >= RUDE_ATTACKED_COUNT &&
@@ -1200,7 +1200,7 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap)
(!battle_check_range(&md->bl, abl, md->status.rhw.range) &&
( //Reach check
(!can_move && DIFF_TICK(tick, md->ud.canmove_tick) > 0 &&
- (battle_config.mob_ai&0x2 || md->sc.data[SC_SPIDERWEB].timer != -1)) ||
+ (battle_config.mob_ai&0x2 || md->sc.data[SC_SPIDERWEB])) ||
!mob_can_reach(md, abl, dist+md->db->range3, MSS_RUSH)
)
)
@@ -1787,9 +1787,9 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
md->state.skillstate = MSS_DEAD;
mobskill_use(md,tick,-1); //On Dead skill.
- if (md->sc.data[SC_KAIZEL].timer != -1)
+ if (md->sc.data[SC_KAIZEL])
{ //Revive in a bit.
- add_timer(gettick()+3000, mob_respawn, md->bl.id, 10*md->sc.data[SC_KAIZEL].val1); //% of life to rebirth with
+ add_timer(gettick()+3000, mob_respawn, md->bl.id, md->sc.data[SC_KAIZEL]->val2); //% of life to rebirth with
map_delblock(&md->bl);
return 1; //Return 1 to only clear the object.
}
@@ -1900,8 +1900,8 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
bonus = 100;
- if (md->sc.data[SC_RICHMANKIM].timer != -1)
- bonus += md->sc.data[SC_RICHMANKIM].val2;
+ if (md->sc.data[SC_RICHMANKIM])
+ bonus += md->sc.data[SC_RICHMANKIM]->val2;
if(battle_config.mobs_level_up && md->level > md->db->lv) // [Valaris]
bonus += (md->level-md->db->lv)*battle_config.mobs_level_up_exp_rate;
@@ -2017,13 +2017,8 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
// attempt to drop the item
if (rand() % 10000 >= drop_rate)
- {
- if (sd && sd->sc.data[SC_ITEMBOOST].timer != -1)
- {
- if (rand() % 10000 >= drop_rate)
- continue; // Double try by Bubble Gum
- }
- else
+ { // Double try by Bubble Gum
+ if (!(sd && sd->sc.data[SC_ITEMBOOST] && rand() % 10000 < drop_rate))
continue;
}
@@ -2667,11 +2662,11 @@ int mob_getfriendstatus_sub(struct block_list *bl,va_list ap)
if( cond2==-1 ){
int j;
for(j=SC_COMMON_MIN;j<=SC_COMMON_MAX && !flag;j++){
- if ((flag=(md->sc.data[j].timer!=-1))) //Once an effect was found, break out. [Skotlex]
+ if ((flag=(md->sc.data[j] != NULL))) //Once an effect was found, break out. [Skotlex]
break;
}
}else
- flag=( md->sc.data[cond2].timer!=-1 );
+ flag=( md->sc.data[cond2] != NULL );
if( flag^( cond1==MSC_FRIENDSTATUSOFF ) )
(*fr)=md;
@@ -2755,10 +2750,10 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event)
flag = 0;
} else if (ms[i].cond2 == -1) {
for (j = SC_COMMON_MIN; j <= SC_COMMON_MAX; j++)
- if ((flag = (md->sc.data[j].timer != -1)) != 0)
+ if ((flag = (md->sc.data[j]!=NULL)) != 0)
break;
} else {
- flag = (md->sc.data[ms[i].cond2].timer != -1);
+ flag = (md->sc.data[ms[i].cond2]!=NULL);
}
flag ^= (ms[i].cond1 == MSC_MYSTATUSOFF); break;
case MSC_FRIENDHPLTMAXRATE: // friend HP < maxhp%
@@ -3236,7 +3231,7 @@ static bool mob_parse_dbrow(char** str)
}
if (mob_db_data[class_] == NULL)
- mob_db_data[class_] = aCalloc(1, sizeof (struct mob_data));
+ mob_db_data[class_] = aCalloc(1, sizeof (struct mob_db));
db = mob_db_data[class_];
status = &db->status;