mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 09:06:46 +00:00
Cleanup ranged and ammo calculations - Adds throwing check for match
This commit is contained in:
+51
-55
@@ -584,33 +584,34 @@ uint32 Bot::GetBotRangedValue() {
|
|||||||
ammo_item = ammo_inst->GetItem();
|
ammo_item = ammo_inst->GetItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool has_ammo = ammo_item;
|
||||||
|
|
||||||
|
if (!range_item || !has_ammo) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Bow requires arrows
|
// Bow requires arrows
|
||||||
if (
|
if (
|
||||||
range_item &&
|
|
||||||
range_item->ItemType == EQ::item::ItemTypeBow &&
|
range_item->ItemType == EQ::item::ItemTypeBow &&
|
||||||
(
|
ammo_item->ItemType != EQ::item::ItemTypeArrow
|
||||||
!ammo_item ||
|
|
||||||
ammo_item->ItemType != EQ::item::ItemTypeArrow
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Throwing items
|
// Throwing items
|
||||||
if (
|
if (
|
||||||
range_item &&
|
range_item->ItemType == EQ::item::ItemTypeSmallThrowing ||
|
||||||
(
|
range_item->ItemType == EQ::item::ItemTypeLargeThrowing
|
||||||
range_item->ItemType == EQ::item::ItemTypeSmallThrowing ||
|
|
||||||
range_item->ItemType == EQ::item::ItemTypeLargeThrowing
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
return range_item->Range;
|
if (range_item->ID == ammo_item->ID) {
|
||||||
|
return range_item->Range;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0; // mismatched throwing
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bows and arrows
|
// Bows and arrows
|
||||||
if (
|
if (
|
||||||
range_item &&
|
|
||||||
ammo_item &&
|
|
||||||
range_item->ItemType == EQ::item::ItemTypeBow &&
|
range_item->ItemType == EQ::item::ItemTypeBow &&
|
||||||
ammo_item->ItemType == EQ::item::ItemTypeArrow
|
ammo_item->ItemType == EQ::item::ItemTypeArrow
|
||||||
) {
|
) {
|
||||||
@@ -1903,43 +1904,42 @@ bool Bot::BotRangedAttack(Mob* other, bool can_double_attack) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bow requires arrows
|
// Bow requires arrows
|
||||||
if (
|
// Check if ammo is invalid
|
||||||
!ammo ||
|
bool is_invalid_ammo = !ammo;
|
||||||
|
|
||||||
|
// Check if ranged weapon type is invalid
|
||||||
|
bool is_invalid_ranged_weapon_type = ranged_weapon &&
|
||||||
|
(ranged_weapon->ItemType != EQ::item::ItemTypeBow &&
|
||||||
|
ranged_weapon->ItemType != EQ::item::ItemTypeSmallThrowing &&
|
||||||
|
ranged_weapon->ItemType != EQ::item::ItemTypeLargeThrowing);
|
||||||
|
|
||||||
|
// Check if bow has the wrong ammo
|
||||||
|
bool is_bow_with_invalid_ammo = ranged_weapon &&
|
||||||
|
(ranged_weapon->ItemType == EQ::item::ItemTypeBow &&
|
||||||
|
(!ammo || ammo->ItemType != EQ::item::ItemTypeArrow));
|
||||||
|
|
||||||
|
// Check if throwing weapon has insufficient charges
|
||||||
|
bool is_throwing_weapon_with_insufficient_ammo = ranged_weapon &&
|
||||||
|
(ranged_weapon->ItemType == EQ::item::ItemTypeSmallThrowing || ranged_weapon->ItemType == EQ::item::ItemTypeLargeThrowing) &&
|
||||||
(
|
(
|
||||||
ranged_weapon &&
|
!ammo_item || ammo_item->GetCharges() < 1 || // Not enough ammo
|
||||||
(
|
(
|
||||||
(
|
(RuleI(Bots, StackSizeMin) != -1 && ranged_item->GetCharges() != ranged_weapon->StackSize) || // Invalid stack size
|
||||||
ranged_weapon->ItemType != EQ::item::ItemTypeBow &&
|
ranged_item->GetCharges() < RuleI(Bots, StackSizeMin) // Charges below minimum
|
||||||
ranged_weapon->ItemType != EQ::item::ItemTypeSmallThrowing &&
|
|
||||||
ranged_weapon->ItemType != EQ::item::ItemTypeLargeThrowing) ||
|
|
||||||
(
|
|
||||||
ranged_weapon->ItemType == EQ::item::ItemTypeBow &&
|
|
||||||
(ammo->ItemType != EQ::item::ItemTypeArrow)
|
|
||||||
) ||
|
|
||||||
(
|
|
||||||
(
|
|
||||||
ranged_weapon->ItemType == EQ::item::ItemTypeSmallThrowing ||
|
|
||||||
ranged_weapon->ItemType == EQ::item::ItemTypeLargeThrowing
|
|
||||||
) &&
|
|
||||||
ammo_item->GetCharges() < 1 ||
|
|
||||||
(
|
|
||||||
(
|
|
||||||
RuleI(Bots, StackSizeMin) != -1 &&
|
|
||||||
ranged_item->GetCharges() != ranged_weapon->StackSize
|
|
||||||
) ||
|
|
||||||
ranged_item->GetCharges() < RuleI(Bots, StackSizeMin)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
);
|
||||||
) {
|
|
||||||
|
// Final ranged weapon validity check
|
||||||
|
bool is_invalid_ranged_weapon = is_invalid_ranged_weapon_type || is_bow_with_invalid_ammo || is_throwing_weapon_with_insufficient_ammo;
|
||||||
|
|
||||||
|
// Final condition
|
||||||
|
if (is_invalid_ammo || is_invalid_ranged_weapon) {
|
||||||
if (!ammo || ammo_item->GetCharges() < 1) {
|
if (!ammo || ammo_item->GetCharges() < 1) {
|
||||||
if (!GetCombatRoundForAlerts()) {
|
if (!GetCombatRoundForAlerts()) {
|
||||||
SetCombatRoundForAlerts();
|
SetCombatRoundForAlerts();
|
||||||
BotGroupSay(this, "I do not have enough any ammo!");
|
BotGroupSay(this, "I do not have any ammo!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1955,21 +1955,17 @@ bool Bot::BotRangedAttack(Mob* other, bool can_double_attack) {
|
|||||||
|
|
||||||
SendItemAnimation(other, ammo, (ranged_weapon->ItemType == EQ::item::ItemTypeBow ? EQ::skills::SkillArchery : EQ::skills::SkillThrowing));
|
SendItemAnimation(other, ammo, (ranged_weapon->ItemType == EQ::item::ItemTypeBow ? EQ::skills::SkillArchery : EQ::skills::SkillThrowing));
|
||||||
if (ranged_weapon->ItemType == EQ::item::ItemTypeBow) {
|
if (ranged_weapon->ItemType == EQ::item::ItemTypeBow) {
|
||||||
DoArcheryAttackDmg(other, ranged_item, ammo_item); // watch
|
DoArcheryAttackDmg(other, ranged_item, ammo_item);
|
||||||
//EndlessQuiver AA base1 = 100% Chance to avoid consumption arrow.
|
|
||||||
int ChanceAvoidConsume = aabonuses.ConsumeProjectile + itembonuses.ConsumeProjectile + spellbonuses.ConsumeProjectile;
|
|
||||||
|
|
||||||
// Consume Ammo, unless Ammo Consumption is disabled or player has Endless Quiver
|
int chance_avoid_consume = aabonuses.ConsumeProjectile + itembonuses.ConsumeProjectile + spellbonuses.ConsumeProjectile;
|
||||||
bool consumes_ammo = RuleB(Bots, BotArcheryConsumesAmmo);
|
bool consumes_ammo = RuleB(Bots, BotArcheryConsumesAmmo);
|
||||||
if (
|
bool is_expendable_arrow = ranged_weapon->ExpendableArrow;
|
||||||
consumes_ammo &&
|
bool no_chance_to_avoid = chance_avoid_consume == 0;
|
||||||
(
|
bool failed_avoid_check = chance_avoid_consume < 100 && zone->random.Int(0, 99) > chance_avoid_consume;
|
||||||
ranged_weapon->ExpendableArrow ||
|
bool should_consume_ammo = consumes_ammo && (is_expendable_arrow || no_chance_to_avoid || failed_avoid_check);
|
||||||
!ChanceAvoidConsume ||
|
|
||||||
(ChanceAvoidConsume < 100 && zone->random.Int(0, 99) > ChanceAvoidConsume)
|
if (should_consume_ammo) {
|
||||||
)
|
ammo_item->SetCharges(ammo_item->GetCharges() - 1);
|
||||||
) {
|
|
||||||
ammo_item->SetCharges((ammo_item->GetCharges() - 1));
|
|
||||||
LogCombatDetail("Consumed Archery Ammo from slot {}.", EQ::invslot::slotAmmo);
|
LogCombatDetail("Consumed Archery Ammo from slot {}.", EQ::invslot::slotAmmo);
|
||||||
|
|
||||||
if (ammo_item->GetCharges() < 1) {
|
if (ammo_item->GetCharges() < 1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user