Zeruel87 wrote: ↑Tue Dec 03, 2019 2:38 pm
another Rroblem i encounter when i try to shorten my Script is:
when i try to shorten
Code: Select all
fact = p2.GetActorsByType("fact")
pyle = p2.GetActorsByType("pyle")
hand = p2.GetActorsByType("hand")
afld = p2.GetActorsByType("afld")
weap = p2.GetActorsByType("weap")
hpad = p2.GetActorsByType("hpad")
to
Code: Select all
buildings = p2.GetActorsByType("fact","pyle","hand","afld","weap","hpad")
it seems that only the first actor, in that case "fact" seems to be affected and nothing behind the line.
do i have to use "GetActorsByTypes" for that?
I can show you how i solved this problem.
This just gives all trees a codition wich changes its colors. ( of course no needle trees
)
Code: Select all
AllTrees = {"t03", "t10", "t11", "t12", "t13", "t14", "t15", "t17", "tc02", "tc05"}
AprilTrees = function()
for i=1,#AllTrees do
if i ~= nil then
local Trees = Neutral.GetActorsByType(AllTrees[i])
for p,tree in pairs(Trees) do
Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(1, 210)), function()
if not tree.IsDead and tree.IsInWorld and tree.HasProperty("GrantCondition") and tree.AcceptsCondition("spring2") then
tree.GrantCondition("spring2", 0)
end
end)
end
end
end
end
Now a bit more comlex i get the wintertrees ( i added wintertrees in yaml ) change them (Destroy and rebuild) to normal trees and put a condition on them at the same time.
Code: Select all
AllWinterStufft = {"t01winter", "t02winter", "t03winter", "t05winter", "t06winter", "t07winter", "t08winter", "t10winter", "t11winter", "t12winter", "t13winter", "t14winter", "t15winter", "t16winter", "t17winter"}
AllWinterStufftc = {"tc01winter", "tc02winter", "tc03winter", "tc04winter", "tc05winter"}
AllTNumbers = {"01", "02", "03", "04", "05", "06", "07", "08", "10", "11", "12", "13", "14", "15", "16", "17", "18"}
AllTCNumbers = {"01", "02", "03", "04", "05"}
ChangeSpringTrees = function()
for u=1,#AllWinterStufft do
if u ~= nil then
local Trees = Neutral.GetActorsByType(AllWinterStufft[u])
for p,tree in pairs(Trees) do
for i=1,#AllTNumbers do
if tree.Type == "t0" .. i .. "winter" then -- This is important if you want to do different things with the actors
Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(1, 25)), function()
if not tree.IsDead and tree.IsInWorld then
Newtree = Actor.Create("t0" .. i .. "" , true, { Location = tree.Location, Owner = Neutral })
if Newtree.HasProperty("GrantCondition") and Newtree.AcceptsCondition("spring") then
Newtree.GrantCondition("spring", 0)
end
tree.Destroy()
end
end)
elseif tree.Type == "t" .. i .. "winter" then
Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(1, 25)), function()
if not tree.IsDead and tree.IsInWorld then
Newtree = Actor.Create("t" .. i .. "" , true, { Location = tree.Location, Owner = Neutral })
if Newtree.HasProperty("GrantCondition") and Newtree.AcceptsCondition("spring") then
Newtree.GrantCondition("spring", 0)
end
tree.Destroy()
end
end)
end
end
end
end
end
for u=1,#AllWinterStufftc do
if u ~= nil then
local Trees = Neutral.GetActorsByType(AllWinterStufftc[u])
for p,tree in pairs(Trees) do
for i=1,#AllTCNumbers do
if tree.Type == "tc0" .. i .. "winter" then
Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(1, 25)), function()
if not tree.IsDead and tree.IsInWorld then
Newtree = Actor.Create("tc0" .. i .. "" , true, { Location = tree.Location, Owner = Neutral })
if Newtree.HasProperty("GrantCondition") and Newtree.AcceptsCondition("spring") then
Newtree.GrantCondition("spring", 0)
end
tree.Destroy()
end
end)
end
end
end
end
end
Maybe you can also use this for Players in the same step i didnt need that by now.
Another example how you can setup players is here.
Code: Select all
SetupPlayers = function()
Neutral = Player.GetPlayer("Neutral")
Creeps = Player.GetPlayer("Creeps")
Multi0 = Player.GetPlayer("Multi0")
Multi1 = Player.GetPlayer("Multi1")
Multi2 = Player.GetPlayer("Multi2")
Multi3 = Player.GetPlayer("Multi3")
Multi4 = Player.GetPlayer("Multi4")
Multi5 = Player.GetPlayer("Multi5")
Multi6 = Player.GetPlayer("Multi6")
Multi7 = Player.GetPlayer("Multi7")
Multi8 = Player.GetPlayer("Multi8")
Multi9 = Player.GetPlayer("Multi9")
Humans = { Multi0, Multi1, Multi2, Multi3, Multi4, Multi5, Multi6, Multi7, Multi8, Multi9 }
end
FuseFlag1Cell = function()
Utils.Do(Humans, function(player)
local flagactors = player.GetActorsByType("ctflag")
for p,flag in pairs(flagactors) do
if not flag.HasTag("isfused1") then
flag.AddTag("isfused1") -- This tag is to dont fuse already checked flags
Trigger.OnEnteredProximityTrigger(flag.CenterPosition, WDist.FromCells(1), function(a, id)
local mine = flag.Owner
local yours = a.Owner
if a.HasTag("flagholdingunit") and mine == yours then
a.Stop()
a.Kill()
elseif mine ~= yours and a.Type == "tflag" and mine.IsAlliedWith(yours) == true then
NewPositionFlag = Actor.Create("ctflag", true, { Location = a.Location + CVec.New(Utils.RandomInteger(-1, 2), 1), Owner = yours })
a.Destroy()
elseif mine ~= yours and a.Type ~= "mcv" and a.Type ~= "truk" and a.Type ~= "ctfmcv" and a.Type ~= "dpctflag" and a.HasProperty("GrantCondition") and a.AcceptsCondition("flagholder") and not a.HasTag("flagholdingunit") then
if Mode ~= "temprasphere" and mine.IsAlliedWith(yours) == true then
return
else
Trigger.RemoveProximityTrigger(id)
if mine.IsLocalPlayer then
SetCamera(mine)
end
Beacon.New(mine, a.CenterPosition, 100, true)
a.AddTag("flagholdingunit")
a.GrantCondition("flagholder", 0)
a.GrantCondition("hold" .. mine.InternalName .. "flag", 0)
if Mode ~= "hawkie" then
if DateTime.GameTime < DateTime.Minutes(5) then
a.GrantCondition("snailspeed", 0)
elseif DateTime.GameTime < DateTime.Minutes(7) then
a.GrantCondition("turtlespeed", 0)
else
a.GrantCondition("frogspeed", 0)
end
end
flag.Destroy()
Trigger.OnKilled(a, function()
Flag = Actor.Create("tflag", true, { Location = a.Location, Owner = mine })
end)
end
end
end)
end
end
end)
end
Here is the map i used this code for, weather effects or a capture the flag mode (and other things) are optional in the gamelobby.
https://resource.openra.net/maps/32840/
The update just failed for the newest release, but i will add an updated version soon.