Improve r6723. Adds EVENT_LASTWEAPON.

Patch from Fox.

git-svn-id: https://svn.eduke32.com/eduke32@6738 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2018-03-08 03:54:54 +00:00
parent 6e7cc1878a
commit 4158aa802a
10 changed files with 22 additions and 14 deletions

View file

@ -111,7 +111,7 @@ char gamefunctions[NUMGAMEFUNCTIONS][MAXGAMEFUNCLEN] =
"Dpad_Select", "Dpad_Select",
"Dpad_Aiming", "Dpad_Aiming",
"Alternate_Weapon", "Alternate_Weapon",
"Last_Used_Weapon" "Last_Used_Weapon",
}; };
#ifdef __SETUP__ #ifdef __SETUP__

View file

@ -149,6 +149,7 @@ enum GameEvent_t {
EVENT_PLAYLEVELMUSICSLOT, EVENT_PLAYLEVELMUSICSLOT,
EVENT_CONTINUELEVELMUSICSLOT, EVENT_CONTINUELEVELMUSICSLOT,
EVENT_DISPLAYPOINTER, EVENT_DISPLAYPOINTER,
EVENT_LASTWEAPON,
#ifdef LUNATIC #ifdef LUNATIC
EVENT_ANIMATEALLSPRITES, EVENT_ANIMATEALLSPRITES,
#endif #endif

View file

@ -7157,5 +7157,5 @@ static void G_SetupGameButtons(void)
CONTROL_DefineFlag(gamefunc_Next_Weapon,FALSE); CONTROL_DefineFlag(gamefunc_Next_Weapon,FALSE);
CONTROL_DefineFlag(gamefunc_Previous_Weapon,FALSE); CONTROL_DefineFlag(gamefunc_Previous_Weapon,FALSE);
CONTROL_DefineFlag(gamefunc_Alt_Weapon,FALSE); CONTROL_DefineFlag(gamefunc_Alt_Weapon,FALSE);
CONTROL_DefineFlag(gamefunc_Last_Weapon, FALSE); CONTROL_DefineFlag(gamefunc_Last_Weapon,FALSE);
} }

View file

@ -756,6 +756,7 @@ const char *EventNames[MAXEVENTS] =
"EVENT_PLAYLEVELMUSICSLOT", "EVENT_PLAYLEVELMUSICSLOT",
"EVENT_CONTINUELEVELMUSICSLOT", "EVENT_CONTINUELEVELMUSICSLOT",
"EVENT_DISPLAYPOINTER", "EVENT_DISPLAYPOINTER",
"EVENT_LASTWEAPON",
#ifdef LUNATIC #ifdef LUNATIC
"EVENT_ANIMATEALLSPRITES", "EVENT_ANIMATEALLSPRITES",
#endif #endif
@ -1090,6 +1091,7 @@ const memberlabel_t PlayerLabels[]=
{ "connected", PLAYER_CONNECTED, 0, 0 }, { "connected", PLAYER_CONNECTED, 0, 0 },
{ "frags", PLAYER_FRAGS, LABEL_HASPARM2, MAXPLAYERS }, { "frags", PLAYER_FRAGS, LABEL_HASPARM2, MAXPLAYERS },
{ "deaths", PLAYER_DEATHS, 0, 0 }, { "deaths", PLAYER_DEATHS, 0, 0 },
{ "last_used_weapon", PLAYER_LAST_USED_WEAPON, 0, 0 },
{ NULL, -1, 0, 0 } // END OF LIST { NULL, -1, 0, 0 } // END OF LIST
}; };

View file

@ -421,6 +421,7 @@ enum PlayerLabel_t
PLAYER_CONNECTED, PLAYER_CONNECTED,
PLAYER_FRAGS, PLAYER_FRAGS,
PLAYER_DEATHS, PLAYER_DEATHS,
PLAYER_LAST_USED_WEAPON,
PLAYER_END PLAYER_END
}; };

View file

@ -694,6 +694,7 @@ int32_t __fastcall VM_GetPlayer(int32_t const playerNum, int32_t labelNum, int32
labelNum = g_player[playerNum].frags[lParm2]; labelNum = g_player[playerNum].frags[lParm2];
break; break;
case PLAYER_DEATHS: labelNum = g_player[playerNum].frags[playerNum]; break; case PLAYER_DEATHS: labelNum = g_player[playerNum].frags[playerNum]; break;
case PLAYER_LAST_USED_WEAPON: labelNum = ps->last_used_weapon; break;
default: labelNum = -1; break; default: labelNum = -1; break;
} }
@ -890,6 +891,7 @@ void __fastcall VM_SetPlayer(int32_t const playerNum, int32_t const labelNum, in
g_player[playerNum].frags[lParm2] = iSet; g_player[playerNum].frags[lParm2] = iSet;
break; break;
case PLAYER_DEATHS: g_player[playerNum].frags[playerNum] = iSet; break; case PLAYER_DEATHS: g_player[playerNum].frags[playerNum] = iSet; break;
case PLAYER_LAST_USED_WEAPON: ps->last_used_weapon = iSet; break;
default: break; default: break;
} }
} }

View file

