apace100/apoli

[1.20.2] `action_on_death` not working with bientity action `actor_action`

Reniel80 opened this issue · 5 comments

In my case with the power type change_resource
This action_on_death it is very important if you want to reset binary resources to 0
If you use delay to change resource to 0 when time is over and you die in the middle... everything becomes a chaos.. all resources remain in 1.

I cannot reproduce this issue. Are you sure you need to use actor_action? Because in the context of the action_on_death power type (or any of the power types related to dealing/taking damage), the actor is the attacker entity while the target is the entity being attacked

If you need to change_resource to 0 when you die to reset a resource value used as counter for example *:*_counter

action_on_hit -> change_resource -> *:*_counter -> add 1

but a target_action (enemy) cannot change your *:*_counter value to zero if you die.
an actor_action (you) must do it using action_on_death (your death) -> change_resource -> *:*_counter -> set 0

otherwise i must use:

condition: *:*_counter > 0
prevent_death -> change_resource -> *:*_counter -> set 0
execute_command -> /kill @s

Although this works... this is not a clean solution, but using action_on_death (your death) would be perfect and direct.

but a target_action (enemy) cannot change your *:*_counter value to zero if you die.
an actor_action (you) must do it using action_on_death (your death) -> change_resource -> *:*_counter -> set 0

As I've said before, actor_action would refer to the attacker entity. You're supposed to use target_action, since that would refer to the entity that has been attacked, which in the case for the action_on_death power type, will be you, the entity that died, which also have the power

Currently, you're trying to set the value of the *:*_counter resource from the entity that attacked you, which wouldn't work since the entity wouldn't have the resource that only you have

Here's an example that does exactly what you described, but with the proper actor and target context:

{
    type: "apoli:multiple",
    tracker: {
        type: "apoli:resource",
        min: 0,
        max: 20,
        hud_render: {
            should_render: true
        }
    },
    add_to_tracker: {
        type: "apoli:action_on_hit",
        bientity_action: {
            type: "apoli:actor_action",         //  `actor_action` is used here, because the actor would be you, the attacker
            action: {
                type: "apoli:change_resource",
                resource: "*:*_tracker",
                change: 1
            }
        }
    },
    reset_tracker: {
        type: "apoli:action_on_death",
        bientity_action: {
            type: "apoli:target_action",        //  `target_action` is used here, because the target would be you, the entity that died
            action: {
                type: "apoli:change_resource",
                resource: "*:*_tracker",
                change: 0,
                operation: "set"
            }
        }
    }
}

Wow!!! that explains everything. Thanks for your enlightenment.