From 36c2ef1d4a74600bdb0dbf7148fda67ea48e59be Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 10 Feb 2015 09:09:18 +1100 Subject: [PATCH] Some small updates to buffs system --- qcsrc/common/buffs.qc | 3 +- qcsrc/common/buffs.qh | 12 +++++- qcsrc/common/deathtypes.qh | 2 +- qcsrc/common/notifications.qh | 4 +- qcsrc/server/g_damage.qc | 9 ++++- qcsrc/server/mutators/mutator_buffs.qc | 55 +++++++++++++++++--------- 6 files changed, 58 insertions(+), 27 deletions(-) diff --git a/qcsrc/common/buffs.qc b/qcsrc/common/buffs.qc index cbb40d13d..89e2d80be 100644 --- a/qcsrc/common/buffs.qc +++ b/qcsrc/common/buffs.qc @@ -54,8 +54,7 @@ int Buff_Type_FromSprite(string buff_sprite) return 0; } - -int Buff_Skin(float buff_id) +int Buff_Skin(int buff_id) { entity e; for(e = Buff_Type_first; e; e = e.enemy) diff --git a/qcsrc/common/buffs.qh b/qcsrc/common/buffs.qh index a629de607..b8cb7372a 100644 --- a/qcsrc/common/buffs.qh +++ b/qcsrc/common/buffs.qh @@ -1,11 +1,16 @@ #ifndef BUFFS_H #define BUFFS_H +// Welcome to the stuff behind the scenes +// Below, you will find the list of buffs +// Add new buffs here! +// Note: Buffs also need spawnfuncs, which are set below entity Buff_Type_first; entity Buff_Type_last; .entity enemy; // internal next pointer int BUFF_LAST = 1; +int BUFF_ALL; .int items; // buff ID .string netname; // buff name @@ -21,6 +26,7 @@ int BUFF_LAST = 1; { \ BUFF_##NAME = BUFF_LAST * 2; \ BUFF_LAST = BUFF_##NAME; \ + BUFF_ALL |= BUFF_##NAME; \ Buff_Type##sname = spawn(); \ Buff_Type##sname.items = BUFF_##NAME; \ Buff_Type##sname.netname = #sname; \ @@ -77,7 +83,7 @@ BUFF_SPAWNFUNCS(invisible, BUFF_INVISIBLE) BUFF_SPAWNFUNCS(random, 0) BUFF_SPAWNFUNC_Q3TA_COMPAT(doubler, BUFF_MEDIC) -BUFF_SPAWNFUNC_Q3TA_COMPAT(resistance, BUFF_RESISTANCE) +BUFF_SPAWNFUNC_Q3TA_COMPAT(resistance, BUFF_RESISTANCE) BUFF_SPAWNFUNC_Q3TA_COMPAT(scout, BUFF_SPEED) BUFF_SPAWNFUNC_Q3TA_COMPAT(ammoregen, BUFF_AMMO) @@ -85,6 +91,10 @@ BUFF_SPAWNFUNC_Q3TA_COMPAT(ammoregen, BUFF_AMMO) BUFF_SPAWNFUNC_Q3TA_COMPAT(haste, BUFF_SPEED) BUFF_SPAWNFUNC_Q3TA_COMPAT(invis, BUFF_INVISIBLE) BUFF_SPAWNFUNC_Q3TA_COMPAT(medic, BUFF_MEDIC) + +#undef BUFF_SPAWNFUNC +#undef BUFF_SPAWNFUNC_Q3TA_COMPAT +#undef BUFF_SPAWNFUNCS #endif vector Buff_Color(int buff_id); diff --git a/qcsrc/common/deathtypes.qh b/qcsrc/common/deathtypes.qh index 301d66576..dae684c14 100644 --- a/qcsrc/common/deathtypes.qh +++ b/qcsrc/common/deathtypes.qh @@ -18,7 +18,7 @@ int DEATH_VHLAST; #define DEATHTYPES \ DEATHTYPE(DEATH_AUTOTEAMCHANGE, DEATH_SELF_AUTOTEAMCHANGE, NO_MSG, DEATH_SPECIAL_START) \ - DEATHTYPE(DEATH_BUFF_VENGEANCE, NO_MSG, DEATH_MURDER_VENGEANCE, NORMAL_POS) \ + DEATHTYPE(DEATH_BUFF, NO_MSG, DEATH_MURDER_BUFF, NORMAL_POS) \ DEATHTYPE(DEATH_CAMP, DEATH_SELF_CAMP, NO_MSG, NORMAL_POS) \ DEATHTYPE(DEATH_CHEAT, DEATH_SELF_CHEAT, DEATH_MURDER_CHEAT, NORMAL_POS) \ DEATHTYPE(DEATH_CUSTOM, DEATH_SELF_CUSTOM, NO_MSG, NORMAL_POS) \ diff --git a/qcsrc/common/notifications.qh b/qcsrc/common/notifications.qh index 1cb1adf51..99578b7ab 100644 --- a/qcsrc/common/notifications.qh +++ b/qcsrc/common/notifications.qh @@ -365,6 +365,7 @@ void Send_Notification_WOCOVA( MULTITEAM_INFO(1, INFO_CTF_PICKUP_, 2, 1, 0, "s1", "s1", "notify_%s_taken", _("^BG%s^BG got the ^TC^TT^BG flag"), "") \ MULTITEAM_INFO(1, INFO_CTF_RETURN_, 2, 1, 0, "s1", "s1", "notify_%s_returned", _("^BG%s^BG returned the ^TC^TT^BG flag"), "") \ MULTITEAM_INFO(1, INFO_CTF_RETURN_MONSTER_, 2, 1, 0, "s1", "s1", "notify_%s_returned", _("^BG%s^BG returned the ^TC^TT^BG flag"), "") \ + MSG_INFO_NOTIF(1, INFO_DEATH_MURDER_BUFF, 3, 3, "spree_inf s1 s2 f3buffname s3loc spree_end", "s2 s1", "notify_death", _("^BG%s%s^K1 was killed by ^BG%s^K1's ^BG%s^K1 buff ^K1%s%s"), _("^BG%s%s^K1 was scored against by ^BG%s^K1's ^BG%s^K1 buff ^K1%s%s")) \ MSG_INFO_NOTIF(1, INFO_DEATH_MURDER_CHEAT, 3, 2, "spree_inf s1 s2 s3loc spree_end", "s2 s1", "notify_death", _("^BG%s%s^K1 was unfairly eliminated by ^BG%s^K1%s%s"), "") \ MSG_INFO_NOTIF(1, INFO_DEATH_MURDER_DROWN, 3, 2, "spree_inf s1 s2 s3loc spree_end", "s2 s1", "notify_water", _("^BG%s%s^K1 was drowned by ^BG%s^K1%s%s"), "") \ MSG_INFO_NOTIF(1, INFO_DEATH_MURDER_FALL, 3, 2, "spree_inf s1 s2 s3loc spree_end", "s2 s1", "notify_fall", _("^BG%s%s^K1 was grounded by ^BG%s^K1%s%s"), "") \ @@ -393,7 +394,6 @@ void Send_Notification_WOCOVA( MSG_INFO_NOTIF(1, INFO_DEATH_MURDER_VH_WAKI_DEATH, 3, 2, "spree_inf s1 s2 s3loc spree_end", "s2 s1", "notify_death", _("^BG%s%s^K1 got caught in the blast when ^BG%s^K1's Racer exploded%s%s"), "") \ MSG_INFO_NOTIF(1, INFO_DEATH_MURDER_VH_WAKI_GUN, 3, 2, "spree_inf s1 s2 s3loc spree_end", "s2 s1", "notify_death", _("^BG%s%s^K1 was bolted down by ^BG%s^K1's Racer%s%s"), "") \ MSG_INFO_NOTIF(1, INFO_DEATH_MURDER_VH_WAKI_ROCKET, 3, 2, "spree_inf s1 s2 s3loc spree_end", "s2 s1", "notify_death", _("^BG%s%s^K1 couldn't find shelter from ^BG%s^K1's Racer%s%s"), "") \ - MSG_INFO_NOTIF(1, INFO_DEATH_MURDER_VENGEANCE, 3, 2, "spree_inf s1 s2 s3loc spree_end", "s2 s1", "notify_death", _("^BG%s%s^K1 was destroyed by the vengeful ^BG%s^K1%s%s"), "") \ MSG_INFO_NOTIF(1, INFO_DEATH_MURDER_VOID, 3, 2, "spree_inf s1 s2 s3loc spree_end", "s2 s1", "notify_void", _("^BG%s%s^K1 was thrown into a world of hurt by ^BG%s^K1%s%s"), "") \ MSG_INFO_NOTIF(1, INFO_DEATH_SELF_AUTOTEAMCHANGE, 2, 1, "s1 s2loc death_team", "", "", _("^BG%s^K1 was moved into the %s%s"), "") \ MSG_INFO_NOTIF(1, INFO_DEATH_SELF_BETRAYAL, 2, 1, "s1 s2loc spree_lost", "s1", "notify_teamkill_red", _("^BG%s^K1 became enemies with the Lord of Teamplay%s%s"), "") \ @@ -752,6 +752,7 @@ void Send_Notification_WOCOVA( MULTITEAM_MULTI##teams(default,prefix,anncepre,infopre,centerpre) #define MSG_MULTI_NOTIFICATIONS \ + MSG_MULTI_NOTIF(1, DEATH_MURDER_BUFF, NO_MSG, INFO_DEATH_MURDER_BUFF, NO_MSG) \ MSG_MULTI_NOTIF(1, DEATH_MURDER_CHEAT, NO_MSG, INFO_DEATH_MURDER_CHEAT, NO_MSG) \ MSG_MULTI_NOTIF(1, DEATH_MURDER_DROWN, NO_MSG, INFO_DEATH_MURDER_DROWN, NO_MSG) \ MSG_MULTI_NOTIF(1, DEATH_MURDER_FALL, NO_MSG, INFO_DEATH_MURDER_FALL, NO_MSG) \ @@ -780,7 +781,6 @@ void Send_Notification_WOCOVA( MSG_MULTI_NOTIF(1, DEATH_MURDER_VH_WAKI_DEATH, NO_MSG, INFO_DEATH_MURDER_VH_WAKI_DEATH, NO_MSG) \ MSG_MULTI_NOTIF(1, DEATH_MURDER_VH_WAKI_GUN, NO_MSG, INFO_DEATH_MURDER_VH_WAKI_GUN, NO_MSG) \ MSG_MULTI_NOTIF(1, DEATH_MURDER_VH_WAKI_ROCKET, NO_MSG, INFO_DEATH_MURDER_VH_WAKI_ROCKET, NO_MSG) \ - MSG_MULTI_NOTIF(1, DEATH_MURDER_VENGEANCE, NO_MSG, INFO_DEATH_MURDER_VENGEANCE, NO_MSG) \ MSG_MULTI_NOTIF(1, DEATH_MURDER_VOID, NO_MSG, INFO_DEATH_MURDER_VOID, NO_MSG) \ MSG_MULTI_NOTIF(1, DEATH_SELF_AUTOTEAMCHANGE, NO_MSG, INFO_DEATH_SELF_AUTOTEAMCHANGE, CENTER_DEATH_SELF_AUTOTEAMCHANGE) \ MSG_MULTI_NOTIF(1, DEATH_SELF_BETRAYAL, NO_MSG, INFO_DEATH_SELF_BETRAYAL, CENTER_DEATH_SELF_BETRAYAL) \ diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index d170cf4c0..392cb4ea5 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -5,6 +5,7 @@ #elif defined(SVQC) #include "../warpzonelib/common.qh" #include "../common/constants.qh" + #include "../common/buffs.qh" #include "../common/teams.qh" #include "../common/util.qh" #include "../common/weapons/weapons.qh" @@ -499,8 +500,12 @@ void Obituary(entity attacker, entity inflictor, entity targ, float deathtype) ); } + float f3 = 0; + if(deathtype == DEATH_BUFF) + f3 = attacker.buffs; + if (!Obituary_WeaponDeath(targ, true, deathtype, targ.netname, attacker.netname, deathlocation, targ.killcount, kill_count_to_attacker)) - Obituary_SpecialDeath(targ, true, deathtype, targ.netname, attacker.netname, deathlocation, targ.killcount, kill_count_to_attacker, 0); + Obituary_SpecialDeath(targ, true, deathtype, targ.netname, attacker.netname, deathlocation, targ.killcount, kill_count_to_attacker, f3); } } @@ -855,7 +860,7 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, float // count the damage if(attacker) if(!targ.deadflag) - if(deathtype != DEATH_BUFF_VENGEANCE) + if(deathtype != DEATH_BUFF) if(targ.takedamage == DAMAGE_AIM) if(targ != attacker) { diff --git a/qcsrc/server/mutators/mutator_buffs.qc b/qcsrc/server/mutators/mutator_buffs.qc index b2f800a27..aef575ae4 100644 --- a/qcsrc/server/mutators/mutator_buffs.qc +++ b/qcsrc/server/mutators/mutator_buffs.qc @@ -24,6 +24,12 @@ float buffs_BuffModel_Customize() return true; } +vector buff_GlowColor(entity buff) +{ + //if(buff.team) { return Team_ColorRGB(buff.team); } + return buff.color; +} + // buff item float buff_Waypoint_visible_for_player(entity plr) { @@ -174,7 +180,7 @@ void buff_Think() if(self.buffs != self.oldbuffs) { self.color = Buff_Color(self.buffs); - self.glowmod = ((self.team) ? Team_ColorRGB(self.team) + '0.1 0.1 0.1' : self.color); + self.glowmod = buff_GlowColor(self); self.skin = Buff_Skin(self.buffs); setmodel(self, "models/relics/relic.md3"); @@ -225,19 +231,8 @@ void buff_Think() } } - if(!self.buff_active) + if(self.buff_active) { - self.alpha = 0.3; - self.effects &= ~(EF_FULLBRIGHT); - self.pflags = 0; - } - else - { - self.alpha = 1; - self.effects |= EF_FULLBRIGHT; - self.light_lev = 220 + 36 * sin(time); - self.pflags = PFLAGS_FULLDYNAMIC; - if(self.team && !self.buff_waypoint) buff_Waypoint_Spawn(self); @@ -270,6 +265,25 @@ void buff_Reset() buff_Respawn(self); } +float buff_Customize() +{ + entity player = WaypointSprite_getviewentity(other); + if(!self.buff_active || (self.team && DIFF_TEAM(player, self))) + { + self.alpha = 0.3; + if(self.effects & EF_FULLBRIGHT) { self.effects &= ~(EF_FULLBRIGHT); } + self.pflags = 0; + } + else + { + self.alpha = 1; + if(!(self.effects & EF_FULLBRIGHT)) { self.effects |= EF_FULLBRIGHT; } + self.light_lev = 220 + 36 * sin(time); + self.pflags = PFLAGS_FULLDYNAMIC; + } + return true; +} + void buff_Init(entity ent) { if(!cvar("g_buffs")) { remove(self); return; } @@ -294,9 +308,10 @@ void buff_Init(entity ent) self.skin = Buff_Skin(self.buffs); self.effects = EF_FULLBRIGHT | EF_STARDUST | EF_NOSHADOW; self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY; + self.customizeentityforclient = buff_Customize; //self.gravity = 100; self.color = Buff_Color(self.buffs); - self.glowmod = ((self.team) ? Team_ColorRGB(self.team) + '0.1 0.1 0.1' : self.color); + self.glowmod = buff_GlowColor(self); buff_SetCooldown(autocvar_g_buffs_cooldown_activate + game_starttime); self.buff_active = !self.buff_activetime; self.pflags = PFLAGS_FULLDYNAMIC; @@ -337,7 +352,7 @@ void buff_SpawnReplacement(entity ent, entity old) // mutator hooks MUTATOR_HOOKFUNCTION(buffs_PlayerDamage_SplitHealthArmor) { - if(frag_deathtype == DEATH_BUFF_VENGEANCE) { return false; } // oh no you don't + if(frag_deathtype == DEATH_BUFF) { return false; } if(frag_target.buffs & BUFF_RESISTANCE) { @@ -352,7 +367,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerDamage_SplitHealthArmor) void buff_Vengeance_DelayedDamage() { if(self.enemy) - Damage(self.enemy, self.owner, self.owner, self.dmg, DEATH_BUFF_VENGEANCE, self.enemy.origin, '0 0 0'); + Damage(self.enemy, self.owner, self.owner, self.dmg, DEATH_BUFF, self.enemy.origin, '0 0 0'); remove(self); return; @@ -360,7 +375,7 @@ void buff_Vengeance_DelayedDamage() MUTATOR_HOOKFUNCTION(buffs_PlayerDamage_Calculate) { - if(frag_deathtype == DEATH_BUFF_VENGEANCE) { return false; } // oh no you don't + if(frag_deathtype == DEATH_BUFF) { return false; } if(frag_target.buffs & BUFF_SPEED) if(frag_target != frag_attacker) @@ -405,6 +420,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerDamage_Calculate) frag_target.buff_disability_time = time + autocvar_g_buffs_disability_time; if(frag_attacker.buffs & BUFF_MEDIC) + if(DEATH_WEAPONOF(frag_deathtype) != WEP_ARC) if(SAME_TEAM(frag_attacker, frag_target)) if(frag_attacker != frag_target) { @@ -415,6 +431,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerDamage_Calculate) // this... is ridiculous (TODO: fix!) if(frag_attacker.buffs & BUFF_VAMPIRE) if(!frag_target.vehicle) + if(DEATH_WEAPONOF(frag_deathtype) != WEP_ARC) if(!ITEM_DAMAGE_NEEDKILL(frag_deathtype)) if(frag_target.deadflag == DEAD_NO) if(IS_PLAYER(frag_target) || (frag_target.flags & FL_MONSTER)) @@ -644,7 +661,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerThink) self.buff_model.customizeentityforclient = buffs_BuffModel_Customize; } self.buff_model.color = Buff_Color(self.buffs); - self.buff_model.glowmod = ((self.buff_model.team) ? Team_ColorRGB(self.buff_model.team) + '0.1 0.1 0.1' : self.buff_model.color); + self.buff_model.glowmod = buff_GlowColor(self.buff_model); self.buff_model.skin = Buff_Skin(self.buffs); self.effects |= EF_NOSHADOW; @@ -767,7 +784,7 @@ MUTATOR_DEFINITION(mutator_buffs) MUTATOR_HOOK(VehicleExit, buffs_VehicleExit, CBC_ORDER_ANY); MUTATOR_HOOK(PlayerRegen, buffs_PlayerRegen, CBC_ORDER_ANY); MUTATOR_HOOK(PlayerDies, buffs_PlayerDies, CBC_ORDER_ANY); - MUTATOR_HOOK(PlayerUseKey, buffs_PlayerUseKey, CBC_ORDER_ANY); + MUTATOR_HOOK(PlayerUseKey, buffs_PlayerUseKey, CBC_ORDER_FIRST); MUTATOR_HOOK(MakePlayerObserver, buffs_RemovePlayer, CBC_ORDER_ANY); MUTATOR_HOOK(ClientDisconnect, buffs_RemovePlayer, CBC_ORDER_ANY); MUTATOR_HOOK(OnEntityPreSpawn, buffs_OnEntityPreSpawn, CBC_ORDER_ANY); -- 2.39.2