mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 06:53:58 +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)
|
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)
|
else if (keylen == 9 && stricmp (Line1, "Unknown 1") == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,6 +55,8 @@ extern void LoadActors ();
|
||||||
extern void InitBotStuff();
|
extern void InitBotStuff();
|
||||||
extern void ClearStrifeTypes();
|
extern void ClearStrifeTypes();
|
||||||
|
|
||||||
|
FRandom FState::pr_statetics;
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
15
src/info.h
15
src/info.h
|
@ -45,6 +45,7 @@
|
||||||
#include "doomdef.h"
|
#include "doomdef.h"
|
||||||
|
|
||||||
#include "m_fixed.h"
|
#include "m_fixed.h"
|
||||||
|
#include "m_random.h"
|
||||||
|
|
||||||
struct Baggage;
|
struct Baggage;
|
||||||
class FScanner;
|
class FScanner;
|
||||||
|
@ -61,18 +62,19 @@ enum
|
||||||
|
|
||||||
struct FState
|
struct FState
|
||||||
{
|
{
|
||||||
|
FState *NextState;
|
||||||
|
actionf_p ActionFunc;
|
||||||
WORD sprite;
|
WORD sprite;
|
||||||
SWORD Tics;
|
SWORD Tics;
|
||||||
int Misc1; // Was changed to SBYTE, reverted to long for MBF compat
|
WORD TicRange;
|
||||||
int Misc2; // Was changed to BYTE, reverted to long for MBF compat
|
|
||||||
BYTE Frame;
|
BYTE Frame;
|
||||||
BYTE DefineFlags; // Unused byte so let's use it during state creation.
|
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;
|
short Light;
|
||||||
BYTE Fullbright:1; // State is fullbright
|
BYTE Fullbright:1; // State is fullbright
|
||||||
BYTE SameFrame:1; // Ignore Frame (except when spawning actor)
|
BYTE SameFrame:1; // Ignore Frame (except when spawning actor)
|
||||||
BYTE Fast:1;
|
BYTE Fast:1;
|
||||||
FState *NextState;
|
|
||||||
actionf_p ActionFunc;
|
|
||||||
int ParameterIndex;
|
int ParameterIndex;
|
||||||
|
|
||||||
inline int GetFrame() const
|
inline int GetFrame() const
|
||||||
|
@ -88,9 +90,13 @@ struct FState
|
||||||
return Fullbright ? 0x10 /*RF_FULLBRIGHT*/ : 0;
|
return Fullbright ? 0x10 /*RF_FULLBRIGHT*/ : 0;
|
||||||
}
|
}
|
||||||
inline int GetTics() const
|
inline int GetTics() const
|
||||||
|
{
|
||||||
|
if (TicRange == 0)
|
||||||
{
|
{
|
||||||
return Tics;
|
return Tics;
|
||||||
}
|
}
|
||||||
|
return Tics + pr_statetics.GenRand32() % (TicRange + 1);
|
||||||
|
}
|
||||||
inline int GetMisc1() const
|
inline int GetMisc1() const
|
||||||
{
|
{
|
||||||
return Misc1;
|
return Misc1;
|
||||||
|
@ -134,6 +140,7 @@ struct FState
|
||||||
}
|
}
|
||||||
static const PClass *StaticFindStateOwner (const FState *state);
|
static const PClass *StaticFindStateOwner (const FState *state);
|
||||||
static const PClass *StaticFindStateOwner (const FState *state, const FActorInfo *info);
|
static const PClass *StaticFindStateOwner (const FState *state, const FActorInfo *info);
|
||||||
|
static FRandom pr_statetics;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FStateLabels;
|
struct FStateLabels;
|
||||||
|
|
|
@ -199,6 +199,7 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def)
|
||||||
if (info->NumOwnedStates == 1)
|
if (info->NumOwnedStates == 1)
|
||||||
{
|
{
|
||||||
info->OwnedStates->Tics = -1;
|
info->OwnedStates->Tics = -1;
|
||||||
|
info->OwnedStates->TicRange = 0;
|
||||||
info->OwnedStates->Misc1 = 0;
|
info->OwnedStates->Misc1 = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -226,6 +227,7 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
info->OwnedStates[i].Tics = -1;
|
info->OwnedStates[i].Tics = -1;
|
||||||
|
info->OwnedStates[i].TicRange = 0;
|
||||||
info->OwnedStates[i].Misc1 = 0;
|
info->OwnedStates[i].Misc1 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,6 +275,7 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
info->OwnedStates[i].Tics = -1;
|
info->OwnedStates[i].Tics = -1;
|
||||||
|
info->OwnedStates[i].TicRange = 0;
|
||||||
info->OwnedStates[i].Misc1 = 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].NextState = &info->OwnedStates[info->NumOwnedStates-1];
|
||||||
info->OwnedStates[i].Tics = 5;
|
info->OwnedStates[i].Tics = 5;
|
||||||
|
info->OwnedStates[i].TicRange = 0;
|
||||||
info->OwnedStates[i].Misc1 = 0;
|
info->OwnedStates[i].Misc1 = 0;
|
||||||
info->OwnedStates[i].SetAction(FindGlobalActionFunction("A_FreezeDeath"));
|
info->OwnedStates[i].SetAction(FindGlobalActionFunction("A_FreezeDeath"));
|
||||||
|
|
||||||
i = info->NumOwnedStates - 1;
|
i = info->NumOwnedStates - 1;
|
||||||
info->OwnedStates[i].NextState = &info->OwnedStates[i];
|
info->OwnedStates[i].NextState = &info->OwnedStates[i];
|
||||||
info->OwnedStates[i].Tics = 1;
|
info->OwnedStates[i].Tics = 1;
|
||||||
|
info->OwnedStates[i].TicRange = 0;
|
||||||
info->OwnedStates[i].Misc1 = 0;
|
info->OwnedStates[i].Misc1 = 0;
|
||||||
info->OwnedStates[i].SetAction(FindGlobalActionFunction("A_FreezeDeathChunks"));
|
info->OwnedStates[i].SetAction(FindGlobalActionFunction("A_FreezeDeathChunks"));
|
||||||
bag.statedef.SetStateLabel("Ice", &info->OwnedStates[extra.IceDeathStart]);
|
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.Tics = rate;
|
||||||
|
state.TicRange = 0;
|
||||||
|
|
||||||
while (*token)
|
while (*token)
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
#include "colormatcher.h"
|
#include "colormatcher.h"
|
||||||
#include "thingdef_exp.h"
|
#include "thingdef_exp.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
#include "templates.h"
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//***
|
//***
|
||||||
|
@ -237,8 +238,30 @@ do_stop:
|
||||||
sc.MustGetString();
|
sc.MustGetString();
|
||||||
statestring = sc.String;
|
statestring = sc.String;
|
||||||
|
|
||||||
|
if (sc.CheckString("RANDOM"))
|
||||||
|
{
|
||||||
|
int min, max;
|
||||||
|
|
||||||
|
sc.MustGetStringName("(");
|
||||||
sc.MustGetNumber();
|
sc.MustGetNumber();
|
||||||
state.Tics = clamp<int>(sc.Number, -1, 32767);
|
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)
|
while (sc.GetString() && !sc.Crossed)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue