Choose random player?

[FP] OBV10U3_NINJA

L1: Registered
Oct 20, 2015
9
1
I'm currently working on a trade map for the FirePowered community, and right now I'm making the admin room. Inside the admin room is a few controls, and I want one of them, when pressed, to fire a giant laser at one of the players on the map, with the player being chosen at random. And yes, the chance of the admin getting shot is fine, since that in itself would be hilarious.

I already have synthesized the sounds, but I would both like to know how to get the map to choose a player and how to make the laser object (which I think would be something like one of the env_beam entities maybe).

Any help would be greatly appreciated :D
If you are curious about the map, go to 98.213.220.95 - And if the map is not up, do an !rtv for it.
 

worMatty

Repacking Evangelist
aa
Jul 22, 2014
1,257
999
Welcome to our community!

I have experience making Deathrun maps, and know a lot about logic. I will try to help you as best I can.

You have two entities to choose from: env_laser and env_beam.

env_laser will not travel through brushes so it needs to be in the same room as your target. Or you could put an env_laser in every room but this will look a bit strange because people will see lasers just hitting walls.

env_beam will actually travel through brushes. If it travels through a dynamic brush (door, func_brush), it will still damage its target but if it travels through a solid brush (func_detail, world brush), it will do no damage to its target so you would need to simulate the damage using a trigger_hurt, or teleport the player into the room that contains the beam entity.

In order to use a player as a beam target you need to give them a targetname so the beam knows what to hit. A targetname is just the name of the entity. When you name a door, respawn room, resupply locker or any other entity, you are giving it a targetname. You'd use the targetname in the Ending Entity field of the env_beam. Players don't have a targetname to begin with. There are two ways to go about this and they determine how you set it all up so pay close attention:
  1. You can give everyone the same targetname, using a trigger_multiple in spawn. When you fire the beam, it will pick one player at random. This is very simple but is problematic because the player needs to be in the same room as the beam source in order to get hurt. If your map is composed of multiple rooms, this method will not work.
  2. Put a trigger_multiple brush over the whole map and give it an output to set a targetname on only one player by using OnStartTouch and ticking the 'Fire once only' box. When the trigger is enabled, one of the players inside it will receive the targetname. You can then teleport the player in to the laser room using a point_teleport, or if using an env_beam to hit him through walls, simulate the damage by placing a trigger_hurt over the whole map that uses a filter_activator_name to limit the damage to entities with the targetname you chose. Players keep the targetname across rounds and between lives so you would need to remove it the next time they spawn by using a trigger in the spawn room to set their targetname to something else like player.
This is what the output of your trigger brush would look like in either situation:

SUndB5Y.png