
- UID
- 305430
- 帖子
- 32478
- 精华
- 0
- 威望
- 43
- 阅读权限
- 100
- 来自
- CRO复活区
- 注册时间
- 2005-8-6
|
-------------------------------------------
-- 攻击型态选择(以生命体类型为条件) 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 = GetMyEnemyA (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
进游戏以后 打/hoai
PS:红字部分 我是准备所有生命体 都是被动的
这样做对不对 请高手赐教
[ 本帖最后由 WAKATA 于 2006-1-10 22:28 编辑 ] |
|