YesNoOk
avatar

Advanced CNS Prrograming (Read 4393 times)

Started by FoQuS, October 30, 2007, 08:45:01 pm
Share this topic:
Advanced CNS Prrograming
#1  October 30, 2007, 08:45:01 pm
  • *
I am currently programming a Piccolo for UB22.  I learned the basics and he has a nice set of moves with what i would say is low moderate - moderate programming. I believe that if i can learn how to take advantage of vairiables i can make my character more fluid, solid and balanced. Can anlyone help me understand variables and more advanced CNS programiing? and what advantages there are to using variables?
Thanks
FoQ
Re: Advanced CNS Prrograming
#2  October 30, 2007, 08:58:37 pm
  • ******
  • [E]
    • Mexico
Re: Advanced CNS Prrograming
#3  October 30, 2007, 09:03:02 pm
  • *
Thx. That on helped me to understand how variable are manipulated, however I still dont get how to set them up proporly in terms setting them  state -2 vs -3 or in a normal state of the character.
Re: Advanced CNS Prrograming
#4  October 31, 2007, 04:23:55 am
  • *****
    • Peru
That depends on what do you want to do.
Exactly what use are you going to give to your character variables?
Re: Advanced CNS Prrograming
#5  October 31, 2007, 05:22:27 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
Variables won't really make anything more fluid. Precise triggering and lots of time spent checking and changing values will. Using variables doesn't actually make you a good coder. Novel use of everything available will though.

If you can get your head around all the different ways of using variables you can have some fun with them but they won't instantly improve your character.

Practice makes perfect.


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.
Re: Advanced CNS Prrograming
#6  October 31, 2007, 06:20:44 pm
  • ******
  • [E]
    • Mexico
while not directly related to programming, but directly related to improving, there are two things you should study.

first, fighting game theory,design and mechanics.. this might be the funniest thing, as it is done by watching fighting game videos and playing fighting games, and if you are into mugen and creating stuff, you should already like fighting games.. a video like that http://youtube.com/watch?v=7KQJonJ6XoQ , is very useful to grasp concepts, as well as combo and tournament videos.

second, study physics and math, just a bit, even the most basic concepts on both subjects will help you improve tremendously.
Re: Advanced CNS Prrograming
#7  October 31, 2007, 08:43:53 pm
  • *
I am mainly interested in using the variable for charging attacks. E.G i created a ChangeAnim triggered by a "hold_y" command. I was attempting to create a variale that would increase damage as the "hold_y" is held down. When released, the variable value would be added to the damage of a hitdef. Also i would lke to use variable in my juggles and to create a transformation state that would persist after it is initiated. it would add damage, defense, speed, life and power to the char
Re: Advanced CNS Prrograming
#8  October 31, 2007, 09:15:10 pm
  • ******
  • [E]
    • Mexico
sounds like a plan.
Re: Advanced CNS Prrograming
#9  October 31, 2007, 10:44:55 pm
  • *
Triggering is another thing. again i know the basics but lack advanced triggering methods
Re: Advanced CNS Prrograming
#10  November 01, 2007, 11:31:28 am
  • avatar
  • ******
If it's a move where the character goes in a state when you press y, holds, and doesn't leave it until you release y, then you don't need a variable, just count the time he stays in it. If you stay in the same statedef when releasing you can use time, but if you go to a different state for the actual attack when releasing, you have to store the time in a variable just before changing state.
If it's a move sorta like Raiden's dropkick or Bison's chargeable punch, then it's a variable. Start counting when you enter the first state, then in statedef -2, keep adding 1 to the variable as long as it's != 0, when you release (if you have control) go to the attack state and transfer the variable then put it back to 0, but if you release it without having control, you won't change state, and don't forget to still reset the var to 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.
Re: Advanced CNS Prrograming
#11  November 01, 2007, 09:32:07 pm
  • *
