交流區

奇幻留言版 - 回覆文章

【綜合】寵物的AI
發表人 奧扉特(安黛莉 - 2)(1F) 2008-04-16 00:31:37
回覆
在判斷敵人的狀態的選項有哪一個是可以判斷敵人已經死亡的嗎?

不然每次寵物把敵人打死了之後還會繼續開技能真是浪費耐力或魔力的事情。

而且我明明只有設定他用反擊擊退敵人之後使用火焰呀,怎麼有時候他莫名其妙自己竟然用起火焰來了?

以下是我自己寫的AI:



- <rules>

- <rule name="重擊">

- <conditions>

<condition name="target_state" state="shoved" />

</conditions>

- <pattern>

<param_decl />

- <sequence>

<cmd name="prepare_skill" pet_skill="smash" try_cnt="5" timeout="0" />

<cmd name="process_skill" target="enemy" timeout="0" />

</sequence>

</pattern>

<event name="master_attack" master_skill="smash" />

</rule>

- <rule name="救援">

<conditions />

- <pattern>

<param_decl />

- <sequence>

<cmd name="melee_attack" timeout="0" />

</sequence>

</pattern>

<event name="master_attacked" master_skill="all" down="false" />

</rule>

- <rule name="治療">

- <conditions>

<condition name="master_damaged_life_greater" life="40" />

</conditions>

- <pattern>

<param_decl />

- <sequence>

<cmd name="prepare_skill" pet_skill="healing" try_cnt="0" timeout="5000" />

<cmd name="process_skill" target="master" timeout="0" />

</sequence>

</pattern>

<event name="master_attacked" master_skill="all" down="true" />

</rule>

- <rule name="反擊">

- <conditions>

<condition name="skill_preparable" pet_skill="counter" />

</conditions>

- <pattern>

<param_decl />

- <sequence>

<cmd name="prepare_skill" pet_skill="counter" try_cnt="3" timeout="10000" />

</sequence>

</pattern>

<event name="attacked" master_skill="all" down="true" />

</rule>

- <rule name="反擊2">

- <conditions>

<condition name="target_distance" min_distance="400" max_distance="1000" />

</conditions>

- <pattern>

<param_decl />

- <sequence>

<cmd name="prepare_skill" pet_skill="counter" try_cnt="2" timeout="0" />

</sequence>

</pattern>

<event name="targeted" targeting_type="attack" />

</rule>

- <rule name="反擊3">

- <conditions>

<condition name="skill_preparable" pet_skill="counter" />

</conditions>

- <pattern>

<param_decl />

- <sequence>

<cmd name="prepare_skill" pet_skill="counter" try_cnt="0" timeout="10000" />

</sequence>

</pattern>

<event name="attack" pet_attackable_skill="firebolt" down="true" />

</rule>

- <rule name="反擊4">

- <conditions>

<condition name="skill_preparable" pet_skill="counter" />

</conditions>

- <pattern>

<param_decl />

- <sequence>

<cmd name="prepare_skill" pet_skill="counter" try_cnt="0" timeout="10000" />

</sequence>

</pattern>

<event name="attack" pet_attackable_skill="lightningbolt" down="false" />

</rule>

- <rule name="反擊5">

<conditions />

- <pattern>

<param_decl />

- <sequence>

<cmd name="prepare_skill" pet_skill="counter" try_cnt="3" timeout="10000" />

</sequence>

</pattern>

<event name="attack" pet_attackable_skill="basic" down="true" />

</rule>

- <rule name="火焰">

- <conditions>

<condition name="skill_preparable" pet_skill="firebolt" />

</conditions>

- <pattern>

<param_decl />

- <sequence>

<cmd name="stackmagic_attack" stack_magic="firebolt" charge="1" timeout="0" />

</sequence>

</pattern>

<event name="attack" pet_attackable_skill="counter" down="true" />

</rule>

- <rule name="雷矢">

- <conditions>

<condition name="skill_preparable" pet_skill="lightningbolt" />

</conditions>

- <pattern>

<param_decl />

- <sequence>

<cmd name="stackmagic_attack" stack_magic="lightningbolt" charge="1" timeout="0" />

</sequence>

</pattern>

