Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PeasentTypes = {"mwwand1","mwwand2","mwwand3","mwwand6","mwwand4","mwwand5","mwwand10","mwwand11","mwwand12"}
- Noble = {"noble3","noble4","noble1","noble2"}
- PropsList = {"mwconst1","mwconst2","mwconst3","mwconst4","mwconst5","mwconst6","mwconst7"}
- Transporter1 = {}
- Transporter2 = {}
- Transporter3 = {}
- TransportProvider = {}
- FreeEngineer = {}
- WorldLoaded = function()
- -- set up Player
- People = {}
- LumberShaks = {}
- Lumberer = {}
- CamelShacks = {}
- CamelTrader = {}
- --Timer = 50
- Timer = Utils.RandomInteger(625,1250)
- CamelTimer = Utils.RandomInteger(325,650)
- Trigger.AfterDelay(1, function()
- People = Player.GetPlayers(function(P)
- return P.InternalName ~= "Neutral" and P.InternalName ~= "Creeps" and P.InternalName ~= "Everyone"
- end)
- end)
- Trigger.AfterDelay(2,function()
- --print(tostring(#People) .. " player found")
- for i = 1,#People do
- local who = People[i]
- --print(who.Name .. " Triggeredd!")
- Trigger.AfterDelay(DateTime.Seconds(10),function()
- SpawnSettlers(who)
- end)
- end
- LumberShaks = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(C)
- return C.Type == "split5"
- end)
- if LumberShaks and #LumberShaks > 0 then
- for i = 1, #LumberShaks do
- table.insert(Lumberer,"empty")
- end
- Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(25,45)),CheckForLumberjacks)
- end
- CamelShacks = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(C)
- return C.Type == "split6"
- end)
- if CamelShacks and #CamelShacks > 0 then
- for i = 1, #CamelShacks do
- table.insert(CamelTrader,"empty")
- Trigger.AfterDelay(DateTime.Seconds(1),function()
- SpawnACamel(CamelShacks[i])
- end)
- end
- Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(25,45)),CheckForCamelTrader)
- end
- Trigger.OnEnteredProximityTrigger(Map.CenterOfCell(CPos.New(24,24)), WDist.FromCells(512), function(a)
- if a.Type == "factnew" then
- local fact = a
- table.insert(TransportProvider,fact)
- table.insert(Transporter1,"empty")
- table.insert(Transporter2,"empty")
- table.insert(Transporter3,"empty")
- table.insert(FreeEngineer,"empty")
- Trigger.AfterDelay(45,function() SpawnStartTransporterA(fact) end)
- Trigger.AfterDelay(50,function() SpawnStartTransporterB(fact) end)
- Trigger.AfterDelay(55,function() SpawnStartTransporterC(fact) end)
- Trigger.AfterDelay(60,function() FreeEngeneer(fact) end)
- CallA(fact)
- Trigger.OnKilled(fact,function()
- local index = 0
- for i = 1, #TransportProvider do
- if TransportProvider[i] == fact then
- index = i
- print("87")
- break
- end
- end
- if fact.IsDead then
- table.remove(TransportProvider,index)
- table.remove(Transporter1,index)
- table.remove(Transporter2,index)
- table.remove(Transporter3,index)
- table.remove(FreeEngineer,index)
- Trigger.RemoveProximityTrigger(ProxyTriger[index])
- table.remove(ProxyTriger,index)
- print("99")
- end
- end)
- end
- end)
- end)
- end
- CallA = function(fact)
- Trigger.OnExitedProximityTrigger(fact.CenterPosition,WDist.FromCells(5),function(b)
- --WorkerReturnWhenIdle(fact,b)
- table.insert(ProxyTriger,id)
- end)
- end
- SpawnStartTransporterA = function(fact)
- local index = 0
- for i = 1, #TransportProvider do
- if TransportProvider[i] == fact then
- index = i
- break
- end
- end
- if Transporter1[index] == "empty" and fact and not fact.IsDead then
- Transporter1[index] = Actor.Create("transporter",true,{Owner = fact.Owner ,Location = fact.Location+CVec.New(1,1)})
- Transporter1[index].Move(Transporter1[index].Location+CVec.New(-1,1),3)
- Trigger.OnKilled(Transporter1[index],function()
- Trigger.AfterDelay(DateTime.Seconds(30),function()
- RespawnWorker(Transporter1[index], Transporter1)
- end)
- end)
- end
- end
- SpawnStartTransporterB = function(fact)
- local index = 0
- for i = 1, #TransportProvider do
- if TransportProvider[i] == fact then
- index = i
- break
- end
- end
- if Transporter2[index] == "empty" and fact and not fact.IsDead then
- Transporter2[index] = Actor.Create("transporter",true,{Owner = fact.Owner ,Location = fact.Location+CVec.New(1,1)})
- Transporter2[index].Move(Transporter2[index].Location+CVec.New(0,1),3)
- Trigger.OnKilled(Transporter2[index],function()
- Trigger.AfterDelay(DateTime.Seconds(30),function()
- RespawnWorker(Transporter2[index], Transporter2)
- end)
- end)
- end
- end
- SpawnStartTransporterC = function(fact)
- local index = 0
- for i = 1, #TransportProvider do
- if TransportProvider[i] == fact then
- index = i
- break
- end
- end
- if Transporter3[index] == "empty" and fact and not fact.IsDead then
- Transporter3[index] = Actor.Create("transporter",true,{Owner = fact.Owner ,Location = fact.Location+CVec.New(1,1)})
- Transporter3[index].Move(Transporter3[index].Location+CVec.New(1,1),3)
- Trigger.OnKilled(Transporter3[index],function()
- Trigger.AfterDelay(DateTime.Seconds(30),function()
- RespawnWorker(Transporter3[index], Transporter3)
- end)
- end)
- end
- end
- FreeEngeneer = function(fact)
- local index = 0
- for i = 1, #TransportProvider do
- if TransportProvider[i] == fact then
- index = i
- break
- end
- end
- if FreeEngineer[index] == "empty" and fact and not fact.IsDead then
- FreeEngineer[index] = Actor.Create("engeneer",true,{Owner = fact.Owner ,Location = fact.Location+CVec.New(1,1)})
- FreeEngineer[index].Move(FreeEngineer[index].Location+CVec.New(0,2),3)
- Trigger.OnKilled(FreeEngineer[index],function()
- Trigger.AfterDelay(DateTime.Seconds(30),function()
- RespawnWorker(FreeEngineer[index], FreeEngineer)
- end)
- end)
- end
- end
- WorkerReturnWhenIdle = function (fact, worker)
- local index = nil
- local fact = nil
- for i = 1, #TransportProvider do
- if TransportProvider[i] == fact then
- index = i
- print("196")
- break
- end
- end
- Trigger.OnIdle(worker,function()
- if fact and not fact.IsDead and worker and not worker.IsDead and math.abs(worker.Location.X - fact.Location.X) > 5 and math.abs(worker.Location.Y - fact.Location.Y) > 5 then
- worker.Move(fact.Location+CVec.New(2,1),5)
- end
- end)
- end
- RespawnWorker = function(Worker, tablevar)
- local index = nil
- local fact = nil
- for i = 1, #tablevar do
- if tablevar[i] == Worker then
- index = i
- break
- end
- end
- if index then
- if TransportProvider[index] and not TransportProvider[index].IsDead then
- fact = TransportProvider[index]
- end
- if Transporter1[index] == Worker and not Transporter3[index].IsDead and not fact.IsDead and fact then
- Transporter1[index] = Actor.Create("transporter",true,{Owner = fact.Owner ,Location = fact.Location+CVec.New(1,1)})
- Transporter1[index].Move(Transporter1[index].Location+CVec.New(0,1),3)
- Trigger.OnKilled(Transporter1[index],function()
- Trigger.AfterDelay(DateTime.Seconds(30),function()
- RespawnWorker(Transporter1[index], Transporter1)
- end)
- end)
- elseif Transporter2[index] == Worker and not Transporter3[index].IsDead and not fact.IsDead and fact then
- Transporter2[index] = Actor.Create("transporter",true,{Owner = fact.Owner ,Location = fact.Location+CVec.New(1,1)})
- Transporter2[index].Move(Transporter2[index].Location+CVec.New(0,1),3)
- Trigger.OnKilled(Transporter2[index],function()
- Trigger.AfterDelay(DateTime.Seconds(30),function()
- RespawnWorker(Transporter2[index], Transporter2)
- end)
- end)
- elseif Transporter3[index] == Worker and not Transporter3[index].IsDead and not fact.IsDead and fact then
- Transporter3[index] = Actor.Create("transporter",true,{Owner = fact.Owner ,Location = fact.Location+CVec.New(1,1)})
- Transporter3[index].Move(Transporter3[index].Location+CVec.New(0,1),3)
- Trigger.OnKilled(Transporter3[index],function()
- Trigger.AfterDelay(DateTime.Seconds(30),function()
- RespawnWorker(Transporter3[index], Transporter3)
- end)
- end)
- elseif FreeEngineer[index] == Worker and not FreeEngineer[index].IsDead and not fact.IsDead and fact then
- FreeEngineer[index] = Actor.Create("engeneer",true,{Owner = fact.Owner ,Location = fact.Location+CVec.New(1,1)})
- FreeEngineer[index].Move(FreeEngineer[index].Location+CVec.New(0,1),3)
- Trigger.OnKilled(FreeEngineer[index],function()
- Trigger.AfterDelay(DateTime.Seconds(30),function()
- RespawnWorker(FreeEngineer[index], FreeEngineer)
- end)
- end)
- end
- end
- end
- CheckForCamelTrader = function()
- if CamelShacks and #CamelShacks > 0 then
- for i = 1, #CamelShacks do
- if CamelTrader[i] == "empty" then
- --print("Line 107, Camel: " .. tostring(CamelShacks[i].Location))
- table.insert(CamelTrader,i,Actor.Create("cameltrader",true,{Owner = CamelShacks[i].Owner,Location = CamelShacks[i].Location}))
- CamelTrader[i].Move(CamelTrader[i].Location+CVec.New(0,1),3)
- elseif CamelTrader[i].IsDead then
- table.remove(CamelTrader,i)
- --print("Line 111, Camel: " .. tostring(CamelShacks[i].Location))
- table.insert(CamelTrader,i,Actor.Create("cameltrader",true,{Owner = CamelShacks[i].Owner,Location = CamelShacks[i].Location}))
- CamelTrader[i].Move(CamelTrader[i].Location+CVec.New(0,1),3)
- end
- end
- Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(25,45)),CheckForCamelTrader)
- end
- end
- CheckForLumberjacks = function()
- if LumberShaks and #LumberShaks > 0 then
- for i = 1, #LumberShaks do
- if Lumberer[i] == "empty" then
- table.insert(Lumberer,i,Actor.Create("mwlumberer",true,{Owner = LumberShaks[i].Owner,Location = LumberShaks[i].Location}))
- --print("Line 107, Lumberer: " .. tostring(LumberShaks[i].Location)); Lumberer[i].Move(Lumberer[i].Location+CVec.New(0,1),3)
- elseif Lumberer[i].IsDead then
- table.remove(Lumberer,i)
- table.insert(Lumberer,i,Actor.Create("mwlumberer",true,{Owner = LumberShaks[i].Owner,Location = LumberShaks[i].Location}))
- --print("Line 107, Lumberer: " .. tostring(LumberShaks[i].Location)); table.insert(Lumberer,i,Actor.Create("mwlumberer",true,{Owner = LumberShaks[i].Owner,Location = LumberShaks[i].Location}))
- Lumberer[i].Move(Lumberer[i].Location+CVec.New(0,1),3)
- end
- end
- Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(25,45)),CheckForLumberjacks)
- end
- end
- SpawnACamel = function(Lactor)
- local actors = Map.ActorsInCircle(Map.CenterOfCell(Lactor.Location),WDist.FromCells(8),function(C)
- return (C.Type == "mwcamel" or C.Type == "grownmwcamel") and (not C.IsDead)
- end)
- if #actors < 9 and Lactor and (not Lactor.IsDead) then
- local camel = Actor.Create("mwcamel",true,{Owner = Lactor.Owner,Location = Lactor.Location+CVec.New(1,0)})
- camel.Move(camel.Location+CVec.New(0,1),3)
- end
- end
- Talkagain = function(Actor)
- if Actor and (not Actor.IsDead) then
- Actor.GrantCondition("Talking",Utils.RandomInteger(150,500))
- Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(15,90)),function()
- if Actor and (not Actor.IsDead) then
- Talkagain(Actor)
- end
- end)
- end
- end
- SpawnSettlers = function(Player)
- local who = Player
- local hut = nil
- local largehuts = {}
- local huts = {}
- local peasantss = {}
- local peasent = nil
- local PeasType = nil
- local castles = {}
- local nobles = {}
- local Facts = {}
- local Chicken = {}
- peasantss = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(C)
- return (C.Type == "mwwand1" or C.Type == "mwwand2" or C.Type == "mwwand3" or C.Type == "mwwand4" or C.Type == "mwwand5" or C.Type == "mwwand6" or C.Type == "mwwand10" or C.Type == "mwwand11" or C.Type == "mwwand12") and C.Owner == who
- end)
- Chicken = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(C)
- return (C.Type == "mwchick1") and C.Owner == who
- end)
- huts = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(C)
- return (C.Type == "nukenew" or C.Type == "sulnuke" or C.Type == "nodnuke" ) and C.Owner == who
- end)
- largehuts = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(C)
- return (C.Type == "nuk2new" or C.Type == "sulnuk2" or C.Type == "nodnuk2") and C.Owner == who
- end)
- Facts = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(C)
- return C.Type == "factnew" and C.Owner == who
- end)
- if #peasantss < (#huts*2 + #largehuts*3) then
- if #largehuts ~= 0 and #huts ~= 0 then
- local rnd = Utils.RandomInteger(1,3)
- if rnd == 1 and #huts > 0 then
- hut = Utils.Random(huts)
- elseif rnd == 2 and #largehuts > 0 then
- hut = Utils.Random(largehuts)
- end
- elseif #largehuts > 0 then
- hut = Utils.Random(largehuts)
- elseif #huts > 0 then
- hut = Utils.Random(huts)
- elseif #Facts > 0 then
- hut = Utils.Random(Facts)
- end
- PeasType = Utils.Random(PeasentTypes)
- if hut and (not hut.IsDead) then
- --print("Line 424, Peasant: " .. tostring(hut.Location))
- peasent = Actor.Create(PeasType,true,{Owner = who,Location = hut.Location+CVec.New(1,1)})
- peasent.Move(peasent.Location+CVec.New(0,1),3)
- table.insert(peasantss,peasent)
- Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(30,150)),function()
- if peasent and (not peasent.IsDead) then
- Talkagain(peasent)
- end
- end)
- if (#peasantss + #nobles) > #Chicken*5 and hut and (not hut.IsDead) then
- Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(25,100)),function()
- if hut and (not hut.IsDead) then
- --print("Line 439, Chicken: " .. tostring(hut.Location))
- local chicko = Actor.Create("mwchick1",true,{Owner = who,Location = hut.Location+CVec.New(1,2)})
- chicko.Move(chicko.Location+CVec.New(0,1),3)
- end
- end)
- end
- end
- end
- nobles = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(C)
- return (C.Type == "noble1" or C.Type == "noble2" or C.Type == "noble3" or C.Type == "noble4") and C.Owner == who
- end)
- castles = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(C)
- return (C.Type == "castle" or C.Type == "castle2" or C.Type == "sulcastle") and C.Owner == who
- end)
- landlord = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(C)
- return C.Type == "noble5" and C.Owner == who
- end)
- if #landlord < (#castles) and #castles > 0 then
- hut = Utils.Random(castles)
- peasent = nil
- if hut and (not hut.IsDead) then
- --print("Line 469, Noble: " .. tostring(hut.Location))
- peasent = Actor.Create("noble5",true,{Owner = who,Location = hut.Location+CVec.New(1,2)})
- peasent.Move(peasent.Location+CVec.New(0,1),3)
- Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(15,90)),function()
- if (not peasent.IsDead) and peasent then
- Talkagain(peasent)
- end
- end)
- end
- elseif #nobles < (#castles+4) and #castles > 0 then
- peasent = nil
- hut = Utils.Random(castles)
- PeasType = Utils.Random(Noble)
- if hut and (not hut.IsDead) then
- --print("Line 488, Noble: " .. tostring(hut.Location))
- peasent = Actor.Create(PeasType,true,{Owner = who,Location = hut.Location+CVec.New(1,2)})
- peasent.Move(peasent.Location+CVec.New(0,1),3)
- table.insert(peasantss,peasent)
- Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(15,90)),function()
- if peasent and (not peasent.IsDead) then
- Talkagain(peasent)
- end
- end)
- end
- end
- if (#largehuts + #huts) == 0 then
- Trigger.AfterDelay(DateTime.Seconds(10),function()
- SpawnSettlers(who)
- SpawnHunter(who)
- end)
- else
- Trigger.AfterDelay(DateTime.Seconds(10+math.floor(100/((#castles*3 +#largehuts*2 + #huts +2)/2))),function()
- SpawnSettlers(who)
- SpawnHunter(who)
- end)
- end
- local Stuff = {}
- local Spawn = nil
- local dep = nil
- local here = {}
- local Factor = nil
- here = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(C)
- return (C.Type == "nukenew" or C.Type == "sulnuke" or C.Type == "sulnuk2" or C.Type == "nuk2new" or C.Type == "nodnuke" or C.Type == "nodnuk2") and C.Owner == who
- end)
- Stuff = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(C)
- return (C.Type == "mwconst1" or C.Type == "mwconstback" or C.Type == "prop1" or C.Type == "prop2" or C.Type == "prop3" or C.Type == "prop4" or C.Type == "prop5" or C.Type == "prop6" or C.Type == "prop7" ) and C.Owner == who
- end)
- if #peasantss > ((#Stuff+1)*4) and #here > 0 and #Facts > 0 then
- Spawn = Utils.Random(here)
- Factor = Utils.Random(Facts)
- Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(3,8)),function()
- if Spawn and Factor and (not Factor.IsDead) and (not Spawn.IsDead) then
- --print("Line 533, Props: " .. tostring(hut.Location))
- dep = Actor.Create(Utils.Random(PropsList),true,{Owner = who,Location = Factor.Location+CVec.New(1,1)})
- dep.Move(dep.Location+CVec.New(0,1),3)
- dep.Move(Spawn.Location+CVec.New(Utils.RandomInteger(-4,5),Utils.RandomInteger(-4,5)),5)
- dep.Deploy()
- end
- end)
- end
- end
- SpawnHunter = function(Player)
- local who = Player
- local hunteres = {}
- local hunter = nil
- local hut = nil
- local Facts = {}
- local peasent = nil
- local Add = 0
- local Smiths = {}
- local Vehicle = {}
- Smiths = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(C)
- return (C.Type == "hqnod" or C.Type == "sulcastle") and C.Owner == who
- end)
- Vehicle = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(C)
- return (C.Type == "stall" or C.Type == "nodstall" or C.Type == "sulmystic") and C.Owner == who
- end)
- hunteres = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(C)
- return (C.Type == "hunter") and C.Owner == who
- end)
- Facts = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(C)
- return C.Type == "factnew" and C.Owner == who
- end)
- if #Facts > 0 then
- hut = Utils.Random(Facts)
- end
- if #Smiths > 0 then
- Add = Add+1
- end
- if #Vehicle > 0 then
- Add = Add+1
- end
- if (#hunteres < (#Facts+Add)) and hut then
- if hut and (not hut.IsDead) then
- peasent = Actor.Create("hunter",true,{Owner = who,Location = hut.Location+CVec.New(1,1)})
- peasent.Move(peasent.Location+CVec.New(0,1),3)
- end
- end
- end
- Tick = function()
- CamelTimer = CamelTimer-1
- if CamelTimer < 1 then
- if CamelShacks and #CamelShacks > 0 then
- for i = 1, #CamelShacks do
- SpawnACamel(CamelShacks[i])
- end
- end
- CamelTimer = Utils.RandomInteger(325,650)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement