Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - JT

#1
Circumstances:

When running an ideology with all roles removed, the right-click float "verb" menu will fail to open.

Savegame:

Not applicable.

Cause and solution:

The culprit is the RimWorld function:


// H:\RimWorld13\RimWorldWin64_Data\Managed\Assembly-CSharp.dll
// Assembly-CSharp, Version=1.3.7922.19870, Culture=neutral, PublicKeyToken=null
// Global type: <Module>
// Architecture: AnyCPU (64-bit preferred)
// Runtime: v4.0.30319
// Hash algorithm: SHA1
// RimWorld.RitualBehaviorWorker_Conversion
public override string CanStartRitualNow(TargetInfo target, Precept_Ritual ritual, Pawn selectedPawn = null, Dictionary<string, Pawn> forcedForRole = null)
{
Precept_Role precept_Role = ritual.ideo.RolesListForReading.First((Precept_Role r) => r.def == PreceptDefOf.IdeoRole_Moralist);
if (precept_Role.ChosenPawnSingle() == null)
{
return "CantStartRitualRoleNotAssigned".Translate(precept_Role.LabelCap);
}
bool flag = false;
foreach (Pawn item in target.Map.mapPawns.FreeColonistsAndPrisonersSpawned)
{
if (ValidateConvertee(item, precept_Role.ChosenPawnSingle(), throwMessages: false))
{
flag = true;
break;
}
}
if (!flag)
{
return "CantStartRitualNoConvertee".Translate(precept_Role.ChosenPawnSingle().Ideo.name);
}
return base.CanStartRitualNow(target, ritual, selectedPawn, forcedForRole);
}


If the error doesn't immediately leap out at you, the problem is that the routine is scanning for the first spiritual leader role of the pawn's ideology.  Upon finding that role, it then verifies whether that role is assigned to any colonist.

However, if you have removed every role from your ideology, the IEnumerable<>.First() function will throw an exception, because it cannot operate against an empty set.

The function should be changed to use FirstOrDefault() instead, and the following line should double-check to be sure that precept_Role is non-null.

This is a vanilla bug, but is exposed by mods, because Achtung! includes a prompt that reports when an exception is encountered while attempting to display the float menu.

jcstryker first discovered this issue: https://github.com/lilwhitemouse/RimWorld-LWM.DeepStorage/issues/110#issuecomment-926989363

Cheers!
#2
I spend so much time refining mods that I often forget to release my updates!  Damn'd be him that first cries "hold, enough", but enough is enough!  Damn me!

Field Surgery
Combat Casualty Care and Essential Medicines


No immediate danger because the malignant lung was literally just removed.  Ask me again in 2 hours, 51 minutes, and 36 seconds.

Features:
* Ability to dismember malignant limbs and organs without the use of anaesthetic, in emergency situations.
* This causes loads of surgical pain, including phantom pain for all trailing digits, which really sucks for the patient... so you'll generally want to use proper amputation unless you don't have any medicine or don't care.
* Dismemberment will also leave a surgical cut in the parent body part.
* Hold Shift before clicking Add Bill to dismember non-malignant limbs and organs, if you so choose...
* Untransplantable waste material is produced from a dismemberment.  Suggestion: Remove "human flesh" from your freezer's whitelist and add it to your dumping zone.  Or don't.
* Draw blood packs and plasma packs from colonists.
* Blood packs will deteriorate when frozen.  Keep refrigerated only!  Can be treated with neutroamine for indefinite storage in freezer.
* Plasma can be frozen safely and lasts longer than blood, but only treats blood loss symptomatically.
* Saline is available from traders or easily manufactured from neutroamine.  It lasts indefinitely and is ideal for use in the field, but treats even fewer symptoms than plasma.
* Antimalarial medications for nauseating self-treatment of malaria.  Slightly-less-nauseating tonic water and alcoholic jinnantonyx for a more palatable solution (figuratively and literally).
* Ananogel for treating both the positive and negative side effects of fibrous and sensory mechanites.  Caution: Will not treat luciferium but will suppress its positive side effects.
* Endotide, a psychoid painkiller, for treating pain.  Avoid administering to patients with critical blood loss.
* Wormicide for treating gutworms.  Ingestible poison: please moderate your doses.
* Newly added additional symptoms of blood loss include respiratory depression as well as impairments to blood circulation and blood filtration.

