Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Assemblies/TorannMagic.dll
Binary file not shown.
103 changes: 102 additions & 1 deletion Defs/AbilityDefs/Abilities_TMagic_Priest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<efficiencyReductionPercent>.06</efficiencyReductionPercent>
<learnChance>.3</learnChance>
<canCopy>true</canCopy>
<MainVerb Class="AbilityUser.VerbProperties_Ability">
<MainVerb Class="TorannMagic.VerbProperties_Purify">
<verbClass>TorannMagic.Verb_Purify</verbClass>
<tooltipShowProjectileDamage>false</tooltipShowProjectileDamage>
<tooltipShowExtraDamages>false</tooltipShowExtraDamages>
Expand All @@ -91,6 +91,107 @@
<canTargetSelf>true</canTargetSelf>
<canTargetLocations>false</canTargetLocations>
</targetParams>
<healableHediffs>
<li>
<hediffs>
<li>Cataract</li>
<li>HearingLoss</li>
<li>ToxicBuildup</li>
</hediffs>
<minLevel>0</minLevel>
<baseAmount>0.4</baseAmount>
<amountPerLevel>0.3</amountPerLevel>
</li>
<li>
<hediffs>
<li>Asthma</li>
</hediffs>
<minLevel>1</minLevel>
<baseAmount>10</baseAmount>
<alsoRemoveOnFullHeal>Asthma</alsoRemoveOnFullHeal>
</li>
<li>
<hediffs>
<li>Blindness</li>
<li>Cirrhosis</li>
<li>ChemicalDamageModerate</li>
</hediffs>
<minLevel>1</minLevel>
<baseAmount>0.3</baseAmount>
<amountPerLevel>0.2</amountPerLevel>
</li>
<li>
<hediffs>
<li>Frail</li>
<li>BadBack</li>
<li>Carcinoma</li>
<li>ChemicalDamageSevere</li>
</hediffs>
<minLevel>2</minLevel>
<baseAmount>0.25</baseAmount>
<amountPerLevel>0.2</amountPerLevel>
</li>
<li>
<hediffs>
<li>Alzheimers</li>
<li>Dementia</li>
<li>HeartArteryBlockage</li>
<li>PsychicShock</li>
<li>CatatonicBreakdown</li>
</hediffs>
<minLevel>3</minLevel>
<baseAmount>0.15</baseAmount>
<amountPerLevel>0.15</amountPerLevel>
</li>
<li>
<hediffs>
<li>Abasia</li>
</hediffs>
<minLevel>3</minLevel>
<isRemovalChance>true</isRemovalChance>
<baseAmount>0.25</baseAmount>
<amountPerLevel>0.05</amountPerLevel>
</li>
<li>
<hediffs>
<li>AlcoholAddiction</li>
<li>SmokeleafAddiction</li>
</hediffs>
<minLevel>0</minLevel>
<baseAmount>0.3</baseAmount>
<amountPerLevel>0.3</amountPerLevel>
<useArcaneDamage>true</useArcaneDamage>
</li>
<li>
<hediffs>
<li>GoJuiceAddiction</li>
<li>WakeUpAddiction</li>
</hediffs>
<minLevel>1</minLevel>
<baseAmount>0.25</baseAmount>
<amountPerLevel>0.25</amountPerLevel>
<useArcaneDamage>true</useArcaneDamage>
</li>
<li>
<hediffs>
<li>PsychiteAddiction</li>
</hediffs>
<minLevel>2</minLevel>
<baseAmount>0.25</baseAmount>
<amountPerLevel>0.25</amountPerLevel>
<useArcaneDamage>true</useArcaneDamage>
</li>
<li>
<hediffs>
<li>LuciferiumAddiction</li>
</hediffs>
<minLevel>3</minLevel>
<baseAmount>0.15</baseAmount>
<amountPerLevel>0.15</amountPerLevel>
<useArcaneDamage>true</useArcaneDamage>
<alsoRemoveOnFullHeal>LuciferiumHigh</alsoRemoveOnFullHeal>
</li>
</healableHediffs>
</MainVerb>
</TorannMagic.TMAbilityDef>

Expand Down
13 changes: 13 additions & 0 deletions Source/TMagic/TMagic/ModOptions/TM_DebugTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ public static void RemoveClass(Pawn pawn)
}
}

