YesNoOk
avatar

A mid-air special move question (Read 672 times)

Started by Continuity, July 12, 2009, 07:10:56 pm
Share this topic:
A mid-air special move question
#1  July 12, 2009, 07:10:56 pm
  • ***
  • 我が名は 「ハクメン」、押して参る!
here's a part of my code for my mid-air hadouken attack, I intend the move to execute in mid-air with no velocity and then resume the character's original jump velocity
[mcode][state 1400,2]
type=veladd
trigger1=animelem=7
x=const(velocity.jump.fwd.x)[/mcode]

this is where I'm stuck, the code will always cause my character to fall foward after the move, I wish to add velocity.jum.back.x as an additional state so he'll fall backwards when he was originally jumping backward, but I don't know right trigger for it. Can anyone help me , thank you
Re: A mid-air special move question
#2  July 12, 2009, 07:41:55 pm
  • ******
What you need to do is to "remember" the velocity you had when you entered the state, stop it, and then retrieve it. You need variables for that.
When entering the state, don't change the velocity, leave it as it is. First, use a [mcode]varset[/mcode] to put the value of your x and y velocities into two variables (or just one variable if you only want the x velocity and when resuming the move you just drop down instead of going up again).
When you have your velocity memorized, still at time = 0, you can put a velset at 0, and execute the move.
For the y velocity you can either use a constant velset Y=0 during the fireball or set the physics to N (and leave statetype to A in case you get hit).
When you're done with the move, you'll just use a velset to set x back to the value saved in the variable you used, and set your physic back to A so your char will drop down by himself, with the x velocity you had at the beginning.

That can be useful if you have, say, a long jump included, where the x value can be different depending on the jump.
If you have no such thing, then you'll always jump with the same x velocity (forward or backward), so alternatively, you can use the sysvar(1). Have a look at statedef 40 in the common1.cns to see how that specific variable is used - then instead of setting a variable like I described, you'll only need to read that variable the same way it's used in statedef 40.
Statedef 40 said:
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
If I struggled to the end of my determination, to the end of my way of life with my followers, if the result is ruin, then this ruin is inevitable. Grieve. Shed tears. But you cannot regret.
Last Edit: July 12, 2009, 07:47:14 pm by Byakko
Re: A mid-air special move question
#3  July 12, 2009, 09:39:18 pm
  • ***
  • 我が名は 「ハクメン」、押して参る!
my character doesn't have a specific common1.cns, and I didn't write any statedef for the basic movements like stand, walk, or jump. Are their statedef required to make this work?
Re: A mid-air special move question
#4  July 12, 2009, 09:40:48 pm
  • ******
... they're in the common1.cns. which is located in the "data" folder. It's called common because it's used by all the characters.Look at your .def file, there's one line that says data/common1.cns.
If I struggled to the end of my determination, to the end of my way of life with my followers, if the result is ruin, then this ruin is inevitable. Grieve. Shed tears. But you cannot regret.
Re: A mid-air special move question
#5  July 13, 2009, 02:12:19 pm
  • ***
  • 我が名は 「ハクメン」、押して参る!
it's still not working, here's what I wrote
[mcode][statedef 1400]
type=A
movetype=A
physics=N
poweradd=30
velset=0,0
ctrl=0
anim=1200
sprpriority=2

[state 1400,1]
type=helper
trigger1=animelem=6
stateno = 7010
pos = 55,-68
ownpal = 1
keyctrl = 0
ID = 7002

[state 1400,4]
type=statetypeset
trigger1=animelem=7
type=A
physics=A

[State 1400, 6]
type = VelSet
trigger1 = animelem = 8
x = ifelse(sysvar(1)=0, const(velocity.airjump.neu.x), ifelse(sysvar(1)=1, const(velocity.airjump.fwd.x), const(velocity.airjump.back.x)))
[/mcode]

my intention is for him to do the move with no velocity in mid-air then fall down according to his original speed, now the character stays still when doing the move, but always drops straight down regardless of his original velocity
Re: A mid-air special move question
#6  July 13, 2009, 02:25:19 pm
  • ******
Odd, the sysvar(1) must have a reset at some point. Maybe it's reset when physics isn't A or something, I dunno, can't check right now (it shouldn't though, since statedef -2 isn't in the common file). You can always try saving in a variable the x velocity you enter the state in before setting it to 0, and then reading that variable at the end.
Also, just to check, try adding a [mcode]DisplayToClipboard[/mcode] to display in the debug mode (ctrl+d while fighting) the value of sysvar(1) and see if it resets somewhere.


