自動步行

在格鬥遊戲之中, 懂得如何移動到一個有利位置是十分重要的. 在這一節將會介紹如何制止電腦亂行.
;Stop AI Walk [State -1]
type = AssertSpecial
trigger1 = Var(59);當 ai 開啟昤
flag = NoWalk;就禁止按方向鍵步行

之後就是控制 ai 自動步行. 以步行至對方面前 80 pixel 為例:
[state -1]
type = ChangeState
trigger1 = P2bodyDist X != [60,100];通常會在要在目標位置加減 10-20 作為空間
trigger1 = Anim != 5
trigger1 = StateNo = 0
trigger1 = Pos Y = 0;確保是在地上
value = 20
之後是 state 20 的修改:
;---------------------------------------------------------------------------
; Walk
[Statedef 20]
type = S
physics = S
sprpriority = 0

[State 20, 1]
type = VelSet;如人物在預定位置後就向前行
trigger1 = !Var(59)
trigger1 = command = "holdfwd"
trigger2 = Var(59)
trigger2 = P2BodyDist X >= 90
x = const(velocity.walk.fwd.x)

[State 20, 2]
type = VelSet;如人物在預定位置前就向後行
trigger1 = !Var(59)
trigger1 = command = "holdback"
trigger2 = Var(59)
trigger2 = P2BodyDist X <= 70
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]
type = ChangeState;人物進入預定位置後便回站立 state
triggerall = Var(59)
trigger1 = P2BodyDist X > 70
trigger1 = P2BodyDist X < 90
trigger2 = P2MoveType = A;敵方在攻擊而人物向後行
trigger2 = Vel X <= 0 ;就回 state 0, 否則會出現攻擊向後行而不防守的情況
trigger3 = RoundState = 3;戰鬥完結
trigger4 = Vel X = 0;以防萬一, 沒什麼實際用途
trigger4 = Anim != 0
value = 0

只要大家改變不同的數值就可令 ai 行到不同的距離.

順手介紹如何阻止 ai 跳躍.
在 state 40 的最上加入以下的東西:
[State 40]
type = ChangeState
trigger1 = Var(59)
trigger1 = Pos Y = 0;以防是空中跳躍
trigger1 .....;可以自行加入容許 ai 跳躍的 trigger
value = 0
ctrl = 1
如希望 ai 能自動跳躍:
[State -1]
type = ChangeState
triggerall = Var(59)
triggerall = Ctrl
triggerall = StateType != A
triggerall = StateNo != 40
trigger1 = ;其他命令 ai 跳的 trigger
value = 40
要記得在 state 40 中阻止 ai 跳躍時指明是否 ai 跳躍. 似如:
trigger1 = p2movetype = a;是跳的 trigger
那麼容許跳的 trigger 就是:
trigger1 = p2movetype != a
簡單來說就是把跳的 not 了就是阻止跳的 trigger.


自動步行完. 回首頁
Make your own free website on Tripod.com