configID checks for Rapid Fire

This commit is contained in:
Joaquin 2022-08-05 19:53:20 -06:00
parent 92cc932852
commit 41a53fde48

View File

@ -80,7 +80,7 @@ namespace cheat::feature
} }
bool RapidFire::NeedStatusDraw() const bool RapidFire::NeedStatusDraw() const
{ {
return f_Enabled && (f_MultiHit || f_MultiTarget); return f_Enabled && (f_MultiHit || f_MultiTarget);
} }
@ -183,6 +183,20 @@ namespace cheat::feature
return attackerID == avatarID || IsAvatarOwner(attacker); return attackerID == avatarID || IsAvatarOwner(attacker);
} }
bool IsConfigByAvatar(game::Entity& attacker)
{
if (attacker.raw() == nullptr)
return false;
auto& manager = game::EntityManager::instance();
auto avatarID = manager.avatar()->raw()->fields._configID_k__BackingField;
auto attackerID = attacker.raw()->fields._configID_k__BackingField;
// Taiga#5555: IDs can be found in ConfigAbility_Avatar_*.json or GadgetExcelConfigData.json
bool bulletID = attackerID >= 40000160 && attackerID <= 41069999;
return avatarID == attackerID || bulletID;
}
bool IsValidByFilter(game::Entity* entity) bool IsValidByFilter(game::Entity* entity)
{ {
if (game::filters::combined::OrganicTargets.IsValid(entity) || if (game::filters::combined::OrganicTargets.IsValid(entity) ||
@ -203,7 +217,7 @@ namespace cheat::feature
{ {
auto attacker = game::Entity(__this->fields._._._entity); auto attacker = game::Entity(__this->fields._._._entity);
RapidFire& rapidFire = RapidFire::GetInstance(); RapidFire& rapidFire = RapidFire::GetInstance();
if (!IsAttackByAvatar(attacker) || !rapidFire.f_Enabled) if (!IsConfigByAvatar(attacker) || !IsAttackByAvatar(attacker) || !rapidFire.f_Enabled)
return CALL_ORIGIN(LCBaseCombat_DoHitEntity_Hook, __this, targetID, attackResult, ignoreCheckCanBeHitInMP, method); return CALL_ORIGIN(LCBaseCombat_DoHitEntity_Hook, __this, targetID, attackResult, ignoreCheckCanBeHitInMP, method);
auto& manager = game::EntityManager::instance(); auto& manager = game::EntityManager::instance();
@ -243,7 +257,8 @@ namespace cheat::feature
int attackCount = rapidFire.GetAttackCount(__this, entity->runtimeID(), attackResult); int attackCount = rapidFire.GetAttackCount(__this, entity->runtimeID(), attackResult);
for (int i = 0; i < attackCount; i++) for (int i = 0; i < attackCount; i++)
CALL_ORIGIN(LCBaseCombat_DoHitEntity_Hook, __this, entity->runtimeID(), attackResult, ignoreCheckCanBeHitInMP, method); CALL_ORIGIN(LCBaseCombat_DoHitEntity_Hook, __this, entity->runtimeID(), attackResult, ignoreCheckCanBeHitInMP, method);
} else CALL_ORIGIN(LCBaseCombat_DoHitEntity_Hook, __this, entity->runtimeID(), attackResult, ignoreCheckCanBeHitInMP, method); }
else CALL_ORIGIN(LCBaseCombat_DoHitEntity_Hook, __this, entity->runtimeID(), attackResult, ignoreCheckCanBeHitInMP, method);
} }
} }
} }