Skip to content

Commit

Permalink
Allow disabling OpenTopped weapons if transport has DisableWeapons AE
Browse files Browse the repository at this point in the history
  • Loading branch information
Starkku committed Jun 16, 2024
1 parent d7e4616 commit f8bc5c0
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 76 deletions.
132 changes: 67 additions & 65 deletions docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ This page describes all the engine features that are either new and introduced b
- `RevengeWeapon` can be used to temporarily grant the specified weapon as a [revenge weapon](#revenge-weapon) for the attached object.
- `RevengeWeapon.AffectsHouses` customizes which houses can trigger the revenge weapon.
- `DisableWeapons` can be used to disable ability to fire any and all weapons.
- On TechnoTypes with `OpenTopped=true`, `OpenTopped.CheckTransportDisableWeapons` can be set to true to make passengers not be able to fire out if transport's weapons are disabled by `DisableWeapons`.
- It is possible to set groups for attach effect types by defining strings in `Groups`.
- Groups can be used instead of types for removing effects and weapon filters.

Expand Down Expand Up @@ -66,71 +67,72 @@ In `rulesmd.ini`:
[AttachEffectTypes]
0=SOMEATTACHEFFECT

[SOMEATTACHEFFECT] ; AttachEffectType
Duration=0 ; integer - game frames or negative value for indefinite duration
Cumulative=false ; boolean
Cumulative.MaxCount=-1 ; integer
Powered=false ; boolean
DiscardOn=none ; list of discard condition enumeration (none|entry|move|stationary|drain)
PenetratesIronCurtain=false ; boolean
Animation= ; Animation
Animation.ResetOnReapply=false ; boolean
Animation.OfflineAction=Hides ; AttachedAnimFlag (None, Hides, Temporal, Paused or PausedTemporal)
Animation.TemporalAction=None ; AttachedAnimFlag (None, Hides, Temporal, Paused or PausedTemporal)
Animation.UseInvokerAsOwner=false ; boolean
CumulativeAnimations= ; list of animations
ExpireWeapon=
ExpireWeapon.TriggerOn=expire ; List of expire weapon trigger condition enumeration (none|expire|remove|death|all)
ExpireWeapon.CumulativeOnlyOnce=false ; boolean
Tint.Color= ; integer - R,G,B
Tint.Intensity= ; floating point value
Tint.VisibleToHouses=all ; list of Affected House Enumeration (none|owner/self|allies/ally|team|enemies/enemy|all)
FirepowerMultiplier=1.0 ; floating point value
ArmorMultiplier=1.0 ; floating point value
SpeedMultiplier=1.0 ; floating point value
ROFMultiplier=1.0 ; floating point value
ROFMultiplier.ApplyOnCurrentTimer=true ; boolean
Cloakable=false ; boolean
ForceDecloak=false ; boolean
WeaponRange.Multiplier=1.0 ; floating point value
WeaponRange.ExtraRange=0.0 ; floating point value
WeaponRange.AllowWeapons= ; list of WeaponTypes
WeaponRange.DisallowWeapons= ; list of WeaponTypes
Crit.Multiplier=1.0 ; floating point value
Crit.ExtraChance=0.0 ; floating point value
Crit.AllowWarheads= ; list of WarheadTypes
Crit.DisallowWarheads= ; list of WarheadTypes
RevengeWeapon= ; WeaponType
RevengeWeapon.AffectsHouses=all ; list of Affected House Enumeration (none|owner/self|allies/ally|team|enemies/enemy|all)
DisableWeapons=false ; boolean
Groups= ; comma-separated list of strings (group IDs)

[SOMETECHNO] ; TechnoType
AttachEffect.AttachTypes= ; List of AttachEffectTypes
AttachEffect.DurationOverrides= ; integer - duration overrides (comma-separated) for AttachTypes in order from first to last.
AttachEffect.Delays= ; integer - delays (comma-separated) for AttachTypes in order from first to last.
AttachEffect.InitialDelays= ; integer - initial delays (comma-separated) for AttachTypes in order from first to last.
AttachEffect.RecreationDelays= ; integer - recreation delays (comma-separated) for AttachTypes in order from first to last.
OpenTopped.UseTransportRangeModifiers=false ; boolean

[SOMEWEAPON] ; WeaponType
AttachEffect.RequiredTypes= ; List of AttachEffectTypes
AttachEffect.DisallowedTypes= ; List of AttachEffectTypes
AttachEffect.RequiredGroups= ; comma-separated list of strings (group IDs)
AttachEffect.DisallowedGroups= ; comma-separated list of strings (group IDs)
AttachEffect.RequiredMinCounts= ; integer - minimum required instance count (comma-separated) for cumulative types in order from first to last.
AttachEffect.RequiredMaxCounts= ; integer - maximum required instance count (comma-separated) for cumulative types in order from first to last.
AttachEffect.DisallowedMinCounts= ; integer - minimum disallowed instance count (comma-separated) for cumulative types in order from first to last.
AttachEffect.DisallowedMaxCounts= ; integer - maximum disallowed instance count (comma-separated) for cumulative types in order from first to last.
AttachEffect.IgnoreFromSameSource=false ; boolean

[SOMEWARHEAD]
AttachEffect.AttachTypes= ; List of AttachEffectTypes
AttachEffect.RemoveTypes= ; List of AttachEffectTypes
AttachEffect.RemoveGroups= ; comma-separated list of strings (group IDs)
AttachEffect.CumulativeRemoveMinCounts= ; integer - minimum required instance count (comma-separated) for cumulative types in order from first to last.
AttachEffect.CumulativeRemoveMaxCounts= ; integer - maximum removed instance count (comma-separated) for cumulative types in order from first to last.
AttachEffect.DurationOverrides= ; integer - duration overrides (comma-separated) for AttachTypes in order from first to last.
[SOMEATTACHEFFECT] ; AttachEffectType
Duration=0 ; integer - game frames or negative value for indefinite duration
Cumulative=false ; boolean
Cumulative.MaxCount=-1 ; integer
Powered=false ; boolean
DiscardOn=none ; list of discard condition enumeration (none|entry|move|stationary|drain)
PenetratesIronCurtain=false ; boolean
Animation= ; Animation
Animation.ResetOnReapply=false ; boolean
Animation.OfflineAction=Hides ; AttachedAnimFlag (None, Hides, Temporal, Paused or PausedTemporal)
Animation.TemporalAction=None ; AttachedAnimFlag (None, Hides, Temporal, Paused or PausedTemporal)
Animation.UseInvokerAsOwner=false ; boolean
CumulativeAnimations= ; list of animations
ExpireWeapon=
ExpireWeapon.TriggerOn=expire ; List of expire weapon trigger condition enumeration (none|expire|remove|death|all)
ExpireWeapon.CumulativeOnlyOnce=false ; boolean
Tint.Color= ; integer - R,G,B
Tint.Intensity= ; floating point value
Tint.VisibleToHouses=all ; list of Affected House Enumeration (none|owner/self|allies/ally|team|enemies/enemy|all)
FirepowerMultiplier=1.0 ; floating point value
ArmorMultiplier=1.0 ; floating point value
SpeedMultiplier=1.0 ; floating point value
ROFMultiplier=1.0 ; floating point value
ROFMultiplier.ApplyOnCurrentTimer=true ; boolean
Cloakable=false ; boolean
ForceDecloak=false ; boolean
WeaponRange.Multiplier=1.0 ; floating point value
WeaponRange.ExtraRange=0.0 ; floating point value
WeaponRange.AllowWeapons= ; list of WeaponTypes
WeaponRange.DisallowWeapons= ; list of WeaponTypes
Crit.Multiplier=1.0 ; floating point value
Crit.ExtraChance=0.0 ; floating point value
Crit.AllowWarheads= ; list of WarheadTypes
Crit.DisallowWarheads= ; list of WarheadTypes
RevengeWeapon= ; WeaponType
RevengeWeapon.AffectsHouses=all ; list of Affected House Enumeration (none|owner/self|allies/ally|team|enemies/enemy|all)
DisableWeapons=false ; boolean
Groups= ; comma-separated list of strings (group IDs)

[SOMETECHNO] ; TechnoType
AttachEffect.AttachTypes= ; List of AttachEffectTypes
AttachEffect.DurationOverrides= ; integer - duration overrides (comma-separated) for AttachTypes in order from first to last.
AttachEffect.Delays= ; integer - delays (comma-separated) for AttachTypes in order from first to last.
AttachEffect.InitialDelays= ; integer - initial delays (comma-separated) for AttachTypes in order from first to last.
AttachEffect.RecreationDelays= ; integer - recreation delays (comma-separated) for AttachTypes in order from first to last.
OpenTopped.UseTransportRangeModifiers=false ; boolean
OpenTopped.CheckTransportDisableWeapons=false ; boolean

[SOMEWEAPON] ; WeaponType
AttachEffect.RequiredTypes= ; List of AttachEffectTypes
AttachEffect.DisallowedTypes= ; List of AttachEffectTypes
AttachEffect.RequiredGroups= ; comma-separated list of strings (group IDs)
AttachEffect.DisallowedGroups= ; comma-separated list of strings (group IDs)
AttachEffect.RequiredMinCounts= ; integer - minimum required instance count (comma-separated) for cumulative types in order from first to last.
AttachEffect.RequiredMaxCounts= ; integer - maximum required instance count (comma-separated) for cumulative types in order from first to last.
AttachEffect.DisallowedMinCounts= ; integer - minimum disallowed instance count (comma-separated) for cumulative types in order from first to last.
AttachEffect.DisallowedMaxCounts= ; integer - maximum disallowed instance count (comma-separated) for cumulative types in order from first to last.
AttachEffect.IgnoreFromSameSource=false ; boolean

[SOMEWARHEAD]
AttachEffect.AttachTypes= ; List of AttachEffectTypes
AttachEffect.RemoveTypes= ; List of AttachEffectTypes
AttachEffect.RemoveGroups= ; comma-separated list of strings (group IDs)
AttachEffect.CumulativeRemoveMinCounts= ; integer - minimum required instance count (comma-separated) for cumulative types in order from first to last.
AttachEffect.CumulativeRemoveMaxCounts= ; integer - maximum removed instance count (comma-separated) for cumulative types in order from first to last.
AttachEffect.DurationOverrides= ; integer - duration overrides (comma-separated) for AttachTypes in order from first to last.
```

### Custom Radiation Types
Expand Down
25 changes: 14 additions & 11 deletions src/Ext/Techno/Hooks.Firing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,22 +334,25 @@ DEFINE_HOOK(0x6FC0C5, TechnoClass_CanFire_DisableWeapons, 0x6)
return Continue;
}

DEFINE_HOOK(0x6FC587, TechnoClass_CanFire_OpenTopped, 0x6)
DEFINE_HOOK(0x6FC5C7, TechnoClass_CanFire_OpenTopped, 0x6)
{
enum { DisallowFiring = 0x6FC86A };
enum { Illegal = 0x6FC86A, OutOfRange = 0x6FC0DF, Continue = 0x6FC5D5 };

GET(TechnoClass*, pThis, ESI);

Check warning on line 341 in src/Ext/Techno/Hooks.Firing.cpp

View workflow job for this annotation

GitHub Actions / build

'pThis': local variable is initialized but not referenced [D:\a\Phobos\Phobos\Phobos.vcxproj]

Check warning on line 341 in src/Ext/Techno/Hooks.Firing.cpp

View workflow job for this annotation

GitHub Actions / build

GET(TechnoClass*, pThis, ESI); [D:\a\Phobos\Phobos\Phobos.vcxproj]

Check warning on line 341 in src/Ext/Techno/Hooks.Firing.cpp

View workflow job for this annotation

GitHub Actions / build

^ [D:\a\Phobos\Phobos\Phobos.vcxproj]
GET(TechnoClass*, pTransport, EAX);

if (auto const pTransport = pThis->Transporter)
{
if (auto pExt = TechnoTypeExt::ExtMap.Find(pTransport->GetTechnoType()))
{
if (pTransport->Deactivated && !pExt->OpenTopped_AllowFiringIfDeactivated)
return DisallowFiring;
}
}
auto const pTypeExt = TechnoTypeExt::ExtMap.Find(pTransport->GetTechnoType());

return 0;
if (pTransport->Deactivated && !pTypeExt->OpenTopped_AllowFiringIfDeactivated)
return Illegal;

if (pTransport->Transporter)
return Illegal;

if (pTypeExt->OpenTopped_CheckTransportDisableWeapons && TechnoExt::ExtMap.Find(pTransport)->AE_DisableWeapons)
return OutOfRange;

return Continue;
}

DEFINE_HOOK(0x6FC689, TechnoClass_CanFire_LandNavalTarget, 0x6)
Expand Down
2 changes: 2 additions & 0 deletions src/Ext/TechnoType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->OpenTopped_AllowFiringIfDeactivated.Read(exINI, pSection, "OpenTopped.AllowFiringIfDeactivated");
this->OpenTopped_ShareTransportTarget.Read(exINI, pSection, "OpenTopped.ShareTransportTarget");
this->OpenTopped_UseTransportRangeModifiers.Read(exINI, pSection, "OpenTopped.UseTransportRangeModifiers");
this->OpenTopped_CheckTransportDisableWeapons.Read(exINI, pSection, "OpenTopped.CheckTransportDisableWeapons");

this->AutoFire.Read(exINI, pSection, "AutoFire");
this->AutoFire_TargetSelf.Read(exINI, pSection, "AutoFire.TargetSelf");
Expand Down Expand Up @@ -548,6 +549,7 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
.Process(this->OpenTopped_AllowFiringIfDeactivated)
.Process(this->OpenTopped_ShareTransportTarget)
.Process(this->OpenTopped_UseTransportRangeModifiers)
.Process(this->OpenTopped_CheckTransportDisableWeapons)

.Process(this->AutoFire)
.Process(this->AutoFire_TargetSelf)
Expand Down
2 changes: 2 additions & 0 deletions src/Ext/TechnoType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class TechnoTypeExt
Valueable<bool> OpenTopped_AllowFiringIfDeactivated;
Valueable<bool> OpenTopped_ShareTransportTarget;
Valueable<bool> OpenTopped_UseTransportRangeModifiers;
Valueable<bool> OpenTopped_CheckTransportDisableWeapons;

Valueable<bool> AutoFire;
Valueable<bool> AutoFire_TargetSelf;
Expand Down Expand Up @@ -296,6 +297,7 @@ class TechnoTypeExt
, OpenTopped_AllowFiringIfDeactivated { true }
, OpenTopped_ShareTransportTarget { true }
, OpenTopped_UseTransportRangeModifiers { false }
, OpenTopped_CheckTransportDisableWeapons { false }

, AutoFire { false }
, AutoFire_TargetSelf { false }
Expand Down

0 comments on commit f8bc5c0

Please sign in to comment.