Ludeon Forums

RimWorld => General Discussion => Topic started by: juanval on July 21, 2016, 05:07:57 AM

Title: What is the pain formula?
Post by: juanval on July 21, 2016, 05:07:57 AM
I see that pain is rated with percentages. I'd like to ask you how pain is calculated.

Thanks in advance
Title: Re: What is the pain formula?
Post by: skullywag on July 21, 2016, 05:24:57 AM

// 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.
Title: Re: What is the pain formula?
Post by: juanval on July 21, 2016, 06:35:55 AM
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
Title: Re: What is the pain formula?
Post by: skullywag on July 21, 2016, 08:07:45 AM
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.
Title: Re: What is the pain formula?
Post by: 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
Title: Re: What is the pain formula?
Post by: Jimyoda on August 24, 2016, 12:49:56 PM
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.
Title: Re: What is the pain formula?
Post by: 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.
Title: Re: What is the pain formula?
Post by: 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.
Title: Re: What is the pain formula?
Post by: Wex on August 24, 2016, 03:27:54 PM
It's probably something related to consciousness.
Title: Re: What is the pain formula?
Post by: juanval on August 24, 2016, 06:31:36 PM
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