Player inside cube

Have a question about modding, modelling or skinning? Have a tutorial to post? Post here!

Moderator: Core Staff

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Player inside cube

Post by Moustache » October 4th, 2010, 4:52 pm

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.

Pedsdude
Site Admin
Site Admin
Posts: 15909
Joined: October 15th, 2004, 7:18 pm
Location: UK

Re: Player inside cube

Post by Pedsdude » October 4th, 2010, 5:20 pm

You could make a cube out of player clip and then use scripting to make it solid and non-solid.
Image
Image

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: Player inside cube

Post by Moustache » October 4th, 2010, 6:04 pm

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?

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: Player inside cube

Post by Rezil » October 4th, 2010, 6:13 pm

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.
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: Player inside cube

Post by Moustache » October 4th, 2010, 6:18 pm

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?

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: Player inside cube

Post by Rezil » October 4th, 2010, 6:30 pm

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.
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: Player inside cube

Post by Moustache » October 4th, 2010, 8:34 pm

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?

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: Player inside cube

Post by Rezil » October 4th, 2010, 8:50 pm

Why do you need a cube? A sphere would be much better suited for keeping a player in a certain area.
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Player inside cube

Post by Drofder2004 » October 4th, 2010, 10:05 pm

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)
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: Player inside cube

Post by Moustache » October 5th, 2010, 8:03 pm

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?

Soviet
Core Staff
Core Staff
Posts: 7760
Joined: April 23rd, 2005, 9:12 pm
Location: Plano, Texas
Contact:

Re: Player inside cube

Post by Soviet » October 5th, 2010, 9:05 pm

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.
Image
ImageImageImage
Image
"Zaitsev is a cunt." - Pedsdude

Pedsdude
Site Admin
Site Admin
Posts: 15909
Joined: October 15th, 2004, 7:18 pm
Location: UK

Re: Player inside cube

Post by Pedsdude » October 5th, 2010, 9:18 pm

Maybe you could do a series of quick teleports which would make it seem like a push (even though it's not).
Image
Image

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Player inside cube

Post by Drofder2004 » October 5th, 2010, 9:35 pm

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.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Soviet
Core Staff
Core Staff
Posts: 7760
Joined: April 23rd, 2005, 9:12 pm
Location: Plano, Texas
Contact:

Re: Player inside cube

Post by Soviet » October 5th, 2010, 9:39 pm

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.
Image
ImageImageImage
Image
"Zaitsev is a cunt." - Pedsdude

Moustache
CJ Worshipper
CJ Worshipper
Posts: 476
Joined: August 18th, 2008, 9:30 am

Re: Player inside cube

Post by Moustache » October 6th, 2010, 7:02 am

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 :mrgreen:

Post Reply

Who is online

Users browsing this forum: No registered users and 26 guests