- UID
- 317864
- 帖子
- 117
- 精华
- 0
- 威望
- 0
- 阅读权限
- 100
- 注册时间
- 2005-10-15
|
6#
发表于 2006-1-7 22:26
| 只看该作者
- require "./AI/Const.lua"
- require "./AI/Util.lua"
- -----------------------------
- -- RO的技能常数
- -----------------------------
- --[[
- 丽芙-治癒之手 = 8001
- 丽芙-轻捷移动 = 8002
- 丽芙-脑手术 = 8003
- 丽芙-智力变换 = 8004(未开放)
- 艾咪斯可鲁-位置互换 = 8005
- 艾咪斯可鲁-防御力 = 8006
- 艾咪斯可鲁-活命之肤 = 8007
- 艾咪斯可鲁-血的贪求 = 8008(未开放)
- 飞里乐-月光 = 8009
- 飞里乐-横越速度 = 8010
- 飞里乐-紧急回避 = 8011
- 飞里乐-S.B.R.44 = 8012(未开放)
- 巴尼米乐斯-善变 = 8013
- 巴尼米乐斯-混乱的祈福 = 8014
- 巴尼米乐斯-变更指示 = 8015
- 巴尼米乐斯-生物爆炸 = 8016(未开放)
- --]]
- -----------------------------
- -----------------------------
- -- state
- -----------------------------
- IDLE_ST = 0 -- 休息(发呆)
- FOLLOW_ST = 1 -- 跟随
- CHASE_ST = 2 -- 追纵
- ATTACK_ST = 3 -- 攻击中
- MOVE_CMD_ST = 4 -- 移动
- STOP_CMD_ST = 5 -- 停止
- ATTACK_OBJECT_CMD_ST = 6 -- 攻击某物的状态
- ATTACK_AREA_CMD_ST = 7 -- 攻击某区域
- PATROL_CMD_ST = 8 -- 侦查中
- HOLD_CMD_ST = 9 -- 死守中
- SKILL_OBJECT_CMD_ST = 10 -- 对某物使用技能时
- SKILL_AREA_CMD_ST = 11 -- 对某区域使用技能时
- FOLLOW_CMD_ST = 12 -- 跟随某物
- ----------------------------
- ------------------------------------------
- -- Global variable
- ------------------------------------------
- MyState = IDLE_ST -- 最初的状态是 休息
- MyEnemy = 0 -- 敌人的 id
- MyDestX = 0 -- 目前位置 x
- MyDestY = 0 -- 目前位置 y
- MyPatrolX = 0 -- 侦查 目的地 x
- MyPatrolY = 0 -- 侦查 目的地 y
- ResCmdList = List.new() -- 预约 命令 清单
- MyID = 0 -- 生命体 id
- MySkill = 0 -- 生命体技能
- MySkillLevel = 0 -- 生命体技能等级
- ------------------------------------------
- ------------- command process ---------------------
- function OnMOVE_CMD (x,y)
-
- TraceAI ("OnMOVE_CMD")
- if ( x == MyDestX and y == MyDestY and MOTION_MOVE == GetV(V_MOTION,MyID)) then
- return --
- end
- local curX, curY = GetV (V_POSITION,MyID)
- if (math.abs(x-curX)+math.abs(y-curY) > 15) then -- 迹瞳虽陛 橾姜 剪葬 桧鼻桧贼 (怃帼缣怃 试剪葬朝 籀葬虽 强晦 阳侥缣)
- List.pushleft (ResCmdList,{MOVE_CMD,x,y}) -- 锰楚 迹瞳虽煎暧 桧翕击 蕨擒棻.
- x = math.floor((x+curX)/2) -- 酝除虽薄戏煎 试荡 桧翕棻.
- y = math.floor((y+curY)/2) --
- end
- Move (MyID,x,y)
-
- MyState = MOVE_CMD_ST
- MyDestX = x
- MyDestY = y
- MyEnemy = 0
- MySkill = 0
- end
- function OnSTOP_CMD ()
- TraceAI ("OnSTOP_CMD")
- if (GetV(V_MOTION,MyID) ~= MOTION_STAND) then
- Move (MyID,GetV(V_POSITION,MyID))
- end
- MyState = IDLE_ST
- MyDestX = 0
- MyDestY = 0
- MyEnemy = 0
- MySkill = 0
- end
- function OnATTACK_OBJECT_CMD (id)
- TraceAI ("OnATTACK_OBJECT_CMD")
- MySkill = 0
- MyEnemy = id
- MyState = CHASE_ST
- end
- function OnATTACK_AREA_CMD (x,y)
- TraceAI ("OnATTACK_AREA_CMD")
- if (x ~= MyDestX or y ~= MyDestY or MOTION_MOVE ~= GetV(V_MOTION,MyID)) then
- Move (MyID,x,y)
- end
- MyDestX = x
- MyDestY = y
- MyEnemy = 0
- MyState = ATTACK_AREA_CMD_ST
-
- end
- function OnPATROL_CMD (x,y)
- TraceAI ("OnPATROL_CMD")
- MyPatrolX , MyPatrolY = GetV (V_POSITION,MyID)
- MyDestX = x
- MyDestY = y
- Move (MyID,x,y)
- MyState = PATROL_CMD_ST
- end
- function OnHOLD_CMD ()
- TraceAI ("OnHOLD_CMD")
- MyDestX = 0
- MyDestY = 0
- MyEnemy = 0
- MyState = HOLD_CMD_ST
- end
- function OnSKILL_OBJECT_CMD (level,skill,id)
- TraceAI ("OnSKILL_OBJECT_CMD")
- MySkillLevel = level
- MySkill = skill
- MyEnemy = id
- MyState = CHASE_ST
- end
- function OnSKILL_AREA_CMD (level,skill,x,y)
- TraceAI ("OnSKILL_AREA_CMD")
- Move (MyID,x,y)
- MyDestX = x
- MyDestY = y
- MySkillLevel = level
- MySkill = skill
- MyState = SKILL_AREA_CMD_ST
-
- end
- function OnFOLLOW_CMD ()
- -- 系统接收到RO的ALT+T
- if (MyState ~= FOLLOW_CMD_ST) then
- MoveToOwner (MyID)
- MyState = FOLLOW_CMD_ST
- MyDestX, MyDestY = GetV (V_POSITION,GetV(V_OWNER,MyID))
- MyEnemy = 0
- MySkill = 0
- TraceAI ("OnFOLLOW_CMD")
- else
- MyState = IDLE_ST
- MyEnemy = 0
- MySkill = 0
- TraceAI ("FOLLOW_CMD_ST --> IDLE_ST")
- end
- end
- function ProcessCommand (msg)
- if (msg[1] == MOVE_CMD) then
- OnMOVE_CMD (msg[2],msg[3])
- TraceAI ("MOVE_CMD")
- elseif (msg[1] == STOP_CMD) then
- OnSTOP_CMD ()
- TraceAI ("STOP_CMD")
- elseif (msg[1] == ATTACK_OBJECT_CMD) then
- OnATTACK_OBJECT_CMD (msg[2])
- TraceAI ("ATTACK_OBJECT_CMD")
- elseif (msg[1] == ATTACK_AREA_CMD) then
- OnATTACK_AREA_CMD (msg[2],msg[3])
- TraceAI ("ATTACK_AREA_CMD")
- elseif (msg[1] == PATROL_CMD) then
- OnPATROL_CMD (msg[2],msg[3])
- TraceAI ("PATROL_CMD")
- elseif (msg[1] == HOLD_CMD) then
- OnHOLD_CMD ()
- TraceAI ("HOLD_CMD")
- elseif (msg[1] == SKILL_OBJECT_CMD) then
- OnSKILL_OBJECT_CMD (msg[2],msg[3],msg[4],msg[5])
- TraceAI ("SKILL_OBJECT_CMD")
- elseif (msg[1] == SKILL_AREA_CMD) then
- OnSKILL_AREA_CMD (msg[2],msg[3],msg[4],msg[5])
- TraceAI ("SKILL_AREA_CMD")
- elseif (msg[1] == FOLLOW_CMD) then
- OnFOLLOW_CMD ()
- TraceAI ("FOLLOW_CMD")
- end
- end
- -------------- state process --------------------
- --------------------------------------------------
- -- 休息(发呆) ST
- --------------------------------------------------
- function OnIDLE_ST ()
-
- TraceAI ("OnIDLE_ST")
- local cmd = List.popleft(ResCmdList)
- if (cmd ~= nil) then
- ProcessCommand (cmd) -- 执行预约命令
- return
- end
- local object = GetOwnerEnemy (MyID)
- if (object ~= 0) then -- 取得主人的敌人ID
- MyState = CHASE_ST
- MyEnemy = object
- TraceAI ("IDLE_ST -> CHASE_ST : MYOWNER_ATTACKED_IN")
- return
- end
- object = GetMyEnemy (MyID)
- if (object ~= 0) then -- 取得自己的敌人ID
- MyState = CHASE_ST
- MyEnemy = object
- TraceAI ("IDLE_ST -> CHASE_ST : ATTACKED_IN")
- return
- end
- local distance = GetDistanceFromOwner(MyID)
- if ( distance > 2 or distance == -1) then -- 与主人的距离 > 2格时开始跟随
- MyState = FOLLOW_ST
- TraceAI ("IDLE_ST -> FOLLOW_ST")
- return;
- end
- end
- --------------------------------------------------------------
- -- 没事时自动跟随主人
- --------------------------------------------------------------
- function OnFOLLOW_ST ()
- TraceAI ("OnFOLLOW_ST")
- if (GetDistanceFromOwner(MyID) <= 2) then -- DESTINATION_ARRIVED_IN
- MyState = IDLE_ST
- TraceAI ("FOLLOW_ST -> IDLW_ST")
- return;
- elseif (GetV(V_MOTION,MyID) == MOTION_STAND) then
- MoveToOwner (MyID)
- TraceAI ("FOLLOW_ST -> FOLLOW_ST")
- return;
- end
- end
- ---------------------------------------------------------------
- -- 追踪中ST
- ---------------------------------------------------------------
- function OnCHASE_ST ()
-
- TraceAI ("OnCHASE_ST")
- if (true == IsOutOfSight(MyID,MyEnemy)) then -- IF人工生命和魔物为不可视距离
- MyState = IDLE_ST
- MyEnemy = 0
- MyDestX, MyDestY = 0,0
- TraceAI ("CHASE_ST -> IDLE_ST : ENEMY_OUTSIGHT_IN")
- return
- end
- if (true == IsInAttackSight(MyID,MyEnemy)) then -- IF人工生命正在对目标攻击或使用技能
- MyState = ATTACK_ST
- TraceAI ("CHASE_ST -> ATTACK_ST : ENEMY_INATTACKSIGHT_IN")
- return
- end
- local x, y = GetV (V_POSITION,MyEnemy)
- if (MyDestX ~= x or MyDestY ~= y) then -- 改变现在的位置到目标的位置去
- MyDestX, MyDestY = GetV (V_POSITION,MyEnemy);
- Move (MyID,MyDestX,MyDestY)
- TraceAI ("CHASE_ST -> CHASE_ST : DESTCHANGED_IN")
- return
- end
- end
- ---------------------------------------------------------------
- -- 攻击中 ST
- ---------------------------------------------------------------
- function OnATTACK_ST ()
- TraceAI ("OnATTACK_ST")
- local HPp = GetV (V_HP,MyID) / GetV (V_MAXHP,MyID) -- HP%
- local SPp = GetV (V_SP,MyID) / GetV (V_MAXSP,MyID) -- SP%
- local owner = GetV (V_OWNER,MyID)
- local OHPp = GetV (V_HP,owner) / GetV (V_MAXHP,owner) -- OWNER HP%
- local OSPp = GetV (V_SP,owner) / GetV (V_MAXSP,owner) -- OWNER SP%
- local type = GetV (V_HOMUNTYPE,MyID)
- if (true == IsOutOfSight(MyID,MyEnemy)) then -- IF敌人和人工生命为不可视距离
- MyState = IDLE_ST
- TraceAI ("ATTACK_ST -> IDLE_ST")
- return
- end
- if (MOTION_DEAD == GetV(V_MOTION,MyEnemy)) then -- 敌人死亡
- MyState = IDLE_ST
- TraceAI ("ATTACK_ST -> IDLE_ST")
- return
- end
-
- if (false == IsInAttackSight(MyID,MyEnemy)) then -- 敌人逃跑时追过去
- MyState = CHASE_ST
- MyDestX, MyDestY = GetV (V_POSITION,MyEnemy);
- Move (MyID,MyDestX,MyDestY)
- TraceAI ("ATTACK_ST -> CHASE_ST : ENEMY_OUTATTACKSIGHT_IN")
- return
- end
- if (MySkill == 0) then -- 非使用技能状态
- ---------------------自动使用技能区块----------------------------------------------------------
- if (GetV (V_SP,MyID) >= 25) then
- if (type == AMISTR or type == AMISTR_H) then
- if ((OHPp <= 0.25 or HPp <= 0.25) and MOTION_ATTACK == GetV(V_MOTION,GetMyEnemy (MyID))) then
- MySkill = AutoSkillSet (MyID) -- 羊
- MySkillLevel = 5 -- 技能等级请自行设定
- SkillObject (MyID,MySkillLevel,MySkill,owner)
- TraceAI ("OnAutoSkill")
- end
- elseif (type == FILIR or type == FILIR_H or type == VANILMIRTH or type == VANILMIRTH_H) then
- if (HPp <= 0.25 or SPp == 1) then
- MySkill = AutoSkillSet (MyID) -- 飞里乐 和 布丁
- MySkillLevel = 5 -- 技能等级请自行设定
- SkillObject (MyID,MySkillLevel,MySkill,MyEnemy)
- TraceAI ("OnAutoSkill")
- end
- end
- MySkill = 0
- end
- -----------------------------------------------------------------------------------------------
- Attack (MyID,MyEnemy)
- else -- 技能使用状态
- SkillObject (MyID,MySkillLevel,MySkill,MyEnemy)
- TraceAI (string.format("MySkillLevel: %d,MySkill:%d",MySkillLevel,MySkill))
- MySkill = 0
- end
- TraceAI ("ATTACK_ST -> ATTACK_ST : ENERGY_RECHARGED_IN")
- return
- end
- ----------------------------------------------------------------
- -- 移动到指定位置
- ----------------------------------------------------------------
- function OnMOVE_CMD_ST ()
- TraceAI ("OnMOVE_CMD_ST")
- local x, y = GetV (V_POSITION,MyID)
- if (x == MyDestX and y == MyDestY) then -- 到达指定位置时
- MyState = IDLE_ST -- 可改成指定ST
- end
- end
- ----------------------------------------------------------------
- -- STOP (可程式)
- ----------------------------------------------------------------
- function OnSTOP_CMD_ST ()
- -- TraceAI ("OnSTOP_CMD_ST")
- -- MyState = HOLD_CMD_ST
- end
- ----------------------------------------------------------------
- -- 攻击目标命令 (可程式)
- ----------------------------------------------------------------
- function OnATTACK_OBJECT_CMD_ST ()
- end
- ----------------------------------------------------------------
- -- 区域攻击
- ----------------------------------------------------------------
- function OnATTACK_AREA_CMD_ST ()
- TraceAI ("OnATTACK_AREA_CMD_ST")
- local object = GetOwnerEnemy (MyID)
- if (object == 0) then
- object = GetMyEnemy (MyID)
- end
- if (object ~= 0) then -- MYOWNER_ATTACKED_IN or ATTACKED_IN
- MyState = CHASE_ST
- MyEnemy = object
- return
- end
- local x , y = GetV (V_POSITION,MyID)
- if (x == MyDestX and y == MyDestY) then -- DESTARRIVED_IN
- MyState = IDLE_ST
- end
- end
- ----------------------------------------------------------------
- -- 侦查中
- ----------------------------------------------------------------
- function OnPATROL_CMD_ST ()
- TraceAI ("OnPATROL_CMD_ST")
- local object = GetOwnerEnemy (MyID)
- if (object == 0) then
- object = GetMyEnemy (MyID)
- end
- if (object ~= 0) then -- MYOWNER_ATTACKED_IN or ATTACKED_IN
- MyState = CHASE_ST
- MyEnemy = object
- TraceAI ("PATROL_CMD_ST -> CHASE_ST : ATTACKED_IN")
- return
- end
- local x , y = GetV (V_POSITION,MyID)
- if (x == MyDestX and y == MyDestY) then -- DESTARRIVED_IN
- MyDestX = MyPatrolX
- MyDestY = MyPatrolY
- MyPatrolX = x
- MyPatrolY = y
- Move (MyID,MyDestX,MyDestY)
- end
- end
- ----------------------------------------------------------------
- -- 守候(死守)..游戏中指令控制是否进入,程式不会自动进入此回圈
- ----------------------------------------------------------------
- function OnHOLD_CMD_ST ()
- TraceAI ("OnHOLD_CMD_ST")
-
- if (MyEnemy ~= 0) then
- local d = GetDistance(MyEnemy,MyID)
- if (d ~= -1 and d <= GetV(V_ATTACKRANGE,MyID)) then
- Attack (MyID,MyEnemy)
- else
- MyEnemy = 0;
- end
- return
- end
- local object = GetOwnerEnemy (MyID)
- if (object == 0) then
- object = GetMyEnemy (MyID)
- if (object == 0) then
- return
- end
- end
- MyEnemy = object
- end
- ----------------------------------------------------------------
- -- 对物体目标使用技能(可程式)
- ----------------------------------------------------------------
- function OnSKILL_OBJECT_CMD_ST ()
-
- end
- ----------------------------------------------------------------
- -- 对区域使用技能
- ----------------------------------------------------------------
- function OnSKILL_AREA_CMD_ST ()
- TraceAI ("OnSKILL_AREA_CMD_ST")
- local x , y = GetV (V_POSITION,MyID)
- if (GetDistance(x,y,MyDestX,MyDestY) <= GetV(V_SKILLATTACKRANGE,MyID,MySkill)) then -- DESTARRIVED_IN
- SkillGround (MyID,MySkillLevel,MySkill,MyDestX,MyDestY)
- MyState = IDLE_ST
- MySkill = 0
- end
- end
- ----------------------------------------------------------------
- -- 跟随主人(系统指令) 相当於ALT+T
- ----------------------------------------------------------------
- function OnFOLLOW_CMD_ST ()
- local object = GetOwnerEnemy (MyID)
- local x, y
- local SPp = GetV (V_SP,MyID) / GetV (V_MAXSP,MyID) -- SP%
- local type = GetV (V_HOMUNTYPE,MyID)
- if (object ~= 0) then -- 取得主人的敌人ID
- MyEnemy = object
- if (false == IsInAttackSight(MyID,MyEnemy)) then -- IF人工生命正在对目标攻击或使用技能
- MyDestX, MyDestY = GetV (V_POSITION,MyEnemy)
- Move (MyID,MyDestX,MyDestY)
- return
- end
- if (MySkill == 0) then -- 非使用技能状态
- ----------------------------------自动使用技能区块---------------------------------
- if (GetV (V_SP,MyID) >= 25) then
- if (type == AMISTR or type == AMISTR_H) then
- if ((OHPp <= 0.25 or HPp <= 0.25) and MOTION_ATTACK == GetV(V_MOTION,GetMyEnemy (MyID))) then
- MySkill = AutoSkillSet (MyID) -- 羊
- MySkillLevel = 5 -- 技能等级请自行设定
- SkillObject (MyID,MySkillLevel,MySkill,owner)
- TraceAI ("OnAutoSkill")
- end
- elseif (type == FILIR or type == FILIR_H or type == VANILMIRTH or type == VANILMIRTH_H) then
- if (SPp == 1) then
- MySkill = AutoSkillSet (MyID) -- 飞里乐 和 布丁
- MySkillLevel = 1 -- 技能等级请自行设定
- SkillObject (MyID,MySkillLevel,MySkill,MyEnemy)
- TraceAI ("OnAutoSkill")
- end
- end
- MySkill = 0
- end
- -----------------------------------------------------------------------------------
- Attack (MyID,MyEnemy)
- else -- 技能使用状态
- SkillObject (MyID,MySkillLevel,MySkill,MyEnemy)
- TraceAI (string.format("MySkillLevel: %d,MySkill:%d",MySkillLevel,MySkill))
- MySkill = 0
- end
- return
- end
- TraceAI ("OnFOLLOW_CMD_ST")
- local ownerX, ownerY, myX, myY
- ownerX, ownerY = GetV (V_POSITION,GetV(V_OWNER,MyID)) -- 主人ID位置
- myX, myY = GetV (V_POSITION,MyID) -- 生命体ID位置
-
- local d = GetDistance (ownerX,ownerY,myX,myY)
- if ( d <= 2) then -- 3捻 桧 剪葬贼
- return
- end
- local motion = GetV (V_MOTION,MyID)
- if (motion == MOTION_MOVE) then -- 生命体为移动中时
- d = GetDistance (ownerX, ownerY, MyDestX, MyDestY)
- if ( d > 2 ) then -- 距离大於2格时
- MoveToOwner (MyID)
- MyDestX = ownerX
- MyDestY = ownerY
- return
- end
- else -- 棻艇 翕蒙
- MoveToOwner (MyID)
- MyDestX = ownerX
- MyDestY = ownerY
- return
- end
-
- end
- -------------------------------------------
- -- 人工生命体自动依类型选择技能设定 AutoSkillSet (myid)
- -------------------------------------------
- function AutoSkillSet (myid)
- local result = 0
- local skilltype
- local type = GetV (V_HOMUNTYPE,myid)
- if (type == LIF or type == LIF_H) then
- skilltype = 8001
- elseif (type == AMISTR or type == AMISTR_H) then
- skilltype = 8005
- elseif (type == FILIR or type == FILIR_H) then
- skilltype = 8009
- elseif (type == VANILMIRTH or type == VANILMIRTH_H) then
- skilltype = 8013
- end
- result = skilltype
- return result
- end
- -------------------------------------------
- -- 取得主人的敌人 GetOwnerEnemy(被攻击时锁定)
- -------------------------------------------
- function GetOwnerEnemy (myid)
- local result = 0
- local owner = GetV (V_OWNER,myid)
- local actors = GetActors ()
- local enemys = {}
- local index = 1
- local target
- for i,v in ipairs(actors) do
- if (v ~= owner and v ~= myid) then
- target = GetV (V_TARGET,v)
- if (target == owner) then
- if (IsMonster(v) == 1) then
- enemys[index] = v
- index = index+1
- else
- local motion = GetV(V_MOTION,i)
- if (motion == MOTION_ATTACK or motion == MOTION_ATTACK2) then
- enemys[index] = v
- index = index+1
- end
- end
- end
- end
- end
- local min_dis = 100
- local dis
- for i,v in ipairs(enemys) do
- dis = GetDistance2 (myid,v)
- if (dis < min_dis) then
- result = v
- min_dis = dis
- end
- end
-
- return result
- end
- --[[
- -------------------------------------------
- -- 攻击型态选择(以生命体类型为条件) GetMyEnemy
- -------------------------------------------
- function GetMyEnemy (myid)
- local result = 0
- local type = GetV (V_HOMUNTYPE,myid)
- if (type == LIF or type == LIF_H or type == AMISTR or type == AMISTR_H) then
- result = GetMyEnemyA (myid)
- elseif (type == FILIR or type == FILIR_H or type == VANILMIRTH or type == VANILMIRTH_H) then
- result = GetMyEnemyB (myid)
- end
- return result
- end
- -------------------------------------------
- -- 非主动攻击型 GetMyEnemyA
- -------------------------------------------
- function GetMyEnemyA (myid)
- local result = 0
- local owner = GetV (V_OWNER,myid)
- local actors = GetActors ()
- local enemys = {}
- local index = 1
- local target
- for i,v in ipairs(actors) do
- if (v ~= owner and v ~= myid) then
- target = GetV (V_TARGET,v)
- if (target == myid) then
- enemys[index] = v
- index = index+1
- end
- end
- end
- local min_dis = 100
- local dis
- for i,v in ipairs(enemys) do
- dis = GetDistance2 (myid,v)
- if (dis < min_dis) then
- result = v
- min_dis = dis
- end
- end
- return result
- end
- --]]
- -------------------------------------------
- -- 主动攻击型 GetMyEnemyB
- -------------------------------------------
- function GetMyEnemy (myid)
- local result = 0
- local owner = GetV (V_OWNER,myid)
- local actors = GetActors ()
- local enemys = {}
- local index = 1
- local type
- for i,v in ipairs(actors) do
- if (v ~= owner and v ~= myid) then
- -- 这里可以插入判断怪物属性的程式
- if (1 == IsMonster(v)) then
- enemys[index] = v
- index = index+1
- end
- end
- end
- local min_dis = 100
- local dis
- for i,v in ipairs(enemys) do
- dis = GetDistance2 (myid,v)
- if (dis < min_dis) then
- result = v
- min_dis = dis
- end
- end
- return result
- end
- --------------------------------------------------------------------
- -- 人工AI主程式
- --------------------------------------------------------------------
- function AI(myid)
- MyID = myid
- local owner = GetV (V_OWNER,MyID)
- local HPp = GetV (V_HP,MyID) / GetV (V_MAXHP,MyID) -- HP%
- local OHPp = GetV (V_HP,owner) / GetV (V_MAXHP,owner) -- OWNER HP%
- local type = GetV (V_HOMUNTYPE,MyID)
- if (type == LIF or type == LIF_H) then
- if (GetV (V_SP,MyID) >= 25) then
- if (OHPp <= 0.25) then
- MySkill = AutoSkillSet (MyID) -- 丽芙(对玩家)
- MySkillLevel = 5 -- 技能等级请自行设定
- SkillObject (MyID,MySkillLevel,MySkill,owner)
- TraceAI ("OnAutoSkill")
- elseif (HPp <= 0.25) then
- MySkill = AutoSkillSet (MyID) -- 丽芙(对自己)
- MySkillLevel = 5 -- 技能等级请自行设定
- SkillObject (MyID,MySkillLevel,MySkill,MyID)
- TraceAI ("OnAutoSkill")
- end
- end
- end
- local msg = GetMsg (myid) -- 立即命令
- local rmsg = GetResMsg (myid) -- 预约的命令
- if msg[1] == NONE_CMD then
- if rmsg[1] ~= NONE_CMD then
- if List.size(ResCmdList) < 15 then
- List.pushright (ResCmdList,rmsg) -- 储存预约命令
- end
- end
- else
- List.clear (ResCmdList) -- 当有立即命令时,清除预约命令清单
- ProcessCommand (msg) -- 执行命令
- end
-
- -- 鼻鹧 籀葬
- if (MyState == IDLE_ST) then
- OnIDLE_ST ()
- elseif (MyState == CHASE_ST) then
- OnCHASE_ST ()
- elseif (MyState == ATTACK_ST) then
- OnATTACK_ST ()
- elseif (MyState == FOLLOW_ST) then
- OnFOLLOW_ST ()
- elseif (MyState == MOVE_CMD_ST) then
- OnMOVE_CMD_ST ()
- elseif (MyState == STOP_CMD_ST) then
- OnSTOP_CMD_ST ()
- elseif (MyState == ATTACK_OBJECT_CMD_ST) then
- OnATTACK_OBJECT_CMD_ST ()
- elseif (MyState == ATTACK_AREA_CMD_ST) then
- OnATTACK_AREA_CMD_ST ()
- elseif (MyState == PATROL_CMD_ST) then
- OnPATROL_CMD_ST ()
- elseif (MyState == HOLD_CMD_ST) then
- OnHOLD_CMD_ST ()
- elseif (MyState == SKILL_OBJECT_CMD_ST) then
- OnSKILL_OBJECT_CMD_ST ()
- elseif (MyState == SKILL_AREA_CMD_ST) then
- OnSKILL_AREA_CMD_ST ()
- elseif (MyState == FOLLOW_CMD_ST) then
- OnFOLLOW_CMD_ST ()
- end
- end
复制代码
--PS:我给转成简体的。这个文件另存为AI.lua
[ 本帖最后由 非注册用户 于 2006-1-7 23:43 编辑 ] |
|