Level up.

Started by Ichisennen, July 09, 2011, 09:25:38 PM

Previous topic - Next topic

Ichisennen

I have a problem concerning some custom bars for my character. I posted a topic a while ago but I tried to solve it on my own instead. Then I came across another problem

To recap , this bar of mine accumulates points according to damage you deal and receive. When it becomes full, a number beside it goes up, and you have to fill it again. Works like the MVC3 powerbar.

Now, I'm having trouble with making it scale levels. First problem, whenever I do more/receive more damage than required to fill the meter, it skips a level with my current way of making it "level up".

Basically, I need to have an idea on what changestate trigger it should have so that it doesn't go more than the bounds.

Here's the code for the -2's, equations for damage computation which is used for meter scaling


[Statedef -2]

;Var reference
;var(40)=damage dealt,var(41)=chip damage dealt.
;var(42)=Sum of var(40) and var(41)
;fvar(23)=calculation used for the modifyexplod scale that applies to the meter.

;Damage Dealt
[state driveadd]
type = varadd
triggerall = var(45)<4
trigger1 = movecontact = 1
var(42) = cond(movehit, var(40), var(41))

;Damage Received
[State 0, VarSet]
type = VarAdd
triggerall = var(45)<4
trigger1 = 1
v = 42    ;fv = 10
value = gethitvar(damage)

;The Bar's Scale Calculation
[State 0, VarSet]
type = VarSet
triggerall = var(45)<4
triggerall = var(30)=0
trigger1 =1
fv = 23  ;fv = 10
value = var(42)/1000.0

;The Bar which changes when levels up
[State 0, Helper]
type =Helper
trigger1= numhelper(9875) != 1
helpertype = normal ;player
name = "DriveBar"
ID = 9875
stateno = 9876
pos =10,150
postype = left    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 1
supermovetime=9999
pausemovetime=9999
size.xscale = 1
size.yscale = 1
removetime = 1
size.shadowoffset = 999


;The meter that fills the bar
[State 0, Helper]
type =Helper
trigger1 = numhelper(9112) != 1
helpertype = normal ;player
name = "DriveBarMeter"
ID = 9112
stateno = 9112
pos =10,150
postype = left    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 1
supermovetime=9999
pausemovetime=9999
size.xscale = 1
size.yscale = 1
removetime = 1
size.shadowoffset = 999


Code for the helpers:


;-------------------------------------------------------------------
;The scaling meter
[statedef 9112]
movetype = I
physics = U