[DebugAction("RWoM", "Grant 1000 XP", actionType = DebugActionType.ToolMapForPawns, allowedGameStates = AllowedGameStates.PlayingOnMap)]
public static void Grant1000XP(Pawn pawn)
{
if (pawn == null)
return;

CompAbilityUserMagic compMagic = pawn.GetComp<CompAbilityUserMagic>();
if (compMagic == null)
return;

compMagic.MagicUserXP += 1000;
}

public static void RemoveClassHediffs(Pawn pawn)
{
List<Hediff> rhd = new List<Hediff>();
Expand Down
1 change: 1 addition & 0 deletions Source/TMagic/TMagic/TorannMagic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
<Compile Include="TM_AutocastConditionDef.cs" />
<Compile Include="TM_CustomPowerDef.cs" />
<Compile Include="TM_WeatherEvent_MeshGeneric.cs" />
<Compile Include="VerbProperties_Purify.cs" />
<Compile Include="Verb_Discord.cs" />
<Compile Include="Verb_SummonSpiritWolves.cs" />
<Compile Include="Verb_SummonTotemHealing.cs" />
Expand Down
26 changes: 26 additions & 0 deletions Source/TMagic/TMagic/VerbProperties_Purify.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using RimWorld;
using AbilityUser;
using Verse;
using UnityEngine;

namespace TorannMagic
{
public class VerbProperties_Purify : AbilityUser.VerbProperties_Ability
{
public class HealableHediffParameters
{
public List<string> hediffs = new List<string>();
public int minLevel = 0;
public float baseAmount = 0.0f;
public float amountPerLevel = 0.0f;
public bool useArcaneDamage = false;
public bool isRemovalChance = false;
public string alsoRemoveOnFullHeal = "";
}

public List<HealableHediffParameters> healableHediffs = new List<HealableHediffParameters>();
}
}
129 changes: 49 additions & 80 deletions Source/TMagic/TMagic/Verb_Purify.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class Verb_Purify : Verb_UseAbility
private int pwrVal;
float arcaneDmg = 1f;

public VerbProperties_Purify Props => (VerbProperties_Purify)UseAbilityProps;

bool validTarg;
//Used for non-unique abilities that can be used with shieldbelt
public override bool CanHitTargetFrom(IntVec3 root, LocalTargetInfo targ)
Expand Down Expand Up @@ -68,13 +70,13 @@ protected override bool TryCastShot()
bool flag = pawn != null && !pawn.Dead;
if (flag)
{
int num = Mathf.RoundToInt(1f + (.4f * verVal));
int numberOfThingsToHeal = Mathf.RoundToInt(1f + (.4f * verVal));
using (IEnumerator<BodyPartRecord> enumerator = pawn.health.hediffSet.GetInjuredParts().GetEnumerator())
{
while (enumerator.MoveNext())
{
BodyPartRecord rec = enumerator.Current;
bool flag2 = num > 0;
bool flag2 = numberOfThingsToHeal > 0;
if (flag2)
{
int num2 = 1 + verVal;
Expand All @@ -96,15 +98,15 @@ protected override bool TryCastShot()
if (pwrVal >= 1)
{
current.Heal(pwrVal * arcaneDmg);
num--;
numberOfThingsToHeal--;
num2--;
}
}
else
{
current.Heal((2f + pwrVal * 2) * arcaneDmg);
//current.Heal(5.0f + (float)pwrVal * 3f); // power affects how much to heal
num--;
numberOfThingsToHeal--;
num2--;
}
TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .6f);
Expand All @@ -116,94 +118,61 @@ protected override bool TryCastShot()
}
}
}
//if (pawn.RaceProps.Humanlike)
//{
using (IEnumerator<Hediff> enumerator = pawn.health.hediffSet.GetHediffs<Hediff>().GetEnumerator())

