Skip to content
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

Block damage system #1390

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ This page lists all the individual contributions to the project by their author.
- **Ollerus**
- Build limit group enhancement
- Customizable rocker amplitude
- Damage blocking system
- **handama** - AI script action to jump back to previous script
- **Ares developers**
- YRpp and Syringe which are used, save/load, project foundation and generally useful code from Ares
Expand Down
2 changes: 2 additions & 0 deletions Phobos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<ItemGroup>
<ClCompile Include="src\Ext\Techno\Hooks.Cloak.cpp" />
<ClCompile Include="src\New\Entity\AttachEffectClass.cpp" />
<ClCompile Include="src\New\Type\Affiliated\BlockTypeClass.cpp" />
<ClCompile Include="src\New\Type\AttachEffectTypeClass.cpp" />
<ClCompile Include="src\Commands\Commands.cpp" />
<ClCompile Include="src\Commands\DamageDisplay.cpp" />
Expand Down Expand Up @@ -183,6 +184,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\New\Entity\AttachEffectClass.h" />
<ClInclude Include="src\New\Type\Affiliated\BlockTypeClass.h" />
<ClInclude Include="src\New\Type\AttachEffectTypeClass.h" />
<ClInclude Include="src\Commands\FrameByFrame.h" />
<ClInclude Include="src\Commands\FrameStep.h" />
Expand Down
108 changes: 108 additions & 0 deletions docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ This page describes all the engine features that are either new and introduced b
- On TechnoTypes with `OpenTopped=true`, `OpenTopped.UseTransportRangeModifiers` can be set to true to make passengers firing out use the transport's active range bonuses instead.
- `Crit.Multiplier` and `Crit.ExtraChance` can be used to multiply the [critical hit](#chance-based-extra-damage-or-warhead-detonation--critical-hits) chance or grant a fixed bonus to it for the object the effect is attached to, respectively.
- `Crit.AllowWarheads` can be used to list only Warheads that can benefit from this critical hit chance multiplier and `Crit.DisallowWarheads` weapons that are not allowed to, respectively.
- `Block.ChanceMultiplier` and `Block.ExtraChance` can be used to multiply the [block](#block-damage) chance or grant a fixed bonus to it for the object the effect is attached to, respectively.
- `Block.DamageMult.Multiplier` and `Block.DamageMult.Bonus` can be used to multiply the [block](#block-damage) damage multiplier or grant a fixed bonus to it for the object the effect is attached to, respectively.
- `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.
- `ReflectDamage` can be set to true to have any positive damage dealt to the object the effect is attached to be reflected back to the attacker. `ReflectDamage.Warhead` determines which Warhead is used to deal the damage, defaults to `[CombatDamage]`->`C4Warhead`. If `ReflectDamage.Warhead` is set to true, the Warhead is fully detonated instead of used to simply deal damage. `ReflectDamage.Multiplier` is a multiplier to the damage received and then reflected back. Already reflected damage cannot be further reflected back.
Expand Down Expand Up @@ -111,6 +113,10 @@ Crit.Multiplier=1.0 ; floating point value
Crit.ExtraChance=0.0 ; floating point value
Crit.AllowWarheads= ; list of WarheadTypes
Crit.DisallowWarheads= ; list of WarheadTypes
Block.ChanceMultiplier=1.0 ; floating point value
Block.ExtraChance=0.0 ; floating point value
Block.DamageMult.Multiplier=1.0 ; floating point value
Block.DamageMult.Bonus=0.0 ; floating point value
RevengeWeapon= ; WeaponType
RevengeWeapon.AffectsHouses=all ; list of Affected House Enumeration (none|owner/self|allies/ally|team|enemies/enemy|all)
ReflectDamage=false ; boolean
Expand Down Expand Up @@ -153,6 +159,106 @@ SuppressReflectDamage=false ; boolean
SuppressReflectDamage.Types= ; List of AttachEffectTypes
```

### Block damage

- You can now make techno have a chance to block the incoming damage, which will make it multiply by a set percentage.
- `CanBlock`, if set to false, make this TechnoType can't trigger a block, even if the block settings are from warheads, or affected by [attached effects](#attached-effects) with block chance modifiers.
- `Block.Chances` determines chance for a block to occur. Value from position matching the position from `Block.AffectBelowPercents` is used if found, or 0.0 if not found.
- `Block.DamageMultipliers` determines the multiplier of received damage. Value from position matching the position from `Block.AffectBelowPercents` is used if found, or 1.0 if not found.
- `Block.AffectBelowPercents`, if set to a single value, determines minimum percentage of their maximum `Strength` that targets must have left to be affected by a critical hit. If set to a list of values, it'll further determine `Block.Chances` and `Block.DamageMultipliers` when target health is below the certain percentage listed here.
- `Block.AffectsHouses` can be used to customize houses that damage from this firer can be blocked. Notice that not all damage has a firer, such as damage dealt by anims.
- Following conditions determine whether a block can be triggered.
- `Block.CanActive.NoFirer` determines if the block can be triggered when the damage has no firer.
- `Block.CanActive.Powered` determines if the block can be triggered when the techno is deactivated (`PoweredUnit` or affected by EMP) or on low power.
- `Block.CanActive.ShieldActive` determines if the block can be triggered when the techno has an active [shield](#shields). If you only want it to be triggered by certain type of shield, you can further set `CanBlock` for them.
- `Block.CanActive.ShieldInactive` determines if the block can be triggered when the techno doesn't have an active shield.
- `Block.CanActive.ZeroDamage` and `Block.CanActive.NegativeDamage` determine if the block can be triggered when the damage is equal to or below 0. determines if the block can be triggered when the damage is below 0, respectively.
- `Block.CanActive.Move` and `Block.CanActive.Stationary`determines the block can be triggered when the techno is moving or not, respectively.
- `Block.Flash`, if set to true, makes it so that a light flash is generated when a block is triggered. Size of the flash is determined by damage dealt (based on original damage instead of the blocked one), unless `Block.Flash.FixedSize` is set to a number, in which case that value is used instead (range of values that produces visible effect are increments of 4 from 81 to 252, anything higher or below does not have effect). Color can be customized via `Block.Flash.Red/Green/Blue`. If `Block.Flash.Black` is set to true, the generated flash will be black regardless of other color settings.
- `Block.Anims` can be used to set animation to be displayed if a block is triggered. If more than one animation is listed, a random one is selected.
- `Block.Weapon`, if set, will be fired at the techno once a block is triggered.
- `Block.ReflectDamage` can be set to true to have positive damage dealt to the object to be reflected back to the attacker, if a block is triggered and there is a firer of the damage. `Block.ReflectDamage.Warhead` determines which Warhead is used to deal the damage, defaults to `[CombatDamage]`->`C4Warhead`. If `Block.ReflectDamage.Warhead.Detonate` is set to true, the Warhead is fully detonated instead of used to simply deal damage. `Block.ReflectDamage.Chance` determines the chance of reflection. - `Block.ReflectDamage.AffectsHouses` customizes which houses can trigger the reflect damage, default to `Block.AffectsHouses`. `Block.ReflectDamage.Multiplier` is a multiplier to the damage received and then reflected back (based on original damage instead of the blocked one), while `Block.ReflectDamage.Override` directly overrides the damage. Already reflected damage cannot be further reflected back.
- Warheads can prevent reflect damage from occuring by setting `SuppressReflectDamage` to true.

- Warheads can also use the above settings to determine their own block behaviors when hitting the target.
- Despite all block settings can be overridden, if you want to override `Block.Chances` or `Block.DamageMultipliers`, it's recommended to override `Block.AffectBelowPercents` in the meantime since they're lists with values in correpsonding positions.
- `Block.BasedOnWarhead`, if set to true, makes the warhead block settings as a base when calculating a block. If set to false, block settings on techno is used as a base.
- `Block.AllowOverride`, if set to true, allows the block settings from techno or warhead to override the other, if set. If `Block.BasedOnWarhead` is set to true, then it'll uses the set values from techno to override warheads', while keeping the unset values as the same. If it's set to false, then it'll do the override from warhead to techno with the same rule.
- `Block.IgnoreAttachEffect` can be set on WarheadTypes to make their attack ignore modifiers of `Block.Chances` and `Block.DamageMultipliers` from the [attached effects](#attached-effects) on the techno.
- `Block.ChanceMultiplier` and `Block.ExtraChance` can be set on WarheadTypes to multiply the block chance or grant a fixed bonus to it when these warheads hit their targets, respectively.
- `Block.DamageMult.Multiplier` and `Block.DamageMult.Bonus` can be set on WarheadTypes to multiply the block damage multiplier or grant a fixed bonus to it when these warheads hit their targets, respectively.
- `ImmuneToBlock` can be set on WarheadTypes to make them can't trigger a block.

In `rulesmd.ini`:
```ini
[SOMETECHNO] ; TechnoType
CanBlock=true ; boolean
Block.Chances= ; list of floating-point values (percentage or absolute) (0.0-1.0)
Block.DamageMultipliers= ; list of floating-point values (percentage or absolute)
Block.AffectBelowPercents= ; list of floating-point values (percentage or absolute) (0.0-1.0)
Block.AffectsHouses=all ; list of Affected House Enumeration (none|owner/self|allies/ally|team|enemies/enemy|all)
Block.CanActive.NoFirer=true ; boolean
Block.CanActive.Powered=false ; boolean
Block.CanActive.ShieldActive=true ; boolean
Block.CanActive.ShieldInactive=true ; boolean
Block.CanActive.ZeroDamage=false ; boolean
Block.CanActive.NegativeDamage=false ; boolean
Block.CanActive.Move=true ; boolean
Block.CanActive.Stationary=true ; boolean
Block.Flash=false ; boolean
Block.Flash.FixedSize= ; integer
Block.Flash.Red=true ; boolean
Block.Flash.Green=true ; boolean
Block.Flash.Blue=true ; boolean
Block.Flash.Black=false ; boolean
Block.Anims= ; list of animations
Block.Weapon= ; WeaponType
Block.ReflectDamage=false ; boolean
Block.ReflectDamage.Chance=1.0 ; floating point value
Block.ReflectDamage.Warhead= ; WarheadType
Block.ReflectDamage.Warhead.Detonate=false ; WarheadType
Block.ReflectDamage.Multiplier=1.0 ; floating point value, percents or absolute
Block.ReflectDamage.AffectsHouses= ; list of Affected House Enumeration (none|owner/self|allies/ally|team|enemies/enemy|all)
Block.ReflectDamage.Override= ; integer

[SOMEWARHEAD] ; WarheadType
Block.Chances= ; list of floating-point values (percentage or absolute) (0.0-1.0)
Block.DamageMultipliers= ; list of floating-point values (percentage or absolute)
Block.AffectBelowPercents= ; list of floating-point values (percentage or absolute) (0.0-1.0)
Block.AffectsHouses=all ; list of Affected House Enumeration (none|owner/self|allies/ally|team|enemies/enemy|all)
Block.CanActive.NoFirer=true ; boolean
Block.CanActive.Powered=false ; boolean
Block.CanActive.ShieldActive=true ; boolean
Block.CanActive.ShieldInactive=true ; boolean
Block.CanActive.ZeroDamage=false ; boolean
Block.CanActive.NegativeDamage=false ; boolean
Block.CanActive.Move=true ; boolean
Block.CanActive.Stationary=true ; boolean
Block.Flash=false ; boolean
Block.Flash.FixedSize= ; integer
Block.Flash.Red=true ; boolean
Block.Flash.Green=true ; boolean
Block.Flash.Blue=true ; boolean
Block.Flash.Black=false ; boolean
Block.Anims= ; list of animations
Block.Weapon= ; WeaponType
Block.ReflectDamage=false ; boolean
Block.ReflectDamage.Chance=1.0 ; floating point value
Block.ReflectDamage.Warhead= ; WarheadType
Block.ReflectDamage.Warhead.Detonate=false ; WarheadType
Block.ReflectDamage.Multiplier=1.0 ; floating point value, percents or absolute
Block.ReflectDamage.AffectsHouses= ; list of Affected House Enumeration (none|owner/self|allies/ally|team|enemies/enemy|all)
Block.ReflectDamage.Override= ; integer
Block.BasedOnWarhead=false ; boolean
Block.AllowOverride=true ; boolean
Block.IgnoreAttachEffect=true ; boolean
Block.ChanceMultiplier=1.0 ; floating point value
Block.ExtraChance=0.0 ; floating point value
Block.DamageMult.Multiplier=1.0 ; floating point value
Block.DamageMult.Bonus=0.0 ; floating point value
ImmuneToBlock=false ; boolean
```

### Custom Radiation Types

![image](_static/images/radtype-01.png)
Expand Down Expand Up @@ -308,6 +414,7 @@ ImmuneToCrit=no ; boolean
Tint.Color= ; integer - R,G,B
Tint.Intensity=0.0 ; floating point value
Tint.VisibleToHouses=all ; list of Affected House Enumeration (none|owner/self|allies/ally|team|enemies/enemy|all)
CanBlock=true ; boolean

[SOMETECHNO] ; TechnoType
ShieldType=SOMESHIELDTYPE ; ShieldType; none by default
Expand Down Expand Up @@ -955,6 +1062,7 @@ AutoFire.TargetSelf=false ; boolean
```

### Build limit group

- You can now make different technos share build limit in a group.
- `BuildLimitGroup.Types` determines the technos that'll be used for build limit conditions of the selected techno. Note that the limit won't be applied to technos in the list. To do this, you'll have to manually define the limit per techno.
- `BuildLimitGroup.Nums` determines the amount of technos that would reach the build limit. If using a single integer, it'll use the sum of all technos in the group to calculate build limit. If using a list of integers with the same size of `BuildLimitGroup.Types`, it'll calculate build limit per techno with value matching the position in `BuildLimitGroup.Types` is used for that type.
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ New:
- Nonprovocative Warheads (by Starkku)
- Option to restore `PowerSurplus` setting for AI (by Starkku)
- `FireOnce` infantry sequence reset toggle (by Starkku)
- Damage blocking system (by Ollerus)

Vanilla fixes:
- Allow AI to repair structures built from base nodes/trigger action 125/SW delivery in single player missions (by Trsdy)
Expand Down
Loading
Loading