From 59c88c732c10f639a1dae12c712ec010ec8fa492 Mon Sep 17 00:00:00 2001 From: Jakob MG Date: Tue, 31 Jul 2012 07:14:49 +0200 Subject: [PATCH] Fix dropwepons not animating. Fix cl_weapon_stay_ (rename cvars). Initiate autocvars to defualts. Add cl_animate_items to turn animation on/off. Honor .angles set on items by map. --- qcsrc/server/mutators/gamemode_onslaught.qc | 290 ++++++++++---------- qcsrc/server/t_items.qc | 94 +++++-- 2 files changed, 219 insertions(+), 165 deletions(-) diff --git a/qcsrc/server/mutators/gamemode_onslaught.qc b/qcsrc/server/mutators/gamemode_onslaught.qc index 87a059d72..8d4da0f9f 100644 --- a/qcsrc/server/mutators/gamemode_onslaught.qc +++ b/qcsrc/server/mutators/gamemode_onslaught.qc @@ -1,6 +1,6 @@ -float autocvar_g_onslaught_spawn_at_controlpoints = FALSE; -float autocvar_g_onslaught_spawn_at_generator = FALSE; - +float autocvar_g_onslaught_spawn_at_controlpoints = FALSE; +float autocvar_g_onslaught_spawn_at_generator = FALSE; + void onslaught_generator_updatesprite(entity e); void onslaught_controlpoint_updatesprite(entity e); void onslaught_link_checkupdate(); @@ -20,9 +20,9 @@ void onslaught_link_checkupdate(); .float lastcaptured; .string model1, model2, model3; - -entity ons_red_generator; -entity ons_blue_generator; + +entity ons_red_generator; +entity ons_blue_generator; void ons_gib_damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector vforce) { @@ -405,29 +405,29 @@ void onslaught_generator_think() if (e.islinked) d = d + 1; e = e.chain; - } + } if(autocvar_g_campaign && autocvar__campaign_testrun) d = d * self.max_health; else d = d * self.max_health / max(30, 60 * autocvar_timelimit_suddendeath); - + Damage(self, self, self, d, DEATH_HURTTRIGGER, self.origin, '0 0 0'); } else if (overtime_msg_time) - overtime_msg_time = 0; - - if(!self.isshielded && self.wait < time) - { - self.wait = time + 5; - FOR_EACH_PLAYER(e) - { - if(e.team == self.team) - { - centerprint(e, "^1Your generator is NOT shielded!\n^7Re-capture controlpoints to shield it!"); - soundto(MSG_ONE, e, CHAN_AUTO, "kh/alarm.wav", VOL_BASE, ATTN_NONE); // FIXME: Uniqe sound? - } - } + overtime_msg_time = 0; + + if(!self.isshielded && self.wait < time) + { + self.wait = time + 5; + FOR_EACH_PLAYER(e) + { + if(e.team == self.team) + { + centerprint(e, "^1Your generator is NOT shielded!\n^7Re-capture controlpoints to shield it!"); + soundto(MSG_ONE, e, CHAN_AUTO, "kh/alarm.wav", VOL_BASE, ATTN_NONE); // FIXME: Uniqe sound? + } + } } } } @@ -852,10 +852,10 @@ void onslaught_generator_reset() self.nextthink = time + 0.2; setmodel(self, "models/onslaught/generator.md3"); setsize(self, '-52 -52 -14', '52 52 75'); - + if (!self.noalign) droptofloor(); - + WaypointSprite_UpdateMaxHealth(self.sprite, self.max_health); WaypointSprite_UpdateHealth(self.sprite, self.health); } @@ -906,13 +906,13 @@ void spawnfunc_onslaught_generator() precache_sound("onslaught/electricity_explode.wav"); if (!self.team) objerror("team must be set"); - - if(self.team == COLOR_TEAM1) - ons_red_generator = self; - - if(self.team == COLOR_TEAM2) - ons_blue_generator = self; - + + if(self.team == COLOR_TEAM1) + ons_red_generator = self; + + if(self.team == COLOR_TEAM2) + ons_blue_generator = self; + self.team_saved = self.team; self.colormap = 1024 + (self.team - 1) * 17; self.solid = SOLID_BBOX; @@ -931,7 +931,7 @@ void spawnfunc_onslaught_generator() onslaught_generator_damage_spawn(self); // spawn shield model which indicates whether this can be damaged self.enemy = spawn(); - setattachment(self.enemy , self, ""); + setattachment(self.enemy , self, ""); self.enemy.classname = "onslaught_generator_shield"; self.enemy.solid = SOLID_NOT; self.enemy.movetype = MOVETYPE_NONE; @@ -952,7 +952,7 @@ void spawnfunc_onslaught_generator() waypoint_spawnforitem(self); onslaught_updatelinks(); - + self.reset = onslaught_generator_reset; } @@ -1331,8 +1331,8 @@ void spawnfunc_onslaught_controlpoint() setmodel(self, "models/onslaught/controlpoint_pad.md3"); //setsize(self, '-32 -32 0', '32 32 8'); if (!self.noalign) - droptofloor(); - + droptofloor(); + setorigin(self, self.origin); self.touch = onslaught_controlpoint_touch; self.team = 0; @@ -1346,11 +1346,11 @@ void spawnfunc_onslaught_controlpoint() self.enemy.solid = SOLID_NOT; self.enemy.movetype = MOVETYPE_NONE; self.enemy.effects = EF_ADDITIVE; - setmodel(self.enemy , "models/onslaught/controlpoint_shield.md3"); - + setmodel(self.enemy , "models/onslaught/controlpoint_shield.md3"); + setattachment(self.enemy , self, ""); //setsize(e, '-32 -32 0', '32 32 128'); - + //setorigin(e, self.origin); self.enemy.colormap = self.colormap; @@ -1359,7 +1359,7 @@ void spawnfunc_onslaught_controlpoint() WaypointSprite_SpawnFixed(string_null, self.origin + '0 0 128', self, sprite, RADARICON_NONE, '0 0 0'); WaypointSprite_UpdateRule(self.sprite, COLOR_TEAM2, SPRITERULE_TEAMPLAY); - onslaught_updatelinks(); + onslaught_updatelinks(); self.reset = onslaught_controlpoint_reset; } @@ -1466,8 +1466,8 @@ void spawnfunc_onslaught_link() objerror("target and target2 must be set\n"); InitializeEntity(self, onslaught_link_delayed, INITPRIO_FINDTARGET); Net_LinkEntity(self, FALSE, 0, onslaught_link_send); -} - +} + MUTATOR_HOOKFUNCTION(ons_BuildMutatorsString) { ret_string = strcat(ret_string, ":ONS"); @@ -1478,28 +1478,28 @@ MUTATOR_HOOKFUNCTION(ons_BuildMutatorsPrettyString) { ret_string = strcat(ret_string, ", Onslught"); return 0; -} - +} + MUTATOR_HOOKFUNCTION(ons_Spawn_Score) -{ - - /* - float _neer_home = (random() > 0.5 ? TRUE : FALSE); +{ + + /* + float _neer_home = (random() > 0.5 ? TRUE : FALSE); RandomSelection_Init(); - - if(self.team == COLOR_TEAM1) - RandomSelection_Add(ons_red_generator, 0, string_null, 1, 1); - - if(self.team == COLOR_TEAM2) - RandomSelection_Add(ons_blue_generator, 0, string_null, 1, 1); - - entity _cp = findchain(classname, "onslaught_controlpoint"): + + if(self.team == COLOR_TEAM1) + RandomSelection_Add(ons_red_generator, 0, string_null, 1, 1); + + if(self.team == COLOR_TEAM2) + RandomSelection_Add(ons_blue_generator, 0, string_null, 1, 1); + + entity _cp = findchain(classname, "onslaught_controlpoint"): while _cp; - { + { if(_cp.team == self.team) - RandomSelection_Add(_cp, 0, string_null, 1, 1); - + RandomSelection_Add(_cp, 0, string_null, 1, 1); + _cp = _cp.chain; } @@ -1510,108 +1510,108 @@ MUTATOR_HOOKFUNCTION(ons_Spawn_Score) } else if(self.team == spawn_spot.team) spawn_score_x += SPAWN_PRIO_NEAR_TEAMMATE_SAMETEAM; // prefer same team, if we can't find a spawn near teammate - - */ + + */ return 0; -} - -MUTATOR_HOOKFUNCTION(ons_PlayerSpawn) -{ - if(!autocvar_g_onslaught_spawn_at_controlpoints) - return 0; - - if(random() < 0.5) // 50/50 chane to use default spawnsystem. - return 0; - - float _close_to_home = ((random() > 0.5) ? TRUE : FALSE); - entity _best, _trg_gen; - float _score, _best_score = MAX_SHOT_DISTANCE; +} + +MUTATOR_HOOKFUNCTION(ons_PlayerSpawn) +{ + if(!autocvar_g_onslaught_spawn_at_controlpoints) + return 0; + + if(random() < 0.5) // 50/50 chane to use default spawnsystem. + return 0; + + float _close_to_home = ((random() > 0.5) ? TRUE : FALSE); + entity _best, _trg_gen; + float _score, _best_score = MAX_SHOT_DISTANCE; - RandomSelection_Init(); - - if(self.team == COLOR_TEAM1) - { - if(!_close_to_home) - _trg_gen = ons_blue_generator; - else - _trg_gen = ons_red_generator; - } - - if(self.team == COLOR_TEAM2) - { - if(_close_to_home) - _trg_gen = ons_blue_generator; - else - _trg_gen = ons_red_generator; - } - - entity _cp = findchain(classname, "onslaught_controlpoint"); + RandomSelection_Init(); + + if(self.team == COLOR_TEAM1) + { + if(!_close_to_home) + _trg_gen = ons_blue_generator; + else + _trg_gen = ons_red_generator; + } + + if(self.team == COLOR_TEAM2) + { + if(_close_to_home) + _trg_gen = ons_blue_generator; + else + _trg_gen = ons_red_generator; + } + + entity _cp = findchain(classname, "onslaught_controlpoint"); while(_cp) - { + { if(_cp.team == self.team) - { - _score = vlen(_trg_gen.origin - _cp.origin); - if(_score < _best_score) - { - _best = _cp; - _best_score = _score; - } - } + { + _score = vlen(_trg_gen.origin - _cp.origin); + if(_score < _best_score) + { + _best = _cp; + _best_score = _score; + } + } _cp = _cp.chain; - } - - vector _loc; - float i; - if(_best) - { - for(i = 0; i < 10; ++i) - { - _loc = _best.origin + '0 0 96'; - _loc += ('0 1 0' * random()) * 128; - tracebox(_loc, PL_MIN, PL_MAX, _loc, MOVE_NORMAL, self); - if(trace_fraction == 1.0 && !trace_startsolid) - { - setorigin(self, _loc); - self.angles = normalize(_loc - _best.origin) * RAD2DEG; - return 0; - } - } - } - else - { - if(!autocvar_g_onslaught_spawn_at_generator) - return 0; - - _trg_gen = ((self.team == COLOR_TEAM1) ? ons_red_generator : ons_blue_generator); - - for(i = 0; i < 10; ++i) - { - _loc = _trg_gen.origin + '0 0 96'; - _loc += ('0 1 0' * random()) * 128; - tracebox(_loc, PL_MIN, PL_MAX, _loc, MOVE_NORMAL, self); - if(trace_fraction == 1.0 && !trace_startsolid) - { - setorigin(self, _loc); - self.angles = normalize(_loc - _trg_gen.origin) * RAD2DEG; - return 0; - } - } - } - - return 0; -} - + } + + vector _loc; + float i; + if(_best) + { + for(i = 0; i < 10; ++i) + { + _loc = _best.origin + '0 0 96'; + _loc += ('0 1 0' * random()) * 128; + tracebox(_loc, PL_MIN, PL_MAX, _loc, MOVE_NORMAL, self); + if(trace_fraction == 1.0 && !trace_startsolid) + { + setorigin(self, _loc); + self.angles = normalize(_loc - _best.origin) * RAD2DEG; + return 0; + } + } + } + else + { + if(!autocvar_g_onslaught_spawn_at_generator) + return 0; + + _trg_gen = ((self.team == COLOR_TEAM1) ? ons_red_generator : ons_blue_generator); + + for(i = 0; i < 10; ++i) + { + _loc = _trg_gen.origin + '0 0 96'; + _loc += ('0 1 0' * random()) * 128; + tracebox(_loc, PL_MIN, PL_MAX, _loc, MOVE_NORMAL, self); + if(trace_fraction == 1.0 && !trace_startsolid) + { + setorigin(self, _loc); + self.angles = normalize(_loc - _trg_gen.origin) * RAD2DEG; + return 0; + } + } + } + + return 0; +} + MUTATOR_DEFINITION(gamemode_onslaught) { //MUTATOR_HOOK(PlayerDies, nexball_BallDrop, CBC_ORDER_ANY); //MUTATOR_HOOK(MakePlayerObserver, nexball_BallDrop, CBC_ORDER_ANY); - //MUTATOR_HOOK(ClientDisconnect, nexball_BallDrop, CBC_ORDER_ANY); + //MUTATOR_HOOK(ClientDisconnect, nexball_BallDrop, CBC_ORDER_ANY); //MUTATOR_HOOK(PlayerPreThink, nexball_PlayerPreThink, CBC_ORDER_ANY); MUTATOR_HOOK(BuildMutatorsPrettyString, ons_BuildMutatorsPrettyString, CBC_ORDER_ANY); MUTATOR_HOOK(BuildMutatorsString, ons_BuildMutatorsString, CBC_ORDER_ANY); MUTATOR_HOOK(PlayerSpawn, ons_PlayerSpawn, CBC_ORDER_ANY); - //MUTATOR_HOOK(Spawn_Score, ons_Spawn_Score, CBC_ORDER_ANY); + //MUTATOR_HOOK(Spawn_Score, ons_Spawn_Score, CBC_ORDER_ANY); MUTATOR_ONADD { diff --git a/qcsrc/server/t_items.qc b/qcsrc/server/t_items.qc index 2e7b9bfba..fe1c8e805 100644 --- a/qcsrc/server/t_items.qc +++ b/qcsrc/server/t_items.qc @@ -10,17 +10,19 @@ #define ITS_POWERUP 64 #define ISF_COLORMAP 16 #define ISF_DROP 32 +#define ISF_ANGLES 64 .float ItemStatus; #ifdef CSQC -var float autocvar_cl_ghost_items = 1; +var float autocvar_cl_animate_items = 1; +var float autocvar_cl_ghost_items = 0.45; var vector autocvar_cl_ghost_items_color = '-1 -1 -1'; float autocvar_cl_fullbright_items; -vector autocvar_cl_staywep_color; -float autocvar_cl_staywep_alpha; -float autocvar_cl_simple_items; +vector autocvar_cl_weapon_stay_color = '2 0.5 0.5'; +float autocvar_cl_weapon_stay_alpha = 0.75; +float autocvar_cl_simple_items = 1; float cl_simple_items; float cl_ghost_items_alpha; @@ -29,26 +31,50 @@ float cl_ghost_items_alpha; .vector colormod; void ItemDraw() { - if(self.ItemStatus & ITS_ANIMATE1) - { - self.angles += '0 180 0' * frametime; - setorigin(self, '0 0 10' + self.oldorigin + '0 0 8' * sin(time * 2)); - } - - if(self.ItemStatus & ITS_ANIMATE2) - { - self.angles += '0 -90 0' * frametime; - setorigin(self, '0 0 8' + self.oldorigin + '0 0 4' * sin(time * 3)); - } - if(self.gravity) + { Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy); + if(self.move_flags & FL_ONGROUND) + { // For some reason move_avelocity gets set to '0 0 0' here ... + self.oldorigin = self.origin; + self.gravity = 0; + + if(autocvar_cl_animate_items) + { // ... so reset it if animations are requested. + if(self.ItemStatus & ITS_ANIMATE1) + self.move_avelocity = '0 180 0'; + + if(self.ItemStatus & ITS_ANIMATE2) + self.move_avelocity = '0 -90 0'; + } + } + + } + else if (autocvar_cl_animate_items) + { + if(self.ItemStatus & ITS_ANIMATE1) + { + self.angles += self.move_avelocity * frametime; + setorigin(self, '0 0 10' + self.oldorigin + '0 0 8' * sin(time * 2)); + } + + if(self.ItemStatus & ITS_ANIMATE2) + { + self.angles += self.move_avelocity * frametime; + setorigin(self, '0 0 8' + self.oldorigin + '0 0 4' * sin(time * 3)); + } + } } void ItemDrawSimple() { if(self.gravity) + { Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy); + + if(self.move_flags & FL_ONGROUND) + self.gravity = 0; + } } float csqcitems_started; // remove this after a release or two @@ -78,6 +104,14 @@ void ItemRead(float _IsNew) self.oldorigin = self.origin; } + if(sf & ISF_ANGLES) + { + self.angles_x = ReadCoord(); + self.angles_y = ReadCoord(); + self.angles_z = ReadCoord(); + self.move_angles = self.angles; + } + if(sf & ISF_STATUS) // need to read/write status frist so model can handle simple, fb etc. { self.ItemStatus = ReadByte(); @@ -104,8 +138,8 @@ void ItemRead(float _IsNew) if(self.ItemStatus & ITS_STAYWEP) { - self.colormod = self.glowmod = autocvar_cl_staywep_color; - self.alpha = autocvar_cl_staywep_alpha; + self.colormod = self.glowmod = autocvar_cl_weapon_stay_color; + self.alpha = autocvar_cl_weapon_stay_alpha; } @@ -167,6 +201,7 @@ void ItemRead(float _IsNew) if(sf & ISF_DROP) { self.gravity = 1; + self.move_angles = '0 0 0'; self.move_movetype = MOVETYPE_TOSS; self.move_velocity_x = ReadCoord(); self.move_velocity_y = ReadCoord(); @@ -181,8 +216,18 @@ void ItemRead(float _IsNew) } else self.move_time = max(self.move_time, time); - } + } + + if(autocvar_cl_animate_items) + { + if(self.ItemStatus & ITS_ANIMATE1) + self.move_avelocity = '0 180 0'; + + if(self.ItemStatus & ITS_ANIMATE2) + self.move_avelocity = '0 -90 0'; + } } + #endif #ifdef SVQC @@ -197,7 +242,6 @@ float ItemSend(entity to, float sf) WriteByte(MSG_ENTITY, ENT_CLIENT_ITEM); WriteByte(MSG_ENTITY, sf); - //WriteByte(MSG_ENTITY, self.cnt); if(sf & ISF_LOCATION) { @@ -205,6 +249,13 @@ float ItemSend(entity to, float sf) WriteCoord(MSG_ENTITY, self.origin_y); WriteCoord(MSG_ENTITY, self.origin_z); } + + if(sf & ISF_ANGLES) + { + WriteCoord(MSG_ENTITY, self.angles_x); + WriteCoord(MSG_ENTITY, self.angles_y); + WriteCoord(MSG_ENTITY, self.angles_z); + } if(sf & ISF_STATUS) WriteByte(MSG_ENTITY, self.ItemStatus); @@ -1043,6 +1094,9 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime, remove (self); return; } + + if(self.angles != '0 0 0') + self.SendFlags |= ISF_ANGLES; self.reset = Item_Reset; // it's a level item -- 2.39.2