Page 1 of 2
Player inside cube
Posted: October 4th, 2010, 4:52 pm
by Moustache
Does anyone know how can you code a mod (script) so that a player can't leave a certain virtual cube?
Or how can you create it that a player can not cross a line between point A and B?
Then I can try to script the rest of the cube myself.
Re: Player inside cube
Posted: October 4th, 2010, 5:20 pm
by Pedsdude
You could make a cube out of player clip and then use scripting to make it solid and non-solid.
Re: Player inside cube
Posted: October 4th, 2010, 6:04 pm
by Moustache
Pedsdude wrote:You could make a cube out of player clip and then use scripting to make it solid and non-solid.
Thank you for your reply.
I don't know what you mean with "player clip".
Can you give an example or a link to a tutorial or something?
Re: Player inside cube
Posted: October 4th, 2010, 6:13 pm
by Rezil
Spawn a trigger radius. Check every frame if player is touching said trigger. If not, teleport back to trigger radius center. Not exactly a cube but will do the job.
Re: Player inside cube
Posted: October 4th, 2010, 6:18 pm
by Moustache
KillerSam wrote:Moustache wrote:Pedsdude wrote:You could make a cube out of player clip and then use scripting to make it solid and non-solid.
Thank you for your reply.
I don't know what you mean with "player clip".
Can you give an example or a link to a tutorial or something?
Peds was refering to a mapping technique where you use selectively passable invisible walls to control players.
If it's a mod, I assume you can create a cube from player co-ordinates and then script it so that the player gets returned to the cube if they leave (or suicide, w/e works best). I'm not sure how to do this though, but I know it to be possible.
Thank you for the explanation
I will try screwing around with some codes.
EDIT:
Rezil wrote:Spawn a trigger radius. Check every frame if player is touching said trigger. If not, teleport back to trigger radius center. Not exactly a cube but will do the job.
How can you make a trigger radius?
Re: Player inside cube
Posted: October 4th, 2010, 6:30 pm
by Rezil
Code: Select all
trig = Spawn( <classname>, <origin>, <flags>, <radius>, <height> )
classname: trigger_radius
origin: any point(keep in mind points in space are written like so: (x, y, z) with the brackets mandatory!)
flags: not sure what flags the trigger_radius has, check in Radiant.
radius: self-explanatory
height: how tall do you want the trigger to be.
Re: Player inside cube
Posted: October 4th, 2010, 8:34 pm
by Moustache
Hmm. I don't know if I can use that. Because that is a cylinder.
But maybe I can place a few columns on the side and create a wall with it.
Then it would look a bit like this (view from above):
OOOOOOO
O---------O
O---------O
O---------O
OOOOOOO
The O is a trigger radius and if you touch it you get pushed back, at least that is my theory

.
Or is there a better way to create this?
Re: Player inside cube
Posted: October 4th, 2010, 8:50 pm
by Rezil
Why do you need a cube? A sphere would be much better suited for keeping a player in a certain area.
Re: Player inside cube
Posted: October 4th, 2010, 10:05 pm
by Drofder2004
Take a quick look at how killtriggers worked in CoD2.
Pseudo:
If PLAYER X coordinates are between 500-600.
If PLAYER Y coordinates are between 200-300.
If PLAYER Z coordinates are between 0 -100.
You can now use that code and create a box with corners:
Bottom back left corner
(500, 200, 0)
Top front right corner
(600, 300, 100)
Re: Player inside cube
Posted: October 5th, 2010, 8:03 pm
by Moustache
K thank you all that worked
Put how can I prevent the players from leaving the cube?
Is there a way to push them back a bit instead of teleporting/killing them?
Re: Player inside cube
Posted: October 5th, 2010, 9:05 pm
by Soviet
You could use the finishPlayerDamage function, but it would be pretty complicated to do properly.
Code: Select all
if(players[i] istouching(trigger) && isalive(players[i]))
{
players[i].health = 1000000;
players[i].maxhealth = 1000000;
players[i] finishPlayerDamage(players[i], players[i], damage 0, "MOD_FALLING", "deserteaglegold_mp", origin, direction, "head", 0);
wait(0.05);
players[i].health = 100;
players[i].maxhealth = 100;
}
You would have to do some code similar to that for each side of the box. The tricky part would be getting it to push the player in the right direction. It would probably be possible by saving some variables, but I haven't paid close attention to the rest of this thread so I'm not exactly sure how you'd go about it.
Re: Player inside cube
Posted: October 5th, 2010, 9:18 pm
by Pedsdude
Maybe you could do a series of quick teleports which would make it seem like a push (even though it's not).
Re: Player inside cube
Posted: October 5th, 2010, 9:35 pm
by Drofder2004
Soviets method will work, but you need some knowledg in Maths.
The directionial vector is simple in theory (player origin forward to centre of cube), but you need to now how to use the vector commands to do this.
I don't know of the top of my head and haven't the time or effort that is required to work it out.
Re: Player inside cube
Posted: October 5th, 2010, 9:39 pm
by Soviet
Peds' method was used in nm_cure. Since there are no fastfiles for CoD1 you could download it and take a look at how Nightmare did it. He used it for a conveyor belt I believe.
Re: Player inside cube
Posted: October 6th, 2010, 7:02 am
by Moustache
Isn't it possible to set a center of the cube and let the direction be placed towards it.
The origin would be a bit harder I guess. But I will give it a try.
Thanks all for the help and info
