From 38593b19068a9615a9f067046a2d40c95f359e66 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 15 Feb 2015 02:18:57 +1100 Subject: [PATCH] Rough support for buff timers --- _hud_descriptions.cfg | 2 ++ hud_luma.cfg | 2 ++ hud_luminos.cfg | 2 ++ hud_luminos_minimal.cfg | 2 ++ hud_luminos_minimal_xhair.cfg | 2 ++ hud_luminos_old.cfg | 2 ++ hud_nexuiz.cfg | 2 ++ mutators.cfg | 14 +++++++++++++- qcsrc/client/autocvars.qh | 2 ++ qcsrc/client/hud.qc | 18 ++++++++++++++++++ qcsrc/client/hud_config.qc | 3 +++ qcsrc/common/buffs.qc | 9 +++++++++ qcsrc/common/buffs.qh | 13 +++++++++++++ qcsrc/common/stats.qh | 2 +- qcsrc/server/autocvars.qh | 2 +- qcsrc/server/mutators/mutator_buffs.qc | 26 ++++++++++++++++++++++++-- qcsrc/server/mutators/mutator_buffs.qh | 3 +-- 17 files changed, 99 insertions(+), 7 deletions(-) diff --git a/_hud_descriptions.cfg b/_hud_descriptions.cfg index a47884ef0..5cabda2f6 100644 --- a/_hud_descriptions.cfg +++ b/_hud_descriptions.cfg @@ -310,3 +310,5 @@ seta hud_panel_buffs_bg_color_team "" "override panel color with team color in t seta hud_panel_buffs_bg_alpha "" "if set to something else than \"\" = override default panel background alpha" seta hud_panel_buffs_bg_border "" "if set to something else than \"\" = override default size of border around the background" seta hud_panel_buffs_bg_padding "" "if set to something else than \"\" = override default padding of contents from border" +seta hud_panel_buffs_progressbar "" "use progressbar behind buff names" +seta hud_panel_buffs_progressbar_name "" "name of progressbar to use behind buff names" diff --git a/hud_luma.cfg b/hud_luma.cfg index 4f801509e..ae0b5f0d9 100644 --- a/hud_luma.cfg +++ b/hud_luma.cfg @@ -308,5 +308,7 @@ seta hud_panel_buffs_bg_color_team "" seta hud_panel_buffs_bg_alpha "" seta hud_panel_buffs_bg_border "" seta hud_panel_buffs_bg_padding "" +seta hud_panel_buffs_progressbar 1 +seta hud_panel_buffs_progressbar_name "progressbar" menu_sync diff --git a/hud_luminos.cfg b/hud_luminos.cfg index 34db2beb6..4d95e94f7 100644 --- a/hud_luminos.cfg +++ b/hud_luminos.cfg @@ -308,5 +308,7 @@ seta hud_panel_buffs_bg_color_team "" seta hud_panel_buffs_bg_alpha "" seta hud_panel_buffs_bg_border "" seta hud_panel_buffs_bg_padding "" +seta hud_panel_buffs_progressbar 1 +seta hud_panel_buffs_progressbar_name "progressbar" menu_sync diff --git a/hud_luminos_minimal.cfg b/hud_luminos_minimal.cfg index 39a6fd2ed..e0a381c6f 100644 --- a/hud_luminos_minimal.cfg +++ b/hud_luminos_minimal.cfg @@ -308,5 +308,7 @@ seta hud_panel_buffs_bg_color_team "" seta hud_panel_buffs_bg_alpha "" seta hud_panel_buffs_bg_border "" seta hud_panel_buffs_bg_padding "" +seta hud_panel_buffs_progressbar 1 +seta hud_panel_buffs_progressbar_name "progressbar" menu_sync diff --git a/hud_luminos_minimal_xhair.cfg b/hud_luminos_minimal_xhair.cfg index 4b6b7e4a7..2d72b3cd4 100644 --- a/hud_luminos_minimal_xhair.cfg +++ b/hud_luminos_minimal_xhair.cfg @@ -308,5 +308,7 @@ seta hud_panel_buffs_bg_color_team "" seta hud_panel_buffs_bg_alpha "" seta hud_panel_buffs_bg_border "" seta hud_panel_buffs_bg_padding "" +seta hud_panel_buffs_progressbar 1 +seta hud_panel_buffs_progressbar_name "progressbar" menu_sync diff --git a/hud_luminos_old.cfg b/hud_luminos_old.cfg index 20650899e..88c0d8f41 100644 --- a/hud_luminos_old.cfg +++ b/hud_luminos_old.cfg @@ -308,5 +308,7 @@ seta hud_panel_buffs_bg_color_team "" seta hud_panel_buffs_bg_alpha "" seta hud_panel_buffs_bg_border "" seta hud_panel_buffs_bg_padding "" +seta hud_panel_buffs_progressbar 1 +seta hud_panel_buffs_progressbar_name "progressbar" menu_sync diff --git a/hud_nexuiz.cfg b/hud_nexuiz.cfg index 2d86881f5..f3d9180be 100644 --- a/hud_nexuiz.cfg +++ b/hud_nexuiz.cfg @@ -308,5 +308,7 @@ seta hud_panel_buffs_bg_color_team "" seta hud_panel_buffs_bg_alpha "" seta hud_panel_buffs_bg_border "" seta hud_panel_buffs_bg_padding "" +seta hud_panel_buffs_progressbar 1 +seta hud_panel_buffs_progressbar_name "progressbar" menu_sync diff --git a/mutators.cfg b/mutators.cfg index dd9c2100a..4dbc1826f 100644 --- a/mutators.cfg +++ b/mutators.cfg @@ -287,37 +287,49 @@ set g_buffs_replace_powerups 1 "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" +set g_buffs_ammo_time 60 "ammo buff carry time" set g_buffs_resistance 1 "resistance buff: greatly reduces damage taken" +set g_buffs_resistance_time 60 "resistance buff time" set g_buffs_resistance_blockpercent 0.7 "damage reduction multiplier, higher values mean less damage" set g_buffs_medic 1 "medic buff: increased regeneration speed, extra health, chance to survive a fatal attack" +set g_buffs_medic_time 60 "medic buff carry time" set g_buffs_medic_survive_chance 0.6 "multiplier chance of player surviving a fatal hit" set g_buffs_medic_survive_health 5 "amount of health player survives with after taking a fatal hit" set g_buffs_medic_rot 0.2 "health rot rate multiplier" set g_buffs_medic_max 1.5 "stable health medic limit multiplier" set g_buffs_medic_regen 1.7 "health medic rate multiplier" set g_buffs_vengeance 1 "vengeance buff: attackers also take damage" +set g_buffs_vengeance_time 60 "vengeance buff carry time" set g_buffs_vengeance_damage_multiplier 0.6 "amount of damage dealt the attacker takes when hitting a target with vengeance" set g_buffs_bash 1 "bash buff: increased knockback force and immunity to knockback" +set g_buffs_bash_time 60 "bash buff carry time" set g_buffs_bash_force 2 "bash force multiplier" set g_buffs_bash_force_self 1.2 "bash self force multiplier" set g_buffs_disability 1 "disability buff: attacks to players and monsters deal slowness (decreased movement/attack speed) for a few seconds" -set g_buffs_disability_time 3 "time in seconds for target disability" +set g_buffs_disability_time 60 "disability buff carry time" +set g_buffs_disability_slowtime 3 "time in seconds for target disability" set g_buffs_disability_speed 0.5 "player speed multiplier while disabled" set g_buffs_disability_rate 1.7 "player weapon rate multiplier while disabled" set g_buffs_speed 1 "speed buff: increased movement/attack/health regeneration speed, carrier takes slightly more damage" +set g_buffs_speed_time 60 "speed buff carry time" set g_buffs_speed_speed 1.7 "player speed multiplier while holding speed buff" set g_buffs_speed_rate 0.8 "player weapon rate multiplier while holding speed buff" set g_buffs_speed_damage_take 1.2 "damage taken multiplier while holding speed buff" set g_buffs_speed_regen 1.2 "regeneration speed multiplier while holding speed buff" set g_buffs_vampire 1 "vampire buff: attacks to players and monsters heal the carrier" +set g_buffs_vampire_time 60 "vampire buff carry time" set g_buffs_vampire_damage_steal 0.6 "damage stolen multiplier while holding vampire buff" set g_buffs_jump 1 "jump buff: greatly increased jump height" +set g_buffs_jump_time 60 "jump buff carry time" set g_buffs_jump_height 600 "jump height while holding jump buff" set g_buffs_flight 1 "flight buff: greatly decreased gravity" +set g_buffs_flight_time 60 "flight buff carry time" set g_buffs_flight_gravity 0.3 "player gravity multiplier while holding flight buff" set g_buffs_invisible 1 "invisible buff: carrier becomes invisible" +set g_buffs_invisible_time 60 "invisible buff carry time" set g_buffs_invisible_alpha 0.4 "player invisibility multiplier while holding invisible buff" set g_buffs_inferno 1 "inferno buff: targets damaged by player carrying inferno buff will also receive burning damage" +set g_buffs_inferno_time 60 "inferno buff carry time" set g_buffs_inferno_damagemultiplier 0.05 "multiplier of damage dealt during burn" set g_buffs_inferno_burntime_factor 2 "burn time logarithm base. 0 < x < 1: increasingly increasing, x > 1: decreasingly increasing" set g_buffs_inferno_burntime_min_time 0.5 "minimum seconds of burn time" diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index e35bf82dd..48666902a 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -304,6 +304,8 @@ bool autocvar_hud_panel_powerups_flip; int autocvar_hud_panel_powerups_iconalign; bool autocvar_hud_panel_powerups_progressbar; bool autocvar_hud_panel_buffs; +bool autocvar_hud_panel_buffs_progressbar; +string autocvar_hud_panel_buffs_progressbar_name = "progressbar"; //float autocvar_hud_panel_buffs_iconalign; string autocvar_hud_panel_powerups_progressbar_shield; string autocvar_hud_panel_powerups_progressbar_strength; diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 105cce5f2..3fb74183b 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -4459,8 +4459,26 @@ void HUD_Buffs(void) //float buff_iconalign = autocvar_hud_panel_buffs_iconalign; vector buff_offset = '0 0 0'; + /*float strength = ceil(strength_time); + if(autocvar_hud_panel_powerups_progressbar) + HUD_Panel_DrawProgressBar(pos + strength_offset, mySize, autocvar_hud_panel_powerups_progressbar_strength, strength/maxstrength, is_vertical, strength_baralign, autocvar_hud_progressbar_strength_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); + if(autocvar_hud_panel_powerups_text) + { + if(strength > 1) + DrawNumIcon(pos + strength_offset, mySize, strength, "strength", is_vertical, strength_iconalign, '1 1 1', 1); + if(strength <= 5) + DrawNumIcon_expanding(pos + strength_offset, mySize, strength, "strength", is_vertical, strength_iconalign, '1 1 1', 1, bound(0, (strength - strength_time) / 0.5, 1)); + }*/ + + float buff_time, buff_maxtime; + buff_time = bound(0, getstatf(STAT_BUFF_TIME) - time, 99); + buff_maxtime = 60; // TODO: stat? for(e = Buff_Type_first; e; e = e.enemy) if(buffs & e.items) { + if(buff_time && autocvar_hud_panel_buffs_progressbar) + HUD_Panel_DrawProgressBar(pos + buff_offset, mySize, autocvar_hud_panel_buffs_progressbar_name, buff_time/buff_maxtime, 0, 0, + Buff_Color(e.items) * 0.5, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); + //DrawNumIcon(pos + buff_offset, mySize, shield, "shield", is_vertical, buff_iconalign, '1 1 1', 1); drawcolorcodedstring_aspect(pos + buff_offset, s, mySize, panel_fg_alpha * 0.5, DRAWFLAG_NORMAL); } diff --git a/qcsrc/client/hud_config.qc b/qcsrc/client/hud_config.qc index 898f3eb56..3f79abd3d 100644 --- a/qcsrc/client/hud_config.qc +++ b/qcsrc/client/hud_config.qc @@ -204,6 +204,9 @@ void HUD_Panel_ExportCfg(string cfgname) HUD_Write_PanelCvar_q("_fade_subsequent_minfontsize"); HUD_Write_PanelCvar_q("_fade_minfontsize"); break; + case HUD_PANEL_BUFFS: + HUD_Write_PanelCvar_q("_progressbar"); + HUD_Write_PanelCvar_q("_progressbar_name"); } HUD_Write("\n"); } diff --git a/qcsrc/common/buffs.qc b/qcsrc/common/buffs.qc index 89e2d80be..9348e119a 100644 --- a/qcsrc/common/buffs.qc +++ b/qcsrc/common/buffs.qc @@ -71,3 +71,12 @@ string Buff_Sprite(int buff_id) return e.model2; return ""; } + +float Buff_Timer(int buff_id) +{ + entity e; + for(e = Buff_Type_first; e; e = e.enemy) + if(buff_id == e.items) + return e.buff_time; + return 0; +} diff --git a/qcsrc/common/buffs.qh b/qcsrc/common/buffs.qh index ef1a0e824..c888d27fe 100644 --- a/qcsrc/common/buffs.qh +++ b/qcsrc/common/buffs.qh @@ -18,6 +18,17 @@ int BUFF_ALL; .vector colormod; // buff color .string model2; // buff sprite .int skin; // buff skin +.float buff_time; + +// hacky function to return the cvar value only to server - TODO: do this properly! +float sv_cvar(string cvarname) +{ +#ifdef SVQC + return cvar(cvarname); +#else + return 0; +#endif +} #define REGISTER_BUFF(hname,sname,NAME,bskin,bcolor) \ int BUFF_##NAME; \ @@ -33,6 +44,7 @@ int BUFF_ALL; Buff_Type##sname.message = hname; \ Buff_Type##sname.skin = bskin; \ Buff_Type##sname.colormod = bcolor; \ + Buff_Type##sname.buff_time = sv_cvar(strcat("g_buffs_", #sname, "_time")); \ Buff_Type##sname.model2 = strzone(strcat("buff-", #sname)); \ if(!Buff_Type_first) \ Buff_Type_first = Buff_Type##sname; \ @@ -106,4 +118,5 @@ int Buff_Type_FromName(string buff_name); int Buff_Type_FromSprite(string buff_sprite); int Buff_Skin(int buff_id); string Buff_Sprite(int buff_id); +float Buff_Timer(int buff_id); #endif diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index 481713cc9..8f68bafbc 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -92,7 +92,7 @@ const int STAT_HEALING_ORB_ALPHA = 83; const int STAT_PLASMA = 84; const int STAT_OK_AMMO_CHARGE = 85; const int STAT_OK_AMMO_CHARGEPOOL = 86; -// 87 empty? +const int STAT_BUFF_TIME = 87; // 88 empty? // 89 empty? // 90 empty? diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index d93d5a68e..75a76f97e 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -871,7 +871,7 @@ float autocvar_g_buffs_medic_regen; float autocvar_g_buffs_vengeance_damage_multiplier; float autocvar_g_buffs_bash_force; float autocvar_g_buffs_bash_force_self; -float autocvar_g_buffs_disability_time; +float autocvar_g_buffs_disability_slowtime; float autocvar_g_buffs_disability_speed; float autocvar_g_buffs_disability_rate; float autocvar_g_buffs_speed_speed; diff --git a/qcsrc/server/mutators/mutator_buffs.qc b/qcsrc/server/mutators/mutator_buffs.qc index 0a74d7f39..f375c5f4a 100644 --- a/qcsrc/server/mutators/mutator_buffs.qc +++ b/qcsrc/server/mutators/mutator_buffs.qc @@ -422,7 +422,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerDamage_Calculate) if(frag_attacker.buffs & BUFF_DISABILITY) if(frag_target != frag_attacker) - frag_target.buff_disability_time = time + autocvar_g_buffs_disability_time; + frag_target.buff_disability_time = time + autocvar_g_buffs_disability_slowtime; if(frag_attacker.buffs & BUFF_MEDIC) if(DEATH_WEAPONOF(frag_deathtype) != WEP_ARC) @@ -605,11 +605,27 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerThink) self.buff_disability_effect_time = time + 0.5; } - if(self.frozen) + // handle buff lost status + // 1: notify everyone else + // 2: notify carrier as well + int buff_lost = 0; + + if(self.buff_time) + if(time >= self.buff_time) + buff_lost = 2; + + if(self.frozen) { buff_lost = 1; } + + if(buff_lost) { if(self.buffs) { Send_Notification(NOTIF_ALL_EXCEPT, self, MSG_INFO, INFO_ITEM_BUFF_LOST, self.netname, self.buffs); + if(buff_lost >= 2) + { + Send_Notification(NOTIF_ONE, self, MSG_MULTI, ITEM_BUFF_DROP, self.buffs); // TODO: special timeout message? + sound(self, CH_TRIGGER, "relics/relic_effect.wav", VOL_BASE, ATTN_NORM); + } self.buffs = 0; } } @@ -620,6 +636,11 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerThink) if(self.buffs != self.oldbuffs) { + if(self.buffs && Buff_Timer(self.buffs)) + self.buff_time = time + Buff_Timer(self.buffs); + else + self.buff_time = 0; + if(self.oldbuffs & BUFF_AMMO) { if(self.buff_ammo_prev_infitems) @@ -784,6 +805,7 @@ void buffs_Initialize() precache_sound("keepaway/respawn.wav"); addstat(STAT_BUFFS, AS_INT, buffs); + addstat(STAT_BUFF_TIME, AS_FLOAT, buff_time); addstat(STAT_MOVEVARS_JUMPVELOCITY, AS_FLOAT, stat_jumpheight); InitializeEntity(world, buffs_DelayedInit, INITPRIO_FINDTARGET); diff --git a/qcsrc/server/mutators/mutator_buffs.qh b/qcsrc/server/mutators/mutator_buffs.qh index 06a76b1bb..8833813ae 100644 --- a/qcsrc/server/mutators/mutator_buffs.qh +++ b/qcsrc/server/mutators/mutator_buffs.qh @@ -11,7 +11,6 @@ .float buff_flight_prev_gravity; // jump .float stat_jumpheight; -//const float STAT_MOVEVARS_JUMPVELOCITY = 250; // engine hack // disability .float buff_disability_time; .float buff_disability_effect_time; @@ -21,7 +20,7 @@ .float buff_activetime; .float buff_activetime_updated; .entity buff_waypoint; -.float oldbuffs; // for updating effects +.int oldbuffs; // for updating effects .entity buff_model; // controls effects (TODO: make csqc) const vector BUFF_MIN = ('-16 -16 -20'); -- 2.39.2