YesNoOk
avatar

NAttacks.cns (Read 4138 times)

Started by recruta42, December 12, 2007, 01:26:28 am
NAttacks.cns
New #1  December 12, 2007, 01:26:28 am
  • **
  • Call me Private42.
I will describe here how to mount the normal attacks of the chars...Like always I won´t give a really detailed explanation unless asked...
For each of them I use some ready to use recipe that I always follow.

I can divide the normal attacks of the chars into 4 groups:

- 1 state grounded attacks (really basic ones)
- 2 states grounded attacks (those that have air to ground transition like running attacks and overheads)
- air attacks (the name says all)
- throws (idem air)


- 1 state grounded attacks

These are those states that only have one single state (don´t have transitions) and are made on the ground, not mattering if you are standing or crouching.

Recipe:

<Skeleton>
     - Sounds
     - Velocity
     - Attack sparks (optional)
     - Blood sparks
     - Hitdef
     - Swordpower
     - Recoil
<Skeleton>


1 - Skeleton

The basic skeleton for these states are like this:

;---------------------------------------------------------------------------
; <Name of the state>

[Statedef <Number>]
type    = <S for standing attacks, C for crouching attacks>                     
movetype= A                     
physics = N                     
juggle  = 1                     
velset = 0,0                     
ctrl = 0                         
anim = <Number>
facep2 = 1                                                           

[State <number>, changestate]
type = ChangeState
trigger1 = AnimTime = <0 for standing attacks , 11 for crouching attacks>
value = 0
ctrl = 1

;---------------------------------------------------------------------------



2 - Sounds

I always get the sounds from MAME mapping 16 bits starting at memory position 108F0E

After making the basic skeleton for the attack I put the sounds.

- Group 0 in common.snd maps the common sounds for all chars.
- Group 20 in common.snd maps the special sounds for each char in the game.
- Group 10 is <char_name>.snd maps the voices of the char.

Giving some sound examples: 

; Char voice

[State 230, PlaySnd]
type = PlaySnd
trigger1 = AnimElem = 3
value = 10, (22 + (random > 500))
persistent = 0
channel = 0

; Weapon sound attack
[State 230, PlaySnd]
type = PlaySnd
trigger1 = AnimElem = 3
value = F0, 19
persistent = 0


3 - Velocities

After putting the sounds I put the velocities and posadds for the moves.

Here I always try to use the least number of possible controls to deal with velocities...If, for example, I want the velocity of my char to be:

- 15 on animElem = 2 with an additional of -1 each gametick from AnimElem = 2, > 0 to AnimElem = 6 , < 0
- 0 on AnimElem = 6
- 3.5 on animElem = 8 with an additional of -0.5 each gametick from AnimElem = 8, > 0 to AnimElem = 10, < 0
- 0 on AnimElem = 10

[State xxx, Velset]
type = Velset
trigger1 = AnimElem = 2
trigger2 = AnimElem = 6
trigger3 = AnimElem = 8
trigger4 = AnimElem = 10
x = 15*(AnimElem = 2,=0)+3.5*(AnimElem = 8,=0)

[State xxx, Veladd]
type = Veladd
trigger1 = AnimElem = 2, > 0 && AnimElem = 6, < 0
trigger2 = AnimElem = 8, > 0 && AnimElem = 10 < 0
x = -0.1*(AnimElem = 2, > 0 && AnimElem = 6, < 0)-0.5*(AnimElem = 8, > 0 && AnimElem = 10 < 0)


4 - Attack sparks



If you are making one of those attacks that requires slash sparks you can call it by using a special helper that points to the current state + 1, so if you are at stateno 200,  the spark state will set at stateNo 201.

An example of the four spark animations above in .AIR is:

[Begin Action 2000281]
281, 0, 0, 0, 1, , AS200D128

[Begin Action 2001281]
281, 1, 0, 0, 1, , AS200D128

[Begin Action 2002281]
281, 2, 0, 0, 1, , AS200D128

[Begin Action 2003281]
281, 3, 0, 0, 1, , AS200D128

The helper to call it is this on here:

[State xxx, helper]
type = helper
trigger1 = AnimElemTime(When it starts) >= 0
helpertype = Normal
ID = <Stateno+1>
pos = 0,0
postype = p1
stateno = <Stateno+1>
name = "<Name>"   
ownpal = 0
persistent = 0

The helper state byitself can be examplified as the following:

;---------------------------------------------------------------------------
; <Name of the spark state>

[Statedef <stateno>]
type    = S
movetype = I
physics = N
sprpriority = 5
ctrl = 0

[State xxx, VarRandom]
type = assertspecial
trigger1 = Gametime%2=0
flag = invisible

[State xxx, BindToParent]
type = BindToParent
trigger1 = 1
facing = 1
pos = 0,0
time = -1

