Need help with a character having his own gauge.

Started by GBA64, May 24, 2012, 09:37:40 PM

Previous topic - Next topic

GBA64

I need some coding help. I want to be able to create a boost gauge like in Sonic games when you boost, the gauge goes down, and when the gauge is empty, you can't boost anymore. I want to know if anyone here can help me with that.  :???:

Cyanide

You will need 2 variables, one to fill it up, and one to indicate if it is full or empty.

While variable 1 is 0, variable 2 is able to increase in value, lets say to 100. When it reaches 100, variable 1 becomes 1 and variable 2 begins to decrease. While variable 1 is 1 and variable 2 is greater than 0, you can boost, when variable 1 is 0, you cannot boost. Variable 1 will reset to 0 when variable 2 is also 0.

Get that bit working, then we'll do graphics.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.

GBA64

Is there maybe any chance you could post some coding so I can understand this a little better because that what you said there is kinda confusing. I have 2 VarSet triggers. They're Var(15) and Var(16). Am I doing it right so far?

Gamez

Here's a Dante WIP that someone made that uses a helper to create some sort of custom timer bar. I think the data for it starts in [Statedef 6000] and resumes most of what's needed in [Statedef 6010] in the cns file

I don't know if this is specific enough, but I figured it';s a good start for reference, since it's an already working piece. I can't make heads or tails of too much of it, but I wanted to do somethin to help. Maybe this'l be jsut watcha need.

I hope it's a good example.
http://www.4shared.com/rar/AqQOQYpv/dante.html

----THIS IS NOT MY DANTE. I am simply referencing other works I figured could help teach you. Rememebr anything you learn from something should have credit given to the owner, and nothing should be outright taken without permission THEN giving kudos. Just FYI.

Again hope this helps.

Cyanide

I'll give you some pseudo code.

Put all of this under statedef -2

varset
trigger1 = var(16) <= 0
v = 15
value = 0

varadd
trigger1 = var(15) = 0
v = 16
value = 1

varset
trigger1 = var(16) >= 100
v = 15
value = 1

varadd
trigger1 = var(15) = 1
v = 16
value = -1

Of course all that's going to do is make the variable go up and down every 100 ticks. You will need additional triggers for when you want it to increase, if you want it to decrease over time as well, if you want to make it decrease EXTRA when you use the boost.

Get this working, and make a move in the cmd that looks a little like this

type=  changestate
triggerall = command = "whatever"
trigger1 = ctrl && statetype != A
trigger1 = var(15) = 1
value = pick any state

That attack will ONLY function when var(16) has hit 100%


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.

GBA64

OK so I got the VarAdd's and VarSet's in StateDef -2 and I put some additional triggers in them as well. I got the sprites and animations ready, but I don't have the state created yet. Want me to show you what I did?

Cyanide

Nope, i want to hear from you that it functions, you should only be able to do the "special state" move after 100 ticks.

Alternatively you can do, once more in state -2

type = explod
trigger1 = var(15) = 1
anim = 0
pos = -30,0
removetime = 1
bindtime = 1

To display an explod while the variable is "true" it should disappear and reappear as var(16) increases and decreases. You can also use display to clipboard for this, but explods are nice and visible.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.

GBA64

Alright. I'll see what happens. The anim on the explod is the boost meter, right?

Cyanide

Yeah, sure, use that for now, we'll change things up when you know that you have the whole increase decrease method working.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.

GBA64

OK. o_O So... When the boost meter is showing and Sonic is boosting, it keeps reseting the state and making a bunch of copies of the boost effect appear. But when the boost meter's gone, he boost's normally.  I know there probably an issue with that.

Cyanide

At this point, when the boost meter is gone, he should not be able to boost at all. In this case that means the meter has "drained" and he shouldn't be able to boost any more until it refills. The problem is less the copies of the meter and more that your "boosting" is not working.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.

GBA64


Cyanide

any triggers for Boost should include var(15) = 1, if it's not 1, the bar has not yet maxed out.

The whole bar thing is a graphical effect, it has little bearing on it's own unless you get the incrementing right.

Show me what changestates you have for Boost. Show me the statedef -2 stuff as well please.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.

GBA64

CMD:

;Speed Blast
[State -1, Speed Blast]
type = ChangeState
value = 1664
triggerall = power != 0 && command = "holdfwd" && command = "hold_x"
trigger1 = (statetype = s) && ctrl
trigger2 = var(15) = 1

;Speed Blast B
[State -1, Speed Blast B]
type = ChangeState
value = 16641
triggerall = power != 0 && command = "holdback" && command = "hold_x"
trigger1 = (statetype = s) && ctrl
trigger2 = var(15) = 1

;Air Boost
[State -1, Air Boost]
type = ChangeState
value = 16642
triggerall = pos y != 0 && command = "holdfwd" && command = "y"
trigger1 = (statetype = a) && ctrl
trigger2 = var(15) = 1

;Backward Air Boost
[State -1, Bacward Air Boost]
type = ChangeState
value = 16643
triggerall = pos y != 0 && command = "holdback" && command = "y"
trigger1 = (statetype = a) && ctrl
trigger2 = var(15) = 1

CNS:


[State -2, explod]
type = explod
trigger1 = var(15) = 1
anim = 820701
pos = -30,0
removetime = 1
bindtime = 1

[State -2, varset]
type = varset
trigger1 = var(16) <= 0
v = 15
value = 0

[State -2, varadd]
type = varadd
trigger1 = var(15) = 0
v = 16
value = 1

[State -2, varset]
type = varset
trigger1 = var(16) >= 100
v = 15
value = 1

[State -2, varadd]
type = varadd
trigger1 = var(15) = 1
v = 16
value = -1

Cyanide

As they're boost only moves, that should be trigger1 not trigger2. Check it and confirm, and then i'll explain the boost bar stuff.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.

GBA64

So I gotta change the trigger2 into trigger1 on all the things I showed you?

Cyanide

I'm going to let you answer that. Your boost bar is FULL when the value is one, why should you be able to do the attack when it's not? That's what you've coded.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.

GBA64

The boost is suppose to go until the meter is completely empty. Plus, I changed the trigger2's into trigger1's and the boost is more accurate now. Shall we get to the meter draining effect?

Cyanide

Trigger2 is an ADDITIONAL trigger, you have said in those attacks "Have control OR have the variable maxed out" Now you have "Have control AND the variable maxed out"

I hate bars, but what the hell. I assume you have the standard outside bar inside bar thing?

-------------------
|>>>>>>             |
-------------------

That sort of thing? With 2 sprites. Make sure the >>> sprite is the FULL length of the bar.

To make this easier, spawn a single helper, using the animation for the box and place it where you need it on screen. Create an Explod within that helper state, make sure you give the explod an ID and make sure that you apply the following

scale = 0.01*root, var(16), 1

We also want a modifyexplod, happening EVERY tick

trigger1 = 1

All parameters need to match the explod. The modifyexplod will use that same scale calculation. To explain

when Sonics var(16) is 0, that scale will look like 0,1. When sonics var(16) = 50 the scale will look like 0.5,1 and be half the bar sprite. when it's 100, the scale will look like 1,1 and be the full bar, then it will begin draining. You may find it a bit fast right now and it will need some tweaking, you may even wish to swap to an fvar to do smaller increments. Get the bar to show, and see if you can make it shrink and grow, then things can become more complex as you have the base in place.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.

GBA64

I'm still having some problems. I try'd doing the helper thing on State -2 and used the NumHelper(***) = 0 trigger so it wouldn't re-spawn everytime I'm in a new state I put the Explod and MotifyExplod things in the helper's state and used the NumExplod(***) = 0 and it spawns a bunch of the same explod. Not sure about the helper though.