2016.02.2314:36

AI走路,跑步,跳跃定义

Episode 2 走路,跑步,跳跃定义

我们先来改个东西,看到人物DATA下方
找到intpersistindex和floatpersistindex,改一下
改成这样
intpersistindex = 5
floatpersistindex = 20

什么意思呢,第一局结束后直接带到下一局的var,因为var是记忆的,有些var如果记忆一次后不赋值则会失去之前的数据,比如intpersistindex = 5,就是var(5)包括var(5)以后的var会直接带入下局,则之前的如果没有赋值会清空,很好理解吧,先记下来,以后用得上

接下来是正题
定义statedef 20为走路,anim = 20为前,21为后,statedef 40为跳跃,statedef 45为二次跳跃(一般KOF系统不使用,所以这里不讲),statedef 50为跳跃中,statedef 52为默认落地,statedef 100为跑步,statedef 105为后撤(后面就不说了,就用到这些)

需要修改和复制的有statedef 20 statedef 40 statedef 100,也就是,走,跳,跑

先说走路,定义一个前走

;-------------------------------------------------------------------------------
; Walk(前進)
[Statedef 19]
type = S
physics = S
sprpriority = 0

[State 20, 1]
type = VelSet
trigger1 = !var(59) ;非AI启动
trigger1 = command = "holdfwd" ;指令,按住前
trigger2 = var(59) ;AI启动
x = const(velocity.walk.fwd.x)

[State 20, 2]
type = VelSet
trigger1 = !var(59) ;非AI启动
trigger1 = command = "holdback" ;指令,按住后
x = const(velocity.walk.back.x)

[State 20, 3]
type = ChangeAnim
triggerall = vel x > 0
trigger1 = Anim != 20 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0
value = 20

[State 20, 4]
type = ChangeAnim
triggerall = vel x < 0
trigger1 = Anim != 21 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0
value = 21

于是这样就定义一个前走了,那么下面是泛用走路


;---------------------------------------------------------------------------
; Walk(AI、汎用)
[Statedef 21]
type = S
physics = S
sprpriority = 0
ctrl = 0

[State 20, Turn]
Type = Turn ;转向,走路中如果背对了对面转回去面对对面
Trigger1 =!Ctrl
Trigger1 = P2Dist X < 0
Trigger1 = Anim = 20 || Anim = 21

[State 20, AI 前進]
Type = VelSet ;前进AI部分
triggerall = var(59)
triggerall = Vel X >= 0
triggerall =(PrevStateNo != [140,155]) || P2BodyDist X > 140 ;不能是撤防时或者离对面较远时
trigger1 =(P2BodyDist X = [20,120]) || enemynear,facing = facing ;看上面的条件,第一个是在20-120距离,不满足上面的P2BodyDist X > 140条件,则必须满足(PrevStateNo != [140,155])条件才会触发,第二个是被对对面时触发
trigger2 = P2BodyDist X > 140 ;同上面主条件第二项
x = const(velocity.walk.fwd.x)

[State 20, AI 後退]
Type = VelSet
triggerall = var(59)
triggerall = Vel X <= 0
triggerall = enemynear,facing != facing ;面对对面
triggerall = enemynear,MoveType != H ;对面不能是不被打的情况
trigger1 = P2BodyDist X = [0,60] ;在0-60码的距离
trigger2 = P2BodyDist X = [90,160] ;在90-160码的距离
trigger3 = enemynear,MoveType = I || enemynear,StateNo >= 1000 ;对面未作出任何动作或者对面stateno >= 1000(通常是必杀技以上,也有可能是拳脚但概率不大)
trigger4 =(PrevStateNo = [140,155]) && P2BodyDist X <= 140 ;刚刚撤防且离对面140码内
x = const(velocity.walk.back.x)

[State 20, 1]
type = VelSet
triggerall = !var(59)
trigger1 = command = "holdfwd"
x = const(velocity.walk.fwd.x)

[State 20, 2]
type = VelSet
triggerall = !var(59)
trigger1 = command = "holdback"
x = const(velocity.walk.back.x)

[State 20, 3]
type = ChangeAnim
triggerall = vel x > 0
trigger1 = Anim != 20 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0
value = 20

[State 20, 4]
type = ChangeAnim
triggerall = vel x < 0
trigger1 = Anim != 21 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0
value = 21

