Added SpriteAngle and SpriteRotation properties.
- Includes four functions, A_SetSprite(Angle/Rotation) and GetSprite(Angle/Rotation). - SpriteRotation offsets the angle of the sprite, allowing for actors to move backwards or sideways for example. - SpriteAngle requires +SPRITEANGLE and sets the actor's sprite to the absolute rotation found at that angle. Overrides SpriteRotation once the flag is on.
This commit is contained in:
parent
6ada8aa644
commit
dfed6ac1fb
8 changed files with 154 additions and 5 deletions
|
|
@ -395,6 +395,64 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetGibHealth)
|
|||
return 0;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// GetSpriteAngle
|
||||
//
|
||||
// NON-ACTION function returns the sprite angle of a pointer.
|
||||
//==========================================================================
|
||||
DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetSpriteAngle)
|
||||
{
|
||||
if (numret > 0)
|
||||
{
|
||||
assert(ret != NULL);
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
PARAM_INT_OPT(ptr) { ptr = AAPTR_DEFAULT; }
|
||||
|
||||
AActor *target = COPY_AAPTR(self, ptr);
|
||||
if (target == nullptr)
|
||||
{
|
||||
ret->SetFloat(0.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
const double ang = target->SpriteAngle.Degrees;
|
||||
ret->SetFloat(ang);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// GetSpriteRotation
|
||||
//
|
||||
// NON-ACTION function returns the sprite rotation of a pointer.
|
||||
//==========================================================================
|
||||
DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetSpriteRotation)
|
||||
{
|
||||
if (numret > 0)
|
||||
{
|
||||
assert(ret != NULL);
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
PARAM_INT_OPT(ptr) { ptr = AAPTR_DEFAULT; }
|
||||
|
||||
AActor *target = COPY_AAPTR(self, ptr);
|
||||
if (target == nullptr)
|
||||
{
|
||||
ret->SetFloat(0.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
const double ang = target->SpriteRotation.Degrees;
|
||||
ret->SetFloat(ang);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// GetZAt
|
||||
|
|
@ -7219,3 +7277,49 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CopySpriteFrame)
|
|||
if (!(flags & CPSF_NOFRAME)) copyto->frame = copyfrom->frame;
|
||||
ACTION_RETURN_BOOL(true);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// A_SetSpriteAngle(angle, ptr)
|
||||
//
|
||||
// Specifies which angle the actor must always draw its sprite from.
|
||||
//==========================================================================
|
||||
|
||||
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetSpriteAngle)
|
||||
{
|
||||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_FLOAT_OPT(angle) { angle = 0.; }
|
||||
PARAM_INT_OPT(ptr) { ptr = AAPTR_DEFAULT; }
|
||||
|
||||
AActor *mobj = COPY_AAPTR(self, ptr);
|
||||
|
||||
if (mobj == nullptr)
|
||||
{
|
||||
ACTION_RETURN_BOOL(false);
|
||||
}
|
||||
mobj->SpriteAngle = angle;
|
||||
ACTION_RETURN_BOOL(true);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// A_SetSpriteRotation(angle, ptr)
|
||||
//
|
||||
// Specifies how much to fake a sprite rotation.
|
||||
//==========================================================================
|
||||
|
||||
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetSpriteRotation)
|
||||
{
|
||||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_ANGLE_OPT(angle) { angle = 0.; }
|
||||
PARAM_INT_OPT(ptr) { ptr = AAPTR_DEFAULT; }
|
||||
|
||||
AActor *mobj = COPY_AAPTR(self, ptr);
|
||||
|
||||
if (mobj == nullptr)
|
||||
{
|
||||
ACTION_RETURN_BOOL(false);
|
||||
}
|
||||
mobj->SpriteRotation = angle;
|
||||
ACTION_RETURN_BOOL(true);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue