Skip to content

FeatureDamaged and FeaturePreDamaged#5752

Open
Stiofan-K wants to merge 2 commits into
ZeroK-RTS:masterfrom
Stiofan-K:FeatureDamaged-and-FeaturePreDamaged-Callins
Open

FeatureDamaged and FeaturePreDamaged#5752
Stiofan-K wants to merge 2 commits into
ZeroK-RTS:masterfrom
Stiofan-K:FeatureDamaged-and-FeaturePreDamaged-Callins

Conversation

@Stiofan-K

Copy link
Copy Markdown
Contributor

What it says on the tin!

FeatureDamage is tested in Refumble mod and seems to work as intended.
FeaturePreDamaged I am uncertain about, though it mimics the UnitPreDamaged Callin.

@GoogleFrog

Copy link
Copy Markdown
Contributor

What are they for? The comment you haven't removed says that they are missing on purpose to avoid paying the performance cost.

@Stiofan-K

Stiofan-K commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

Sprung had asked for it to be split off from the Nanoplague PR

Reasoning as per issue #5668

I had asked about how to do feature damaged detection the way the comment described but handnt gotten an answer/it was easier to implement the callin.

Comment thread LuaRules/gadgets.lua Outdated
local allWeaponDefs = {}

do
for i=-7,#WeaponDefs do

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why -7?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is an uncommeted offset taken from usage in UnitPreDamaged.
I'm unsure why it's there either, but assumed it was intentional.

The UnitPreDamaged Callin is used a decent amount, also using the weapondef value within.
Its also reused as a fallback on line 2215 for the Explosion gadgetHandler

I'll remove the duplicate declaration I suppose, and maybe make an issue for the -7? (Line 1748)

Since it's the fallback option in all usecases, it may just never be used and has as such never failed yet?

Comment thread LuaRules/gadgets.lua
"FeatureCreated",
"FeatureDestroyed",
"FeaturePreDamaged",
"FeatureDamaged",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the comment below was discovered to be untrue (no perf cost if callin not actually used) and no longer applies, remove it

Comment thread LuaRules/gadgets.lua Outdated
local weaponDefs = (g.FeaturePreDamaged_GetWantedWeaponDef and g:FeatureDamaged_GetWantedWeaponDef()) or allWeaponDefs
tracy.ZoneEnd()
for _,wdid in ipairs(weaponDefs) do
if FeatureDamaged_GadgetMap[wdid] then

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

wrong var

Comment thread LuaRules/gadgets.lua
Comment on lines +2049 to +2051
function gadgetHandler:FeaturePreDamaged(featureID, featureDefID, featureTeam,
damage, paralyzer, weaponDefID,
projectileID, attackerID, attackerDefID, attackerTeam)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this doesnt seem to be the actual signature of the function as passed by the engine

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I missed the paralyze damage not being included in feature callins (Except add damage) when checking the recoil docs

Comment thread LuaRules/gadgets.lua Outdated
Comment on lines +2079 to +2081
if gadgetHandler.GG._AddUnitDamage_teamID then
attackerTeam = gadgetHandler.GG._AddUnitDamage_teamID
end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

probably remove this bit (unless an equivalent AddFeatureDamage hack for features is implemented)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should do the same for FeatureDamaged at line 2109?

@sprunk

sprunk commented Jun 12, 2026

Copy link
Copy Markdown
Member

I had asked about how to do feature damaged detection the way the comment described but handnt gotten an answer/it was easier to implement the callin.

Without the callin it's just not possible to identify non-lethal damage. The "use armordefs" comment is only about implementing basic "deals more/less/zero damage to features" kind of logic, which I think was the bulk of what people used to want to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants