Skip to content

Commit

Permalink
移除 NoRepeatFire 相关功能,改为使用武器的 AttachEffect 功能
Browse files Browse the repository at this point in the history
  • Loading branch information
CrimRecya committed Dec 29, 2024
1 parent a7639c6 commit 6dbe50b
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 45 deletions.
3 changes: 0 additions & 3 deletions src/Ext/Techno/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,6 @@ void TechnoExt::ExtData::Serialize(T& Stm)
.Process(this->LastWeaponType)
.Process(this->LastWeaponFLH)
.Process(this->LastHurtFrame)
.Process(this->LastBeLockedFrame)
.Process(this->LastLockedMeID)
.Process(this->LastLockedMeWH)
.Process(this->LastBeControlledFrame)
.Process(this->LastTargetID)
.Process(this->AccumulatedGattlingValue)
Expand Down
6 changes: 0 additions & 6 deletions src/Ext/Techno/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ class TechnoExt
WeaponTypeClass* LastWeaponType;
CoordStruct LastWeaponFLH;
int LastHurtFrame;
int LastBeLockedFrame;
DWORD LastLockedMeID;
WarheadTypeClass* LastLockedMeWH;
int LastBeControlledFrame;
DWORD LastTargetID;
int AccumulatedGattlingValue;
Expand Down Expand Up @@ -107,9 +104,6 @@ class TechnoExt
, LastWeaponType {}
, LastWeaponFLH {}
, LastHurtFrame { 0 }
, LastBeLockedFrame { 0 }
, LastLockedMeID { 0xFFFFFFFF }
, LastLockedMeWH { nullptr }
, LastBeControlledFrame { 0 }
, LastTargetID { 0xFFFFFFFF }
, AccumulatedGattlingValue { 0 }
Expand Down
24 changes: 6 additions & 18 deletions src/Ext/Techno/Hooks.Firing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,19 +274,6 @@ DEFINE_HOOK(0x6FC339, TechnoClass_CanFire, 0x6)
const auto pTechno = abstract_cast<TechnoClass*>(pTarget);
CellClass* pTargetCell = nullptr;

if (pWeaponExt->NoRepeatFire > 0)
{
if (const auto pTargetTechnoExt = TechnoExt::ExtMap.Find(pTechno))
{
if ((pTargetTechnoExt->LastLockedMeID != pThis->UniqueID || !pWeaponExt->NoRepeatFire_IgnoreSameFirer)
&& (pTargetTechnoExt->LastLockedMeWH == pWeapon->Warhead || !pWeaponExt->NoRepeatFire_OnlySameWarhead)
&& ((Unsorted::CurrentFrame - pTargetTechnoExt->LastBeLockedFrame) < pWeaponExt->NoRepeatFire))
{
return CannotFire;
}
}
}