[State xxx, SprPriority 1]
type = SprPriority
trigger1 = parent, Anim = <root anim>
value = 5

[State xxx, ChangeAnim]
type = ChangeAnim
triggerall = parent, Var(1) = 0
trigger1 =  (parent, AnimElemTime(<time>) = 0) && (parent,Anim = <root anim>)
value = <sparkanim>
persistent = 0
ignorehitpause = 1

[State xxx, ChangeAnim]
type = ChangeAnim
triggerall = parent, Var(1) = 0
trigger1 =  (parent, AnimElemTime(<time>) = 2) && (parent,Anim = <root anim> )
value = <sparkanim>
persistent = 0
ignorehitpause = 1

[State xxx, ChangeAnim]
type = ChangeAnim
triggerall = parent, Var(1) = 0
trigger1 =  (parent, AnimElemTime(<time> ) = 0) && (parent,Anim = <root anim>)
value = <sparkanim>
persistent = 0
ignorehitpause = 1

[State xxx, ChangeAnim]
type = ChangeAnim
triggerall = parent, Var(1) = 0
trigger1 =  (parent, AnimElemTime(<time>) = 2) && (parent,Anim = <root anim>)
value = <sparkanim>
persistent = 0
ignorehitpause = 1

[State xxx, Destroyself]
type = destroyself
trigger1 = parent,AnimElem = <When if finishes>
trigger2 = parent,Anim != <root anim>


5 - Blood sparks

I usually do this only after the hitdef but for sequencial purposes....

To facilitate our lives I just created another series of helpers on common.cns so when we hit an attack we just call this helper and let the rest with him.

This helper varies from attack to attack and the main factors that alter it is if the char is sworded or bare handed, etc..

[State xxx, helper]
type = helper
trigger1 = movecontact
helpertype = Normal
ID = 4900
pos = <X>, <Y>
postype = p2
stateno = <Bloods_park>+<Defended_spark>*(Moveguarded)
name = "bloodspark"   
ownpal = 0
persistent = 0
ignorehitpause = 1

List of hit spark states at the moment:

- 4900 - vertical sword blood
- 4901 - horizontal sword blood
- 4902 - swordless attack

- 4050 - normal defence
- 4051 - bare handed defence

So, if you want an horizontal sword blood combination you need to do at stateno: stateno = 4901+49*(Moveguarded)

-----------------------------------------------
6 - HitDef


For this one, just check this topic:

http://mugenguild.com/forumx/index.php?topic=68209.0


7 - Swordpower

Here is the amount of power you will subtract from the sword bar if you miss a hit or it was guarded. How it works on SS5Sp?

Situations where you have your sword bar subtracted:

- successfull hit (any attack)
- all normal missed hits (except those using kick)
- all normal guarded hits (except those using kick)

In a successfull hit you will lose sword power equal to the same amount of damage divided by 10...so if you score a 248 hit damage you will lose 24.8 sword bar.

If a normal hit is missed (the exact AnimElem after the last attack inside the state) you will lose sword bar according to this table:

[State XXX, Varadd]
type = Varadd
trigger1 = AnimElem = <After last attack inside state>
fv = 30
value = <table>

table:

value = -5.859375  ;Weak attack
value = -9.765625  ;Medium attack
value = -15.625 ;Hard attack

If your move is guarded and you were put inside a recoil state you will lose:

value = -7.8125 ;Weak attack
value = -11.71875  ;Medium attack
value = -17.578125 ;Hard attack

PS: You only need to program the normal missed hits according to the example above.


8 - Recoil

Some normal attacks put you in a recoil state (160 - 162 for standing attacks, 165 - 167 for crouching attacks) when are defended by the enemy. Unfortunatly I don´t know if it is a bug or you can transfer the pause hit time from one state into another, so to remedy this I used var(7)

So if you want to send put your char into a recoil state after a defended hit FIRST you have to put ZEROOOO in the guard pause time for P1 on the hitdef like:

guard.pausetime = 0,<p2>

After you have to send him to the apropriated recoil state with these 2 sctrls:

[State xxx, varset]
type = varset
trigger1 = time = 0
v = 7
value = <pausetime>

[State xxx, changestate]
type = ChangeState
trigger1 = Moveguarded || Movereversed
value = <recoil state>
ignorehitpause = 1

On the first one you set the pausetime that you want for him to be at the recoil state (usually p2 guarded pausetime +1) and in the second you set the recoil state for the attack:

160 - stand weak attack
161 - stand medium attack
162 - stand hard attack
165 - crouch weak attack
166 - crouch medium attack
167 - crouch hard attack


DONE!


Now an example of Kyoshiro´s running hard attack to give you an almost complete idea of the process:


;---------------------------------------------------------------------------
; Running Hard Sword

