What defines a variable?

Started by JLS, December 14, 2009, 12:37:05 AM

Previous topic - Next topic

JLS

Spoiler: Unnecessary tl;dr (click to show)
Hi, I'm just starting to get my feet wet in coding a character. I've read the majority of the documentation and I have began taking steps towards making a character from KFM scratch. I want to making a character based on cvs2 gameplay so I've been looking at characters made by warusaki, H, and jesuszilla as reference.

Everything looks pretty advanced and complicated so I've been trying to take my time in trying to learn whats going on in there. Unfortunately even the very first attack state has me stumped at figuring out the what, why, and how of this block of code. Take this hiddef from warusaki's ryu's light punch.
[State 200, 1]
type = Hitdef
trigger1 = AnimElem = 2
attr = S, NA
hitflag = MAF
guardflag = M
animtype = Light
air.animtype = back
fall.animtype = back
priority = 3,Hit
damage = ceil(ifelse((21*fvar(10))<7,7,(21*fvar(10))))
pausetime = ceil(9*(2-(var(16)>0))/2),ceil(9*(2-(var(16)>0))/2)
guard.pausetime = ceil(9*(2-(var(16)>0))/2),ceil(8*(2-(var(16)>0))/2)
sparkno = S8200+(random%8)
guard.sparkno = S8100
sparkxy = -10, -78
hitsound = S2, 0
guardsound = S1, 0
ground.type = High
air.type = High
ground.slidetime = 10+(var(41)*2)
ground.hittime = 10+(var(41)*2)
air.hittime = 10+(var(41)*2)
guard.ctrltime = 11
ground.velocity = -6*(2-(var(16)>0))/2
guard.velocity = -5*(2-(var(16)>0))/2
air.velocity = -4, -5.25
airguard.velocity = -4,-1
ground.cornerpush.veloff = -8.4*(2-(var(16)>0))/2
air.cornerpush.veloff = 0
airguard.cornerpush.veloff = 0
getpower = 70*(1000+var(24))/1000*!(var(15)||var(16)),35*(1000+var(24))/1000*!(var(15)||var(16))
givepower = 35, 35
persistent = 0
air.fall = 1
fall.recover = !var(16)
air.recover = !var(16)
palfx.time = 12*var(41)
palfx.add = 255,255,255
palfx.mul = 128,128,128
yaccel = .5
nochainID = var(40)

I understand the functions of the parameters well enough as they are either explained in the docs or self explanatory by title, but I am totally lost when it comes to their values (specifically anything inside parentheses).

damage = ceil(ifelse((21*fvar(10))<7,7,(21*fvar(10))))

What is going on here? I've looked up the meaning of ceil and ifelse in the trigger list, but some things just wern't clicking for me (maybe because I haven't had a math class since freshman year, let alone ANYTHING involving any kind of computer coding).

While typing this and looking at the trigger list again I do understand what ceil and ifelse do and I realize that the () all contain smaller expressions that make up the overall expression, but what defines the fvar?

What defines the properties of var and fvar? I've been reading the docs and kfm.cns half the day. I see them in use and I know what the two vars in KFMs do, but I can't find anything in the cns that show "var(1) = n" or "[var(2)def]". I couldn't find the answer in the docs either so could someone please point out what I am overlooking?

Byakko

Quotebut what defines the fvar?
Some other code somewhere else in the file. somewhere, there are "type = varset"s and "type = varadd"s that change the values of the variables as needed.
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.