2016.02.2313:31

AI启动器

Episode 1 AI启动器,触发AI的必要元素之一,首先大家如果看过AI的话,肯定见过这么长的一串文字
;---------------------------------------------------------------------------
; AI switch -> ON
[State -3, AI] ;←Title
Type = VarSet ;←变量设置,少了这个不谈
TriggerAll = !IsHelper || IsHelper(30000) ;←本体或者helper(30000)存在
TriggerAll = var(59) != 1 ;←命令var(59) = 1为AI,那么不等于1的话AI则代表未启动
TriggerAll = RoundState = [1,2] ;←在比赛或者比赛开始前
Trigger1 = Command = "AI1" ;←指令1
Trigger2 = Command = "AI2" ;←指令2
Trigger3 = Command = "AI3" ;←指令3
Trigger4 = Command = "AI4" ;←指令4
Trigger5 = Command = "AI5" ;←指令5
Trigger6 = Command = "AI6" ;←指令6
Trigger7 = Command = "AI7" ;←指令7
Trigger8 = Command = "AI8" ;←指令8
Trigger9 = Command = "AI9" ;←指令9
Trigger10 = Command = "AI10" ;←指令10
Trigger11 = Command = "AI11" ;←指令11
Trigger12 = Command = "AI12" ;←指令12
Trigger13 = Command = "AI13" ;←指令13
Trigger14 = Command = "AI14" ;←指令14
Trigger15 = Command = "AI15" ;←指令15
Trigger16 = Command = "AI16" ;←指令16
Trigger17 = Command = "AI17" ;←指令17
Trigger18 = Command = "AI18" ;←指令18
Trigger19 = Command = "AI19" ;←指令19
Trigger20 = Command = "AI20" ;←指令20
Trigger21 = Command = "AI21" ;←指令21
Trigger22 = Command = "AI22" ;←指令22
Trigger23 = Command = "AI23" ;←指令23
Trigger24 = Command = "AI24" ;←指令24
Trigger25 = Command = "AI25" ;←指令25
Trigger26 = NumHelper(30000) ;←存在helper(30000),这里helper(30000)是AI启动的helper,一会会给出
Trigger26 = Helper(30000),var(59) ;←helper(30000)的var(59)不为0(相当于辅助)
Trigger26 = Helper(30000),Time > 5 ;←helper(30000)的出现时间在5F以上
Trigger27 = Helper(40000),var(0) ;←helper(40000)的var(0)不为0(自己写的常时AI开关)
var(59) = 1 ;←则这里启动AI

这里的AI指令有25个,那么25个指令,可以按照以下command来写
这里就顺便把25个指令也贴出来吧,这里载入到Statedef -1上方,和那群command一起的位置
;-------------------------------------------------------------------------------
[Command]
name = "AI1"
command = F, B, B, F, F, B, B, F, F, B, B, F, F, B ;←不用在意这些看得懂看不懂,其实就算你按不出来AI也按得出来,指令越多AI一次性触发的概率就越大
time = 1

[Command]
name = "AI2"
command = U, D, D, U, U, D, D, U, U, D, D, U, U, D
time = 1

[Command]
name = "AI3"
command = D, U, U, D, D, U, U, D, D, U, U, D, D, U
time = 1

[Command]
name = "AI4"
command = B, F, F, B, B, F, F, B, B, F, F, B, B, F
time = 1

[Command]
name = "AI5"
command = a, x, x, a, a, x, x, a, a, x, x, a, a, x
time = 1

[Command]
name = "AI6"
command = b, y, y, b, b, y, y, b, b, y, y, b, b, y
time = 1

[Command]
name = "AI7"
command = c, z, z, c, c, z, z, c, c, z, z, c, c, z
time = 1

[Command]
name = "AI8"
command = x, a, a, x, x, a, a, x, x, a, a, x, x, a
time = 1

[Command]
name = "AI9"
command = y, b, b, y, y, b, b, y, y, b, b, y, y, b
time = 1

