summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-08-09 03:43:46 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-08-09 03:43:46 +0000
commite1d84a18ec61d7132505d9ece70cc1f0adac675e (patch)
tree106cdff4e7c02898e51f8f5bdf393f8d3c5e1276
parent67785396c1d2a3740404bd993f74dcaad87304ab (diff)
downloadhercules-e1d84a18ec61d7132505d9ece70cc1f0adac675e.tar.gz
hercules-e1d84a18ec61d7132505d9ece70cc1f0adac675e.tar.bz2
hercules-e1d84a18ec61d7132505d9ece70cc1f0adac675e.tar.xz
hercules-e1d84a18ec61d7132505d9ece70cc1f0adac675e.zip
- Moved damage logging to mob_log_damage, now non-damage targetted (or splash) skills also get logged into the monster's 'damage history' which affects the exp-bonus per attacker setting.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10966 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--Changelog-Trunk.txt3
-rw-r--r--src/map/mob.c159
-rw-r--r--src/map/mob.h1
-rw-r--r--src/map/skill.c4
4 files changed, 93 insertions, 74 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 990833092..79a163d3e 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -4,6 +4,9 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2007/08/08
+ * Moved damage logging to mob_log_damage, now non-damage targetted (or
+ splash) skills also get logged into the monster's 'damage history' which
+ affects the exp-bonus per attacker setting.
* Implemented the evolution stat growth bonuses for homunculus.
* Updated the @homstats command to show evolution bonuses
* Corrected initial intimacy of a newly created homunculus (should be
diff --git a/src/map/mob.c b/src/map/mob.c
index 2799b76a4..d15a50a27 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -1587,91 +1587,66 @@ int mob_respawn(int tid, unsigned int tick, int id,int data )
return 1;
}
-//Call when a mob has received damage.
-void mob_damage(struct mob_data *md, struct block_list *src, int damage)
+void mob_log_damage(struct mob_data *md, struct block_list *src, int damage)
{
int char_id = 0, flag = 0;
+ if(damage < 0) return; //Do nothing for absorbed damage.
- if (damage > 0)
- { //Store total damage...
- if (UINT_MAX - (unsigned int)damage > md->tdmg)
- md->tdmg+=damage;
- else if (md->tdmg == UINT_MAX)
- damage = 0; //Stop recording damage once the cap has been reached.
- else { //Cap damage log...
- damage = (int)(UINT_MAX - md->tdmg);
- md->tdmg = UINT_MAX;
- }
- if (md->state.aggressive)
- { //No longer aggressive, change to retaliate AI.
- md->state.aggressive = 0;
- if(md->state.skillstate== MSS_ANGRY)
- md->state.skillstate = MSS_BERSERK;
- if(md->state.skillstate== MSS_FOLLOW)
- md->state.skillstate = MSS_RUSH;
- }
- }
-
- if(md->guardian_data && md->guardian_data->number < MAX_GUARDIANS) // guardian hp update [Valaris] (updated by [Skotlex])
- md->guardian_data->castle->guardian[md->guardian_data->number].hp = md->status.hp;
-
- if (battle_config.show_mob_info&3)
- clif_charnameack (0, &md->bl);
-
- if (!src)
- return;
-
- if(md->nd)
- mob_script_callback(md, src, CALLBACK_ATTACK);
+ if(!damage && !(src->type&DEFAULT_ENEMY_TYPE(md)))
+ return; //Do not log non-damaging effects from non-enemies.
switch (src->type) {
- case BL_PC:
- {
- struct map_session_data *sd = (TBL_PC*)src;
- char_id = sd->status.char_id;
+ case BL_PC:
+ {
+ struct map_session_data *sd = (TBL_PC*)src;
+ char_id = sd->status.char_id;
+ if (damage)
md->attacked_id = src->id;
- break;
- }
- case BL_HOM: //[orn]
- {
- struct homun_data *hd = (TBL_HOM*)src;
- flag = 1;
- if (hd->master)
- char_id = hd->master->status.char_id;
+ break;
+ }
+ case BL_HOM: //[orn]
+ {
+ struct homun_data *hd = (TBL_HOM*)src;
+ flag = 1;
+ if (hd->master)
+ char_id = hd->master->status.char_id;
+ if (damage)
md->attacked_id = src->id;
- break;
- }
- case BL_PET:
- {
- struct pet_data *pd = (TBL_PET*)src;
- if (battle_config.pet_attack_exp_to_master && pd->msd) {
- char_id = pd->msd->status.char_id;
- damage=(damage*battle_config.pet_attack_exp_rate)/100; //Modify logged damage accordingly.
- }
- //Let mobs retaliate against the pet's master [Skotlex]
- if(pd->msd)
- md->attacked_id = pd->msd->bl.id;
- break;
+ break;
+ }
+ case BL_PET:
+ {
+ struct pet_data *pd = (TBL_PET*)src;
+ if (battle_config.pet_attack_exp_to_master && pd->msd) {
+ char_id = pd->msd->status.char_id;
+ damage=(damage*battle_config.pet_attack_exp_rate)/100; //Modify logged damage accordingly.
+ }
+ //Let mobs retaliate against the pet's master [Skotlex]
+ if(pd->msd && damage)
+ md->attacked_id = pd->msd->bl.id;
+ break;
+ }
+ case BL_MOB:
+ {
+ struct mob_data* md2 = (TBL_MOB*)src;
+ if(md2->special_state.ai && md2->master_id) {
+ struct map_session_data* msd = map_id2sd(md2->master_id);
+ if (msd) char_id = msd->status.char_id;
}
- case BL_MOB:
- {
- struct mob_data* md2 = (TBL_MOB*)src;
- if(md2->special_state.ai && md2->master_id) {
- struct map_session_data* msd = map_id2sd(md2->master_id);
- if (msd) char_id = msd->status.char_id;
- }
- //Let players decide whether to retaliate versus the master or the mob. [Skotlex]
- if (md2->master_id && battle_config.retaliate_to_master)
- md->attacked_id = md2->master_id;
- else
- md->attacked_id = src->id;
+ if (!damage)
break;
- }
- default: //For all unhandled types.
+ //Let players decide whether to retaliate versus the master or the mob. [Skotlex]
+ if (md2->master_id && battle_config.retaliate_to_master)
+ md->attacked_id = md2->master_id;
+ else
md->attacked_id = src->id;
+ break;
+ }
+ default: //For all unhandled types.
+ md->attacked_id = src->id;
}
//Log damage...
- if (char_id && damage > 0) {
+ if(char_id) {
int i,minpos;
unsigned int mindmg;
for(i=0,minpos=DAMAGELOG_SIZE-1,mindmg=UINT_MAX;i<DAMAGELOG_SIZE;i++){
@@ -1697,6 +1672,44 @@ void mob_damage(struct mob_data *md, struct block_list *src, int damage)
md->dmglog[minpos].dmg = damage;
}
}
+ return;
+}
+//Call when a mob has received damage.
+void mob_damage(struct mob_data *md, struct block_list *src, int damage)
+{
+ if (damage > 0)
+ { //Store total damage...
+ if (UINT_MAX - (unsigned int)damage > md->tdmg)
+ md->tdmg+=damage;
+ else if (md->tdmg == UINT_MAX)
+ damage = 0; //Stop recording damage once the cap has been reached.
+ else { //Cap damage log...
+ damage = (int)(UINT_MAX - md->tdmg);
+ md->tdmg = UINT_MAX;
+ }
+ if (md->state.aggressive)
+ { //No longer aggressive, change to retaliate AI.
+ md->state.aggressive = 0;
+ if(md->state.skillstate== MSS_ANGRY)
+ md->state.skillstate = MSS_BERSERK;
+ if(md->state.skillstate== MSS_FOLLOW)
+ md->state.skillstate = MSS_RUSH;
+ }
+ //Log damage
+ if (src) mob_log_damage(md, src, damage);
+ }
+
+ if(md->guardian_data && md->guardian_data->number < MAX_GUARDIANS) // guardian hp update [Valaris] (updated by [Skotlex])
+ md->guardian_data->castle->guardian[md->guardian_data->number].hp = md->status.hp;
+
+ if (battle_config.show_mob_info&3)
+ clif_charnameack (0, &md->bl);
+
+ if (!src)
+ return;
+
+ if(md->nd)
+ mob_script_callback(md, src, CALLBACK_ATTACK);
if(md->special_state.ai==2/* && md->master_id == src->id*/)
{ //LOne WOlf explained that ANYONE can trigger the marine countdown skill. [Skotlex]
diff --git a/src/map/mob.h b/src/map/mob.h
index c17104d6e..71abe8d8d 100644
--- a/src/map/mob.h
+++ b/src/map/mob.h
@@ -164,6 +164,7 @@ struct mob_data* mob_spawn_dataset(struct spawn_data *data);
int mob_spawn(struct mob_data *md);
int mob_setdelayspawn(struct mob_data *md);
int mob_parse_dataset(struct spawn_data *data);
+void mob_log_damage(struct mob_data *md, struct block_list *src, int damage);
void mob_damage(struct mob_data *md, struct block_list *src, int damage);
int mob_dead(struct mob_data *md, struct block_list *src, int type);
void mob_revive(struct mob_data *md, unsigned int hp);
diff --git a/src/map/skill.c b/src/map/skill.c
index 431278123..91757aca1 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -5565,8 +5565,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
return 1;
}
- if (dstmd) //Mob skill event for no damage skills (damage ones are handled in battle_calc_damage) [Skotlex]
+ if (dstmd) { //Mob skill event for no damage skills (damage ones are handled in battle_calc_damage) [Skotlex]
+ mob_log_damage(dstmd, src, 0); //Log interaction (counts as 'attacker' for the exp bonus)
mobskill_event(dstmd, src, tick, MSC_SKILLUSED|(skillid<<16));
+ }
if (sd && !(flag&1) && sd->state.arrow_atk) //Consume arrow on last invocation to this skill.
battle_consume_ammo(sd, skillid, skilllv);