]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Rough support for buff timers
authorMario <zacjardine@y7mail.com>
Sat, 14 Feb 2015 15:18:57 +0000 (02:18 +1100)
committerMario <zacjardine@y7mail.com>
Sat, 14 Feb 2015 15:18:57 +0000 (02:18 +1100)
17 files changed:
_hud_descriptions.cfg
hud_luma.cfg
hud_luminos.cfg
hud_luminos_minimal.cfg
hud_luminos_minimal_xhair.cfg
hud_luminos_old.cfg
hud_nexuiz.cfg
mutators.cfg
qcsrc/client/autocvars.qh
qcsrc/client/hud.qc
qcsrc/client/hud_config.qc
qcsrc/common/buffs.qc
qcsrc/common/buffs.qh
qcsrc/common/stats.qh
qcsrc/server/autocvars.qh
qcsrc/server/mutators/mutator_buffs.qc
qcsrc/server/mutators/mutator_buffs.qh

index a47884ef05f586d66da20ad330a33b864eb3d017..5cabda2f6b118ad5208bb1529bb0a24a62e27b25 100644 (file)
@@ -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"
index 4f801509eb8681932a3ca0e9cdd98cd9fb9daf60..ae0b5f0d972d70883f3da799fcee296a00014958 100644 (file)
@@ -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
index 34db2beb663e7cdf118e8cdb3814575a18529ef1..4d95e94f7662d5c80acfaf3d7b08f0bb76b66256 100644 (file)
@@ -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
index 39a6fd2eddbcb8547c9be24ca5cc983ad6ac0c7c..e0a381c6f4fe9c7acbbaac030a3212bbf3832cac 100644 (file)
@@ -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
index 4b6b7e4a74288362ce8761363045f4d2e8767042..2d72b3cd41633ef007903a5abca354485892a373 100644 (file)
@@ -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
index 20650899e77de25e7e1e33d485fbeb5beb2e243f..88c0d8f414c547d61a65ee5870a02c8d8549e7e4 100644 (file)
@@ -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
index 2d86881f5fa81c7827cf133718987757fd0da4df..f3d9180be8358244232da09e0c6040f5e8b8a873 100644 (file)
@@ -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
index dd9c2100a4040fd9694ec7f9fbe9c0f370fc2431..4dbc1826fb02c36b4a08cac23414558fe9487b01 100644 (file)
@@ -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"
index e35bf82dd2759122afc2cf11d46707ef5fc1177b..48666902abe838063d56603af1721427a0eea5b7 100644 (file)
@@ -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;
index 105cce5f2ea850f6cc95fbc25283b304e726f325..3fb74183bf5cacdbcaf093d39d59ef701f25cc6a 100644 (file)
@@ -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);
        }
index 898f3eb56f00f9cf6bb1195ba6d31e7a41035e74..3f79abd3de2196d9144e8ffa39267d2610956caf 100644 (file)
@@ -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");
                }
index 89e2d80be84d40150f6fe4df8ca8d85fc43b747d..9348e119a6842968f00257c98d49c4a30fa6b581 100644 (file)
@@ -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;
+}
index ef1a0e8241eb7116d9874f57b438abb0ab634305..c888d27fed5f43c8b9f72779af2f3fc12056053c 100644 (file)
@@ -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
index 481713cc9cb8f17df86aad4be260f8fd6f5ba76a..8f68bafbc89bc5992713358468efe8a1d58dab7a 100644 (file)
@@ -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?
index d93d5a68eee2c9863b26eca66292f13ac4daa020..75a76f97e274e3ba1b7d468ce9a055661f4d26a6 100644 (file)
@@ -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;
index 0a74d7f390a7af48c1527f617e9c9e6568a1c973..f375c5f4acb5fb6fa01abc502e90188d4e13e8b0 100644 (file)
@@ -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);
index 06a76b1bba71c03d0d35e3c7a60dd511d69aff00..8833813ae705149deae87d9e2aa736c33cc92f44 100644 (file)
@@ -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');