Ok I dont really know where to put this so here goes
TEXT
Ok lets say that first we want an NPC/Boss whatever to say something when he enters combat
Code:
function Phase_2.4(pUnit, Event)
^
||
||
||
First to define the event "Phase_2.4" was something out of one of my boss scripts but you can change it to whatever you like "Chat_OnCombat" for example.
now
Code:
pUnit:SendChatMessage(11, 0, "Come Forth My Flames!")
^
||
||
||
Make this your next Line so that
Code:
function Phase_2.4(pUnit, Event)
pUnit:SendChatMessage(11, 0, "Come Forth My Flames!")
Now the 11 in that says that it is to be yelled by the NPC just as you would /yell and the 0 is Universal language in otherwords all races can understand.
To finish it off we will register the event in the script, or END it
Code:
function Phase_2.4(pUnit, Event)
pUnit:SendChatMessage(11, 0, "Come Forth My Flames!")
pUnit:RegisterEvent("Phase_2.4",123456, 1)
To disect this part
pUnit = the MOB the variable we defined at the beggining
RegisterEvent = It registers the script or the part of the script
"Phase_2.4" = what we defined and I described at the beggining
123456 = The ID of the boss this script is for replace it with the ID of the mob you are scripting
1 = Tells it to say this when it enters combat
SPELLS
Alright for spellcasting it would be the same as the earlier script so ill copy it.
Code:
function Phase_2.4(pUnit, Event)
pUnit:SendChatMessage(11, 0, "Come Forth My Flames!")
pUnit:RegisterEvent("Phase_2.4",123456, 1)
but this time we would add
Code:
pUnit:FullCastSpell(SPELL ID HERE)
OR
Code:
pUnit:CastSpell(SPELL ID HERE)
The difference between FullCastSpell and CastSpell is that CastSpell should only be used for instant casts, and FullCastSpell is used for spells with Cast Times.
the new code would look like this
Code:
function Phase_2.4(pUnit, Event)
pUnit:SendChatMessage(11, 0, "Come Forth My Flames!")
pUnit:CastSpell(SPELL ID HERE)
pUnit:RegisterEvent("Phase_2.4",123456, 1)
Now he will cast a spell of your choosing as well as saying something.
SUMMONING AND PERCENTS
For summoning we would use a different VAR altogether so that
Code:
function KyronesSpawn_80PCT(pUnit)
if pUnit:GetHealthPct() < 80 then
RemoveEvents();
x=pUnit:GetX();
y=pUnit:GetY();
z=pUnit:GetZ();
pUnit:SpawnCreature(CREATURE ID HERE, x, y, z, 0, 14, 3600000000000);
end
end
RegisterUnitEvent(21966, 0, "KyronesSpawn_80PCT")
to disect this code
GetHealthPct() = Is saying that if the Mob's health percentage is at 80 run this script.
x=pUnit:Getx(); = This is saying that the Mob's X coord is the X coord for the creature to spawn
y=pUnit:GetY(); = This is saying that the Mob's Y coord is the Y coord for the creature to spawn
z=pUnit:GetZ(); = This is saying that the Mob's Z coord is the Z coord for the creature to spawn
SpawnCreature = Is obvious it spawns the creature with that ID at the XYZ's that we already defined
360000 = The respawn time for the respawned NPC but this ussually doesnt matter because you would be long gone by then.
end2 - ends the whole function the first end tells it to do all that between If and End and the second one ends the function