PDA

View Full Version : [release]{lua} capture the town



runiker
12-02-09, 03:16 AM
Here is my lua script it might look like a boss script at first look but its not this script was made by me when i wanted to make a new type of an event this event is called capture the town. In this event a group of players must go to the opposing factions town and get all there npc below 10% health after they do this they npc will then turn there faction (horde = 2 ally = 1). I myself use this on things i would put inside a city like vendors bankers stable masters quest givers and much more that npc can be. This is a great end game pvp event and im releasing my first script for it (the one i use now is more advanced and contains bosses) hope this will help out your server. (its up to you to make the npc but dont forget to make the npc respawn timer set to 0)





function Gruntworker_die1 (pUnit, event)
pUnit:RemoveEvents()
local race=player:GetPlayerRace()
if race==1 or race==3 or race==4 or race==7 or race==11 then
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760001,x,y,z,1,0)
pUnit:SendChatMessage(14, 0, "The Ally have taken a unit!")
else
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760000,x,y,z,2,0)
pUnit:SendChatMessage(14, 0, "The Horde have taken a unit!")
end
pUnit:RemoveEvents()
end

function Gruntworker_die2 (pUnit, event)
pUnit:RemoveEvents()
local race=player:GetPlayerRace()
if race==1 or race==3 or race==4 or race==7 or race==11 then
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760003,x,y,z,1,0)
pUnit:SendChatMessage(14, 0, "The Ally have taken a unit!")
else
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760002,x,y,z,2,0)
pUnit:SendChatMessage(14, 0, "The Horde have taken a unit!")
end
pUnit:RemoveEvents()
end

function Gruntworker_die3 (pUnit, event)
pUnit:RemoveEvents()
local race=player:GetPlayerRace()
if race==1 or race==3 or race==4 or race==7 or race==11 then
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760005,x,y,z,1,0)
pUnit:SendChatMessage(14, 0, "The Ally have taken a unit!")
else
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760004,x,y,z,2,0)
pUnit:SendChatMessage(14, 0, "The Horde have taken a unit!")
end
pUnit:RemoveEvents()
end

function Gruntworker_die4 (pUnit, event)
pUnit:RemoveEvents()
local race=player:GetPlayerRace()
if race==1 or race==3 or race==4 or race==7 or race==11 then
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760007,x,y,z,1,0)
pUnit:SendChatMessage(14, 0, "The Ally have taken a unit!")
else
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760006,x,y,z,2,0)
pUnit:SendChatMessage(14, 0, "The Horde have taken a unit!")
end
pUnit:RemoveEvents()
end

function Gruntworker_die5 (pUnit, event)
pUnit:RemoveEvents()
local race=player:GetPlayerRace()
if race==1 or race==3 or race==4 or race==7 or race==11 then
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760009,x,y,z,1,0)
pUnit:SendChatMessage(14, 0, "The Ally have taken a unit!")
else
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760008,x,y,z,2,0)
pUnit:SendChatMessage(14, 0, "The Horde have taken a unit!")
end
pUnit:RemoveEvents()
end

function Gruntworker_die6 (pUnit, event)
pUnit:RemoveEvents()
local race=player:GetPlayerRace()
if race==1 or race==3 or race==4 or race==7 or race==11 then
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760011,x,y,z,1,0)
pUnit:SendChatMessage(14, 0, "The Ally have taken a unit!")
else
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760010,x,y,z,2,0)
pUnit:SendChatMessage(14, 0, "The Horde have taken a unit!")
end
pUnit:RemoveEvents()
end

function Gruntworker_die7 (pUnit, event)
pUnit:RemoveEvents()
local race=player:GetPlayerRace()
if race==1 or race==3 or race==4 or race==7 or race==11 then
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760013,x,y,z,1,0)
pUnit:SendChatMessage(14, 0, "The Ally have taken a unit!")
else
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760012,x,y,z,2,0)
pUnit:SendChatMessage(14, 0, "The Horde have taken a unit!")
end
pUnit:RemoveEvents()
end

function Gruntworker_die8 (pUnit, event)
pUnit:RemoveEvents()
local race=player:GetPlayerRace()
if race==1 or race==3 or race==4 or race==7 or race==11 then
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760015,x,y,z,1,0)
pUnit:SendChatMessage(14, 0, "The Ally have taken a unit!")
else
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760014,x,y,z,2,0)
pUnit:SendChatMessage(14, 0, "The Horde have taken a unit!")
end
pUnit:RemoveEvents()
end

