X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fmutators%2Fmutator_buffs.qc;h=7c24ea14f205bfc76ccee0e2213ec4fd2b5a2a21;hb=c51698509e174e343dff48128a1dcfff1527c535;hp=165f677064295b5d91aaf8a3ae6f77327fb172fe;hpb=0e3eea33053f3a86b7b44b755c31b3147075598e;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/mutators/mutator_buffs.qc b/qcsrc/server/mutators/mutator_buffs.qc index 165f67706..7c24ea14f 100644 --- a/qcsrc/server/mutators/mutator_buffs.qc +++ b/qcsrc/server/mutators/mutator_buffs.qc @@ -1,15 +1,24 @@ #include "../../common/triggers/target/music.qh" #include "mutator_buffs.qh" -#include "../_all.qh" #include "mutator.qh" -#include "../../common/buffs.qh" +#include "../../common/gamemodes/all.qh" +#include "../../common/buffs/all.qh" -float buffs_BuffModel_Customize() +entity buff_FirstFromFlags(int _buffs) { + if (flags) + { + FOREACH(Buffs, it.m_itemid & _buffs, LAMBDA(return it)); + } + return BUFF_Null; +} + +bool buffs_BuffModel_Customize() +{SELFPARAM(); entity player, myowner; - float same_team; + bool same_team; player = WaypointSprite_getviewentity(other); myowner = self.owner; @@ -18,6 +27,9 @@ float buffs_BuffModel_Customize() if(myowner.alpha <= 0.5 && !same_team && myowner.alpha != 0) return false; + if(MUTATOR_CALLHOOK(BuffModel_Customize, self, player)) + return false; + if(player == myowner || (IS_SPEC(other) && other.enemy == myowner)) { // somewhat hide the model, but keep the glow @@ -35,7 +47,7 @@ float buffs_BuffModel_Customize() void buffs_BuffModel_Spawn(entity player) { player.buff_model = spawn(); - setmodel(player.buff_model, BUFF_MODEL); + setmodel(player.buff_model, MDL_BUFF); setsize(player.buff_model, '0 0 -40', '0 0 40'); setattachment(player.buff_model, player, ""); setorigin(player.buff_model, '0 0 1' * (player.buff_model.maxs.z * 1)); @@ -49,49 +61,45 @@ void buffs_BuffModel_Spawn(entity player) vector buff_GlowColor(entity buff) { //if(buff.team) { return Team_ColorRGB(buff.team); } - return buff.color; + return buff.m_color; } void buff_Effect(entity player, string eff) -{ +{SELFPARAM(); if(!autocvar_g_buffs_effects) { return; } if(time >= self.buff_effect_delay) { - pointparticles(particleeffectnum(eff), player.origin + ((player.mins + player.maxs) * 0.5), '0 0 0', 1); + Send_Effect_(eff, player.origin + ((player.mins + player.maxs) * 0.5), '0 0 0', 1); self.buff_effect_delay = time + 0.05; // prevent spam } } // buff item float buff_Waypoint_visible_for_player(entity plr) -{ - if(!self.owner.buff_active && !self.owner.buff_activetime) - return false; +{SELFPARAM(); + if(!self.owner.buff_active && !self.owner.buff_activetime) + return false; - if(plr.buffs) + if (plr.buffs) { - if(plr.cvar_cl_buffs_autoreplace) - { - if(plr.buffs == self.owner.buffs) - return false; - } - else - return false; + return plr.cvar_cl_buffs_autoreplace == false || plr.buffs != self.owner.buffs; } - return WaypointSprite_visible_for_player(plr); + return WaypointSprite_visible_for_player(plr); } void buff_Waypoint_Spawn(entity e) { - WaypointSprite_Spawn(Buff_Sprite(e.buffs), 0, autocvar_g_buffs_waypoint_distance, e, '0 0 1' * e.maxs.z, world, e.team, e, buff_waypoint, true, RADARICON_POWERUP, e.glowmod); - WaypointSprite_UpdateTeamRadar(e.buff_waypoint, RADARICON_POWERUP, e.glowmod); - e.buff_waypoint.waypointsprite_visible_for_player = buff_Waypoint_visible_for_player; + entity buff = buff_FirstFromFlags(e.buffs); + entity wp = WaypointSprite_Spawn(WP_Buff, 0, autocvar_g_buffs_waypoint_distance, e, '0 0 1' * e.maxs.z, world, e.team, e, buff_waypoint, true, RADARICON_Buff); + wp.wp_extra = buff.m_id; + WaypointSprite_UpdateTeamRadar(e.buff_waypoint, RADARICON_Buff, e.glowmod); + e.buff_waypoint.waypointsprite_visible_for_player = buff_Waypoint_visible_for_player; } void buff_SetCooldown(float cd) -{ +{SELFPARAM(); cd = max(0, cd); if(!self.buff_waypoint) @@ -103,7 +111,7 @@ void buff_SetCooldown(float cd) } void buff_Respawn(entity ent) -{ +{SELFPARAM(); if(gameover) { return; } vector oldbufforigin = ent.origin; @@ -127,16 +135,16 @@ void buff_Respawn(entity ent) if(autocvar_g_buffs_random_lifetime > 0) ent.lifetime = time + autocvar_g_buffs_random_lifetime; - pointparticles(particleeffectnum("electro_combo"), oldbufforigin + ((ent.mins + ent.maxs) * 0.5), '0 0 0', 1); - pointparticles(particleeffectnum("electro_combo"), CENTER_OR_VIEWOFS(ent), '0 0 0', 1); + Send_Effect(EFFECT_ELECTRO_COMBO, oldbufforigin + ((ent.mins + ent.maxs) * 0.5), '0 0 0', 1); + Send_Effect(EFFECT_ELECTRO_COMBO, CENTER_OR_VIEWOFS(ent), '0 0 0', 1); WaypointSprite_Ping(ent.buff_waypoint); - sound(ent, CH_TRIGGER, "keepaway/respawn.wav", VOL_BASE, ATTEN_NONE); // ATTEN_NONE (it's a sound intended to be heard anywhere) + sound(ent, CH_TRIGGER, SND_KA_RESPAWN, VOL_BASE, ATTEN_NONE); // ATTEN_NONE (it's a sound intended to be heard anywhere) } void buff_Touch() -{ +{SELFPARAM(); if(gameover) { return; } if(ITEM_TOUCH_NEEDKILL()) @@ -148,7 +156,6 @@ void buff_Touch() if((self.team && DIFF_TEAM(other, self)) || (other.frozen) || (other.vehicle) - || (!IS_PLAYER(other)) || (!self.buff_active) ) { @@ -156,15 +163,22 @@ void buff_Touch() return; } - if(other.buffs) + if(MUTATOR_CALLHOOK(BuffTouch, self, other)) + return; + + if(!IS_PLAYER(other)) + return; // incase mutator changed other + + if (other.buffs) { - if(other.cvar_cl_buffs_autoreplace && other.buffs != self.buffs) + if (other.cvar_cl_buffs_autoreplace && other.buffs != self.buffs) { + int buffid = buff_FirstFromFlags(other.buffs).m_id; //Send_Notification(NOTIF_ONE, other, MSG_MULTI, ITEM_BUFF_DROP, other.buffs); - Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ITEM_BUFF_LOST, other.netname, other.buffs); + Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ITEM_BUFF_LOST, other.netname, buffid); other.buffs = 0; - //sound(other, CH_TRIGGER, "relics/relic_effect.wav", VOL_BASE, ATTN_NORM); + //sound(other, CH_TRIGGER, SND_BUFF_LOST, VOL_BASE, ATTN_NORM); } else { return; } // do nothing } @@ -172,51 +186,49 @@ void buff_Touch() self.owner = other; self.buff_active = false; self.lifetime = 0; + int buffid = buff_FirstFromFlags(self.buffs).m_id; + Send_Notification(NOTIF_ONE, other, MSG_MULTI, ITEM_BUFF_GOT, buffid); + Send_Notification(NOTIF_ALL_EXCEPT, other, MSG_INFO, INFO_ITEM_BUFF, other.netname, buffid); - Send_Notification(NOTIF_ONE, other, MSG_MULTI, ITEM_BUFF_GOT, self.buffs); - Send_Notification(NOTIF_ALL_EXCEPT, other, MSG_INFO, INFO_ITEM_BUFF, other.netname, self.buffs); - - pointparticles(particleeffectnum("item_pickup"), CENTER_OR_VIEWOFS(self), '0 0 0', 1); - sound(other, CH_TRIGGER, "misc/shield_respawn.wav", VOL_BASE, ATTN_NORM); + Send_Effect(EFFECT_ITEM_PICKUP, CENTER_OR_VIEWOFS(self), '0 0 0', 1); + sound(other, CH_TRIGGER, SND_SHIELD_RESPAWN, VOL_BASE, ATTN_NORM); other.buffs |= (self.buffs); } -float buff_Available(float buffid) +float buff_Available(entity buff) { - if(buffid == BUFF_AMMO && ((start_items & IT_UNLIMITED_WEAPON_AMMO) || (start_items & IT_UNLIMITED_AMMO) || (cvar("g_melee_only")))) + if (buff == BUFF_Null) return false; - - if(buffid == BUFF_VAMPIRE && cvar("g_vampire")) + if (buff == BUFF_AMMO && ((start_items & IT_UNLIMITED_WEAPON_AMMO) || (start_items & IT_UNLIMITED_AMMO) || (cvar("g_melee_only")))) return false; - - if(!cvar(strcat("g_buffs_", Buff_Name(buffid)))) + if (buff == BUFF_VAMPIRE && cvar("g_vampire")) return false; - - return true; + return cvar(strcat("g_buffs_", buff.m_name)); } +.int buff_seencount; + void buff_NewType(entity ent, float cb) { - entity e; RandomSelection_Init(); - for(e = Buff_Type_first; e; e = e.enemy) - if(buff_Available(e.items)) - { - RandomSelection_Add(world, e.items, string_null, 1, 1 / e.count); // if it's already been chosen, give it a lower priority - e.count += 1; - } + FOREACH(Buffs, buff_Available(it), LAMBDA( + it.buff_seencount += 1; + // if it's already been chosen, give it a lower priority + RandomSelection_Add(world, it.m_itemid, string_null, 1, max(0.2, 1 / it.buff_seencount)); + )); ent.buffs = RandomSelection_chosen_float; } void buff_Think() -{ +{SELFPARAM(); if(self.buffs != self.oldbuffs) { - self.color = Buff_Color(self.buffs); - self.glowmod = buff_GlowColor(self); - self.skin = Buff_Skin(self.buffs); + entity buff = buff_FirstFromFlags(self.buffs); + self.color = buff.m_color; + self.glowmod = buff_GlowColor(buff); + self.skin = buff.m_skin; - setmodel(self, BUFF_MODEL); + setmodel(self, MDL_BUFF); if(self.buff_waypoint) { @@ -236,7 +248,7 @@ void buff_Think() { buff_SetCooldown(self.buff_activetime); self.buff_activetime_updated = true; - } + } if(!self.buff_active && !self.buff_activetime) if(!self.owner || self.owner.frozen || self.owner.deadflag != DEAD_NO || !self.owner.iscreature || !(self.owner.buffs & self.buffs)) @@ -259,8 +271,8 @@ void buff_Think() if(!self.buff_activetime) { self.buff_active = true; - sound(self, CH_TRIGGER, "misc/strength_respawn.wav", VOL_BASE, ATTN_NORM); - pointparticles(particleeffectnum("item_respawn"), CENTER_OR_VIEWOFS(self), '0 0 0', 1); + sound(self, CH_TRIGGER, SND_STRENGTH_RESPAWN, VOL_BASE, ATTN_NORM); + Send_Effect(EFFECT_ITEM_RESPAWN, CENTER_OR_VIEWOFS(self), '0 0 0', 1); } } @@ -279,14 +291,14 @@ void buff_Think() } void buff_Waypoint_Reset() -{ +{SELFPARAM(); WaypointSprite_Kill(self.buff_waypoint); if(self.buff_activetime) { buff_Waypoint_Spawn(self); } } void buff_Reset() -{ +{SELFPARAM(); if(autocvar_g_buffs_randomize) buff_NewType(self, self.buffs); self.owner = world; @@ -299,7 +311,7 @@ void buff_Reset() } float buff_Customize() -{ +{SELFPARAM(); entity player = WaypointSprite_getviewentity(other); if(!self.buff_active || (self.team && DIFF_TEAM(player, self))) { @@ -318,14 +330,15 @@ float buff_Customize() } void buff_Init(entity ent) -{ +{SELFPARAM(); if(!cvar("g_buffs")) { remove(ent); return; } if(!teamplay && ent.team) { ent.team = 0; } - entity oldself = self; - self = ent; - if(!self.buffs || buff_Available(self.buffs)) + entity buff = buff_FirstFromFlags(self.buffs); + + setself(ent); + if(!self.buffs || buff_Available(buff)) buff_NewType(self, 0); self.classname = "item_buff"; @@ -338,12 +351,12 @@ void buff_Init(entity ent) self.gravity = 1; self.movetype = MOVETYPE_TOSS; self.scale = 1; - self.skin = Buff_Skin(self.buffs); + self.skin = buff.m_skin; 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.color = buff.m_color; self.glowmod = buff_GlowColor(self); buff_SetCooldown(autocvar_g_buffs_cooldown_activate + game_starttime); self.buff_active = !self.buff_activetime; @@ -355,23 +368,23 @@ void buff_Init(entity ent) if(self.noalign) self.movetype = MOVETYPE_NONE; // reset by random location - setmodel(self, BUFF_MODEL); + setmodel(self, MDL_BUFF); setsize(self, BUFF_MIN, BUFF_MAX); if(cvar("g_buffs_random_location") || (self.spawnflags & 64)) buff_Respawn(self); - self = oldself; + setself(this); } -void buff_Init_Compat(entity ent, float replacement) +void buff_Init_Compat(entity ent, entity replacement) { - if(ent.spawnflags & 2) + if (ent.spawnflags & 2) ent.team = NUM_TEAM_1; - else if(ent.spawnflags & 4) + else if (ent.spawnflags & 4) ent.team = NUM_TEAM_2; - ent.buffs = replacement; + ent.buffs = replacement.m_itemid; buff_Init(ent); } @@ -386,9 +399,9 @@ void buff_SpawnReplacement(entity ent, entity old) } void buff_Vengeance_DelayedDamage() -{ +{SELFPARAM(); if(self.enemy) - Damage(self.enemy, self.owner, self.owner, self.dmg, DEATH_BUFF, self.enemy.origin, '0 0 0'); + Damage(self.enemy, self.owner, self.owner, self.dmg, DEATH_BUFF.m_id, self.enemy.origin, '0 0 0'); remove(self); return; @@ -402,9 +415,9 @@ float buff_Inferno_CalculateTime(float x, float offset_x, float offset_y, float // mutator hooks MUTATOR_HOOKFUNCTION(buffs_PlayerDamage_SplitHealthArmor) { - if(frag_deathtype == DEATH_BUFF) { return false; } + if(frag_deathtype == DEATH_BUFF.m_id) { return false; } - if(frag_target.buffs & BUFF_RESISTANCE) + if(frag_target.buffs & BUFF_RESISTANCE.m_itemid) { vector v = healtharmor_applydamage(50, autocvar_g_buffs_resistance_blockpercent, frag_deathtype, frag_damage); damage_take = v.x; @@ -416,24 +429,24 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerDamage_SplitHealthArmor) MUTATOR_HOOKFUNCTION(buffs_PlayerDamage_Calculate) { - if(frag_deathtype == DEATH_BUFF) { return false; } + if(frag_deathtype == DEATH_BUFF.m_id) { return false; } - if(frag_target.buffs & BUFF_SPEED) + if(frag_target.buffs & BUFF_SPEED.m_itemid) if(frag_target != frag_attacker) frag_damage *= autocvar_g_buffs_speed_damage_take; - if(frag_target.buffs & BUFF_MEDIC) + if(frag_target.buffs & BUFF_MEDIC.m_itemid) if((frag_target.health - frag_damage) <= 0) if(!ITEM_DAMAGE_NEEDKILL(frag_deathtype)) if(frag_attacker) if(random() <= autocvar_g_buffs_medic_survive_chance) frag_damage = max(5, frag_target.health - autocvar_g_buffs_medic_survive_health); - if(frag_target.buffs & BUFF_JUMP) - if(frag_deathtype == DEATH_FALL) + if(frag_target.buffs & BUFF_JUMP.m_itemid) + if(frag_deathtype == DEATH_FALL.m_id) frag_damage = 0; - if(frag_target.buffs & BUFF_VENGEANCE) + if(frag_target.buffs & BUFF_VENGEANCE.m_itemid) if(frag_attacker) if(frag_attacker != frag_target) if(!ITEM_DAMAGE_NEEDKILL(frag_deathtype)) @@ -447,23 +460,23 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerDamage_Calculate) dmgent.nextthink = time + 0.1; } - if(frag_target.buffs & BUFF_BASH) + if(frag_target.buffs & BUFF_BASH.m_itemid) if(frag_attacker != frag_target) if(vlen(frag_force)) frag_force = '0 0 0'; - if(frag_attacker.buffs & BUFF_BASH) + if(frag_attacker.buffs & BUFF_BASH.m_itemid) if(vlen(frag_force)) if(frag_attacker == frag_target) frag_force *= autocvar_g_buffs_bash_force_self; else frag_force *= autocvar_g_buffs_bash_force; - if(frag_attacker.buffs & BUFF_DISABILITY) + if(frag_attacker.buffs & BUFF_DISABILITY.m_itemid) if(frag_target != frag_attacker) frag_target.buff_disability_time = time + autocvar_g_buffs_disability_slowtime; - if(frag_attacker.buffs & BUFF_MEDIC) + if(frag_attacker.buffs & BUFF_MEDIC.m_itemid) if(DEATH_WEAPONOF(frag_deathtype) != WEP_ARC) if(SAME_TEAM(frag_attacker, frag_target)) if(frag_attacker != frag_target) @@ -472,7 +485,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerDamage_Calculate) frag_damage = 0; } - if(frag_attacker.buffs & BUFF_INFERNO) + if(frag_attacker.buffs & BUFF_INFERNO.m_itemid) if(frag_target != frag_attacker) { float time = buff_Inferno_CalculateTime( frag_damage, @@ -482,16 +495,16 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerDamage_Calculate) autocvar_g_buffs_inferno_burntime_target_time, autocvar_g_buffs_inferno_burntime_factor ); - Fire_AddDamage(frag_target, frag_attacker, (frag_damage * autocvar_g_buffs_inferno_damagemultiplier) * time, time, DEATH_BUFF); + Fire_AddDamage(frag_target, frag_attacker, (frag_damage * autocvar_g_buffs_inferno_damagemultiplier) * time, time, DEATH_BUFF.m_id); } // this... is ridiculous (TODO: fix!) - if(frag_attacker.buffs & BUFF_VAMPIRE) + if(frag_attacker.buffs & BUFF_VAMPIRE.m_itemid) 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)) + if(IS_PLAYER(frag_target) || IS_MONSTER(frag_target)) if(frag_attacker != frag_target) if(!frag_target.frozen) if(frag_target.takedamage) @@ -506,7 +519,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerDamage_Calculate) } MUTATOR_HOOKFUNCTION(buffs_PlayerSpawn) -{ +{SELFPARAM(); self.buffs = 0; // reset timers here to prevent them continuing after re-spawn self.buff_disability_time = 0; @@ -514,9 +527,13 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerSpawn) return false; } +.float stat_sv_maxspeed; +.float stat_sv_airspeedlimit_nonqw; +.float stat_sv_jumpvelocity; + MUTATOR_HOOKFUNCTION(buffs_PlayerPhysics) -{ - if(self.buffs & BUFF_SPEED) +{SELFPARAM(); + if(self.buffs & BUFF_SPEED.m_itemid) { self.stat_sv_maxspeed *= autocvar_g_buffs_speed_speed; self.stat_sv_airspeedlimit_nonqw *= autocvar_g_buffs_speed_speed; @@ -528,7 +545,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerPhysics) self.stat_sv_airspeedlimit_nonqw *= autocvar_g_buffs_disability_speed; } - if(self.buffs & BUFF_JUMP) + if(self.buffs & BUFF_JUMP.m_itemid) { // automatically reset, no need to worry self.stat_sv_jumpvelocity = autocvar_g_buffs_jump_height; @@ -538,15 +555,15 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerPhysics) } MUTATOR_HOOKFUNCTION(buffs_PlayerJump) -{ - if(self.buffs & BUFF_JUMP) +{SELFPARAM(); + if(self.buffs & BUFF_JUMP.m_itemid) player_jumpheight = autocvar_g_buffs_jump_height; return false; } MUTATOR_HOOKFUNCTION(buffs_MonsterMove) -{ +{SELFPARAM(); if(time < self.buff_disability_time) { monster_speed_walk *= autocvar_g_buffs_disability_speed; @@ -557,10 +574,11 @@ MUTATOR_HOOKFUNCTION(buffs_MonsterMove) } MUTATOR_HOOKFUNCTION(buffs_PlayerDies) -{ +{SELFPARAM(); if(self.buffs) { - Send_Notification(NOTIF_ALL_EXCEPT, self, MSG_INFO, INFO_ITEM_BUFF_LOST, self.netname, self.buffs); + int buffid = buff_FirstFromFlags(self.buffs).m_id; + Send_Notification(NOTIF_ALL_EXCEPT, self, MSG_INFO, INFO_ITEM_BUFF_LOST, self.netname, buffid); self.buffs = 0; if(self.buff_model) @@ -573,25 +591,26 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerDies) } MUTATOR_HOOKFUNCTION(buffs_PlayerUseKey) -{ +{SELFPARAM(); if(MUTATOR_RETURNVALUE || gameover) { return false; } if(self.buffs) { - Send_Notification(NOTIF_ONE, self, MSG_MULTI, ITEM_BUFF_DROP, self.buffs); - Send_Notification(NOTIF_ALL_EXCEPT, self, MSG_INFO, INFO_ITEM_BUFF_LOST, self.netname, self.buffs); + int buffid = buff_FirstFromFlags(self.buffs).m_id; + Send_Notification(NOTIF_ONE, self, MSG_MULTI, ITEM_BUFF_DROP, buffid); + Send_Notification(NOTIF_ALL_EXCEPT, self, MSG_INFO, INFO_ITEM_BUFF_LOST, self.netname, buffid); self.buffs = 0; - sound(self, CH_TRIGGER, "relics/relic_effect.wav", VOL_BASE, ATTN_NORM); + sound(self, CH_TRIGGER, SND_BUFF_LOST, VOL_BASE, ATTN_NORM); return true; } return false; } MUTATOR_HOOKFUNCTION(buffs_PlayerThrowKey) -{ +{SELFPARAM(); if(MUTATOR_RETURNVALUE || gameover) { return false; } - if(self.buffs & BUFF_SWAPPER) + if(self.buffs & BUFF_SWAPPER.m_itemid) { float best_distance = autocvar_g_buffs_swapper_range; entity closest = world; @@ -622,7 +641,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerThrowKey) if(closest.flagcarried) { ctf_Handle_Throw(closest, world, DROP_THROW); } if(closest.nade) { toss_nade(closest, '0 0 0', time + 0.05); } - MUTATOR_CALLHOOK(PortalTeleport); // initiate flag dropper + MUTATOR_CALLHOOK(PortalTeleport, self); // initiate flag dropper setorigin(self, their_org); setorigin(closest, my_org); @@ -643,11 +662,11 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerThrowKey) closest.pushltime = time + autocvar_g_maxpushtime; closest.istypefrag = closest.BUTTON_CHAT; - pointparticles(particleeffectnum("electro_combo"), their_org, '0 0 0', 1); - pointparticles(particleeffectnum("electro_combo"), my_org, '0 0 0', 1); + Send_Effect(EFFECT_ELECTRO_COMBO, their_org, '0 0 0', 1); + Send_Effect(EFFECT_ELECTRO_COMBO, my_org, '0 0 0', 1); - sound(self, CH_TRIGGER, "keepaway/respawn.wav", VOL_BASE, ATTEN_NORM); - sound(closest, CH_TRIGGER, "keepaway/respawn.wav", VOL_BASE, ATTEN_NORM); + sound(self, CH_TRIGGER, SND_KA_RESPAWN, VOL_BASE, ATTEN_NORM); + sound(closest, CH_TRIGGER, SND_KA_RESPAWN, VOL_BASE, ATTEN_NORM); // TODO: add a counter to handle how many times one can teleport, and a delay to prevent spam self.buffs = 0; @@ -658,7 +677,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerThrowKey) } MUTATOR_HOOKFUNCTION(buffs_RemovePlayer) -{ +{SELFPARAM(); if(self.buff_model) { remove(self.buff_model); @@ -673,12 +692,12 @@ MUTATOR_HOOKFUNCTION(buffs_RemovePlayer) } MUTATOR_HOOKFUNCTION(buffs_CustomizeWaypoint) -{ +{SELFPARAM(); entity e = WaypointSprite_getviewentity(other); // if you have the invisibility powerup, sprites ALWAYS are restricted to your team // but only apply this to real players, not to spectators - if((self.owner.flags & FL_CLIENT) && (self.owner.buffs & BUFF_INVISIBLE) && (e == other)) + if((self.owner.flags & FL_CLIENT) && (self.owner.buffs & BUFF_INVISIBLE.m_itemid) && (e == other)) if(DIFF_TEAM(self.owner, e)) return true; @@ -686,7 +705,7 @@ MUTATOR_HOOKFUNCTION(buffs_CustomizeWaypoint) } MUTATOR_HOOKFUNCTION(buffs_OnEntityPreSpawn) -{ +{SELFPARAM(); if(autocvar_g_buffs_replace_powerups) switch(self.classname) { @@ -702,8 +721,8 @@ MUTATOR_HOOKFUNCTION(buffs_OnEntityPreSpawn) } MUTATOR_HOOKFUNCTION(buffs_WeaponRate) -{ - if(self.buffs & BUFF_SPEED) +{SELFPARAM(); + if(self.buffs & BUFF_SPEED.m_itemid) weapon_rate *= autocvar_g_buffs_speed_rate; if(time < self.buff_disability_time) @@ -713,8 +732,8 @@ MUTATOR_HOOKFUNCTION(buffs_WeaponRate) } MUTATOR_HOOKFUNCTION(buffs_WeaponSpeed) -{ - if(self.buffs & BUFF_SPEED) +{SELFPARAM(); + if(self.buffs & BUFF_SPEED.m_itemid) ret_float *= autocvar_g_buffs_speed_weaponspeed; if(time < self.buff_disability_time) @@ -723,14 +742,16 @@ MUTATOR_HOOKFUNCTION(buffs_WeaponSpeed) return false; } +.float buff_time; + MUTATOR_HOOKFUNCTION(buffs_PlayerThink) -{ +{SELFPARAM(); if(gameover || self.deadflag != DEAD_NO) { return false; } if(time < self.buff_disability_time) if(time >= self.buff_disability_effect_time) { - pointparticles(particleeffectnum("smoking"), self.origin + ((self.mins + self.maxs) * 0.5), '0 0 0', 1); + Send_Effect(EFFECT_SMOKING, self.origin + ((self.mins + self.maxs) * 0.5), '0 0 0', 1); self.buff_disability_effect_time = time + 0.5; } @@ -749,49 +770,48 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerThink) { if(self.buffs) { - Send_Notification(NOTIF_ALL_EXCEPT, self, MSG_INFO, INFO_ITEM_BUFF_LOST, self.netname, self.buffs); + int buffid = buff_FirstFromFlags(self.buffs).m_id; + Send_Notification(NOTIF_ALL_EXCEPT, self, MSG_INFO, INFO_ITEM_BUFF_LOST, self.netname, buffid); 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); + Send_Notification(NOTIF_ONE, self, MSG_MULTI, ITEM_BUFF_DROP, buffid); // TODO: special timeout message? + sound(self, CH_TRIGGER, SND_BUFF_LOST, VOL_BASE, ATTN_NORM); } self.buffs = 0; } } - if(self.buffs & BUFF_MAGNET) + if(self.buffs & BUFF_MAGNET.m_itemid) { vector pickup_size = '1 1 1' * autocvar_g_buffs_magnet_range_item; for(other = world; (other = findflags(other, flags, FL_ITEM)); ) if(boxesoverlap(self.absmin - pickup_size, self.absmax + pickup_size, other.absmin, other.absmax)) { - entity oldself = self; - self = other; - other = oldself; + setself(other); + other = this; if(self.touch) self.touch(); other = self; - self = oldself; + setself(this); } } - if(self.buffs & BUFF_AMMO) + if(self.buffs & BUFF_AMMO.m_itemid) if(self.clip_size) self.clip_load = self.(weapon_load[self.switchweapon]) = self.clip_size; - if((self.buffs & BUFF_INVISIBLE) && (self.oldbuffs & BUFF_INVISIBLE)) + if((self.buffs & BUFF_INVISIBLE.m_itemid) && (self.oldbuffs & BUFF_INVISIBLE.m_itemid)) if(self.alpha != autocvar_g_buffs_invisible_alpha) self.alpha = autocvar_g_buffs_invisible_alpha; // powerups reset alpha, so we must enforce this (TODO) -#define BUFF_ONADD(b) if((self.buffs & (b)) && !(self.oldbuffs & (b))) -#define BUFF_ONREM(b) if(!(self.buffs & (b)) && (self.oldbuffs & (b))) +#define BUFF_ONADD(b) if ( (self.buffs & (b).m_itemid) && !(self.oldbuffs & (b).m_itemid)) +#define BUFF_ONREM(b) if (!(self.buffs & (b).m_itemid) && (self.oldbuffs & (b).m_itemid)) 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; + entity buff = buff_FirstFromFlags(self.buffs); + float bufftime = buff != BUFF_Null ? buff.m_time(buff) : 0; + self.buff_time = (bufftime) ? time + bufftime : 0; BUFF_ONADD(BUFF_AMMO) { @@ -841,9 +861,9 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerThink) if(!self.buff_model) buffs_BuffModel_Spawn(self); - self.buff_model.color = Buff_Color(self.buffs); + self.buff_model.color = buff.m_color; self.buff_model.glowmod = buff_GlowColor(self.buff_model); - self.buff_model.skin = Buff_Skin(self.buffs); + self.buff_model.skin = buff.m_skin; self.effects |= EF_NOSHADOW; } @@ -871,7 +891,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerThink) } MUTATOR_HOOKFUNCTION(buffs_SpectateCopy) -{ +{SELFPARAM(); self.buffs = other.buffs; return false; } @@ -891,15 +911,15 @@ MUTATOR_HOOKFUNCTION(buffs_VehicleExit) } MUTATOR_HOOKFUNCTION(buffs_PlayerRegen) -{ - if(self.buffs & BUFF_MEDIC) +{SELFPARAM(); + if(self.buffs & BUFF_MEDIC.m_itemid) { regen_mod_rot = autocvar_g_buffs_medic_rot; regen_mod_limit = regen_mod_max = autocvar_g_buffs_medic_max; regen_mod_regen = autocvar_g_buffs_medic_regen; } - if(self.buffs & BUFF_SPEED) + if(self.buffs & BUFF_SPEED.m_itemid) regen_mod_regen = autocvar_g_buffs_speed_regen; return false; @@ -941,13 +961,6 @@ void buffs_DelayedInit() void buffs_Initialize() { - precache_model(BUFF_MODEL); - precache_sound("misc/strength_respawn.wav"); - precache_sound("misc/shield_respawn.wav"); - precache_sound("relics/relic_effect.wav"); - precache_sound("weapons/rocket_impact.wav"); - precache_sound("keepaway/respawn.wav"); - addstat(STAT_BUFFS, AS_INT, buffs); addstat(STAT_BUFF_TIME, AS_FLOAT, buff_time);