So I'm having difficulty working my mind around a way to get this to work. I have two triggers. both modify hp, and the event of one is units hp is modified.
Ill copy my two triggers out below. Basically, I have an attribute that modifies total hp. one trigger fires whenever a unit's attribute is modified, and if it is, update its hp. I have another trigger that when its hp is modified (level up or items), it updates its total hp based on its attribute. I disable the hp modifying trigger in both triggers to prevent infinite loops and the attribute modifying the hp twice.
everything works well if only one thing changes at a time, but there will be scenarios eventually where something may modify both at once. IF this happens, the attribute trigger disables the hp trigger, so the actual hp change isnt registered.
How can I prevent attribute gains from firing the hp changes trigger, but also allow for something to increase both the attribute and hp at the same time?
i hope i explained that properly, ask if anything doesnt make sense
With your current format, if you were to combine the triggers, would that solve it? You'd have one trigger with two events, and more if-thens to prevent errors, but you'd just calculate everything in one trigger, which is being turned off/on for the duration to prevent the infiniloop.
I'd recommend having another trigger (ideally, a custom action definition) which calculates the stats based on stored values, and turns off changes from the player for the action length, and can be ran everytime a change takes place.
and if something both increased hp and changed attributes at the same time? would that not still mess up because the trigger fires the first time, shuts itself off, and then the second time its not active to fire
and if something both increased hp and changed attributes at the same time? would that not still mess up because the trigger fires the first time, shuts itself off, and then the second time its not active to fire
I really just think you need a new system. Something that can be ran whenever to calculate the stats of a unit based on independent variables, ran every time those are modified. It would be much cleaner and efficient, and more compatible with various mechanics (i.e. saving, reviving). Sorry I couldn't be more help with your current method.
But with a "refresh" action, as I call it, instead of directly modifying a unit's health or attributes, you modify a global value (custom values work, but they're bound to the unit) and then run the refresh, which recalculates the stats the unit should have and applies them.
I wish I could tell you how to make your current method work, but I just can't see how.
It seems the easiest solution would be as suggested above making it all 1 trigger with both events.
Btw when looking at your trigs it seems your adding stats using attribute increases with trigs have you instead tried adding stat increases on the actually attribute? Cause you can add life increase and regen using just attributes in data editor IDK if that was what you were goin for tho
attributes give a % of total hp. So 1 attribute = 5% bonus max hp.
you can give live fraction with attributes, but it doesnt affect bonus hp gained from leveling
Hmmm are your units leveling the only other way they gain HP?
If this is the case you could change to (IDK if your using veterancy or trig lvls)
Unit - Any Unit has Veteran change Increase
if your using Triggers to level it should be even easier :P
then do hp modifying without having to worry about it, only problem is still with the 5% bonus' appyling before this takes place so you could try putting a wait for condition in the Toughness trigger and set a Bool equal to true when level up occurs and set to false when the trigger ends.
I think I figured it out. If the attribute changing fires off the oh trigger that's fine, cause nothing will be changes in the hp trigger (the correct values have been set and it'll register a change of 0)
I'll just need to put blocking in there so only one trigger has access to the units hp at one time. (Wait for time actions I think would work)
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hey,
So I'm having difficulty working my mind around a way to get this to work. I have two triggers. both modify hp, and the event of one is units hp is modified.
Ill copy my two triggers out below. Basically, I have an attribute that modifies total hp. one trigger fires whenever a unit's attribute is modified, and if it is, update its hp. I have another trigger that when its hp is modified (level up or items), it updates its total hp based on its attribute. I disable the hp modifying trigger in both triggers to prevent infinite loops and the attribute modifying the hp twice.
everything works well if only one thing changes at a time, but there will be scenarios eventually where something may modify both at once. IF this happens, the attribute trigger disables the hp trigger, so the actual hp change isnt registered.
How can I prevent attribute gains from firing the hp changes trigger, but also allow for something to increase both the attribute and hp at the same time?
i hope i explained that properly, ask if anything doesnt make sense
@Grasshopper721: Go
With your current format, if you were to combine the triggers, would that solve it? You'd have one trigger with two events, and more if-thens to prevent errors, but you'd just calculate everything in one trigger, which is being turned off/on for the duration to prevent the infiniloop.
I'd recommend having another trigger (ideally, a custom action definition) which calculates the stats based on stored values, and turns off changes from the player for the action length, and can be ran everytime a change takes place.
Sorry if I'm misunderstanding the problem.
@Charysmatic: Go
and if something both increased hp and changed attributes at the same time? would that not still mess up because the trigger fires the first time, shuts itself off, and then the second time its not active to fire
@Grasshopper721: Go
I really just think you need a new system. Something that can be ran whenever to calculate the stats of a unit based on independent variables, ran every time those are modified. It would be much cleaner and efficient, and more compatible with various mechanics (i.e. saving, reviving). Sorry I couldn't be more help with your current method.
But with a "refresh" action, as I call it, instead of directly modifying a unit's health or attributes, you modify a global value (custom values work, but they're bound to the unit) and then run the refresh, which recalculates the stats the unit should have and applies them.
I wish I could tell you how to make your current method work, but I just can't see how.
thats what i wasnt hoping for : P
ill see what I can do with what you suggest
It seems the easiest solution would be as suggested above making it all 1 trigger with both events.
Btw when looking at your trigs it seems your adding stats using attribute increases with trigs have you instead tried adding stat increases on the actually attribute? Cause you can add life increase and regen using just attributes in data editor IDK if that was what you were goin for tho
attributes give a % of total hp. So 1 attribute = 5% bonus max hp.
you can give live fraction with attributes, but it doesnt affect bonus hp gained from leveling
Hmmm are your units leveling the only other way they gain HP?
If this is the case you could change to (IDK if your using veterancy or trig lvls)
Unit - Any Unit has Veteran change Increase
if your using Triggers to level it should be even easier :P
then do hp modifying without having to worry about it, only problem is still with the 5% bonus' appyling before this takes place so you could try putting a wait for condition in the Toughness trigger and set a Bool equal to true when level up occurs and set to false when the trigger ends.
I think I figured it out. If the attribute changing fires off the oh trigger that's fine, cause nothing will be changes in the hp trigger (the correct values have been set and it'll register a change of 0) I'll just need to put blocking in there so only one trigger has access to the units hp at one time. (Wait for time actions I think would work)