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

Messages - SickBoyWi

#1
I finally fixed this issue, and I'm posting the issue here for any one else that encounters it.

RawCode is on the right track here.

I was doing this:

List<Thing> thrones = maps[index].listerThings.ThingsOfDef(RH_TET_DwarfDefOf.RH_TET_Dwarfs_Throne);
thrones.AddRange(maps[index].listerThings.ThingsOfDef(RH_TET_DwarfDefOf.RH_TET_Dwarfs_KingsThrone));


The correct thing to do is this:
               
List<Thing> thrones = new List<Thing>();
thrones.AddRange(maps[index].listerThings.ThingsOfDef(RH_TET_DwarfDefOf.RH_TET_Dwarfs_Throne));
thrones.AddRange(maps[index].listerThings.ThingsOfDef(RH_TET_DwarfDefOf.RH_TET_Dwarfs_KingsThrone));


If that first call to the listerThings.ThingsOfdef finds nothing, it returns null. That causes all kinds of chaos, and the next call doesn't throw a NPE, it throws the weird error I mentioned above. This was very tough to track, and find. Almost impossible I'd say, as the actual error gets squashed.

I encountered this same error while working on a different mod, and was actually able to pin it down. With that info, I fixed my original error from way back when.

Hopefully this can be of help to someone at some point!
#2
I think I'm going to use a QuestScriptDef that stays alive for a while. It seems fitting, since it is effectively a global quest for the mod in question.

The issue with the map and world components are that the player may not have a base at given time due to the nomadic nature of the pawns in the mod, and there won't be a specific world object associated with things.

I'm trying to make the player have to destroy so many bases of a specific other faction. So I need to keep a count of how many they've destroyed to date, keep that data in between game loads. The Quest stuff should work great here.

Thanks for the answer.
#3
I'm trying to add a new value to the FactionDef, specific to the player faction. It's a single integer value. I've explored several options, but thus far have not see a good solution.

Looks like DefModExtension cannot be loaded from a save file, so using that seems out.

Is there a way to do this? Effectively I'm tracking a value in my mod, and need to be able to restore it in between save/shut down/reloads. The value is specific the player faction, but I'm tracking it in a static mod class.

Any thoughts or ideas are welcome and appreciated!
#4
I took your advice RawCode, and am still rather lost on this issue.

I added code to output what's happening in the methods that die.

In CurrentSkyTarget, the call to
         List<Thing> list = this.map.listerThings.ThingsInGroup(ThingRequestGroup.AffectsSky);

Returns the building in question.

Same goes for the line in in WindManagerTick():
      List<Thing> thingList = this.map.listerThings.ThingsInGroup(ThingRequestGroup.WindSource);

That call returns the building in question too.

Lastly, in Alert_ThroneroomInvalidConfiguration's GetReport method, the call to
      maps[index].listerThings.ThingsInGroup(ThingRequestGroup.Throne)

returns the building too.

The first two are pretty straight forward, those calls should return a thing only if it has the specific appropriate comp.