Recommended for use with Combat Extended for optimal combat realism (but not required).  Be sure to load Field Surgery lower in your mod order, as Combat Extended replaces the BloodLoss hediff outright: if Field Surgery is loaded first then Combat Extended will undo everything, which is bad and it should feel bad.

Post-traumatic stress disorder was not caused by the surgery (surprisingly, I know... it was actually caused by the battle which led to the lung being damaged by an explosion) and is provided by RimDisorders (also not required).

Compatible with all known surgery mods (again, not required, but now you're just being pedantic).

Changelog:

06 July 2017 - A17 Version 4 Hotfixed:
* Fixed offset messages in the beverages (tonic water, jinnantonyx) -- the XML syntax had changed from A16 to A17.
* Version number unchanged.  Same download link.

05 July 2017 - A17 Version 4:
* Updated to Alpha 17, finally.  Eventually I may even be able to release a mod update without the "finally" qualifier.
    Eventually.  In my admittedly less than humble opinion, however, the wait was worth it.
* Some of the features I intended for this release are being delayed until version 5.  Specifically, no vanilla
    surgeries accommodate my improvements (yet).
* Minor rewrites to accommodate a few more seemingly unnecessary core restructurings in A17.
* Removed most of the prefixing on the internal classes of the mod, since it was redundant against the namespace.
* Conceptual body parts can no longer be dismembered. (waist, etc.)
* Although prostheses cannot be directly dismembered, by intention, dismembered higher limb segments will now properly
    drop the prostheses of lower segments.
* Dismemberment will now cause damage to the next higher body part(s) proportional to the side area of the part being
    removed, +1 HP.  e.g., if a lung is 20 HP, the side area is 20**(2/3) = 7.36, so floor(7.36 + 1) = 8 HP of damage
    to the torso.  This also applies to parts within parts -- removing the brain will cut the skull and cut the head
    based on the size of the brain.  Of course, the patient would not likely survive such a procedure.
* Fixed bug where the removed organ, if destroyed by surgery failure, would result in a 99999-point hit to the next
    higher body part (which in the case of the torso or head would be rather fatal I'm afraid).  Also reduced the
    damage applied to be no greater than the health of the specified body part.
* Re-enabled "elective" dismemberment: hold Shift while clicking Add Bill.  Options are therefore now hidden from non-
    guilty persons unless you want to see them.
* Parts that should not be dismembered can no longer be dismembered therapeutically (neck, etc.).  They can still be
    electively removed, with predictable results.
* Waste flesh is now produced upon removing any organ or non-solid tissue.  Currently the amount is a simple formula
    based on the part's hit points rather than volume.  This could theoretically produce more meat than simply
    butchering the body, but is balanced with the high chance of death and the moral implications of cutting a person
    apart piece by piece for food.  You know.  Just sayin'.
* Cannibals are now treated as psychopaths for purposes of positive thoughts from dismembering patients.
* Operations now produce plenty of blood filth in the operating area, especially on failure.
* New HediffComponent: CapToHediff.  This prevents the attached Hediff from having a higher severity than the target
    hediff.
* New HediffComponent: ExpireWithHediff.  This causes the attached Hediff to be removed if the target hediff is no
    longer detected.
* New HediffComponent: ModifyHediff.  This increases or reduces the severity of the target hediff over time, but only
    if the target hediff is actually present.
* New IngestionOutcomeDoer: TreatHediff.  This simply tends the first found target hediff with a quality of 0%.
* New ThingComponent: DeteriorateWhenFrozen.  This causes the attached Thing to suffer damage over time when frozen, an
    instant amount of damage when dropping below freezing, and/or an instant amount of damage when thawing above
    freezing.
* Added blood packs and blood extraction.
* Blood will DeteriorateWhenFrozen and will ModifyHediff of blood loss.
* Added plasma packs and plasma extraction.
* Plasma is CapToHediff'ed of blood loss, and will ExpireWithHediff of blood loss.  It suppresses the symptoms
    proportional to the amount of plasma IVs attached.
* Added saline packs and saline manufacturing.
* Saline is identical to plasma but treats fewer side effects (if using the exsanguination patch).
* All transfusion packs provide an attached IV.  The patient, if not incapacitated, is able to move around with reduced
    mobility with the IV pack attached.  Low-skilled medics may spill some of the contents while rigging it up.
* Added antimalarials, a bottled malaria preventive and treatment.  Nauseating.  Can be self-administered.
* Added wormicide, a bottled gutworms treatment.  Toxic, especially if multiple doses are taken too quickly.  Can be
    self-administered.
* Added tonic water.  Can be made at any stove from antimalarials.  Less nauseating and is a joy item.  Can be self-
    administered.
* Added jinnantonyx.  Can be made at any stove from antimalarials and beer.  Less nauseating and is a joy item.  Can be
    self-administered.
* Added ananogel, a bottled anti-mechanite treatment.  Simple and safe glittertech which can be self-administered.
* Added endotide, a strong painkiller.  Therapeutic in low doses, anaesthetic in high doses.  Avoid use on patients
    with heart problems as it reduces blood circulation.
* Optional exsanguination patch activated by default adds additional symptoms to blood loss, including respiratory
    depression and reduced circulation and blood filtration.

19 April 2017 - A16 Version 3:
* Updated to Alpha 16, finally.
* Since Tynan and crew threw me a bone and converted a utility class from protected to public, I no longer have to use
    a ridiculous IL reflection in the code, so this is now also safer and more robust.
* Changed: For colonists, "elective" dismemberment will no longer appear in the list of operations -- only injured
    parts can be dismembered.
* Prisoners can however still be Reservoir Dogs'ed, with all normal penalties intact.

14 August 2016 - A14 Version 2b:
* Hotfix: Whoops, stuck my version identifier in About.xml after the closing tag of the description, which caused debug
    errors on load. (The mod still worked fine, though.)  Which, naturally, I changed after I finished testing and
    before uploading... sigh.
* No other changes. =P

14 August 2016 - A14 Version 2:
* Finally came up with a solution for masochism I liked -- positive thoughts from limb(s) removed occur only if both
    masochist and prosthophile
* Fixed missing abstracts

12 August 2016 - A14 Version 1:
* First release


Download:
A17 - D O W N L O A D <- Click me! Or don't. I'm not your boss.
(v4 - A17 - 2017-JUL-04)

(Archived A16 v3 and A14 v2b versions.)

Licence:
Simplified BSD.  Feel free to adapt, claim, use, abuse, or embed in a modpack.  (Provided the licence remains intact, obviously.  Which is, basically, "give credit".  Full text in the mod's About folder as usual.)  I will continue making my own changes to the mod, unless I get bored, so by all means contribute back if you come up with something cool!



Not affiliated with Jamestec.  But he's got, like, six more letters to choose from for his namespaces. ;-)
#3
Yet another of my crazy difficult questions. =)

Has anyone been able to achieve success with creating an entirely new HediffComp_ from scratch, which inherits from HediffComp, rather than just re-using the existing HediffComps?  I'm attempting to create the following:


public class HediffComp_ReduceHediff : HediffComp
{
protected const int SeverityUpdateInterval = 200;

private HediffCompProperties_ReduceHediff Props {
get {
return (HediffCompProperties_ReduceHediff)this.props;
}
}

public override void CompPostTick() {
base.CompPostTick();
if (base.Pawn.IsHashIntervalTick(200)) {
float num = ReduceSeverityPerDay();
num *= (200f/60000f); //ticks per day
foreach(Hediff hediff in Pawn.health.hediffSet.hediffs) {
if(hediff.def == this.Props.hediffToReduce) {
hediff.Severity -= num;
}
}
}
}

protected virtual float ReduceSeverityPerDay() {
return this.Props.reduceSeverityPerDay;
}
}

public class HediffCompProperties_ReduceHediff : HediffCompProperties
{
public HediffDef hediffToReduce;
public float reduceSeverityPerDay = 1f;

public HediffCompProperties_ReduceHediff() {
this.compClass = typeof(HediffComp_ReduceHediff);
}
}


In other words, it's a slightly hacked variation of the conventional HediffComp_SeverityPerDay which decreases the severity of a different Hediff.  (I chose a reduction mainly because that would be the more likely use, but I'm considering renaming to ModifyHediff and requiring a negative severityPerDay to heal for consistency with SeverityPerDay.  But that's neither here nor there.)

The goal is to allow hediffs to reduce other hediffs gradually over time, allowing for mutually antagonistic hediffs which fight each other and cancel each other out and/or to allow pharmaceuticals which heal other hediffs slowly.

However, Rimworld seems completely unable to parse the definition; on load, errors are thrown that the XmlToObject reflection isn't capable of locating the class.  Naturally, of course, the properties fail to populate as well.

Could not find type named HediffCompProperties_ReduceHediff from node <li Class="HediffCompProperties_ReduceHediff"><hediffToReduce>WoundInfection</hediffToReduce><reduceSeverityPerDay>-0.25</reduceSeverityPerDay></li>
Verse.Log:Error(String)
Verse.XmlToObject:ClassTypeOf(XmlNode)
Verse.XmlToObject:ObjectFromXml(XmlNode, Boolean)
Verse.XmlToObject:ListFromXml(XmlNode)
System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&)
System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MethodBase:Invoke(Object, Object[])
Verse.XmlToObject:ObjectFromXml(XmlNode, Boolean)
System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&)
System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MethodBase:Invoke(Object, Object[])
Verse.XmlToObject:ObjectFromXml(XmlNode, Boolean)
System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&)
System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MethodBase:Invoke(Object, Object[])
Verse.<AllDefsFromAsset>c__Iterator1EE:MoveNext()
Verse.ModContentPack:LoadDefs()
Verse.ModContentPack:ReloadAllContent()
Verse.LoadedModManager:LoadAllActiveMods()
Verse.PlayDataLoader:DoPlayLoad()
Verse.PlayDataLoader:LoadAllPlayData(Boolean)
Verse.Root:<Start>m__735()
Verse.LongEventHandler:RunEventFromAnotherThread(Action)
Verse.LongEventHandler:<UpdateCurrentAsynchronousEvent>m__733()


