AI.lua | 14,066 字节 | 2005-12-22 | 11:22 | LUA 文件 |
Const.lua | 2,447 字节 | 2005-12-22 | 11:22 | LUA 文件 |
Util.lua | 2,663 字节 | 2005-12-22 | 11:22 | LUA 文件 |
AI.lua | 14,066 字节 | 2005-9-27 | 9:15 | LUA 文件 |
AI_M.lua | 13,803 字节 | 2008-1-17 | 19:47 | LUA 文件 |
Const.lua | 3,111 字节 | 2008-1-17 | 19:47 | LUA 文件 |
Util.lua | 2,663 字节 | 2005-6-28 | 9:41 | LUA 文件 |
弓箭手佣兵 | 等级 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
代码 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | |
编码 | ARCHER01 | ARCHER02 | ARCHER03 | ARCHER04 | ARCHER05 | ARCHER06 | ARCHER07 | ARCHER08 | ARCHER09 | ARCHER10 | |
枪兵佣兵 | 等级 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
代码 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | |
编码 | LANCER01 | LANCER02 | LANCER03 | LANCER04 | LANCER05 | LANCER06 | LANCER07 | LANCER08 | LANCER09 | LANCER10 | |
剑士佣兵 | 等级 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
代码 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | |
编码 | SWORDMAN01 | SWORDMAN02 | SWORDMAN03 | SWORDMAN04 | SWORDMAN05 | SWORDMAN06 | SWORDMAN07 | SWORDMAN08 | SWORDMAN09 | SWORDMAN10 |
function GetMyEnemy (myid)
local result = 0
local type = GetV (V_MERTYPE,myid)
if (type >= ARCHER01 and type <= SWORDMAN10) then
result = GetMyEnemyA (myid)
else
result = GetMyEnemyB (myid)
end
return result
end
-------------------------------------------
-- 厚急傍屈 GetMyEnemy
-------------------------------------------
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
-------------------------------------------
-- 急傍屈 GetMyEnemy
-------------------------------------------
function GetMyEnemyB (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
原帖由 natineprince 于 2008-1-18 09:03 发表
dis = GetDistance2 (myid,v)
if (dis < min_dis) then
result = v
min_dis = dis
end
老狗试下把这段改成min_dis=0
看看会不会原地攻击
function OnATTACK_ST ()
TraceAI ("OnATTACK_ST")
//敌人不在视线内
if (true == IsOutOfSight(MyID,MyEnemy)) then -- ENEMY_OUTSIGHT_IN
MyState = IDLE_ST
TraceAI ("ATTACK_ST -> IDLE_ST")
return
end
//敌人已死亡
if (MOTION_DEAD == GetV(V_MOTION,MyEnemy)) then -- ENEMY_DEAD_IN
MyState = IDLE_ST
TraceAI ("ATTACK_ST -> IDLE_ST")
return
end
//在攻击范围外.状态变为 追
if (false == IsInAttackSight(MyID,MyEnemy)) then -- ENEMY_OUTATTACKSIGHT_IN
MyState = CHASE_ST
//移动片段.远程攻击关键?
MyDestX, MyDestY = GetV (V_POSITION,MyEnemy);
Move (MyID,MyDestX,MyDestY)
//移动片段END
TraceAI ("ATTACK_ST -> CHASE_ST : ENEMY_OUTATTACKSIGHT_IN")
return
end
//没使用技能,则普攻
if (MySkill == 0) then
Attack (MyID,MyEnemy)
else
//使用技能,则...SkillObject函数没看...
if (1 == SkillObject(MyID,MySkillLevel,MySkill,MyEnemy)) then
MyEnemy = 0
end
MySkill = 0
end
TraceAI ("ATTACK_ST -> ATTACK_ST : ENERGY_RECHARGED_IN")
return
end
原帖由 natineprince 于 2008-1-18 09:50 发表
function GetMyEnemyA (myid)
local result = 0//返回值,敌人
local owner = GetV (V_OWNER,myid)//主人
local actors = GetActors ()//角色
local enemys = {}//敌人集
local index = 1
local target
...
原帖由 蜡烛鞭二郎 于 2008-1-18 10:14 发表
function OnATTACK_ST ()下的
IsOutOfSight()函数应该就是锁敌距离判定了。
IsOutOfSight()的function在Util.lua下
原帖由 蜡烛鞭二郎 于 2008-1-18 10:21 发表
那看来要写弓箭手的ai,第一要增加一个GetMyEnemy来增加锁敌方式
还要增加一个IsInAttackSight来增加一个15格的攻击距离判定
因为默认的IsInAttackSight是怪物进入GetDistance的初始值就攻击的,也就是2格,不 ...
生命体AI免调整11-3老狗移植版.rar
原帖由 南都夜夜 于 2008-1-18 09:14 发表
A10:59:18
fuland是福州?
B10:59:26
…没啊…
B11:00:10
福州你个头
A 11:00:14
= =
A 11:00:17
那是啥
B11:00:21
…我没在山区打野战的爱好
IsOutOfSight
欢迎光临 浆糊论坛-RO小站 (http://bbs.rohome.cn/) | Powered by Discuz! 7.2 |