When I put code in to ThingDef's HasComp function, which is what those other calls use to determine whether a thing has a comp, none of those comps exist. The HasComp function is super simple, and I loop through and print out all the comps on the thing, there's only one (and it isn't one of the ones in question).

I tried to go a step further, and put some code into ListerThings's ThingsMatching function, to see which code path was being taken, and it's taking the path that is doing the checks I mentioned before.

I'm at a total loss here still.
#5
I'm still searching for a fix for this. Been over and over the code. Any ideas at all to set me in a direction would be helpful.
#6
Help / Re: looking for 1.1 Tutorials/Help
June 28, 2020, 09:24:10 PM
I'd recommend finding a mod that does something simple, subscribing/downloading it, and digging through the Defs folder to see how what it's setting up.

The folder structure of a mod is specific.
If it has an Assemblies folder, then it has source code associated. Those types of mods are going to be harder for you to figure out if you have no programming experience.
The Defs folder defines all the configuration that the game uses for items, pawns, and everything else.
The Textures folder has the images.
The Patches folder has xpath patches. These, again, will be more complicated if you aren't familiar with how markup language looks and works.
The About folder just has a file that tells Steam about the mod, and perhaps a preview image

Find some simple mods that only have Def folders, dig around, open the files, and look at what they're doing. See if you can figure it out there. Once you feel like you have some mastery of that, dig into a mod's Patches folder, and download DotPeek to decompile the file in a mod's assembly folder. Then you'll need Visual Studio Community edition to open the source code solution and dig around in there.

If you're starting with no knowledge, there's a ton to figure out. Start slow, and spend the time it takes to learn it.

#7
The issue seems to happen on a delayed tick. Since when I build the throne, it takes an hour or so (in game time) for the error to occur. That comp doesn't have any code that should run, since it's all based on the player trying to assign a pawn to it. Unless maybe CompInspectStringExtra gets called. In the time before the error happens I can click on the throne, and there's no issues, so CompInspectStringExtra should be fine.

Unless those functions mentioned in the error run on a delayed/game-hourly tick. Then I guess it makes sense that they could be accessing something that is causing it. This issue shouldn't be such a gotcha, since it's related to the one throne only. The two throne defs are identical, other than the names, descriptions, stuff to make them, and beauty.
#8
Sure thing.

Let me reiterate, the issue is for the King's Throne only, so that should narrow down the parts to look at dramatically. I'll look over it too, and see if I can see anything that might be causing it.

One note, is that if a Thane's Throne is already built, then building the King's Throne works just fine (the issues don't occur).

Code is attached.
#9
Sure thing.

Here's the config for it:
  <ThingDef ParentName="FurnitureWithQualityBase">
    <defName>RH_TET_Dwarfs_KingsThrone</defName>
    <label>king's throne</label>
    <drawGUIOverlay>true</drawGUIOverlay>
    <drawGUIOverlayQuality>false</drawGUIOverlayQuality>
    <description>A large, extremely ornate chair on a raised dais, designed for a dwarven king to rest upon.\n\nAssigning a dwarf to a dwarven throne will make the dwarf a high blood. High blood dwarfs have their own special needs, and requirements.\n\nOnce a dwarf is made a high blood, it cannot be undone unless they die. Their death will greatly upset the clans.\n\nA king's throne is the ultimate in dwarven furniture craftsmanship. They're extremely beautiful, and only enhance the respect given to the person that sits upon them; from both dawi and non-dawi alike.</description>
    <defaultPlacingRot>South</defaultPlacingRot>
    <altitudeLayer>BuildingOnTop</altitudeLayer>
    <leaveResourcesWhenKilled>true</leaveResourcesWhenKilled>
    <tickerType>Normal</tickerType>
    <category>Building</category>
    <!--<thingSetMakerTags><li>RewardStandardQualitySuper</li></thingSetMakerTags>-->
    <hasInteractionCell>true</hasInteractionCell>
    <interactionCellOffset>(0,0,1)</interactionCellOffset>
    <statBases>
      <MaxHitPoints>250</MaxHitPoints>
      <WorkToBuild>15000</WorkToBuild>
      <Mass>40</Mass>
      <Flammability>0</Flammability>
      <Beauty>25</Beauty>
      <Comfort>1.5</Comfort>
    </statBases>
    <thingClass>TheEndTimes_Dwarfs.Building_DwarfThrone</thingClass>
    <socialPropernessMatters>true</socialPropernessMatters>
    <constructionSkillPrerequisite>12</constructionSkillPrerequisite>
    <stuffCategories>
      <li>Stony</li>
    </stuffCategories>
    <costStuffCount>200</costStuffCount>
    <costList>
      <RH_TET_Dwarf_Gromril>25</RH_TET_Dwarf_Gromril>
      <Gold>50</Gold>
      <Silver>100</Silver>
    </costList>
    <pathCost>30</pathCost>
    <rotatable>true</rotatable>
    <fillPercent>0.6</fillPercent>
    <building>
      <isSittable>true</isSittable>
    </building>
<size>(3,2)</size>
    <uiIconOffset>(0, 0)</uiIconOffset>
    <uiIconScale>0.8</uiIconScale>
    <comps>
      <li Class="CompProperties_AssignableToPawn">
        <drawAssignmentOverlay>true</drawAssignmentOverlay>
        <compClass>TheEndTimes_Dwarfs.CompAssignableToPawn_Throne</compClass>
      </li>
    </comps>
    <researchPrerequisites>
      <li>RH_TET_Dwarfs_HighBlood_King</li>
    </researchPrerequisites>
    <graphicData>
      <drawSize>(3.0,3.0)</drawSize>
      <texPath>Things/Building/Furniture/RH_TET_Dwarfs_ThroneKing</texPath>
      <graphicClass>Graphic_Multi</graphicClass>
      <shadowData>
        <volume>(0.5,0.35,0.4)</volume>
      </shadowData>
      <damageData>
        <rect>(0.2,0,2, 0.6, 0.6)</rect>
      </damageData>
  <shaderType>CutoutComplex</shaderType>
    </graphicData>
    <designationCategory>RH_TET_Dwarfs_Buildings</designationCategory>
  </ThingDef>


The code is attached. The code is shared by a thane's throne and a king's throne. The thane's throne works fine, no issues. The king's throne causes the aforementioned errors.
#10
I'm working on a mod. When I build one of my buildings, this happens:

https://gist.github.com/HugsLibRecordKeeper/85a443e1a09cf7370ef105a985d42b9a

Here's the summary:
Root level exception in Update(): System.NullReferenceException: Object reference not set to an instance of an object
  at Verse.SkyManager.CurrentSkyTarget () [0x00164] in <4489f1367c1c4d76b2ae1272c8ed691d>:0
  at Verse.SkyManager.SkyManagerUpdate () [0x00000] in <4489f1367c1c4d76b2ae1272c8ed691d>:0
  at Verse.Map.MapUpdate () [0x00005] in <4489f1367c1c4d76b2ae1272c8ed691d>:0
  at Verse.Game.UpdatePlay () [0x00031] in <4489f1367c1c4d76b2ae1272c8ed691d>:0
  at Verse.Root_Play.Update () [0x00026] in <4489f1367c1c4d76b2ae1272c8ed691d>:0
Verse.Log:Error(String, Boolean)
Verse.Root_Play:Update()

Root level exception in Update(): System.NullReferenceException: Object reference not set to an instance of an object
  at Verse.WindManager.WindManagerTick () [0x000b0] in <4489f1367c1c4d76b2ae1272c8ed691d>:0
  at Verse.Map.MapPreTick () [0x0003b] in <4489f1367c1c4d76b2ae1272c8ed691d>:0
  at Verse.TickManager.DoSingleTick () [0x00011] in <4489f1367c1c4d76b2ae1272c8ed691d>:0
  at Verse.TickManager.TickManagerUpdate () [0x0006a] in <4489f1367c1c4d76b2ae1272c8ed691d>:0
  at Verse.Game.UpdatePlay () [0x00000] in <4489f1367c1c4d76b2ae1272c8ed691d>:0
  at Verse.Root_Play.Update () [0x00026] in <4489f1367c1c4d76b2ae1272c8ed691d>:0
Verse.Log:Error(String, Boolean)
Verse.Root_Play:Update()


It fogs the map, and requires a reboot of the entire game. I have a second building just like the one that causes this issue, that works fine. I've compared the config line by line, and all looks to be the same.

Is this an issue with a typical cause? Any input is very much appreciated.
#11
Help / Re: Limit Quests to Specific Faction
March 10, 2020, 03:07:26 PM
I figured it out with some help from the RW Discord folks. Ended up adding a prefix for the QuestUtility_GenerateQuestAndMakeAvailable method.
#12
Help / Limit Quests to Specific Faction
March 10, 2020, 11:24:46 AM
Hi! I'm working on a series of mods. Each adds their own factions, and they're intended to all be played together.

With the 1.1 update, I haven't yet seen a simple way to limit a quest to a specific player faction. Some of the quests for each of the mods I'm working on only make sense in the context of that faction.

What I'd like to do is have a check before a quest fires, and make sure the player is using one of the appropriate factions. In 1.0, since world events were incidents, I was able to easily control this via the CanFireNowSub function in the incident class. That isn't an option now for quests.

Does any one have any thoughts on how to accomplish this?
#13
Help / Re: 1.1 Mod Update Harmony Reference Issue (?)
February 25, 2020, 09:47:07 PM
It turns out that I was referencing the wrong version of Harmony, despite what I thought there. I pulled the latest, and things are working fine.
#14
Help / 1.1 Mod Update Harmony Reference Issue (?)
February 25, 2020, 08:52:01 PM
My mod works fine on its own, but when I add in HugsLib, I get a weird error:

Error while instantiating a mod of type TheEndTimes.TheEndTimesMod: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeLoadException: Could not resolve type with token 01000092 (from typeref, class/assembly Harmony.HarmonyInstance, 0Harmony, Version=1.2.0.1, Culture=neutral, PublicKeyToken=null)
  at (wrapper managed-to-native) System.Reflection.MonoCMethod.InternalInvoke(System.Reflection.MonoCMethod,object,object[],System.Exception&)
  at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in <567df3e0919241ba98db88bec4c6696f>:0
   --- End of inner exception stack trace ---
  at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00014] in <567df3e0919241ba98db88bec4c6696f>:0
  at System.Reflection.MonoCMethod.DoInvoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0007a] in <567df3e0919241ba98db88bec4c6696f>:0
  at System.Reflection.MonoCMethod.Invoke (System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0
  at System.RuntimeType.CreateInstanceImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Threading.StackCrawlMark& stackMark) [0x00213] in <567df3e0919241ba98db88bec4c6696f>:0
  at System.Activator.CreateInstance (System.Type type, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x00095] in <567df3e0919241ba98db88bec4c6696f>:0
  at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0
  at Verse.LoadedModManager.CreateModClasses () [0x00076] in <fcd99b24cbb3485baa8263b0d6197784>:0
