From fe8c0d80cf9b75024b33d565770f5e10ff956376 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 4 Nov 2014 17:38:05 +1100 Subject: [PATCH] Add support for Quake 3 buffs --- qcsrc/common/buffs.qh | 17 ++++++++++++----- qcsrc/server/mutators/mutator_buffs.qc | 22 ++++++++++++++++------ qcsrc/server/t_quake3.qc | 10 +++++----- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/qcsrc/common/buffs.qh b/qcsrc/common/buffs.qh index b61d5307d..fe2dcc6ac 100644 --- a/qcsrc/common/buffs.qh +++ b/qcsrc/common/buffs.qh @@ -42,6 +42,7 @@ REGISTER_BUFF(_("Vengeance"),vengeance,VENGEANCE,15,'0.55 0.5 1'); REGISTER_BUFF(_("Jump"),jump,JUMP,10,'0.7 0.2 1'); REGISTER_BUFF(_("Flight"),flight,FLIGHT,11,'1 0.2 0.5'); REGISTER_BUFF(_("Invisible"),invisible,INVISIBLE,12,'0.9 0.9 0.9'); +#undef REGISTER_BUFF #ifdef SVQC .float buffs; @@ -49,7 +50,7 @@ void buff_Init(entity ent); void buff_Init_Compat(entity ent, float replacement); #define BUFF_SPAWNFUNC(e,b,t) void spawnfunc_item_buff_##e() { self.buffs = b; self.team = t; buff_Init(self); } -#define BUFF_SPAWNFUNC_Q3TA_COMPAT(o,r) void spawnfunc_##o() { buff_Init_Compat(self,r); } +#define BUFF_SPAWNFUNC_Q3TA_COMPAT(o,r) void spawnfunc_item_##o() { buff_Init_Compat(self,r); } #define BUFF_SPAWNFUNCS(e,b) \ BUFF_SPAWNFUNC(e, b, 0) \ BUFF_SPAWNFUNC(e##_team1, b, NUM_TEAM_1) \ @@ -70,10 +71,16 @@ BUFF_SPAWNFUNCS(flight, BUFF_FLIGHT) BUFF_SPAWNFUNCS(invisible, BUFF_INVISIBLE) BUFF_SPAWNFUNCS(random, 0) -BUFF_SPAWNFUNC_Q3TA_COMPAT(item_doubler, BUFF_MEDIC) -BUFF_SPAWNFUNC_Q3TA_COMPAT(item_resistance, BUFF_RESISTANCE) -BUFF_SPAWNFUNC_Q3TA_COMPAT(item_scout, BUFF_SPEED) -BUFF_SPAWNFUNC_Q3TA_COMPAT(item_ammoregen, BUFF_AMMO) +BUFF_SPAWNFUNC_Q3TA_COMPAT(doubler, BUFF_MEDIC) +BUFF_SPAWNFUNC_Q3TA_COMPAT(resistance, BUFF_RESISTANCE) +BUFF_SPAWNFUNC_Q3TA_COMPAT(scout, BUFF_SPEED) +BUFF_SPAWNFUNC_Q3TA_COMPAT(ammoregen, BUFF_AMMO) + +// actually Q3 +BUFF_SPAWNFUNC_Q3TA_COMPAT(flight, BUFF_FLIGHT) +BUFF_SPAWNFUNC_Q3TA_COMPAT(haste, BUFF_SPEED) +BUFF_SPAWNFUNC_Q3TA_COMPAT(invis, BUFF_INVISIBLE) +BUFF_SPAWNFUNC_Q3TA_COMPAT(medic, BUFF_MEDIC) #endif vector Buff_Color(float buff_id); diff --git a/qcsrc/server/mutators/mutator_buffs.qc b/qcsrc/server/mutators/mutator_buffs.qc index 200c307ac..12c3e4feb 100644 --- a/qcsrc/server/mutators/mutator_buffs.qc +++ b/qcsrc/server/mutators/mutator_buffs.qc @@ -1,10 +1,16 @@ float buffs_BuffModel_Customize() { - float same_team = (SAME_TEAM(other, self.owner) || (IS_SPEC(other) && SAME_TEAM(other.enemy, self.owner))); - if(self.owner.alpha <= 0.5 && !same_team && self.owner.alpha != 0) + entity player, myowner; + float same_team; + + player = WaypointSprite_getviewentity(other); + myowner = self.owner; + same_team = (SAME_TEAM(player, myowner) || SAME_TEAM(player, myowner)); + + if(myowner.alpha <= 0.5 && !same_team && myowner.alpha != 0) return FALSE; - - if(other == self.owner || (IS_SPEC(other) && other.enemy == self.owner)) + + if(player == myowner || (IS_SPEC(other) && other.enemy == myowner)) { // somewhat hide the model, but keep the glow self.effects = 0; @@ -66,10 +72,14 @@ void buff_Respawn(entity ent) if(!MoveToRandomMapLocation(ent, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, ((autocvar_g_buffs_random_location_attempts > 0) ? autocvar_g_buffs_random_location_attempts : 10), 1024, 256)) { entity spot = SelectSpawnPoint(TRUE); - setorigin(self, (spot.origin + '0 0 200') + (randomvec() * 300)); - self.angles = spot.angles; + setorigin(ent, ((spot.origin + '0 0 200') + (randomvec() * 300))); + ent.angles = spot.angles; } + tracebox(ent.origin, ent.mins * 1.5, self.maxs * 1.5, ent.origin, MOVE_NOMONSTERS, ent); + + setorigin(ent, trace_endpos); // attempt to unstick + ent.movetype = MOVETYPE_TOSS; makevectors(ent.angles); diff --git a/qcsrc/server/t_quake3.qc b/qcsrc/server/t_quake3.qc index bb1128bd6..5a1885588 100644 --- a/qcsrc/server/t_quake3.qc +++ b/qcsrc/server/t_quake3.qc @@ -114,18 +114,18 @@ void spawnfunc_target_give() InitializeEntity(self, target_give_init, INITPRIO_FINDTARGET); } -//void spawnfunc_item_flight() /* not supported */ -//void spawnfunc_item_haste() /* not supported */ +//void spawnfunc_item_flight() /* handled by buffs mutator */ +//void spawnfunc_item_haste() /* handled by buffs mutator */ //void spawnfunc_item_health() /* handled in t_quake.qc */ //void spawnfunc_item_health_large() /* handled in t_items.qc */ //void spawnfunc_item_health_small() /* handled in t_items.qc */ //void spawnfunc_item_health_mega() /* handled in t_items.qc */ -//void spawnfunc_item_invis() /* not supported */ -//void spawnfunc_item_regen() /* not supported */ +//void spawnfunc_item_invis() /* handled by buffs mutator */ +//void spawnfunc_item_regen() /* handled by buffs mutator */ // CTF spawnfuncs handled in mutators/gamemode_ctf.qc now -void spawnfunc_item_flight() { spawnfunc_item_jetpack(); } +//void spawnfunc_item_flight() { spawnfunc_item_jetpack(); } .float notteam; .float notsingle; -- 2.39.2