[State 20, 5]
type = ChangeState
trigger1 = Vel X = 0
trigger2 = frontedgebodydist < 10 ;离版边太近时停止
trigger3 = roundstate != 2 ;回合结束后停止
trigger4 = inguarddist ;在对面的Inguarddist(这里的意思就是说,对面攻击,你在一定范围内会摆出防御姿势的距离)
trigger4 = EnemyNear,facing != facing ;不面对对手
value = 0
ctrl = 1

;---------------------------------------------------------------------------
; Walk(AI、起き攻め位置取り用) ;(这个,用在对面倒地起身时移动用的,以后再讲)
[Statedef 22]
Type = S
physics = S
sprpriority = 0
ctrl = 0

[State 20, Turn]
Type = Turn
Trigger1 =!Ctrl
Trigger1 = P2Dist X < 0
Trigger1 = Anim = 20 || Anim = 21

[State 20, 前進]
Type = VelSet
triggerall = var(59)
trigger1 = var(44) = 1
trigger1 = P2BodyDist X > 40
trigger2 = var(44) != 1
trigger2 = P2BodyDist X > 60
x = const(velocity.walk.fwd.x)

[State 20, 後退]
Type = VelSet
triggerall = var(59)
trigger1 = var(44) = 1
trigger1 = P2BodyDist X < 20
trigger2 = var(44) != 1
trigger2 = P2BodyDist X < 40
x = const(velocity.walk.back.x)

[State 20, 1]
type = VelSet
triggerall = !var(59)
trigger1 = command = "holdfwd"
x = const(velocity.walk.fwd.x)

[State 20, 2]
type = VelSet
triggerall = !var(59)
trigger1 = command = "holdback"
x = const(velocity.walk.back.x)

[State 20, 3]
type = ChangeAnim
triggerall = vel x > 0
trigger1 = Anim != 20 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0
value = 20

[State 20, 4]
type = ChangeAnim
triggerall = vel x < 0
trigger1 = Anim != 21 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0
value = 21

[State 20, 5]
type = ChangeState
trigger1 = Vel X = 0
trigger2 = frontedgebodydist < 10
trigger3 = roundstate != 2
trigger4 = inguarddist
trigger4 = EnemyNear(var(58)),facing != facing
value = 0
ctrl = 1

那么 statedef 20呢?

它在这!

;---------------------------------------------------------------------------
; Walk
[Statedef 20]
type = S
physics = S
sprpriority = 0

[State 20, 0]
type = ChangeState
triggerall = var(59) = 1 ;为了防止乱走,直接限制AI启动时它自动回0
trigger1 = time = 0
value = 0
ctrl = 1

[State 20, 1]
type = VelSet
trigger1 = command = "holdfwd"
x = const(velocity.walk.fwd.x)

[State 20, 2]
type = VelSet
trigger1 = command = "holdback"
x = const(velocity.walk.back.x)

[State 20, 3]
type = ChangeAnim
triggerall = vel x > 0
trigger1 = Anim != 20 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0
value = 20

[State 20, 4]
type = ChangeAnim
triggerall = vel x < 0
trigger1 = Anim != 21 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0
value = 21

走路部分就到这里,接下来是跳跃,以KOF96以后的ADV系统为例子

;---------------------------------------------------------------------------
; Jump Start
[Statedef 40]
type = S
physics = S
anim = 40
ctrl = 0
sprpriority = 1
facep2 = 1

[State 40, 0]
type = ChangeState
triggerall = var(59) = 1 ;同样,防止AI乱跳,限制一下AI的动作
trigger1 = time = 0
value = 0
ctrl = 1

[State 40, 1] ;这里var(4)控制小,通常跳
type = VarSet
trigger1 = time = 0
var(4) = 0

[State 40, 1];小ジャンプ
type = VarSet
trigger1 = command != "holdup"
var(4) = 1

[State 40, 1] ;基本定义,sysvar(1) = 0为上跳, = 1为前,-1为后
type = VarSet
trigger1 = Time = 0
sysvar(1) = 0

[State 40, 2]
type = VarSet
trigger1 = command = "holdfwd"
sysvar(1) = 1

[State 40, 3]
type = VarSet
trigger1 = command = "holdback"
sysvar(1) = -1

[State 40, 4] ;通常跳速度定义
type = VelSet
trigger1 = AnimTime = 0
trigger1 = Var(4) = 0
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = const(velocity.jump.y)

[State 40, 4];小ジャンプ ;小跳速度定义
type = VelSet
trigger1 = AnimTime = 0
trigger1 = Var(4) = 1
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = -6