[Command]
name = "AI10"
command = z, c, c, z, z, c, c, z, z, c, c, z, z, c
time = 1

[Command]
name = "AI11"
command = F, B, F, B, F, B, F, B, F, B, F, B, F, B
time = 1

[Command]
name = "AI12"
command = U, D, U, D, U, D, U, D, U, D, U, D, U, D
time = 1

[Command]
name = "AI13"
command = D, U, D, U, D, U, D, U, D, U, D, U, D, U
time = 1

[Command]
name = "AI14"
command = B, F, B, F, B, F, B, F, B, F, B, F, B, F
time = 1

[Command]
name = "AI15"
command = a, x, a, x, a, x, a, x, a, x, a, x, a, x
time = 1

[Command]
name = "AI16"
command = b, y, b, y, b, y, b, y, b, y, b, y, b, y
time = 1

[Command]
name = "AI17"
command = c, z, c, z, c, z, c, z, c, z, c, z, c, z
time = 1

[Command]
name = "AI18"
command = x, a, x, a, x, a, x, a, x, a, x, a, x, a
time = 1

[Command]
name = "AI19"
command = y, b, y, b, y, b, y, b, y, b, y, b, y, b
time = 1

[Command]
name = "AI20"
command = z, c, z, c, z, c, z, c, z, c, z, c, z, c
time = 1

[Command]
name = "AI21"
command = F, B, F, B, F, B, F, B, F, B
time = 1

[Command]
name = "AI22"
command = U, D, U, D, U, D, U, D, U, D
time = 1

[Command]
name = "AI23"
command = D, U, D, U, D, U, D, U, D, U
time = 1

[Command]
name = "AI24"
command = B, F, B, F, B, F, B, F, B, F
time = 1

[Command]
name = "AI25"
command = D, U, B, F, D, U, B, F, D
time = 1

然后就在Statedef -1或者Statedef -3下载入一个HELPER,一会HELPER给出(一般不建议在Statedef -2下写,不过很多整合在-2下写AI,当然是整合)

;------------------------------------------------------------------------------
[State -3, AI Helper]
Type = Helper
TriggerAll =!var(59)
Trigger1 =!NumHelper(30000)
Trigger1 =!IsHelper
Trigger1 = RoundState <= 2 && Alive
Trigger1 =!Ctrl && StateNo = 0
helperType = Normal
Name = "AI"
StateNo = 30000
ID = 30000
Pos = 0,0
keyCtrl = 1
PauseMoveTime = 9999999
SuperMoveTime = 9999999
Persistent = 0

接下来是刚才说好的AI HELPER,Statedef 30000

;------------------------------------------------------------------------------
[Statedef 30000]
anim = 0
ctrl = 0

[State 30000, AssertSpecial]
type = AssertSpecial ;这里让玩家无法看见helper
Trigger1 = 1
flag = NoShadow ;无影子
flag2 = invisible ;不可视

[State 30000, NotHitBy]
type = NotHitBy ;为了保证helper在战斗中不受某些类似AOE的影响,给helper写上无敌作为保险项
Trigger1 = 1
value = SCA

[State 30000, 間違いで本体が来たら立ちへ移行]
type = SelfState ;当这个statedef不是helper时转到0,并在statedef 0内写上destroyself,一会给出例子
trigger1 =!ishelper
value = 0

[State 30000, Turn]
type = Turn ;转向,其实没什么太大意义
trigger1 = Facing*ifelse((EnemyNear,Pos X-Pos X)>=0,1,-1) < 0
IgnoreHitPause = 1
supermovetime = 99999999
pausemovetime = 99999999

