Skip to content

[MultiWeapon] Use WeaponX #1630

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

a851903106
Copy link
Contributor

@a851903106 a851903106 commented Apr 16, 2025

Technology types are free to enable WeaponX and use them as usable weapons.

  • TechnoType reads WeaponX as their weapon when MultiWeapon=yes, be careful not to forget WeaponCount.
  • MultiWeapon.IsSecondary can only be used for infantry and is responsible for determining which weapons should use SecondaryFire in the Sequence.

In rulesmd.ini:

[SOMETECHNO]          ; TechnoType
MultiWeapon=          ; boolean

[SOMEINFANTRY]                 ; InfantryType
MultiWeapon.IsSecondary=       ; List of integers

科技类型可以自由启用WeaponX并将它们作为可用武器使用。

  • MultiWeapon=yes时科技类型会读取WeaponX作为它的武器,同时注意不要忘记写WeaponCount
  • MultiWeapon.IsSecondary只对步兵有效,它会负责判断哪些武器开火时播放副武器动作帧。

Copy link

github-actions bot commented Apr 16, 2025

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

@a851903106 a851903106 changed the title [Multi Weapon] Free use of WeaponX [Multi Weapon] Use WeaponX Apr 16, 2025
@a851903106 a851903106 changed the title [Multi Weapon] Use WeaponX [MultiWeapon] Use WeaponX Apr 16, 2025
@TaranDahl TaranDahl added ❓New feature ⚙️T2 T2 maintainer review is sufficient labels Apr 16, 2025
@Coronia Coronia added the Tested label Apr 17, 2025

const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType());

if (pTypeExt && pTypeExt->MultiWeapon.Get() &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to do sanity check for pTypeExt

bool TechnoExt::CheckMultiWeapon(TechnoClass* const pThis, AbstractClass* const pTarget, WeaponTypeClass* const pWeaponType)
{
if (!pThis || !pWeaponType || pWeaponType->NeverUse ||
!pWeaponType->Projectile || !pWeaponType->Warhead ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to check if Projectile or Warhead exist since they'll still crash elsewhere

if (pTargetTechno->Health <= 0 || !pTargetTechno->IsAlive)
return false;

if (const auto pTargetExt = TechnoExt::ExtMap.Find(pTargetTechno))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, no need to do sanity check for pTargetExt

}

if (GeneralUtils::GetWarheadVersusArmor(pWH, pTargetTechno->GetTechnoType()->Armor) == 0.0)
return false;
Copy link
Contributor

@Coronia Coronia Apr 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is wrong when having a shield with a different armor that could be targeted. Should check it separately

if (pShield || pShield->IsActive())
{ // shield checking }
else if (GeneralUtils::GetWarheadVersusArmor(pWH, pTargetTechno->GetTechnoType()->Armor) == 0.0)
{ return false; }


const auto pBld = abstract_cast<BuildingClass*>(pTargetTechno);

if (!pBld || !pBld->Type || !pBld->Type->Overpowerable)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to check if pBld->Type exists

@@ -996,6 +996,11 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
.Process(this->Overload_DeathSound)
.Process(this->Overload_ParticleSys)
.Process(this->Overload_ParticleSysCount)

.Process(this->MultiWeapon)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong spacing

INI_EX exINI(pINI);
const char* pSection = pThis->ID;

if (const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pThis))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since there's pThis->ID above, I'm assuming pThis will always be not null. In this case this sanity check is not needed

GET(TechnoTypeClass*, pThis, EBP);
enum { ReadWeaponX = 0x715B1F, Continue = 0x715B17 };

if (const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pThis))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check if pThis here is always not null too

}

// maybe it could be used as a new SelectWeapon, but not for now.
bool TechnoExt::CheckMultiWeapon(TechnoClass* const pThis, AbstractClass* const pTarget, WeaponTypeClass* const pWeaponType)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that this function is not being used yet?

if (pWH->Parasite && (pTargetTechno->WhatAmI() == AbstractType::Building ||
abstract_cast<FootClass*>(pTargetTechno)->ParasiteEatingMe))
return false;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, maybe armor versus check can be put to here to save as many as calculations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❓New feature ⚙️T2 T2 maintainer review is sufficient Tested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants