Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added SetBloodColor #2922

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/playsim/a_decals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,11 @@ void DBaseDecal::Serialize(FSerializer &arc)
("renderflags", RenderFlags)
("renderstyle", RenderStyle)
("side", Side)
("sector", Sector);
("sector", Sector)
("bisblood", bIsBlood);

if (arc.isReading() && bIsBlood && Translation != NO_TRANSLATION)
Translation = CreateBloodTranslation(AlphaColor);
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -697,15 +701,15 @@ void DImpactDecal::Expired()
//
//----------------------------------------------------------------------------

DBaseDecal* DImpactDecal::StaticCreate (FLevelLocals *Level, const char *name, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color, FTranslationID translation)
DBaseDecal* DImpactDecal::StaticCreate (FLevelLocals *Level, const char *name, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color, FTranslationID translation, bool isBlood)
{
if (cl_maxdecals > 0)
{
const FDecalTemplate *tpl = DecalLibrary.GetDecalByName (name);

if (tpl != NULL && (tpl = tpl->GetDecal()) != NULL)
{
return StaticCreate (Level, tpl, pos, wall, ffloor, color, translation);
return StaticCreate (Level, tpl, pos, wall, ffloor, color, translation, isBlood);
}
}
return nullptr;
Expand All @@ -717,7 +721,7 @@ DBaseDecal* DImpactDecal::StaticCreate (FLevelLocals *Level, const char *name, c
//
//----------------------------------------------------------------------------

DBaseDecal* DImpactDecal::StaticCreate (FLevelLocals *Level, const FDecalTemplate *tpl, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color, FTranslationID translation, bool permanent)
DBaseDecal* DImpactDecal::StaticCreate (FLevelLocals *Level, const FDecalTemplate *tpl, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color, FTranslationID translation, bool isBlood, bool permanent)
{
DBaseDecal *decal = NULL;
if (tpl != NULL && ((cl_maxdecals > 0 && !(wall->Flags & WALLF_NOAUTODECALS)) || permanent))
Expand All @@ -732,7 +736,7 @@ DBaseDecal* DImpactDecal::StaticCreate (FLevelLocals *Level, const FDecalTemplat
if (tpl->ShadeColor != tpl_low->ShadeColor) lowercolor=0;
else lowercolor = color;

StaticCreate (Level, tpl_low, pos, wall, ffloor, lowercolor, translation, permanent);
StaticCreate (Level, tpl_low, pos, wall, ffloor, lowercolor, translation, isBlood, permanent);
}
if (!permanent) decal = Level->CreateThinker<DImpactDecal>(pos.Z);
else decal = Level->CreateThinker<DBaseDecal>(pos.Z);
Expand All @@ -741,6 +745,7 @@ DBaseDecal* DImpactDecal::StaticCreate (FLevelLocals *Level, const FDecalTemplat
return NULL;
}

decal->bIsBlood = isBlood;
if (!decal->StickToWall (wall, pos.X, pos.Y, ffloor).isValid())
{
decal->Destroy();
Expand Down Expand Up @@ -854,7 +859,7 @@ void SprayDecal(AActor *shooter, const char *name, double distance, DVector3 off
{
if (trace.HitType == TRACE_HitWall)
{
DImpactDecal::StaticCreate(shooter->Level, name, trace.HitPos, trace.Line->sidedef[trace.Side], trace.ffloor, entry, trans);
DImpactDecal::StaticCreate(shooter->Level, name, trace.HitPos, trace.Line->sidedef[trace.Side], trace.ffloor, entry, trans, useBloodColor);
}
}
}
Expand All @@ -878,7 +883,7 @@ DBaseDecal *ShootDecal(FLevelLocals *Level, const FDecalTemplate *tpl, sector_t

if (trace.HitType == TRACE_HitWall)
{
return DImpactDecal::StaticCreate(Level, tpl, trace.HitPos, trace.Line->sidedef[trace.Side], trace.ffloor, 0, NO_TRANSLATION, permanent);
return DImpactDecal::StaticCreate(Level, tpl, trace.HitPos, trace.Line->sidedef[trace.Side], trace.ffloor, 0, NO_TRANSLATION, false, permanent);
}
return NULL;
}
Expand Down
5 changes: 3 additions & 2 deletions src/playsim/a_sharedglobal.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class DBaseDecal : public DThinker
FRenderStyle RenderStyle;
side_t *Side = nullptr;
sector_t *Sector = nullptr;
bool bIsBlood;

protected:
virtual DBaseDecal *CloneSelf(const FDecalTemplate *tpl, double x, double y, double z, side_t *wall, F3DFloor * ffloor) const;
Expand All @@ -73,8 +74,8 @@ class DImpactDecal : public DBaseDecal
}
void Construct(side_t *wall, const FDecalTemplate *templ);

static DBaseDecal *StaticCreate(FLevelLocals *Level, const char *name, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color = 0, FTranslationID translation = NO_TRANSLATION);
static DBaseDecal *StaticCreate(FLevelLocals *Level, const FDecalTemplate *tpl, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color = 0, FTranslationID translation = NO_TRANSLATION, bool permanent = false);
static DBaseDecal *StaticCreate(FLevelLocals *Level, const char *name, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color = 0, FTranslationID translation = NO_TRANSLATION, bool isBlood = false);
static DBaseDecal *StaticCreate(FLevelLocals *Level, const FDecalTemplate *tpl, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color = 0, FTranslationID translation = NO_TRANSLATION, bool isBlood = false, bool permanent = false);

void BeginPlay ();
void Expired() override;
Expand Down
2 changes: 1 addition & 1 deletion src/playsim/p_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5278,7 +5278,7 @@ void P_TraceBleed(int damage, const DVector3 &pos, AActor *actor, DAngle angle,
auto bloodTrans = (bloodcolor != 0 ? actor->BloodTranslation : NO_TRANSLATION);

DImpactDecal::StaticCreate(actor->Level, bloodType, bleedtrace.HitPos,
bleedtrace.Line->sidedef[bleedtrace.Side], bleedtrace.ffloor, bloodcolor, bloodTrans);
bleedtrace.Line->sidedef[bleedtrace.Side], bleedtrace.ffloor, bloodcolor, bloodTrans, true);
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/playsim/p_mobj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,9 @@ void AActor::Serialize(FSerializer &arc)
SerializeTerrain(arc, "floorterrain", floorterrain, &def->floorterrain);
SerializeArgs(arc, "args", args, def->args, special);

// Recreate this when loading since it doesn't serialize properly anyway.
if (arc.isReading() && BloodTranslation != NO_TRANSLATION)
BloodTranslation = CreateBloodTranslation(BloodColor);
}

#undef A
Expand Down
16 changes: 16 additions & 0 deletions src/scripting/vmthunks_actors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1732,6 +1732,22 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, CopyBloodColor, CopyBloodColor)
return 0;
}

static void SetBloodColor(AActor* self, int color)
{
PalEntry col = color;
self->BloodColor = col;
self->BloodColor.a = 255;
self->BloodTranslation = CreateBloodTranslation(col);
}

DEFINE_ACTION_FUNCTION_NATIVE(AActor, SetBloodColor, SetBloodColor)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_INT(color);
SetBloodColor(self, color);
return 0;
}

//=====================================================================================
//
// Inventory exports
Expand Down
1 change: 1 addition & 0 deletions wadsrc/static/zscript/actors/actor.zs
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,7 @@ class Actor : Thinker native
native void A_SprayDecal(String name, double dist = 172, vector3 offset = (0, 0, 0), vector3 direction = (0, 0, 0), bool useBloodColor = false, color decalColor = 0, TranslationID translation = 0);
native void A_SetMugshotState(String name);
native void CopyBloodColor(Actor other);
native void SetBloodColor(Color col);

native void A_RearrangePointers(int newtarget, int newmaster = AAPTR_DEFAULT, int newtracer = AAPTR_DEFAULT, int flags=0);
native void A_TransferPointer(int ptr_source, int ptr_recipient, int sourcefield, int recipientfield=AAPTR_DEFAULT, int flags=0);
Expand Down