Browse Source

- Range attack now has strength based damage added
- Fixed "Ranged" skill-ups instead of damage type (piercing, slashing so on)
- Fixed skill ups not occurring if you are behind target

Emagi 1 year ago
parent
commit
7271e470f3

+ 15 - 9
EQ2/source/WorldServer/Combat.cpp

@@ -202,7 +202,7 @@ void Entity::MeleeAttack(Spawn* victim, float distance, bool primary, bool multi
 		CancelAllStealth();
 		
 
-	int8 hit_result = DetermineHit(victim, damage_type, 0, false);
+	int8 hit_result = DetermineHit(victim, DAMAGE_PACKET_TYPE_SIMPLE_DAMAGE, damage_type, 0, false);
 	if(hit_result == DAMAGE_PACKET_RESULT_SUCCESSFUL){		
 		/*if(GetAdventureClass() == MONK){
 			max_damage*=3;
@@ -285,7 +285,7 @@ void Entity::RangeAttack(Spawn* victim, float distance, Item* weapon, Item* ammo
 
 	if(weapon && weapon->IsRanged() && ammo && ammo->IsAmmo() && ammo->IsThrown()) {
 		if(weapon->ranged_info->range_low <= distance && (weapon->ranged_info->range_high + ammo->thrown_info->range) >= distance) {
-			int8 hit_result = DetermineHit(victim, ammo->thrown_info->damage_type, ammo->thrown_info->hit_bonus, false);
+			int8 hit_result = DetermineHit(victim, DAMAGE_PACKET_TYPE_RANGE_DAMAGE, ammo->thrown_info->damage_type, ammo->thrown_info->hit_bonus, false);
 			if(hit_result == DAMAGE_PACKET_RESULT_SUCCESSFUL) {
 				DamageSpawn((Entity*)victim, DAMAGE_PACKET_TYPE_RANGE_DAMAGE, ammo->thrown_info->damage_type, weapon->ranged_info->weapon_info.damage_low3, weapon->ranged_info->weapon_info.damage_high3+ammo->thrown_info->damage_modifier, 0);
 				if (!multi_attack) {
@@ -381,9 +381,9 @@ bool Entity::SpellAttack(Spawn* victim, float distance, LuaSpell* luaspell, int8
 		is_tick = true;
 	}
 	else if(spell->GetSpellData()->type == SPELL_BOOK_TYPE_COMBAT_ART)
-		hit_result = DetermineHit(victim, damage_type, 0, false);
+		hit_result = DetermineHit(victim, DAMAGE_PACKET_TYPE_SPELL_DAMAGE, damage_type, 0, false);
 	else
-		hit_result = DetermineHit(victim, damage_type, 0, true, luaspell);
+		hit_result = DetermineHit(victim, DAMAGE_PACKET_TYPE_SPELL_DAMAGE, damage_type, 0, true, luaspell);
 		
 	if(hit_result == DAMAGE_PACKET_RESULT_SUCCESSFUL) {
 		luaspell->last_spellattack_hit = true;
@@ -488,7 +488,7 @@ bool Entity::SpellAttack(Spawn* victim, float distance, LuaSpell* luaspell, int8
 }
 
 bool Entity::ProcAttack(Spawn* victim, int8 damage_type, int32 low_damage, int32 high_damage, string name, string success_msg, string effect_msg) {
-	int8 hit_result = DetermineHit(victim, damage_type, 0, true);
+	int8 hit_result = DetermineHit(victim, DAMAGE_PACKET_TYPE_SPELL_DAMAGE, damage_type, 0, true);
 
 	if (hit_result == DAMAGE_PACKET_RESULT_SUCCESSFUL) {
 		DamageSpawn((Entity*)victim, DAMAGE_PACKET_TYPE_SPELL_DAMAGE, damage_type, low_damage, high_damage, name.c_str());
@@ -667,7 +667,7 @@ bool Entity::SpellHeal(Spawn* target, float distance, LuaSpell* luaspell, string
 	return true;
 }
 
-int8 Entity::DetermineHit(Spawn* victim, int8 damage_type, float ToHitBonus, bool is_caster_spell, LuaSpell* lua_spell){
+int8 Entity::DetermineHit(Spawn* victim, int8 type, int8 damage_type, float ToHitBonus, bool is_caster_spell, LuaSpell* lua_spell){
 	if(!victim) {
 		return DAMAGE_PACKET_RESULT_MISS;
 	}
@@ -677,13 +677,16 @@ int8 Entity::DetermineHit(Spawn* victim, int8 damage_type, float ToHitBonus, boo
 	}
 
 	bool behind = false;
+	
+	// move this above the if statement to assure skill-ups on successful damage return
+	Skill* skill = GetSkillByWeaponType(type, damage_type, true);
+	
 	// Monk added with Brawler to 360 degree support per KoS Prima Official eGuide Fighter: Monk, pg 138, denoted '360-Degree Avoidance!'
 	if(!victim->IsEntity() || (!is_caster_spell && victim->GetAdventureClass() != BRAWLER && victim->GetAdventureClass() != MONK && (behind = BehindTarget(victim)))) {
 		return DAMAGE_PACKET_RESULT_SUCCESSFUL;
 	}
 
 	float bonus = ToHitBonus;
-	Skill* skill = GetSkillByWeaponType(damage_type, true);
 
 	float skillAddedByWeapon = 0.0f;
 	if(skill)
@@ -884,8 +887,11 @@ float Entity::GetDamageTypeResistPercentage(int8 damage_type) {
 	return ret;
 }
 
-Skill* Entity::GetSkillByWeaponType(int8 type, bool update) {
-	switch(type) {
+Skill* Entity::GetSkillByWeaponType(int8 type, int8 damage_type, bool update) {
+	if(type == DAMAGE_PACKET_TYPE_RANGE_DAMAGE) {
+		return GetSkillByName("Ranged", update);
+	}
+	switch(damage_type) {
 	case DAMAGE_PACKET_DAMAGE_TYPE_SLASH: // slash
 		return GetSkillByName("Slashing", update);
 	case DAMAGE_PACKET_DAMAGE_TYPE_CRUSH: // crush

+ 4 - 2
EQ2/source/WorldServer/Entity.cpp

@@ -772,11 +772,13 @@ void Entity::ChangeRangedWeapon(){
 		return;
 	}
 	
+	int32 str_offset_dmg = GetStrengthDamage();
+	
 	Item* item = equipment_list.GetItem(EQ2_RANGE_SLOT);
 	if(item && item->details.item_id > 0 && item->IsRanged()){
 		GetInfoStruct()->set_ranged_weapon_delay(item->ranged_info->weapon_info.delay*100);
-		GetInfoStruct()->set_ranged_weapon_damage_low(item->ranged_info->weapon_info.damage_low3);
-		GetInfoStruct()->set_ranged_weapon_damage_high(item->ranged_info->weapon_info.damage_high3);
+		GetInfoStruct()->set_ranged_weapon_damage_low(item->ranged_info->weapon_info.damage_low3 + str_offset_dmg);
+		GetInfoStruct()->set_ranged_weapon_damage_high(item->ranged_info->weapon_info.damage_high3 + str_offset_dmg);
 		GetInfoStruct()->set_ranged_weapon_type(item->GetWeaponType());
 	}
 }

+ 2 - 2
EQ2/source/WorldServer/Entity.h

@@ -1372,9 +1372,9 @@ public:
 	bool			SpellAttack(Spawn* victim, float distance, LuaSpell* luaspell, int8 damage_type, int32 low_damage, int32 high_damage, int8 crit_mod = 0, bool no_calcs = false);
 	bool			ProcAttack(Spawn* victim, int8 damage_type, int32 low_damage, int32 high_damage, string name, string success_msg, string effect_msg);
 	bool            SpellHeal(Spawn* target, float distance, LuaSpell* luaspell, string heal_type, int32 low_heal, int32 high_heal, int8 crit_mod = 0, bool no_calcs = false, string custom_spell_name="");
-	int8			DetermineHit(Spawn* victim, int8 damage_type, float ToHitBonus, bool is_caster_spell, LuaSpell* lua_spell = nullptr);
+	int8			DetermineHit(Spawn* victim, int8 type, int8 damage_type, float ToHitBonus, bool is_caster_spell, LuaSpell* lua_spell = nullptr);
 	float			GetDamageTypeResistPercentage(int8 damage_type);
-	Skill*			GetSkillByWeaponType(int8 type, bool update);
+	Skill*			GetSkillByWeaponType(int8 type, int8 damage_type, bool update);
 	bool			DamageSpawn(Entity* victim, int8 type, int8 damage_type, int32 low_damage, int32 high_damage, const char* spell_name, int8 crit_mod = 0, bool is_tick = false, bool no_damage_calcs = false, bool ignore_attacker = false, LuaSpell* spell = 0);
 	float			CalculateMitigation(int8 type = DAMAGE_PACKET_TYPE_SIMPLE_DAMAGE, int8 damage_type = 0, int16 attacker_level = 0, bool for_pvp = false);
 	void			AddHate(Entity* attacker, sint32 hate);

+ 1 - 1
EQ2/source/WorldServer/SpellProcess.cpp

@@ -1769,7 +1769,7 @@ bool SpellProcess::CastProcessedSpell(LuaSpell* spell, bool passive, bool in_her
 
 	// if the caster is a player and the spell is a tradeskill spell check for a tradeskill event
 	if (client && spell->spell->GetSpellData()->spell_book_type == SPELL_BOOK_TYPE_TRADESKILL) {
-		spell->resisted = (spell->caster->DetermineHit(target ? target : spell->caster, 255, 0, true, spell) == DAMAGE_PACKET_RESULT_RESIST);
+		spell->resisted = (spell->caster->DetermineHit(target ? target : spell->caster, DAMAGE_PACKET_TYPE_SPELL_DAMAGE, 255, 0, true, spell) == DAMAGE_PACKET_RESULT_RESIST);
 		client->GetCurrentZone()->GetTradeskillMgr()->CheckTradeskillEvent(client, spell->resisted ? 0 : spell->spell->GetSpellData()->icon);
 	}