]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Enable buffs by default and don't report them as a mutator (support for maps that...
authorMario <mario@smbclan.net>
Fri, 30 Dec 2016 14:47:35 +0000 (00:47 +1000)
committerMario <mario@smbclan.net>
Fri, 30 Dec 2016 14:47:35 +0000 (00:47 +1000)
mutators.cfg
qcsrc/common/mutators/mutator/buffs/all.inc
qcsrc/common/mutators/mutator/buffs/sv_buffs.qc
qcsrc/common/mutators/mutator/buffs/sv_buffs.qh

index 781377637e076515e4fc0474340d4357e4460079..cd6a9e231a2598dec4472d8b5e4b64da40bbc2eb 100644 (file)
@@ -304,7 +304,7 @@ set g_new_toys_use_pickupsound 1 "play the 'new toys, new toys!' roflsound when
 //  buffs
 // =======
 set cl_buffs_autoreplace 1 "automatically drop current buff when picking up another"
-set g_buffs 0 "enable buffs (requires buff items or powerups)"
+set g_buffs -1 "enable buffs (requires buff items or powerups)"
 set g_buffs_effects 1 "show particle effects from carried buffs"
 set g_buffs_waypoint_distance 1024 "maximum distance at which buff waypoint can be seen from item"
 set g_buffs_randomize 1 "randomize buff type when player drops buff"
@@ -312,7 +312,7 @@ set g_buffs_random_lifetime 30 "re-spawn the buff again if it hasn't been touche
 set g_buffs_random_location 0 "randomize buff location on start and when reset"
 set g_buffs_random_location_attempts 10 "number of random locations a single buff will attempt to respawn at before giving up"
 set g_buffs_spawn_count 0 "how many buffs to spawn on the map if none exist already"
-set g_buffs_replace_powerups 1 "replace powerups on the map with random buffs"
+set g_buffs_replace_powerups 0 "replace powerups on the map with random buffs"
 set g_buffs_cooldown_activate 5 "cooldown period when buff is first activated"
 set g_buffs_cooldown_respawn 3 "cooldown period when buff is reloading"
 set g_buffs_ammo 1 "ammo buff: infinite ammunition"
@@ -377,6 +377,8 @@ set g_buffs_luck 1 "luck buff: randomly increased damage"
 set g_buffs_luck_time 60 "luck buff carry time"
 set g_buffs_luck_chance 0.15 "chance for 'critical' hit (multiplied damage) with luck buff"
 set g_buffs_luck_damagemultiplier 3 "luck damage multiplier"
+set g_buffs_flight 0 "flight buff: crouch jump to reverse your gravity!"
+set g_buffs_flight_time 60 "flight buff carry time"
 
 
 // ==============
index f6c25f76103353e9bd865123f944ec7d61303070..915f95329dbda327f6d3f752221892346a4bb114 100644 (file)
@@ -116,3 +116,11 @@ REGISTER_BUFF(LUCK) {
     this.m_color = '1 0.23 0.44';
 }
 BUFF_SPAWNFUNCS(luck, BUFF_LUCK)
+
+REGISTER_BUFF(FLIGHT) {
+    this.m_prettyName = _("Flight");
+    this.m_name = "flight";
+    this.m_skin = 11;
+    this.m_color = '0.23 0.44 1';
+}
+BUFF_SPAWNFUNCS(flight, BUFF_FLIGHT)
index 45037186d01c230777694969e04c9b8603a2957f..d9eed031cd2f15b2fe4d6459bb2d6a19351d6e7a 100644 (file)
@@ -6,11 +6,14 @@
 .float buff_time = _STAT(BUFF_TIME);
 void buffs_DelayedInit(entity this);
 
-REGISTER_MUTATOR(buffs, cvar("g_buffs"))
+AUTOCVAR(g_buffs, int, -1, _("Enable buffs, -1: enabled but no auto location or replacing powerups, 1: enabled and can replace them"));
+
+REGISTER_MUTATOR(buffs, autocvar_g_buffs)
 {
        MUTATOR_ONADD
        {
-               InitializeEntity(NULL, buffs_DelayedInit, INITPRIO_FINDTARGET);
+               if(autocvar_g_buffs > 0)
+                       InitializeEntity(NULL, buffs_DelayedInit, INITPRIO_FINDTARGET);
        }
 }
 
@@ -592,6 +595,10 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerJump)
 
        if(player.buffs & BUFF_JUMP.m_itemid)
                M_ARGV(1, float) = autocvar_g_buffs_jump_height;
+
+       if(player.buffs & BUFF_FLIGHT.m_itemid)
+       if(!IS_JUMP_HELD(player) && PHYS_INPUT_BUTTON_CROUCH(player))
+               player.gravity *= -1;
 }
 
 MUTATOR_HOOKFUNCTION(buffs, MonsterMove)
@@ -744,6 +751,9 @@ MUTATOR_HOOKFUNCTION(buffs, CustomizeWaypoint)
 
 MUTATOR_HOOKFUNCTION(buffs, OnEntityPreSpawn, CBC_ORDER_LAST)
 {
+       if(autocvar_g_buffs < 0)
+               return; // no auto replacing of entities in this mode
+
        entity ent = M_ARGV(0, entity);
 
        if(autocvar_g_buffs_replace_powerups)
@@ -899,6 +909,16 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink)
                BUFF_ONREM(BUFF_INVISIBLE)
                        player.alpha = player.buff_invisible_prev_alpha;
 
+               BUFF_ONADD(BUFF_FLIGHT)
+               {
+                       player.buff_flight_oldgravity = player.gravity;
+                       if(!player.gravity)
+                               player.gravity = 1;
+               }
+
+               BUFF_ONREM(BUFF_FLIGHT)
+                       player.gravity = ((player.trigger_gravity_check) ? player.trigger_gravity_check.enemy.gravity : player.buff_flight_oldgravity);
+
                player.oldbuffs = player.buffs;
                if(player.buffs)
                {
@@ -982,12 +1002,14 @@ REPLICATE(cvar_cl_buffs_autoreplace, bool, "cl_buffs_autoreplace");
 
 MUTATOR_HOOKFUNCTION(buffs, BuildMutatorsString)
 {
-       M_ARGV(0, string) = strcat(M_ARGV(0, string), ":Buffs");
+       if(autocvar_g_buffs > 0) // only report as a mutator if they're enabled
+               M_ARGV(0, string) = strcat(M_ARGV(0, string), ":Buffs");
 }
 
 MUTATOR_HOOKFUNCTION(buffs, BuildMutatorsPrettyString)
 {
-       M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Buffs");
+       if(autocvar_g_buffs > 0)
+               M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Buffs");
 }
 
 void buffs_DelayedInit(entity this)
index 5b14c39f41c96804bbe04bfa4e10d3b59128cc96..8383a72ef5789a2cb269e9f61d422bca3c75a04f 100644 (file)
@@ -59,6 +59,8 @@ float autocvar_g_buffs_luck_damagemultiplier = 3;
 // disability
 .float buff_disability_time;
 .float buff_disability_effect_time;
+// flight
+.float buff_flight_oldgravity;
 // common buff variables
 .float buff_effect_delay;