Page 1 of 1
Access to entity prototype's "action" field
Posted: Wed Aug 09, 2023 6:31 am
by wasmoo
I'm trying to dynamically determine the "damage-type" of the cursor's item stack. For example, if holding a "poison-capsule", I want to find the damage-type "poison".
However, for poison capsules, the damage isn't done by the thrown attack_parameters, but rather from a smoke-with-trigger that has an `action` that deals poison. I am unable to get access to the `smoke-with-trigger` action.
I'm also having a similar difficulty accessing the `land-mine` action and the `artillery-projectile` action.
Re: Access to entity prototype's "action" field
Posted: Wed Aug 09, 2023 12:39 pm
by wasmoo
I was able to create a workaround where I create an `ammo-type` for the action.
However, this had a different problem where the "nested-result" effect had a type of "nil", and I couldn't retrieve the underlying action.
Re: Access to entity prototype's "action" field
Posted: Thu Aug 10, 2023 12:56 am
by Rseding91
All of this is readable from the prototypes already.
Re: Access to entity prototype's "action" field
Posted: Thu Aug 10, 2023 8:04 am
by Bilka
To give more info,
LuaEntityPrototype::attack_result provides the action of the smoke-with-trigger, landmine and artillery-projectile (and more).
Re: Access to entity prototype's "action" field
Posted: Thu Aug 10, 2023 10:32 pm
by wasmoo
Thank you. The issue seems to be that the "nested-result" TriggerEffectItem has a type of nil. This code logs the nil type:
Code: Select all
for _,prototype in pairs({game.entity_prototypes["land-mine"]}) do
for a_index,trigger_item in pairs(prototype.attack_result or {}) do
for d_index,trigger_delivery in pairs(trigger_item.action_delivery or {}) do
for _, effects_key in pairs({"source_effects", "target_effects"}) do
for e_index, trigger_effect_item in pairs(trigger_delivery[effects_key] or {}) do
log("game.entity_prototypes[" .. prototype.name .. "]"
.. ".attack_result[" .. a_index .. "]"
.. ".action_delivery[" .. d_index .. "]"
.. "." .. effects_key .. "[" .. e_index .. "].type=" .. serpent.line(trigger_effect_item.type) )
end
end
end
end
end
I can access the `action` field, so my original issue is resolved. However, the missing type should be still fixed to avoid future confusion.
Re: Access to entity prototype's "action" field
Posted: Fri Aug 11, 2023 3:02 am
by wasmoo
Seems like there are more nuances with `nested_result`. Sometimes it has an `action` and sometimes it's just an array of TriggerEffectItem.