2016.03.1011:15

AI HELPER-1,记忆前版边/后版边离自己的真实距离

Episode 1 记忆前版边/后版边离自己的真实距离

前面的AI部分先暂时休息一下,今天我们来学一个新的HELPER

先不要管这个HELPER是什么,我们先确认一下人物的AIR里面有没有空动画

比如这种的

[Begin Action 9999]
-1,0, 0,0, -1

一般HELPER用这个东西作为ANIM就可以了,看起来没有任何作用的ANIM,实际上用处很大的

那么接下来,直接给出HELPER了

;━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
;AIヘルパー
;━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[Statedef 20000]
type = A
movetype = I
physics = N
anim = 9999
velset = 10,0
ctrl = 0
sprpriority = 1

[State 20000, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = NoShadow
flag2 = invisible

[State 20000, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA

[State 20000, 間違いで本体が来たら立ちへ移行]
type = SelfState
trigger1 =!ishelper
value = 0

[State 20000, PlayerPush]
type = PlayerPush
trigger1 = 1
value = 0

[State 20000, Projectile]
type = Projectile
trigger1 = time = 0
velocity = 10,0
projID = 20000
projanim = 9999
offset = 0,100000
projstagebound = 0
projedgebound = 100000
projremovetime = -1

[State 20000, VelSet]
type = VelSet
trigger1 = Root,NumProjID(20000) = 0
trigger1 = time > 0
x = 0
y = 0

;-------------------------------------------------------------------------------------
[Statedef 20001]
type = A
movetype = I
physics = N
anim = 9999
velset = -10,0
ctrl = 0
sprpriority = 1

[State 20000, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = NoShadow
flag2 = invisible

[State 20000, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA

[State 20000, 間違いで本体が来たら立ちへ移行]
type = SelfState
trigger1 =!ishelper
value = 0

[State 20000, PlayerPush]
type = PlayerPush
trigger1 = 1
value = 0

[State 20000, Projectile]
type = Projectile
trigger1 = time = 0
velocity = -10,0
projID = 20001
projanim = 9999
offset = 0,100000
projstagebound = 0
projedgebound = 100000
projremovetime = -1

[State 20000, VelSet]
type = VelSet
trigger1 = Root,NumProjID(20001) = 0
trigger1 = time > 0
x = 0
y = 0

然后在-3下召唤出HELPER

;---------------------------------------------------------------------------
; 画面端検出ヘルパー
;---------------------------------------------------------------------------
[State -3, 画面端検出ヘルパー]
Type = Helper
Trigger1 =!NumHelper(20000+ID)
Trigger1 =!IsHelper
HelperType = Normal
Name = "Edge of Stage Right"
PosType = P1
StateNo = 20000
ID = 20000+ID
PauseMoveTime = 0
Persistent = 0
IgnoreHitPause = 1
KeyCtrl = 0
Ownpal = 1

[State -3, 画面端検出ヘルパー]
Type = Helper
Trigger1 =!NumHelper(20001+ID)
Trigger1 =!IsHelper
HelperType = Normal
Name = "Edge of Stage Left"
PosType = P1
StateNo = 20001
ID = 20001+ID
PauseMoveTime = 0
Persistent = 0
IgnoreHitPause = 1
KeyCtrl = 0
Ownpal = 1

;---------------------------------------------------------------------------
; 関係無いステートに行かないように
;---------------------------------------------------------------------------
[State -3, 関係無いステートに行かないように]
Type = ChangeState
Trigger1 = IsHelper
Trigger1 = IsHelper(20000+Root,ID)
Trigger1 = StateNo != 20000
Value = 20000

[State -3, 関係無いステートに行かないように]
Type = ChangeState
Trigger1 = IsHelper
Trigger1 = IsHelper(20001+Root,ID)
Trigger1 = StateNo != 20001
Value = 20001

原理很简单,HELPER出现时候,发射一个飞行道具,然后飞行道具到达屏幕最边缘的时候会删除,因为HELPER的初速度是10,并且不受摩擦等因素,HELPER做匀速直线运动,这个时候给HELPER设置速度让HELPER停下来,那么HELPER就达到了屏幕的最边缘处

那么HELPER达到了最边缘处,我们现在要用两个var,分别代表屏幕前边缘和屏幕后边缘,以1P朝向右为例,右方向就是前边缘,左方向就是后边缘

;-----------------------------------------------------------------------------
; ステージ前後方端までの距離
;-----------------------------------------------------------------------------
[State -3, ステージ前方端までの距離]
Type = VarSet
Trigger1 =(NumHelper(20000+ID) && NumHelper(20001+ID))
Trigger1 = TeamSide = 1
var(41) = floor(Abs(ifelse(Facing = 1,Helper(20000+ID),RootDist X,Helper(20001+ID),RootDist X)))
IgnoreHitPause = 1

[State -3, ステージ前方端までの距離]
Type = VarSet
Trigger1 =(NumHelper(20000+ID) && NumHelper(20001+ID))
Trigger1 = TeamSide = 2
var(41) = floor(Abs(ifelse(Facing = 1,Helper(20001+ID),RootDist X,Helper(20000+ID),RootDist X)))
IgnoreHitPause = 1

[State -3, ステージ後方端までの距離]
Type = VarSet
Trigger1 =(NumHelper(20000+ID) && NumHelper(20001+ID))
Trigger1 = TeamSide = 1
var(42) = floor(Abs(ifelse(Facing = 1,Helper(20001+ID),RootDist X,Helper(20000+ID),RootDist X)))
IgnoreHitPause = 1

[State -3, ステージ後方端までの距離]
Type = VarSet
Trigger1 =(NumHelper(20000+ID) && NumHelper(20001+ID))
Trigger1 = TeamSide = 2
var(42) = floor(Abs(ifelse(Facing = 1,Helper(20000+ID),RootDist X,Helper(20001+ID),RootDist X)))
IgnoreHitPause = 1

var(41)代表面对的前边缘,var(42)代表面对的后边缘

用DISPLAYTOCLIPBOARD查看效果,如果有DISPLAYTOCLIPBOARD存在的话,直接写APPENDTOCLIPBOARD即可

[State -2, DisplayToClipboard]
type = DisplayToClipboard
trigger1 = 1
text = "V41=%d,V42=%d"
params = var(41),var(42)
ignorehitpause = 1

接下来是效果

X)X[7VQKH$1}0MS{0MG7$`V

可以看到,开局的时候,有两个HELPER正在动
3LI@8[137P})9YD_{G4K{QA

然后他们会到达版边,接下来看下面的DEBUG,(CTRL+D开启DEBUG模式,前提要在DATA/MUGEN.CFG里面找到AllowDebugMode,并修改成AllowDebugMode = 1,然后就可以开启DEBUG)

OINZ6WCL000O8LYY7MCN7}W

HELPER已经到达边缘,然后看到这里的小字,var(41) = 186,var(42) = 393,说明你现在面对的前版边距离是186个像素,后方是393个
09CS8U]2~MA93K]U`7ZETFD

然后我们换个面,var(41) = 94,var(42) = 485,var(41) + var(42) = 186+393 = 94+485 = 579,说明var(41)和var(42)的和为定值,就是全图的长度,该图的长度为579

AI1DI]ZHD}3L{93$I)Q~ES

那么以后只要这么用就可以检测到真实的版边距离了,是不是很方便呢

好了,今天的课就先到这,如果您有什么问题的话可以私信我(只要是我会的,不管什么问题),我会第一时间给您答复,或者把问题发到我的邮箱

mizore@kotori.moe, 谢谢大家!

发表留言

秘密留言

等待许可的留言

此留言需要管理员的许可

アクセス

オンライン