ref: d1c8cb2cfed18f5c5c32347011f33a210c96ff38
parent: 1c756bd681af926fabdb99c57248e68b776e66fd
author: Samuel Villareal <svkaiser@gmail.com>
date: Fri Sep 3 00:11:39 EDT 2010
+ More button flags added to buttoncode_e + Looking/jumping implemented + Jump/look/center keys supported + Strife mouse firing bug implemented Subversion-branch: /branches/strife-branch Subversion-revision: 2003
--- a/src/d_event.h
+++ b/src/d_event.h
@@ -94,13 +94,19 @@
typedef enum
{
// Player view look up
- BT_LOOKUP = 1,
+ BT2_LOOKUP = 1,
// Player view look down
- BT_LOOKDOWN = 2,
+ BT2_LOOKDOWN = 2,
// Center player's view
- BT_CENTERVIEW = 4,
+ BT2_CENTERVIEW = 4,
+ // Use inventory item
+ BT2_INVUSE = 8,
+ // Drop inventory item
+ BT2_INVDROP = 16,
// Jump up and down
- BT_JUMP = 32,
+ BT2_JUMP = 32,
+ // Use medkit
+ BT2_HEALTH = 128,
} buttoncode2_t;
--- a/src/m_controls.h
+++ b/src/m_controls.h
@@ -49,6 +49,17 @@
extern int key_invright;
extern int key_useartifact;
+// villsa [STRIFE] strife keys
+extern int key_usehealth;
+extern int key_invquery;
+extern int key_mission;
+extern int key_invpop;
+extern int key_invkey;
+extern int key_invhome;
+extern int key_invend;
+extern int key_invuse;
+extern int key_invdrop;
+
extern int key_message_refresh;
extern int key_pause;
--- a/src/strife/doomstat.h
+++ b/src/strife/doomstat.h
@@ -191,6 +191,7 @@
//?
extern boolean demoplayback;
extern boolean demorecording;
+extern int mouse_fire_countdown; // villsa [STRIFE]
// Round angleturn in ticcmds to the nearest 256. This is used when
// recording Vanilla demos in netgames.
--- a/src/strife/g_game.c
+++ b/src/strife/g_game.c
@@ -170,6 +170,8 @@
fixed_t sidemove[2] = {0x18, 0x28};
fixed_t angleturn[3] = {640, 1280, 320}; // + slow turn
+int mouse_fire_countdown = 0; // villsa [STRIFE]
+
static int *weapon_keys[] = {
&key_weapon1,
&key_weapon2,
@@ -364,6 +366,16 @@
cmd->consistancy =
consistancy[consoleplayer][maketic%BACKUPTICS];
+
+ // villsa [STRIFE]
+ if(gamekeydown[key_lookup])
+ cmd->buttons2 |= BT2_LOOKUP;
+ if (gamekeydown[key_lookdown])
+ cmd->buttons2 |= BT2_LOOKDOWN;
+ if (gamekeydown[key_usehealth])
+ cmd->buttons2 |= BT2_HEALTH;
+
+
strafe = gamekeydown[key_strafe] || mousebuttons[mousebstrafe]
|| joybuttons[joybstrafe];
@@ -377,6 +389,14 @@
|| joybuttons[joybspeed];
forward = side = 0;
+
+ // villsa [STRIFE] running causes centerview to occur
+ if(speed)
+ cmd->buttons2 |= BT2_CENTERVIEW;
+
+ // villsa [STRIFE] disable running if low on health
+ if (players[consoleplayer].health <= 15)
+ speed = 0;
// use two stage accelerative turning
// on the keyboard and joystick
@@ -456,10 +476,25 @@
// buttons
cmd->chatchar = HU_dequeueChatChar();
+
+ // villsa [STRIFE] TODO - add mouse button support for jump
+ if(gamekeydown[key_jump] /*|| mousebuttons[mousebjump]*/)
+ cmd->buttons2 |= BT2_JUMP;
- if (gamekeydown[key_fire] || mousebuttons[mousebfire]
+ // villsa [STRIFE]
+ if (gamekeydown[key_fire] /*|| mousebuttons[mousebfire]*/
|| joybuttons[joybfire])
- cmd->buttons |= BT_ATTACK;
+ cmd->buttons |= BT_ATTACK;
+
+ // villsa [STRIFE]
+ if(mousebuttons[mousebfire])
+ {
+ if(mouse_fire_countdown <= 0)
+ cmd->buttons |= BT_ATTACK;
+ else
+ --mouse_fire_countdown;
+
+ }
if (gamekeydown[key_use]
|| joybuttons[joybuse]
--- a/src/strife/m_menu.c
+++ b/src/strife/m_menu.c
@@ -1542,6 +1542,7 @@
{
key = key_menu_forward;
mousewait = I_GetTime() + 15;
+ mouse_fire_countdown = 5; // villsa [STRIFE]
}
if (ev->data1&2)
--- a/src/strife/p_user.c
+++ b/src/strife/p_user.c
@@ -167,7 +167,7 @@
onground = (player->mo->z <= player->mo->floorz);
// villsa [STRIFE] jump button
- if (onground && cmd->buttons2 & BT_JUMP)
+ if (onground && cmd->buttons2 & BT2_JUMP)
{
if(!player->deltaviewheight)
player->mo->momz += (8*FRACUNIT);
@@ -187,7 +187,7 @@
}
// villsa [STRIFE] centerview button
- if (cmd->buttons2 & BT_CENTERVIEW)
+ if (cmd->buttons2 & BT2_CENTERVIEW)
player->centerview = 1;
// villsa [STRIFE] adjust player's pitch when centerviewing
@@ -210,7 +210,7 @@
}
// villsa [STRIFE] look up action
- if (cmd->buttons2 & BT_LOOKUP)
+ if (cmd->buttons2 & BT2_LOOKUP)
{
player->pitch += LOOKPITCHAMOUNT;
if ((player->pitch + LOOKPITCHAMOUNT) > LOOKUPMAX ||
@@ -220,7 +220,7 @@
else
{
// villsa [STRIFE] look down action
- if (cmd->buttons2 & BT_LOOKDOWN)
+ if (cmd->buttons2 & BT2_LOOKDOWN)
{
player->pitch -= LOOKPITCHAMOUNT;
if ((player->pitch - LOOKPITCHAMOUNT) > LOOKUPMAX ||
--- a/src/strife/r_main.c
+++ b/src/strife/r_main.c
@@ -35,6 +35,7 @@
#include "doomdef.h"
+#include "doomstat.h" // villsa [STRIFE]
#include "d_net.h"
#include "m_bbox.h"
@@ -79,6 +80,8 @@
fixed_t viewy;
fixed_t viewz;
+int viewpitch; // villsa [STRIFE]
+
angle_t viewangle;
fixed_t viewcos;
@@ -697,7 +700,10 @@
detailshift = setdetail;
viewwidth = scaledviewwidth>>detailshift;
- centery = viewheight/2;
+ // villsa [STRIFE] calculate centery from player's pitch
+ centery = (setblocks*players[consoleplayer].pitch);
+ centery = (unsigned int)(centery/10)+viewheight/2;
+
centerx = viewwidth/2;
centerxfrac = centerx<<FRACBITS;
centeryfrac = centery<<FRACBITS;
@@ -823,8 +829,36 @@
return &subsectors[nodenum & ~NF_SUBSECTOR];
}
+//
+// R_SetupPitch
+// villsa [STRIFE] new function
+// Calculate centery/centeryfrac for player viewpitch
+//
+void R_SetupPitch(player_t* player)
+{
+ fixed_t pitchfrac;
+ int i = 0;
+ if(viewpitch != player->pitch)
+ {
+ viewpitch = player->pitch;
+ pitchfrac = ((setblocks*player->pitch)/10);
+ centery = (pitchfrac+viewheight)/2;
+ centeryfrac = centery<<FRACBITS;
+
+ if(viewheight > 0)
+ {
+ for(i = 0; i < viewheight; i++)
+ {
+ yslope[i] = FixedDiv(viewwidth/2*FRACUNIT,
+ abs(((i-centery)<<FRACBITS)+(FRACUNIT/2)));
+ }
+ }
+ }
+}
+
+
//
// R_SetupFrame
//
@@ -832,6 +866,8 @@
{
int i;
+ R_SetupPitch(player); // villsa [STRIFE]
+
viewplayer = player;
viewx = player->mo->x;
viewy = player->mo->y;
--- a/src/strife/r_things.c
+++ b/src/strife/r_things.c
@@ -699,7 +699,6 @@
// store information in a vissprite
vis = &avis;
vis->mobjflags = 0;
- vis->texturemid = (BASEYCENTER<<FRACBITS)+FRACUNIT/2-(psp->sy-spritetopoffset[lump]);
vis->x1 = x1 < 0 ? 0 : x1;
vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2;
vis->scale = pspritescale<<detailshift;
@@ -714,6 +713,10 @@
vis->xiscale = pspriteiscale;
vis->startfrac = 0;
}
+
+ // villsa [STRIFE] calculate y offset with view pitch
+ vis->texturemid = ((BASEYCENTER<<FRACBITS)+FRACUNIT/2)-(psp->sy-spritetopoffset[lump])
+ + FixedMul(vis->xiscale, (centery-viewheight/2)<<FRACBITS);
if (vis->x1 > x1)
vis->startfrac += vis->xiscale*(vis->x1-x1);