]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into martin-t/okc
authorMartin Taibr <taibr.martin@gmail.com>
Fri, 25 Aug 2017 15:08:43 +0000 (17:08 +0200)
committerMartin Taibr <taibr.martin@gmail.com>
Fri, 25 Aug 2017 15:08:43 +0000 (17:08 +0200)
defaultOverkill.cfg
defaultServer.cfg
mutators.cfg
qcsrc/common/mutators/mutator/damagetext/cl_damagetext.qc
qcsrc/common/mutators/mutator/dodging/sv_dodging.qc
qcsrc/common/mutators/mutator/nades/nades.qc
qcsrc/common/mutators/mutator/overkill/sv_overkill.qc
qcsrc/common/t_items.qc
qcsrc/common/t_items.qh
qcsrc/lib/math.qh

index 634943c581dfd85e7c94b2fef04bc0f3b704ad93..1dc68c70de1a085b438bc79d4cf7a947ae5e4d1c 100644 (file)
@@ -8,6 +8,13 @@ exec physicsOverkill.cfg
 
 // general gameplay
 set g_overkill 1
+
+// hack - eventually, we should be able to choose overkill models in menu like for vanilla
+set sv_defaultcharacter 1
+set sv_defaultplayermodel "models/ok_player/okrobot1.dpm models/ok_player/okrobot2.dpm models/ok_player/okrobot3.dpm models/ok_player/okrobot4.dpm models/ok_player/okmale1.dpm models/ok_player/okmale2.dpm models/ok_player/okmale3.dpm models/ok_player/okmale4.dpm"
+set sv_defaultplayermodel_red "models/ok_player/okrobot1.dpm models/ok_player/okrobot2.dpm models/ok_player/okrobot3.dpm models/ok_player/okrobot4.dpm"
+set sv_defaultplayermodel_blue "models/ok_player/okmale1.dpm models/ok_player/okmale2.dpm models/ok_player/okmale3.dpm models/ok_player/okmale4.dpm"
+
 set g_respawn_ghosts 0
 
 set g_nades 1
index ed24832d142e70aedf1445a76bf9b57a8e38edcf..596576a097fb93c6841a9e76ba1927a5909a1e13 100644 (file)
@@ -185,6 +185,9 @@ set g_weapon_throwable 1 "if set to 1, weapons can be dropped"
 set g_powerups -1 "if set to 0 the strength and shield (invincibility) will not spawn on the map, if 1 they will spawn in all game modes, -1 is game mode default"
 set g_use_ammunition 1 "if set to 0 all weapons have unlimited ammunition"
 set g_pickup_items -1 "if set to 0 all items (health, armor, ammo, weapons...) are removed from the map, if 1 they are forced to spawn"
+set g_pickup_respawntime_scaling_reciprocal 0 "Multiply respawn time by `reciprocal / (p + offset) + linear` where `p` is the current number of players, takes effect with 2 or more players present, `reciprocal` (with `offset` and `linear` set to 0) can be used to achieve a constant number of items spawned *per player*"
+set g_pickup_respawntime_scaling_offset 0 "Multiply respawn time by `reciprocal / (p + offset) + linear` where `p` is the current number of players, takes effect with 2 or more players present, `offset` offsets the curve left or right - the results are not intuitive and I recommend plotting the respawn time and the number of items per player to see what's happening"
+set g_pickup_respawntime_scaling_linear 1 "Multiply respawn time by `reciprocal / (p + offset) + linear` where `p` is the current number of players, takes effect with 2 or more players present, `linear` can be used to simply scale the respawn time linearly"
 set g_weaponarena "0"  "put in a list of weapons to enable a weapon arena mode, or try \"all\" or \"most\""
 set g_weaponarena_random "0"   "if set to a number, only that weapon count is given on every spawn (randomly)"
 set g_weaponarena_random_with_blaster "1"      "additionally, always provide the blaster in random weapon arena games"
index 9e8460da15ad4dbcfcc3edf24802e65eaf02a3a4..23c72435c1e399233872a18114c265debb945150 100644 (file)
@@ -176,7 +176,7 @@ set g_random_gravity_negative 1000 "negative gravity multiplier"
 // =======
 set g_nades 0 "enable off-hand grenades"
 set g_nades_spread 0.04 "random spread offset of throw direction"
-set g_nades_throw_offset "0 0 0" "nade throwing offset"
+set g_nades_throw_offset "0 -25 0" "nade throwing offset"
 set g_nades_spawn 1 "give nades right away when player spawns rather than delaying entire refire"
 set g_nades_client_select 0 "allow client side selection of nade type"
 set g_nades_pickup 0 "allow picking up thrown nades (not your own)"
index fbb6bcb75762a567ba80cbed3ca1d542b70a74d5..53042b8ef2779199c1a8412c138eacc2ab9c59bf 100644 (file)
@@ -158,13 +158,9 @@ CLASS(DamageText, Object)
         if (this.text) strunzone(this.text);
         this.text = strzone(s);
 
-        float size_range = autocvar_cl_damagetext_size_max - autocvar_cl_damagetext_size_min;
-        float damage_range = autocvar_cl_damagetext_size_max_damage - autocvar_cl_damagetext_size_min_damage;
-        float scale_factor = size_range / damage_range;
-        this.m_size = bound(
-            autocvar_cl_damagetext_size_min,
-            (potential - autocvar_cl_damagetext_size_min_damage) * scale_factor + autocvar_cl_damagetext_size_min,
-            autocvar_cl_damagetext_size_max);
+        this.m_size = map_bound_ranges(potential,
+            autocvar_cl_damagetext_size_min_damage, autocvar_cl_damagetext_size_max_damage,
+            autocvar_cl_damagetext_size_min, autocvar_cl_damagetext_size_max);
     }
 
     CONSTRUCTOR(DamageText, int _group, vector _origin, bool _screen_coords, int _health, int _armor, int _potential_damage, int _deathtype, bool _friendlyfire) {
index d62aa42c4e529e8c64ff85798a8e4a85b98534b9..70aac4d9a3fcda663448d035199f3d46b93dc1a0 100644 (file)
@@ -104,19 +104,20 @@ REGISTER_MUTATOR(dodging, true);
 .int pressedkeys;
 #endif
 
-// returns 1 if the player is close to a wall
+// returns true if the player is close to a wall
 bool check_close_to_wall(entity this, float threshold)
 {
        if (PHYS_DODGING_WALL == 0) { return false; }
 
-#define X(OFFSET) \
-       tracebox(this.origin, this.mins, this.maxs, this.origin + OFFSET, true, this); \
-       if(trace_fraction < 1 && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY) && vdist(this.origin - trace_endpos, <, threshold)) \
+#define X(dir) \
+       tracebox(this.origin, this.mins, this.maxs, this.origin + threshold * dir, true, this); \
+       if (trace_fraction < 1 && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY)) \
                return true;
-       X(1000*v_right);
-       X(-1000*v_right);
-       X(1000*v_forward);
-       X(-1000*v_forward);
+
+       X(v_right);
+       X(-v_right);
+       X(v_forward);
+       X(-v_forward);
 #undef X
 
        return false;
index ae1bbff6525cac70a7348eb46bc4049ae81c76a7..11926b36d025b263032e2c1cf6355094c1305802 100644 (file)
@@ -889,20 +889,18 @@ void toss_nade(entity e, bool set_owner, vector _velocity, float _time)
        delete(e.fake_nade);
        e.fake_nade = NULL;
 
+       Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_NADES);
+
        makevectors(e.v_angle);
 
        // NOTE: always throw from first weapon entity?
        W_SetupShot(e, _nade.weaponentity_fld, false, false, SND_Null, CH_WEAPON_A, 0);
 
-       Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_NADES);
-
        vector offset = (v_forward * autocvar_g_nades_throw_offset.x)
-                                 + (v_right * autocvar_g_nades_throw_offset.y)
-                                 + (v_up * autocvar_g_nades_throw_offset.z);
-       if(autocvar_g_nades_throw_offset == '0 0 0')
-               offset = '0 0 0';
+                     + (v_right * autocvar_g_nades_throw_offset.y)
+                     + (v_up * autocvar_g_nades_throw_offset.z);
 
-       setorigin(_nade, w_shotorg + offset + (v_right * 25) * -1);
+       setorigin(_nade, w_shotorg + offset);
        //setmodel(_nade, MDL_PROJECTILE_NADE);
        //setattachment(_nade, NULL, "");
        PROJECTILE_MAKETRIGGER(_nade);
index f39c4fc0f7ef7ca4edb7d37780569c436016f9fe..d2a7308dedf04267af31ea7b599a4abd447ca08f 100644 (file)
@@ -303,19 +303,8 @@ MUTATOR_HOOKFUNCTION(ok, SetModname)
        return true;
 }
 
-void ok_SetCvars()
-{
-       // hack to force overkill playermodels
-       cvar_settemp("sv_defaultcharacter", "1");
-       cvar_settemp("sv_defaultplayermodel", "models/ok_player/okrobot1.dpm models/ok_player/okrobot2.dpm models/ok_player/okrobot3.dpm models/ok_player/okrobot4.dpm models/ok_player/okmale1.dpm models/ok_player/okmale2.dpm models/ok_player/okmale3.dpm models/ok_player/okmale4.dpm");
-       cvar_settemp("sv_defaultplayermodel_red", "models/ok_player/okrobot1.dpm models/ok_player/okrobot2.dpm models/ok_player/okrobot3.dpm models/ok_player/okrobot4.dpm");
-       cvar_settemp("sv_defaultplayermodel_blue", "models/ok_player/okmale1.dpm models/ok_player/okmale2.dpm models/ok_player/okmale3.dpm models/ok_player/okmale4.dpm");
-}
-
 void ok_Initialize()
 {
-       ok_SetCvars();
-
        precache_all_playermodels("models/ok_player/*.dpm");
 
        WEP_RPC.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
index f5b3b2c19f7122bc0cfbe45cf10b1dfa8e9e0f22..2c42e472847794b4440be0d2675886ebd0014bca 100644 (file)
@@ -631,12 +631,35 @@ void Item_ScheduleRespawnIn(entity e, float t)
        }
 }
 
