I've been asked to add support for PvP scenario to RSO.
I'm not sure how to do that currently - anyone knows if there is a way to figure out where players start to be able to spawn starting locations for them?
PvP scenario help needed
Re: PvP scenario help needed
Each force is given a unique spawn position based on what settings the player chooses,orzelek wrote:I've been asked to add support for PvP scenario to RSO.
I'm not sure how to do that currently - anyone knows if there is a way to figure out where players start to be able to spawn starting locations for them?
So to get each spawn position you will need to worry about, look through the teams like this:
Code: Select all
for k, team in pairs(global.teams) do
local force = game.forces[team.name]
if force then
make_spawn(force.get_spawn_position(global.surface))
end
end
Re: PvP scenario help needed
You used global.teams and global.surface there - I'm assuming those are from PvP scenario script.
I looked a bit and do I see correctly that when player is created I should have all the data needed to spawn starting area under him?
And would it work in PvP scenario in this way?
I would monitor players spawning and if I see new location I haven't spawned yet I would add new starting area there.
This could have side effects.. if someone creates players in different context then actually spawning them in game. But it's the best approach I see currently.
I looked a bit and do I see correctly that when player is created I should have all the data needed to spawn starting area under him?
And would it work in PvP scenario in this way?
I would monitor players spawning and if I see new location I haven't spawned yet I would add new starting area there.
This could have side effects.. if someone creates players in different context then actually spawning them in game. But it's the best approach I see currently.
Re: PvP scenario help needed
It would be best i think to listen to 'on_player_changed_force',orzelek wrote:You used global.teams and global.surface there - I'm assuming those are from PvP scenario script.
I looked a bit and do I see correctly that when player is created I should have all the data needed to spawn starting area under him?
And would it work in PvP scenario in this way?
I would monitor players spawning and if I see new location I haven't spawned yet I would add new starting area there.
This could have side effects.. if someone creates players in different context then actually spawning them in game. But it's the best approach I see currently.
As when a player joins, he is not immediately moved to the new force,
Then once a player joins that force, you can check if you have already created a starting area for that force, and if not, create one
Re: PvP scenario help needed
Few questions:
1. Would this also work in single player? I'm assuming it should since player is in some force always.
2. How do I know whats the surface with starting location for force? Interface to get it requires surface and from what I see in pvp scenario I can't use nauvis since scenario is using more surfaces.
1. Would this also work in single player? I'm assuming it should since player is in some force always.
2. How do I know whats the surface with starting location for force? Interface to get it requires surface and from what I see in pvp scenario I can't use nauvis since scenario is using more surfaces.
Re: PvP scenario help needed
In single player they are still put on a team in global.teams,orzelek wrote:Few questions:
1. Would this also work in single player? I'm assuming it should since player is in some force always.
2. How do I know whats the surface with starting location for force? Interface to get it requires surface and from what I see in pvp scenario I can't use nauvis since scenario is using more surfaces.
The surface can be found with 'on_player_surface_changed'
If you'd prefer, work on a solution that is good for you, and i can add the necessary remote interface to the PvP script,
And/or any custom events you would like to listen to, such as an event for when the map is ready, or an event when the round is over etc.
Re: PvP scenario help needed
Main problem I see now would be that there is no event that gives all the required information at once.
To generate starting area I need position and surface - from what you wrote it seems that those could be grabbed from two separate events.
If there is a guarantee that both of those events happen every time round is started then I could work with them I think. I would also need to detect when surface is regenerated when round changes - I think there is an event on surface destruction. If surface is reused then I'd need to have a way of detecting that round has ended to clear up previous round starting positions.
To generate starting area I need position and surface - from what you wrote it seems that those could be grabbed from two separate events.
If there is a guarantee that both of those events happen every time round is started then I could work with them I think. I would also need to detect when surface is regenerated when round changes - I think there is an event on surface destruction. If surface is reused then I'd need to have a way of detecting that round has ended to clear up previous round starting positions.