mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-14 15:41:30 +00:00
Range attack clean up, prevent possible nullptr checks.
This commit is contained in:
parent
48be7c508d
commit
921433f998
@ -676,7 +676,8 @@ void Mob::RogueAssassinate(Mob* other)
|
||||
|
||||
void Client::RangedAttack(Mob* other, bool CanDoubleAttack) {
|
||||
//conditions to use an attack checked before we are called
|
||||
|
||||
if (!other)
|
||||
return;
|
||||
//make sure the attack and ranged timers are up
|
||||
//if the ranged timer is disabled, then they have no ranged weapon and shouldent be attacking anyhow
|
||||
if(!CanDoubleAttack && ((attack_timer.Enabled() && !attack_timer.Check(false)) || (ranged_timer.Enabled() && !ranged_timer.Check()))) {
|
||||
@ -716,7 +717,7 @@ void Client::RangedAttack(Mob* other, bool CanDoubleAttack) {
|
||||
return;
|
||||
}
|
||||
|
||||
mlog(COMBAT__RANGED, "Shooting %s with bow %s (%d) and arrow %s (%d)", GetTarget()->GetName(), RangeItem->Name, RangeItem->ID, AmmoItem->Name, AmmoItem->ID);
|
||||
mlog(COMBAT__RANGED, "Shooting %s with bow %s (%d) and arrow %s (%d)", other->GetName(), RangeItem->Name, RangeItem->ID, AmmoItem->Name, AmmoItem->ID);
|
||||
|
||||
//look for ammo in inventory if we only have 1 left...
|
||||
if(Ammo->GetCharges() == 1) {
|
||||
@ -766,17 +767,18 @@ void Client::RangedAttack(Mob* other, bool CanDoubleAttack) {
|
||||
float range = RangeItem->Range + AmmoItem->Range + GetRangeDistTargetSizeMod(GetTarget());
|
||||
mlog(COMBAT__RANGED, "Calculated bow range to be %.1f", range);
|
||||
range *= range;
|
||||
if(DistNoRoot(*GetTarget()) > range) {
|
||||
mlog(COMBAT__RANGED, "Ranged attack out of range... client should catch this. (%f > %f).\n", DistNoRootNoZ(*GetTarget()), range);
|
||||
float dist = DistNoRoot(*other);
|
||||
if(dist > range) {
|
||||
mlog(COMBAT__RANGED, "Ranged attack out of range... client should catch this. (%f > %f).\n", dist, range);
|
||||
Message_StringID(13,TARGET_OUT_OF_RANGE);//Client enforces range and sends the message, this is a backup just incase.
|
||||
return;
|
||||
}
|
||||
else if(DistNoRoot(*GetTarget()) < (RuleI(Combat, MinRangedAttackDist)*RuleI(Combat, MinRangedAttackDist))){
|
||||
else if(dist < (RuleI(Combat, MinRangedAttackDist)*RuleI(Combat, MinRangedAttackDist))){
|
||||
Message_StringID(15,RANGED_TOO_CLOSE);//Client enforces range and sends the message, this is a backup just incase.
|
||||
return;
|
||||
}
|
||||
|
||||
if(!IsAttackAllowed(GetTarget()) ||
|
||||
if(!IsAttackAllowed(other) ||
|
||||
IsCasting() ||
|
||||
IsSitting() ||
|
||||
(DivineAura() && !GetGM()) ||
|
||||
@ -788,7 +790,7 @@ void Client::RangedAttack(Mob* other, bool CanDoubleAttack) {
|
||||
}
|
||||
|
||||
//Shoots projectile and/or applies the archery damage
|
||||
DoArcheryAttackDmg(GetTarget(), RangeWeapon, Ammo,0,0,0,0,0,0, AmmoItem, ammo_slot);
|
||||
DoArcheryAttackDmg(other, RangeWeapon, Ammo,0,0,0,0,0,0, AmmoItem, ammo_slot);
|
||||
|
||||
//EndlessQuiver AA base1 = 100% Chance to avoid consumption arrow.
|
||||
int ChanceAvoidConsume = aabonuses.ConsumeProjectile + itembonuses.ConsumeProjectile + spellbonuses.ConsumeProjectile;
|
||||
@ -1322,7 +1324,8 @@ uint16 Mob::GetThrownDamage(int16 wDmg, int32& TotalDmg, int& minDmg) {
|
||||
|
||||
void Client::ThrowingAttack(Mob* other, bool CanDoubleAttack) { //old was 51
|
||||
//conditions to use an attack checked before we are called
|
||||
|
||||
if (!other)
|
||||
return;
|
||||
//make sure the attack and ranged timers are up
|
||||
//if the ranged timer is disabled, then they have no ranged weapon and shouldent be attacking anyhow
|
||||
if((!CanDoubleAttack && (attack_timer.Enabled() && !attack_timer.Check(false)) || (ranged_timer.Enabled() && !ranged_timer.Check()))) {
|
||||
@ -1348,7 +1351,7 @@ void Client::ThrowingAttack(Mob* other, bool CanDoubleAttack) { //old was 51
|
||||
return;
|
||||
}
|
||||
|
||||
mlog(COMBAT__RANGED, "Throwing %s (%d) at %s", item->Name, item->ID, GetTarget()->GetName());
|
||||
mlog(COMBAT__RANGED, "Throwing %s (%d) at %s", item->Name, item->ID, other->GetName());
|
||||
|
||||
if(RangeWeapon->GetCharges() == 1) {
|
||||
//first check ammo
|
||||
@ -1370,19 +1373,20 @@ void Client::ThrowingAttack(Mob* other, bool CanDoubleAttack) { //old was 51
|
||||
}
|
||||
}
|
||||
|
||||
float range = item->Range + GetRangeDistTargetSizeMod(GetTarget());
|
||||
float range = item->Range + GetRangeDistTargetSizeMod(other);
|
||||
mlog(COMBAT__RANGED, "Calculated bow range to be %.1f", range);
|
||||
range *= range;
|
||||
if(DistNoRoot(*GetTarget()) > range) {
|
||||
mlog(COMBAT__RANGED, "Throwing attack out of range... client should catch this. (%f > %f).\n", DistNoRootNoZ(*GetTarget()), range);
|
||||
float dist = DistNoRoot(*other);
|
||||
if(dist > range) {
|
||||
mlog(COMBAT__RANGED, "Throwing attack out of range... client should catch this. (%f > %f).\n", dist, range);
|
||||
Message_StringID(13,TARGET_OUT_OF_RANGE);//Client enforces range and sends the message, this is a backup just incase.
|
||||
return;
|
||||
}
|
||||
else if(DistNoRoot(*GetTarget()) < (RuleI(Combat, MinRangedAttackDist)*RuleI(Combat, MinRangedAttackDist))){
|
||||
else if(dist < (RuleI(Combat, MinRangedAttackDist)*RuleI(Combat, MinRangedAttackDist))){
|
||||
Message_StringID(15,RANGED_TOO_CLOSE);//Client enforces range and sends the message, this is a backup just incase.
|
||||
}
|
||||
|
||||
if(!IsAttackAllowed(GetTarget()) ||
|
||||
if(!IsAttackAllowed(other) ||
|
||||
IsCasting() ||
|
||||
IsSitting() ||
|
||||
(DivineAura() && !GetGM()) ||
|
||||
@ -1393,7 +1397,7 @@ void Client::ThrowingAttack(Mob* other, bool CanDoubleAttack) { //old was 51
|
||||
return;
|
||||
}
|
||||
|
||||
DoThrowingAttackDmg(GetTarget(), RangeWeapon, item);
|
||||
DoThrowingAttackDmg(other, RangeWeapon, item);
|
||||
|
||||
//consume ammo
|
||||
DeleteItemInInventory(ammo_slot, 1, true);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user