|
|
Step 1
In this lesson we will try to create a self teleporter.
This is is made by editing the weapons.qc file, and the defs.qc file
(Just like the MOTD lesson) I suggest we edit the weapons.qc file first, so open it up.
Step 2
Now, the first this you'll see, is a lot of viod functions.
We're gonna add a few of those, just like i have done under.
The added ones are commented.
/*
*/
void (entity targ, entity inflictor, entity attacker, float damage) T_Damage;
void () player_run;
void(entity bomb, entity attacker, float rad, entity ignore) T_RadiusDamage;
void(vector org, vector vel, float damage) SpawnBlood;
void() SuperDamageSound;
void() DropTeleport; //Add this
void() Teleport_to_drop; //Add this
void (vector org) spawn_tfog; //Add this
void (vector org, entity death_owner) spawn_tdeath; //Add this
Step 3
Ok, now what we have to do, is to add the teleport functions. Search for "ImpulseCommands" and place the
text shown below, just over the the impulse commands (The beginning of the impulse list is shown
below in blue, just so that you'll manage to place everything right :)
/*
==========
Self Teleporter
==========
*/
void() DropTeleport = //Will drop location for The destination
{
if(!self.tele_dropped) {
self.teledrop_dest = spawn(); //create a temp entity for location of Teleporter
}
self.teledrop_dest.origin = self.origin; //records the location
self.teledrop_dest.mangle = self.angles;
self.tele_dropped = 1;
dprint("Teleport destination dropped.");
};
void() Teleport_to_drop =
{ //This will Teleport you to the Teleport Location temp entity that was recorded above
local vector org;
if(!self.tele_dropped) {
dprint("No destination dropped.");
return;
}
if(self.health <= 0) {
return;
}
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;
};
/*
============
ImpulseCommands
============
Step 4
Now scroll down just a little bit, under Impulse Commands, and before self.impulse = 0;
add(add is red) these lines:
if (self.impulse == 14)
DropTeleport ();
if (self.impulse == 15)
Teleport_to_drop ();
self.impulse = 0;
Step 5
Now, the last step is to edit the defs.qc file, a thing wich is quite easy.Just open it, and
scroll down all the way to the end, then insert
.entity teledrop_dest;
.float tele_dropped;
(They are going to be the 2 very last lines in the defs.qc file!)
Step 6
And that's it! Compile it, and load it up the usual way. And remember to bind the impulses to a
key! That makes it alot easier to get away from a beeing killed!
|