mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
Modify EVENT_CHANGEWEAPON so that it actually serves a purpose. Instead of being triggered before curr_weapon is changed, with nothing used for input or output with RETURN (meaning you could not cancel), now RETURN is set to the prospective new weapon ID and you can change it or cancel it in the event.
Note that since setting RETURN did nothing before, there is no backwards compatibility to uphold. Therefore, setting RETURN to 1 will cause the pistol to be selected, not disable the event. Set RETURN to -1 to cancel switching. git-svn-id: https://svn.eduke32.com/eduke32@2976 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
a0dc378eda
commit
3c5aeae341
1 changed files with 10 additions and 5 deletions
|
@ -3491,6 +3491,11 @@ void P_AddWeapon(DukePlayer_t *p,int32_t weapon)
|
|||
|
||||
if (p->reloading) return;
|
||||
|
||||
if (p->curr_weapon != weapon && apScriptGameEvent[EVENT_CHANGEWEAPON])
|
||||
weapon = VM_OnEvent(EVENT_CHANGEWEAPON,p->i, snum, -1, weapon);
|
||||
if (weapon < 0)
|
||||
return;
|
||||
|
||||
p->random_club_frame = 0;
|
||||
|
||||
if (p->weapon_pos == 0)
|
||||
|
@ -3508,9 +3513,6 @@ void P_AddWeapon(DukePlayer_t *p,int32_t weapon)
|
|||
|
||||
p->kickback_pic = 0;
|
||||
|
||||
if (p->curr_weapon != weapon && apScriptGameEvent[EVENT_CHANGEWEAPON])
|
||||
VM_OnEvent(EVENT_CHANGEWEAPON,p->i, snum, -1, 0);
|
||||
|
||||
p->curr_weapon = weapon;
|
||||
|
||||
Gv_SetVar(g_iWeaponVarID,p->curr_weapon, p->i, snum);
|
||||
|
@ -3580,14 +3582,17 @@ void P_CheckWeapon(DukePlayer_t *p)
|
|||
|
||||
// Found the weapon
|
||||
|
||||
if (apScriptGameEvent[EVENT_CHANGEWEAPON])
|
||||
weap = VM_OnEvent(EVENT_CHANGEWEAPON,p->i, snum, -1, weap);
|
||||
if (weap < 0)
|
||||
return;
|
||||
|
||||
p->last_weapon = p->curr_weapon;
|
||||
p->random_club_frame = 0;
|
||||
p->curr_weapon = weap;
|
||||
Gv_SetVar(g_iWeaponVarID,p->curr_weapon, p->i, snum);
|
||||
Gv_SetVar(g_iWorksLikeVarID, (unsigned)p->curr_weapon < MAX_WEAPONS ? aplWeaponWorksLike[p->curr_weapon][snum] : -1, p->i, snum);
|
||||
|
||||
if (apScriptGameEvent[EVENT_CHANGEWEAPON])
|
||||
VM_OnEvent(EVENT_CHANGEWEAPON,p->i, snum, -1, 0);
|
||||
p->kickback_pic = 0;
|
||||
if (p->holster_weapon == 1)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue