mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-23 12:32:34 +00:00
- Added support for random state durations. Instead of defining a frame like this:
POSS A 10 A_Look You can define it as: POSS A random(10,20) A_Look and the state will last a random duration between 10 and 20 tics, inclusive. SVN r3847 (trunk)
This commit is contained in:
parent
c954fb5477
commit
1c71c1dce1
5 changed files with 46 additions and 8 deletions
|
@ -1353,7 +1353,7 @@ static int PatchFrame (int frameNum)
|
|||
|
||||
if (keylen == 8 && stricmp (Line1, "Duration") == 0)
|
||||
{
|
||||
tics = clamp (val, -1, 65534);
|
||||
tics = clamp (val, -1, SHRT_MAX);
|
||||
}
|
||||
else if (keylen == 9 && stricmp (Line1, "Unknown 1") == 0)
|
||||
{
|
||||
|
|
|
@ -55,6 +55,8 @@ extern void LoadActors ();
|
|||
extern void InitBotStuff();
|
||||
extern void ClearStrifeTypes();
|
||||
|
||||
FRandom FState::pr_statetics;
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
|
17
src/info.h
17
src/info.h
|
@ -45,6 +45,7 @@
|
|||
#include "doomdef.h"
|
||||
|
||||
#include "m_fixed.h"
|
||||
#include "m_random.h"
|
||||
|
||||
struct Baggage;
|
||||
class FScanner;
|
||||
|
@ -61,18 +62,19 @@ enum
|
|||
|
||||
struct FState
|
||||
{
|
||||
FState *NextState;
|
||||
actionf_p ActionFunc;
|
||||
WORD sprite;
|
||||
SWORD Tics;
|
||||
int Misc1; // Was changed to SBYTE, reverted to long for MBF compat
|
||||
int Misc2; // Was changed to BYTE, reverted to long for MBF compat
|
||||
WORD TicRange;
|
||||
BYTE Frame;
|
||||
BYTE DefineFlags; // Unused byte so let's use it during state creation.
|
||||
int Misc1; // Was changed to SBYTE, reverted to long for MBF compat
|
||||
int Misc2; // Was changed to BYTE, reverted to long for MBF compat
|
||||
short Light;
|
||||
BYTE Fullbright:1; // State is fullbright
|
||||
BYTE SameFrame:1; // Ignore Frame (except when spawning actor)
|
||||
BYTE Fast:1;
|
||||
FState *NextState;
|
||||
actionf_p ActionFunc;
|
||||
int ParameterIndex;
|
||||
|
||||
inline int GetFrame() const
|
||||
|
@ -89,7 +91,11 @@ struct FState
|
|||
}
|
||||
inline int GetTics() const
|
||||
{
|
||||
return Tics;
|
||||
if (TicRange == 0)
|
||||
{
|
||||
return Tics;
|
||||
}
|
||||
return Tics + pr_statetics.GenRand32() % (TicRange + 1);
|
||||
}
|
||||
inline int GetMisc1() const
|
||||
{
|
||||
|
@ -134,6 +140,7 @@ struct FState
|
|||
}
|
||||
static const PClass *StaticFindStateOwner (const FState *state);
|
||||
static const PClass *StaticFindStateOwner (const FState *state, const FActorInfo *info);
|
||||
static FRandom pr_statetics;
|
||||
};
|
||||
|
||||
struct FStateLabels;
|
||||
|
|
|
@ -199,6 +199,7 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def)
|
|||
if (info->NumOwnedStates == 1)
|
||||
{
|
||||
info->OwnedStates->Tics = -1;
|
||||
info->OwnedStates->TicRange = 0;
|
||||
info->OwnedStates->Misc1 = 0;
|
||||
}
|
||||
else
|
||||
|
@ -226,6 +227,7 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def)
|
|||
else
|
||||
{
|
||||
info->OwnedStates[i].Tics = -1;
|
||||
info->OwnedStates[i].TicRange = 0;
|
||||
info->OwnedStates[i].Misc1 = 0;
|
||||
}
|
||||
|
||||
|
@ -273,6 +275,7 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def)
|
|||
else
|
||||
{
|
||||
info->OwnedStates[i].Tics = -1;
|
||||
info->OwnedStates[i].TicRange = 0;
|
||||
info->OwnedStates[i].Misc1 = 0;
|
||||
}
|
||||
|
||||
|
@ -307,12 +310,14 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def)
|
|||
}
|
||||
info->OwnedStates[i].NextState = &info->OwnedStates[info->NumOwnedStates-1];
|
||||
info->OwnedStates[i].Tics = 5;
|
||||
info->OwnedStates[i].TicRange = 0;
|
||||
info->OwnedStates[i].Misc1 = 0;
|
||||
info->OwnedStates[i].SetAction(FindGlobalActionFunction("A_FreezeDeath"));
|
||||
|
||||
i = info->NumOwnedStates - 1;
|
||||
info->OwnedStates[i].NextState = &info->OwnedStates[i];
|
||||
info->OwnedStates[i].Tics = 1;
|
||||
info->OwnedStates[i].TicRange = 0;
|
||||
info->OwnedStates[i].Misc1 = 0;
|
||||
info->OwnedStates[i].SetAction(FindGlobalActionFunction("A_FreezeDeathChunks"));
|
||||
bag.statedef.SetStateLabel("Ice", &info->OwnedStates[extra.IceDeathStart]);
|
||||
|
@ -671,6 +676,7 @@ static void ParseSpriteFrames (FActorInfo *info, TArray<FState> &states, FScanne
|
|||
}
|
||||
|
||||
state.Tics = rate;
|
||||
state.TicRange = 0;
|
||||
|
||||
while (*token)
|
||||
{
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
#include "colormatcher.h"
|
||||
#include "thingdef_exp.h"
|
||||
#include "version.h"
|
||||
#include "templates.h"
|
||||
|
||||
//==========================================================================
|
||||
//***
|
||||
|
@ -237,8 +238,30 @@ do_stop:
|
|||
sc.MustGetString();
|
||||
statestring = sc.String;
|
||||
|
||||
sc.MustGetNumber();
|
||||
state.Tics = clamp<int>(sc.Number, -1, 32767);
|
||||
if (sc.CheckString("RANDOM"))
|
||||
{
|
||||
int min, max;
|
||||
|
||||
sc.MustGetStringName("(");
|
||||
sc.MustGetNumber();
|
||||
min = clamp<int>(sc.Number, -1, SHRT_MAX);
|
||||
sc.MustGetStringName(",");
|
||||
sc.MustGetNumber();
|
||||
max = clamp<int>(sc.Number, -1, SHRT_MAX);
|
||||
sc.MustGetStringName(")");
|
||||
if (min > max)
|
||||
{
|
||||
swapvalues(min, max);
|
||||
}
|
||||
state.Tics = min;
|
||||
state.TicRange = max - min;
|
||||
}
|
||||
else
|
||||
{
|
||||
sc.MustGetNumber();
|
||||
state.Tics = clamp<int>(sc.Number, -1, SHRT_MAX);
|
||||
state.TicRange = 0;
|
||||
}
|
||||
|
||||
while (sc.GetString() && !sc.Crossed)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue