Hey guys, I'll be the first to say, I suck at scripting. I was wondering if someone could help me out with this.
Basically, in the map I am creating currently, there are 4 buildings/bunkers that each player spawns on. It is a challenge map inspired by Shit Brick House and TMG Fun. But, unlike Shit Brick House, I want a movable box. In 4 player, this wouldn't be a problem, because the box would just keep moving to each of the 4 bunkers. But if you play say 2 player, and the box moves to an inaccessible location, you wouldn't be able to use the box forever...
But each location will also have different perks and wall weapons, so being able to teleport around each round is extremely ideal for what I had in mind, plus it adds more of a challenge and gives a nice feeling of randomness in my opinion.
Easy enough, one thing though could you add "tp points" for each player you want or do you want it to be random?
Yeah I was hoping for randomness, maybe so you could get lucky and end up with another person, but if it's too difficult I can settle for a non random order
Yeah I was hoping for randomness, maybe so you could get lucky and end up with another person, but if it's too difficult I can settle for a non random order
Alright another thing are they going to be in the same room? Or will it always be random and players can't spawn in same room (/spawn point). What I mean is having 1-4 spawn points per room and then it'll be randomly selected, then it'll be filtered out. I could also make it teleport random players (randomize player array).
Alright another thing are they going to be in the same room? Or will it always be random and players can't spawn in same room (/spawn point). What I mean is having 1-4 spawn points per room and then it'll be randomly selected, then it'll be filtered out. I could also make it teleport random players (randomize player array).
Yes, I was hoping for 1-4 spawn points per room, so maybe one round, everyone is alone, and the next round, there's that minimal chance that all 4 players end up in the same room, so yes!
//DUKIP - Don't run it on round 1? //Can remove the if line to make it run on the first round. if((level.round_number - 1) > 1) level thread moveAllPlayers(); } }
moveAllPlayers() { //DUKIP - Grab total players and randomize the array. players = get_players(); players = array_randomize( players ); //DUKIP - Grab our tp structs and randomize the array. tp_points = GetStructArray("player_teleport_point", "targetname"); tp_points = array_randomize( tp_points ); useSameTPPoint = false; for(i = 0; i < players.size; i++) { //DUKIP - Select randomize TP point, if we're not keeping the same spawn point. if(!useSameTPPoint) teleportPoint = tp_points[randomInt(tp_points.size)]; //DUKIP - 20% chance remove the gotten spawn point from the array. if(RandomIntRange(0, 100) >= 80 && !useSameTPPoint) tp_points = array_remove(tp_points, teleportPoint); //DUKIP - 60% chance to reuse same spawn point. if(RandomIntRange(0, 100) >= 60) useSameTPPoint = true; else useSameTPPoint = false; } }
Here's a mockup of what I have now.
Pseudocode
Code Snippet
Plaintext
Wait until between_round_over to move players. Grab players array then randomize Grab teleport points struct then randomize For each player have set conditions for randomize spawn point or reuse same point. With spawn point struct determined teleport player, apply a black overlay before teleporting then take fade it out.
Last Edit: February 25, 2015, 12:20:19 am by DidUknowiPwn
//DUKIP - Don't run it on round 1? //Can remove the if line to make it run on the first round. if((level.round_number - 1) > 1) level thread moveAllPlayers(); } }
moveAllPlayers() { //DUKIP - Grab total players and randomize the array. players = get_players(); players = array_randomize( players ); //DUKIP - Grab our tp structs and randomize the array. tp_points = GetStructArray("player_teleport_point", "targetname"); tp_points = array_randomize( tp_points ); useSameTPPoint = false; for(i = 0; i < players.size; i++) { //DUKIP - Select randomize TP point, if we're not keeping the same spawn point. if(!useSameTPPoint) teleportPoint = tp_points[randomInt(tp_points.size)]; //DUKIP - 20% chance remove the gotten spawn point from the array. if(RandomIntRange(0, 100) >= 80 && !useSameTPPoint) tp_points = array_remove(tp_points, teleportPoint); //DUKIP - 60% chance to reuse same spawn point. if(RandomIntRange(0, 100) >= 60) useSameTPPoint = true; else useSameTPPoint = false; } }
Here's a mockup of what I have now.
Pseudocode
Code Snippet
Plaintext
Wait until between_round_over to move players. Grab players array then randomize Grab teleport points struct then randomize For each player have set conditions for randomize spawn point or reuse same point. With spawn point struct determined teleport player, apply a black overlay before teleporting then take fade it out.
Wow, thanks! where do I put that top code at? and do I need to add that second part to anything?
This isn't complete it's just a mockup of the code. Another thing I wanted to bring up do you want a chance for a player to spawn in the same room again? Because that's how it can be now, if you don't we'll have to go through some more checks.
This isn't complete it's just a mockup of the code. Another thing I wanted to bring up do you want a chance for a player to spawn in the same room again? Because that's how it can be now, if you don't we'll have to go through some more checks.
Ahh ok, and yes, I do want players to be able to spawn in the same place again.
//DUKIP - Move players before round restarts. //DUKIP - Don't run it on round 1? //Can remove the if line to make it run on the first round. if(level.round_number > 1) level thread moveAllPlayers();
moveAllPlayers() { //DUKIP - Grab total players and randomize the array. players = get_players(); players = array_randomize( players ); //DUKIP - Grab our tp structs and randomize the array. tp_points = GetStructArray("player_teleport_point", "targetname"); tp_points = array_randomize( tp_points ); useSameTPPoint = false; for(i = 0; i < players.size; i++) { //DUKIP - Select randomize TP point, if we're not keeping the same spawn point. if(!useSameTPPoint) //{ teleportPoint = tp_points[randomInt(tp_points.size)]; //DUKIP - If our tp room is the same our players tp room then reselect a new spawn point for the player alone. //deprecated, map will have a chance of reselecting same areas. //while(teleportPoint.script_string == players[i].tp_room) // teleportPoint = tp_points[randomInt(tp_points.size)]; //}
//DUKIP - Set player var we'll always update it instead of having it a chance of it failing. //deprecated, map will have a chance of reselecting same areas. //players[i].tp_room = teleportPoint.script_string;
//DUKIP - 20% chance remove the gotten spawn point from the array. if(RandomIntRange(0, 101) >= 80 && !useSameTPPoint) tp_points = array_remove(tp_points, teleportPoint); //DUKIP - 60% chance to reuse same spawn point for the next player. if(RandomIntRange(0, 101) >= 60) useSameTPPoint = true; else useSameTPPoint = false;
if(IsDefined(teleportPoint)) players[i] thread movePlayerToRoom(teleportPoint); else IPrintLnBold("^1ERROR^7: Failed to generate teleportPoint for player #" + i + ": " + players[i].playername); } }
movePlayerToRoom(tpPoint) { //DUKIP - Disable player controls and weapons. self FreezeControls(true); self DisableWeapons(); //DUKIP - Spawn HUD element fadeToBlack = NewClientHudElem( self ); fadeToBlack.x = 0; fadeToBlack.y = 0; fadeToBlack.alpha = 0; fadeToBlack.horzAlign = "fullscreen"; fadeToBlack.vertAlign = "fullscreen"; fadeToBlack.foreground = false; fadeToBlack.sort = 50; fadeToBlack SetShader( "black", 640, 480 ); //DUKIP - Fade at 0.5 seconds fadeToBlack FadeOverTime( 0.5 ); fadeToBlack.alpha = 1; wait 1; //DUKIP - Wait one second, then move player to new point, unlock controls and enable weapons. self SetOrigin(tpPoint.origin); self FreezeControls(false); self EnableWeapons(); wait 0.5; //DUKIP - Fade at 0.5 seconds fadeToBlack FadeOverTime( 0.5 ); fadeToBlack.alpha = 0; wait 1; //DUKIP - Make sure to destroy the element. fadeToBlack Destroy(); }
Pseudocode
Quote
Start moving players before round is incremented/restarted. Grab players then randomize. Grab teleport points then randomize. For each player, if we're not reusing same spawn point from prev player (first player in array will always move) then generate new point, have a chance to remove the spawn point from the tp array but make sure not to remove it if we're using same point, have a chance to reuse same tp point for the next player, and finally make sure the teleport point is real then move the player while setting a black overlay.
Last Edit: February 25, 2015, 12:57:48 am by DidUknowiPwn
//DUKIP - Move players before round restarts. //DUKIP - Don't run it on round 1? //Can remove the if line to make it run on the first round. if(level.round_number > 1) level thread moveAllPlayers();
moveAllPlayers() { //DUKIP - Grab total players and randomize the array. players = get_players(); players = array_randomize( players ); //DUKIP - Grab our tp structs and randomize the array. tp_points = GetStructArray("player_teleport_point", "targetname"); tp_points = array_randomize( tp_points ); useSameTPPoint = false; for(i = 0; i < players.size; i++) { //DUKIP - Select randomize TP point, if we're not keeping the same spawn point. if(!useSameTPPoint) //{ teleportPoint = tp_points[randomInt(tp_points.size)]; //DUKIP - If our tp room is the same our players tp room then reselect a new spawn point for the player alone. //deprecated, map will have a chance of reselecting same areas. //while(teleportPoint.script_string == players[i].tp_room) // teleportPoint = tp_points[randomInt(tp_points.size)]; //}
//DUKIP - Set player var we'll always update it instead of having it a chance of it failing. //deprecated, map will have a chance of reselecting same areas. //players[i].tp_room = teleportPoint.script_string;
//DUKIP - 20% chance remove the gotten spawn point from the array. if(RandomIntRange(0, 101) >= 80 && !useSameTPPoint) tp_points = array_remove(tp_points, teleportPoint); //DUKIP - 60% chance to reuse same spawn point for the next player. if(RandomIntRange(0, 101) >= 60) useSameTPPoint = true; else useSameTPPoint = false;
if(IsDefined(teleportPoint)) players[i] thread movePlayerToRoom(teleportPoint); else IPrintLnBold("^1ERROR^7: Failed to generate teleportPoint for player #" + i + ": " + players[i].playername); } }
movePlayerToRoom(tpPoint) { //DUKIP - Disable player controls and weapons. self FreezeControls(true); self DisableWeapons(); //DUKIP - Spawn HUD element fadeToBlack = NewClientHudElem( self ); fadeToBlack.x = 0; fadeToBlack.y = 0; fadeToBlack.alpha = 0; fadeToBlack.horzAlign = "fullscreen"; fadeToBlack.vertAlign = "fullscreen"; fadeToBlack.foreground = false; fadeToBlack.sort = 50; fadeToBlack SetShader( "black", 640, 480 ); //DUKIP - Fade at 0.5 seconds fadeToBlack FadeOverTime( 0.5 ); fadeToBlack.alpha = 1; wait 1; //DUKIP - Wait one second, then move player to new point, unlock controls and enable weapons. self SetOrigin(tpPoint.origin); self FreezeControls(false); self EnableWeapons(); wait 0.5; //DUKIP - Fade at 0.5 seconds fadeToBlack FadeOverTime( 0.5 ); fadeToBlack.alpha = 0; wait 1; //DUKIP - Make sure to destroy the element. fadeToBlack Destroy(); }
Pseudocode
So when I do this, I'll need 4 script structs in each area not including the initial spawn point correct?
Yeah you can put any number you want but 4 would be a good number as there might be a chance for all 4 players to be in same room. Edit: Give the struct a targetname of player_teleport_point and then copy it for each new point
Last Edit: February 25, 2015, 01:04:58 am by DidUknowiPwn
Yeah you can put any number you want but 4 would be a good number as there might be a chance for all 4 players to be in same room. Edit: Give the struct a targetname of player_teleport_point and then copy it for each new point
when launching the game it says "round_think" already defined