diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 5290e897a..17b6e5c25 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,5 @@ October 8, 2009 (Changes by Graf Zahl) +- Added a PainThreshold actor property. - fixed: Teleport_EndGame did not set the end sequence name properly. October 7, 2009 diff --git a/src/actor.h b/src/actor.h index c2b0ef1a8..8260b8fbf 100644 --- a/src/actor.h +++ b/src/actor.h @@ -842,6 +842,7 @@ public: fixed_t MaxDropOffHeight, MaxStepHeight; SDWORD Mass; SWORD PainChance; + int PainThreshold; FNameNoInit DamageType; FState *SpawnState; diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 6b52bdd38..8c0246555 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -1268,49 +1268,54 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage } } - pc = target->GetClass()->ActorInfo->PainChances; - painchance = target->PainChance; - if (pc != NULL) - { - BYTE * ppc = pc->CheckKey(mod); - if (ppc != NULL) - { - painchance = *ppc; - } - } -dopain: if (!(target->flags5 & MF5_NOPAIN) && (inflictor == NULL || !(inflictor->flags5 & MF5_PAINLESS)) && - !G_SkillProperty(SKILLP_NoPain) && (pr_damagemobj() < painchance || - (inflictor != NULL && (inflictor->flags6 & MF6_FORCEPAIN))) && !(target->flags & MF_SKULLFLY)) + !G_SkillProperty(SKILLP_NoPain) && !(target->flags & MF_SKULLFLY)) { - if (mod == NAME_Electric) + + pc = target->GetClass()->ActorInfo->PainChances; + painchance = target->PainChance; + if (pc != NULL) { - if (pr_lightning() < 96) + BYTE * ppc = pc->CheckKey(mod); + if (ppc != NULL) + { + painchance = *ppc; + } + } + + if ((damage > target->PainThreshold && pr_damagemobj() < painchance) || + (inflictor != NULL && (inflictor->flags6 & MF6_FORCEPAIN))) + { +dopain: + if (mod == NAME_Electric) + { + if (pr_lightning() < 96) + { + justhit = true; + FState * painstate = target->FindState(NAME_Pain, mod); + if (painstate != NULL) target->SetState (painstate); + } + else + { // "electrocute" the target + target->renderflags |= RF_FULLBRIGHT; + if ((target->flags3 & MF3_ISMONSTER) && pr_lightning() < 128) + { + target->Howl (); + } + } + } + else { justhit = true; FState * painstate = target->FindState(NAME_Pain, mod); if (painstate != NULL) target->SetState (painstate); - } - else - { // "electrocute" the target - target->renderflags |= RF_FULLBRIGHT; - if ((target->flags3 & MF3_ISMONSTER) && pr_lightning() < 128) + if (mod == NAME_PoisonCloud) { - target->Howl (); - } - } - } - else - { - justhit = true; - FState * painstate = target->FindState(NAME_Pain, mod); - if (painstate != NULL) target->SetState (painstate); - if (mod == NAME_PoisonCloud) - { - if ((target->flags3 & MF3_ISMONSTER) && pr_poison() < 128) - { - target->Howl (); + if ((target->flags3 & MF3_ISMONSTER) && pr_poison() < 128) + { + target->Howl (); + } } } } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 3cb95148e..a8975a5cd 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -301,6 +301,11 @@ void AActor::Serialize (FArchive &arc) << Score << Tag; + if (SaveVersion >= 1900) + { + arc << PainThreshold; + } + for(int i=0; i<10; i++) arc << uservar[i]; if (arc.IsStoring ()) diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index 92e259f0c..66e7cdc6f 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -363,6 +363,16 @@ DEFINE_PROPERTY(painchance, ZI, Actor) } } +//========================================================================== +// +//========================================================================== +DEFINE_PROPERTY(painthreshold, I, Actor) +{ + PROP_INT_PARM(id, 0); + + defaults->PainThreshold = id; +} + //========================================================================== // //==========================================================================