Originally Posted by
choweyiii
How about if I want a visible, un-attackable, but can attack unit? Like Flame Orb behaves. I really appreciate the help, stoneharry.
Not sure if there is a specific flag for that (I don't think there is).
However, if you're scripting that creature (as you should be for that sort of unit) then you can tell it to attack the player even though it has flags 2 applied.
If that doesn't work, directly casting spells that deal damage or using the Strike(args) method works.
For my 'beams of light' which people must avoid, I used a displayid for effects and made it have untargetable flags, but set to faction 35 so that it won't engage in combat. When the player draws within 7 yards of it, I use Strike to deal damage and then knock them back with a spell I have the player cast on himself. It works.
Spawn creature, set untargetable:
Code:
local plr = pUnit:GetRandomPlayer(0)
if plr ~= nil then
INS[id].VAR.BeamA = pUnit:SpawnCreature(203123, plr:GetX(), plr:GetY(), plr:GetZ(), 0, 35, 0)
end
plr = pUnit:GetRandomPlayer(0)
if plr ~= nil then
INS[id].VAR.BeamB = pUnit:SpawnCreature(203123, plr:GetX(), plr:GetY(), plr:GetZ(), 0, 35, 0)
end
INS[id].VAR.BeamA:SetUnitToFollow(INS[id].VAR.BeamA:GetClosestPlayer(), 0.2, 1)
INS[id].VAR.BeamB:SetUnitToFollow(INS[id].VAR.BeamB:GetClosestPlayer(), 0.2, 1)
INS[id].VAR.BeamA:SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)
INS[id].VAR.BeamB:SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)
Strike when near:
Code:
local plr = INS[id].VAR.BeamA:GetClosestPlayer()
if plr ~= nil then
if plr:GetDistanceYards(INS[id].VAR.BeamA) < 7 then
plr:CastSpell(43418) -- impact
INS[id].VAR.BeamA:Strike(plr, 0, 38043, 520, 530, 2) -- strike plr, display spell 38043 in combat log, deal 520-530 damage, deal x2 damage on critical strike.
end
end