function Gruntworker_die9 (pUnit, event)
pUnit:RemoveEvents()
local race=player:GetPlayerRace()
if race==1 or race==3 or race==4 or race==7 or race==11 then
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760017,x,y,z,1,0)
pUnit:SendChatMessage(14, 0, "The Ally have taken a unit!")
else
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760016,x,y,z,2,0)
pUnit:SendChatMessage(14, 0, "The Horde have taken a unit!")
end
pUnit:RemoveEvents()
end

function Gruntworker_die10 (pUnit, event)
pUnit:RemoveEvents()
local race=player:GetPlayerRace()
if race==1 or race==3 or race==4 or race==7 or race==11 then
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760019,x,y,z,1,0)
pUnit:SendChatMessage(14, 0, "The Ally have taken a unit!")
else
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760018,x,y,z,2,0)
pUnit:SendChatMessage(14, 0, "The Horde have taken a unit!")
end
pUnit:RemoveEvents()
end

function Gruntworker_die11 (pUnit, event)
pUnit:RemoveEvents()
local race=player:GetPlayerRace()
if race==1 or race==3 or race==4 or race==7 or race==11 then
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760021,x,y,z,1,0)
pUnit:SendChatMessage(14, 0, "The Ally have taken a unit!")
else
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760020,x,y,z,2,0)
pUnit:SendChatMessage(14, 0, "The Horde have taken a unit!")
end
pUnit:RemoveEvents()
end

function Gruntworker_die12 (pUnit, event)
pUnit:RemoveEvents()
local race=player:GetPlayerRace()
if race==1 or race==3 or race==4 or race==7 or race==11 then
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760023,x,y,z,1,0)
pUnit:SendChatMessage(14, 0, "The Ally have taken a unit!")
else
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760022,x,y,z,2,0)
pUnit:SendChatMessage(14, 0, "The Horde have taken a unit!")
end
pUnit:RemoveEvents()
end

function Gruntworker_die13 (pUnit, event)
pUnit:RemoveEvents()
local race=player:GetPlayerRace()
if race==1 or race==3 or race==4 or race==7 or race==11 then
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760025,x,y,z,1,0)
pUnit:SendChatMessage(14, 0, "The Ally have taken a unit!")
else
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760024,x,y,z,2,0)
pUnit:SendChatMessage(14, 0, "The Horde have taken a unit!")
end
pUnit:RemoveEvents()
end

function Gruntworker_die14 (pUnit, event)
pUnit:RemoveEvents()
local race=player:GetPlayerRace()
if race==1 or race==3 or race==4 or race==7 or race==11 then
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760027,x,y,z,1,0)
pUnit:SendChatMessage(14, 0, "The Ally have taken a unit!")
else
pUnit:RegisterEvent("getcords", 15000, 0)
pUnit:SpawnCreature(7760026,x,y,z,2,0)
pUnit:SendChatMessage(14, 0, "The Horde have taken a unit!")
end
pUnit:RemoveEvents()
end

function Gruntworker_LeaveCombat (pUnit, event)
pUnit:RemoveEvents()
end

function getcords (pUnit, event)
x = pUnit:GetSpawnX();
y = pUnit:GetSpawnY();
z = pUnit:GetSpawnZ();
o = pUnit:GetSpawnO();
end

