Code bar of flight

Started by mrgamer123, March 07, 2018, 07:48:07 AM

Previous topic - Next topic

mrgamer123

How do you code a bar of fly that will not allow the player to fly after it is depleted.

Like this one:

https://imgur.com/a/sWETN

Odb718

Image isn't working.
But basically you're going to make a variable. As you fly you'll use a varadd to subtract the value. I'd use time%3 as a trigger for it. This way it subtracts 20x a second. Then decide how many seconds of flight you want and times that by 20. That'll be your starting value.

In the cmd don't allow the changestate to happen unless your var > 0.

To display the bar, look into other health/power/magic bars where and how you want it displayed. Attached to P1, or attached to the screen at the bottom left, or top left or what?
vVv Gouken718 vVv SabreTooth718 vVv


mrgamer123

Could you possibly show me the code? I'm better at listening when people show me the code admmitedly.

altoiddealer

#3
For the bar itself, I recommend using a 1px thick bar, and the Scale parameter to control its length.
The bar should also be a 1 tick anim so it constantly refreshes.


Beginning of Fly State:


Type = VarSet
trigger1 = Time = 0
Var(1) = 100 ;whatever value you want.  It can be the length you want the bar to be.

Type = VarAdd
trigger1 = Time%3 = 0 ;triggers every 3rd tick. Adjust as necessary.
Var(1) = -1

Type = Explod
trigger1 = 1
value = 2000 ;whatever the bar anim is
scale = var(1),1 ;if it's a vertical bar, swap these values.


End of Fly State:


Type = ChangeState
trigger1 = var(1) <= 0
value = 0
ctrl = 1