Building the assembly is of course successful, so is there something obvious I'm missing here?  Is there any special step I'm missing for permitting this class to parse properly?  I note, for instance, that there are zero problems with the newly added dismemberment/unanaesthetised amputation class in my field surgery mod, and I can't see any functional difference between a new hard-code recipe and a new hard-code healthdiff component...


[edit] I just thought of something fairly obvious... namespaces.  I'm gonna play around with it a bit. =P

[edit2] Yup, figures.  I have learned nothing.  Sigh...  Well, all fixed now, at least!
#4
Help / ThingCategory as resource for building?
April 18, 2017, 06:23:59 PM
I'm currently working on a side mod where it is possible to use stone chunks to construct buildings, but trying the resource cost: <stuffCategories>
<li>StoneChunks</li>
</stuffCategories>
<costStuffCount>1</costStuffCount>

will actually break the game badly.  Don't even try it, it will wipe your mods list because it will crash Unity's XML parser (Unity's a fickle hivemind, which is why Rick likes it so much, but it's technically RimWorld's fault: it makes no safety check before trying to invoke the constructor, as it tries to reflect a class that doesn't exist -- bad things ensue).

However, I'm not aware of any similar construct that would allow me to use the matching ThingCategory -- i.e., to use the StoneChunks thingcategory like recipes have access to.  Recipes, of course, can take advantage of the nifty little selector and specific slots filtered by ThingCategory, but buildings don't seem to have this option available.

