Skip to content

Conversation

@bloerwald
Copy link
Collaborator

@bloerwald bloerwald commented Apr 25, 2023

The hp.can_explode condition assumes 40%, but there is at least Corpse Explosion having the same semantics but using 15% instead. Future abilities might be added with yet another percentage but scripts already can't handle Corpse Explosion, so adding support for this would be good.

I don't want to break existing scripts, so there are two approaches here:

  • In addition to hp.can_explode (40%), add hp.can_explode_15 (15%) and hp.can_explode_40 (40%) (or hp.can_explode15, hp.can_explode40)
  • In addition to hp.can_explode (40%), add hp.can_explode_pct(x) and thus hp.can_explode_pct(15) to have full flexibility.

I don't like the first solution since it requires a hard list of percentages (then again, there are only two). I don't like the second solution because the name is ugly. Sadly, hp.can_explode(15) isn't possible that easily and I don't want to do bigger changes just for this feature.

@bloerwald bloerwald force-pushed the issue_9-add_hp_can_explode_pct branch from 70d13e1 to 726e438 Compare May 3, 2023 23:13
@axc450
Copy link
Owner

axc450 commented May 7, 2023

What would be the effort involved in .can_explode == .can_explode() == .can_explode(40) ?
I see you mentioned it isn't easy so I will have a think about this.

@bloerwald
Copy link
Collaborator Author

What would be the effort involved in .can_explode == .can_explode() == .can_explode(40) ?
I see you mentioned it isn't easy so I will have a think about this.

Currently, only the first part can have an argument, i.e. self.ability(y).z is possible, but self.ability.z(y) is not. This is buried very deep and implicitly in the parser, to be specific

There can be exactly one argument, and it can only be in the first/middle part of a condition. This is before we even talk about overloading the function to optionally have an argument rather than requiring it.

If one wants changes like this, I'd highly recommend redoing the parser/evaluation completely to have the math expressions and alike and have this as a side effect. Doing it just for this seems very not worth it.

@cosinussinus
Copy link
Contributor

I noticed that the condition needs an opts.pet = false. It's always the active pets that are affected.

Addon:RegisterCondition('hp.can_explode', { type = 'boolean', pet = false, arg = false }, function(owner, pet) return ConditionCanExplode(owner, pet, 0.4) end)

Addon:RegisterCondition('hp.can_explode_pct', { type = 'boolean', pet = false }, function(owner, pet, arg) return ConditionCanExplode(owner, pet, arg / 100.) end)

@bloerwald
Copy link
Collaborator Author

### `hp.can_explode_pct`
If the damage from a pet self-destructing would kill the opponent.

**Return**: `bool`  
**Examples**: `self.hp.can_explode_pct(16)` (Can the explode damage of the current player pet kill the enemy pet, assuming it does 16% damage?)

@bloerwald
Copy link
Collaborator Author

After trying this again, it seems that I did a bad PR here. This adds hp(15).can_explode, not hp.can_explode(15) and from reading my comment again, it seems the latter isn't possible either. I'll change the condition to be _15, to at least have something.

@bloerwald
Copy link
Collaborator Author

I noticed that the condition needs an opts.pet = false. It's always the active pets that are affected.

It actually always is the selected pet vs the opponent active pet, i.e. enemy(#2).hp.can_explode compares enemy.2 vs self.active.

This entire condition is confusing as hell, especially with the inverse nature and the horrible name. My desire to not touch this at all is rising every minute.

@bloerwald bloerwald marked this pull request as draft October 26, 2023 13:06
@cosinussinus
Copy link
Contributor

cosinussinus commented Oct 26, 2023

Technically it works. but this can lead to unexpected behavior. here is an example:
exp
To me it makes sense to be restrictive in this case and only allow active pets.

What the user want is: ´[enemy(#2).active & enemy.hp.can_explode]´

@bloerwald
Copy link
Collaborator Author

Technically it works. but this can lead to unexpected behavior. here is an example: exp To me it makes sense to be restrictive in this case and only allow active pets.

What the user want is: ´[enemy(#2).active & enemy.hp.can_explode]´

I'm not saying it is the most useful thing, but I don't think there needs to be a restriction here. There could be a pet with both explode, force-swap-enemy and backline-damage. That pet could

use (force-swap-enemy) [ enemy(#2).hp.can_explode ]
use (explode) [ enemy(#2).active ]
use (backline-damage)

It doesn't exist and it likely never will, but hey, why not support it?

@cosinussinus
Copy link
Contributor

Indeed, that's a creative way of using it :D
You are right, there is no point to be restrictive.

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.

4 participants