<event name="attack" pet_attackable_skill="counter" down="true" />

</rule>

- <rule name="先發制人">

<conditions />

- <pattern>

<param_decl />

- <sequence>

<cmd name="prepare_skill" pet_skill="smash" try_cnt="5" timeout="0" />

<cmd name="process_skill" target="enemy" timeout="0" />

</sequence>

</pattern>

<event name="master_targeted" targeting_type="alert" />

</rule>

- <rule name="先發制人2">

- <conditions>

<condition name="target_state" state="walk, run" />

</conditions>

- <pattern>

<param_decl />

- <sequence>

<cmd name="prepare_skill" pet_skill="smash" try_cnt="5" timeout="0" />

<cmd name="process_skill" target="enemy" timeout="0" />

</sequence>

</pattern>

<event name="master_targeted" targeting_type="attack" />

</rule>

- <rule name="先發制人3">

<conditions />

- <pattern>

<param_decl />

- <sequence>

<cmd name="prepare_skill" pet_skill="smash" try_cnt="5" timeout="0" />

<cmd name="process_skill" target="enemy" timeout="0" />

</sequence>

</pattern>

<event name="targeted" targeting_type="alert" />

</rule>

- <rule name="先發制人4">

- <conditions>

<condition name="target_distance" min_distance="100" max_distance="400" />

<condition name="target_state" state="walk, run" />

</conditions>

- <pattern>

<param_decl />

- <sequence>

<cmd name="melee_attack" timeout="0" />

</sequence>

</pattern>

<event name="targeted" targeting_type="attack" />

</rule>

- <rule name="先發制人5">

- <conditions>

<condition name="target_distance" min_distance="400" max_distance="1500" />

<condition name="skill_preparable" pet_skill="firebolt" />

</conditions>

- <pattern>

<param_decl />

- <sequence>

<cmd name="stackmagic_attack" stack_magic="firebolt" charge="1" timeout="0" />

</sequence>

</pattern>

<event name="targeted" targeting_type="attack" />

</rule>

- <rule name="先發制人6">

- <conditions>

<condition name="target_distance" min_distance="400" max_distance="1500" />

<condition name="skill_preparable" pet_skill="lightningbolt" />

</conditions>

- <pattern>

<param_decl />

- <sequence>

<cmd name="stackmagic_attack" stack_magic="lightningbolt" charge="1" timeout="0" />

</sequence>

</pattern>

<event name="targeted" targeting_type="attack" />

</rule>

- <rule name="弓箭手">

- <conditions>

<condition name="skill_preparable" pet_skill="firebolt" />

</conditions>

- <pattern>

<param_decl />

- <sequence>

<cmd name="move_against" distance="1500" run="true" timeout="0" />

<cmd name="stackmagic_attack" stack_magic="firebolt" charge="1" timeout="0" />

</sequence>

</pattern>

<event name="aimed" />

</rule>

- <rule name="弓箭手2">

- <conditions>

<condition name="skill_preparable" pet_skill="lightningbolt" />

</conditions>

- <pattern>

<param_decl />

- <sequence>

<cmd name="move_against" distance="1500" run="true" timeout="0" />

<cmd name="stackmagic_attack" stack_magic="lightningbolt" charge="1" timeout="0" />

</sequence>

</pattern>

<event name="aimed" />

</rule>

- <rule name="弓箭手3">

- <conditions>

<condition name="target_state" state="stop" />

</conditions>

- <pattern>

<param_decl />

- <sequence>

<cmd name="prepare_skill" pet_skill="smash" try_cnt="5" timeout="0" />

<cmd name="process_skill" target="enemy" timeout="0" />

</sequence>

</pattern>

<event name="master_aimed" />

</rule>

- <rule name="受攻擊防禦">

- <conditions>

<condition name="target_state" state="hit" />

<condition name="skill_preparable" pet_skill="defence" />

</conditions>

- <pattern>

<param_decl />

- <sequence>

<cmd name="prepare_skill" pet_skill="defence" try_cnt="3" timeout="5000" />

</sequence>

</pattern>

<event name="attacked" master_skill="basic" down="false" />

</rule>

- <rule name="防禦後攻擊">

<conditions />

- <pattern>

<param_decl />

- <sequence>