[Statedef 280]
type    = S                     
movetype= A                     
physics = N                     
juggle  = 1                     
velset = 0,0                     
ctrl = 0                         
anim = 280                                                           
facep2 = 1

[State 280, PlaySnd]
type = PlaySnd
trigger1 = AnimElem = 1
value = F0, 49
persistent = 0

[State 280, PlaySnd]
type = PlaySnd
trigger1 = AnimElem = 7
value = F0, 22
persistent = 0

[State 280, Velset]
type = Velset
trigger1 = time = 0
trigger2 = AnimElem = 9,=5
x = 3.99609375*(time = 0)

[State 280, Velset]
type = Veladd
trigger1 = time > 0 && AnimElem = 9, < 5
x = -0.1875

[State 280, helper]
type = helper
trigger1 = AnimElemTime(8) >= 0
helpertype = Normal
ID = 281
pos = 0,0
postype = p1
stateno = 281
name = "RHSspark"   
ownpal = 0
persistent = 0

[State 280, helper]
type = helper
trigger1 = movecontact
helpertype = Normal
ID = 4900
pos = -6, -46
postype = p2
stateno = 4901+49*(Moveguarded)
name = "bloodspark"   
ownpal = 0
persistent = 0
ignorehitpause = 1

[State 280,Hit]
type = HitDef
trigger1 = AnimElem =  8, =3
attr = S,NA                  
hitflag = MA             
guardflag =   MA                            
;-------------------------------------------------
animtype =  up
priority = 4, Hit
;-------------------------------------------------
damage = floor((fvar(30)/(256/(15.0*2-4.0))+ceil(0.4375*15.0-0.79)+ random/480.0)*(1.0 + 0.41*(fvar(30)=80 && var(26)<16384)+0.72*(fvar(30)=104))*10.0),10*(enemyNear,var(1) = 1)
pausetime = 7,6
guard.pausetime = 7,6
ground.velocity = -3.5,-9.720703125+0.501953125*(facing = enemyNear,facing)
guard.velocity = -5.25
guard.slidetime = 6
guard.hittime = 5
guard.dist = 241
airguard.velocity = -4,-5.791015625
air.velocity = -3.5,-9.720703125+0.501953125*(facing = enemyNear,facing)
yaccel = 0.5625
;-------------------------------------------------
sparkno = -1
guard.sparkno = -1
;-------------------------------------------------
hitsound = 0,ceil(random/200)
guardsound = 0,ifelse(enemyNear,var(1)=0,25+(random>499),5+ceil(random/250))
;-------------------------------------------------
ground.cornerpush.veloff = -4.322
guard.cornerpush.veloff = -6.115    
air.cornerpush.veloff = 0    
airguard.cornerpush.veloff = 0
fall = 1
air.fall = 1
fall.xvelocity = -1.375
fall.yvelocity = -1.966796875
down.bounce = 1
fall.recover = 0

[State 240, Varadd]
type = Varadd
trigger1 = AnimElem = 9
fv = 30
value = -15.625

[State 280, changestate]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1

;---------------------------------------------------------------------------
; Running Hard Sword Cut Spark

[Statedef 281]
type    = S
movetype = I
physics = N
sprpriority = 5
ctrl = 0

[State 281, VarRandom]
type = assertspecial
trigger1 = Gametime%2=0
flag = invisible

[State 281, BindToParent]
type = BindToParent
trigger1 = 1
facing = 1
pos = 0,0
time = -1

[State 281, SprPriority 1]
type = SprPriority
trigger1 = parent, Anim = 280
value = 5

[State 281, ChangeAnim]
type = ChangeAnim
triggerall = parent, Var(1) = 0
trigger1 =  (parent, AnimElemTime(8) = 0) && (parent,Anim = 280)
value = 2000281
persistent = 0
ignorehitpause = 1

[State 281, ChangeAnim]
type = ChangeAnim
triggerall = parent, Var(1) = 0
trigger1 =  (parent, AnimElemTime(8) = 2) && (parent,Anim = 280)
value = 2001281
persistent = 0
ignorehitpause = 1

[State 281, ChangeAnim]
type = ChangeAnim
triggerall = parent, Var(1) = 0
trigger1 =  (parent, AnimElemTime(9) = 0) && (parent,Anim = 280)
value = 2002281
persistent = 0
ignorehitpause = 1

[State 281, ChangeAnim]
type = ChangeAnim
triggerall = parent, Var(1) = 0
trigger1 =  (parent, AnimElemTime(9) = 2) && (parent,Anim = 280)
value = 2003281
persistent = 0
ignorehitpause = 1

[State 281, Destroyself]
type = destroyself
trigger1 = parent,AnimElem = 9, >= 4
trigger2 = parent,Anim != 280



Last Edit: January 25, 2008, 04:29:09 pm by W. Fast