|
发表于 2015-3-9 09:00:41
|
显示全部楼层
本帖最后由 暗影流沙 于 2015-3-9 09:17 编辑
追悼大大已经回复得很清楚了。
因为我也有个法师,关于幻灵水晶消失后目标获取的写法
最简单的是,如果当前没目标,则选取最近敌人为目标
if not UnitExists("playertarget") then
TargetNearestEnemy()
end
但这样会容易ADD,卡视角
下面是比较复杂一点的写法,当你再团队中时可以使用
- local GetGroupHeaderType= function ()--获得所在队伍的属性
- local kind, start, stop;
-
- local nRaid = GetNumGroupMembers();
- local nParty = GetNumSubgroupMembers();
- if ( IsInRaid() ) then
- kind = "RAID";
- elseif ( IsInGroup()) then
- kind = "PARTY";
- else
- kind = "SOLO";
- end
- if ( kind ) then
- if ( kind == "RAID" ) then
- start = 1;
- stop = nRaid;
- else
- if ( kind == "SOLO" ) then
- start = 0;
- else
- start = 1;
- end
- stop = nParty;
- end
- end
- return kind, start, stop;
- end
- local GetGroupRosterInfo=function(kind, index)--队伍角色
- local _, unit, name, subgroup, className, role, server, assignedRole;
- if ( kind == "RAID" ) then
- unit = "raid"..index;
- name, _, subgroup, _, _, className, _, _, _, role, _, assignedRole = GetRaidRosterInfo(index);
- else
- if ( index > 0 ) then
- unit = "party"..index;
- else
- unit = "player";
- end
- if ( UnitExists(unit) ) then
- name, server = UnitName(unit);
- if (server and server ~= "") then
- name = name.."-"..server
- end
- _, className = UnitClass(unit);
- if ( GetPartyAssignment("MAINTANK", unit) ) then
- role = "MAINTANK";
- elseif ( GetPartyAssignment("MAINASSIST", unit) ) then
- role = "MAINASSIST";
- end
- assignedRole = UnitGroupRolesAssigned(unit)
- end
- subgroup = 1;
- end
- return unit, name, subgroup, className, role, assignedRole;
- end
- local tankInfo=function()--找到队伍中T的信息
- local kind, start, stop=GetGroupHeaderType()
- if stop then
- for i=1,stop do
- if select(6,GetGroupRosterInfo(kind, i))=="TANK" then
- return GetGroupRosterInfo(kind, i)
- end
- end
- end
- return false
- end
- local Tunit=tankInfo()--T的信息
- local Tunittarget=Tunit.."target"--以T当前的目标做为目标
- if not UnitExists("playertarget") and UnitExists(Tunittarget) and UnitCanAttack("player",Tunittarget) and msII(Tunittarget)
- then
- TargetUnit(Tunittarget)
- end
复制代码 如实装需完善其他判断信息
|
|