@ -2811,7 +2811,6 @@ enddisplayweapon:
int32_t g_myAimMode = 0, g_myAimStat = 0, g_oldAimStat = 0; int32_t g_myAimMode = 0, g_myAimStat = 0, g_oldAimStat = 0;
int32_t mouseyaxismode = -1; int32_t mouseyaxismode = -1;
int32_t g_emuJumpTics = 0; int32_t g_emuJumpTics = 0;
int32_t g_lastWeapon = 0;
void P_GetInput(int playerNum) void P_GetInput(int playerNum)
{ {
@ -2975,7 +2974,7 @@ void P_GetInput(int playerNum)
weaponSelection = 13; weaponSelection = 13;
if (BUTTON(gamefunc_Last_Weapon)) if (BUTTON(gamefunc_Last_Weapon))
weaponSelection = g_lastWeapon + 1; weaponSelection = 14;
if (BUTTON(gamefunc_Jump) && pPlayer->on_ground) if (BUTTON(gamefunc_Jump) && pPlayer->on_ground)
g_emuJumpTics = 4; g_emuJumpTics = 4;
@ -3350,15 +3349,10 @@ static void P_ChangeWeapon(DukePlayer_t * const pPlayer, int const weaponNum)
} }
if (currentWeapon != pPlayer->curr_weapon && if (currentWeapon != pPlayer->curr_weapon &&
// p->last_weapon != -1 &&
!(PWEAPON(playerNum, currentWeapon, WorksLike) == HANDREMOTE_WEAPON && PWEAPON(playerNum, pPlayer->curr_weapon, WorksLike) == HANDBOMB_WEAPON) && !(PWEAPON(playerNum, currentWeapon, WorksLike) == HANDREMOTE_WEAPON && PWEAPON(playerNum, pPlayer->curr_weapon, WorksLike) == HANDBOMB_WEAPON) &&
!(PWEAPON(playerNum, currentWeapon, WorksLike) == HANDBOMB_WEAPON && PWEAPON(playerNum, pPlayer->curr_weapon, WorksLike) == HANDREMOTE_WEAPON)) !(PWEAPON(playerNum, currentWeapon, WorksLike) == HANDBOMB_WEAPON && PWEAPON(playerNum, pPlayer->curr_weapon, WorksLike) == HANDREMOTE_WEAPON))
{ {
g_lastWeapon = PWEAPON(playerNum, currentWeapon, WorksLike) == HANDREMOTE_WEAPON ? (int) HANDBOMB_WEAPON : currentWeapon; pPlayer->last_used_weapon = currentWeapon;
if (g_lastWeapon == GROW_WEAPON) g_lastWeapon = SHRINKER_WEAPON;
#ifdef __ANDROID__
CONTROL_Android_SetLastWeapon(g_lastWeapon);
#endif
} }
pPlayer->kickback_pic = 0; pPlayer->kickback_pic = 0;

View file

@ -201,6 +201,8 @@ typedef struct {
uint8_t palette; uint8_t palette;
palette_t pals; palette_t pals;
int8_t last_used_weapon;
#ifdef LUNATIC #ifdef LUNATIC
int8_t palsfadespeed, palsfadenext, palsfadeprio, padding2_; int8_t palsfadespeed, palsfadenext, palsfadeprio, padding2_;
@ -208,7 +210,7 @@ typedef struct {
// anywhere (like with spritetype_t): g_player[i].ps->wa.idx == i. // anywhere (like with spritetype_t): g_player[i].ps->wa.idx == i.
struct { int32_t idx; } wa; struct { int32_t idx; } wa;
#endif #endif
int8_t padding_[1]; // int8_t padding_[0];
} DukePlayer_t; } DukePlayer_t;
// KEEPINSYNC lunatic/_defs_game.lua // KEEPINSYNC lunatic/_defs_game.lua

View file

@ -870,6 +870,7 @@ void P_ResetWeapons(int playerNum)
pPlayer->show_empty_weapon = 0; pPlayer->show_empty_weapon = 0;
pPlayer->last_pissed_time = 0; pPlayer->last_pissed_time = 0;
pPlayer->holster_weapon = 0; pPlayer->holster_weapon = 0;
pPlayer->last_used_weapon = -1;
VM_OnEvent(EVENT_RESETWEAPONS, pPlayer->i, playerNum); VM_OnEvent(EVENT_RESETWEAPONS, pPlayer->i, playerNum);
} }

View file

@ -2555,6 +2555,9 @@ CHECKINV1:
case 12: case 12:
weaponNum = VM_OnEventWithReturn(EVENT_ALTWEAPON,pPlayer->i,playerNum, weaponNum); weaponNum = VM_OnEventWithReturn(EVENT_ALTWEAPON,pPlayer->i,playerNum, weaponNum);
break; break;
case 13:
weaponNum = VM_OnEventWithReturn(EVENT_LASTWEAPON,pPlayer->i,playerNum, weaponNum);
break;
} }
// NOTE: it is assumed that the above events return either -1 or a // NOTE: it is assumed that the above events return either -1 or a
@ -2647,9 +2650,11 @@ CHECKINV1:
pPlayer->subweapon |= (1<<GROW_WEAPON); pPlayer->subweapon |= (1<<GROW_WEAPON);
} }
if (weaponNum == 12) // last used weapon will depend on subweapon
if (weaponNum >= 12) // alt weapon, last used weapon
{ {
switch (pPlayer->curr_weapon) uint32_t const weaponNumSwitch = weaponNum == 13 ? pPlayer->last_used_weapon : pPlayer->curr_weapon;
switch (weaponNumSwitch)
{ {
case HANDREMOTE_WEAPON: case HANDREMOTE_WEAPON:
weaponNum = HANDBOMB_WEAPON; weaponNum = HANDBOMB_WEAPON;
@ -2658,7 +2663,7 @@ CHECKINV1:
weaponNum = SHRINKER_WEAPON; weaponNum = SHRINKER_WEAPON;
break; break;
default: default:
weaponNum = pPlayer->curr_weapon; weaponNum = weaponNumSwitch;
break; break;
} }
} }