I woul like to hold_y on animelem = 3 for a maximum of 3 seconds. When 3 seconds are up , or if the button is release, the move would goto the next animelem which has a HitDef with damage modified by the holding duration from 0 - 3 seconds.
1) How do you track time while holding "Y"
2) How do you turn off the "timecounter" in the same state?
3) How do i add the damage to the hitdef E.G. (damage = [1,60(based off of duration)]+40

also are you saying
[State Blah]

type = Varset
trigger1 = animelem = 3
value = 1
v = 0

[Statedef -2]
type = varadd
Trigger1 = time = 0
value = 1
v = 0

will add 1 to var(0)?
Re: Advanced CNS Prrograming
#12  November 01, 2007, 10:15:09 pm
  • avatar
  • ******
Well, there can be various ways. The most straight forward would be the variable, yes (there are workarounds to avoid using a variable, but it would only be to have fun making it complicated for no real reason :P).
So, the variable.
[state blah]
type = varset
trigger1 = animelem = 3, = 0
var([number of your variable]) = 0
[state blah]
type = varadd
trigger1 = animelem = 3, > 0 && animelem = 4, < 0
trigger1 = command = "hold_y"
v = [same number]
value = 1
[state blah]
type = changeanim
trigger1 = animelem = 3, > 2 && animelem = 4, < 0
trigger1 = command != "hold_y"
trigger2 = var([same number]) >= 180 && animelem = 4, < 0
value = anim
elem = 4

Then, in the hitdef,
damage = 40 + var([still same number])
Charging to the max would give 220 damage with that formula. Manipulate var([number]) (like, var([number])/2 or whatever) as you want to adjust the damages.
If you didn't hold y at all, anim elem 3 will display for only 2 ticks and the total damage will be 40 ; hold y for one second and anim elem 3 will display for 60 ticks (1 second) with damages be of 40+60=100...
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: November 01, 2007, 10:18:59 pm by Baiken
Re: Advanced CNS Prrograming
#13  November 01, 2007, 11:22:55 pm
  • *
AHA!!! Thx it all makes sense except the ,< 0 and ,> 0.
Re: Advanced CNS Prrograming
#14  November 01, 2007, 11:46:30 pm
  • avatar
  • ******
The trigger "animelem = 3, > 0" is "true" at any time in the animation past one tick after the third element. It's actually the exact same as writing "animelemtime(3) > 0", just that I'm more used to the former for some reason. Don't mind that. Ditto with "animelem = 4, < 0" it's "true" at any point before the 4th element, meaning it's the same as animelemtime(4) < 0.
So, the whole trigger is "true" at any time during anim elem 3, starting from one tick after the beginning up to the end of elem 3.
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: Advanced CNS Prrograming
#15  November 01, 2007, 11:49:20 pm
  • *
ahhhh i get it thx.......i was wondering how to specify tics whithin an element ;D
Re: Advanced CNS Prrograming
#16  November 02, 2007, 01:54:54 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
If either of those elude you, remember time is always an option.

Time > 10 for eg would work just as well as animelemtime(3) >= 0


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.
Re: Advanced CNS Prrograming
#17  November 02, 2007, 07:10:55 pm
  • *
OK...another problem is that i Have a "power charge" state which of course adds power while holding "a+x". aand all that worls fine hower, i have several explods that are drawn when the power meter reaches a cirtain value e.g 2000, 4000. My first explood draws fines however when i try to get my second and third explods to draw using 

trigger1 = power >= 2000

for example the sprites are distorted (by the way  the way i am using "A" on my transparencies). I can set the triggers to

time = 0 && power >=2000

but then i have to end the state and press the command again to see the new explods . How can i trigger  my additinal explods without them drawing distorted.

PS i think my imagination is past my progoming...lol
Re: Advanced CNS Prrograming
#18  November 02, 2007, 08:05:22 pm
  • ******
  • [E]
    • Mexico
if they are distorted, it has nothing to do with the trigger.
Re: Advanced CNS Prrograming
#19  November 02, 2007, 08:27:57 pm
  • *
well... if i trigger them at time = 0 they display fine
Re: Advanced CNS Prrograming
#20  November 02, 2007, 08:29:42 pm
  • ******
  • [E]
    • Mexico
post your code...
Re: Advanced CNS Prrograming
#21  November 04, 2007, 01:40:42 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
You're changing explod as you travel up the power settings. You need to remove the old one when you hit a new setting.

Creation triggers are power > 1000, power = [1000,1999] and power = [2000,3000]

Give each explod an unique ID and remove it when power > 1000/2000

All same state.


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.
Re: Advanced CNS Prrograming
#22  November 13, 2007, 11:05:37 pm
  • *
post your code...

[Statedef 1000]
Type =S
physics = S
anim = 1000
ctrl = 0
velset = 0,0

[State 1000, PowerAdd]
type = PowerAdd
trigger1 = ((GameTime%3) = 0) && (command = "hold_x") && (command = "hold_a")
value = 25


[State 1000, Explod]
type = Explod
;trigger1 = animelem = 4
trigger1 = power > 2000
;trigger1 = (command = "hold_x") && (command = "hold_a")
;trigger1 = command = "hold"
trigger1 = time = 0
anim = 1100
ID = 1100
pos = 0,0
postype = p1  ;p2,front,back,left,right
facing = 1
vfacing = 1
bindtime = 1
vel = 0,0
accel = 0,0
random = 0,0
removetime = -1
;supermove
;ausemove
scale = 1,1
sprpriority = 3
ontop = 1
shadow = 0,0,0
ownpal = 1
removeongethit = 0
trans = add

[State 1001, RemoveExplod]
type = RemoveExplod
trigger1 = (command != "hold_x") || (command != "hold_a")
id =  1100

[State 1000, Explod]
type = Explod
trigger1 = animelem = 4
trigger1 = power <= 2000
anim = 6030;
ID = 6030;
pos = 0,0;-110,-190
postype = p1  ;p2,front,back,left,right
facing = 1
vfacing = 1
bindtime = 1
vel = 0,0
accel = 0,0
random = 0,0
removetime = -1
supermove
pausemove
scale = 1,1
sprpriority = 2
ontop = 0
shadow = 0,0,0
ownpal = 0
removeongethit = 0
;ignorehitpause =
;persistent =

[State 1000, RemoveExplod]
type = RemoveExplod
trigger1 = time = 0
trigger1 = power > 2000
id = 6030;Var(9)
;ignorehitpause =
;persistent =

[State 1000, Explod2]
type = Explod
trigger1 = AnimElem = 4
trigger1 = power >= 4000
anim = 6192
ID = 6192
pos = -60,60
postype = p1  ;p2,front,back,left,right
facing = 1
vfacing = 1
bindtime = 1
vel = 0,0
accel = 0,0
random = 0,0
removetime = -1
;supermove
;ausemove
scale = 1,1
sprpriority = 2
ontop = 0
shadow = 0,0,0
ownpal = 1
removeongethit = 0
trans = add

[State 1000, Explod]
type = Explod
trigger1 = animelem = 4
anim = 6031
ID = 6031
pos = 0,3
postype = p1  ;p2,front,back,left,right
facing = 1
vfacing = 1
bindtime = 1
vel = 0,0
accel = 0,0
random = 0,0
removetime = -1
scale = 1,1
sprpriority = 0
ontop = 0
shadow = 0,0,0
ownpal = 0
removeongethit = 0
;ignorehitpause =
;persistent =


[State 1000, EnvShake]
type = EnvShake
trigger1 = time > 44
trigger1 = TimeMod = 4,0
time = 4
freq = 60
ampl = -4
;phase = 90
;ignorehitpause =
persistent = 1

[State 1000, PlaySnd]
type = PlaySnd
trigger1 = Time = 0
channel = 1
value = 1100, 0

[State 1000, PlaySnd]
type = PlaySnd
trigger1 = Time = 0
channel = 1
value = 1100, 2
loop = 1

[State 1000, PlaySnd]
type = PlaySnd
trigger1 = time = 44
channel = 2
value = 1100, 1
loop = 80

[State 1000, End]
type = ChangeState
trigger1 = (command != "hold_x") || (command != "hold_a")
trigger2 = power = 2000
trigger3 = power = 4000
value = 1001

[State 1000, End]
type = null;ChangeState
trigger1 = (command != "hold_x") || (command != "hold_a")
trigger2 = power = 4000
value = 1001
Re: Advanced CNS Prrograming
#23  November 13, 2007, 11:37:34 pm
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
You have 2 removeexplods. 1 will only trigger if you release X or Y, the other one only triggers when you enter the state.

You need 1 removeexplod, per explod, with the conditions it should be removed under.

For example the level 1 version should always be removed when power > 1000 OR when you release the keys.


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.