[State 120, 5] ;Can't be thrown right after getting up ;起跳时防投
type = NotHitBy
trigger1 = time >= 0
value = , NT,ST,HT

[State 40, 6]
type = ChangeState ;跳转到50,也就是跳跃中
trigger1 = AnimTime = 0
value = 50
ctrl = 1

那么下面大家可以参考我使用的跳跃系统

30:通常前跳,31:通常后跳,32:小前跳,33:小后跳,34:影前跳,35:影后跳,36:大前跳,37:大后跳,38:通常上跳,39:小上跳

不同的人物系统不同的利用方法,这里自己理解了

以30为例子,后面就不说明了(笑)
;---------------------------------------------------------------------------
; AI前ジャンプ
[Statedef 30]
type = S
physics = S
anim = 40
ctrl = 0
sprpriority = 1

[State 40, 2]
type = VarSet
trigger1 = 1
sysvar(1) = 1 ;方向:前

[State 40, 1]
type = VarSet
trigger1 = 1
var(4) = 0 ;定义通常跳

[State 40, 4]
type = VelSet ;因为是var(4) = 0,那么取这一部分
trigger1 = AnimTime = 0
trigger1 = var(4) = 0
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = const(velocity.jump.y)

[State 40, 4];小ジャンプ
type = VelSet
trigger1 = AnimTime = 0
trigger1 = var(4) = 1
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = -6

[State 120, 5] ;Can't be thrown right after getting up
type = NotHitBy
trigger1 = time >= 0
value = , NT,ST,HT

[State 40, 6]
type = ChangeState
trigger1 = AnimTime = 0
value = 50
ctrl = 1

;---------------------------------------------------------------------------
;後ろジャンプ
[Statedef 31]
type = S
physics = S
anim = 40
ctrl = 0
sprpriority = 1

[State 40, 2]
type = VarSet
trigger1 = 1
sysvar(1) = -1

[State 40, 1]
type = VarSet
trigger1 = 1
var(4) = 0

[State 40, 4]
type = VelSet
trigger1 = AnimTime = 0
trigger1 = var(4) = 0
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = const(velocity.jump.y)

[State 40, 4];小ジャンプ
type = VelSet
trigger1 = AnimTime = 0
trigger1 = var(4) = 1
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = -6

[State 120, 5] ;Can't be thrown right after getting up
type = NotHitBy
trigger1 = time >= 0
value = , NT,ST,HT

[State 40, 6]
type = ChangeState
trigger1 = AnimTime = 0
value = 50
ctrl = 1

;---------------------------------------------------------------------------
;前小ジャンプ
[Statedef 32]
type = S
physics = S
anim = 40
ctrl = 0
sprpriority = 1

[State 40, 2]
type = VarSet
trigger1 = 1
sysvar(1) = 1

[State 40, 1]
type = VarSet
trigger1 = 1
var(4) = 1

[State 40, 4]
type = VelSet
trigger1 = AnimTime = 0
trigger1 = var(4) = 0
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = const(velocity.jump.y)

[State 40, 4];小ジャンプ
type = VelSet
trigger1 = AnimTime = 0
trigger1 = var(4) = 1
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = -6

[State 120, 5] ;Can't be thrown right after getting up
type = NotHitBy
trigger1 = time >= 0
value = , NT,ST,HT

[State 40, 6]
type = ChangeState
trigger1 = AnimTime = 0
value = 50
ctrl = 1

;---------------------------------------------------------------------------
;後ろ小ジャンプ
[Statedef 33]
type = S
physics = S
anim = 40
ctrl = 0
sprpriority = 1

[State 40, 2]
type = VarSet
trigger1 = 1
sysvar(1) = -1

[State 40, 1]
type = VarSet
trigger1 = 1
var(4) = 1

[State 40, 4]
type = VelSet
trigger1 = AnimTime = 0
trigger1 = var(4) = 0
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = const(velocity.jump.y)

[State 40, 4];小ジャンプ
type = VelSet
trigger1 = AnimTime = 0
trigger1 = var(4) = 1
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = -6

[State 120, 5] ;Can't be thrown right after getting up
type = NotHitBy
trigger1 = time >= 0
value = , NT,ST,HT

[State 40, 6]
type = ChangeState
trigger1 = AnimTime = 0
value = 50
ctrl = 1

