diff --git a/src/actor.h b/src/actor.h index a79b584cd..74516301a 100644 --- a/src/actor.h +++ b/src/actor.h @@ -874,10 +874,12 @@ public: line_t *BlockingLine; // Line that blocked the last move int PoisonDamage; // Damage received per tic from poison. + FNameNoInit PoisonDamageType; // Damage type dealt by poison. int PoisonDuration; // Duration left for receiving poison damage. int PoisonPeriod; // How often poison damage is applied. (Every X tics.) int PoisonDamageReceived; // Damage received per tic from poison. + FNameNoInit PoisonDamageTypeReceived; // Damage type received by poison. int PoisonDurationReceived; // Duration left for receiving poison damage. int PoisonPeriodReceived; // How often poison damage is applied. (Every X tics.) TObjPtr Poisoner; // Last source of received poison damage. diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 957fdd2c8..6337d71cf 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -1368,11 +1368,8 @@ dopain: target->flags |= MF_JUSTHIT; // fight back! } -void P_PoisonMobj (AActor *target, AActor *inflictor, AActor *source, int damage, int duration, int period) +void P_PoisonMobj (AActor *target, AActor *inflictor, AActor *source, int damage, int duration, int period, FName type) { - int olddamage = target->PoisonDamageReceived; - int oldduration = target->PoisonDurationReceived; - // Check for invulnerability. if (!(inflictor->flags6 & MF6_POISONALWAYS)) { @@ -1393,6 +1390,8 @@ void P_PoisonMobj (AActor *target, AActor *inflictor, AActor *source, int damage } target->Poisoner = source; + target->PoisonDamageTypeReceived = type; + target->PoisonPeriodReceived = period; if (inflictor->flags6 & MF6_ADDITIVEPOISONDAMAGE) { @@ -1412,7 +1411,6 @@ void P_PoisonMobj (AActor *target, AActor *inflictor, AActor *source, int damage target->PoisonDurationReceived = duration; } - target->PoisonPeriodReceived = period; } bool AActor::OkayToSwitchTarget (AActor *other) diff --git a/src/p_local.h b/src/p_local.h index b3d58bc3b..c4bf127b3 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -479,7 +479,7 @@ extern FBlockNode** blocklinks; // for thing chains // void P_TouchSpecialThing (AActor *special, AActor *toucher); void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, FName mod, int flags=0); -void P_PoisonMobj (AActor *target, AActor *inflictor, AActor *source, int damage, int duration, int period); +void P_PoisonMobj (AActor *target, AActor *inflictor, AActor *source, int damage, int duration, int period, FName type); bool P_GiveBody (AActor *actor, int num); bool P_PoisonPlayer (player_t *player, AActor *poisoner, AActor *source, int poison); void P_PoisonDamage (player_t *player, AActor *source, int damage, bool playPainSound); diff --git a/src/p_map.cpp b/src/p_map.cpp index 000946462..73b17e7d1 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -1118,7 +1118,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) // Do poisoning (if using new style poison) if (tm.thing->PoisonDamage > 0 && tm.thing->PoisonDuration != INT_MIN) { - P_PoisonMobj(thing, tm.thing, tm.thing->target, tm.thing->PoisonDamage, tm.thing->PoisonDuration, tm.thing->PoisonPeriod); + P_PoisonMobj(thing, tm.thing, tm.thing->target, tm.thing->PoisonDamage, tm.thing->PoisonDuration, tm.thing->PoisonPeriod, tm.thing->PoisonDamageType); } damage = tm.thing->GetMissileDamage (3, 2); @@ -1146,7 +1146,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) // Do poisoning (if using new style poison) if (tm.thing->PoisonDamage > 0 && tm.thing->PoisonDuration != INT_MIN) { - P_PoisonMobj(thing, tm.thing, tm.thing->target, tm.thing->PoisonDamage, tm.thing->PoisonDuration, tm.thing->PoisonPeriod); + P_PoisonMobj(thing, tm.thing, tm.thing->target, tm.thing->PoisonDamage, tm.thing->PoisonDuration, tm.thing->PoisonPeriod, tm.thing->PoisonDamageType); } // Do damage @@ -3526,7 +3526,7 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, // Allow puffs to inflict poison damage, so that hitscans can poison, too. if (puffDefaults->PoisonDamage > 0 && puffDefaults->PoisonDuration != INT_MIN) { - P_PoisonMobj(trace.Actor, puff ? puff : t1, t1, puffDefaults->PoisonDamage, puffDefaults->PoisonDuration, puffDefaults->PoisonPeriod); + P_PoisonMobj(trace.Actor, puff ? puff : t1, t1, puffDefaults->PoisonDamage, puffDefaults->PoisonDuration, puffDefaults->PoisonPeriod, puffDefaults->PoisonDamageType); } // [GZ] If MF6_FORCEPAIN is set, we need to call P_DamageMobj even if damage is 0! @@ -3900,7 +3900,7 @@ void P_RailAttack (AActor *source, int damage, int offset, int color1, int color if (spawnpuff) P_SpawnPuff (source, puffclass, x, y, z, (source->angle + angleoffset) - ANG90, 1, PF_HITTHING); if (puffDefaults && puffDefaults->PoisonDamage > 0 && puffDefaults->PoisonDuration != INT_MIN) - P_PoisonMobj(RailHits[i].HitActor, thepuff ? thepuff : source, source, puffDefaults->PoisonDamage, puffDefaults->PoisonDuration, puffDefaults->PoisonPeriod); + P_PoisonMobj(RailHits[i].HitActor, thepuff ? thepuff : source, source, puffDefaults->PoisonDamage, puffDefaults->PoisonDuration, puffDefaults->PoisonPeriod, puffDefaults->PoisonDamageType); P_DamageMobj (RailHits[i].HitActor, thepuff? thepuff:source, source, damage, damagetype, DMG_INFLICTOR_IS_PUFF); } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 6016c0487..075124a1e 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -313,8 +313,12 @@ void AActor::Serialize (FArchive &arc) << DamageFactor << WeaveIndexXY << WeaveIndexZ << PoisonDamageReceived << PoisonDurationReceived << PoisonPeriodReceived << Poisoner - << PoisonDamage << PoisonDuration << PoisonPeriod - << ConversationRoot << Conversation; + << PoisonDamage << PoisonDuration << PoisonPeriod; + if (SaveVersion >= 3235) + { + arc << PoisonDamageType << PoisonDamageTypeReceived; + } + arc << ConversationRoot << Conversation; { FString tagstr; @@ -3231,7 +3235,7 @@ void AActor::Tick () // Check for poison damage, but only once per PoisonPeriod tics (or once per second if none). if (PoisonDurationReceived && (level.time % (PoisonPeriodReceived ? PoisonPeriodReceived : TICRATE) == 0)) { - P_DamageMobj(this, NULL, Poisoner, PoisonDamageReceived, NAME_Poison, 0); + P_DamageMobj(this, NULL, Poisoner, PoisonDamageReceived, PoisonDamageTypeReceived ? PoisonDamageTypeReceived : (FName)NAME_Poison, 0); --PoisonDurationReceived; diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index 8e94e7817..69adc302f 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -1090,6 +1090,16 @@ DEFINE_PROPERTY(poisondamage, Iii, Actor) } } +//========================================================================== +// +//========================================================================== +DEFINE_PROPERTY(poisondamagetype, S, Actor) +{ + PROP_STRING_PARM(poisondamagetype, 0); + + defaults->PoisonDamageType = poisondamagetype; +} + //========================================================================== // //==========================================================================