// AAOnly doesn't need to be checked if LandTargeting=1.
if (pThis->GetTechnoType()->LandTargeting != LandTargetingType::Land_Not_OK && pWeapon->Projectile->AA && pTarget && !pTarget->IsInAir())
{
Expand Down Expand Up @@ -478,13 +465,14 @@ DEFINE_HOOK(0x6FDDC0, TechnoClass_FireAt_DiscardAEOnFire, 0x6)

if (const auto pWeaponExt = WeaponTypeExt::ExtMap.Find(pWeapon))
{
if (pWeaponExt->NoRepeatFire > 0)
if (pWeaponExt->AttachEffect_Enable)
{
if (const auto pTargetTechnoExt = TechnoExt::ExtMap.Find(abstract_cast<TechnoClass*>(pTarget)))
if (const auto pTargetTechno = abstract_cast<TechnoClass*>(pTarget))
{
pTargetTechnoExt->LastBeLockedFrame = Unsorted::CurrentFrame;
pTargetTechnoExt->LastLockedMeID = pTarget->UniqueID;
pTargetTechnoExt->LastLockedMeWH = pWeapon->Warhead;
auto const& info = pWeaponExt->AttachEffects;
AttachEffectClass::Attach(pTargetTechno, pThis->Owner, pThis, pWeapon, info);
AttachEffectClass::Detach(pTargetTechno, info);
AttachEffectClass::DetachByGroups(pTargetTechno, info);
}
}
}
Expand Down
13 changes: 7 additions & 6 deletions src/Ext/WeaponType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ void WeaponTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->ExtraWarheads_FullDetonation.Read(exINI, pSection, "ExtraWarheads.FullDetonation");
this->AmbientDamage_Warhead.Read<true>(exINI, pSection, "AmbientDamage.Warhead");
this->AmbientDamage_IgnoreTarget.Read(exINI, pSection, "AmbientDamage.IgnoreTarget");

// AttachEffect
this->AttachEffects.LoadFromINI(pINI, pSection);
this->AttachEffect_Enable = (this->AttachEffects.AttachTypes.size() > 0 || this->AttachEffects.RemoveTypes.size() > 0 || this->AttachEffects.RemoveGroups.size() > 0);

this->AttachEffect_RequiredTypes.Read(exINI, pSection, "AttachEffect.RequiredTypes");
this->AttachEffect_DisallowedTypes.Read(exINI, pSection, "AttachEffect.DisallowedTypes");
exINI.ParseStringList(this->AttachEffect_RequiredGroups, pSection, "AttachEffect.RequiredGroups");
Expand All @@ -119,9 +124,6 @@ void WeaponTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->KeepRange_AllowAI.Read(exINI, pSection, "KeepRange.AllowAI");
this->KeepRange_AllowPlayer.Read(exINI, pSection, "KeepRange.AllowPlayer");
this->Burst_NoDelay.Read(exINI, pSection, "Burst.NoDelay");
this->NoRepeatFire.Read(exINI, pSection, "NoRepeatFire");
this->NoRepeatFire_IgnoreSameFirer.Read(exINI, pSection, "NoRepeatFire.IgnoreSameFirer");
this->NoRepeatFire_OnlySameWarhead.Read(exINI, pSection, "NoRepeatFire.OnlySameWarhead");
this->KickOutPassengers.Read(exINI, pSection, "KickOutPassengers");

this->Beam_Color.Read(exINI, pSection, "Beam.Color");
Expand Down Expand Up @@ -163,6 +165,8 @@ void WeaponTypeExt::ExtData::Serialize(T& Stm)
.Process(this->ExtraWarheads_FullDetonation)
.Process(this->AmbientDamage_Warhead)
.Process(this->AmbientDamage_IgnoreTarget)
.Process(this->AttachEffects)
.Process(this->AttachEffect_Enable)
.Process(this->AttachEffect_RequiredTypes)
.Process(this->AttachEffect_DisallowedTypes)
.Process(this->AttachEffect_RequiredGroups)
Expand All @@ -177,9 +181,6 @@ void WeaponTypeExt::ExtData::Serialize(T& Stm)
.Process(this->KeepRange_AllowAI)
.Process(this->KeepRange_AllowPlayer)
.Process(this->Burst_NoDelay)
.Process(this->NoRepeatFire)
.Process(this->NoRepeatFire_IgnoreSameFirer)
.Process(this->NoRepeatFire_OnlySameWarhead)
.Process(this->KickOutPassengers)
.Process(this->Beam_Color)
.Process(this->Beam_Duration)
Expand Down
10 changes: 4 additions & 6 deletions src/Ext/WeaponType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class WeaponTypeExt
ValueableVector<bool> ExtraWarheads_FullDetonation;
Nullable<WarheadTypeClass*> AmbientDamage_Warhead;
Valueable<bool> AmbientDamage_IgnoreTarget;
AEAttachInfoTypeClass AttachEffects;
Valueable<bool> AttachEffect_Enable;
ValueableVector<AttachEffectTypeClass*> AttachEffect_RequiredTypes;
ValueableVector<AttachEffectTypeClass*> AttachEffect_DisallowedTypes;
std::vector<std::string> AttachEffect_RequiredGroups;
Expand All @@ -64,9 +66,6 @@ class WeaponTypeExt
Valueable<bool> KeepRange_AllowAI;
Valueable<bool> KeepRange_AllowPlayer;
Valueable<bool> Burst_NoDelay;
Valueable<int> NoRepeatFire;
Valueable<int> NoRepeatFire_IgnoreSameFirer;
Valueable<int> NoRepeatFire_OnlySameWarhead;
Valueable<bool> KickOutPassengers;

Nullable<ColorStruct> Beam_Color;
Expand Down Expand Up @@ -104,6 +103,8 @@ class WeaponTypeExt
, ExtraWarheads_FullDetonation {}
, AmbientDamage_Warhead {}
, AmbientDamage_IgnoreTarget { false }
, AttachEffects {}
, AttachEffect_Enable { false }
, AttachEffect_RequiredTypes {}
, AttachEffect_DisallowedTypes {}
, AttachEffect_RequiredGroups {}
Expand All @@ -118,9 +119,6 @@ class WeaponTypeExt
, KeepRange_AllowAI { false }
, KeepRange_AllowPlayer { false }
, Burst_NoDelay { false }
, NoRepeatFire { 0 }
, NoRepeatFire_IgnoreSameFirer { true }
, NoRepeatFire_OnlySameWarhead { true }
, KickOutPassengers { true }
, Beam_Color {}
, Beam_Duration { 15 }
Expand Down
4 changes: 2 additions & 2 deletions src/New/Entity/AttachEffectClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ bool AttachEffectClass::IsFromSource(TechnoClass* pInvoker, AbstractClass* pSour
/// <param name="pTarget">Target techno.</param>
/// <param name="pInvokerHouse">House that invoked the attachment.</param>
/// <param name="pInvoker">Techno that invoked the attachment.</param>
/// <param name="pSource">Source object for the attachment e.g a Warhead or Techno.</param>
/// <param name="pSource">Source object for the attachment e.g a Weapon, Warhead or Techno.</param>
/// <param name="attachEffectInfo">AttachEffect attach info.</param>
/// <returns>Number of AttachEffect instances created and attached.</returns>
int AttachEffectClass::Attach(TechnoClass* pTarget, HouseClass* pInvokerHouse, TechnoClass* pInvoker, AbstractClass* pSource, AEAttachInfoTypeClass const& attachEffectInfo)
Expand Down Expand Up @@ -547,7 +547,7 @@ int AttachEffectClass::Attach(TechnoClass* pTarget, HouseClass* pInvokerHouse, T
/// <param name="targetAEs">Target's AttachEffect vector</param>
/// <param name="pInvokerHouse">House that invoked the attachment.</param>
/// <param name="pInvoker">Techno that invoked the attachment.</param>
/// <param name="pSource">Source object for the attachment e.g a Warhead or Techno.</param>
/// <param name="pSource">Source object for the attachment e.g a Weapon, Warhead or Techno.</param>
/// <param name="attachParams">Attachment parameters.</param>
/// <returns>The created and attached AttachEffect if successful, nullptr if not.</returns>
AttachEffectClass* AttachEffectClass::CreateAndAttach(AttachEffectTypeClass* pType, TechnoClass* pTarget, std::vector<std::unique_ptr<AttachEffectClass>>& targetAEs,
Expand Down
19 changes: 15 additions & 4 deletions 整合包说明/额外功能说明.md
Original file line number Diff line number Diff line change
Expand Up @@ -662,15 +662,26 @@ UniqueTechno=no ; 布尔值,该单位是否被视
- 开关时显示的提示信息,可以在csf中添加名为 `TXT_HEROS_VISIBLE` 和 `TXT_HEROS_INVISIBLE` 的项目来分别定义开和关时显示的文本
```

### 29. 避免武器同帧火力溢出( 暂无pr )
### 29. 开火瞬间附加或移除AE( 暂无pr )

`rulesmd.ini` 之中:

```ini
[SOMEWEAPON] ; 任意武器
NoRepeatFire=0 ; 整数型,任何单位使用该值为正数的武器向目标开火时会将目标标记,而后若又有某个单位使用该值为正数的武器尝试攻击这个目标时,会在这么多帧内(使用后者的值)不能向其开火,即当前时间与上一次目标被标记的时间需要大于该值时才能朝目标开火
NoRepeatFire.IgnoreSameFirer=yes ; 布尔值,是否忽略来自相同开火者的检查,即相同的开火者不会受到这个限制(注意与AE不同,开火者的记录是会被覆盖的)
NoRepeatFire.OnlySameWarhead=yes ; 布尔值,是否只有拥有相同弹头的武器需要检查,即使用相同的弹头才会受到这个限制(注意与AE不同,弹头的记录是会被覆盖的)
AttachEffect.AttachTypes=
AttachEffect.CumulativeRefreshAll=false
AttachEffect.CumulativeRefreshAll.OnAttach=false
AttachEffect.CumulativeRefreshSameSourceOnly=true
AttachEffect.RemoveTypes=
AttachEffect.RemoveGroups=
AttachEffect.CumulativeRemoveMinCounts=
AttachEffect.CumulativeRemoveMaxCounts=
AttachEffect.DurationOverrides=
```

```{note}
- 懒得写了,和弹头的类似,公版说明书都有
- 在开火后抛体生成的瞬间附加或移除,即会先判断 `AttachEffect.RequiredTypes` 等等条件
```

### 30. 自定义激光围墙( 暂无pr )
Expand Down

0 comments on commit 6dbe50b

Please sign in to comment.