YesNoOk
avatar

LifeAdd and Timer (Read 2843 times)

Started by Afterthought, March 10, 2018, 07:55:43 am
Share this topic:
LifeAdd and Timer
#1  March 10, 2018, 07:55:43 am
  • avatar
  • **
Pretty sure there's many ways to solve what I need but with my current code, I'm kinda stuck.

This is basic: I want a character to heal himself for a certain amount of time; when the limit is reached, healing stops. Simple. This is controlled by a single variable which turns on in one state, and turns off once the time limit is reached.

However, I find that more often than not, if my character does anything aside from standing or walking, the healing actually WON'T stop and will continue past the limit I set. I tried an alternative method using another variable and VarAdd, hoping that when this variable reached its limit, it would turn the main variable off. That didn't work for me, however.

Variable that activates within statedef:
Code:
[State 0]
type = VarSet
trigger1 = animelem = 3
trigger1 = var(12) = 0
var(12) = 1

Code in Statedef -2:
Code:
[State 0]
type = LifeAdd
triggerall = var(12) = 1
trigger1 = (gametime%10) = 1
value = 15

[State 0]
type = PalFx
trigger1 = var(12) = 1
time = 300
add = 100, 100, 200
sinadd = 100, 100, 256, 2
color = 256

[State 0]
type = VarSet
trigger1 = var(12) = 1
trigger1 = (time) = 300
var(12) = 0

If anyone has a solution to create a timer that definitely works, regardless of what my character does, I would love to hear it. All help is appreciated.

Re: LifeAdd and Timer
#2  March 10, 2018, 08:09:25 am
  • ****
  • Vs Style Debuts Tag Project CEO
  • The Dark Wolf Returns
    • USA
That code won't work the way you have it since in -2, once time passes 300 ticks in that state, it won't work further since you'll be automatically in -2 soon as match initiates so do this instead:

Code:

[State 0]
type = VarSet
trigger1 = animelem = 3
trigger1 = var(12) = 0
var(12) = 1


[State Use this as a timer]
type = VarSet
trigger1 = animelem = 3
trigger1 = var(12) = 1
var(13) = 300



Code in Statedef -2:
Code:
[State 0]
type = LifeAdd
triggerall = var(12) = 1
trigger1 = (gametime%10) = 1
value = 15
ignorehitpause=1

[State 0]
type = PalFx
trigger1 = var(12) = 1
time = 300
add = 100, 100, 200
sinadd = 100, 100, 256, 2
color = 256

[State deplete timer]
type = Varadd
trigger1 = var(13)>0
var(13) = -1
ignorehitpause=1

[State 0]
type = VarSet
trigger1 = var(12) = 1
trigger1 = var(13) <= 0;(time) = 300
var(12) = 0


Beware the Dark Wolf once more!
Re: LifeAdd and Timer
#3  March 10, 2018, 10:05:19 am
  • ******
  • Hedgehog Whisperer
  • Red Bull addict
    • Spain
    • xgargoyle.mgbr.net
It is easier to spawn a helper or a projectile with a destroy time of 300 ticks, and then trigger the lifeadd only when the helper/projectile is alive

No need to waste variables for such easy task
XGargoyle: Battle posing since 1979
http://xgargoyle.mgbr.net
http://www.pandorabots.com/pandora/talk?botid=e71c0d43fe35093a  <-- Please click that link
http://paypal.me/XGargoyle  <-- Donations welcome!
Re: LifeAdd and Timer
#4  March 10, 2018, 02:33:01 pm
  • avatar
  • **
@DarkWolf13: Believe it or not I did have something similar to this (mentioned in first post), but "trigger1 = var(13)>0" went over my head completely. Explains why it didn't work the first time. It works now, thanks.

@XGargoyle: I saw you say something similar in another topic similar to this one during my research; while I respect your opinion, the truth is, a sane person wouldn't use every variable within their character's code, they'd only use a good handful at most. The character I'm working with doesn't have a lot in use, so this is fine. When I find myself working with a character that has ALL of their variables in use, then I'll bother you about helpers and using those to time. I appreciate your input regardless.