From 7ae4eda7db1d10dfb6eeb72efa9ea7b2046feef1 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 31 Dec 2016 00:47:35 +1000 Subject: [PATCH] Enable buffs by default and don't report them as a mutator (support for maps that add buff items, they don't replace powerups) --- mutators.cfg | 6 ++-- qcsrc/common/mutators/mutator/buffs/all.inc | 8 +++++ .../common/mutators/mutator/buffs/sv_buffs.qc | 30 ++++++++++++++++--- .../common/mutators/mutator/buffs/sv_buffs.qh | 2 ++ 4 files changed, 40 insertions(+), 6 deletions(-) diff --git a/mutators.cfg b/mutators.cfg index 781377637..cd6a9e231 100644 --- a/mutators.cfg +++ b/mutators.cfg @@ -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" // ============== diff --git a/qcsrc/common/mutators/mutator/buffs/all.inc b/qcsrc/common/mutators/mutator/buffs/all.inc index f6c25f761..915f95329 100644 --- a/qcsrc/common/mutators/mutator/buffs/all.inc +++ b/qcsrc/common/mutators/mutator/buffs/all.inc @@ -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) diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc index 45037186d..d9eed031c 100644 --- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc @@ -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) diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qh b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qh index 5b14c39f4..8383a72ef 100644 --- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qh +++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qh @@ -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; -- 2.39.2