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

#1
In AI.JobGiver.WorkRoot.TryGiveTerminalJob(Pawn pawn), there's this piece of code according to ILSpy:

IntVec3 position = pawn.Position;
float num2 = 99999f;
foreach (IntVec3 current2 in giver.PotentialWorkLocs)
{
if ((current2 - position).LengthHorizontalSquared < num2 && giver.StartingJobOn(pawn, current2) != null)
{
targetPack = current2;
workGiver = giver;
}
}


Shouldn't it instead be something like this, so that it will always return the closest work location?

IntVec3 position = pawn.Position;
float num2 = 99999f;
foreach (IntVec3 current2 in giver.PotentialWorkLocs)
{
float num3 = (current2 - position).LengthHorizontalSquared;
if (num3 < num2 && giver.StartingJobOn(pawn, current2) != null)
{
targetPack = current2;
workGiver = giver;
num2 = num3;
}
}


Edit: Also, not relevant to alpha 3 since there are no workgivers that it applies to, but if one workgiver class can have both PotentialWorkThings aswell as PotentialWorkLocs, maybe if it finds a work thing before it starts checking for work locations, num2 should initially be set to "(thing.Position - pawn.Position).LengthHorizontalSquared" instead of 99999f.
#2
I tried to use Find.MainTabsRoot.tabArchitect.selectedPanel.dragger.DragSquares in a custom placement restricter (after checking dragger.dragging ofcourse) and it just crashes to desktop whenever I try to do anything with those squares.

My theory is it doesn't like it when startDragSquare equals Gen.MouseWorldSquare(). Unfortunately, startDragSquare is private so there's no way for me to handle that condition.

Edit: Oh wait, actually I think it crashes to desktop because DragSquares calls CanDesignateAt, which in turn calls my placement restricter, which calls DragSquares again, resulting in a never ending recursion... ok, so I guess this isn't a bug, but it would still be nice to be able to use the dragger in placement restricters. Hmm, maybe I can come up with a solution if I watch Inception again :P.

Edit2: I came up with a solution btw, without even having to sit through Inception again :). There's probably some room for optimization, but this works:


    public class PlacementRestricter_NoWaffle : PlacementRestricter
    {
        private IntVec3 firstDragSquare;
        private IntVec3 lastDragSquare;
        private bool dragging = false;

        public override AcceptanceReport CanPlaceWithRestriction(EntityDef checkingDef, IntVec3 loc, IntRot rot)
        {
            DesignationDragger dragger = Find.MainTabsRoot.tabArchitect.selectedPanel.dragger;

            if (!dragger.dragging)
            {
                if (dragging)
                {
                    dragging = false;
                    firstDragSquare = IntVec3.Invalid;
                    lastDragSquare = IntVec3.Invalid;
                }
            }
            else if (!dragging)
            {
                dragging = true;
                firstDragSquare = loc;
            }
            else if (firstDragSquare == Gen.MouseWorldSquare())
            {
                lastDragSquare = IntVec3.Invalid;
            }

            if (SquareHas(new IntVec3(loc.x - 1, loc.y, loc.z), (ThingDef)checkingDef)
                && SquareHas(new IntVec3(loc.x - 1, loc.y, loc.z + 1), (ThingDef)checkingDef)
                && SquareHas(new IntVec3(loc.x, loc.y, loc.z + 1), (ThingDef)checkingDef))
                return false;

            if (SquareHas(new IntVec3(loc.x, loc.y, loc.z + 1), (ThingDef)checkingDef)
                && SquareHas(new IntVec3(loc.x + 1, loc.y, loc.z + 1), (ThingDef)checkingDef)
                && SquareHas(new IntVec3(loc.x + 1, loc.y, loc.z), (ThingDef)checkingDef))
                return false;

            if (SquareHas(new IntVec3(loc.x + 1, loc.y, loc.z), (ThingDef)checkingDef)
                && SquareHas(new IntVec3(loc.x + 1, loc.y, loc.z - 1), (ThingDef)checkingDef)
                && SquareHas(new IntVec3(loc.x, loc.y, loc.z - 1), (ThingDef)checkingDef))
                return false;

            if (SquareHas(new IntVec3(loc.x, loc.y, loc.z - 1), (ThingDef)checkingDef)
                && SquareHas(new IntVec3(loc.x - 1, loc.y, loc.z - 1), (ThingDef)checkingDef)
                && SquareHas(new IntVec3(loc.x - 1, loc.y, loc.z), (ThingDef)checkingDef))
                return false;

            if (dragging)
                lastDragSquare = loc;

            return true;
        }

        private bool SquareHas(IntVec3 sq, ThingDef def)
        {
            if (!sq.InBounds())
                return false;
            if (Find.Grids.ThingAt(sq, def) != null || Find.Grids.ThingAt(sq, def.blueprintDef) != null)
                return true;
            if (dragging && lastDragSquare == sq)
                return true;
            return false;
        }
    }