Verse.Log:Error(String, Boolean)
Verse.LoadedModManager:CreateModClasses()
Verse.LoadedModManager:LoadAllActiveMods()
Verse.PlayDataLoader:DoPlayLoad()
Verse.PlayDataLoader:LoadAllPlayData(Boolean)
Verse.<>c:<Start>b__6_1()
Verse.LongEventHandler:RunEventFromAnotherThread(Action)
Verse.<>c:<UpdateCurrentAsynchronousEvent>b__27_0()
System.Threading.ThreadHelper:ThreadStart_Context(Object)
System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object, Boolean)
System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object)
System.Threading.ThreadHelper:ThreadStart()

Clearly there's a library that isn't up to date somewhere. It appears to be Harmony, but the Harmony runtime version in my project references is v2.0.50727, which should be correct for the 1.1 update. Version of reference is set to 1.2.0.1, which seems like it could be a potential issue; but when I update that to match the 2.0.50727 runtime version, it causes unknown version issues.

Any ideas here? It has to be something simple that I'm missing.
#15
Mods / RimWorld Custom Maps Utility
February 15, 2020, 09:39:13 AM
I've seen stuff around related to creating custom maps for quests,player home locations and the like, and for decoding the parts of save files that are deflated. I couldn't find anything that was doing what I needed. I did see that some other mods were using the MapGeneratorBlueprints.dll to read in XML files and build custom maps (RimQuests for one of the better examples I found).

I created a console utility that will take a RW save game, read it all, and kick it out as an XML file that can be read by the MapGeneratorBlueprints library. I'm using this specifically for my mods, so there's some stuff that is specific to what I'm working on in there, but this example may help others who are trying to do something similar. I wish I had found it back when I started trying to make custom maps, it would have saved me many hours of work.

The source code can be found here: https://github.com/SickBoyWi/RimWorldMaps

If you have questions or whatever, I'd be happy to help. You'll be more likely to get a quick response if you post in the Discord for the Rimhammer - The End Times mod series, but I'll check here once in a while too.

I hope that someone can make use of this to solve issues they're encountering.