翔鹰帝国网|帝国时代论坛|帝国时代系列|神话时代
 找回密码
 注册翔鹰会员(昵称)
搜索
查看: 742|回复: 3

[教程] [UP1.5] 用4种攻击姿态来发动技能 - RPG战役又添一神器!

[复制链接]

183

主题

9

精华

2万

积分

教皇

耕战
3325
鹰币
14967
天龙币
0
回帖
1200

翔鹰建站十周年纪念章

附庸关系3
 楼主| 发表于 2020-5-22 01:27:24 | 显示全部楼层 |阅读模式
AI文件:(与下面的正文完全一致,可选择其中一种阅读)
注:本per文件为GBK编码,可直接用于UP1.5/WK。在DE里用时,需要自己转码为UTF-8。




;///////////////////////////////////////////////////////////
;// --------------------- AI实用模块 ---------------------//
;//                 检测主角姿态→改变状态                //
;//                 检测主角姿态→发动技能                //
;//                                     作者:newtonerdai //
;//                                       www.hawkaoe.net //
;///////////////////////////////////////////////////////////
;
;                         【前言】
;▲模块作用:在RPG战役里,使用4种攻击姿态按钮作为发动效果的方式。



;(有两种用法,一种是点击后切换状态,第一种是点击后发动一次效果
;
;▲适用版本:仅适用于支持UP1.5 AI语句的版本。如UP1.5、WK、DE。
;

;----------------------------------------------------------
;              1. 获取主角姿态 → 切换4种状态
;----------------------------------------------------------




(defconst hero-mapid 100)   ; 储存主角的地图ID
(defconst hero-stance 101)  ; 储存主角的姿态
(defconst rsc-amount 102)   ; 储存联动资源数量。rsc = ReSourCe


;====================   参数输入部分   ===================
;主角的地图ID。可通过AOKTS(旧版)或[https://www.hawkaoe.net/bbs/thread-146210-1-1.html]这个AI模块(DE版)来获取
(defrule
    (true)
=>
    (set-goal hero-mapid 0)
    (disable-self)
)

;======================   运行部分   ======================
;获取主角攻击姿态数值。
(defrule
    (true)
    (up-set-target-by-id g: hero-mapid)   ;只有ID有效且主角还活着才会执行
=>
    (up-get-object-data 21 hero-stance)   ;【核心语句】21 = 攻击姿态
)

;清空联动资源220号
(defrule
    (true)
=>
    ; 34 = 资源数量。220为资源编号
    (up-get-fact 34 220 rsc-amount)
    (up-modify-goal rsc-amount c:* -1)
    (up-cc-add-resource c: 220 g: rsc-amount)
)

;分别判断4种姿态,并维持资源量状态,让触发检测
(defrule
    (true)
    (up-compare-goal hero-stance c:== 0)  ; 0 = 进攻姿态
=>
    (up-cc-add-resource c: 220 c: 1)
)
(defrule
    (true)
    (up-compare-goal hero-stance c:== 1)  ; 1 = 防御姿态
=>
    (up-cc-add-resource c: 220 c: 2)
)
(defrule
    (true)
    (up-compare-goal hero-stance c:== 2)  ; 2 = 坚守姿态
=>
    (up-cc-add-resource c: 220 c: 4)
)
(defrule
    (true)
    (up-compare-goal hero-stance c:== 3)  ; 3 = 不还击姿态
=>
    (up-cc-add-resource c: 220 c: 8)
)



;----------------------------------------------------------
;            2. 获取主角姿态 → 改变时发动效果
;----------------------------------------------------------




(defconst hero-mapid2 110)        ; 储存主角的地图ID
(defconst hero-stance-now 111)    ; 储存主角当前的姿态
(defconst hero-stance-pre 112)    ; 储存主角1秒前的姿态
(defconst rsc-amount2 113)        ; 储存联动资源数量。rsc = ReSourCe

;====================   参数输入部分   ===================
;主角的地图ID。可通过AOKTS(旧版)或[https://www.hawkaoe.net/bbs/thread-146210-1-1.html]这个AI模块(DE版)来获取
(defrule
    (true)
=>
    (set-goal hero-mapid2 0)
    (disable-self)
)

;======================   运行部分   ======================
;激活这个模块时,先获取一轮相同的now和pre姿态,避免激活时判断为姿态变化
(defrule
    (true)
    (up-set-target-by-id g: hero-mapid2)
=>
    (up-get-object-data 21 hero-stance-now)
    (up-get-object-data 21 hero-stance-pre)
    (disable-self)
)

;时刻获取当前主角攻击姿态
(defrule
    (true)
    (up-timer-status 11 c:<= 1)                 ; 11号计时器关闭或触发时满足条件
    (up-set-target-by-id g: hero-mapid2)
=>
    (up-get-object-data 21 hero-stance-now)     ; 21 = 攻击姿态
)

;清空联动资源219号
(defrule
    (true)
    (up-timer-status 11 c:<= 1)
=>
    ; 34 = 资源数量。219为资源编号
    (up-get-fact 34 219 rsc-amount2)
    (up-modify-goal rsc-amount2 c:* -1)
    (up-cc-add-resource c: 219 g: rsc-amount2)
)

;>> 如果姿态改变了,则获取100~103点219号资源 <<
(defrule
    (true)
    (up-timer-status 11 c:<= 1)
    (up-compare-goal hero-stance-now g:!= hero-stance-pre)
=>
    ;如果变了则资源219将为100~103。在触发里可以检测>=100并-100,得到0~4的姿态数值。
    (up-cc-add-resource c: 219 g: hero-stance-now)
    (up-cc-add-resource c: 219 c: 100)
)
;>> 如果姿态未改变,则直接获取0~3点219号资源 <<
(defrule
    (true)
    (up-timer-status 11 c:<= 1)
    (up-compare-goal hero-stance-now g:== hero-stance-pre)
=>
    (up-cc-add-resource c: 219 g: hero-stance-now)
)

;遍历结束前,把当前姿态作为下次遍历时的“之前姿态”
(defrule
    (true)
    (up-timer-status 11 c:<= 1)
=>
    (up-modify-goal hero-stance-pre g:= hero-stance-now)
    (enable-timer 11 1)         ;【重要】最好使用1秒间隔,否则会出现AI过快更迭“当前”“之前”但触发没有收到变化的情况
)



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册翔鹰会员(昵称)

x
索引:
Userpatch 实用技术贴索引←点击进入
决定版精品贴大索引←点击进入

战役:
《 兔与豹》——柔弱奴隶公主  猛兽口中求生←点击进入
《敛由国的统一》←点击进入

殊途战役制作群 QQ: 616317226
翔鹰帝国Ⅱ:决定版交流群 QQ: 112822759
回复

使用道具 举报

本版积分规则

排行榜|小黑屋|翔鹰帝国

GMT+8, 2024-3-29 20:34 , Processed in 0.111884 second(s), 26 queries , File On.

Powered by Hawk Studio  QS Security Corp.® Licensed

Copyright © 2001-2023, Hawkaoe.net All Rights Reserved

快速回复 返回顶部 返回列表