YesNoOk
avatar

Variables (Read 4962 times)

Started by Just No Point, June 04, 2014, 06:01:13 pm
Variables
#1  June 04, 2014, 06:01:13 pm
  • ******
    • www.justnopoint.com/
1 = Tells which button is being pressed
example
Code:
[State 1000, Button Detect]
type = VarSet
trigger1 = !Time && !AILevel
var(1) = ifElse((command = "x" || command = "rlsx"), 0, ifElse((command = "y" || command = "rlsy"), 1, 2))
Code:
[State 1000, ChangeAnim]
type = ChangeAnim
trigger1 = !Time
value = 1000+var(1)


-------------------------

2 = delayed pausetime variable
example
Code:
    [State 205, Time Offset]
    type = VarSet
    trigger1 = moveContact = 1
    var(x) = Time
    ignorehitpause = 1
    persistent = 0

    [State 205, Play Anim]
    type = ChangeAnim
    triggerall = AnimElemTime(y) >= 0 && AnimElemTime(z) <= 0 
    trigger1 = hitPauseTime = [1,{pausetime} - ({total number of frames up until the end of the first frame of animation} - Var(x))]
    value = anim
    elem = z
    ignorehitpause = 1
Last Edit: June 04, 2014, 07:53:35 pm by Just No Point
Re: Variables
#2  June 04, 2014, 07:20:09 pm
  • *****
  • Hedgehog Whisperer
  • Red Bull addict
    • Spain
    • xgargoyle.mgbr.net
Quote
value = ifElse(var(1) = 0, 1000, ifElse(var(1) = 1, 1001, 1002))

Come'on what's wrong in doing it easier? :P
value = 1000+var(1)
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: Variables
#3  June 04, 2014, 07:42:42 pm
  • ******
    • www.justnopoint.com/
Nothing at all! I just didn't think about doing it that way. @JMorphMan: set his up like this. Optimization isn't my focus while I'm learning =p

I'll change those.
Re: Variables
#4  June 04, 2014, 07:50:05 pm
  • ******
  • I'm not pushing you away,
  • I'm pulling *me* towards myself!
    • USA
    • network.mugenguild.com/jmorphman
I did it that way because PotS did it (this is the answer to every question ever about coding from me, BTW) but also since my animations usually go like 1000,1010,1020 instead of 1000,1001,1002. And doing 1000 + var(10) * 10 is just blugh. It's ugly!
Re: Variables
#5  June 04, 2014, 08:08:41 pm
  • ****
  • Busy, busy, busy
    • www.trinitymugen.net/forum/index.php
I do it both ways since I tend to code in my sleep :p. You should probably decide your variables before you get to the code. Its a pain in the ass later when you want to use vars 22-25 only to realize you used 24 randomly :p. Try to keep related stuff together. Like 6-8 for cancels. Fvar(10)-12 for dampening. etc

-
http://www.Trinitymugen.net/Hosted/CFJ2/
-
thanks again Vans/Jesuszilla!
Re: Variables
#6  June 04, 2014, 10:32:38 pm
  • ******
    • www.justnopoint.com/
Since I'm making my 1st character I don't know what all will and won't need vars yet. This list is not final till Ryu and the mechanics are finished. It shouldn't be too tough to use fighter factory to replace all instances of a var later on. Once all vars are accounted for I'll reorder them.
Re: Variables
#7  June 16, 2014, 04:01:10 am
  • ******
    • www.justnopoint.com/
So, looking through the various coding archives/snippets I can see myself running through the variables pretty fast.

I have 60 vars and 40 float vars.
1. Don't use a variable if you don't have to. Using many variables could get confusing to you and it's just not even worth wasting them. If you need to use variables, make sure to jot down their usage for yourself and others who might want to edit your character.

2. Helpers have their own variables! Don't be afraid to use helpers for variables. If you know how to use redirection triggers, then using helpers to harness variables is not only convenient, you essentially have tons more variables at your disposal. Remember, though, just because you can, doesn't mean you should, and reading helpers' variables is slow by 1 tick in some cases, so it might not work as best as you may want.
Basically I should try to use the non helper variables for in fight stuff that needs 1 tick precision and I should use helper variables for anything that doesn't have to be that precise in battle. So all system related things should use a helper variable.

Are there any other tips to help me conserve variables early on so I do not mess myself up later? Besides don't use any that I don't have to use :P
Re: Variables
#8  June 16, 2014, 09:45:53 am
  • *****
  • Hedgehog Whisperer
  • Red Bull addict
    • Spain
    • xgargoyle.mgbr.net
Quote
Are there any other tips to help me conserve variables early on so I do not mess myself up later? Besides don't use any that I don't have to use

First you need to ask yourself, why do I need more than 60 vars for a Street Fighter based game?

It would be a good idea if you post the list of variables being used. I'm sure that some of them are either redundant or can be grouped into a single variable.

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: Variables
#9  June 16, 2014, 09:49:08 am
  • ******
There are tricks like bitwise operations to merge several values into a single variable, but that's starting to cause headaches.
For example, in my Jin, I use hi-res hitsparks, and I need one variable for the X and Y axis. Basically, my variable is X offset * 1000 + Y offset, so a spark placed on -10,-76 would give the variable the value 10076. To retrieve those values I use floor(var(x)/1000) and var(x)%1000. This isn't really bitwise operation, but it's close enough in base 10 - a method to have one variable hold several values. It's better if it makes sense that those values are related (like the X and Y axis of something).
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: Variables
#10  June 16, 2014, 11:11:29 am
  • ******
    • www.justnopoint.com/
First you need to ask yourself, why do I need more than 60 vars for a Street Fighter based game?

It would be a good idea if you post the list of variables being used. I'm sure that some of them are either redundant or can be grouped into a single variable.
Getting ready for work so I don't have a lot of time to look and see all the variables. I might not need over 60 at all. I'm just looking at various tutorials for specific things. Off memory Rolento's focus attack coding requires 4 variables by itself. Basically it's all the different types of mechanics from various SF games that worry me. Just looking through tutorials a lot need 2 or more variables. It feels like they will add up fast. But it might not be as bad as I'm making it out to be. Once I start using them I may see that in the end all of it still doesn't amount to 60 variables. Byakko mentioned that one user than ran out of variables real quick for their full game. So I'm just trying to prepare for the worst case scenario!
Re: Variables
#11  June 16, 2014, 12:06:24 pm
  • ******
Well, the user in question had tons of interactions with the stages and fixed elements in the stages and whatnot, so it was just an example of what to expect in a full game, but if there's no big fancy system, it shouldn't make much of a difference between one character or a full game. The other cases where you can run out of variables are people who implement big systems like CvS2's Grooves. Other than that, chances are you can make do with maybe 30 variables for everyone.
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.