Skip to content

Commit

Permalink
Added new AutomapOffsets property.
Browse files Browse the repository at this point in the history
This Vector2 property allows you visually offset the XY position of an actors' sprites on the automap.
  • Loading branch information
inkoalawetrust authored and madame-rachelle committed Jan 28, 2024
1 parent b3fabb0 commit 5680331
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/am_map.cpp
Expand Up @@ -2952,7 +2952,8 @@ void DAutomap::drawThings ()
if (am_cheat > 0 || !(t->flags6 & MF6_NOTONAUTOMAP)
|| (am_thingrenderstyles && !(t->renderflags & RF_INVISIBLE) && !(t->flags6 & MF6_NOTONAUTOMAP)))
{
DVector3 pos = t->InterpolatedPosition(r_viewpoint.TicFrac) + t->Level->Displacements.getOffset(sec.PortalGroup, MapPortalGroup);
DVector3 fracPos = t->InterpolatedPosition(r_viewpoint.TicFrac);
FVector2 pos = FVector2(float(fracPos.X),float(fracPos.Y)) + FVector2(t->Level->Displacements.getOffset(sec.PortalGroup, MapPortalGroup)) + FVector2(t->AutomapOffsets);
p.x = pos.X;
p.y = pos.Y;

Expand All @@ -2969,7 +2970,7 @@ void DAutomap::drawThings ()
const size_t spriteIndex = sprite.spriteframes + (show > 1 ? t->frame : 0);

frame = &SpriteFrames[spriteIndex];
DAngle angle = DAngle::fromDeg(270. + 22.5) - t->InterpolatedAngles(r_viewpoint.TicFrac).Yaw - t->SpriteRotation;
DAngle angle = DAngle::fromDeg(270.) - t->InterpolatedAngles(r_viewpoint.TicFrac).Yaw - t->SpriteRotation;
if (frame->Texture[0] != frame->Texture[1]) angle += DAngle::fromDeg(180. / 16);
if (am_rotate == 1 || (am_rotate == 2 && viewactive))
{
Expand Down
4 changes: 3 additions & 1 deletion src/common/engine/namedef.h
Expand Up @@ -80,14 +80,16 @@ xx(__decorate_internal_float__)
// Per-actor sound channels (for deprecated PlaySoundEx function) Do not separate this block!!!
xx(Auto)
xx(Weapon)
xx(BobPivot3D)
xx(Voice)
xx(Item)
xx(Body)
xx(SoundSlot5)
xx(SoundSlot6)
xx(SoundSlot7)

// Actor properties
xx(BobPivot3D)

xx(LevelLocals)
xx(Level)

Expand Down
1 change: 1 addition & 0 deletions src/playsim/actor.h
Expand Up @@ -1103,6 +1103,7 @@ class AActor final : public DThinker

DAngle SpriteAngle;
DAngle SpriteRotation;
DVector2 AutomapOffsets; // Offset the actors' sprite view on the automap by these coordinates.
DRotator Angles;
DRotator ViewAngles; // Angle offsets for cameras
TObjPtr<DViewPosition*> ViewPos; // Position offsets for cameras
Expand Down
1 change: 1 addition & 0 deletions src/scripting/vmthunks_actors.cpp
Expand Up @@ -2141,6 +2141,7 @@ DEFINE_FIELD_NAMED(AActor, ViewAngles.Roll, viewroll)
DEFINE_FIELD(AActor, LightLevel)
DEFINE_FIELD(AActor, ShadowAimFactor)
DEFINE_FIELD(AActor, ShadowPenaltyFactor)
DEFINE_FIELD(AActor, AutomapOffsets)

DEFINE_FIELD_X(FCheckPosition, FCheckPosition, thing);
DEFINE_FIELD_X(FCheckPosition, FCheckPosition, pos);
Expand Down
3 changes: 3 additions & 0 deletions wadsrc/static/zscript/actors/actor.zs
Expand Up @@ -260,6 +260,7 @@ class Actor : Thinker native
native readonly int SpawnTime;
private native int InventoryID; // internal counter.
native uint freezetics;
native Vector2 AutomapOffsets;

meta String Obituary; // Player was killed by this actor
meta String HitObituary; // Player was killed by this actor in melee
Expand Down Expand Up @@ -364,6 +365,7 @@ class Actor : Thinker native
property LightLevel: LightLevel;
property ShadowAimFactor: ShadowAimFactor;
property ShadowPenaltyFactor: ShadowPenaltyFactor;
property AutomapOffsets : AutomapOffsets;

// need some definition work first
//FRenderStyle RenderStyle;
Expand Down Expand Up @@ -443,6 +445,7 @@ class Actor : Thinker native
SelfDamageFactor 1;
ShadowAimFactor 1;
ShadowPenaltyFactor 1;
AutomapOffsets (0,0);
StealthAlpha 0;
WoundHealth 6;
GibHealth int.min;
Expand Down

0 comments on commit 5680331

Please sign in to comment.