]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Turrets: always run at server ticrate
authorbones_was_here <bones_was_here@xonotic.au>
Fri, 3 Nov 2023 16:44:29 +0000 (02:44 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Sun, 4 Aug 2024 16:56:51 +0000 (02:56 +1000)
qcsrc/common/turrets/sv_turrets.qc
qcsrc/common/turrets/sv_turrets.qh
qcsrc/common/turrets/turret/ewheel.qc
qcsrc/common/turrets/turret/hk_weapon.qc
qcsrc/common/turrets/turret/phaser_weapon.qc
qcsrc/common/turrets/turret/walker.qc

index 4c7ce5ab418a7bb6567ee2b6bcaeef2da5fc5f50..d8e2e9af26aa4ee2554deb789cd67d5e8029216a 100644 (file)
@@ -297,7 +297,7 @@ void turret_respawn(entity this)
        this.volly_counter                      = this.shot_volly;
        this.ammo                                       = this.ammo_max;
 
-       this.nextthink = time + this.ticrate;
+       this.nextthink = time;
        setthink(this, turret_think);
 
        this.SendFlags = TNSF_FULL_UPDATE;
@@ -572,7 +572,7 @@ void turret_track(entity this)
        switch(this.track_type)
        {
                case TFL_TRACKTYPE_STEPMOTOR:
-                       f_tmp = this.aim_speed * this.ticrate; // dgr/sec -> dgr/tic
+                       f_tmp = this.aim_speed * frametime; // dgr/sec -> dgr/tic
                        if (this.track_flags & TFL_TRACK_PITCH)
                        {
                                this.tur_head.angles_x += bound(-f_tmp,move_angle_x, f_tmp);
@@ -599,7 +599,7 @@ void turret_track(entity this)
                        return;
 
                case TFL_TRACKTYPE_FLUIDINERTIA:
-                       f_tmp = this.aim_speed * this.ticrate; // dgr/sec -> dgr/tic
+                       f_tmp = this.aim_speed * frametime; // dgr/sec -> dgr/tic
                        move_angle_x = bound(-this.aim_speed, move_angle_x * this.track_accel_pitch * f_tmp, this.aim_speed);
                        move_angle_y = bound(-this.aim_speed, move_angle_y * this.track_accel_rot * f_tmp, this.aim_speed);
                        move_angle = (this.tur_head.avelocity * this.track_blendrate) + (move_angle * (1 - this.track_blendrate));
@@ -617,7 +617,7 @@ void turret_track(entity this)
        if (this.track_flags & TFL_TRACK_PITCH)
        {
                this.tur_head.avelocity_x = move_angle_x;
-               if((this.tur_head.angles_x + this.tur_head.avelocity_x * this.ticrate) > this.aim_maxpitch)
+               if((this.tur_head.angles_x + this.tur_head.avelocity_x * frametime) > this.aim_maxpitch)
                {
                        this.tur_head.avelocity_x = 0;
                        this.tur_head.angles_x = this.aim_maxpitch;
@@ -625,7 +625,7 @@ void turret_track(entity this)
                        this.SendFlags  |= TNSF_ANG;
                }
 
-               if((this.tur_head.angles_x + this.tur_head.avelocity_x * this.ticrate) < -this.aim_maxpitch)
+               if((this.tur_head.angles_x + this.tur_head.avelocity_x * frametime) < -this.aim_maxpitch)
                {
                        this.tur_head.avelocity_x = 0;
                        this.tur_head.angles_x = -this.aim_maxpitch;
@@ -639,7 +639,7 @@ void turret_track(entity this)
        {
                this.tur_head.avelocity_y = move_angle_y;
 
-               if((this.tur_head.angles_y + this.tur_head.avelocity_y * this.ticrate) > this.aim_maxrot)
+               if((this.tur_head.angles_y + this.tur_head.avelocity_y * frametime) > this.aim_maxrot)
                {
                        this.tur_head.avelocity_y = 0;
                        this.tur_head.angles_y = this.aim_maxrot;
@@ -647,7 +647,7 @@ void turret_track(entity this)
                        this.SendFlags  |= TNSF_ANG;
                }
 
-               if((this.tur_head.angles_y + this.tur_head.avelocity_y * this.ticrate) < -this.aim_maxrot)
+               if((this.tur_head.angles_y + this.tur_head.avelocity_y * frametime) < -this.aim_maxrot)
                {
                        this.tur_head.avelocity_y = 0;
                        this.tur_head.angles_y = -this.aim_maxrot;
@@ -1022,7 +1022,7 @@ void turret_fire(entity this)
 
 void turret_think(entity this)
 {
-       this.nextthink = time + this.ticrate;
+       this.nextthink = time;
 
        MUTATOR_CALLHOOK(TurretThink, this);
 
@@ -1038,7 +1038,7 @@ void turret_think(entity this)
        // Handle ammo
        if (!(this.spawnflags & TSF_NO_AMMO_REGEN))
        if (this.ammo < this.ammo_max)
-               this.ammo = min(this.ammo + this.ammo_recharge, this.ammo_max);
+               this.ammo = min(this.ammo + this.ammo_recharge * frametime, this.ammo_max);
 
        // Inactive turrets needs to run the think loop,
        // So they can handle animation and wake up if need be.
@@ -1305,7 +1305,6 @@ bool turret_initialize(entity this, Turret tur)
        load_unit_settings(this, 0);
 
        if(!this.team || !teamplay)             { this.team = FLOAT_MAX; }
-       if(!this.ticrate)                               { this.ticrate = ((this.turret_flags & TUR_FLAG_SUPPORT) ? 0.2 : 0.1); }
        if(!GetResource(this, RES_HEALTH)) { SetResourceExplicit(this, RES_HEALTH, 1000); }
        if(!this.shot_refire)                   { this.shot_refire = 1; }
        if(!this.tur_shotorg)                   { this.tur_shotorg = '50 0 50'; }
@@ -1361,11 +1360,9 @@ bool turret_initialize(entity this, Turret tur)
        this.active                                     = ACTIVE_ACTIVE;
        this.effects                            = EF_NODRAW;
        this.netname                            = tur.turret_name;
-       this.ticrate                            = bound(sys_frametime, this.ticrate, 60);
        this.max_health                         = GetResource(this, RES_HEALTH);
        this.target_validate_flags      = this.target_select_flags;
        this.ammo                                       = this.ammo_max;
-       this.ammo_recharge                 *= this.ticrate;
        this.solid                                      = SOLID_BBOX;
        this.takedamage                         = DAMAGE_AIM;
        set_movetype(this, MOVETYPE_NOCLIP);
@@ -1376,7 +1373,7 @@ bool turret_initialize(entity this, Turret tur)
        this.event_heal                         = turret_heal;
        this.use                                        = turret_use;
        this.bot_attack                         = true;
-       this.nextthink                          = time + 1 + turret_count * sys_frametime;
+       this.nextthink                          = time + 1;
        this.reset                                      = turret_reset;
 
        this.tur_head = new(turret_head);
index 727a8cbc748f4013750852c49c9b3726b6cb73ee..35192d08e5002f297de672b0e22c8afc44724e29 100644 (file)
@@ -25,7 +25,6 @@ TR_PROPS_COMMON(X, , )
 .float shot_volly_refire; // refire after completed volly
 */
 
-.float ticrate; // interal ai think rate
 .entity tur_head; // top part of the turret
 .entity tur_defend; // defend this entity
 .vector tur_shotorg; // shot origin
index 7312d0f16d34f624cc0dc37a5217ced176fee5c7..d5420aa0c17cd06fb5f2611a16ef76f0c811225b 100644 (file)
@@ -209,7 +209,7 @@ METHOD(EWheel, tr_setup, void(EWheel this, entity it))
 
     // Convert from dgr / sec to dgr / tic
     it.tur_head.aim_speed = (autocvar_g_turrets_unit_ewheel_turnrate);
-    it.tur_head.aim_speed = it.tur_head.aim_speed / (1 / it.ticrate);
+    it.tur_head.aim_speed = it.tur_head.aim_speed / (1 / frametime);
 }
 
 #endif // SVQC
index deb508bca297868af8455112045ee3fb9fd47aa3..4bb856d958786ecb91a36908d73a54381a02ec61 100644 (file)
@@ -33,7 +33,6 @@ METHOD(HunterKillerAttack, wr_think, void(entity thiswep, entity actor, .entity
         missile.velocity = actor.tur_shotdir_updated * (actor.shot_speed * 0.75);
         missile.angles = vectoangles(missile.velocity);
         missile.cnt = time + 30;
-        missile.ticrate = max(autocvar_sys_ticrate, 0.05);
         missile.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_GUIDED_AI;
 
         if (!isPlayer)
@@ -53,7 +52,7 @@ void turret_hk_missile_think(entity this)
     float pt_seek;  // Pitch of Trace SEEK (How mutch to angele left, right up, down trace towards v_forward)
     float myspeed;
 
-    this.nextthink = time + this.ticrate;
+    this.nextthink = time;
 
     //if (this.cnt < time)
     // turret_hk_missile_explode();
index e4d09d193f7981338fa3f71429cf1a9bc529d768..b9547bedddef4a19927ee1fcf1c497059566a88c 100644 (file)
@@ -20,7 +20,6 @@ METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, entity actor, .entity
             weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
         }
         entity beam = new(PhaserTurret_beam);
-        beam.ticrate = 0.1; //autocvar_sys_ticrate;
         setmodel(beam, MDL_TUR_PHASER_BEAM);
         beam.effects = EF_LOWPRECISION;
         beam.solid = SOLID_NOT;
@@ -29,7 +28,7 @@ METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, entity actor, .entity
         beam.shot_spread = time + 2;
         beam.nextthink = time;
         beam.owner = actor;
-        beam.shot_dmg = actor.shot_dmg / (actor.shot_speed / beam.ticrate);
+        beam.shot_dmg = actor.shot_dmg / (actor.shot_speed / frametime);
         beam.scale = actor.target_range / 256;
         set_movetype(beam, MOVETYPE_NONE);
         beam.enemy = actor.enemy;
@@ -72,7 +71,7 @@ void beam_think(entity this)
         sound (this, CH_SHOTS_SINGLE, SND_TUR_PHASER, VOL_BASE, ATTEN_NORM);
     }
 
-    this.nextthink = time + this.ticrate;
+    this.nextthink = time;
 
     actor.attack_finished_single[0] = time + frametime;
     FireImoBeam (   actor, actor.tur_shotorg,
index 051ea0accd90ac3ebe3f91f699c200f4325c6b49..8e347f962c2cedbd4cd8cefbe22c6368b668a5a1 100644 (file)
@@ -569,8 +569,6 @@ METHOD(WalkerTurret, tr_death, void(WalkerTurret this, entity it))
 }
 METHOD(WalkerTurret, tr_setup, void(WalkerTurret this, entity it))
 {
-    it.ticrate = 0.05;
-
     // Respawn is called & first spawn to, to set team. need to make sure we do not move the initial spawn.
     if(it.move_movetype == MOVETYPE_WALK)
     {