Hey guys, I'm still pretty new to LUA scripting and some things in my server. However I would like to say I know a couple things from practice. I'm currently working on a project for my tech class and I'm scripting a dungeon that the class can play through. So far it's going well but I do have a couple questions with things that I've seen online, but don't work how they should. If you can only answer 1, or don't feel like answering them all, any help would be appreciated! **EDIT** I am using a 2.4.3 Repack, as well as ArcEmu Core
1. The only targeting function I can get to work for bosses is Unit:GetMainTank(). I would like to randomly target players, but things such as Unit:GetRandomPlayer() give me an error of " calling 'GetRandomPlayer' on bad self (number expected, got no value).
2. I have a boss spawn a mob that will heal the boss, which works fine by using the command Unit:GetUnitBySqlID( X ). However this is very tedious as I have to re-enter the SQL entry every time I delete or edit my mob. I would also like her to cast heals on all mobs friendly to her. I tried Unit:GetClosestFriend but that failed as well.
3. I would like my boss to be interacting with the environment while he isn't in combat. Such as moving around and saying different things. However when I make the function Bossname_OnSpawn and register it as RegisterUnitEvent(70011, 6, "Bossname_OnSpawn") it doesn't do anything. I thought 6 was the value for OnSpawn?
4. I've partially learned how to edit a mob's items through playing around with HeidiSQL. But its very tedious that way, is there any easier way I can edit what weapons/armor a boss wears?
5. My mobs that do have items equipped, unsheathe them and attack, then sheathe them again, then unsheathe to attack, etc. It looks pretty weird and was wondering if there was a fix to it.
I know I'm asking a lot of questions, but I really want to improve on my scripting abilities and expand my knowledge of the subject. So far I've figured everything out without any help, but these are the things I can't find on my own. Please be gentle
Here is my script for my final boss (Subject to change as I am only halfway done with it):
If you could find any errors I might have it would be very helpful! Thanks again in advance!
local Name = "Mr. T"
local NPCID = 70011
function T_OnCombat(pUnit, event, player)
pUnit:RegisterEvent("T", 1000, 1)
pUnit:SendChatMessage(14, 1, "IM DONE POOPIN!")
pUnit:RegisterEvent("T_Fireball",5000,0)
end
function T_OnSpawn(Unit, Event)
Unit:SendChatMessage(14, 0, "ON SPAWN")
end
function T(unit, event, miscunit, misc)
print "T"
unit:RegisterEvent("T_90", 1000, 1)
end
function T_Fireball(Unit, event, miscunit, misc)
print "T Fireball"
Unit:StopMovement(2000)
Unit:FullCastSpellOnTarget(40598, Unit:GetRandomPlayer(0))
end
function T_SpawnTechs(Unit, Event) -- Spawns Random Tech Kids
local faction = 1813
Choice=math.random(1,3)
x = Unit:GetX();
y = Unit:GetY();
z = Unit:GetZ();
o = Unit:GetO();
if Choice == 1 then
Unit:SpawnCreature(70015, x+10, y, z, o, faction, 3000000)
Unit:SendChatMessage(12, 0, "Even the laziest of students can prove useful! Get them BRAM.")
end
if Choice == 2 then
Unit:SpawnCreature(70014, x+10, y, z, o, faction, 3000000)
Unit:SendChatMessage(14, 0, "Come to my aid Linnea!")
end
if Choice == 3 then
Unit:SpawnCreature(70013, x+10, y, z, o, faction, 3000000)
Unit:SendChatMessage(14, 0, "ISS Jordan, if you fail to kill these fools!")
end
end
function T_Soul_Flay(Unit, event, miscunit, misc)
print "T Soul Flay"
Unit:StopMovement(2000)
Unit:FullCastSpellOnTarget(45342,Unit:GetMainTank())
end
function T_90(pUnit, Event) -- Starting of T's Phases
if pUnit:GetHealthPct() <= 90 then
pUnit:RemoveEvents()
pUnit:RegisterEvent("T_Fireball",5000,0)
pUnit:RegisterEvent("T_70", 1000, 1)
else
pUnit:RegisterEvent("T_90", 1000, 1)
end
end
function T_70(pUnit, Event)
if pUnit:GetHealthPct() <= 70 then
pUnit:RemoveEvents()
pUnit:RegisterEvent("T_SpawnTechs", 30000, 0)
pUnit:SendChatMessage(14, 1, "Hahaha! Tech 3, Show these fools who are the TRUE Seniors")
pUnit:RegisterEvent("T_SpawnTechs", 1000, 1)
pUnit:RegisterEvent("T_30", 1000, 1)
else
pUnit:RegisterEvent("T_70", 1000, 1)
end
end -- End of T's Phases
function T_30(pUnit, Event)
if pUnit:GetHealthPct() <= 30 then
pUnit:RemoveEvents()
pUnit:FullCastSpell(45342)
pUnit:RegisterEvent("T_Soul_Flay",15000,0)
pUnit:SetScale(.35)
pUnit:SetModel(23200)
pUnit:SendChatMessage(14, 1, "ANOTHER ISS FOR JORDAN!")
else
pUnit:RegisterEvent("T_30", 1000, 1)
end
end
function T_OnKilledTarget(pUnit, event, player)
pUnit:SendChatMessage(14, 1, "MORE! I NEED MORE!")
pUnit:FullCastSpellOnTarget(45866, pUnit:GetMainTank())
end
function T_OnLeaveCombat(pUnit, event, player)
pUnit:RemoveEvents()
pUnit:SendChatMessage(14, 0, "What a JOKE!")
end
function T_OnDeath(pUnit, event, player)
pUnit:RemoveEvents()
pUnit:SendChatMessage(14, 0, "Chaos....and Cookies...")
end
RegisterUnitEvent(70011, 1, "T_OnCombat")
RegisterUnitEvent(70011, 2, "T_OnLeaveCombat")
RegisterUnitEvent(70011, 3, "T_OnKilledTarget")
RegisterUnitEvent(70011, 4, "T_OnDeath")
RegisterUnitEvent(70011, 6, "T_OnSpawn") -- End of T$'s Actual Script
function L_OnSpawn(Unit, Event)
Unit:RegisterEvent("L_Healing", 2500, 0)
Unit:StopMovement(400000)
end
function L_Healing(Unit, Event)
Unit:FullCastSpellOnTarget(29564, Unit:GetUnitBySqlId(200002265)
end
RegisterUnitEvent(70014, 1, "L_OnSpawn") -- Linnea's Code, I want her to purely heal, not do damage
function B_OnSpawn(Unit, Event)
Unit:RegisterEvent("B_Seal", 30000, 0)
end
function B_Seal(Unit, Event)
Unit:CastSpell(41459)
end
RegisterUnitEvent(70015, 1, "B_OnSpawn") -- Bram's Code
function J_OnSpawn(Unit, Event)
Unit:CastSpellOnTarget(46459, Unit:GetPrimaryCombatTarget())
end
function J_OnDeath(Unit, Event)
Unit:SendChatMessage(12, 0, "All I wanted.... was.. Laynes..")
end
RegisterUnitEvent(70013, 1, "J_OnSpawn") -- Jordan's Code
RegisterUnitEvent(70013, 4, "J_OnDeath")