wip: staterange actions

# Conflicts:
#	src/doomdef.h
This commit is contained in:
toaster 2022-03-18 20:50:03 +00:00
parent 09885ce34b
commit ed00874f5f
3 changed files with 51 additions and 0 deletions

View file

@ -207,6 +207,8 @@ actionpointer_t actionpointers[] =
{{A_SetObjectFlags2}, "A_SETOBJECTFLAGS2"}, {{A_SetObjectFlags2}, "A_SETOBJECTFLAGS2"},
{{A_RandomState}, "A_RANDOMSTATE"}, {{A_RandomState}, "A_RANDOMSTATE"},
{{A_RandomStateRange}, "A_RANDOMSTATERANGE"}, {{A_RandomStateRange}, "A_RANDOMSTATERANGE"},
{{A_StateRangeByAngle}, "A_STATERANGEBYANGLE"},
{{A_StateRangeByParameter}, "A_STATERANGEBYPARAMETER"},
{{A_DualAction}, "A_DUALACTION"}, {{A_DualAction}, "A_DUALACTION"},
{{A_RemoteAction}, "A_REMOTEACTION"}, {{A_RemoteAction}, "A_REMOTEACTION"},
{{A_ToggleFlameJet}, "A_TOGGLEFLAMEJET"}, {{A_ToggleFlameJet}, "A_TOGGLEFLAMEJET"},

View file

@ -161,6 +161,8 @@ enum actionnum
A_SETOBJECTFLAGS2, A_SETOBJECTFLAGS2,
A_RANDOMSTATE, A_RANDOMSTATE,
A_RANDOMSTATERANGE, A_RANDOMSTATERANGE,
A_STATERANGEBYANGLE,
A_STATERANGEBYPARAMETER,
A_DUALACTION, A_DUALACTION,
A_REMOTEACTION, A_REMOTEACTION,
A_TOGGLEFLAMEJET, A_TOGGLEFLAMEJET,
@ -428,6 +430,8 @@ void A_SetObjectFlags();
void A_SetObjectFlags2(); void A_SetObjectFlags2();
void A_RandomState(); void A_RandomState();
void A_RandomStateRange(); void A_RandomStateRange();
void A_StateRangeByAngle();
void A_StateRangeByParameter();
void A_DualAction(); void A_DualAction();
void A_RemoteAction(); void A_RemoteAction();
void A_ToggleFlameJet(); void A_ToggleFlameJet();

View file

@ -187,6 +187,8 @@ void A_SetObjectFlags(mobj_t *actor);
void A_SetObjectFlags2(mobj_t *actor); void A_SetObjectFlags2(mobj_t *actor);
void A_RandomState(mobj_t *actor); void A_RandomState(mobj_t *actor);
void A_RandomStateRange(mobj_t *actor); void A_RandomStateRange(mobj_t *actor);
void A_StateRangeByAngle(mobj_t *actor);
void A_StateRangeByParameter(mobj_t *actor);
void A_DualAction(mobj_t *actor); void A_DualAction(mobj_t *actor);
void A_RemoteAction(mobj_t *actor); void A_RemoteAction(mobj_t *actor);
void A_ToggleFlameJet(mobj_t *actor); void A_ToggleFlameJet(mobj_t *actor);
@ -8132,6 +8134,49 @@ void A_RandomStateRange(mobj_t *actor)
P_SetMobjState(actor, P_RandomRange(locvar1, locvar2)); P_SetMobjState(actor, P_RandomRange(locvar1, locvar2));
} }
// Function: A_StateRangeByAngle
//
// Description: Chooses a state within the range supplied, depending on the actor's angle.
//
// var1 = Minimum state number to use.
// var2 = Maximum state number to use. The difference will act as a modulo operator.
//
void A_StateRangeByAngle(mobj_t *actor)
{
INT32 locvar1 = var1;
INT32 locvar2 = var2;
if (LUA_CallAction(A_STATERANGEBYANGLE, actor))
return;
if (locvar2 - locvar1 < 0)
return; // invalid range
P_SetMobjState(actor, locvar1 + (AngleFixed(actor->angle)>>FRACBITS % (1 + locvar2 - locvar1)));
}
// Function: A_StateRangeByParameter
//
// Description: Chooses a state within the range supplied, depending on the actor's parameter/extrainfo value.
//
// var1 = Minimum state number to use.
// var2 = Maximum state number to use. The difference will act as a modulo operator.
//
void A_StateRangeByParameter(mobj_t *actor)
{
INT32 locvar1 = var1;
INT32 locvar2 = var2;
UINT8 parameter = (actor->spawnpoint ? actor->spawnpoint->extrainfo : 0);
if (LUA_CallAction(A_STATERANGEBYANGLE, actor))
return;
if (locvar2 - locvar1 < 0)
return; // invalid range
P_SetMobjState(actor, locvar1 + (parameter % (1 + locvar2 - locvar1)));
}
// Function: A_DualAction // Function: A_DualAction
// //
// Description: Calls two actions. Be careful, if you reference the same state this action is called from, you can create an infinite loop. // Description: Calls two actions. Be careful, if you reference the same state this action is called from, you can create an infinite loop.