]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/portals.qc
Merge branch 'master' into Mario/stats_eloranking
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / portals.qc
index 99125a1a30c502d58e736cefbdfb59033d02a05a..6f128716365933599e271f4294ef295a779ef8b8 100644 (file)
@@ -1,12 +1,13 @@
 #include "portals.qh"
 
+#include <common/effects/all.qh>
 #include "g_hook.qh"
 #include "mutators/_mod.qh"
 #include "../common/constants.qh"
 #include "../common/deathtypes/all.qh"
 #include "../common/notifications/all.qh"
-#include "../common/triggers/teleporters.qh"
-#include "../common/triggers/subs.qh"
+#include "../common/mapobjects/teleporters.qh"
+#include "../common/mapobjects/subs.qh"
 #include "../common/util.qh"
 #include <common/weapons/_all.qh>
 #include "../lib/csqcmodel/sv_model.qh"
@@ -148,7 +149,7 @@ float Portal_TeleportPlayer(entity teleporter, entity player)
        tracebox(safe, player.mins - SAFENUDGE, player.maxs + SAFENUDGE, step, MOVE_NOMONSTERS, player);
        if(trace_startsolid)
        {
-               LOG_INFO("'safe' teleport location is not safe!\n");
+               LOG_INFO("'safe' teleport location is not safe!");
                // FAIL TODO why does this happen?
                return 0;
        }
@@ -156,7 +157,7 @@ float Portal_TeleportPlayer(entity teleporter, entity player)
        tracebox(safe, player.mins - SAFENUDGE, player.maxs + SAFENUDGE, to, MOVE_NOMONSTERS, player);
        if(trace_startsolid)
        {
-               LOG_INFO("trace_endpos in solid, this can't be!\n");
+               LOG_INFO("trace_endpos in solid, this can't be!");
                // FAIL TODO why does this happen? (reported by MrBougo)
                return 0;
        }
@@ -197,9 +198,9 @@ float Portal_TeleportPlayer(entity teleporter, entity player)
 
        // reset fade counter
        teleporter.portal_wants_to_vanish = 0;
-       teleporter.fade_time = time + autocvar_g_balance_portal_lifetime;
-       teleporter.health = autocvar_g_balance_portal_health;
-       teleporter.enemy.health = autocvar_g_balance_portal_health;
+       teleporter.fade_time = ((autocvar_g_balance_portal_lifetime >= 0) ? time + autocvar_g_balance_portal_lifetime : 0);
+       SetResourceExplicit(teleporter, RES_HEALTH, autocvar_g_balance_portal_health);
+       SetResourceExplicit(teleporter.enemy, RES_HEALTH, autocvar_g_balance_portal_health);
 
        return 1;
 }
@@ -215,7 +216,7 @@ float Portal_FindSafeOrigin(entity portal)
        if(!move_out_of_solid(portal))
        {
 #ifdef DEBUG
-               LOG_INFO("NO SAFE ORIGIN\n");
+               LOG_INFO("NO SAFE ORIGIN");
 #endif
                return 0;
        }
@@ -322,7 +323,6 @@ void Portal_Touch(entity this, entity toucher)
                                toucher.effects += EF_BLUE - EF_RED;
 }
 
-void Portal_Think(entity this);
 void Portal_MakeBrokenPortal(entity portal)
 {
        portal.skin = 2;
@@ -383,7 +383,7 @@ void Portal_Connect(entity teleporter, entity destination)
        destination.enemy = teleporter;
        Portal_MakeInPortal(teleporter);
        Portal_MakeOutPortal(destination);
-       teleporter.fade_time = time + autocvar_g_balance_portal_lifetime;
+       teleporter.fade_time = ((autocvar_g_balance_portal_lifetime >= 0) ? time + autocvar_g_balance_portal_lifetime : 0);
        destination.fade_time = teleporter.fade_time;
        teleporter.portal_wants_to_vanish = 0;
        destination.portal_wants_to_vanish = 0;
@@ -428,15 +428,15 @@ void Portal_Remove(entity portal, float killed)
        }
 }
 
-void Portal_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
+void Portal_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
 {
        if(deathtype == DEATH_TELEFRAG.m_id)
                return;
        if(attacker != this.aiment)
                if(IS_INDEPENDENT_PLAYER(attacker) || IS_INDEPENDENT_PLAYER(this.aiment))
                        return;
-       this.health -= damage;
-       if(this.health < 0)
+       TakeResource(this, RES_HEALTH, damage);
+       if(GetResource(this, RES_HEALTH) < 0)
                Portal_Remove(this, 1);
 }
 
@@ -473,7 +473,7 @@ void Portal_Think(entity this)
 
        fixedmakevectors(this.mangle);
 
-       FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+       FOREACH_CLIENT(IS_PLAYER(it), {
                if(it != o)
                        if(IS_INDEPENDENT_PLAYER(it) || IS_INDEPENDENT_PLAYER(o))
                                continue; // cannot go through someone else's portal
@@ -487,14 +487,14 @@ void Portal_Think(entity this)
                if(it.(weaponentity).hook)
                        Portal_Think_TryTeleportPlayer(this, it.(weaponentity).hook, g);
            }
-       ));
+       });
        this.solid = SOLID_TRIGGER;
        this.aiment = o;
 #endif
 
        this.nextthink = time;
 
-       if(time > this.fade_time)
+       if(this.fade_time && time > this.fade_time)
                Portal_Remove(this, 0);
 }
 
@@ -638,8 +638,8 @@ entity Portal_Spawn(entity own, vector org, vector ang)
        portal.portal_activatetime = time + 0.1;
        portal.takedamage = DAMAGE_AIM;
        portal.event_damage = Portal_Damage;
-       portal.fade_time = time + autocvar_g_balance_portal_lifetime;
-       portal.health = autocvar_g_balance_portal_health;
+       portal.fade_time = ((autocvar_g_balance_portal_lifetime >= 0) ? time + autocvar_g_balance_portal_lifetime : 0);
+       SetResourceExplicit(portal, RES_HEALTH, autocvar_g_balance_portal_health);
        setmodel(portal, MDL_PORTAL);
        portal.savemodelindex = portal.modelindex;
        setcefc(portal, Portal_Customize);