Inside3D tutorials.
Created By: | Ursader |
eMail: | ursader@flash.net |
Difficulty Scale: | Easy |
void() teleport_touch = { local entity t; local vector org; /* This is added: */ if (other.teleport_time > time) return; // Can't teleport before time is up if ( (other.classname != "missile") && (other.classname != "grenade") && (other.classname != "player") && (other.classname != "spike") && (other.classname != "gib") && (other.classname != "weapon_supershotgun") && (other.classname != "weapon_grenadelauncher") && (other.classname != "weapon_supernailgun") && (other.classname != "weapon_nailgun") && (other.classname != "weapon_lightning") && (other.classname != "weapon_rocketlauncher") && (other.classname != "") ) return; /* ^-- Keeps things that spawn near the teleporter from teleporting.. This is a BAD thing to have happen :( If you use this in a TC or something, just add any new classnames you make up there.. */ /* That parts done */ if (self.targetname) { if (self.nextthink < time) { return; // not fired yet } } // When you find this, comment it out. Allows things other than "player" // to pass through... /* if (self.spawnflags & PLAYER_ONLY) { if (other.classname != "player") return; } */ // only teleport living creatures // if (other.health <= 0 || other.solid != SOLID_SLIDEBOX) // return; // Allowing teleporting of non-living objects! if ((other.health <= 0) && (other.solid == SOLID_NOT)) return; if (other.classname == "trigger_teleport") return; // Done.. SUB_UseTargets (); // put a tfog where the player was if (other.classname == "player") spawn_tfog (other.origin); t = find (world, targetname, self.target); if (!t) objerror ("couldn't find target"); // spawn a tfog flash in front of the destination makevectors (t.mangle); org = t.origin + 32 * v_forward; /* Lets not allow telefragging with nails/rockets/grenades :) */ if (other.classname == "player") { spawn_tfog (org); spawn_tdeath(t.origin, other); } /* Done.. */ // move the player and lock him down for a little while if (!other.health) { other.origin = t.origin; /* For right speed and angle of teleported things.. */ // other.velocity = (v_forward * other.velocity_x) + (v_forward * other.velocity_y); // other.velocity = v_forward * 600; if (other.velocity_y < 0) other.velocity_y = other.velocity_y * -1; other.fixangle = 1; // turn this way immediately other.teleport_time = time + 0.7; other.angles = t.mangle; /* Yadda, Yadda.. */ return; } setorigin (other, t.origin); other.angles = t.mangle; if (other.classname == "player") { other.fixangle = 1; // turn this way immediately other.teleport_time = time + 0.7; if (other.flags & FL_ONGROUND) other.flags = other.flags - FL_ONGROUND; other.velocity = v_forward * 300; } other.flags = other.flags - other.flags & FL_ONGROUND; };
void() trigger_teleport = { local vector o; InitTrigger (); self.flags = self.flags | FL_ITEM; // Make big.. BIG!! :) (add this) self.touch = teleport_touch; // find the destination if (!self.target) objerror ("no target"); self.use = teleport_use; if (!(self.spawnflags & SILENT)) { precache_sound ("ambience/hum1.wav"); o = (self.mins + self.maxs)*0.5; ambientsound (o, "ambience/hum1.wav",0.5 , ATTN_STATIC); } };Step 4