[State 0, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = noshadow

[State 0, explod]
type = Explod
triggerall = teamside = 1
trigger1=time=0
anim = 9975
ID=9111
pos=83,220
postype=left
facing=1
vfacing=1
bindtime=99999
vel=0,0
accel=0,0
random=0,0
removetime=-1
supermovetime=9999
pausemovetime=9999
scale = 1,1
sprpriority = 3
ontop = 0

[State 0, explod]
type = Explod
triggerall = teamside = 2
trigger1=time=0
anim =9975
ID=9114
pos=-83,220
postype=right
facing=-1
vfacing=1
bindtime=99999
vel=0,0
accel=0,0
random=0,0
removetime=-1
supermovetime=9999
pausemovetime=9999
scale = 1,1
sprpriority = 3
ontop = 0

[State 0, ModifyExplod]
type = ModifyExplod
triggerall = root,var(45)<4
trigger1 = 1
ID = 9111
scale =root,fvar(23),1

[State 0, ModifyExplod]
type = ModifyExplod
triggerall = root,var(45)<4
trigger1 = 1
ID = 9114
scale =root,fvar(23),1

[State 0, ModifyExplod]
type = ModifyExplod
triggerall = root,var(45)=4
trigger1 = 1
ID = 9111
scale =0,1

[State 0, ModifyExplod]
type = ModifyExplod
triggerall = root,var(45)=4
trigger1 = 1
ID = 9114
scale =0,1
;-------------------------------------------------------------------
;Level 0
[statedef 9876]
movetype = I
physics = U

[State 0, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = noshadow

[State 0, explod]
type = Explod
triggerall = parent,fvar(18)=0
triggerall = teamside = 1
trigger1=time=0
anim = 9876
ID=9876
pos=83,220
postype=left
facing=1
vfacing=1
bindtime=99999
vel=0,0
accel=0,0
random=0,0
removetime=-1
supermovetime=9999
pausemovetime=9999
scale = 1,1
sprpriority = 10
ontop = 0

[State 0, explod]
type = Explod
triggerall =parent,fvar(18)=0
triggerall = teamside = 2
trigger1=time=0
anim =9876
ID=9876
pos=-83,220
postype=right
facing=-1
vfacing=1
bindtime=99999
vel=0,0
accel=0,0
random=0,0
removetime=-1
supermovetime=9999
pausemovetime=9999
scale = 1,1
sprpriority = 10
ontop = 0

[State 0, ModifyExplod]
type = ModifyExplod
trigger1 =root,fvar(23)>1
ID = 9876
removetime = 1

[State 0, ChangeState]
type = ChangeState
trigger1 = root,fvar(23)>1
value = 9877
ctrl = 0
;-------------------------------------------------------------------
;Level 1
[statedef 9877]
movetype = I
physics = U
anim = 8715

[State 0, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = noshadow

[State 0, explod]
type = Explod
triggerall = teamside = 1
trigger1=time=0
anim = 9877
ID=9881
pos=83,220
postype=left
facing=1
vfacing=1
bindtime=99999
vel=0,0
accel=0,0
random=0,0
removetime=-1
supermovetime=9999
pausemovetime=9999
scale = 1,1
sprpriority = 9
ontop = 1

[State 0, explod]
type = Explod
triggerall = teamside = 2
trigger1=time=0
anim =9877
ID=9881
pos=-83,220
postype=right
facing=-1
vfacing=1
bindtime=99999
vel=0,0
accel=0,0
random=0,0
removetime=-1
supermovetime=9999
pausemovetime=9999
scale = 1,1
sprpriority = 9
ontop = 1

[State 0, ParentVarAdd]
type = ParentVarAdd
trigger1 = time=3
v = 45   ;fv = 10
value = 1

[State 0, VarSet]
type = ParentVarSet
trigger1 = time=0
var(42) = 0

[State 0, ModifyExplod]
type = ModifyExplod
triggerall = root,var(45)=1
trigger1 =root,fvar(23)>1
ID = 9881
removetime = 1

[State 0, ModifyExplod]
type = ModifyExplod
triggerall = root,var(45)=1
trigger1 = parent,fvar(18)=1
ID = 9881
removetime = 1

[State 0, ChangeState]
type = ChangeState
triggerall = root,var(45)=1
trigger1 = root,fvar(23)> 1
value = 9878
ctrl = 0

[State 0, ChangeState]
type = ChangeState
trigger1 = parent,stateno=9999
value = 8877
ctrl = 0
;-------------------------------------------------------------------
;Level 2
[statedef 9878]
movetype = I
physics = U

[State 0, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = noshadow

[State 0, explod]
type = Explod
triggerall = teamside = 1
trigger1=time=0
anim = 9878
ID=9887
pos=83,220
postype=left
facing=1
vfacing=1
bindtime=99999
vel=0,0
accel=0,0
random=0,0
removetime=-1
supermovetime=9999
pausemovetime=9999
scale = 1,1
sprpriority = 8
ontop = 1

[State 0, explod]
type = Explod
triggerall = teamside = 2
trigger1=time=0
anim =9878
ID=9887
pos=-83,220
postype=right
facing=-1
vfacing=1
bindtime=99999
vel=0,0
accel=0,0
random=0,0
removetime=-1
supermovetime=9999
pausemovetime=9999
scale = 1,1
sprpriority = 8
ontop = 1

[State 0, ParentVarAdd]
type = ParentVarAdd
trigger1 = time=4
v = 45 
value = 1

[State 0, VarSet]
type = ParentVarSet
trigger1 = time=0
var(42) = 0  ;fv = 10

[State 0, ModifyExplod]
type = ModifyExplod
triggerall = root,var(45)=2
trigger1 =root,fvar(23)>1
ID = 9887
removetime = 1

[State 0, ChangeState]
type = ChangeState
triggerall = root,var(45)=2
trigger1 = root,fvar(23)> 1
value = 9879
ctrl = 0

;-------------------------------------------------------------------
;Level 2
[statedef 9879]
movetype = I
physics = U

[State 0, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = noshadow
[State 0, VarSet]
type = ParentVarSet
trigger1 = time=0
var(42) = 0  ;fv = 10
[State 0, explod]
type = Explod
triggerall = teamside = 1
trigger1=time=0
anim = 9879
ID=9879
pos=83,220
postype=left
facing=1
vfacing=1
bindtime=99999
vel=0,0
accel=0,0
random=0,0
removetime=-1
supermovetime=9999
pausemovetime=9999
scale = 1,1
sprpriority = 8
ontop = 1
[State 0, ParentVarAdd]
type = ParentVarAdd
trigger1 = time=5
v = 45
value = 1
[State 0, explod]
type = Explod
triggerall = teamside = 2
trigger1=time=0
anim =9879
ID=9879
pos=-83,220
postype=right
facing=-1
vfacing=1
bindtime=99999
vel=0,0
accel=0,0
random=0,0
removetime=-1
supermovetime=9999
pausemovetime=9999
scale = 1,1
sprpriority = 8
ontop = 1

[State 0, ModifyExplod]
type = ModifyExplod
triggerall = root,var(45)=3
trigger1 =root,fvar(23)>1
ID = 9879
removetime = 1

[State 0, ChangeState]
type = ChangeState
triggerall = root,var(45)=3
trigger1 = root,fvar(23)> 1
value = 9880
ctrl = 0
;-------------------------------------------------------------------
;Level 3
[statedef 9880]
movetype = I
physics = U
[State 0, ParentVarSet]
type = ParentVarSet
trigger1 = time=0
v = 45    ;fv =
value = 4
[State 0, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = noshadow
[State 0, VarSet]
type = ParentVarSet
trigger1 = time=0
var(42) = 0  ;fv = 10
[State 0, explod]
type = Explod
triggerall = teamside = 1
trigger1=time=0
anim = 9880
ID=9879
pos=83,220
postype=left
facing=1
vfacing=1
bindtime=99999
vel=0,0
accel=0,0
random=0,0
removetime=-1
supermovetime=9999
pausemovetime=9999
scale = 1,1
sprpriority = 0
ontop = 1
[State 0, explod]
type = Explod
triggerall = teamside = 2
trigger1=time=0
anim =9880
ID=9879
pos=-83,220
postype=right
facing=-1
vfacing=1
bindtime=99999
vel=0,0
accel=0,0
random=0,0
removetime=-1
supermovetime=9999
pausemovetime=9999
scale = 1,1
sprpriority = 0
ontop =1


I know I shouldn't use time. But so far I dont know what to use. Help?

Odb718

I read a lot of your post and I noticed you dont use an ifelse().
You can try to level up where it uses ifelse to catch it's excess damage and saves it..
Something along the lines of

value = ifelse(var(42)>=1000,var(42)-1000,var(42))

1000 would be the max ammount of points you want to accumulate. so what it's doing is checking if you've hit 1000 perfect or went over. If you have, it reduces var(42) 1000 points so you'll get the extra back added on. Say 1073 - 1000 = 73. So that check will make it so var(42) = 73.
If var(42) is less than 1000 then it is what it is.
Value would be what ever you use to check when you level up. I'm not sure what it is  :-\

I dont know if this is exactly what you're looking for but I hope it helps.
vVv Gouken718 vVv SabreTooth718 vVv


Ichisennen

So youre suggesting that I add some sort of varset that triggers whenever var(42)>1000 then? So that it never goes past 1000.

Still my problem remains unsolved, how do I use that to trigger the helper to changestate into new state aka lvl 1 to lvl 2?

BTW, mistake in var descriptions... for those who think they can help me out in this unsolvable thingy.

Var(42) = var add adds points to var(42) equivalent to damage dealt, either hit or chip damage, plus damage taken.
fvar(23) = var(42) divided by 1000, so that points even out to 1.00, since fvar(23) is used for scaling the x of the bar, and max life is 1000. So in order to "level up", you need to deal at least 1000 points or receive 1000 pts of damage. With the dampener i have thats quite possible w/o killing p2.
var(45) = var that holds what level the bar is currently in. I use this so that I can check what level I am currently in.

Алексей

Well if you just wanted to make it so it never hit past 1000, you could just use var(42) = var(42)%1000. (Too bad there's no %= operator ;) )

But, since you want to ChangeState whenever var(42) is greater than 1000, then do that. Write a trigger that activates when var(42)>=1000, then in the state to change to, essentially the "level up" state, reset var(42) back to 0.

Also, a state per level might get tedious and monotonous. Why don't you have one state for level up's and just increment a variable to represent the level. Then, you can change animations (such as the level up number) using that level variable.

-[Все слова это только слова.]-

Ichisennen

Nope, I want it to changestate when it hits 1000, then the meter resets and goes up a level. That 1000 points requirement remains the same for all levels. So even if I had a changeanim with a trigger=var(42)=1000, it'll skip to the other levels since they too require 1000 points. How do I keep them from skipping is the main problem actually, and going about making var(42) reset correctly, since I tried varset with trigger=var(42)=1000, but then the level up never triggers since the trigger I previously used is trigger=var(42)=1000.

So what's another method, or maybe a little bit of adjustment to what I have in mind?

Алексей

I really think you're over thinking this:

When var(42) is 1000 or greater, meaning that it has hit 1000 already, level up (ChangeState) and reset var(42). Think about it. var(42) will never go past 1000 for longer than 1 tick because you are resetting it back to using VarSet at the start of your level up ChangeState.

-[Все слова это только слова.]-

Ichisennen

#6
. . . And I really think you're not getting my real problem.

Like my var descrips say, or at least after really reading my code,

fvar(23) = calculation used for the modifyexplod scale that applies to the meter, 1.00 being max since my sprite is correctly scaled.

fvar(23) >1 is greater than max right? I can't make this into fvar(23)=1 since it will never equal to exactly one all the time. Now I put into a changestate that I should changestate whenever I reach greater than max then reset it on the next state. Which would go like (and yes, this was already in my code before, if you read it) :

[State 0, ModifyExplod]
type = ModifyExplod
trigger1 =root,fvar(23)>1
ID = 9876
removetime = 1

[State 0, ChangeState]
type = ChangeState
trigger1 = root,fvar(23)>1
value = 9877
ctrl = 0

Then I reset fvar(23) or var(42) since its part of the same equation right? Which of course was, again, also in my code before you even said so.

[State 0, VarSet]
type = ParentVarSet
trigger1 = time=0
var(42) = 0

But then, thats true for all levels. Due to mugen syntax I guess, especially whenever I do a multiple hit attack, it changestates first before resetting the var, even though I have time=0 as a trigger there.

And root,var(42)>1000 yields the same results btw.

Back to my question, How do i correctly trigger a changestate without it skipping any levels? Meaning varreset 1st before changestate? And no...  im not overthinking it.

EDIT:

Fuck yea, found the solution. Make one var keeping track of overall damage, and one resetting every level. Problem solved.

Cyanide

Cheat. You're setting to 0 so

changestate
value = 9877 + fvar(23) := 0

It'll attempt to add on the value of the variable, but it's 0, so it won't add anything on, but it will reset it on statechange.


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.

Ichisennen

#8
That came a little late, but boy is that much easier on the eyes than what I did. I'll keep that in mind next time. Thanks for the help Odb718, Kenshinx0 and Cyanide.  :sugoi: