From 1b32a3bbad6ff508e528498a4eca9848d51996f7 Mon Sep 17 00:00:00 2001 From: avirox Date: Thu, 19 Jan 2006 23:45:15 +0000 Subject: [PATCH] - Added sprite entity that spawns over players and is visible to teammates (from nexuiz 1.3) - Added system to detect if client is using bloom in ClientCommand parse code - Flash grenades will not display bloom effects if "r_bloom" is not on git-svn-id: svn://svn.icculus.org/nexuiz/trunk@854 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- TeamNexuiz/game/gamec/cl_client.c | 29 ++++++++++++++++++ TeamNexuiz/game/gamec/tfclient.c | 49 +++++++++++++++++++++++++++++- TeamNexuiz/game/gamec/tfdefs.c | 2 ++ TeamNexuiz/game/gamec/tfgrenades.c | 29 +++++++++--------- TeamNexuiz/game/gamec/w_common.c | 2 +- 5 files changed, 95 insertions(+), 16 deletions(-) diff --git a/TeamNexuiz/game/gamec/cl_client.c b/TeamNexuiz/game/gamec/cl_client.c index 979ca4916..f70a7ddb7 100644 --- a/TeamNexuiz/game/gamec/cl_client.c +++ b/TeamNexuiz/game/gamec/cl_client.c @@ -635,12 +635,30 @@ ClientDisconnect Called when a client disconnects from the server ============= */ +.entity chatbubbleentity; void ClientDisconnect (void) { //ClientDisconnected(); self.has_disconnected = 1; bprint ("^4",self.netname); bprint (" disconnected\n"); + + if (self.chatbubbleentity) + { + remove (self.chatbubbleentity); + self.chatbubbleentity = world; + } + + if (self.teambubble_friendly) + { + remove (self.teambubble_friendly); + self.teambubble_friendly = world; + } + if (self.teambubble_needhealth) + { + remove (self.teambubble_needhealth); + self.teambubble_needhealth = world; + } } .entity chatbubbleentity; @@ -1144,6 +1162,7 @@ void PlayerPostThink (void) CheckRules_Player(); UpdateChatBubble(); UpdateColorModHack(); + UpdateTeamBubble(); if (self.deadflag == DEAD_NO) if (self.impulse) ImpulseCommands (); @@ -1342,6 +1361,16 @@ void SV_ParseClientCommand (string s) } return; } + else if (c == "check_val") + { + if (d == "r_bloom") + { + if (f == "1") + self.uses_bloom = 1; + else + self.uses_bloom = 0; + } + } else { clientcommand(self, s); diff --git a/TeamNexuiz/game/gamec/tfclient.c b/TeamNexuiz/game/gamec/tfclient.c index 4ded7f3f3..7a6c721d2 100644 --- a/TeamNexuiz/game/gamec/tfclient.c +++ b/TeamNexuiz/game/gamec/tfclient.c @@ -106,4 +106,51 @@ void () execute_changelevel = other = find (other, classname, "player"); } WriteByte (2, 30); -}; \ No newline at end of file +}; + +.entity teambubble_needhealth; // displays when player's health is below 30% +.entity teambubble_friendly; // displays that player is friendly teammate +//repeated defs: +.float buttonchat; +.entity exteriormodeltoclient; + +void() TeamBubbleThink = +{ + self.nextthink = time; + if (!self.owner.modelindex || self.owner.teambubble_friendly != self) + { + remove(self); + return; + } + setorigin(self, self.owner.origin + '0 0 15' + self.owner.maxs_z * '0 0 1'); + if (self.owner.buttonchat || self.owner.deadflag) + self.model = ""; + else + self.model = self.mdl; + +}; + +.float() customizeentityforclient; // new DP extension used for the team bubble +float() ChatBubble_customizeentityforclient = {return (self.owner.team_no == other.team_no && other.killcount > -666);}; + + + +void() UpdateTeamBubble = +{ + if (!self.modelindex || !cvar("teamplay")) + return; + // spawn a teambubble entity if needed + if (!self.teambubble_friendly && cvar("teamplay")) + { + self.teambubble_friendly = spawn(); + self.teambubble_friendly.owner = self; + self.teambubble_friendly.exteriormodeltoclient = self; + self.teambubble_friendly.think = TeamBubbleThink; + self.teambubble_friendly.nextthink = time; + setmodel(self.teambubble_friendly, "models/team/team.sp2"); + setorigin(self.teambubble_friendly, self.origin + '0 0 15' + self.maxs_z * '0 0 1'); + self.teambubble_friendly.mdl = self.teambubble_friendly.model; + self.teambubble_friendly.model = self.teambubble_friendly.mdl; + self.teambubble_friendly.customizeentityforclient = ChatBubble_customizeentityforclient; + } +} diff --git a/TeamNexuiz/game/gamec/tfdefs.c b/TeamNexuiz/game/gamec/tfdefs.c index 252888300..625f19882 100644 --- a/TeamNexuiz/game/gamec/tfdefs.c +++ b/TeamNexuiz/game/gamec/tfdefs.c @@ -165,6 +165,8 @@ float CLIP_MAX_PIPEGRENADES = 6; .float heat; // What tf uses for powering up weapons. Could be useful later? +.float uses_bloom; // Does the client have bloom enabled? (used for flash bloom effect) + entity otemp; entity stemp; diff --git a/TeamNexuiz/game/gamec/tfgrenades.c b/TeamNexuiz/game/gamec/tfgrenades.c index b0ae976fa..8eb817e49 100644 --- a/TeamNexuiz/game/gamec/tfgrenades.c +++ b/TeamNexuiz/game/gamec/tfgrenades.c @@ -89,19 +89,17 @@ void () FlashTimer = { te.FlashTime = 0.000000; stuffcmd (te, "v_cshift 0\n"); - stuffcmd (te, "r_bloom_power 2\n"); - stuffcmd (te, "r_bloom_intensity 1.5\n"); + if (te.uses_bloom) + { + stuffcmd (te, "r_bloom_power 2\n"); + stuffcmd (te, "r_bloom_intensity 1.5\n"); + } remove (self); return; } if ((te.FlashTime < 1.700000)) { - st = ftos ((te.FlashTime * 150.000000)); -// lets add a bloom check later? -/* - avirox: stuffcmd(self, "cmd mycvar $mycvar\n"); - avirox: then later in your SV_ParseClientCommand() qc function you'll see a string come in like "mycvar 1" -*/ + st = ftos ((te.FlashTime * 150.000000)); stuffcmd (te, "v_cshift "); stuffcmd (te, st); stuffcmd (te, " "); @@ -113,12 +111,14 @@ void () FlashTimer = stuffcmd (te, "\n"); // BLOOM!!! :D - stuffcmd (te, "r_bloom_power 1\n"); - - st = ftos(2 + (te.FlashTime * 10)); - stuffcmd (te, "r_bloom_intensity "); - stuffcmd (te, st); - stuffcmd (te, "\n"); + if (te.uses_bloom) + { + stuffcmd (te, "r_bloom_power 1\n"); + st = ftos(2 + (te.FlashTime * 10)); + stuffcmd (te, "r_bloom_intensity "); + stuffcmd (te, st); + stuffcmd (te, "\n"); + } } if ((te.FlashTime >= 1.700000)) @@ -171,6 +171,7 @@ void () FlashGrenadeExplode = newmis.owner = te; newmis.think = FlashTimer; newmis.nextthink = (time + 0.100000); + stuffcmd(te, "cmd check_val r_bloom $r_bloom\n"); // checks if the client has bloom enabled } te.FlashTime = 4.500000; stuffcmd (te, "v_cshift 255 255 255 255\n"); diff --git a/TeamNexuiz/game/gamec/w_common.c b/TeamNexuiz/game/gamec/w_common.c index e1ba64055..a0d7d9241 100644 --- a/TeamNexuiz/game/gamec/w_common.c +++ b/TeamNexuiz/game/gamec/w_common.c @@ -698,7 +698,7 @@ float (entity a, vector start, vector end, float flt, entity b) FindBodyDamage = x = vlen ((g - h)); f = ((normalize (f) * x) + trace_endpos); zdif = (f_z - trace_ent.origin_z); - bprint(ftos(zdif)); + bprint(ftos(x)); bprint("\n"); deathmsg = 18; trace_ent.head_shot_vector = '0 0 0'; -- 2.39.2