--Hordeids
RegisterUnitEvent(7760000, 4, "Gruntworker_die1")
RegisterUnitEvent(7760000, 2, "Gruntworker_LeaveCombat")
RegisterUnitEvent(7760002, 4, "Gruntworker_die2")
RegisterUnitEvent(7760002, 2, "Gruntworker_LeaveCombat")
RegisterUnitEvent(7760004, 4, "Gruntworker_die3")
RegisterUnitEvent(7760004, 2, "Gruntworker_LeaveCombat")
RegisterUnitEvent(7760006, 4, "Gruntworker_die4")
RegisterUnitEvent(7760006, 2, "Gruntworker_LeaveCombat")
RegisterUnitEvent(7760008, 4, "Gruntworker_die5")
RegisterUnitEvent(7760008, 2, "Gruntworker_LeaveCombat")
RegisterUnitEvent(7760010, 4, "Gruntworker_die6")
RegisterUnitEvent(7760010, 2, "Gruntworker_LeaveCombat")
RegisterUnitEvent(7760012, 4, "Gruntworker_die7")
RegisterUnitEvent(7760012, 2, "Gruntworker_LeaveCombat")
RegisterUnitEvent(7760014, 4, "Gruntworker_die8")
RegisterUnitEvent(7760014, 2, "Gruntworker_LeaveCombat")
RegisterUnitEvent(7760016, 4, "Gruntworker_die9")
RegisterUnitEvent(7760016, 2, "Gruntworker_LeaveCombat")
RegisterUnitEvent(7760018, 4, "Gruntworker_die10")
RegisterUnitEvent(7760018, 2, "Gruntworker_LeaveCombat")
RegisterUnitEvent(7760020, 4, "Gruntworker_die11")
RegisterUnitEvent(7760020, 2, "Gruntworker_LeaveCombat")
RegisterUnitEvent(7760022, 4, "Gruntworker_die12")
RegisterUnitEvent(7760022, 2, "Gruntworker_LeaveCombat")
RegisterUnitEvent(7760024, 4, "Gruntworker_die13")
RegisterUnitEvent(7760024, 2, "Gruntworker_LeaveCombat")
RegisterUnitEvent(7760026, 4, "Gruntworker_die14")
RegisterUnitEvent(7760026, 2, "Gruntworker_LeaveCombat")
--Allyids
RegisterUnitEvent(7760003, 4, "Gruntworker_die1")
RegisterUnitEvent(7760003, 2, "Gruntworker_LeaveCombat")
RegisterUnitEvent(7760001, 4, "Gruntworker_die2")
RegisterUnitEvent(7760001, 2, "Gruntworker_LeaveCombat")
RegisterUnitEvent(7760005, 4, "Gruntworker_die3")
RegisterUnitEvent(7760005, 2, "Gruntworker_LeaveCombat")
RegisterUnitEvent(7760007, 4, "Gruntworker_die4")
RegisterUnitEvent(7760007, 2, "Gruntworker_LeaveCombat")
RegisterUnitEvent(7760009, 4, "Gruntworker_die5")
RegisterUnitEvent(7760009, 2, "Gruntworker_LeaveCombat")
RegisterUnitEvent(7760011, 4, "Gruntworker_die6")
RegisterUnitEvent(7760011, 2, "Gruntworker_LeaveCombat")
RegisterUnitEvent(7760013, 4, "Gruntworker_die7")
RegisterUnitEvent(7760013, 2, "Gruntworker_LeaveCombat")
RegisterUnitEvent(7760015, 4, "Gruntworker_die8")
RegisterUnitEvent(7760015, 2, "Gruntworker_LeaveCombat")
RegisterUnitEvent(7760017, 4, "Gruntworker_die9")
RegisterUnitEvent(7760017, 2, "Gruntworker_LeaveCombat")
RegisterUnitEvent(7760019, 4, "Gruntworker_die10")
RegisterUnitEvent(7760019, 2, "Gruntworker_LeaveCombat")
RegisterUnitEvent(7760021, 4, "Gruntworker_die11")
RegisterUnitEvent(7760021, 2, "Gruntworker_LeaveCombat")
RegisterUnitEvent(7760023, 4, "Gruntworker_die12")
RegisterUnitEvent(7760023, 2, "Gruntworker_LeaveCombat")
RegisterUnitEvent(7760025, 4, "Gruntworker_die13")
RegisterUnitEvent(7760025, 2, "Gruntworker_LeaveCombat")
RegisterUnitEvent(7760027, 4, "Gruntworker_die14")
RegisterUnitEvent(7760027, 2, "Gruntworker_LeaveCombat")

stoneharry
12-02-09, 11:10 AM
Would still keep attacking the players even though there the npc is now the same faction :( Still +Rep for the effert

runiker
12-02-09, 12:57 PM
Alright i will change it around thanks for letting me know so i can change it so it will work.

runiker
12-02-09, 01:52 PM
This code is a bit longer does the same thing and it should work now :P

Zaronz
12-02-09, 01:57 PM
Looks good, finally something unique that's not some simple boss fight :P

http://www.mmopro.net/forums/images/dark_vb/buttons/reputation.gif (http://www.mmopro.net/forums/reputation.php?p=5408)