... You do have a velocity.airjump.back/fwd.x set to a correct value in your data section at the top of your .cns file, right ? You're sure it shouldn't be just jump and not airjump if your character doesn't have an airjump and you just left it at 0 ?
If I struggled to the end of my determination, to the end of my way of life with my followers, if the result is ruin, then this ruin is inevitable. Grieve. Shed tears. But you cannot regret.
Last Edit: July 13, 2009, 02:34:18 pm by Byakko
Re: A mid-air special move question
#7  July 13, 2009, 04:56:17 pm
  • ******
  • [E]
    • Mexico

  • Online
delete the velset =0,0 in the statedef part, you should do that for all aerial moves anyway.
Re: A mid-air special move question
#8  July 13, 2009, 05:00:19 pm
  • ******
It's just for this one, he wants it to stop still at the beginning of the move. Putting the velset at the beginning (instead of, say, a state controller triggered by time = 0) shouldn't influence sysvar(1), does it ?
If I struggled to the end of my determination, to the end of my way of life with my followers, if the result is ruin, then this ruin is inevitable. Grieve. Shed tears. But you cannot regret.
Re: A mid-air special move question
#9  July 13, 2009, 05:12:01 pm
  • ******
  • [E]
    • Mexico

  • Online
as you said, sysvar might have reset at some point, so it's better to not make the vel0 in the statedef, then save the vel in a fvar.
Re: A mid-air special move question
#10  July 13, 2009, 05:18:33 pm
  • ******
To be honest I suspect much more the fact that he used his velocity.airjump constant instead of just velocity.jump. I'm also wondering what use it would be of Elecbyte to have sysvar reset at some point, considering the common1 already has a varset setting sysvar(1) to 0 at the beginning of the jump states. Which should be, along with the "gethit-bounce" state, the only one needing this sysvar.
If I struggled to the end of my determination, to the end of my way of life with my followers, if the result is ruin, then this ruin is inevitable. Grieve. Shed tears. But you cannot regret.
Re: A mid-air special move question
#11  July 13, 2009, 05:28:27 pm
  • ******
  • [E]
    • Mexico

  • Online
yeah, airjump is wrong, most likely, unless he copied the ground jump values ot ir jump.
Re: A mid-air special move question
#12  July 14, 2009, 02:08:33 am
  • ***
  • 我が名は 「ハクメン」、押して参る!
I deleted the velset in the original statedef and the character falls according to original speed but doesn't pause in mid-air like I intended it to do. And everytime I try adding velset of any sort to pause the character it stops all together like before, here is my code
[mcode][statedef 1400]
type=A
movetype=A
physics=N
poweradd=30
ctrl=0
anim=1200
sprpriority=2

[state 1400,1]
type=helper
trigger1=animelem=6
stateno = 7010
pos = 55,-68
ownpal = 1
keyctrl = 0
ID = 7002


[state 1400,4]
type=statetypeset
trigger1=animelem=7
type=A
physics=A
velset=ifelse(sysvar(1)=0, const(velocity.airjump.neu.x), ifelse(sysvar(1)=1, const(velocity.airjump.fwd.x), const(velocity.airjump.back.x))),-5
[/mcode]

what am I doing wrong? appreciate the help, thank you
Last Edit: July 14, 2009, 03:09:34 am by juggernaut117
Re: A mid-air special move question
#13  July 14, 2009, 11:33:42 am
  • ******
Did you somehow miss all the times I pointed out that HEY ARE YOU SURE USING AIRJUMP INSTEAD OF JUMP IS RIGHT ??

on the velset :
-either you put the velset in the statedef definition (the one you just took off at the very top of the statedef)
-or you put a type = velset state controller
if you remove the velset at the begining of the statedef, you have to put a type = velset controller elsewhere. If you don't, of course your character will never pause, because you never tell it to.


...
[mcode][state 1400,4]
type=statetypeset
trigger1=animelem=7
type=A
physics=A
velset=yada yadda[/mcode]
Look at this, this is what you wrote. Can you click on "statetypeset" ? It sends you to the docs on statetypeset. Read it.
Do you find in it anything that says you can put a velset in it ?
No ? It's because you can't.
You have to use a regular "type = velset" like you did the first time around.
If I struggled to the end of my determination, to the end of my way of life with my followers, if the result is ruin, then this ruin is inevitable. Grieve. Shed tears. But you cannot regret.
Last Edit: July 14, 2009, 11:42:55 am by Byakko
Re: A mid-air special move question
#14  July 14, 2009, 02:14:57 pm
  • ***
  • 我が名は 「ハクメン」、押して参る!
