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 - Napoleonite

#1
    The DesignatorDropdownGroupDef shows some (the first one I believe) ingredient item in the dropdown menu instead of the icon of the building/tile/etc. itself. This wasn't always the case and this is not mentioned in any patch notes that I could find. There's no XML option to change this and using an "uiIcon" in the XML doesn't work either.

    This also happens w/o any mods. When you try to place carpets. It just shows cloth-icons for every carpet instead of the different colors of carpets as it used to be in 1.0 and before.

Steps we can follow to make the bug appear on our machine
1. Start any new game with Core + Royalty.
2. Enable godmode.
3. Open the 'carpet menu' for placing carpets and click on the button.
4. You should now see a list of ingredients instead of carpets.


For more info please also see: https://ludeon.com/forums/index.php?topic=50699.0[/list]
#2
Help / Detecting DLC in XML-only mod?
April 08, 2020, 03:52:28 AM
I have this in my XML:
<ThingDef ParentName="ApparelArmorHelmetCataphractBase">
...
</ThingDef>

It uses a parent XML-node from the Royalty DLC. However, players w/o the DLC installed get an error: XML error: Could not find parent node named "ApparelArmorHelmetCataphractBase" for node "ThingDef".

Is there an option somehow to add a conditional or do I have to put everything that uses Royalty code inside HUGE xpatches like this:
<Operation Class="PatchOperationFindMod">
<mods>
<li>Royalty</li>
</mods>
<match Class="PatchOperationAdd">
<xpath>check forsome Royalty node here?</xpath>
<value>
Okay so DLC is installed. Dump DLC-related items all here? That would be so messy!
</value>
</match>
</Operation>


There's probably some simple XML element or attribute that I'm missing to only execute it if the DLC is installed?
#3
How do I retrieve the Config folder path (the one with the mod settings)? Every time a mod gets a serious update the settings can cause problems. I need a way to delete/clear this file and be able to display its contents.

On Windows it's this:
C:\Users\<username>\AppData\LocalLow\Ludeon Studios\RimWorld by Ludeon Studios\Config
but on Mac and Linux it's different. Is there a c# command to retrieve the path or if not, what are all possible paths?
#4
Help / Where to find good artists?
March 05, 2020, 12:11:50 PM
Probably been asked before but where do I find (paid/unpaid) artists for making graphics for Rimworld? My experiences with most freelancers are not that good. The quality doesn't have to be amazing but at least it should be useable. Many 'idiots' from India with great previews and when they deliver you get a piece of garbage... They claim to have 'game experience' but have no idea what the difference is between a tank and a turret...

Also, are there some free art packs we can use/edit (not the original ones from Rimworld)?
#5
Help / DesignatorDropdownGroupDef in 1.1?
March 02, 2020, 12:15:06 PM
<DesignatorDropdownGroupDef>
    <defName>SurveillanceCameras</defName>
</DesignatorDropdownGroupDef>

<!-- in my ThingDef -->
<designatorDropdown>SurveillanceCameras</designatorDropdown>
<uiIconPath>snip</uiIconPath>

Becomes:



In 1.1 the icons worked but in 1.1 they broke. I checked the autogenerated XML documentation but no example was given that is different from mine and this is also not mentioned in the 1.1 upgrade guide for modders. What should I do differently in 1.1?
#6
How do I load&save my
public Dictionary<ThingDef, DrillData> Drillables = new Dictionary<ThingDef, DrillData>();

Note that DrillData inherits IExposable and implements it. The main problem that I have is that DrillData requires the XML-database to be fully loaded before this setting can be loaded. How would I go about this?

