From f4363f6d70eaef4e414effc76cbaabdc89bc2af2 Mon Sep 17 00:00:00 2001 From: avirox Date: Tue, 17 Jan 2006 03:59:41 +0000 Subject: [PATCH] - Added spy feign function (TeamNexuiz_Feign) & impulse constant - Added TeamNexuiz_GunUp/GunDown functions for raising/lowering the first-person gun model - Added smooth(ish) player offset movement function (currently used for feign) to spy.c git-svn-id: svn://svn.icculus.org/nexuiz/trunk@841 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- TeamNexuiz/game/gamec/cl_client.c | 2 + TeamNexuiz/game/gamec/cl_impulse.c | 5 ++ TeamNexuiz/game/gamec/cl_physics.c | 5 +- TeamNexuiz/game/gamec/cl_player.c | 5 ++ TeamNexuiz/game/gamec/cl_weapons.c | 2 +- TeamNexuiz/game/gamec/class.c | 11 ++-- TeamNexuiz/game/gamec/spy.c | 80 ++++++++++++++++++++++++++++ TeamNexuiz/game/gamec/tf_constants.c | 2 + TeamNexuiz/game/gamec/tfdefs.c | 3 ++ TeamNexuiz/game/gamec/tffunctions.c | 16 +++++- 10 files changed, 125 insertions(+), 6 deletions(-) diff --git a/TeamNexuiz/game/gamec/cl_client.c b/TeamNexuiz/game/gamec/cl_client.c index f9ba71e94..979ca4916 100644 --- a/TeamNexuiz/game/gamec/cl_client.c +++ b/TeamNexuiz/game/gamec/cl_client.c @@ -484,6 +484,8 @@ void PutClientInServer (void) self.poison_damage = 0; self.poison_rate = 0; + self.is_feigning = 0; + // if the player is supposed to change model (and hence class) on respawn, do it. if(self.change_mdl_on_respawn != "") { diff --git a/TeamNexuiz/game/gamec/cl_impulse.c b/TeamNexuiz/game/gamec/cl_impulse.c index 9c5942109..27144da31 100644 --- a/TeamNexuiz/game/gamec/cl_impulse.c +++ b/TeamNexuiz/game/gamec/cl_impulse.c @@ -155,6 +155,11 @@ void ImpulseCommands (void) TeamFortress_ThrowGrenade(); } + if (self.impulse == FEIGN_IMPULSE) + { + TeamNexuiz_Feign(); + } + if (self.impulse >= 1 && self.impulse <= 5) { if(self.buttonuse) diff --git a/TeamNexuiz/game/gamec/cl_physics.c b/TeamNexuiz/game/gamec/cl_physics.c index 74dd74a3f..4e7e9b687 100644 --- a/TeamNexuiz/game/gamec/cl_physics.c +++ b/TeamNexuiz/game/gamec/cl_physics.c @@ -34,8 +34,11 @@ void MauveBot_AI(); void SV_PlayerPhysics() { - if (self.is_building == 1/* && self.reload_time > time*/) + if (self.is_building == 1 || self.is_feigning == 1) + { + self.velocity = '0 0 0'; return; + } local vector wishvel, wishdir, v; local float wishspeed, prevspeed, f; diff --git a/TeamNexuiz/game/gamec/cl_player.c b/TeamNexuiz/game/gamec/cl_player.c index 6154f4d9d..82456e674 100644 --- a/TeamNexuiz/game/gamec/cl_player.c +++ b/TeamNexuiz/game/gamec/cl_player.c @@ -96,6 +96,11 @@ void player_anim (void) return; } + if (self.is_feigning == 1) + { + self.frame = self.die_frame; + return; + } if (self.crouch) { diff --git a/TeamNexuiz/game/gamec/cl_weapons.c b/TeamNexuiz/game/gamec/cl_weapons.c index 3321499d3..f70cfa920 100644 --- a/TeamNexuiz/game/gamec/cl_weapons.c +++ b/TeamNexuiz/game/gamec/cl_weapons.c @@ -7,7 +7,7 @@ void (float wreq) w_mac; void (float wreq) w_pistol; void(float wpn, float wrequest) weapon_action = { - if ((self.reload_time + .25) > time) { + if ((self.reload_time + .25) > time || self.is_feigning == 1) { return; } if (wpn == WEP5) { diff --git a/TeamNexuiz/game/gamec/class.c b/TeamNexuiz/game/gamec/class.c index 9d8cf4ea5..b662dc6aa 100644 --- a/TeamNexuiz/game/gamec/class.c +++ b/TeamNexuiz/game/gamec/class.c @@ -293,7 +293,7 @@ float CheckForClassChange() //if(self.health <= 0) // fixme: or if player is an observer // return 0; - bprint("healthy\n"); +// bprint("healthy\n"); if(self.playermodel == self.mdl) return 0; // haven't changed models since last legitimate change @@ -361,7 +361,7 @@ float CheckForClassChange() sprint(self, "You have no lives left.\n"); return 0; } - if (!IsLegalClass(tfcl)) + if (!IsLegalClass(tfcl)) // Checks if class is legal for the map { self.playermodel = self.mdl; // return to old model ResetPlayerModel(self); @@ -378,7 +378,11 @@ float CheckForClassChange() self.change_mdl_on_respawn = strzone(self.change_mdl_on_respawn); self.playermodel = self.model; if (self.team_no > 0) - sprint(self, "You will change class after you die\n"); + { + sprint (self, "After dying, you will return as a "); + TeamFortress_PrintClassName (self, cl, (self.tfstate & 8)); + } +// sprint(self, "You will change class after you die\n"); return 0; } @@ -481,6 +485,7 @@ void ClassPostThink() */ void (float classnum) SetMaxAmmoFor = { + self.is_feigning = 0; self.leg_damage = 0; //temp here //so leg damage doesnt stay on player respawn // if no class is found, it will just default to these self.maxammo_shells = 200; diff --git a/TeamNexuiz/game/gamec/spy.c b/TeamNexuiz/game/gamec/spy.c index 139ddee40..2dca25a9f 100644 --- a/TeamNexuiz/game/gamec/spy.c +++ b/TeamNexuiz/game/gamec/spy.c @@ -216,3 +216,83 @@ void BecomeSpy(float portion) // fixme: also have off-hand grenade, different for each class // where to do that? } + +/*void () Switch_View_Think = +{ + if (self.health < 1) + dremove(self); + self.owner.view_ofs = self.view_ofs * self.health; + + self.health = self.health - 1; + self.nextthink = time; + +}; + +void (vector vchange) Switch_View = +{ + local entity viewchanger; + local vector changevec; + + changevec = ((self.view_ofs - vchange) * .10); + + viewchanger = spawn(); + viewchanger.think = Switch_View_Think; + viewchanger.nextthink = time; + viewchanger.owner = self; + viewchanger.view_ofs = changevec; + viewchanger.health = 10; +};*/ + +void () Switch_View_Think = +{ + if (time > self.button1 + self.health) + dremove(self); + self.owner.view_ofs = self.owner.view_ofs - ((self.view_ofs * frametime) * (1 / self.health)); + self.nextthink = time; +}; +void (vector vchange, float change_spd) Switch_View = +{ + local entity viewchanger; + local vector changevec; + changevec = self.view_ofs - vchange; + viewchanger = spawn(); + viewchanger.think = Switch_View_Think; + viewchanger.nextthink = time; + viewchanger.owner = self; + viewchanger.view_ofs = changevec; + viewchanger.health = change_spd; + viewchanger.button1 = time; +} + +// Spy Feign +void () TeamNexuiz_Feign = +{ + if (self.playerclass != TF_CLASS_SPY) + return; + if ((self.reload_time + .25) > time) + return; + if (self.health <= 0) + return; + if (!(self.flags & FL_ONGROUND)) + { + sprint(self, "You cannot feign mid-air\n"); + return; + } + self.velocity = '0 0 0'; + if (self.is_feigning == 1) + { + self.is_feigning = 0; + setsize(self, PL_MIN, PL_MAX); + Switch_View(PL_VIEW_OFS, .3); + //self.view_ofs = PL_VIEW_OFS; + TeamNexuiz_GunUp(); + } + else + { + self.is_feigning = 1; + setsize(self, '-16 -16 -24', '16 16 5'); + Switch_View(PL_FEIGN_VIEW_OFS, .3); + TeamNexuiz_GunDown(); + //self.view_ofs = PL_FEIGN_VIEW_OFS; + } +}; \ No newline at end of file diff --git a/TeamNexuiz/game/gamec/tf_constants.c b/TeamNexuiz/game/gamec/tf_constants.c index b3ebc859c..d09d229c6 100644 --- a/TeamNexuiz/game/gamec/tf_constants.c +++ b/TeamNexuiz/game/gamec/tf_constants.c @@ -5,6 +5,7 @@ /*****************************************************/ float DROP_FLAG_IMPULSE = 203; float RELOAD_IMPULSE = 70; +float FEIGN_IMPULSE = 204; /******************* Death Messages ********************/ @@ -28,3 +29,4 @@ float BODYSHOT = 0; float LEGSHOT = 1; float CHESTSHOT = 2; float HEADSHOT = 3; +vector PL_FEIGN_VIEW_OFS = '0 0 10'; // feign view offset diff --git a/TeamNexuiz/game/gamec/tfdefs.c b/TeamNexuiz/game/gamec/tfdefs.c index b8bae529a..252888300 100644 --- a/TeamNexuiz/game/gamec/tfdefs.c +++ b/TeamNexuiz/game/gamec/tfdefs.c @@ -91,6 +91,9 @@ float blueflagexists; .void() th_missile; .void() th_melee; +// spy feign +.float is_feigning; + // Weapon Clips .float reload_time; .float clip_pistol; diff --git a/TeamNexuiz/game/gamec/tffunctions.c b/TeamNexuiz/game/gamec/tffunctions.c index 8f29c8b30..03b49ed7a 100644 --- a/TeamNexuiz/game/gamec/tffunctions.c +++ b/TeamNexuiz/game/gamec/tffunctions.c @@ -2342,4 +2342,18 @@ void () DropFlag = Item.nextthink = time + 5; Item.think = tfgoalitem_dropthink; Item.touch = item_tfgoal_touch; -} \ No newline at end of file +} + +void () TeamNexuiz_GunDown = //brings first-person gun model down +{ + self.weaponentity.pos1 = PLAYER_WEAPONSELECTION_RANGE; + self.weaponentity.lip = PLAYER_WEAPONSELECTION_SPEED; +}; +void () TeamNexuiz_GunUp = //brings first-person gun model up +{ + if (self.weaponentity.pos1 != '0 0 0') + { + self.weaponentity.pos1 = '0 0 0'; + self.weaponentity.lip = PLAYER_WEAPONSELECTION_SPEED; + } +}; \ No newline at end of file -- 2.39.2