Jump to content
  • 0

lua script majordomo


kasykiller

Question

local npcid = 12098

local Sulfuron = {}

function Sulfuron.OnDeath(event, creature, killer)
creature:SpawnCreature(12018, 758.645, -1177.60, -118.746, 2.97476)
creature:SpawnCreature(11663, 737.945, -1156.48, -118.945, 4.46804)
creature:SpawnCreature(11663, 752.520, -1191.02, -118.218, 2.49582)
creature:SpawnCreature(11663, 752.953, -1163.94, -118.869, 3.70010)
creature:SpawnCreature(11663, 738.814, -1197.40, -118.018, 1.83260)
creature:SpawnCreature(11664, 746.939, -1194.87, -118.016, 2.21657)
creature:SpawnCreature(11664, 747.132, -1158.87, -118.897, 4.03171)
creature:SpawnCreature(11664, 757.116, -1170.12, -118.793, 3.40339)
creature:SpawnCreature(11664, 755.910, -1184.46, -118.449, 2.80998)
end
RegisterCreatureEvent(12098, 1, Sulfuron.OnDeath)

math.randomseed(os.time());

function Majordomo_OnCombat(creature,event, pMisc)
setvars(creature,{Majordomo = creature, Majordomo_Guards = {},DeadGuardCount = 0})
local door = creature:GetGameObjectNearestCoords(735.972412,-1177.861572,-119.109833,177000)
if (door ~= nil) then
	door:SetUInt32Value(GAMEOBJECT_STATE, 0)
	door:SetUInt32Value(GAMEOBJECT_FLAGS,33)
end
local tbl = creature:GetInRangeFriends()
local args = getvars(creature)
for k,v in pairs(tbl) do
	if (v:GetEntry() == 11663) or (v:GetEntry() == 11664) then
		table.insert(args.Majordomo_Guards,v)
		v:AttackReaction(pMisc,1,0)
	end
end
creature:RegisterEvent("Majordomo_AoR", 30000, 1)
creature:RegisterEvent("Majordomo_Teleport", 15000, 1)
creature:RegisterEvent("Majordomo_BlastWave", 10000, 1)
creature:RegisterEvent("Majordomo_Shields", 15000, 1)
creature:RegsiterEvent("Majordomo_SubmitCheck", 5000, 1)
end

function Majordomo_SubmitCheck(creature,event)
local args = getvars(creature)
local plr = creature:GetRandomPlayer(0)
if (args.DeadGuardCount == 9) then
	creature:SendChatMessage(16,0,"Majordomo Executus submits")
	creature:SetFaction(plr:GetFaction())
	creature:Root()
	creature:SetCombatCapable(1)
	creature:WipeThreatList()
	creature:SpawnGameObject(179703,creature:GetX(),creature:GetY(),creature:GetZ(),creature:GetO(),18000)
	creature:Despawn(10000, 0)
else
	creature:RegisterEvent("Majordomo_SubmitCheck", 5000, 1)
end
end

function Majordomo_OnWipe(creature)
creature:RemoveEvents()
end

function Majordomo_OnDied(creature)
creature:RemoveEvents()
end

function Majordomo_AoR(creature,event)
creature:FullCastSpell(20620)
creature:RegisterEvent("Majordomo_AoR",30000, 1)
end

function  Majordomo_Teleport(creature,event)
local plr  = creature:GetRandomPlayer(0)
if (plr ~= nil) and (plr:IsAlive() == true) then
	creature:FullCastSpellOnTarget(20534,plr)-- teleport visual
	plr:Teleport(creature:GetMapId(),735.972412,-1177.861572,-119.109833)
end
creature:RegisterEvent("Majordomo_Teleport",15000, 1)
end

function Majordomo_BlastWave(creature,event)
if (creature:GetInRangePlayersCount() ~= nil) then
	creature:FullCastSpell(20229)-- Blast Wave.
end
creature:RegisterEvent("Majordomo_BlastWave", 10000, 1)
end

function Majordomo_Shields(creature,event)
local args = getvars(creature)
if (math.random(0,1) > 0.5) then
	for k,v in pairs(args.Majordomo_Guards) do
		creature:FullCastSpellOnTarget(20619, v)-- Magic Reflection.
	end
else
	for k,v in pairs(args.Majordomo_Guards)  do
		v:FullCastSpellOnTarget(21075, v)--Damage Shield
	end