Some extra code if it helps (which totally doesn't work at all):

// In my ModSettings:
public Dictionary<ThingDef, DrillData> Drillables = new Dictionary<ThingDef, DrillData>();
        public override void ExposeData()
        {
List<ThingDef> drillableItems = Drillables.Keys.ToList();
            Scribe_Collections.Look<ThingDef>(ref drillableItems, "SEPD_Drillables");
            //Log.Message(keys.Count.ToString());
            drillableItems.ToList()
                .ForEach(td =>
                {
                    if (td != null)
                    {
                        //Log.Message(td.defName);
                        if (!this.Drillables.ContainsKey(td))
                        {
                            this.Drillables.Add(td, new DrillData(td));
                        }
                    }
                    else
                    {
                        Log.Warning("SEPD_OreMissingWarning".Translate().CapitalizeFirst());
                    }
                });
            this.Drillables.Values.ToList().ForEach(d => d.ExposeData());
}


DrillData:
        public void ExposeData()
        {
            Scribe_Defs.Look(ref ThingDefToDrill, Constants.SETTINGS_PREFIX + ThingDefToDrill.defName + "_DefName");
            Scribe_Values.Look(ref WorkAmount, Constants.SETTINGS_PREFIX + ThingDefToDrill.defName + "_WorkAmount", WorkAmount, true);
        }


Hopefully, I'm not too vague or something :P. My English is not that great at this area.
#7
Help / [Solved] C# add recipe (or 'c#-patch' it)?
February 29, 2020, 01:55:43 PM

            //<snip>

            RecipeDef rd = new RecipeDef
            {
                defName = defName,
                effectWorking = DefDatabase<EffecterDef>.GetNamed("Smith"),
                workSkill = DefDatabase<SkillDef>.GetNamed("Mining"),
                workSpeedStat = DefDatabase<StatDef>.GetNamed("MiningSpeed"),
                workSkillLearnFactor = 0.5f,
                jobString = "Drilling" + " " + forthisThingDef.label,
                workAmount = 5000,
                soundWorking = DefDatabase<SoundDef>.GetNamed("Recipe_Machining"),
                label = "Drill" + " " + forthisThingDef.label,
                description = "Drill" + " " + forthisThingDef.label
            };

            rd.products.Add(new ThingDefCountClass(forthisThingDef, 20));
            DefDatabase<RecipeDef>.Add(rd);


Produces the following error when adding it as a bill (everything else seems to work so far):
QuoteException filling window for Verse.FloatMenu: System.NullReferenceException: Object reference not set to an instance of an object
  at Verse.ThingFilter.CopyAllowancesFrom (Verse.ThingFilter other) [0x0001f] in <33b99ab6cf5748ec8fe371b3321b9db6>:0
  at RimWorld.Bill..ctor (Verse.RecipeDef recipe) [0x00043] in <33b99ab6cf5748ec8fe371b3321b9db6>:0
  at RimWorld.Bill_Production..ctor (Verse.RecipeDef recipe) [0x00042] in <33b99ab6cf5748ec8fe371b3321b9db6>:0
  at RimWorld.BillUtility.MakeNewBill (Verse.RecipeDef recipe) [0x0000f] in <33b99ab6cf5748ec8fe371b3321b9db6>:0
  at RimWorld.ITab_Bills+<>c__DisplayClass10_0.<FillTab>b__1 () [0x0004b] in <33b99ab6cf5748ec8fe371b3321b9db6>:0
  at Verse.FloatMenuOption.Chosen (System.Boolean colonistOrdering, Verse.FloatMenu floatMenu) [0x00028] in <33b99ab6cf5748ec8fe371b3321b9db6>:0
  at Verse.FloatMenuOption.DoGUI (UnityEngine.Rect rect, System.Boolean colonistOrdering, Verse.FloatMenu floatMenu) [0x0030e] in <33b99ab6cf5748ec8fe371b3321b9db6>:0
  at Verse.FloatMenu.DoWindowContents (UnityEngine.Rect rect) [0x000fb] in <33b99ab6cf5748ec8fe371b3321b9db6>:0
  at Verse.Window.InnerWindowOnGUI (System.Int32 x) [0x00165] in <33b99ab6cf5748ec8fe371b3321b9db6>:0
Verse.Log:Error(String, Boolean)
Verse.Window:InnerWindowOnGUI(Int32)
UnityEngine.GUI:CallWindowDelegate(WindowFunction, Int32, Int32, GUISkin, Int32, Single, Single, GUIStyle)

Also, does someone have a link to a tutorial or a good example of how to have C# do this through XML perhaps? Can't I just apply an XML patch instead through C#? I think that would be easier. I'd still like to know how to do both though.

Also, is there an option to inspect the XML database in the game to verify that everything went okay?
#8
Help / [Solved] Simple XPath Replace failing
February 28, 2020, 09:39:56 AM
The XPath surgery topic seems to be death so I'll post here.

Original XML:
<ThingDef Abstract="True" Name="RPP_RechargeStation" ParentName="Base_X2_AIRobotRechargeStation" Class="AIRobot.X2_ThingDef_AIRobot_Building_RechargeStation">
<minifiedDef>AIRobot_MinifiedRechargeStation</minifiedDef>
<thingCategories>
<li>BuildingsFurniture</li>
</thingCategories>
<fillPercent>0.25</fillPercent>
<costList>
<Steel>20</Steel>
<Plasteel>5</Plasteel>
<RPP_Component>1</RPP_Component>
</costList>
<statBases>
<Mass>13</Mass>
</statBases>
<!-- added abstraction for potential future use -->
</ThingDef>>

<ThingDef Abstract="True" Name="RPP_RechargeStation_II" ParentName="RPP_RechargeStation" Class="AIRobot.X2_ThingDef_AIRobot_Building_RechargeStation">
<statBases>
<MaxHitPoints>50</MaxHitPoints>
<Beauty>1</Beauty>
<MarketValue>1236</MarketValue>
<Flammability>0.8</Flammability>
</statBases>
<rechargeEfficiency>1.2</rechargeEfficiency>
</ThingDef>


XPath:
<?xml version="1.0" encoding="utf-8" ?>
<Patch>

<Operation Class="PatchOperationReplace">
<xpath>Defs/ThingDef[@Name="RPP_RechargeStation_II"]/statBases/MaxHitPoints</xpath>
<value>
<MaxHitPoints>75</MaxHitPoints> <!-- default is 50 -->
</value>
</Operation>

</Patch>


Error:
QuotePatch operation Verse.PatchOperationReplace(Defs/ThingDef[@Name="RPP_RechargeStation_II"]/statBases/MaxHitPoints) failed.
Verse.Log:Error(String, Boolean)
Verse.PatchOperation:Complete(String)
Verse.LoadedModManager:ClearCachedPatches()
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()
#9
Help / [Solved] About.xml Mod incompatibility elements?
February 28, 2020, 08:14:30 AM
QuoteMods can now define other mods that they are incompatible with. The interface will warn players about incompatibilities.
How?
#10
Do all turret-top textures now have to point east instead of north? Or did I do something wrong? I couldn't find this in the patch notes but I probably missed it.

Also, my Vector2, Rect, etc. throw errors in 1.1:
QuoteThe type 'Rect' is defined in an assembly that is not referenced. You must add a reference to assembly 'UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
Does this mean we must reference CoreModule instead of the previous one now?

Mmm should we use a different .Net version now?
QuoteWarning      The primary reference "Assembly-CSharp" could not be resolved because it has an indirect dependency on the .NET Framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.

The DesignatorDropdownGroupDef doesn't work anymore (it shows steel icons).

Etc.

Also wondering if there is an 1.0 --> 1.1 upgrade guide somewhere already?

UPDATE:
Nevermind, the 1.1 update contains an update guide.
#11
This is how I currently change the cost list of one of my buildings through C#:
DefDatabase<ThingDef>.GetNamed("SE_FusionReactor").costList.First(c => c.thingDef == ThingDefOf.Steel).count = 5;
Is this the proper way to do it? It looks kinda complicated. Isn't there an easier way?

Second question:
Rimworld doesn't like it when we remove Research Projects (but this code works, kinda... It removes the Research Project but throws errors):
var allDefs = DefDatabase<ResearchProjectDef>.AllDefs.ToList();
var planetaryDrillingDef = DefDatabase<ResearchProjectDef>.GetNamed("PlanetaryDrilling"); // PlanetaryDrilling = name of research project to remove.
DefDatabase<ResearchProjectDef>.Clear();
allDefs.Where(d => d != planetaryDrillingDef).ToList().ForEach(d => DefDatabase<ResearchProjectDef>.Add(d));

I'd like to use this code to create settings that can remove buildings/research from my mod. But, we aren't supposed to do this?
#12
Help / [Solved] Howto: mod settings for XML mod?
February 14, 2020, 10:07:47 AM
I have a mod that is 100% XML. I just want to add some mod settings so users can change some XML values like the cost of an item for example or the research amount required. I checked https://rimworldwiki.com/wiki/Modding_Tutorials/ModSettings#DoSettingsWindowContent and it shows how to load&save variable from&to disk, but how do I actually make it change the XML values for the game so that it actually does something?
So how do I use the variables from the mod settings to change the 'XML values'?
#13
I have a

<workSpeedStat>MiningSpeed</workSpeedStat>

but at skill-level 20 the colonists mine WAY too fast so I would like to add something that dampens that a bit like this:

<miningSkillSpeedFactor>0.25</miningSkillSpeedFactor>

Does something like that exist and if so, what is that XML-node called? Otherwise I would be forced to remove the entire workSpeedStat :(
#14
I placed the soundfile here:
D:\Steam\steamapps\common\RimWorld\Mods\MoreTurrets\Sounds\FireSniperMKII.wav

I then added a new SoundDef:
<?xml version="1.0" encoding="utf-8"?>

<Defs>

  <SoundDef>
    <defName>Shot_TurretSniperMKII</defName>
    <context>MapOnly</context>
    <eventNames />
    <maxSimultaneous>1</maxSimultaneous>
    <subSounds>
      <li>
        <grains>
          <li Class="AudioGrain_Folder">
            <clipFolderPath>Sounds/FireSniperMKII</clipFolderPath> <!-- This also fails: <clipFolderPath>FireSniperMKII</clipFolderPath> -->
          </li>
        </grains>
        <volumeRange>
          <min>77</min>
          <max>77</max>
        </volumeRange>
        <pitchRange>
          <min>0.7</min>
          <max>0.8</max>
        </pitchRange>
        <sustainLoop>False</sustainLoop>
      </li>
    </subSounds>
  </SoundDef>
 
</Defs>


and used it here in my gun xml:
  <ThingDef ParentName="BaseHumanGun">
    <defName>Gun_TurretSniperMKII</defName>
    <label>hi-tech uranium slug cannon</label>
...
    <verbs>
      <li>
        <verbClass>Verb_Shoot</verbClass>
        <hasStandardCommand>true</hasStandardCommand>
        <defaultProjectile>Bullet_TurretSniperMKII</defaultProjectile>
        <warmupTime>0</warmupTime>
        <minRange>11.9</minRange>
        <range>49.9</range>
        <burstShotCount>1</burstShotCount>
        <!--<soundCast>Shot_TurretSniper</soundCast>-->
<soundCast>Shot_TurretSniperMKII</soundCast>
        <soundCastTail>GunTail_Heavy</soundCastTail>
        <muzzleFlashScale>18</muzzleFlashScale>
        <consumeFuelPerShot>1</consumeFuelPerShot>
      </li>
    </verbs>
  </ThingDef>


gives me this error:
QuoteCould not resolve cross-reference: No Verse.SoundDef named Shot_TurretSniperMKII found to give to Verse.VerbProperties VerbProperties(hi-tech uranium slug cannon) (using undefined sound instead)

What is the difference between clipPath and clipFolderPath btw?
#15
Help / [Solved] C# change max hitpoints and cost?
April 22, 2019, 08:54:33 AM
How do I set the MAX hitpoints of a building through C#? I have a mod-setting (HugsLib) with the max-hp value but I do not know how to assign it because I couldn't find the maxHP property anywhere... Where is it?

Also how would I change the building cost through C#? I know how to access it but not how/where to change it.


    public class Indoor_Turret : Building_TurretGun
    {
        public ThingDef_IndoorTurret Def { get { return this.def as ThingDef_IndoorTurret; } }
     
        public Indoor_Turret()
        {
            //base.MaxHitPoints = ... Damn it is a getter...
            HitPoints = ThingDef_IndoorTurret.MaxHitPoints; // Only sets the current HP, not the max hp...
            Log.Message(HitPoints.ToString());
            // def.costList[0].count = 999; // Does not work. Maybe it needs to be set from the ThingDef_IndoorTurret class somewhere?
        }
    }
#16
Help / Simple XML Sandbags graphics problem
April 16, 2019, 05:10:30 PM
Hello,

Problem:

Somehow mine is all 'squared-like'?

Code:
https://pastebin.com/hqk6CTb7

My image:



What am I doing wrong?