Edit3: For anybody wondering what it does, it prevents making sandbag waffles.

Edit4: Just for completion, I've updated it with the same code as I used in Vanilla+ v1.2.3, in case anybody finds it useful
Edit5: oh, I overlooked something... fixed
#3
Video / [REQUEST] Playthrough with Vanilla+
May 15, 2014, 11:58:33 PM
Hey guys, would anybody be interested in doing a playthrough on youtube with my mod Vanilla+? I just released v1.0 so it's basically done.

I always had these mods enabled too while testing, so if you add any combination of these mods there shouldn't be any issues:

PowerSwitch, Cremation Chamber, Electro Slag Remelting, Resource Compression, Fertilizer Pump, Rotating Hoppers.

If you add any other mods to the mix, your mileage may vary.
#4
Vanilla+

Description:
This mod is basically a compilation of all my previous mods but more polished and with some extra features, most of which are configurable in the Architect+ menu.
The aim is to provide an easily extendible core mod that enriches the vanilla gameplay experience without adding too many things that push it in a certain direction or affect balance too much.

Important:
You can't use this mod on an existing savegame. You have to start a new game with this mod enabled and you can't disable the mod for that savegame afterwards.

Download:
The download link is at the bottom of this post or here.

Modpack:
I've also created a small modpack around Vanilla+ with a small selection of mods that in my humble and probably biased opinion fit well with the philosophy of this mod. You can download it here. It includes Vanilla+.

The modpack consists of these mods:
Inventory Panel, PowerSwitch, Cremation Chamber, Electro Slag Remelting, Resource Compression, Fertilizer Pump, Rotating Hoppers, NoMore Naked Colonists.

How to install:
- Unzip the contents and place them in your RimWorld/Mods folder.
- Activate the mod in the mod menu in game.

Screenshots:


* Some details on the options under miscellaneous settings:

- Every tile you build something on will be added to your home region
- Colonists won't take jobs outside of home region when there are enemies
- Puts down new blueprints when buildings or structures get destroyed
- Corpses will be automatically unforbidden in your home region
- Sandbags can't be surrounded by other sandbags anymore
- Adds the sand tile to the "Structure" menu
- Increases the population cap (3 minimum, 25 maximum, 250 critical)
- Will make turrets shoot at hostile animals too




To make your colonists automatically hunt animals, you need to set up a bill in your butcher table and click on the button to enable it. If you want your colonists to hunt faster, set up another butcher table.

Other features:
- Order your colonists to eat or go to sleep when their respective food or rest level drops below 50%.
- Improved firefighting
- Can remove thin rock roofs with no roof region
- Automatically undrafts colonists after rescueing/capturing/etc.
- New jobdriver for hunting which includes hauling corpses back

Notes:
- Architect+, Battle Formations, Automatons and PopCap+ are already included in this mod.
- Click on "Vanilla+" to open up the settings dialog. The second page is still a bit of a mess, I know.
- I removed the sand toggle in v0.9 and didn't add one for the improved no roof region, but if you want to disable those you can still do that in the Mods/VanillaPlus/Settings.xml file.

