X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Fteleporters.qc;h=90a426e630d8e3e0b46dfd271d454470e9216689;hb=a0ed889293e46f6068423089f2a7f24c7f494d37;hp=1f0c00e5e8e2d36211cffe95d5bd1b26390b7771;hpb=43eba8ca70f00458db385630f86009f6d7fa849a;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/triggers/teleporters.qc b/qcsrc/common/triggers/teleporters.qc index 1f0c00e5e..90a426e63 100644 --- a/qcsrc/common/triggers/teleporters.qc +++ b/qcsrc/common/triggers/teleporters.qc @@ -3,40 +3,44 @@ #if defined(CSQC) #elif defined(MENUQC) #elif defined(SVQC) - #include "../../lib/warpzone/common.qh" - #include "../../lib/warpzone/util_server.qh" - #include "../../lib/warpzone/server.qh" + #include + #include + #include #include "../constants.qh" #include "../triggers/subs.qh" #include "../util.qh" - #include "../../server/weapons/csqcprojectile.qh" - #include "../../server/autocvars.qh" - #include "../../server/constants.qh" - #include "../../server/defs.qh" + #include + #include + #include + #include #include "../deathtypes/all.qh" #include "../turrets/sv_turrets.qh" #include "../vehicles/all.qh" #include "../mapinfo.qh" - #include "../../server/anticheat.qh" + #include #endif -#ifdef SVQC - float check_tdeath(entity player, vector org, vector telefragmin, vector telefragmax) { - if (IS_PLAYER(player) && player.health >= 1) + if (IS_PLAYER(player) && !IS_DEAD(player)) { TDEATHLOOP(org) { + #ifdef SVQC if (!(teamplay && autocvar_g_telefrags_teamplay && head.team == player.team)) + #endif if(IS_PLAYER(head)) - if(head.health >= 1) + if(!IS_DEAD(head)) return 1; } } return 0; } +#ifdef SVQC + +void trigger_teleport_link(entity this); + void tdeath(entity player, entity teleporter, entity telefragger, vector telefragmin, vector telefragmax) { TDEATHLOOP(player.origin) @@ -61,8 +65,10 @@ void spawn_tdeath(vector v0, entity e, vector v) tdeath(e, e, e, '0 0 0', '0 0 0'); } +#endif + void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity, vector telefragmin, vector telefragmax, float tflags) -{SELFPARAM(); +{ entity telefragger; vector from; @@ -73,25 +79,40 @@ void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angle makevectors (to_angles); +#ifdef SVQC if(player.teleportable == TELEPORT_NORMAL) // don't play sounds or show particles for anything that isn't a player, maybe change later to block only observers { - if(self.pushltime < time) // only show one teleport effect per teleporter per 0.2 seconds, for better fps + if(teleporter.pushltime < time) // only show one teleport effect per teleporter per 0.2 seconds, for better fps { if(tflags & TELEPORT_FLAG_SOUND) - sound (player, CH_TRIGGER, SND_TELEPORT, VOL_BASE, ATTEN_NORM); + { + string thesound = SND(TELEPORT); + if(teleporter.noise != "") + { + RandomSelection_Init(); + FOREACH_WORD(teleporter.noise, true, + { + RandomSelection_Add(NULL, 0, it, 1, 1); + }); + thesound = RandomSelection_chosen_string; + } + _sound (player, CH_TRIGGER, thesound, VOL_BASE, ATTEN_NORM); + } if(tflags & TELEPORT_FLAG_PARTICLES) { Send_Effect(EFFECT_TELEPORT, player.origin, '0 0 0', 1); Send_Effect(EFFECT_TELEPORT, to + v_forward * 32, '0 0 0', 1); } - self.pushltime = time + 0.2; + teleporter.pushltime = time + 0.2; } } +#endif // Relocate the player // assuming to allows PL_MIN to PL_MAX box and some more +#ifdef SVQC from = player.origin; - setorigin (player, to); + setorigin(player, to); player.oldorigin = to; // don't undo the teleport by unsticking player.angles = to_angles; player.fixangle = true; @@ -101,15 +122,35 @@ void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angle makevectors(player.angles); Reset_ArcBeam(player, v_forward); UpdateCSQCProjectileAfterTeleport(player); + UpdateItemAfterTeleport(player); +#elif defined(CSQC) + from = player.move_origin; + player.move_origin = to; + player.move_angles = to_angles; + player.move_velocity = to_velocity; + player.move_flags &= ~FL_ONGROUND; + player.iflags |= IFLAG_TELEPORTED | IFLAG_V_ANGLE | IFLAG_ANGLES; + player.csqcmodel_teleported = 1; + player.v_angle = to_angles; + + if(player.isplayermodel) // not for anything but the main player + { + setproperty(VF_ANGLES, player.move_angles); + setproperty(VF_CL_VIEWANGLES, player.move_angles); + } + makevectors(player.move_angles); +#endif + +#ifdef SVQC if(IS_PLAYER(player)) { if(tflags & TELEPORT_FLAG_TDEATH) - if(player.takedamage && player.deadflag == DEAD_NO && !g_race && !g_cts && (autocvar_g_telefrags || (tflags & TELEPORT_FLAG_FORCE_TDEATH))) + if(player.takedamage && !IS_DEAD(player) && !g_race && !g_cts && (autocvar_g_telefrags || (tflags & TELEPORT_FLAG_FORCE_TDEATH))) tdeath(player, teleporter, telefragger, telefragmin, telefragmax); // player no longer is on ground - player.flags &= ~FL_ONGROUND; + UNSET_ONGROUND(player); // reset tracking of oldvelocity for impact damage (sudden velocity changes) player.oldvelocity = player.velocity; @@ -119,7 +160,7 @@ void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angle { player.pusher = teleporter.owner; player.pushltime = time + autocvar_g_maxpushtime; - player.istypefrag = player.BUTTON_CHAT; + player.istypefrag = PHYS_INPUT_BUTTON_CHAT(player); } else { @@ -129,6 +170,7 @@ void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angle player.lastteleporttime = time; } +#endif } entity Simple_TeleportPlayer(entity teleporter, entity player) @@ -148,9 +190,13 @@ entity Simple_TeleportPlayer(entity teleporter, entity player) for(e = world; (e = find(e, targetname, teleporter.target)); ) { p = 1; - if(autocvar_g_telefrags_avoid) + if(STAT(TELEPORT_TELEFRAG_AVOID, player)) { + #ifdef SVQC locout = e.origin + '0 0 1' * (1 - player.mins.z - 24); + #elif defined(CSQC) + locout = e.origin + '0 0 1' * (1 - player.mins.z - 24); + #endif if(check_tdeath(player, locout, '0 0 0', '0 0 0')) p = 0; } @@ -159,58 +205,84 @@ entity Simple_TeleportPlayer(entity teleporter, entity player) e = RandomSelection_chosen_ent; } +#ifdef SVQC if(!e) { sprint(player, "Teleport destination vanished. Sorry... please complain to the mapper.\n"); } +#elif defined(CSQC) + if(!e) { LOG_INFO("Teleport destination could not be found from CSQC.\n"); } +#endif makevectors(e.mangle); +#ifdef SVQC if(e.speed) - if(vlen(player.velocity) > e.speed) + if(vdist(player.velocity, >, e.speed)) player.velocity = normalize(player.velocity) * max(0, e.speed); +#elif defined(CSQC) + if(e.speed) + if(vdist(player.move_velocity, >, e.speed)) + player.move_velocity = normalize(player.move_velocity) * max(0, e.speed); +#endif - if(autocvar_g_teleport_maxspeed) - if(vlen(player.velocity) > autocvar_g_teleport_maxspeed) - player.velocity = normalize(player.velocity) * max(0, autocvar_g_teleport_maxspeed); +#ifdef SVQC + if(STAT(TELEPORT_MAXSPEED, player)) + if(vdist(player.velocity, >, STAT(TELEPORT_MAXSPEED, player))) + player.velocity = normalize(player.velocity) * max(0, STAT(TELEPORT_MAXSPEED, player)); +#elif defined(CSQC) + if(STAT(TELEPORT_MAXSPEED, player)) + if(vdist(player.move_velocity, >, STAT(TELEPORT_MAXSPEED, player))) + player.move_velocity = normalize(player.move_velocity) * max(0, STAT(TELEPORT_MAXSPEED, player)); +#endif +#ifdef SVQC locout = e.origin + '0 0 1' * (1 - player.mins.z - 24); + TeleportPlayer(teleporter, player, locout, e.mangle, v_forward * vlen(player.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER); +#elif defined(CSQC) + locout = e.origin + '0 0 1' * (1 - player.mins.z - 24); + + TeleportPlayer(teleporter, player, locout, e.mangle, v_forward * vlen(player.move_velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER); +#endif return e; } -void teleport_findtarget () -{SELFPARAM(); +void teleport_findtarget(entity this) +{ + int n = 0; entity e; - float n; - - n = 0; - for(e = world; (e = find(e, targetname, self.target)); ) + for(e = world; (e = find(e, targetname, this.target)); ) { ++n; +#ifdef SVQC if(e.movetype == MOVETYPE_NONE) - waypoint_spawnforteleporter(self, e.origin, 0); + waypoint_spawnforteleporter(this, e.origin, 0); if(e.classname != "info_teleport_destination") LOG_INFO("^3MAPPER ERROR: teleporter does target an invalid teleport destination entity. Angles will not work.\n"); +#endif } if(n == 0) { // no dest! - objerror ("Teleporter with nonexistant target"); + objerror (this, "Teleporter with nonexistant target"); return; } else if(n == 1) { // exactly one dest - bots love that - self.enemy = find(e, targetname, self.target); + this.enemy = find(e, targetname, this.target); } else { // have to use random selection every single time - self.enemy = world; + this.enemy = world; } // now enable touch - self.touch = Teleport_Touch; + settouch(this, Teleport_Touch); +#ifdef SVQC + trigger_teleport_link(this); +#endif } entity Teleport_Find(vector mi, vector ma) @@ -223,27 +295,33 @@ entity Teleport_Find(vector mi, vector ma) } void WarpZone_PostTeleportPlayer_Callback(entity pl) -{SELFPARAM(); +{ +#ifdef SVQC makevectors(pl.angles); Reset_ArcBeam(pl, v_forward); UpdateCSQCProjectileAfterTeleport(pl); - { - WITH(entity, self, pl, anticheat_fixangle()); - } + UpdateItemAfterTeleport(pl); + if (IS_PLAYER(pl)) anticheat_fixangle(pl); +#endif // "disown" projectiles after teleport if(pl.owner) if(pl.owner == pl.realowner) { + #ifdef SVQC if(!(pl.flags & FL_PROJECTILE)) + #elif defined(CSQC) + if(!(pl.move_flags & BIT(15))) // FL_PROJECTILE + #endif LOG_INFO("A non-projectile got through a warpzone and its owner cleared. It's a ", pl.classname, ".\n"); pl.owner = world; } if(IS_PLAYER(pl)) { // reset tracking of oldvelocity for impact damage (sudden velocity changes) + #ifdef SVQC pl.oldvelocity = pl.velocity; + #endif // reset teleport time tracking too (or multijump can cause insane speeds) pl.lastteleporttime = time; } } -#endif