if (numberOfThingsToHeal > 0)
{
while (enumerator.MoveNext())
foreach (Hediff hediff in pawn.health.hediffSet.GetHediffs<Hediff>())
{
Hediff rec = enumerator.Current;
bool flag2 = num > 0;
if (flag2)
if (numberOfThingsToHeal <= 0)
break;

string hediffName = hediff.def.defName;

// Look up healable parameters and see if there is an entry for this hediff
VerbProperties_Purify.HealableHediffParameters healableParameters = Props.healableHediffs.Find(hh => hh.hediffs.Contains(hediffName));
if (healableParameters == null)
continue;

// Make sure we are capable of healing it
if (verVal < healableParameters.minLevel)
continue;

float healAmount = (healableParameters.baseAmount + (healableParameters.amountPerLevel * pwrVal));
if (healableParameters.useArcaneDamage)
healAmount *= arcaneDmg;

// Is the heal amount just a chance to fully remove?
if (healableParameters.isRemovalChance)
{
if (rec.def.defName == "Cataract" || rec.def.defName == "HearingLoss" || rec.def.defName.Contains("ToxicBuildup"))
{
rec.Heal(.4f + .3f * pwrVal);
num--;
}
if ((rec.def.defName == "Blindness" || rec.def.defName.Contains("Asthma") || rec.def.defName == "Cirrhosis" || rec.def.defName == "ChemicalDamageModerate") && verVal >= 1)
{
rec.Heal(.3f + .2f * pwrVal);
if (rec.def.defName.Contains("Asthma"))
{
pawn.health.RemoveHediff(rec);
}
num--;
}
if ((rec.def.defName == "Frail" || rec.def.defName == "BadBack" || rec.def.defName.Contains("Carcinoma") || rec.def.defName == "ChemicalDamageSevere") && verVal >= 2)
{
rec.Heal(.25f + .2f * pwrVal);
num--;
}
if ((rec.def.defName.Contains("Alzheimers") || rec.def.defName == "Dementia" || rec.def.defName.Contains("HeartArteryBlockage") || rec.def.defName == "PsychicShock" || rec.def.defName == "CatatonicBreakdown") && verVal >= 3)
{
rec.Heal(.15f + .15f * pwrVal);
num--;
}
if(rec.def.defName.Contains("Abasia") && verVal >= 3)
//Log.Message(String.Format("{0}: {1} heal chance {2}", pawn, hediff.def.defName, healAmount));
if (Rand.Chance(healAmount))
{
if(Rand.Chance(.25f + (.05f * pwrVal)))
{
pawn.health.RemoveHediff(pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("Abasia")));
num--;
}
else
{
MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, "Failed to remove Abasia...");
}
//Log.Message(String.Format("{0}: {1} heal successful!", pawn, hediff.def.defName));
pawn.health.RemoveHediff(hediff);
}
TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .6f);
TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .4f);
}
}
}
//}
using (IEnumerator<Hediff_Addiction> enumerator = pawn.health.hediffSet.GetHediffs<Hediff_Addiction>().GetEnumerator())
{
while (enumerator.MoveNext())
{
Hediff_Addiction rec = enumerator.Current;
bool flag2 = num > 0;
if (flag2)
// Otherwise lower the severity by the heal amount
else
{
if (rec.Chemical.defName == "Alcohol" || rec.Chemical.defName == "Smokeleaf")
// If something else should be removed on a full heal
if (!string.IsNullOrEmpty(healableParameters.alsoRemoveOnFullHeal) && hediff.Severity <= healAmount)
{
rec.Severity -= ((.3f + .3f * pwrVal)*arcaneDmg);
num--;
}
if ((rec.Chemical.defName == "GoJuice" || rec.Chemical.defName == "WakeUp") && verVal >= 1)
{
rec.Severity -= ((.25f + .25f * pwrVal)*arcaneDmg);
num--;
}
if (rec.Chemical.defName == "Psychite" && verVal >= 2)
{
rec.Severity -= ((.25f + .25f * pwrVal)*arcaneDmg);
num--;
}
if (verVal >= 3)
{
if (rec.Chemical.defName == "Luciferium" && (rec.Severity - ((.15f + .15f * pwrVal)*arcaneDmg) < 0))
Hediff firstHediffOfDef = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named(healableParameters.alsoRemoveOnFullHeal));
if (firstHediffOfDef != null)
{
Hediff luciHigh = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("LuciferiumHigh"), false);
pawn.health.RemoveHediff(luciHigh);
//Log.Message(String.Format("{0}: {1} removed", pawn, healableParameters.alsoRemoveOnFullHeal));
pawn.health.RemoveHediff(firstHediffOfDef);
}
rec.Severity -= ((.15f + .15f * pwrVal) * arcaneDmg);
num--;
}
TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .6f);
TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .4f);

//Log.Message(String.Format("{0}: {1} being healed by {2}", pawn, hediff.def.defName, healAmount));
hediff.Heal(healAmount);
}

TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, 0.6f);
TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, 0.4f);

--numberOfThingsToHeal;
}
}
}
Expand Down