]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
adjust max shot distance according to map size
authorMartin Taibr <taibr.martin@gmail.com>
Sat, 24 Dec 2016 02:29:55 +0000 (03:29 +0100)
committerMartin Taibr <taibr.martin@gmail.com>
Sat, 24 Dec 2016 02:29:55 +0000 (03:29 +0100)
21 files changed:
qcsrc/client/view.qc
qcsrc/common/debug.qh
qcsrc/common/mutators/mutator/spawn_near_teammate/sv_spawn_near_teammate.qc
qcsrc/common/turrets/sv_turrets.qc
qcsrc/common/turrets/turret/plasma.qc
qcsrc/common/turrets/turret/plasma_dual.qc
qcsrc/common/vehicles/vehicle/bumblebee.qc
qcsrc/common/vehicles/vehicle/raptor.qc
qcsrc/common/vehicles/vehicle/spiderbot.qc
qcsrc/common/vehicles/vehicle/spiderbot_weapons.qc
qcsrc/common/weapons/weapon.qh
qcsrc/common/weapons/weapon/vaporizer.qc
qcsrc/common/weapons/weapon/vortex.qc
qcsrc/lib/float.qh [new file with mode: 0644]
qcsrc/server/cheats.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/mutators/mutator/gamemode_assault.qc
qcsrc/server/teamplay.qc
qcsrc/server/weapons/hitplot.qc
qcsrc/server/weapons/tracing.qc
qcsrc/server/weapons/tracing.qh

index 2ca531166a936555ce61bde93b471579ed3a9a10..032bf2522909da50520f26d8bc19f5d8abbfe780 100644 (file)
@@ -653,7 +653,7 @@ float TrueAimCheck()
                        mv = MOVE_NORMAL;
                        if(zoomscript_caught)
                        {
-                               tracebox(view_origin, '0 0 0', '0 0 0', view_origin + view_forward * MAX_SHOT_DISTANCE, mv, ta);
+                               tracebox(view_origin, '0 0 0', '0 0 0', view_origin + view_forward * max_shot_distance, mv, ta);
                                return EnemyHitCheck();
                        }
                        break;
@@ -679,7 +679,7 @@ float TrueAimCheck()
 
        vecs = decompressShotOrigin(STAT(SHOTORG));
 
-       traceline(traceorigin, traceorigin + view_forward * MAX_SHOT_DISTANCE, mv, ta);
+       traceline(traceorigin, traceorigin + view_forward * max_shot_distance, mv, ta);
        trueaimpoint = trace_endpos;
 
        if(vdist((trueaimpoint - traceorigin), <, g_trueaim_minrange))
@@ -972,7 +972,7 @@ void HUD_Crosshair(entity this)
                float shottype;
 
                // wcross_origin = '0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight;
