Skip to content

Commit

Permalink
Allow A_RandomJump() in deaths in cast sequence
Browse files Browse the repository at this point in the history
Finalize support for the SMOOTHED mod this way.

Thanks @bradharding and @jeffdoggett for the code!
  • Loading branch information
fabiangreffrath committed Jun 7, 2017
1 parent 04b5321 commit bddb243
Showing 1 changed file with 51 additions and 2 deletions.
53 changes: 51 additions & 2 deletions src/doom/f_finale.c
Expand Up @@ -37,6 +37,7 @@
#include "doomstat.h"
#include "r_state.h"
#include "m_controls.h" // [crispy] key_*
#include "m_random.h" // [crispy] Crispy_Random()

typedef enum
{
Expand Down Expand Up @@ -106,6 +107,8 @@ void F_CastTicker (void);
boolean F_CastResponder (event_t *ev);
void F_CastDrawer (void);

extern void A_RandomJump();

//
// F_StartFinale
//
Expand Down Expand Up @@ -435,9 +438,17 @@ void F_CastTicker (void)
else
{
// just advance to next state in animation
if (caststate == &states[S_PLAY_ATK1])
if (!castdeath && caststate == &states[S_PLAY_ATK1])
goto stopattack; // Oh, gross hack!
// [crispy] Allow A_RandomJump() in deaths in cast sequence
if (caststate->action.acp1 == A_RandomJump && Crispy_Random() < caststate->misc2)
{
st = caststate->misc1;
}
else
{
st = caststate->nextstate;
}
caststate = &states[st];
castframes++;

Expand Down Expand Up @@ -477,7 +488,7 @@ void F_CastTicker (void)
S_StartSound (NULL, sfx);
}

if (castframes == 12)
if (!castdeath && castframes == 12)
{
// go into attack frame
castattacking = true;
Expand Down Expand Up @@ -511,7 +522,27 @@ void F_CastTicker (void)

casttics = caststate->tics;
if (casttics == -1)
{
// [crispy] Allow A_RandomJump() in deaths in cast sequence
if (caststate->action.acp1 == A_RandomJump)
{
if (Crispy_Random() < caststate->misc2)
{
caststate = &states[caststate->misc1];
}
else
{
caststate = &states[caststate->nextstate];
}

casttics = caststate->tics;
}

if (casttics == -1)
{
casttics = 15;
}
}
}


Expand Down Expand Up @@ -567,6 +598,19 @@ boolean F_CastResponder (event_t* ev)
else
caststate = &states[mobjinfo[castorder[castnum].type].deathstate];
casttics = caststate->tics;
// [crispy] Allow A_RandomJump() in deaths in cast sequence
if (casttics == -1 && caststate->action.acp1 == A_RandomJump)
{
if (Crispy_Random() < caststate->misc2)
{
caststate = &states [caststate->misc1];
}
else
{
caststate = &states [caststate->nextstate];
}
casttics = caststate->tics;
}
castframes = 0;
castattacking = false;
if (xdeath && mobjinfo[castorder[castnum].type].xdeathstate)
Expand Down Expand Up @@ -649,6 +693,11 @@ void F_CastDrawer (void)

// draw the current frame in the middle of the screen
sprdef = &sprites[caststate->sprite];
// [crispy] the TNT1 sprite is not supposed to be rendered anyway
if (!sprdef->numframes && caststate->sprite == SPR_TNT1)
{
return;
}
sprframe = &sprdef->spriteframes[ caststate->frame & FF_FRAMEMASK];
lump = sprframe->lump[castangle]; // [crispy] turnable cast
flip = (boolean)sprframe->flip[castangle]; // [crispy] turnable cast
Expand Down

2 comments on commit bddb243

@SoDOOManiac
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this SMOOTHED mod?

@fabiangreffrath
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.