Telefrag gun help please :/
Moderator: InsideQC Admins
7 posts
• Page 1 of 1
Telefrag gun help please :/
I'm on my second attempt at making a telefrag gun.
This time I figured I'd adapt the self teleporter tutorial.
I got to the point where shooting the enemy twice would telefrag them, but I didnt want to have to be aiming at them the second time.
I just want to tag them, then be able to teleport to where they are at my leisure.
Any help?
Right now it just teleports me to exactly where I'm at, I dont see anything wrong, except maybe the engine doesnt keep track of the entity position after the frame has already checked it?
This time I figured I'd adapt the self teleporter tutorial.
I got to the point where shooting the enemy twice would telefrag them, but I didnt want to have to be aiming at them the second time.
I just want to tag them, then be able to teleport to where they are at my leisure.
- Code: Select all
void() W_FireTp =
{
local vector dir,org;
local entity t_ent;
dir = aim (self, 100000);
traceline (self.origin, self.origin + dir*2048, FALSE, self);
if(!self.tele_dropped)
{
t_ent = trace_ent; //records entity
if (t_ent.takedamage)
{
self.teledrop_dest = spawn(); //create a temp entity for location of Teleporter
self.tele_dropped = 1;
}
}
else
{
if(self.health <= 0) {
return;
}
self.teledrop_dest.origin = t_ent.origin; //records the entity location
self.teledrop_dest.mangle = self.angles;
spawn_tfog (self.teledrop_dest.origin);
makevectors (self.teledrop_dest.mangle);
org = self.teledrop_dest.origin;
spawn_tfog (org);
spawn_tdeath (org,self);
setorigin (self,self.teledrop_dest.origin);
self.angles = self.teledrop_dest.mangle;
self.fixangle = 1;
self.velocity = v_forward * 100;
self.teleport_time = time + 0.5; // Shorter teleport recovery time
self.flags = self.flags - self.flags & FL_ONGROUND;
self.tele_dropped = 0;
}
};
Any help?
Right now it just teleports me to exactly where I'm at, I dont see anything wrong, except maybe the engine doesnt keep track of the entity position after the frame has already checked it?
-

gnounc - Posts: 424
- Joined: Mon Apr 06, 2009 6:26 am
t_ent is not set (so world). Which means its teleporting you to '0 0 0', surely? If you get stuck, quake will move you back to the last location where you were not stuck, so basically back to where you were, so no difference in position overall.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
You sure about that?gnounc wrote:Works just fine now : )
If t_ent is global, then it means that all players, bots, whatever, will use the same one. This will work fine as long as there's only one Telefrag Gun in play, however, once there's more than one, everybody's telegun will go to the same spot. (Which will be the target that was tagged most recently).
To persitst this properly and not have this issue, t_ent should be stored on the player (or bot, etc) as a field. That way, each one can have it's own location. (Unless, of course, you'd rather they shared one, but I don't think that's the way you designed the thing.)
On a somewhat off-topic note, your code is rather disorganized and contains a lot of unnecessary stuff. Spawning the teledrop_dest entity and then later copying stuff from t_ent to it (only to then immediately copy it to self) is wasteful.
Rather, you should just set self.teledrop_dest to trace_ent. This will sove the problem of multiple teleguns coexisting properly (like I mentioned), simplify your code, and save memory.
Furthermore, if self.tele_dropped is true, there's no need to aim and traceline, so you should move that inside the if statement.
Finally, you might want to see what happen if you try to use it on shootable doors and switches. I don't know off-hand what'll happen, but it'll probably be bugged in some way.
- Karatorian
- Posts: 31
- Joined: Tue Aug 17, 2010 4:26 am
- Location: Rindge, NH, USA
You're absolutely correct in all regards.
My code was based off of the self teleport tutorial and I wanted to get it working before I cleaned it up, as I had posted the code I was
working on at the very second I decided I needed help.
I did make it a field, I just haven't done very much qc so I'm not great
at remembering wtf to call things.
Thank you though
My code was based off of the self teleport tutorial and I wanted to get it working before I cleaned it up, as I had posted the code I was
working on at the very second I decided I needed help.
I did make it a field, I just haven't done very much qc so I'm not great
at remembering wtf to call things.
Thank you though
-

gnounc - Posts: 424
- Joined: Mon Apr 06, 2009 6:26 am
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest