X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Fteleporters.qc;h=949f478fdd3c714e9ba3402416be4b182c348b7a;hb=97cbca4fc1745460133e1bcde48bbc02f7671a53;hp=04667f4cc228391eefab47954ab56695e99d3f10;hpb=3b934631926acf4b06d969dcd361a26a3073d2c8;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/triggers/teleporters.qc b/qcsrc/common/triggers/teleporters.qc index 04667f4cc..949f478fd 100644 --- a/qcsrc/common/triggers/teleporters.qc +++ b/qcsrc/common/triggers/teleporters.qc @@ -80,10 +80,9 @@ void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angle makevectors (to_angles); #ifdef SVQC - SELFPARAM(); 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) { @@ -93,7 +92,7 @@ void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angle RandomSelection_Init(); FOREACH_WORD(teleporter.noise, true, { - RandomSelection_Add(NULL, 0, it, 1, 1); + RandomSelection_AddString(it, 1, 1); }); thesound = RandomSelection_chosen_string; } @@ -104,7 +103,7 @@ void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angle 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 @@ -113,7 +112,7 @@ void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angle // 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; @@ -125,22 +124,20 @@ void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angle 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; + from = player.origin; + setorigin(player, to); + player.angles = to_angles; + player.velocity = to_velocity; + UNSET_ONGROUND(player); 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 + if(player == csqcplayer) // not for anything but the main player { - setproperty(VF_ANGLES, player.move_angles); - setproperty(VF_CL_VIEWANGLES, player.move_angles); + setproperty(VF_ANGLES, player.angles); + setproperty(VF_CL_VIEWANGLES, player.angles); } - - makevectors(player.move_angles); #endif #ifdef SVQC @@ -188,21 +185,21 @@ entity Simple_TeleportPlayer(entity teleporter, entity player) else { RandomSelection_Init(); - for(e = world; (e = find(e, targetname, teleporter.target)); ) + FOREACH_ENTITY_STRING(targetname, teleporter.target, { p = 1; if(STAT(TELEPORT_TELEFRAG_AVOID, player)) { #ifdef SVQC - locout = e.origin + '0 0 1' * (1 - player.mins.z - 24); + locout = it.origin + '0 0 1' * (1 - player.mins.z - 24); #elif defined(CSQC) - locout = e.origin + '0 0 1' * (1 - player.mins.z - 24); + locout = it.origin + '0 0 1' * (1 - player.mins.z - 24); #endif if(check_tdeath(player, locout, '0 0 0', '0 0 0')) p = 0; } - RandomSelection_Add(e, 0, string_null, (e.cnt ? e.cnt : 1), p); - } + RandomSelection_AddEnt(it, (it.cnt ? it.cnt : 1), p); + }); e = RandomSelection_chosen_ent; } @@ -214,35 +211,17 @@ entity Simple_TeleportPlayer(entity teleporter, entity player) makevectors(e.mangle); -#ifdef SVQC if(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 -#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; } @@ -251,12 +230,12 @@ void teleport_findtarget(entity this) { int n = 0; entity e; - for(e = world; (e = find(e, targetname, self.target)); ) + for(e = NULL; (e = find(e, targetname, this.target)); ) { ++n; #ifdef SVQC - if(e.movetype == MOVETYPE_NONE) - waypoint_spawnforteleporter(self, e.origin, 0); + if(e.move_movetype == MOVETYPE_NONE) + 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 @@ -265,37 +244,34 @@ void teleport_findtarget(entity this) 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 = NULL; } // now enable touch + settouch(this, Teleport_Touch); #ifdef SVQC - self.touch = Teleport_Touch; - - trigger_teleport_link(self); -#elif defined(CSQC) - self.move_touch = Teleport_Touch; + trigger_teleport_link(this); #endif } entity Teleport_Find(vector mi, vector ma) { - entity e; - for(e = world; (e = find(e, classname, "trigger_teleport")); ) - if(WarpZoneLib_BoxTouchesBrush(mi, ma, e, world)) - return e; - return world; + IL_EACH(g_teleporters, WarpZoneLib_BoxTouchesBrush(mi, ma, it, NULL), + { + return it; + }); + return NULL; } void WarpZone_PostTeleportPlayer_Callback(entity pl) @@ -314,10 +290,10 @@ void WarpZone_PostTeleportPlayer_Callback(entity pl) #ifdef SVQC if(!(pl.flags & FL_PROJECTILE)) #elif defined(CSQC) - if(!(pl.move_flags & BIT(15))) // FL_PROJECTILE + if(!(pl.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; + pl.owner = NULL; } if(IS_PLAYER(pl)) {