Credits:
Clker.com is where I got the images I used for the buttons
ItchyFlea for allowing me to use PopCap+ in my mod
Joretap0, Haplo, Psyckosama, zelldot, mrofa, WorldOfIllusion and Silvermane for allowing me to add their mods to my modpack

Changelog:
0.1- Sneakpreview
0.5- Added meat threshold for autohunt, turrets attacking animals, toggles to pause game on events
0.9- Merged some namespaces, added thin rock roof removal and improved firefighting, reworked curfew and update home region a little
1.0- Improved firefighting a bit more and fixed 2 options not always being loaded properly
1.0.1- Added automatically undrafting colonists after rescueing/capturing/etc.
1.1- Fixed possible bug caused by "Stay inside during threats", changed auto unforbidding corpses to also affect non-human corpses
1.2- Added jobdriver for hunting which includes hauling the corpse back
1.2.1- Small update to the sandbag waffle restricter, probably not very exciting for most of you
1.2.2- Small bugfix for a (very rare) bug concerning loading a savegame and fire reservations
1.2.3- Slightly improved the waffle restricter
1.2.4- Fixed a bug related to the "Stay inside during threats" option
1.2.5- Fixed this and did another minor tweak in that class related to "Stay inside during threats"
1.2.6- The text above the architect menu can now be changed by editing the Settings.xml file

P.S. No muffalos were harmed during the making of this mod.

[attachment deleted by admin: too old]
#5
Mods / Modders on IRC
May 10, 2014, 07:32:58 PM
Just a reminder that there's a #rimworld IRC channel on quakenet. Not many modders seem to be frequenting it, I think it would be nice to see some more modders and modding related conversations there.
#6
Outdated / [MOD] (Alpha 3F) Architect+ (v1.0)
May 01, 2014, 04:42:33 PM
Architect+

Description:
Adds pages to the architect menus and shows a fixed amount of items per page.
You can browse through the pages by clicking the buttons in the architect menu.

Download:
The download link is at the bottom of this post or here.

How to install:
- Unzip the contents and place them in your RimWorld/Mods folder.
- Activate the mod in the mod menu in game.

Notes:
- Click on "Architect+" to open up the settings dialog.

Changelog:
0.1- Released
0.5- Some fixes and added small icons
0.6- Added a sort option
0.9- Changed name to Architect+ and added a settings menu
1.0- Tweaked the menu a bit and changed auto icon behaviour a little

[attachment deleted by admin: too old]
#7
Outdated / [MOD] (Alpha 3F) Automatons (v1.1)
April 30, 2014, 11:34:21 AM
Automatons

Description:
This mod will automatically put down new blueprints when things get destroyed, add every tile you build something on to your home region,
keep your colonists from taking new jobs outside of your home region when there are enemies on the map and try to satisfy butcher bills by marking animals for hunting and unforbidding their corpses.

Download:
The download links are at the bottom of this post or here: AutoRebuild, AutoHomeRegion, AutoHunt, AutoCurfew and the all in one package Automatons. No need to install the separate mods if you get the all in one package.

How to install:
- Unzip the contents and place them in your RimWorld/Mods folder.
- Activate the mod in the mod menu in game.

Notes:
- Should work on your existing savegames.
- To flag things not to be rebuilt, select them and toggle the rebuild button.
- Your home region gets updated when a colonist starts finishing a frame, so it won't work with god mode on.
- Does not rely on tickers, so should be pretty efficient.

Credits:
Clker.com is where I got the image I used for the button

Changelog:
0.9- Released
0.9.5- Added AutoHomeRegion and AutoHunt
1.0- Split up the mod into separate mods
1.1- Added AutoCurfew, updated AutoHunt, fixed AutoRebuild to also work with modded things

P.S. There won't be anymore updates for Automatons. If you're still using this, consider getting Vanilla+ instead.
Also, there's a pretty serious bug in AutoCurfew, and therefore also in Automatons.

[attachment deleted by admin: too old]
#8
I tried to create a custom ThingComp class for pawns and I noticed the command actions I added weren't there in the game.

