apace100 / apoli

MIT License
40 stars 46 forks source link

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

Closed Reniel80 closed 11 months ago

Reniel80 commented 1 year ago

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.

eggohito commented 12 months ago

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

Reniel80 commented 11 months ago

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.

eggohito commented 11 months ago

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

eggohito commented 11 months ago

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"
            }
        }
    }
}
Reniel80 commented 11 months ago

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