ok, I added a velset to the original statedef, and I added another velset state after the statetypeset and I also changes airjump into jump. The character paused like it should, but after changing statetype, only the y component of the velset worked, while the really really long x part didn't, so I figure there must be something wrong with the really long x part.
Re: A mid-air special move question
#15  July 14, 2009, 02:35:43 pm
  • ******
Also, just to check, try adding a [mcode]DisplayToClipboard[/mcode] to display in the debug mode (ctrl+d while fighting) the value of sysvar(1) and see if it resets somewhere.
Statedef 40 said:
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
This should be all you need. Try again from the start.
Open the statedef with a velset at 0,0 then add a velset with thie above for x at the end.
If I struggled to the end of my determination, to the end of my way of life with my followers, if the result is ruin, then this ruin is inevitable. Grieve. Shed tears. But you cannot regret.
Re: A mid-air special move question
#16  July 14, 2009, 10:30:40 pm
  • ***
  • 我が名は 「ハクメン」、押して参る!
I used displaytoclipboard, and when I executed the move, it said sysvar(1) is 0, and it stayed like that, so I guess this means that the sysvar reset itself somehow. I'm sorry but I'm just really terrible with variables, what am I suppose to do now? Thank you
Re: A mid-air special move question
#17  July 14, 2009, 11:37:36 pm
  • ******
Okay crash course.

A variable is like a box where you put a number at some point and then look at later on to retrieve that number. You can only put one number at a time in it. You put a number in it, it removes the one that was already there.
You have by default around 60 variables you can use. Their default value is 0, and you can pick one (such as var(1) or var(10) and so on), put a value in it and then look later at the same variable to retrive that value. You take one variable (such as var(1)), you change its value at one point, you look at it later on, you change it again, and so on. Whenever you give a value to a variable, you lose the previous value.
The only thing with variables is that their value changes with time, so the point is to know what value is in it at a given time. Simply, don't put yourself in a situation where you put a new number in a variable you already use somewhere, because if you then go to another state that expects to find a certain value in it, it'll come out wrong. For example, at one point you put your vel x in a  given variable, later on you put, say, the distance to your opponent in the same variable, then later on you enter a state that tries to look for the vel x you saved previously, but it has been erased when you put the distance just before. that's where things screw up. If at one point you put a velocity in a variable, if later on you want to retrieve that velocity, you must be sure that you didn't change it for something else, like distance, inbetween.
If you put in the variable the value of your x velocity at the entrance of a state, at the end of the state you know that what's in it is still the same value. It will change the next time you give it another value - or the next time you enter the same state.

First, remove the velset in the state definition (at the top of the statedef). When you enter the state at time = 0, use a [mcode]type = varset[/mcode]and you specify which variable you want to use (for example, var(1) if you don't use it anywhere else) and you give it the value of your current vel x. Like so [mcode][state air fireball]
type = varset
trigger1 = !Time
var(1) = vel x[/mcode]Then still at time = 0, you use a velset to stop your character.
At the end of the state, you use a velset and you give the value memorized in that variable to your x velocity. Like so : x = var(1). Look at the trigger docs on var too.
And you're done.
If I struggled to the end of my determination, to the end of my way of life with my followers, if the result is ruin, then this ruin is inevitable. Grieve. Shed tears. But you cannot regret.
Last Edit: July 14, 2009, 11:52:09 pm by Byakko
Re: A mid-air special move question
#18  July 15, 2009, 01:07:15 am
  • ***
  • 我が名は 「ハクメン」、押して参る!
wow...that was the best crash course I've ever taken, problem officially solved, AND I know the basics of variables, thank you  :sugoi:
Re: A mid-air special move question
New #19  July 15, 2009, 01:19:52 am
  • ******
Oh, detail I forgot : regular variables only take integers. If you want to put a float value, you use... a float variable. those are the fvar. I can't remember if there are as many fvars as vars or if there's a little less (50 instead of 60 ?) but it works the same, they are an additional group of variables that take float numbers. Use that for stuff like ground x velocity or y velocity.
Air x velocity in a jump doesn't really need that if your jump x velocity is an integer, since it will always be an intger until you get hit or land. But if you get hit in the air, or if you're on the ground where friction is applied, then it's (probably) going to be a float number and you'll need a float variable.
Well, that's a detail. You'll find more on that in the docs, but it's basically always the same thing. To be sure, turn on the debug mode, and if you get a debug flood telling you it truncated a value, then it means you probably put a float number in a regular var. If it doesn't, you're safe.
Bottom line is, just know what variable represents what.
If I struggled to the end of my determination, to the end of my way of life with my followers, if the result is ruin, then this ruin is inevitable. Grieve. Shed tears. But you cannot regret.
Last Edit: July 15, 2009, 01:28:35 am by Byakko