Edit: I think this can be fixed by also returning the commands in base.GetCommands() in the Pawn class
#9
Perhaps it helps if I elaborate on what I'm trying to do. I'm working on an expansion of my Battle Formations mod, which adds a structure called an automaton. The main function of the structure is to act as sort of an automated threat response system. When raiders or psychotic animals show up, it will automagically send out your colonists to deal with the threat. I got that part working, mostly, though it still needs some polishing. I also want to automatically mark animals for hunting when running low on meat, shouldn't be too hard either.

The thing I can't see an elegant solution for is I also want it to automatically put down new blueprints when things get destroyed. Maybe it's just not feasible but I figured maybe someone more clever than me can come up with something I hadn't thought about ;).
#10
Outdated / [MOD] (Alpha 3F) Battle Formations (v1.0)
April 24, 2014, 10:57:27 PM

Battle Formations
Now with lasers, banana bombs and exploding sheep!
(not really)
Description:
Allows you to save the positions of all your drafted colonists so you can make them all return to the exact same positions at a later time.
I also added the ability to manually order your colonists to eat or sleep, so while the raiders are staging you can make sure all your colonists are well fed and rested.

Download:
The download link is at the bottom of this post or here.

How to install:
- Unzip the contents and place them in your RimWorld/Mods folder.
- Activate the mod in the mod menu in game.

Important:
You can't use this mod on an existing savegame. You have to start a new game with this mod enabled and you can't disable the mod for that savegame afterwards.
Savegames started with Battle Formations v0.1 also won't work with the new version. If you really want to use this mod in one of your existing savegames you can easily fix this using the awesome XML manipulation tool XmlStarlet which you can download here.

To fix your Battle Formations 0.1 savegame to work with Battle Formations 1.0:
xml ed -P -u "//thing[@Class='BattleFormations.XPawn'][def/text()='Human']/@Class" -v "BF.PawnX" -u "//thing[@Class='BattleFormations.XPawn'][def/text()!='Human']/@Class" -v "Pawn" input.rim >output.rim

To add Battle Formations 1.0 to your vanilla savegame:
xml ed -P -u "//thing[@Class='Pawn'][def/text()='Human']/@Class" -v "BF.PawnX" input.rim >output.rim

To remove Battle Formations 1.0 from your savegame:
xml ed -P -d "//thing[@Class='BF.PawnX']/savedpos" -u "//thing[@Class='BF.PawnX']/@Class" -v "Pawn" input.rim >output.rim

If all this command line stuff scares you, just download XmlStarlet, get this batch file, make sure xml.exe and the batch file are in the same directory and drag and drop your savegame on the batch file. I do advise to keep the backup file, at least until some people have reported it all works as intended.

Notes:
- The easiest way to set up positions for your colonists is to just move them all into position once, select them all and click the "Save positions" button. The other new button in draft mode will make them all return to these positions.
- The options to manually order your colonists to eat or sleep become available when either food or rest drops below 50%. The way I intended it to work is when raiders are staging you can select all your colonists and click the eat or sleep button to make all colonists with food or rest levels below 50% fulfill their needs.

Credits:
Clker.com is where I got the images I used for the buttons
Haplo for his awesome PowerSwitch mod which I used as a template

Changelog:
0.1- Released
1.0- Changed it so it only affects human pawns, the eat and sleep buttons will be disabled if pawns are already eating or sleeping and tidied up the code a bit.

P.S. There won't be anymore updates for Battle Formations. If you're still using this, consider getting Vanilla+ instead.

[attachment deleted by admin: too old]
#11
Mods / [Request] save drafted colonist positions
April 22, 2014, 07:26:31 PM
I think it would be really useful if there was some way to save the exact positions of all your drafted colonists during a raid, and then to be able to make them return to those positions on consequent raids. Kinda like the "Save your current crew positions" and "Return crew to saved positions" buttons in FTL.

The most elegant way to implement this would probably be to have 2 extra icons available next to the undraft and fire buttons when you have one or more drafted colonists selected. One to save their positions and one to make them go to their designated position if they have one.

This would probably also be a nice standard feature to add to alpha 4, but I figured I'd post it in the mod section first since it'd be awesome to have this feature sooner, if possible.