1 registered members (TipmyPip),
18,631
guests, and 7
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Swapping places with entity
[Re: immolat3]
#166974
11/12/07 20:53
11/12/07 20:53
|
Joined: Nov 2007
Posts: 3 Bulgaria,Sofia
BulgarRising
Guest
|
Guest
Joined: Nov 2007
Posts: 3
Bulgaria,Sofia
|
you could try to do a diffrent trace : Code:
var temp1[3]; var temp2[3]; temp1.x = 512; // middle x pos of screen temp1.y = 384; // middle y pos of screen temp1.z = 1; // scan starting 1 quant infront of camera vec_set(temp2.x,temp1.x); temp2.z = 10000; // trace range infront of camera vec_for_screen(camera,temp1.x); // convert to world coords vec_for_screen(camera,temp1.y); c_trace(temp1.x,temp2.x,ignore_me + ignore_passable); if(you) { vec_set(temp1.x,my.x); vec_set(my.x,you.x); vec_set(you.x,temp1.x); }
You have to put that in your player function or in a function called by the player function. If you dont , my will become null for this code , and will give error,I think.
A new World is rising again.
|
|
|
Re: Swapping places with entity
[Re: BulgarRising]
#166976
11/13/07 20:32
11/13/07 20:32
|
Joined: Nov 2007
Posts: 3 Bulgaria,Sofia
BulgarRising
Guest
|
Guest
Joined: Nov 2007
Posts: 3
Bulgaria,Sofia
|
Probably because I made a mistake  correct this : Code:
vec_for_screen(camera,temp1.x); // convert to world coords vec_for_screen(camera,temp1.y);
With this : Code:
vec_for_screen(camera,temp1.x); // convert to world coords vec_for_screen(camera,temp2.x);
A new World is rising again.
|
|
|
Re: Swapping places with entity
[Re: BulgarRising]
#166977
11/13/07 20:49
11/13/07 20:49
|
Joined: Nov 2007
Posts: 73
immolat3
OP
Junior Member
|
OP
Junior Member
Joined: Nov 2007
Posts: 73
|
Thanks, but since I posted that I got it working. Below is the code: function TeleportGun() { var theTarget; vec_set(theTarget.x, vector(10000, 0, 0)); //shoots 10000 quants vec_rotate(theTarget.x, camera.pan); //shoots in the direction of the player c_trace(my.x, theTarget.x, ignore_me + scan_texture | ignore_passable | use_aabb ); // aabb works great here  if(str_cmpi(tex_name, "SQUARE.MDL") == 1) // if the entity hit is square.mdl { var tempX; // var tempY; // Gonna use these later! var tempZ; // tempX = your.x; // tempY = your.y; // Store old entity variables tempZ = your.z; // ent_create("square.mdl", my.x, null); // Create entity at player old position my.x = tempX; // my.y = tempY; // Move player to old entity position my.z = tempZ; // if (your) // if the entity hit still exists { ent_remove(your); // poof } } }
|
|
|
Re: Swapping places with entity
[Re: BulgarRising]
#166978
11/14/07 15:38
11/14/07 15:38
|
Joined: Nov 2007
Posts: 3 Bulgaria,Sofia
BulgarRising
Guest
|
Guest
Joined: Nov 2007
Posts: 3
Bulgaria,Sofia
|
In case someone wants to use the other script , I made another mistake , here is the solution... PS.: I havent used vec_for_screen lately so I forgot how it worked  the view has to be after the vector , not before... So , not tested , but this code should work now without errors. Code:
var temp1[3]; var temp2[3]; temp1.x = 512; // middle x pos of screen temp1.y = 384; // middle y pos of screen temp1.z = 1; // scan starting 1 quant infront of camera vec_set(temp2.x,temp1.x); temp2.z = 10000; // trace range infront of camera vec_for_screen(temp1.x,camera); // convert to world coords vec_for_screen(temp2.x,camera); c_trace(temp1.x,temp2.x,ignore_me + ignore_passable); if(you) { vec_set(temp1.x,my.x); vec_set(my.x,you.x); vec_set(you.x,temp1.x); }
A new World is rising again.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|