What is the pain formula?

Started by juanval, July 21, 2016, 05:07:57 AM

Previous topic - Next topic

juanval

I see that pain is rated with percentages. I'd like to ask you how pain is calculated.

Thanks in advance

skullywag


// Verse.HediffSet
private float CalculatePain()
{
if (!this.pawn.RaceProps.IsFlesh || this.pawn.Dead)
{
return 0f;
}
float num = 0f;
for (int i = 0; i < this.hediffs.Count; i++)
{
num += this.hediffs[i].PainOffset;
}
float num2 = num / this.pawn.HealthScale;
for (int j = 0; j < this.hediffs.Count; j++)
{
num2 *= this.hediffs[j].PainFactor;
}
return Mathf.Clamp(num2, 0f, 1f);
}


Hope that helps, basically it looks at the hediffs and is calculating the pain from those.

Then the pain thoughts are staged as such:


//RimWorld.ThoughtWorker_Pain
protected override ThoughtState CurrentStateInternal(Pawn p)
{
float pain = p.health.hediffSet.Pain;
if (pain < 0.0001f)
{
return ThoughtState.Inactive;
}
if (pain < 0.15f)
{
return ThoughtState.ActiveAtStage(0);
}
if (pain < 0.4f)
{
return ThoughtState.ActiveAtStage(1);
}
if (pain < 0.8f)
{
return ThoughtState.ActiveAtStage(2);
}
return ThoughtState.ActiveAtStage(3);
}
}


Hope that helps.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

juanval

Sorry, I mean the matemathical formula. How much pain in percentaje causes a knive hit or pistol hit. Or, if a colonist has a 67% of pain from different wounds, I'd like to know how much pain causes each wound

skullywag

you mean how much pain a wound causes. (pain doesnt cause wounds)

Every hediff (like burn, crush etc) has some parts of their def that control this, namely:

painPerSeverity

the game looks at the severity of the hediff and multiplies that by the painPerSeverity (from the hediffdef), this is basically how pain is worked out.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

juanval

I see that some dead animals or raiders have lots of injures but doesn't have 0 HP in any vital parts. Why they die then? because of the extreme pain caused?

Thanks in advance. The Rimworld health system is superb

Jimyoda

Taken from the wiki (I have not verified accuracy)...

Pain = Number of Injuries ÷ [80.0 × Max Pain Level Multiplier1 × Health Scale2 + Extra Pain ÷ (80.0 × Max Pain Level Multiplier)]

1 Value for humans is 1.0.
2 Value for humans is 1.0.
Quote from: Rahjital on July 09, 2015, 03:09:55 PM
"I don't like that farmers chop people up."

Obviously she has already played Rimworld :P

Read the wiki. Edit the wiki. Let the wiki be your guide.
http://rimworldwiki.com/

MeowRailroad

Quote from: juanval on August 24, 2016, 11:47:35 AM
I see that some dead animals or raiders have lots of injures but doesn't have 0 HP in any vital parts. Why they die then? because of the extreme pain caused?

Thanks in advance. The Rimworld health system is superb

They may have bled to death, burned to death, or some other thing happened to them.
Quote from: Tynan on December 02, 2016, 05:24:06 PM
This is like being in a remote fishing town in Libera and asking, "Why can't I just pay one of the fishermen $10 to take me back to Los Angeles?"

cultist

Quote from: MeowRailroad on August 24, 2016, 01:30:48 PM
Quote from: juanval on August 24, 2016, 11:47:35 AM
I see that some dead animals or raiders have lots of injures but doesn't have 0 HP in any vital parts. Why they die then? because of the extreme pain caused?

Thanks in advance. The Rimworld health system is superb

They may have bled to death, burned to death, or some other thing happened to them.

I don't think so, I have seen this as well. Tribals will often drop dead with lots of small wounds from gun turrets but no fully destroyed body parts. It doesn't happen fast enough for them to bleed to death and there is usually no fire involved. I always assumed it was pain reaching a certain level that killed them but I have no idea if that's true. Sick pawn are often in extreme pain for a long time without dying, so I'm not sure how it works exactly.

Wex

It's probably something related to consciousness.
"You are not entitled to your opinion. You are entitled to your informed opinion. No one is entitled to be ignorant."
    Harlan Ellison

juanval

Quote from: cultist on August 24, 2016, 02:44:39 PM
Quote from: MeowRailroad on August 24, 2016, 01:30:48 PM
Quote from: juanval on August 24, 2016, 11:47:35 AM
I see that some dead animals or raiders have lots of injures but doesn't have 0 HP in any vital parts. Why they die then? because of the extreme pain caused?

Thanks in advance. The Rimworld health system is superb

They may have bled to death, burned to death, or some other thing happened to them.

I don't think so, I have seen this as well. Tribals will often drop dead with lots of small wounds from gun turrets but no fully destroyed body parts. It doesn't happen fast enough for them to bleed to death and there is usually no fire involved. I always assumed it was pain reaching a certain level that killed them but I have no idea if that's true. Sick pawn are often in extreme pain for a long time without dying, so I'm not sure how it works exactly.

Yeah. Multi-injured enemies with no fatal injures and no time to bleed die due to a unknown factor. The more realistic factor could be the extreme pain