Skip to content

Commit

Permalink
DamageSmoke Z
Browse files Browse the repository at this point in the history
  • Loading branch information
cxong committed Sep 21, 2024
1 parent ff31160 commit 302fec6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
6 changes: 4 additions & 2 deletions data/.wolf3d/N3Ddata.cdogscpn/map_objects.json
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@
"DrawBelow": true,
"DamageSmoke": {
"Particle": "zzz",
"HealthThreshold": 1.0
"HealthThreshold": 1.0,
"Z": 10
}
},
{
Expand All @@ -314,7 +315,8 @@
"DrawBelow": true,
"DamageSmoke": {
"Particle": "zzz",
"HealthThreshold": 1.0
"HealthThreshold": 1.0,
"Z": 10
}
}
]
Expand Down
3 changes: 2 additions & 1 deletion src/cdogs/map_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ static bool TryLoadMapObject(MapObject *m, json_t *node, const int version)

LoadBool(&m->DrawBelow, node, "DrawBelow");
LoadBool(&m->DrawAbove, node, "DrawAbove");

LoadStr(&m->FootstepSound, node, "FootstepSound");
LoadColor(&m->FootprintMask, node, "FootprintMask");

Expand Down Expand Up @@ -449,6 +449,7 @@ static bool TryLoadMapObject(MapObject *m, json_t *node, const int version)
LoadFloat(
&m->DamageSmoke.HealthThreshold, dSmokeNode->child,
"HealthThreshold");
LoadFloat(&m->DamageSmoke.Z, dSmokeNode->child, "Z");
}

return true;
Expand Down
1 change: 1 addition & 0 deletions src/cdogs/map_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ typedef struct
struct {
char *ParticleClass;
float HealthThreshold; // Smoke if map object damaged below this ratio
float Z;
} DamageSmoke;
} MapObject;
typedef struct
Expand Down
10 changes: 6 additions & 4 deletions src/cdogs/objs.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,7 @@ static void DoDamageCharacter(
{
// Don't score for friendly, unpiloted vehicle, or player hits
const bool isFriendly =
(actor->flags & FLAGS_GOOD_GUY) ||
actor->pilotUID == -1 ||
(actor->flags & FLAGS_GOOD_GUY) || actor->pilotUID == -1 ||
(!IsPVP(gCampaign.Entry.Mode) && actor->PlayerUID >= 0);
if (source && source->PlayerUID >= 0 && bullet->Power != 0 &&
!isFriendly)
Expand Down Expand Up @@ -498,7 +497,9 @@ void ObjAdd(const NMapObjectAdd amo)
o->thing.CPicFunc = MapObjectDraw;
MapTryMoveThing(&gMap, &o->thing, NetToVec2(amo.Pos));
EmitterInit(
&o->damageSmoke, StrParticleClass(&gParticleClasses, o->Class->DamageSmoke.ParticleClass),
&o->damageSmoke,
StrParticleClass(
&gParticleClasses, o->Class->DamageSmoke.ParticleClass),
svec2_zero(), -0.05f, 0.05f, 3, 3, 0, 0, 20);
o->isInUse = true;
LOG(LM_MAIN, LL_DEBUG,
Expand Down Expand Up @@ -549,6 +550,7 @@ void UpdateObjects(const int ticks)
RAND_FLOAT(-obj->thing.size.x / 4, obj->thing.size.x / 4),
RAND_FLOAT(
-obj->thing.size.y / 4, obj->thing.size.y / 4)));
ap.Z = obj->Class->DamageSmoke.Z;
ap.Mask = colorWhite;
EmitterUpdate(&obj->damageSmoke, &ap, ticks);
}
Expand Down Expand Up @@ -592,7 +594,7 @@ void UpdateObjects(const int ticks)
CArrayGet(
&gCampaign.Setting.characters.OtherChars,
obj->Class->u.Character.CharId),
NULL);
NULL);
e.u.ActorAdd.CharId = obj->Class->u.Character.CharId;
GameEventsEnqueue(&gGameEvents, e);

Expand Down

0 comments on commit 302fec6

Please sign in to comment.