+AUTOCVAR(g_pickup_respawntime_scaling_reciprocal, float, 0.0, "Multiply respawn time by `reciprocal / (p + offset) + linear` where `p` is the current number of players, takes effect with 2 or more players present, `reciprocal` (with `offset` and `linear` set to 0) can be used to achieve a constant number of items spawned *per player*");
+AUTOCVAR(g_pickup_respawntime_scaling_offset, float, 0.0, "Multiply respawn time by `reciprocal / (p + offset) + linear` where `p` is the current number of players, takes effect with 2 or more players present, `offset` offsets the curve left or right - the results are not intuitive and I recommend plotting the respawn time and the number of items per player to see what's happening");
+AUTOCVAR(g_pickup_respawntime_scaling_linear, float, 1.0, "Multiply respawn time by `reciprocal / (p + offset) + linear` where `p` is the current number of players, takes effect with 2 or more players present, `linear` can be used to simply scale the respawn time linearly");
 void Item_ScheduleRespawn(entity e)
 {
        if(e.respawntime > 0)
        {
                Item_Show(e, 0);
-               Item_ScheduleRespawnIn(e, ITEM_RESPAWNTIME(e));
+
+               CheckAllowedTeams(NULL);
+               GetTeamCounts(NULL);
+               int players = 0;
+               if (c1 != -1) players += c1;
+               if (c2 != -1) players += c2;
+               if (c3 != -1) players += c3;
+               if (c4 != -1) players += c4;
+               float adjusted_respawntime;
+               if (players >= 2) {
+                       float a = autocvar_g_pickup_respawntime_scaling_reciprocal;
+                       float b = autocvar_g_pickup_respawntime_scaling_offset;
+                       float c = autocvar_g_pickup_respawntime_scaling_linear;
+                       adjusted_respawntime = e.respawntime * (a / (players + b) + c);
+               } else {
+                       adjusted_respawntime = e.respawntime;
+               }
+               //LOG_INFOF("item %s will respawn in %f\n", e.classname, adjusted_respawntime);
+               // range: adjusted_respawntime - respawntimejitter .. adjusted_respawntime + respawntimejitter
+               float actual_time = adjusted_respawntime + crandom() * e.respawntimejitter;
+               Item_ScheduleRespawnIn(e, actual_time);
        }
        else // if respawntime is -1, this item does not respawn
                Item_Show(e, -1);
index e52604d994e97c1bf970394d083e1357550f31e6..b92aceb8d0b342028f8c64f3aca50f3e975c8c78 100644 (file)
@@ -67,8 +67,6 @@ bool have_pickup_item(entity this);
 
 const float ITEM_RESPAWN_TICKS = 10;
 
-#define ITEM_RESPAWNTIME(i)         ((i).respawntime + crandom() * (i).respawntimejitter)
-       // range: respawntime - respawntimejitter .. respawntime + respawntimejitter
 #define ITEM_RESPAWNTIME_INITIAL(i) (ITEM_RESPAWN_TICKS + random() * ((i).respawntime + (i).respawntimejitter - ITEM_RESPAWN_TICKS))
        // range: 10 .. respawntime + respawntimejitter
 
index 8ba31516dda7fecffca459d112cbb4affaa92a76..f20b1c66e5bf120be7748737dabe8b9e8dec9f88 100644 (file)
@@ -322,3 +322,25 @@ vector solve_quadratic(float a, float b, float c)
        }
        return v;
 }
+
+/// Maps values between the src and dest range: src_min to dest_min, src_max to dest_max, values between them
+/// to the curresponding values between and extrapolates for values outside the range.
+///
+/// src_min and src_max must not be the same or division by zero accurs.
+///
+/// dest_max can be smaller than dest_min if you want the resulting range to be inverted, all values can be negative.
+ERASEABLE
+float map_ranges(float value, float src_min, float src_max, float dest_min, float dest_max) {
+       float src_diff = src_max - src_min;
+       float dest_diff = dest_max - dest_min;
+       float ratio = (value - src_min) / src_diff;
+       return dest_min + dest_diff * ratio;
+}
+
+/// Same as `map_ranges` except that values outside the source range are clamped to min or max.
+ERASEABLE
+float map_bound_ranges(float value, float src_min, float src_max, float dest_min, float dest_max) {
+       if (value <= src_min) return dest_min;
+       if (value >= src_max) return dest_max;
+       return map_ranges(value, src_min, src_max, dest_min, dest_max);
+}