Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (NewbieZorro, TipmyPip, 1 invisible), 19,045 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Swapping places with entity #166970
11/11/07 21:21
11/11/07 21:21
Joined: Nov 2007
Posts: 73
I
immolat3 Offline OP
Junior Member
immolat3  Offline OP
Junior Member
I

Joined: Nov 2007
Posts: 73
hello, if you read my previous post you know I am trying to create a teleport gun. basically i need to figure out how to make it so if i target a certain type of object in the game i switch places with it...and i need it as simple and dirty as possible.

currently i can easily teleport by changing the my.x, my.y, etc. variables, but im having issues with c_trace.

Also, i am basically building this game off of the default engine script files for the FPS game.

Re: Swapping places with entity [Re: immolat3] #166971
11/11/07 21:43
11/11/07 21:43
Joined: Mar 2005
Posts: 564
/www/europe/ germany/index.php
TSG_Torsten Offline

User
TSG_Torsten  Offline

User

Joined: Mar 2005
Posts: 564
/www/europe/ germany/index.php
c_trace(my.x,target_pos.x,ignore_me);
if(you) // An entity was hit?
{
vec_set(temp.x,my.x); // Store position of the player
vec_set(my.x,you.x); // Setting player to hitten entity
vec_set(you.x,temp.x); // Setting you to the stored player position
}

The target_pos is the position you have to trace (the point the weapon has aimed).

I hope this could help you

Regards
TSGames

Re: Swapping places with entity [Re: TSG_Torsten] #166972
11/11/07 21:48
11/11/07 21:48
Joined: Nov 2007
Posts: 73
I
immolat3 Offline OP
Junior Member
immolat3  Offline OP
Junior Member
I

Joined: Nov 2007
Posts: 73
Thanks for your reply, but where does it send the c_trace from? Right now I put that code you just pasted on when I press my "right_mouse" and it doesn't do anything. Is there some pre-reqs I am missing? Sorry, I am a complete novice to Lite-C and GS7.

Re: Swapping places with entity [Re: immolat3] #166973
11/11/07 23:24
11/11/07 23:24
Joined: Nov 2007
Posts: 73
I
immolat3 Offline OP
Junior Member
immolat3  Offline OP
Junior Member
I

Joined: Nov 2007
Posts: 73
Actually i used the SCAN_TEXTURE and tex_name always show it as hitting the floor under me, do you have any idea why?

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 Offline
Guest
BulgarRising  Offline
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] #166975
11/12/07 21:00
11/12/07 21:00
Joined: Nov 2007
Posts: 73
I
immolat3 Offline OP
Junior Member
immolat3  Offline OP
Junior Member
I

Joined: Nov 2007
Posts: 73
hmm thanks for the reply, i tried that and i get a vector expected error

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 Offline
Guest
BulgarRising  Offline
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
I
immolat3 Offline OP
Junior Member
immolat3  Offline OP
Junior Member
I

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 Offline
Guest
BulgarRising  Offline
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.

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1