end
creature:RegisterEvent("Majordomo_Shields", 16000, 1)
end
function Majordomo_EnterCombat(event, creature, target)
creature:RegisterEvent(12018, 1,"Majordomo_OnCombat")
creature:RegisterEvent(12018, 2,"Majordomo_OnWipe")
creature:RegisterEvent(12018, 4,"Majordomo_OnDied")
creature:RegisterEvent(12018, 21,"Majordomo_SubmitCheck")
end

--[[
Majordomo ADDS AI
]]
function FlameHealer_OnCombat(creature,event)
local tbl = creature:GetInRangeFriends()
for k,v in pairs(tbl) do
	if (v:GetEntry() == 12018) then
		creature:RegisterEvent("FlameHealer_ShadowBolt", math.random(7000, 8000), 1)
		creature:RegisterEvent("FlameHealer_GreaterHeal", math.random(10000, 12000), 1)
		break
	end
end
end

function FlameHealer_OnWipe(creature,event)
creature:RemoveEvents()
end

function FlameHealer_OnDied(creature,event)
local changed = false;
creature:RemoveEvents()
local args = getvars(creature) -- moved here, don't need to refresh it every loop as the changes will only apply to 'args', not the gloabls, until you write args back to the globals.
local tbl = creature:GetInRangeFriends()
for k,v in pairs(tbl) do
	if (v:GetEntry() == 12018) then
	for k,v in pairs(args.Majordomo_Guards) do
			if (v == creature) then
				table.remove(args.Majordomo_Guards, k)
				changed = true;
			end
		end
	end
end
-- if nothing was changed in the args class then don't write anything back (makes for less work, and a 'bit' of a speed boost)
if (changed == true) then 
	setvars(creature,args); 
end
end
function FlameHealer_ShadowBolt(creature,event)
local plr = creature:GetRandomPlayer(0)
if (plr ~= nil) and (plr:IsAlive() == true) then
	creature:StopMovement(500)
	creature:FullCastSpellOnTarget(21077, plr)-- Shadow Bolt
end
creature:RegisterEvent("FlameHealer_ShadowBolt",  math.random(7000, 8000), 1)
end
function FlameHealer_GreaterHeal(creature,event)
local args = getvars(creature)
if (args.Majordomo_Guards ~= nil) then
	local tblend = table.getn(args.Majordomo_Guards)
	creature:StopMovement(2500)
	creature:FullCastSpellOnTarget(29564, args.Majordomo_Guards[math.random(1, tblend)])
end
creature:RegisterEvent("FlameHealer_GreaterHeal", math.random(10000, 12000), 1)
end
function FLamehealer_EnterCombat(event, creature, target)
creature:RegisterEvent(11663, 1, "FlameHealer_OnCombat")
creature:RegisterEvent(11663, 2, "FlameHealer_OnWipe")
creature:RegisterEvent(11663, 4, "FlameHealer_OnDied")
end

function FlameElite_OnCombat(creature,event)
local tbl = creature:GetInRangeFriends()
for k,v in pairs(tbl) do
	if (v:GetEntry() == 12018) then
		creature:RegisterEvent("MajordomoFlameElite_Spells", 10000, 0)
		break
	end
end
end

function FlameElite_OnWipe(creature,event)
creature:RemoveEvents()
end

function FlameElite_OnDead(creature,event)
local changed = false;
creature:RemoveEvents()
local args = getvars(creature)
local tbl = creature:GetInRangeFriends()
for k,v in pairs(tbl) do
	if (v:GetEntry() == 12018) then
		for k,v in pairs(args.Majordomo_Guards) do
			if (v == creature) then
				table.remove(args.Majordomo_Guards,k)
				changed = true;
			end
		end
	end
end
if (changed == true) then 
	setvars(creature,args); 
end
end

function MajordomoFlameElite_Spells(creature,event)
local plr = creature:GetRandomPlayer(0)
if (plr ~= nil) and (plr:IsAlive() == true) then
	if (math.random(0,1) > 0.5) then
		creature:FullCastSpellOnTarget(20623, plr)-- FIRE BLAST
	else
		creature:FullCastSpell(20229) -- Blast Wave
	end
end
end
function FlameElite_EnterCombat(event, creature, target)
creature:RegisterEvent(11664,1,"FlameElite_OnCombat")
creature:RegisterEvent(11664,2,"FlameElite_OnWipe")
creature:RegisterEvent(11664,4,"FlameElite_OnDead")
end

I made the sript to majordomo , but I have a problem, you think you can be. when I kill the adds , majordomo still sticking flag and does not change . as you see the code ?

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use