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_Aiming",
"Alternate_Weapon",
"Last_Used_Weapon"
"Last_Used_Weapon",
};
#ifdef __SETUP__

View File

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

View File

@ -7157,5 +7157,5 @@ static void G_SetupGameButtons(void)
CONTROL_DefineFlag(gamefunc_Next_Weapon,FALSE);
CONTROL_DefineFlag(gamefunc_Previous_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_CONTINUELEVELMUSICSLOT",
"EVENT_DISPLAYPOINTER",
"EVENT_LASTWEAPON",
#ifdef LUNATIC
"EVENT_ANIMATEALLSPRITES",
#endif
@ -1090,6 +1091,7 @@ const memberlabel_t PlayerLabels[]=
{ "connected", PLAYER_CONNECTED, 0, 0 },
{ "frags", PLAYER_FRAGS, LABEL_HASPARM2, MAXPLAYERS },
{ "deaths", PLAYER_DEATHS, 0, 0 },
{ "last_used_weapon", PLAYER_LAST_USED_WEAPON, 0, 0 },
{ NULL, -1, 0, 0 } // END OF LIST
};

View File

@ -421,6 +421,7 @@ enum PlayerLabel_t
PLAYER_CONNECTED,
PLAYER_FRAGS,
PLAYER_DEATHS,
PLAYER_LAST_USED_WEAPON,
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];
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;
}
@ -890,6 +891,7 @@ void __fastcall VM_SetPlayer(int32_t const playerNum, int32_t const labelNum, in
g_player[playerNum].frags[lParm2] = 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;
}
}

View File

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

View File

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

View File

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

View File

@ -2555,6 +2555,9 @@ CHECKINV1:
case 12:
weaponNum = VM_OnEventWithReturn(EVENT_ALTWEAPON,pPlayer->i,playerNum, weaponNum);
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
@ -2647,9 +2650,11 @@ CHECKINV1:
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:
weaponNum = HANDBOMB_WEAPON;
@ -2658,7 +2663,7 @@ CHECKINV1:
weaponNum = SHRINKER_WEAPON;
break;
default:
weaponNum = pPlayer->curr_weapon;
weaponNum = weaponNumSwitch;
break;
}
}