|
1 registered members (Grant),
999
guests, and 2
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Players respawn [splitscreen]
[Re: 3run]
#349276
12/05/10 17:37
12/05/10 17:37
|
Joined: Feb 2010
Posts: 886
Random
User
|
User
Joined: Feb 2010
Posts: 886
|
Try it like this;
ent_create(Model_mdl,vector(random(200),random(200),0),move);
Orange; Create youre model
Purple; The Vector
Red; The randomly setting
Blue; The function.
|
|
|
Re: Players respawn [splitscreen]
[Re: 3run]
#349277
12/05/10 17:49
12/05/10 17:49
|
Joined: Dec 2008
Posts: 605 47°19'02.40" N 8°32'54.67" E...
hopfel
User
|
User
Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67" E...
|
1. The easiest way, you do define a position like:
var random_var = random(360); my.x = cos(random_var) * distance_to_player; my.y = sin(random_var) * distance_to_player;
And then make a scan on that point, if there isn't something in the way, create the player there, if not, try again.
2. I would make a function without global pointers you can create players with. It's a bunch of work, but the most comfortable solution, because you don't have to take attention, when you have to create and remove the player. (something like that is the best way to create enemies too)
Hilf mir, dir zu helfen!
|
|
|
Re: Players respawn [splitscreen]
[Re: Random]
#349278
12/05/10 17:54
12/05/10 17:54
|
Joined: Feb 2005
Posts: 3,687 Hessen, Germany
Tempelbauer
Expert
|
Expert
Joined: Feb 2005
Posts: 3,687
Hessen, Germany
|
1 --> How can I define places for players to respawn, so when one of the players die, he will respawn on the most far place from the second player. this is quite simple: 1.) define an array of respawn-points (vectors of the xyz-coordinates) 2.) take the position of player 2 and calculate the distance to all respawn-coordinates (using vec_dist, look in the manual) 3.) choose the respawn-point with the highest distance
|
|
|
Re: Players respawn [splitscreen]
[Re: Tempelbauer]
#349291
12/05/10 19:33
12/05/10 19:33
|
Joined: May 2009
Posts: 5,365 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,365
Caucasus
|
Random  dude, but that will create player randomly for 200 quants from the nullvector))) But thank you for such detailed explanation  I appreciate it. hopfel I got your idea with 'no pointers', that a good and simple solution, why I didn't even think about it myself? But what you think about weapons and cameras (weapon 1 and weapon2 and as well camera1 and camera2)? Tempelbauer, I thought about using 'vec_dist' too, but I've faced problem with choosing the highest result... Any ideas how can I do that?
|
|
|
Re: Players respawn [splitscreen]
[Re: 3run]
#349293
12/05/10 19:46
12/05/10 19:46
|
Joined: Feb 2010
Posts: 886
Random
User
|
User
Joined: Feb 2010
Posts: 886
|
Maby like this; function respawn() { var i=integer(random(3)); switch(i) { case 0: ent_create(Model_mdl,vector(200,200,0),move)); case 1: ent_create(Model_mdl,vector(400,400,0),move)); case 2: ent_create(Model_mdl,vector(800,800,0),move)); } wait(1); }So when a player dies should it respaw in one of those two cases. Of course you can make more cases. And again randomly 
|
|
|
Re: Players respawn [splitscreen]
[Re: 3run]
#349294
12/05/10 19:56
12/05/10 19:56
|
Joined: Feb 2005
Posts: 3,687 Hessen, Germany
Tempelbauer
Expert
|
Expert
Joined: Feb 2005
Posts: 3,687
Hessen, Germany
|
you could use 2 vars for the result to determine the target: var index=-1, highest = 0 for(iterate throu respawnpoints-array) { if(vec_dist(player2.x, respawnpoints[i])>highest) { index = i highest = vec_dist(player2.x, respawnpoints[i]) } } if(index>=0) { most_far_respawnpoint = respawnpoints[index] } hopfels idea is good if you dont want to have fixed respawn points. after calculating the respawn point, you can re-create or re-translate the player to this position and adjust the camera using the player´s coordinates. but beware: if you have a non planar bottom or a more complex level (like a multi-floor building) you should calculate also the z-coordinate (by using c_trace from the random-generated-z-value to the ground). but i would use (many) fixed respawn points instead a free random position, because if you choose the random-values wrong, your player could respawn at a bad position (like outside the level) So when a player dies should it respaw in one of those two cases.
disagree. he will respawn everytime at vector(800,800,0) and sometimes on more places
Last edited by Tempelbauer; 12/05/10 20:08.
|
|
|
Re: Players respawn [splitscreen]
[Re: Tempelbauer]
#349297
12/05/10 20:37
12/05/10 20:37
|
Joined: May 2009
Posts: 5,365 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,365
Caucasus
|
because if you choose the random-values wrong, your player could respawn at a bad position (like outside the level) I know. That's why I need fixed respawn points  Tell me more about recreating, cause I defined health, and while loop (for each of players) determinate itself when players health under zero, I can't just re-translate player to new position, cause he is dead  Do I need to set dead player's pointer to NULL and then recreate it again and define pointer to it again? Tell me more about this part in your script:
for(iterate throu respawnpoints-array)
{
///
}
Cause I never used to work with 'FOR'... Random, dude, as I see, function 'random()' is one of your favorites 
|
|
|
Re: Players respawn [splitscreen]
[Re: 3run]
#349299
12/05/10 20:55
12/05/10 20:55
|
Joined: Dec 2008
Posts: 605 47°19'02.40" N 8°32'54.67" E...
hopfel
User
|
User
Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67" E...
|
But what you think about weapons and cameras (weapon 1 and weapon2 and as well camera1 and camera2)? You can set a var on the Entitypointer in his function, then you can access your playerentity with another function. Something like:
var player1;
function player()
{
ENTITY* my_ent = ent_create(...);
if(*I'm player one*)
player1 = my_ent;
...
}
function main()
{
...
if(((ENTITY*)player1))
camera.z = ((ENTITY*)player1).z;
...
}
Oh, and I would put the weapencode in the playerfunction too. Or like:
function weapon(ENTITY* my_ent)
{
...
}
function player()
{
ENTITY* my_ent = ent_create(...);
player1 = my_ent;
weapon(my_ent);
...
}
Then you dont have to worry about health etc. because they're away too, just remove the entity and terminate all his functions. ^^
Hilf mir, dir zu helfen!
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|