Page 1 of 1

Revealing Shroud for parts of the map

Posted: Sun Oct 11, 2015 11:04 am
by HeimSpiel
Hi guys,

I'm trying to build a map with an north-south-conflict. There are 4 positions in the north and 4 in the south. They are separated by a river that flows more or less in the middle from east to west.

The following is what I want to do:
I want to reveal the shroud (but not fow) in the northern hemisphere for the 4 northern locations. The equivalent for the south.

I'd thought of the following logical solution:
I create an array with the y-coordinates of the river. At the very beginning of the map I'd run an init function that does the following:

Code: Select all

for x=0..border {
 for y=0..border {
  if (y < rivercoordinates(x) )
   reveal1tilenorth(x,y)
  else
   reveal1tilesouth(x,y)
 }
}
- So the problem I have now is how do I achieve that? It seems to me that I need a lua script, is that correct?
- Is there a list for all available triggers?
- Is there an easier way to to this maybe with map.yaml settings only?
- How can I force an alliance of the northern/southern players?

Re: Revealing Shroud for parts of the map

Posted: Sun Oct 11, 2015 12:08 pm
by Graion Dilach
HeimSpiel wrote: - So the problem I have now is how do I achieve that? It seems to me that I need a lua script, is that correct?
- Is there an easier way to to this maybe with map.yaml settings only?
You can either do a lua script, either add two nonplayable (NonCombatant: true) players (one allied with the north, one with the south) and place camera actors to the places you want revealed. I feel the latter option a bit hacky and unclean to be honest, though.
HeimSpiel wrote: - Is there a list for all available triggers?
https://github.com/OpenRA/OpenRA/wiki/Lua-API Ctrl-F Trigger there.
HeimSpiel wrote: - How can I force an alliance of the northern/southern players?
Set LockTeam to true and Team in the PlayerReference. See Fort Lonestar for an example.

Re: Revealing Shroud for parts of the map

Posted: Sun Oct 11, 2015 4:10 pm
by HeimSpiel
Graion Dilach wrote: You can either do a lua script
So I decided to go that way. What I have so far:

Code: Select all

River = { 80, 80, 79, 78, etc. }

RevealCoord = function(pos, gamer)
	for i=1,#gamer do
		??? what to do here ???
	end
end

WorldLoaded = function()
	north = { }
	south = { }
	for i = 0,3 do
		north[i+1] = Player.GetPlayer("Multi" ..i)
	end
	for i = 4,7 do
		south[i+1] = Player.GetPlayer("Multi" ..i)
	end
	for x = 1,159 do
		for y = 1,159 do
			if (y < River[x]) then
				RevealCoord(WPos.New(x,y,0), north)
			else
				RevealCoord(WPos.New(x,y,0), south)
			end
		end
	end
end
The problem now is that I'm missing an API call to reveal the shroud. What can I do?
Graion Dilach wrote: Set LockTeam to true and Team in the PlayerReference. See Fort Lonestar for an example.
That worked, thanks!

Posted: Sun Oct 11, 2015 8:00 pm
by abcdefg30
You would need to create a camera actor at "??? what to do here ???".
This can be also done through map.yaml / the ingame map editor.
Just place cameras owned by each player you want to have sight there.
(Then you wouldn't need a lua script.)

Posted: Sun Oct 18, 2015 4:05 pm
by HeimSpiel
Hi guys,

after some tries I decided to go with the solution abcdefg30 proposed.
But 2 more questions:

a) is it possible to have multiple locations as an owner of a map? It's quite dull to have the actors spawned 4 times.

b) is there an actor that reveals only fow but not the shroud? 'camera' seems to reveal fow, too.

Posted: Wed Oct 21, 2015 6:35 pm
by HeimSpiel
My current situation is the following: I have a bunch of Actors in map.yaml

Code: Select all

...
	Actor1101: camera
		Owner: Multi0
		Location: 189,216
...
What I try to do is to kill all those camera actors a second after map start with the following lua script

Code: Select all

DoFoW = function()
	for i = 0,7 do
		CurPlayer = Player.GetPlayer("Multi"..i)
		if CurPlayer ~= nil then
			ActCameras = CurPlayer.GetActorsByType("camera")
			for i=1,#ActCameras do
				Trigger.AfterDelay(DateTime.Seconds(10), function()
					ActCameras[i].Destroy()
				end)
			end
		end
	end
end
Nothing happens.
It seems I have access to dynamically assigned cameras. This works and reveals a part of the map around the specified coordinates:

Code: Select all

DoFoW = function()
	loc = CPos.New(28,112)
	for i = 0,7 do
		CurPlayer = Player.GetPlayer("Multi"..i)
		if CurPlayer ~= nil then
			SpyCamera = Actor.Create("camera", true, { Owner = CurPlayer, Location = loc })
			Trigger.AfterDelay(DateTime.Seconds(10), function()
				SpyCamera.Destroy()
			end)
		end
	end
end
I wonder: why don't I get access to the camera actors defined in the map.yaml?

Posted: Sat Oct 24, 2015 1:00 pm
by abcdefg30
HeimSpiel wrote: a) is it possible to have multiple locations as an owner of a map? It's quite dull to have the actors spawned 4 times.
Sorry, I don't exactly get what you mean here...
Something like:

Code: Select all

ActorXY: type
   Owner: Multi0
   Location: 0,0 1,1 2,2 3,3 ...
?
If so, that is not possible.
HeimSpiel wrote: b) is there an actor that reveals only fow but not the shroud? 'camera' seems to reveal fow, too.
Sorry, I don't think that is possible.


Your latest problem is weird.. I couldn't find errors while looking over your code.
Are you running DoFoW from inside WorldLoaded?
Also: You can access the actors from map.yaml through their names.
E.g.

Code: Select all

Trigger.AfterDelay(DateTime.Seconds(10), function()
   ...
   Actor1101.Destroy()
   ...
end)
PS: Sorry for the late answer.

Posted: Sun Oct 25, 2015 8:31 pm
by HeimSpiel
I finally managed to achieve what I wanted. For those who may need a similar thing:

I removed all cameras from the yaml and into the lua. At the beginning of the match, the cameras are created dynamically with a trigger that kills them after a few seconds:

Code: Select all

CamPosNorth = { CPos.New(9,0), CPos.New(9,18), CPos.New(0,9), CPos.New(18,9) ..... }
CamPlayerNorth = { }

RevealNorth = function()
	for i = 0,3 do
		gamer = Player.GetPlayer("Multi"..i)
		if gamer ~= nil then
			CamPlayerNorth[i+1] = { }
			for k = 1,#CamPosNorth do
				CamPlayerNorth[i+1][k] = Actor.Create("camera", true, { Owner = gamer, Location = CamPosNorth[k] })
				Trigger.AfterDelay(DateTime.Seconds(3), function()
					CamPlayerNorth[i+1][k].Destroy()
				end)
			end
		end
	end
end
To completely reveal a region you don't need to add a camera at each cell - it's sufficient to have them at the corners of a diamond with a diameter of 18 cells.

Thanks for all the input!