From 1af5eb4ad8b5a03e430772ececf37f3986d0d537 Mon Sep 17 00:00:00 2001
From: skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>
Date: Mon, 7 Aug 2006 16:53:10 +0000
Subject: - Some code cleaning in status.c - Reflected damage will now also
 have a chance of draining hp/sp.

git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@8164 54d463be-8e91-2dee-dedb-b68131a5f0ec
---
 src/map/battle.c |  7 ++++---
 src/map/battle.h | 14 +++-----------
 src/map/skill.c  |  1 +
 src/map/status.c | 29 ++++++-----------------------
 4 files changed, 14 insertions(+), 37 deletions(-)

(limited to 'src')

diff --git a/src/map/battle.c b/src/map/battle.c
index 34ff61ad2..9b846e82c 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -25,8 +25,6 @@
 #include "guild.h"
 #include "party.h"
 
-#define	is_boss(bl)	status_get_mexp(bl)	// Can refine later [Aru]
-
 int attr_fix_table[4][ELE_MAX][ELE_MAX];
 
 struct Battle_Config battle_config;
@@ -3061,8 +3059,11 @@ int battle_weapon_attack( struct block_list *src,struct block_list *target,
 				battle_drain(sd, target, wd.damage, wd.damage2, tstatus->race, is_boss(target));
 		}
 	}
-	if (rdamage > 0) //By sending attack type "none" skill_additional_effect won't be invoked. [Skotlex]
+	if (rdamage > 0) { //By sending attack type "none" skill_additional_effect won't be invoked. [Skotlex]
+
+		battle_drain(tsd, src, rdamage, rdamage, sstatus->race, is_boss(src));
 		battle_delay_damage(tick+wd.amotion, target, src, 0, 0, 0, rdamage, ATK_DEF, rdelay);
+	}
 
 	if (tsc) {
 		if (tsc->data[SC_POISONREACT].timer != -1 && 
diff --git a/src/map/battle.h b/src/map/battle.h
index 43f20c4e0..d410e7a12 100644
--- a/src/map/battle.h
+++ b/src/map/battle.h
@@ -73,17 +73,9 @@ int battle_getcurrentskill(struct block_list *bl);
 #define BCT_NOONE 0x000000
 #define BCT_SELF 0x010000
 #define BCT_NEUTRAL 0x100000
-/*
-enum {
-	BCT_NOENEMY	=0x00000,
-	BCT_PARTY	=0x10000,
-	BCT_ENEMY	=0x40000,
-	BCT_NOPARTY	=0x50000,
-	BCT_ALL		=0x20000,
-	BCT_NOONE	=0x60000,
-	BCT_SELF	=0x60000,
-};
-*/
+
+#define	is_boss(bl)	status_get_mexp(bl)	// Can refine later [Aru]
+
 int battle_check_undead(int race,int element);
 int battle_check_target(struct block_list *src, struct block_list *target,int flag);
 int battle_check_range(struct block_list *src,struct block_list *bl,int range);
diff --git a/src/map/skill.c b/src/map/skill.c
index 3de357f22..60802d79a 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -2112,6 +2112,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
 			status_fix_damage(bl,src,rdamage,0);
 		clif_damage(src,src,tick, dmg.amotion,0,rdamage,1,4,0);
 		//Use Reflect Shield to signal this kind of skill trigger. [Skotlex]
+		battle_drain(tsd, src, rdamage, rdamage, sstatus->race, is_boss(src));
 		skill_additional_effect(bl,src,CR_REFLECTSHIELD, 1,BF_WEAPON,tick);
 	}
 
diff --git a/src/map/status.c b/src/map/status.c
index a762da8de..48560f17c 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -1992,7 +1992,7 @@ int status_calc_pc(struct map_session_data* sd,int first)
 		status->aspd_rate -= 30*skill;
 	if((skill=pc_checkskill(sd,GS_SINGLEACTION))>0 &&
 		(sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE))
-		status->aspd_rate -= (int)((skill+1)/2) * 10;
+		status->aspd_rate -= ((skill+1)/2) * 10;
 	if(pc_isriding(sd))
 		status->aspd_rate += 500-100*pc_checkskill(sd,KN_CAVALIERMASTERY);
 	
@@ -3842,16 +3842,8 @@ int status_get_party_id(struct block_list *bl)
 		}
 		return 0; //No party.
 	}
-	if(bl->type==BL_HOM){	//[orn]
-		struct homun_data *hd=(struct homun_data *)bl;
-		if( hd->master->bl.id>0 )
-		{
-			if ( hd->master != NULL)
-				return hd->master->status.party_id;
-			return -1;
-		}
-		return 0; //No party.
-	}
+	if(bl->type==BL_HOM && ((TBL_HOM*)bl)->master)
+		return ((TBL_HOM*)bl)->master->status.party_id;
 	if(bl->type==BL_SKILL)
 		return ((struct skill_unit *)bl)->group->party_id;
 	return 0;
@@ -3874,16 +3866,8 @@ int status_get_guild_id(struct block_list *bl)
 			return msd->status.guild_id; //Alchemist's mobs [Skotlex]
 		return 0; //No guild.
 	}
-	if(bl->type==BL_HOM){	//[orn]
-		struct homun_data *hd=(struct homun_data *)bl;
-		if( hd->master->bl.id>0 )
-		{
-			if ( hd->master != NULL)
-				return hd->master->status.guild_id;
-			return -1;
-		}
-		return 0; //No guild.
-	}
+	if(bl->type==BL_HOM && ((TBL_HOM*)bl)->master)
+		return ((TBL_HOM*)bl)->master->status.guild_id;
 	if (bl->type == BL_NPC && bl->subtype == SCRIPT)
 		return ((TBL_NPC*)bl)->u.scr.guild_id;
 	if(bl->type==BL_SKILL)
@@ -3940,7 +3924,7 @@ struct view_data *status_get_viewdata(struct block_list *bl)
 		case BL_NPC:
 			return ((TBL_NPC*)bl)->vd;
 		case BL_HOM: //[blackhole89]
-			return ((struct homun_data*)bl)->vd;
+			return ((TBL_HOM*)bl)->vd;
 	}
 	return NULL;
 }
@@ -5604,7 +5588,6 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
 	sc->data[type].timer = add_timer(
 		gettick() + tick, status_change_timer, bl->id, type);
 
-
 	if (calc_flag)
 		status_calc_bl(bl,calc_flag);
 	
-- 
cgit v1.2.3-70-g09d2