<cmd name="melee_attack" timeout="0" />

</sequence>

</pattern>

<event name="defence" defence_enable_skill="basic" />

</rule>

- <rule name="取消技能攻擊">

- <conditions>

<condition name="target_distance" min_distance="100" max_distance="400" />

</conditions>

- <pattern>

<param_decl />

- <sequence>

<cmd name="cancel_skill" />

<cmd name="melee_attack" timeout="0" />

</sequence>

</pattern>

<event name="target_skill_prepare" />

</rule>

- <rule name="防止敵人貼近">

- <conditions>

<condition name="target_state" state="hit" />

</conditions>

- <pattern>

<param_decl />

- <sequence>

<cmd name="prepare_skill" pet_skill="basic" try_cnt="0" timeout="5000" />

</sequence>

</pattern>

<event name="master_attack" master_skill="ranged_attack" />

</rule>

- <rule name="防止敵人貼近2">

- <conditions>

<condition name="target_state" state="run" />

</conditions>

- <pattern>

<param_decl />

- <sequence>

<cmd name="melee_attack" timeout="0" />

</sequence>

</pattern>

<event name="master_attack" master_skill="ranged_attack" />

</rule>

- <rule name="尋找敵人">

- <conditions>

<condition name="target_state" state="stop, walk" />

</conditions>

- <pattern>

<param_decl />

- <sequence>

<cmd name="cancel_skill" />

<cmd name="melee_attack" timeout="0" />

</sequence>

</pattern>

<event name="seek_target" />

</rule>

- <rule name="輪流攻擊">

- <conditions>

<condition name="target_state" state="shoved" />

</conditions>

- <pattern>

<param_decl />

- <sequence>

<cmd name="melee_attack" timeout="0" />

</sequence>

</pattern>

<event name="master_attack" master_skill="basic" />

</rule>

</rules>



重擊的地方是主人重擊完敵人之後寵物就接著重擊敵人

救援是指主人被打的時候寵物去攻擊攻擊主人的敵人

再來是一系列狀況下的反擊(被盯上的時候、使用魔法攻擊完之後、被攻擊之後)

先發制人系列就是被識別的時候先去攻擊敵人

弓箭手系列是用來對付弓箭手的,但是基本上沒有成功過=3=(可能是弓箭手射程都超過1500吧?AI的設定最多只能讓寵退到1500,而且我的寫法實際上只有在敵人已經採取瞄準姿勢的時候這個AI才會被啟動= =)

受攻擊後防禦是在雙方都因為攻擊進入僵直狀態時讓寵使用防禦,當防禦成功之後便給予反擊

取消技能攻擊是為了防止防禦時被重擊,即敵人距離在4碼以內時取消技能上前攻擊

防止敵人貼近是在使用弓箭時,以寵物牽制敵人防止因miss而導致悲劇發生...

尋找敵人便是讓寵物主動攻擊敵人,這是最成功的AI不過有時寵物會笨笨的呆在原地散步...

最後的輪流攻擊就有點像是輪流重擊了,不過這是對付小怪用的,其實在考慮實用性上可以把它砍掉



不知道大家還有些什麼建議或者是經驗的,歡迎交流一下唷,我很希望能夠把寵物AI寫得盡善盡美
回覆宮代花梨 [ Lv.334 ] ?(愛麗沙 - 8)(2F) 2008-04-16 00:34:22
 
真的...太長了



建議之後用連結的方式連到您用心的創作
[ 此文章已由作者修改 1 次 最後更新於:2008-04-16 00:35:39 ]
回覆snowfire [ Lv.904 ] ?(貝婷 - 6)(3F) 2008-04-16 00:34:27
 
太長啦@@!!||||||

雖然知道你的用心但是文章過長的話~

容易鎖定喔^^"
[ 此文章已由管理員 宮代花梨? 鎖定 ]
 
Message請先 登入 會員才能發表或回覆文章。
 
 
Message此篇文章已鎖定,無法進行回覆。
 

網路禮儀

網路發言雖然是匿名性質,但網路發表文章還是請遵守基本的網路禮儀,請勿發表含有不雅文字、人身攻擊等文章內容,良好的奇幻交流環境需要您的配合!
回頂端