[State 30000, プレイヤー判定]
type = VarSet ;当玩家按到如下按键时,helper也检测到则关闭AI
trigger1 = command = "up" && root,command = "up"
trigger2 = command = "down" && root,command = "down"
trigger3 = command = "back" && root,command = "back"
trigger4 = command = "fwd" && root,command = "fwd"
trigger5 = command = "a" && root,command = "a"
trigger6 = command = "b" && root,command = "b"
trigger7 = command = "c" && root,command = "c"
trigger8 = command = "x" && root,command = "x"
trigger9 = command = "y" && root,command = "y"
trigger10 = command = "z" && root,command = "z"
trigger11 = command = "start" && root,command = "start"
var(59) = -1

[State 30000, 立ったら消失]
Type = DestroySelf ;关闭AI后立即消去HELPER,给玩家手操
triggerall = isHelper
trigger1 = root,var(59) || var(59) = -1
trigger2 = command = "up" && root,command = "up"
trigger3 = command = "down" && root,command = "down"
trigger4 = command = "back" && root,command = "back"
trigger5 = command = "fwd" && root,command = "fwd"
trigger6 = command = "a" && root,command ="a"
trigger7 = command = "b" && root,command ="b"
trigger8 = command = "c" && root,command ="c"
trigger9 = command = "x" && root,command = "x"
trigger10 = command = "y" && root,command = "y"
trigger11 = command = "z" && root,command = "z"
trigger12 = command = "start" && root,command = "start"

[State 30000, フラグON]
type = VarSet ;AI未启动时如果检测到下列按钮,则触发AI
triggerall = var(59) != -1
trigger1 = root,command = "up"
trigger2 = root,command = "down"
trigger3 = root,command = "back"
trigger4 = root,command = "fwd"
trigger5 = root,command = "a"
trigger6 = root,command = "b"
trigger7 = root,command = "c"
trigger8 = root,command = "x"
trigger9 = root,command = "y"
trigger10 = root,command = "z"
trigger11 = root,command = "start"
var(59) = 1

这里有几个command是需要补充的,也列出来

;------------------------------------------------------------------------------
;-| AI Helper |----------------------------------------------------------------
[command]
name = "fwd"
command = F
time = 1

[command]
name = "back"
command = B
time = 1

[command]
name = "up"
command = U
time = 1

[command]
name = "down"
command = D
time = 1

然后就是说好的Statedef 0的举例子,这里Statedef 0不仅代表站立,还可以给helper用作保险消去

;---------------------------------------------------------------------------
; Stand
[Statedef 0]
type = S
physics = S
sprpriority = 0

;分身バグ防止
[State 0, DestroySelf] ;这里是关键,当helper脱离到此状态时,因为helper的属性还是ishelper嘛,所以让helper自动消去,防止一些禁忌多重存在XDDD
type = DestroySelf
trigger1 = IsHelper

[State 0, 残像]
type = AfterImage
trigger1 = time = 0
time = 1

[State 0, 1]
type = ChangeAnim
trigger1 = Anim != 0 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0 ;Turn anim over
value = 0

[State 0, 2]
type = VelSet
trigger1 = Time = 0
y = 0

[State 0, 3] ;Stop moving if low velocity or 4 ticks pass
type = VelSet
trigger1 = abs(vel x) < 2
trigger2 = Time = 4
x = 0

[State 0, 4] ;Are you dead?
type = ChangeState
trigger1 = !alive
value = 5050

最后在statedef -1或者statedef -3下载入helper(个人一般把command和手操控制全部写在-1,AI全部写在-3,不过其实AI写在-1比较好,但个人只是为了方便查看才这么做的)

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

好了,AI顺利载入,嗯,写AI就这么简单,这节课你有没有理解呢?

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

mizore@kotori.moe,谢谢大家!

发表留言

秘密留言

只限管理员阅览

此留言只限管理员阅览

Re: 交朋友

> 您好,大大,这次我来的目的是希望可以跟你交个朋友,好容易跟你交谈,我相信大大您应该有QQ或者其他社交网站(如果是中国大陆我是比较希望用QQ啦,就算是其他的都没关系我会尽量配合大大),不知大大意下如何

您好,在下并不是什么大大,想和我交朋友我也很开心啦,这里呆鹅928468467

アクセス

オンライン