-               wcross_origin = project_3d_to_2d(view_origin + MAX_SHOT_DISTANCE * view_forward);
+               wcross_origin = project_3d_to_2d(view_origin + max_shot_distance * view_forward);
                wcross_origin.z = 0;
                if(autocvar_crosshair_hittest)
                {
index 6d580bd2d69a8b65631a465d0adee730e6bca07d..10a69a70685ebdfdc79c481295410179215fe40d 100644 (file)
@@ -280,7 +280,7 @@ MUTATOR_HOOKFUNCTION(trace, SV_StartFrame)
                vector forward = '0 0 0'; vector right = '0 0 0'; vector up = '0 0 0';
                MAKEVECTORS(makevectors, it.v_angle, forward, right, up);
                vector pos = it.origin + it.view_ofs;
-               traceline(pos, pos + forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, it);
+               traceline(pos, pos + forward * max_shot_distance, MOVE_NORMAL, it);
                FOREACH_ENTITY(true, {
                    it.solid = it.solid_prev;
             it.solid_prev = 0;
index 5f11777c2352b69d0ed4152ab1668e18dae3005b..78cd177f7fe3878ca4fad71a1233dfe014c11d88 100644 (file)
@@ -1,6 +1,6 @@
 #include "sv_spawn_near_teammate.qh"
 
-const float FLOAT_MAX = 340282346638528859811704183484516925440.0f;
+#include <lib/float.qh>
 
 float autocvar_g_spawn_near_teammate_distance;
 int autocvar_g_spawn_near_teammate_ignore_spawnpoint;
index c90eaff1fe98fdb22bc7918fefedd1f28c703738..83db075b422a7efe3f75dd1bab2a9220102d8060 100644 (file)
@@ -1224,13 +1224,13 @@ void turret_initparams(entity tur)
        tur.shot_force                  = bound(0.001,           (TRY(tur.shot_force)                :  tur.shot_dmg * 0.5 + tur.shot_radius * 0.5 ), 5000);
        tur.shot_volly                  = bound(1,               (TRY(tur.shot_volly)                :  1                                          ), floor(tur.ammo_max / tur.shot_dmg));
        tur.shot_volly_refire           = bound(tur.shot_refire, (TRY(tur.shot_volly_refire)         :  tur.shot_refire * tur.shot_volly           ), 60);
-       tur.target_range                = bound(0,               (TRY(tur.target_range)              :  tur.shot_speed * 0.5                       ), MAX_SHOT_DISTANCE);
-       tur.target_range_min            = bound(0,               (TRY(tur.target_range_min)          :  tur.shot_radius * 2                        ), MAX_SHOT_DISTANCE);
-       tur.target_range_optimal        = bound(0,               (TRY(tur.target_range_optimal)      :  tur.target_range * 0.5                     ), MAX_SHOT_DISTANCE);
+       tur.target_range                = bound(0,               (TRY(tur.target_range)              :  tur.shot_speed * 0.5                       ), max_shot_distance);
+       tur.target_range_min            = bound(0,               (TRY(tur.target_range_min)          :  tur.shot_radius * 2                        ), max_shot_distance);
+       tur.target_range_optimal        = bound(0,               (TRY(tur.target_range_optimal)      :  tur.target_range * 0.5                     ), max_shot_distance);
        tur.aim_maxrotate               = bound(0,               (TRY(tur.aim_maxrotate)             :  90                                         ), 360);
        tur.aim_maxpitch                = bound(0,               (TRY(tur.aim_maxpitch)              :  20                                         ), 90);
        tur.aim_speed                   = bound(0.1,             (TRY(tur.aim_speed)                 :  36                                         ), 1000);
-       tur.aim_firetolerance_dist      = bound(0.1,             (TRY(tur.aim_firetolerance_dist)    :  5 + (tur.shot_radius * 2)                  ), MAX_SHOT_DISTANCE);
+       tur.aim_firetolerance_dist      = bound(0.1,             (TRY(tur.aim_firetolerance_dist)    :  5 + (tur.shot_radius * 2)                  ), max_shot_distance);
        tur.target_select_rangebias     = bound(-10,             (TRY(tur.target_select_rangebias)   :  1                                          ), 10);
        tur.target_select_samebias      = bound(-10,             (TRY(tur.target_select_samebias)    :  1                                          ), 10);
        tur.target_select_anglebias     = bound(-10,             (TRY(tur.target_select_anglebias)   :  1                                          ), 10);
@@ -1270,7 +1270,7 @@ bool turret_initialize(entity this, Turret tur)
        this.netname = tur.netname;
        load_unit_settings(this, 0);
 
-       if(!this.team || !teamplay)             { this.team = MAX_SHOT_DISTANCE; }
+       if(!this.team || !teamplay)             { this.team = FLOAT_MAX; }
        if(!this.ticrate)                               { this.ticrate = ((this.turret_flags & TUR_FLAG_SUPPORT) ? 0.2 : 0.1); }
        if(!this.health)                                { this.health = 1000; }
        if(!this.shot_refire)                   { this.shot_refire = 1; }
index d161436ab0807041b4bff31e65205cea02a15264..283cf6e514cbf91d91241e2223ebfa69b3013b02 100644 (file)
@@ -10,7 +10,7 @@ METHOD(PlasmaTurret, tr_attack, void(PlasmaTurret this, entity it))
 {
     if(g_instagib)
     {
-        FireRailgunBullet (it, it.tur_shotorg, it.tur_shotorg + it.tur_shotdir_updated * MAX_SHOT_DISTANCE, 10000000000,
+        FireRailgunBullet (it, it.tur_shotorg, it.tur_shotorg + it.tur_shotdir_updated * max_shot_distance, 10000000000,
                            800, 0, 0, 0, 0, DEATH_TURRET_PLASMA.m_id);
 
         Send_Effect(EFFECT_VORTEX_MUZZLEFLASH, it.tur_shotorg, it.tur_shotdir_updated * 1000, 1);
index 9e6d80b2fd830f165117630e685779d19afb82ca..7859d26e343f50127d302578582bac73a6fb1de9 100644 (file)
@@ -9,7 +9,7 @@ spawnfunc(turret_plasma_dual) { if (!turret_initialize(this, TUR_PLASMA_DUAL)) d
 METHOD(DualPlasmaTurret, tr_attack, void(DualPlasmaTurret thistur, entity it))
 {
     if (g_instagib) {
-        FireRailgunBullet (it, it.tur_shotorg, it.tur_shotorg + it.tur_shotdir_updated * MAX_SHOT_DISTANCE, 10000000000,
+        FireRailgunBullet (it, it.tur_shotorg, it.tur_shotorg + it.tur_shotdir_updated * max_shot_distance, 10000000000,
                            800, 0, 0, 0, 0, DEATH_TURRET_PLASMA.m_id);
 
 
index 3f5f40435819d6de9b7f748eeb7724af411623c6..466a96229a6065653cc846daf7003108b7788d9b 100644 (file)
@@ -167,7 +167,7 @@ bool bumblebee_gunner_frame(entity this, float dt)
                VEHICLE_UPDATE_PLAYER(this, vehic, shield, bumblebee);
 
        ad = gettaginfo(gun, gettagindex(gun, "fire"));
-       traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, gun);
+       traceline(ad, ad + v_forward * max_shot_distance, MOVE_NORMAL, gun);
 
        UpdateAuxiliaryXhair(this, trace_endpos, ('1 0 0' * this.vehicle_reload1) + ('0 1 0' *(1 - this.vehicle_reload1)), 0);
 
index 1068e7430dd47a8cc36b008575f2077b98071d9e..57ea36c9d1ee16d41f10386d56824a1e735df024 100644 (file)
@@ -351,7 +351,7 @@ bool raptor_frame(entity this, float dt)
        /*
        ad = ad * 0.5;
        v_forward = vf * 0.5;
-       traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, vehic);
+       traceline(ad, ad + v_forward * max_shot_distance, MOVE_NORMAL, vehic);
        UpdateAuxiliaryXhair(this, trace_endpos, '0 1 0', 0);
        */
 
index d99335a51c3bcdde3497a9f6cd2866fdfa87d4da..ceb5625d488ce4bdb89b7a20dac26878150e1da7 100644 (file)
@@ -72,15 +72,15 @@ bool spiderbot_frame(entity this, float dt)
        vf += v_forward;
        ad = ad * 0.5;
        v_forward = vf * 0.5;
-       traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, vehic);
+       traceline(ad, ad + v_forward * max_shot_distance, MOVE_NORMAL, vehic);
        UpdateAuxiliaryXhair(this, trace_endpos, ('1 0 0' * this.vehicle_reload1) + ('0 1 0' * (1 - this.vehicle_reload1)), 0);
 #else
        vector ad = gettaginfo(vehic.gun1, gettagindex(vehic.gun1, "barrels"));
-       traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, vehic);
+       traceline(ad, ad + v_forward * max_shot_distance, MOVE_NORMAL, vehic);
        UpdateAuxiliaryXhair(this, trace_endpos, ('1 0 0' * this.vehicle_reload1) + ('0 1 0' * (1 - this.vehicle_reload1)), 0);
        vector vf = ad;
        ad = gettaginfo(vehic.gun2, gettagindex(vehic.gun2, "barrels"));
-       traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, vehic);
+       traceline(ad, ad + v_forward * max_shot_distance, MOVE_NORMAL, vehic);
        UpdateAuxiliaryXhair(this, trace_endpos, ('1 0 0' * this.vehicle_reload1) + ('0 1 0' * (1 - this.vehicle_reload1)), 1);
        ad = 0.5 * (ad + vf);
 #endif
index 5f7a2c31c8a928cbbc5efec1d99e869a0c01a6fc..1fde99b3fcc48e87014fa84f57e1d1a0d11bd9b2 100644 (file)
@@ -221,11 +221,11 @@ void spiderbot_rocket_do(entity this)
             rocket.pos1           = trace_endpos + randomvec() * (0.75 * autocvar_g_vehicle_spiderbot_rocket_radius);
             rocket.pos1_z         = trace_endpos_z;
 
-            traceline(v, v + '0 0 1' * MAX_SHOT_DISTANCE, MOVE_WORLDONLY, this);
+            traceline(v, v + '0 0 1' * max_shot_distance, MOVE_WORLDONLY, this);
             float h1 = 0.75 * vlen(v - trace_endpos);
 
             //v = trace_endpos;
-            traceline(v , rocket.pos1 + '0 0 1' * MAX_SHOT_DISTANCE, MOVE_WORLDONLY, this);
+            traceline(v , rocket.pos1 + '0 0 1' * max_shot_distance, MOVE_WORLDONLY, this);
             float h2 = 0.75 * vlen(rocket.pos1 - v);
 
             rocket.velocity  = spiberbot_calcartillery(v, rocket.pos1, ((h1 < h2) ? h1 : h2));
index e2e978d72e6b1849386b8bcc21ea7d7d545c2acb..6220a0cea9723fc94493d67747f287df67910337 100644 (file)
@@ -175,9 +175,7 @@ ENDCLASS(OffhandWeapon)
 .OffhandWeapon offhand;
 #endif
 
-// currently, NetRadiant's limit is 131072 qu for each side
-// distance from one corner of a 131072qu cube to the opposite corner is approx. 227023 qu
-const int MAX_SHOT_DISTANCE = 230000;
+int max_shot_distance = 32768; // determined by world mins/maxs when map loads
 
 // weapon flags
 const int WEP_TYPE_OTHER          =  0x00; // not for damaging people
index e11e4d8d5211aacc6e6d6e483afd0fe0ac45ea88..9c6d372be746ea8d377645aeadf6235dd2f294cc 100644 (file)
@@ -193,7 +193,7 @@ void W_Vaporizer_Attack(Weapon thiswep, entity actor, .entity weaponentity)
 
        yoda = 0;
        damage_goodhits = 0;
-       FireRailgunBullet(actor, w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, vaporizer_damage, 800, 0, 0, 0, 0, WEP_VAPORIZER.m_id);
+       FireRailgunBullet(actor, w_shotorg, w_shotorg + w_shotdir * max_shot_distance, vaporizer_damage, 800, 0, 0, 0, 0, WEP_VAPORIZER.m_id);
 
        // do this now, as goodhits is disabled below
        SendCSQCVaporizerBeamParticle(actor, damage_goodhits);
index bf3ce8185f2f33168e3da300b5722447151d14c3..f7f20d2e8d4933ca5c39d65a4d5a66f7f08fb2a6 100644 (file)
@@ -193,7 +193,7 @@ void W_Vortex_Attack(Weapon thiswep, entity actor, .entity weaponentity, float i
 
        yoda = 0;
        damage_goodhits = 0;
-       FireRailgunBullet(actor, w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, WEP_VORTEX.m_id);
+       FireRailgunBullet(actor, w_shotorg, w_shotorg + w_shotdir * max_shot_distance, mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, WEP_VORTEX.m_id);
 
        if(yoda && flying)
                Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_YODA);
diff --git a/qcsrc/lib/float.qh b/qcsrc/lib/float.qh
new file mode 100644 (file)
index 0000000..946319e
--- /dev/null
@@ -0,0 +1,3 @@
+#pragma once
+
+const float FLOAT_MAX = 340282346638528859811704183484516925440.0f;
index cf8a4569b30549598c800adf29d8a720d2cdb6e0..16dd07342367f136a047623065a750ea4abccabb 100644 (file)
@@ -324,7 +324,7 @@ float CheatCommand(entity this, int argc)
                                //   effectname
                                effectnum = _particleeffectnum(argv(1));
                                W_SetupShot(this, weaponentities[0], false, false, SND_Null, CH_WEAPON_A, 0);
-                               traceline(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, MOVE_NORMAL, this);
+                               traceline(w_shotorg, w_shotorg + w_shotdir * max_shot_distance, MOVE_NORMAL, this);
                                __trailparticles(this, effectnum, w_shotorg, trace_endpos);
                                DID_CHEAT();
                                break;
index 7f4899f127faed3c1d53e77e9ad15a4d236f197b..a171524b4bc34d229693fcb4688c1216d81b780c 100644 (file)
@@ -32,7 +32,7 @@
 
 void crosshair_trace(entity pl)
 {
-       traceline_antilag(pl, pl.cursor_trace_start, pl.cursor_trace_start + normalize(pl.cursor_trace_endpos - pl.cursor_trace_start) * MAX_SHOT_DISTANCE, MOVE_NORMAL, pl, ANTILAG_LATENCY(pl));
+       traceline_antilag(pl, pl.cursor_trace_start, pl.cursor_trace_start + normalize(pl.cursor_trace_endpos - pl.cursor_trace_start) * max_shot_distance, MOVE_NORMAL, pl, ANTILAG_LATENCY(pl));
 }
 .bool ctrace_solidchanged;
 void crosshair_trace_plusvisibletriggers(entity pl)
@@ -56,7 +56,7 @@ void crosshair_trace_plusvisibletriggers(entity pl)
 }
 void WarpZone_crosshair_trace(entity pl)
 {
-       WarpZone_traceline_antilag(pl, pl.cursor_trace_start, pl.cursor_trace_start + normalize(pl.cursor_trace_endpos - pl.cursor_trace_start) * MAX_SHOT_DISTANCE, MOVE_NORMAL, pl, ANTILAG_LATENCY(pl));
+       WarpZone_traceline_antilag(pl, pl.cursor_trace_start, pl.cursor_trace_start + normalize(pl.cursor_trace_endpos - pl.cursor_trace_start) * max_shot_distance, MOVE_NORMAL, pl, ANTILAG_LATENCY(pl));
 }
 
 
index 1a1d7959fd2799b4e3908d3e13736b314106aced..f4b896401035a938504136565747f81c7d95c4de 100644 (file)
@@ -1,5 +1,7 @@
 #include "gamemode_assault.qh"
 
+#include <lib/float.qh>
+
 .entity sprite;
 
 // random functions
@@ -525,7 +527,7 @@ MUTATOR_HOOKFUNCTION(as, TurretSpawn)
 {
        entity turret = M_ARGV(0, entity);
 
-       if(!turret.team || turret.team == MAX_SHOT_DISTANCE)
+       if(!turret.team || turret.team == FLOAT_MAX)
                turret.team = 5; // this gets reversed when match starts?
 }
 
index 4632866b4886755e7657da57ca2cc95fa3039109..0480eb07096c14f0351a98f9eeb93306d433324b 100644 (file)
@@ -52,6 +52,7 @@ void InitGameplayMode()
        get_mi_min_max(1);
        world.mins = mi_min;
        world.maxs = mi_max;
+       max_shot_distance = vlen(world.maxs - world.mins);
 
        MapInfo_LoadMapSettings(mapname);
        serverflags &= ~SERVERFLAG_TEAMPLAY;
index 372f7357b4057a95d63cba482b826d87b23a441d..355b3afbb87da95d777b1d9391b3982f11e8d885 100644 (file)
@@ -66,7 +66,7 @@ void W_HitPlotAnalysis(entity player, vector screenforward, vector screenright,
                        lag = 0; // only antilag for clients
 
                org = player.origin + player.view_ofs;
-               traceline_antilag_force(player, org, org + screenforward * MAX_SHOT_DISTANCE, MOVE_NORMAL, player, lag);
+               traceline_antilag_force(player, org, org + screenforward * max_shot_distance, MOVE_NORMAL, player, lag);
                if(IS_CLIENT(trace_ent) || IS_MONSTER(trace_ent))
                {
                    entity store = IS_CLIENT(trace_ent) ? CS(trace_ent) : trace_ent;
index 2801971f218bed2fb6d8d288e76a68ff23966bea..fd78c9120a7f1ea42e5e8678aed2c64a33be8dc4 100644 (file)
@@ -354,7 +354,7 @@ void fireBullet(entity this, vector start, vector dir, float spread, float max_s
        vector  end;
 
        dir = normalize(dir + randomvec() * spread);
-       end = start + dir * MAX_SHOT_DISTANCE;
+       end = start + dir * max_shot_distance;
 
        fireBullet_last_hit = NULL;
        float solid_penetration_left = 1;
@@ -399,7 +399,7 @@ void fireBullet(entity this, vector start, vector dir, float spread, float max_s
                start = trace_endpos;
                entity hit = trace_ent;
 
-               // traced up to MAX_SHOT_DISTANCE and didn't hit anything at all
+               // traced up to max_shot_distance and didn't hit anything at all
                if (trace_fraction == 1.0)
                        break;
 
index 21f12c1e4c02633ef9d16f658b99990a87cf74b9..ed046465bc9890329b2140693e0156f031887120 100644 (file)
@@ -9,7 +9,7 @@ vector w_shotend;
 // make sure you call makevectors first (FIXME?)
 void W_SetupShot_Dir_ProjectileSize_Range(entity ent, .entity weaponentity, vector s_forward, vector mi, vector ma, float antilag, float recoil, Sound snd, float chan, float maxdamage, float range);
 
-#define W_SetupShot_Dir_ProjectileSize(ent,wepent,s_forward,mi,ma,antilag,recoil,snd,chan,maxdamage) W_SetupShot_Dir_ProjectileSize_Range(ent, wepent, s_forward, mi, ma, antilag, recoil, snd, chan, maxdamage, MAX_SHOT_DISTANCE)
+#define W_SetupShot_Dir_ProjectileSize(ent,wepent,s_forward,mi,ma,antilag,recoil,snd,chan,maxdamage) W_SetupShot_Dir_ProjectileSize_Range(ent, wepent, s_forward, mi, ma, antilag, recoil, snd, chan, maxdamage, max_shot_distance)
 #define W_SetupShot_ProjectileSize(ent,wepent,mi,ma,antilag,recoil,snd,chan,maxdamage) W_SetupShot_Dir_ProjectileSize(ent, wepent, v_forward, mi, ma, antilag, recoil, snd, chan, maxdamage)
 #define W_SetupShot_Dir(ent,wepent,s_forward,antilag,recoil,snd,chan,maxdamage) W_SetupShot_Dir_ProjectileSize(ent, wepent, s_forward, '0 0 0', '0 0 0', antilag, recoil, snd, chan, maxdamage)
 #define W_SetupShot(ent,wepent,antilag,recoil,snd,chan,maxdamage) W_SetupShot_ProjectileSize(ent, wepent, '0 0 0', '0 0 0', antilag, recoil, snd, chan, maxdamage)