|
发表于 2015-8-10 08:30:18
|
显示全部楼层
本帖最后由 二氧六环 于 2015-8-10 11:28 编辑
试试FHenemiesTable
代码如下:
- for i=1,#FHenemiesTable do
- local para = FHenemiesTable[i].unit;
- local spell = "月火术";
- if UnitCanAttack("player",para)
- and UnitTarget("player")~= para
- and FHObjectDistance("player",thisUnit) <= 30
- and UnitHealth(para) / UnitHealthMax(para)>0.2
- and amaura(spell, para,0,2)<60
- then
- --print(UnitName(units[i],i));
- amrun(spell, para)
- end
- end
复制代码 注意,需要设置下施法范围,超过30码不做处理。但是FHenemiesTable 只判定在战斗中的目标,但是依然有卡顿想象,测试后发现数据量惊人。
有原材料,那么我们就自己定义一个表,直接使用。
如:
代码如下:
- local count = ObjectCount()
- for i = 1, count do
- local obj = ObjectWithIndex(i)
- if ObjectIsType(obj, ObjectTypes.Unit)
- and ObjectExists(obj)
- and UnitHealth(obj) > 1
- and (UnitCanAttack(obj,"player") or UnitCanAttack("player", obj))
- then
- local dis = 30;
- local x1,y1,z1 = ObjectPosition(obj)
- local x2,y2,z2 = ObjectPosition("player")
- local mathDIS = math.sqrt(((x2-x1)^2)+((y2-y1)^2)+((z2-z1)^2))
- if mathDIS<dis
- and amaura("月火术", obj,0,2)<60
- and UnitHealth(obj) / UnitHealthMax(obj)>0.2
- then
- amrun("月火术", obj)
- end
- end
- end
复制代码 经测试,在影月谷[60.36] A大象,最多18只,不卡顿。
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?加入我们
x
评分
-
查看全部评分
|