foxygit / doom Log in
commit 42572cb925b9723cfa69ff37816de213d7d8a469
Author:     Samuel Villareal <svkaiser@gmail.com>
AuthorDate: Thu Sep 2 05:11:42 2010 +0000
Commit:     Samuel Villareal <svkaiser@gmail.com>
CommitDate: Thu Sep 2 05:11:42 2010 +0000

    + Jumping/look/centerview actions added
    + button code/flags added for cmd->buttons2

    Subversion-branch: /branches/strife-branch
    Subversion-revision: 1999
---
 src/d_event.h       | 15 +++++++++++++++
 src/strife/p_user.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+)

diff --git a/src/d_event.h b/src/d_event.h
index e47f82df..eb9211bb 100644
--- a/src/d_event.h
+++ b/src/d_event.h
@@ -89,6 +89,21 @@ typedef enum

 } buttoncode_t;

+// villsa [STRIFE] Strife specific buttons
+// TODO - not finished
+typedef enum
+{
+    // Player view look up
+    BT_LOOKUP           = 1,
+    // Player view look down
+    BT_LOOKDOWN         = 2,
+    // Center player's view
+    BT_CENTERVIEW       = 4,
+    // Jump up and down
+    BT_JUMP             = 32,
+
+} buttoncode2_t;
+



diff --git a/src/strife/p_user.c b/src/strife/p_user.c
index 9d44f78c..3c0cdb5e 100644
--- a/src/strife/p_user.c
+++ b/src/strife/p_user.c
@@ -40,6 +40,10 @@

 // Index of the special effects (INVUL inverse) map.
 #define INVERSECOLORMAP		32
+#define LOOKPITCHAMOUNT         6       // villsa [STRIFE]
+#define CENTERVIEWAMOUNT        (LOOKPITCHAMOUNT + 2)   // villsa [STRIFE]
+#define LOOKUPMAX               90      // villsa [STRIFE]
+#define LOOKDOWNMAX             -110    // villsa [STRIFE]


 //
@@ -161,6 +165,13 @@ void P_MovePlayer (player_t* player)
     // Do not let the player control movement
     //  if not onground.
     onground = (player->mo->z <= player->mo->floorz);
+
+    // villsa [STRIFE] jump button
+    if (onground && cmd->buttons2 & BT_JUMP)
+    {
+        if(!player->deltaviewheight)
+            player->mo->momz += (8*FRACUNIT);
+    }

     if (cmd->forwardmove && onground)
 	P_Thrust (player, player->mo->angle, cmd->forwardmove*2048);
@@ -174,6 +185,50 @@ void P_MovePlayer (player_t* player)
     {
 	P_SetMobjState (player->mo, S_PLAY_01);
     }
+
+    // villsa [STRIFE] centerview button
+    if (cmd->buttons2 & BT_CENTERVIEW)
+        player->centerview = 1;
+
+    // villsa [STRIFE] adjust player's pitch when centerviewing
+    if (player->centerview)
+    {
+        if (player->pitch <= 0)
+        {
+            if (player->pitch < 0)
+                player->pitch = player->pitch + CENTERVIEWAMOUNT;
+        }
+        else
+        {
+            player->pitch = player->pitch - CENTERVIEWAMOUNT;
+        }
+        if (abs(player->pitch) < CENTERVIEWAMOUNT)
+        {
+            player->pitch = 0;
+            player->centerview = 0;
+        }
+    }
+
+    // villsa [STRIFE] look up action
+    if (cmd->buttons2 & BT_LOOKUP)
+    {
+        player->pitch += LOOKPITCHAMOUNT;
+        if ((player->pitch + LOOKPITCHAMOUNT) > LOOKUPMAX ||
+            (player->pitch + LOOKPITCHAMOUNT) < LOOKDOWNMAX)
+            player->pitch -= LOOKPITCHAMOUNT;
+    }
+    else
+    {
+        // villsa [STRIFE] look down action
+        if (cmd->buttons2 & BT_LOOKDOWN)
+        {
+            player->pitch -= LOOKPITCHAMOUNT;
+            if ((player->pitch - LOOKPITCHAMOUNT) > LOOKUPMAX ||
+                (player->pitch - LOOKPITCHAMOUNT) < LOOKDOWNMAX)
+                player->pitch += LOOKPITCHAMOUNT;
+        }
+    }
+
 }