;---------------------------------------------------------------------------
;前中ジャンプ
[Statedef 34]
type = S
physics = S
anim = 40
ctrl = 0
sprpriority = 1

[State 40, 2]
type = VarSet
trigger1 = 1
sysvar(1) = 1

[State 40, 1]
type = VarSet
trigger1 = 1
var(4) = 1

[State 40, 4]
type = VelSet
trigger1 = AnimTime = 0
trigger1 = var(4) = 0
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = const(velocity.jump.y)

[State 40, 4];小ジャンプ
type = VelSet
trigger1 = AnimTime = 0
trigger1 = var(4) = 1
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = -6

[State 120, 5] ;Can't be thrown right after getting up
type = NotHitBy
trigger1 = time >= 0
value = , NT,ST,HT

[State 40, 6]
type = ChangeState
trigger1 = AnimTime = 0
value = 50
ctrl = 1

;---------------------------------------------------------------------------
;後ろ中ジャンプ
[Statedef 35]
type = S
physics = S
anim = 40
ctrl = 0
sprpriority = 1

[State 40, 2]
type = VarSet
trigger1 = 1
sysvar(1) = -1

[State 40, 1]
type = VarSet
trigger1 = 1
var(4) = 1

[State 40, 4]
type = VelSet
trigger1 = AnimTime = 0
trigger1 = var(4) = 0
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = const(velocity.jump.y)

[State 40, 4];小ジャンプ
type = VelSet
trigger1 = AnimTime = 0
trigger1 = var(4) = 1
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = -6

[State 120, 5] ;Can't be thrown right after getting up
type = NotHitBy
trigger1 = time >= 0
value = , NT,ST,HT

[State 40, 6]
type = ChangeState
trigger1 = AnimTime = 0
value = 50
ctrl = 1

;---------------------------------------------------------------------------
;前大ジャンプ
[Statedef 36]
type = S
physics = S
anim = 40
ctrl = 0
sprpriority = 1

[State 40, 2]
type = VarSet
trigger1 = 1
sysvar(1) = 1

[State 40, 1]
type = VarSet
trigger1 = 1
var(4) = 0

[State 40, 4]
type = VelSet
trigger1 = AnimTime = 0
trigger1 = var(4) = 0
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = const(velocity.jump.y)

[State 40, 4];小ジャンプ
type = VelSet
trigger1 = AnimTime = 0
trigger1 = var(4) = 1
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = -6

[State 120, 5] ;Can't be thrown right after getting up
type = NotHitBy
trigger1 = time >= 0
value = , NT,ST,HT

[State 40, 6]
type = ChangeState
trigger1 = AnimTime = 0
value = 50
ctrl = 1

;---------------------------------------------------------------------------
;後ろ大ジャンプ
[Statedef 37]
type = S
physics = S
anim = 40
ctrl = 0
sprpriority = 1

[State 40, 2]
type = VarSet
trigger1 = 1
sysvar(1) = -1

[State 40, 1]
type = VarSet
trigger1 = 1
var(4) = 0

[State 40, 4]
type = VelSet
trigger1 = AnimTime = 0
trigger1 = var(4) = 0
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = const(velocity.jump.y)

[State 40, 4];小ジャンプ
type = VelSet
trigger1 = AnimTime = 0
trigger1 = var(4) = 1
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = -6

[State 120, 5] ;Can't be thrown right after getting up
type = NotHitBy
trigger1 = time >= 0
value = , NT,ST,HT

[State 40, 6]
type = ChangeState
trigger1 = AnimTime = 0
value = 50
ctrl = 1

;---------------------------------------------------------------------------
;上ジャンプ
[Statedef 38]
type = S
physics = S
anim = 40
ctrl = 0
sprpriority = 1

[State 40, 2]
type = VarSet
trigger1 = 1
sysvar(1) = 0

[State 40, 1]
type = VarSet
trigger1 = 1
var(4) = 0

[State 40, 4]
type = VelSet
trigger1 = AnimTime = 0
trigger1 = var(4) = 0
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = const(velocity.jump.y)

[State 40, 4];小ジャンプ
type = VelSet
trigger1 = AnimTime = 0
trigger1 = var(4) = 1
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = -6

[State 120, 5] ;Can't be thrown right after getting up
type = NotHitBy
trigger1 = time >= 0
value = , NT,ST,HT

[State 40, 6]
type = ChangeState
trigger1 = AnimTime = 0
value = 50
ctrl = 1

;---------------------------------------------------------------------------
;垂直小ジャンプ
[Statedef 39]
type = S
physics = S
anim = 40
ctrl = 0
sprpriority = 1

[State 40, 2]
type = VarSet
trigger1 = 1
sysvar(1) = 0

[State 40, 1]
type = VarSet
trigger1 = 1
var(4) = 1

[State 40, 4]
type = VelSet
trigger1 = AnimTime = 0
trigger1 = var(4) = 0
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = const(velocity.jump.y)

[State 40, 4];小ジャンプ
type = VelSet
trigger1 = AnimTime = 0
trigger1 = var(4) = 1
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = -6

[State 120, 5] ;Can't be thrown right after getting up
type = NotHitBy
trigger1 = time >= 0
value = , NT,ST,HT

[State 40, 6]
type = ChangeState
trigger1 = AnimTime = 0
value = 50
ctrl = 1

这么多跳跃,都是从40演变过来的,因为跳跃方式有这么多,所以AI用的话得一个个列举出来了

刚才注意到,人物是有残影跳的,那么怎么设置残影跳呢?

在statedef -3下加入这些东西,我们定义var(3)为控制残影跳和通常跳的变量

;-------------------------------------------------------------------------------
[Statedef -3]

[State -3, コマンドを入れたらVarをON]
Type = VarSet
TriggerAll = !var(59)
Trigger1 = Command = "jump" ;残影跳的指令,一般是269,247这些的,一会给出指令
Trigger1 = Ctrl
Trigger1 = StateType = S
Trigger2 = PrevStateNo = 100
Trigger2 = Command = "holdfwd" ;之前的动作为跑步,并且按住前,才可出现残影跳
V = 3
Value = 1

[State -3, sysvarを引継ぐ] ;出现了残影跳以后,需要继续赋值
Type = VarSet
Trigger1 = Var(3) = 1 ;出现了残影跳
Trigger1 = StateNo = 40 ;ジャンプする前のステート
Trigger1 = AnimTime = 0 ;ジャンプ方向を決めるsysvarがリセットされる寸前
var(3) = ifelse(sysvar(1)=0, 2, ifelse(sysvar(1)=1, 3, 4)) ;利用sysvar来判断赋值,上跳赋值为2,前为3,后为4

[State -3, AI]
Type = VarSet
Trigger1 = var(59)
Trigger1 = StateNo = [34,37] ;定义34-37出现残影跳
Trigger1 = AnimTime = 0
var(3) = ifelse(sysvar(1)=0, 2, ifelse(sysvar(1)=1, 3, 4)) ;给AI定义赋值,和上面相同

[State -3, varをOFFにするステート] ;跳出去以后还原var(3) = 0
Type = VarSet
TriggerAll = Time = 2
Trigger1 = StateNo = 50
Trigger2 = StateNo != [40,59]
V = 3
Value = 0 ;还原

[State -3, 前にボタンを押してたら前にも加速] ;残影前跳加速
Type = VelAdd
Trigger1 = var(3) = 3
Trigger1 = StateNo = 50
y = -0.6
x = 1.8

[State -3, 後ろなら後ろに加速] ;残影后跳加速
Type = VelAdd
Trigger1 = var(3) = 4
Trigger1 = StateNo = 50
y = -0.6
x = -1.8

[State -3, 垂直ジャンプにveladdを使って上に加速] ;残影上跳加速
Type = VelAdd
Trigger1 = var(3) = 2
Trigger1 = StateNo = 50
y = -1.8

[State -3, 成功したときの残像] ;出现残影跳后的残影成分,这里自己设定吧
Type = AfterImage
Trigger1 = var(3) >= 1
Trigger1 = StateNo = 50
Trigger2 = AnimTime = 0
Trigger2 = PrevStateNo = 100 ;RUN_FWD
Trigger2 = Sysvar(1) = 1
Time = 2
Length = 7
PalBright = 0,0,0
PalContrast = 256,256,256
PalAdd = 0,0,0
PalMul = 1,1,1
FrameGap = 3

[State 2041, 2]
Type = AfterImageTime ;非残影跳时的残影,这里可以不要,看自己需要
TriggerAll = var(3) = 0
Trigger1 = StateNo = 50
Trigger1 = Time%2 = 0 && Time < 15
Time = 2

;---------------------------------------------------------------------------
[Command] ;这个是刚才说好的补充指令,影跳跃指令,请加在Statedef -1上方
name = "jump"
command = D, $U ;下蓄力上
time = 12

好了,以上就是定义跳跃的内容,如果有类似定义也可以按照定义进行修改

接下来是跑步,statedef 100,根据每个人anim不同,性能也会有些差距的

;---------------------------------------------------------------------------
; RUN_FWD
[Statedef 100]
type = S
physics = S
anim = 100
sprpriority = 1
ctrl = 0 ;一般是不可控

[State 100, 1]
type = VelSet
trigger1 = AnimElemtime(2) >= 0 ;第二张图后
x = const(velocity.run.fwd.x) ;跑步速度,在人物[Velocity]下可以更改,run.fwd.x项

[State 100, PlaySnd] ;跑步音效
type = PlaySnd
triggerall = time = 4
trigger1 = Alive
loop = 1 ;因为跑步声是循环的,所以写上loop = 1让声音循环
value = s5,0 ;声音
channel = 6 ;频道,有用,一会说明作用

[State 100, 2] ;Prevent run from canceling into walk
type = AssertSpecial
trigger1 = 1
flag = NoWalk ;是跑,所以断言不走

[State 100, 3] ;Prevent from turning
type = AssertSpecial
trigger1 = 1
flag = NoAutoTurn ;不能自动转向面对对手

[State 100, 4]
type = ChangeState
triggerall = var(59) != 1
trigger1 = command = "holdup"
value = 40 ;跑步中跳可以出现残影跳

[State 100, 4]
type = ChangeState
triggerall = var(59) != 1
triggerall = AnimElemtime(2) >= 0
trigger1 = command != "holdfwd"
value = 101 ;101为停止用statedef,我这里使用了,如果不想用,用回MUGEN原来的0也可以

[State 100, AI]
Type = ChangeState
TriggerAll = var(59) = 1
TriggerAll = AnimElemtime(2) >= 0
Trigger1 = Time = 60 ;60帧停一下
Trigger2 = P2BodyDist X <= 40
Trigger2 = P2BodyDist Y >= -120 ;X方向(横向)离40码以内,Y方向(纵向)离120码以内
Trigger2 = EnemyNear,MoveType != H ;对面不是被打状态
Trigger2 = EnemyNear,Facing != Facing || P2BodyDist X < 0 ;面对对面或者对面逆向停止跑动
Trigger3 = EnemyNear,MoveType = A ;对面处于攻击状态
Trigger3 = EnemyNear,Facing != Facing ;面对对面
Trigger4 = EnemyNear,StateType = L ;对面倒地了
Trigger4 = P2BodyDist X <= 60 ;60个距离点内停止跑动
Trigger5 = InGuardDist ;处在inguarddist范围内(之前有说过,inguarddist也就是对面攻击给自己产生的防御距离)
Trigger5 = EnemyNear,Facing != Facing ;面对对面
Trigger6 = Enemy,NumProj ;对面有飞行道具停止跑动
value = 101

[State 100, AI]
Type = ChangeState
triggerall = var(59) != 0
triggerall = AnimElemtime(2) >= 0
trigger1 = alive
trigger1 = life > 0
trigger1 = roundstate = 3 ;回合结束后停止前进
value = 101

;---------------------------------------------------------------------------
; RUN_FWD STOP ;跑步停止用statedef
[Statedef 101]
type = S
physics = S
anim = 101
sprpriority = 1

[State 101, 1]
type = turn
trigger1 = time = 0
trigger1 = p2dist x < 0

[State 100, 2]
type = VelSet
trigger1 = 1
x = 0

[State 101, 3]
type = CtrlSet
trigger1 = Time = 0
value = 1

[State 101, 4]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1

还可以按照自己的需要再补充其他的跑步statedef,那么接下来我们说下如何让跑步的声音彻底停止

在statedef -2下加入这行

[Statedef -2]

[State -2, StopSnd]
type = StopSnd ;停止跑步声音
trigger1 = var(59) = 0
trigger1 = command != "holdfwd"
trigger2 = Anim != 100
channel = 6 ;刚才的channel = 6对应了这里,如果动画不是100或者不按住前了,则声音停止

好了,状态号顺利载入,这节课你有没有理解呢?

如果您有什么问题,可以给我私信,我会第一时间给您解答,或者问题发到我的邮箱

mizore@kotori.moe,谢谢大家!

发表留言

秘密留言

アクセス

オンライン