Has anyone played around with building resources beyond the mere costList (which requires specific thingDefs) and stuffCost?  Is it possible to "stuff" buildings out of ThingCategories rather than StuffCategories?

Worst case scenario, I've conceived of a possible scripted solution -- a "free" building like a conventional crafting spot, which uses an automatic job-giver to stock the building with a stone chunk, which once fulfilled replaces the free building with a special building in its place.  But that's a long and version-dependent workaround for something that seems like it should be ultimately simple to keep to XML... =)
#5
This behaviour is a bit frustrating and it'd be nice if it had an alternative implementation, either:

1) If a mod causes Unity/Verse errors, revert to the last functional mod list.

or

2) If a mod causes Unity/Verse errors, save a backup of the user's mod list before overwriting the mod list.

With over 120 mods installed, it is a bit frustrating to have to click another 120+ times on the mod list to re-enable all of the mods when it was only a single mod being activated that caused the issue. =)

(The issue that caused a failure to load is that a bad item in the stuffList of a building will cause a complete and total meltdown of the mod loader.  But that's a princess for another castle.)

Workaround: For users, I've discovered a convenient method for recovering your modlist, if you have at least one saved game with a functional mod list already.  Exit the game, then locate your latest save file (%appdata%\LocalLow\Ludeon Studios\Rimworld\Rimworld by Ludeon Studios\Saves) and open it in any competent plain text editor.  Locate the "modIds" XML node and copy all of the contents (a bunch of <li> tags) to replace the contents of the "activeMods" XML node in your ModConfig.xml (%appdata%\LocalLow\Ludeon Studios\RimWorld by Ludeon Studios\Config\ModConfig.xml).  Restart the game and find your previous functional mod order intact.
#6


Field Surgery

This quick-and-dirty mod allows you to chop infected or otherwise damaged body parts off of injured people without the use of anaesthetic, for use in emergencies when there is absolutely no medicine available; in a medieval society, you no longer have to sit and watch a pawn progress from minor to major to extreme infection without being able to do a single thing about it but palliative care.  Of course, without proper anaesthesia, the procedure is extremely painful and even if you wind up saving their life, they will receive a negative social opinion of the surgeon for causing them pain.  Chance of dying under the knife is of course very high -- an unanaesthetised amputation should only be attempted if you have no other option, or if you intend for the person to suffer.

(That said, this mod was battle-tested: a raider attacked my colony when I had no medicine.  He was downed without being killed.  We took him into custody and treated his wounds without medicine in the dirty cell -- so, of course, his lung got infected.  My excellent surgeon cut it out, and after a rapid recovery we sent him on his way.)

This feature can also be used to remove otherwise healthy body parts from prisoners and visitors.  Although removed limbs will be fresh, they are not salvageable for resale as they are merely hacked off rather than carefully preserved for transplant.  Removal of benign body parts amounts to torture, and your colony will receive negative thoughts accordingly -- all colonists will be accessories (without concern if psychopathic), the torturer will be culpable (with positive thoughts for psychopaths), and the tortured will be furious (except masochists who are also prosthophiles).  Doing this act will of course severely damage relations with the faction of the victim.

By intention, the part is always removed.  If you fail the procedure, the victim will bleed profusely and it will be treated as "cut off" rather than "removed", although the difference is only cosmetic -- the limb is gone one way or another.

Compatibility
* 100% compatible with Expanded Prosthetics and Organ Engineering, Rah's Bionics and Surgery Expansion, and/or DE Surgeries (original thread).

Known Issues

       
  • If a pawn is already anaesthetised before you began the procedure, the anaesthesia will be removed after this procedure.  This means that you can lop a pinky finger off of a prisoner to wake them up from anaesthesia (although even minor body parts still incur the full mood penalty for torture, so this exploit is somewhat self balancing).
  • As I reuse the silly vanilla failure functions, it is possible to wind up cutting out someone's eye and accidentally stabbing them in the chest while chopping off their infected big toe if you wind up failing the task.  Bug Tynan for a fix -- I just work here! =)
  • After mutilating a prisoner in this manner, as long as they leave the map without any bleeding wounds, you will still receive the positive +15 to relations.  This would require a core detour and is probably an overkill solution to the problem.
  • It is possible to chop off prostheses with this system.  It's actually somewhat hard to detect prosthetic hediffs, so I didn't bother.  It's a potential future improvement.
Source code is included for future maintainability.  Licence is Simplified BSD. =)

Changelog:

19 April 2017 - A16 Version 3:
* Updated to Alpha 16, finally.
* Since Tynan and crew threw me a bone and converted a utility class from protected to public, I no longer have to use a ridiculous IL reflection in the code, so this is now also safer and more robust.
* Changed: For colonists, "elective" dismemberment will no longer appear in the list of operations -- only injured parts can be dismembered.
* Prisoners can however still be Reservoir Dogs'ed, with all normal penalties intact.

14 August 2016 - A14 Version 2b:
* Hotfix: Whoops, stuck my version identifier in About.xml after the closing tag of the description, which caused debug errors on load. (The mod still worked fine, though.)  Which, naturally, I changed after I finished testing and before uploading... sigh.
* No other changes. =P

14 August 2016 - A14 Version 2:
* Finally came up with a solution for masochism I liked -- positive thoughts from limb(s) removed occur only if both masochist and prosthophile
* Fixed missing abstracts (for CCL compatibility notice) (as of Alpha 16 2017 without CCL, this is no longer a significant issue)

12 August 2016 - A14 Version 1:
* First release

Dropbox Download:
A16 | D O W N L O A D (v3 - A16 - 2017-APR-19)
A14 Download (v2b - A14E - 2016-AUG-14)




Sleeping Pallet

This adds a simple and cheap sleeping pallet, a step up from sleeping on the bare ground and a step down from sleeping in a nice, cozy bed.

