]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix g_nades_ice_explode 1 and g_nades_darkness_explode 1 spamming div by 0 warnings... terencehill/nade_timer_fix 1495/head
authorterencehill <piuntn@gmail.com>
Fri, 18 Apr 2025 21:23:43 +0000 (23:23 +0200)
committerterencehill <piuntn@gmail.com>
Fri, 18 Apr 2025 21:34:31 +0000 (23:34 +0200)
Regarding ice.qc and darknes.qc the only functional change is the addition of `timer.nade_lifetime = this.nade_lifetime;`,
the remaining changes are cleanups to make the code more intuitive and readable

qcsrc/common/mutators/mutator/nades/nade/darkness.qc
qcsrc/common/mutators/mutator/nades/nade/ice.qc
qcsrc/common/mutators/mutator/nades/sv_nades.qc
qcsrc/common/mutators/mutator/nades/sv_nades.qh

index 2f5c135113a5da08a5bd9e4d72ef7a543cbd8d35..b9536d527d54812ec7e416554bb60f7eed7209d0 100644 (file)
@@ -77,8 +77,7 @@ void nade_darkness_boom(entity this)
        setorigin(fountain, fountain.origin);
        setthink(fountain, nade_darkness_think);
        fountain.nextthink = time;
-       fountain.ltime = time + autocvar_g_nades_darkness_time;
-       fountain.pushltime = fountain.wait = fountain.ltime;
+       fountain.pushltime = fountain.wait = fountain.ltime = time + autocvar_g_nades_darkness_time;
        fountain.team = this.team;
        set_movetype(fountain, MOVETYPE_TOSS);
        fountain.projectiledeathtype = DEATH_NADE.m_id;
@@ -97,7 +96,8 @@ void nade_darkness_boom(entity this)
                timer.glowmod = this.glowmod;
                setthink(timer, nade_timer_think);
                timer.nextthink = time;
-               timer.wait = fountain.ltime;
+               timer.wait = fountain.wait;
+               timer.nade_lifetime = this.nade_lifetime;
                timer.owner = fountain;
                timer.skin = 10;
        }
index 2d679fad000bf00ba80b7428e9a6023fd7db7f8c..27c7cfc1a230267eff9f3edc374b50eef71b454e 100644 (file)
@@ -86,8 +86,7 @@ void nade_ice_boom(entity this)
        setorigin(fountain, fountain.origin);
        setthink(fountain, nade_ice_think);
        fountain.nextthink = time;
-       fountain.ltime = time + autocvar_g_nades_ice_freeze_time;
-       fountain.pushltime = fountain.wait = fountain.ltime;
+       fountain.pushltime = fountain.wait = fountain.ltime = time + autocvar_g_nades_ice_freeze_time;
        fountain.team = this.team;
        set_movetype(fountain, MOVETYPE_TOSS);
        fountain.projectiledeathtype = DEATH_NADE_ICE.m_id;
@@ -106,7 +105,8 @@ void nade_ice_boom(entity this)
                timer.glowmod = this.glowmod;
                setthink(timer, nade_timer_think);
                timer.nextthink = time;
-               timer.wait = fountain.ltime;
+               timer.wait = fountain.wait;
+               timer.nade_lifetime = this.nade_lifetime;
                timer.owner = fountain;
                timer.skin = 10;
        }
index 0dc520c91f4e721cbcad132c77df4adbb220d62f..6ae5d550dbda919660e7691345c812d3e1693878 100644 (file)
@@ -7,7 +7,6 @@
 #include <server/command/common.qh>
 
 .float nade_time_primed;
-.float nade_lifetime;
 
 .entity nade_spawnloc;
 
@@ -23,7 +22,7 @@ vector nades_PlayerColor(entity this, bool isPants)
 
 void nade_timer_think(entity this)
 {
-       this.skin = 8 - (this.owner.wait - time) / (this.owner.nade_lifetime / 10);
+       this.skin = 8 - (this.wait - time) / (this.nade_lifetime / 10);
        this.nextthink = time;
        if(!this.owner || wasfreed(this.owner))
                delete(this);
@@ -44,6 +43,7 @@ void nade_spawn(entity _nade)
        setthink(timer, nade_timer_think);
        timer.nextthink = time;
        timer.wait = _nade.wait;
+       timer.nade_lifetime = _nade.nade_lifetime;
        timer.owner = _nade;
        timer.skin = 10;
 
index ced6e588f88259e0408c839b51ca6ebf7599598c..0d3311a3fa02e915a550a5abd2c27779d4fb75a3 100644 (file)
@@ -42,6 +42,7 @@ int autocvar_g_nades_bonus_score_spree;
 
 .entity nade;
 .entity fake_nade;
+.float nade_lifetime;
 .float nade_refire;
 .float nade_special_time;
 .string pokenade_type;