From 302fec69da101589414e15838f2a8f0a1f87c046 Mon Sep 17 00:00:00 2001 From: Cong Date: Sat, 21 Sep 2024 22:10:09 +1000 Subject: [PATCH] DamageSmoke Z --- data/.wolf3d/N3Ddata.cdogscpn/map_objects.json | 6 ++++-- src/cdogs/map_object.c | 3 ++- src/cdogs/map_object.h | 1 + src/cdogs/objs.c | 10 ++++++---- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/data/.wolf3d/N3Ddata.cdogscpn/map_objects.json b/data/.wolf3d/N3Ddata.cdogscpn/map_objects.json index f66fe4ac4..3fee98cd0 100644 --- a/data/.wolf3d/N3Ddata.cdogscpn/map_objects.json +++ b/data/.wolf3d/N3Ddata.cdogscpn/map_objects.json @@ -300,7 +300,8 @@ "DrawBelow": true, "DamageSmoke": { "Particle": "zzz", - "HealthThreshold": 1.0 + "HealthThreshold": 1.0, + "Z": 10 } }, { @@ -314,7 +315,8 @@ "DrawBelow": true, "DamageSmoke": { "Particle": "zzz", - "HealthThreshold": 1.0 + "HealthThreshold": 1.0, + "Z": 10 } } ] diff --git a/src/cdogs/map_object.c b/src/cdogs/map_object.c index 1358a902a..8026184d7 100644 --- a/src/cdogs/map_object.c +++ b/src/cdogs/map_object.c @@ -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"); @@ -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; diff --git a/src/cdogs/map_object.h b/src/cdogs/map_object.h index c1673e086..0f40da5aa 100644 --- a/src/cdogs/map_object.h +++ b/src/cdogs/map_object.h @@ -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 diff --git a/src/cdogs/objs.c b/src/cdogs/objs.c index f2d08e908..27235dc72 100644 --- a/src/cdogs/objs.c +++ b/src/cdogs/objs.c @@ -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) @@ -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, @@ -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); } @@ -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);