This mod is entirely standalone (which is how I use it), but is intended to fill the gap caused by mods which add a cloth requirement to beds (which require processing on a textile bench and/or a whole growing season to produce).

Licence: Simplified BSD.  Feel free to adapt, claim, use, abuse, or embed in a modpack.

Changelog:
19 April 2017 - A16 Version 3:
* Updated for Alpha 16.
* Now using a vanilla-friendlier graphic with better contrast and an outline.

17 August 2016 - A14 Version 2:
* Adjusted comfort level to 55%, down from 60%, for less comfort on finely-made pallets (and more discomfort on shoddy ones)
* Fixed unnecessary shader in graphicData causing white pallets

15 August 2016 - A14 Version 1b:
* First release (hotfixed immediately after upload)

Dropbox Download:
A16 | D O W N L O A D (v3 - A16 - 2017-APR-19)
A14 Download (v2 - A14E - 2016-AUG-17)



Butchery Spot
(Mod Deprecated)

Unless requested, I won't be updating this anymore as a functionally identical spot is now available in Nandonalt's Camping Stuff.

This is a spot where you can butcher animal corpses without the need to build a butchering table.  It's small, compact, and free to build.  Because it provides no chopping surface for close knife work, you cannot use this spot to make kibble and any mod-added recipes (e.g., EPOE organ grinding) will not apply to it.

Licence: Simplified BSD.  Feel free to adapt, claim, use, abuse, or embed in a modpack.

Changelog:
16 August 2016 - A14 Version 2:
* Fixed missing workgiver

14 August 2016 - A14 Version 1:
* First (buggy) release

Dropbox Download:
A14 Download (v2 - A14E - 2016-AUG-16)
#7
Help / Can't find a type/class name from recipe
August 08, 2016, 05:30:47 PM
So I'm puzzling over this one.  Here's the relevant portion of the assembly's source:

using System;
using System.Reflection;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Text;

using UnityEngine;
using RimWorld;
using Verse;

namespace JTFieldSurgery
{
class Recipe_JTFieldSurgeryFieldAmputate : Recipe_MedicalOperation
{
...


which compiles successfully and is placed in my mod's Assemblies subfolder.

Here's my RecipeDef:<RecipeDef ParentName="SurgeryFlesh">
<defName>JTFieldSurgeryFieldAmputate</defName>
<label>field amputation</label>
<description>Removes a natural body part without the use of anaesthetic, for use in emergencies if no medicine is available. Removed limb will not be usable.</description>
<jobString>Amputating without anaesthetic.</jobString>

<workerClass>Recipe_JTFieldSurgeryFieldAmputate</workerClass>
...


Yet for reasons I completely fail to understand, I receive a "Could not find a type named Recipe_JTFieldSurgeryFieldAmputate" error during boot.  Is there somewhere I have to "register" an assembly for it to be loaded by the game?  What could be going wrong here?