RimWorld

RimWorld

67 ratings
Defensive Positions - Forked
   
Award
Favorite
Favorited
Unfavorite
Mod, 1.6
File Size
Posted
Updated
404.814 KB
16 Aug @ 4:08pm
23 Aug @ 4:13pm
4 Change Notes ( view )

Subscribe to download
Defensive Positions - Forked

Description
Original Mod: Defensive Positions

WARNING
This mod is not a hop-in replacement for the other one, there were mayor changes in how things are handled by code. If you started a colony with the original, you probably should finish your colony with it.

Changes
  • Removed HugsLib dependency.
  • Changed graphics.
  • Positions are saved per map.
  • Removed Multiplayer Support (I deleted the class with most issues in multiplayer, so maybe it works on multiplayer right out of the bat, I don't know, I don't use that mod).

Description
Allows your colonists to remember their position during base defense. You can send off your colonists to their positions with a single click.

How to use
Set defensive positions for colonists
1) Draft your defenders and place them where you want them.
2) With your defenders selected, right-click the Defensive position button and select "Save defensive position".
Done. The selected colonists will remember their held positions.

Send colonists to saved positions
1) Select your defenders.
2) Click the Defensive position button (or press T).
Your defenders will be drafted and will run to their saved positions.

Advanced mode
Hold the Alt key and click the Defensive position button to switch between basic and advanced mode.
Advanced mode works exactly like Basic, but you have 4 positions to work with. Save a position using the right-click menu, then click the slot to send the selected colonists to the position they have been assigned under that number.
Pressing T is the same as clicking the first slot.

Squad hotkeys
Colonists can be assigned to squads for easier selection. To assign, hold the Ctrl key and press 1-9 on the numeric keypad to assign the squad to that key. Press the numeric key of a squad to select the squad members, press again to focus on the squad location.

Utility hotkeys
There are three other keys on the keypad for quick colonist management: press period to select all colonists on the map, undraft everyone by pressing divide, and press zero to send all colonists to their assigned defensive position.
In the Options > Mod Options window you can switch the Shift key from saving positions to queuing movement orders.

Special Thanks
Symbolic (a.k.a. UnlimitedHugs) - For the original code.
Captain ♥♥♥♥♥♥♥♥ - For a fix in the code.

License
Equally to the original version, this is a free and unencumbered software release into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any means.

You can check the source code on My Github Repository[github.com]
26 Comments
月空 27 Aug @ 11:56pm 
Great job! It's functioning very well now.
GonDragon  [author] 24 Aug @ 3:23pm 
@Thetaprime: It patches some functions that exist only on 1.6 (The gravship's take-off and landing procedures). Maybe it works and just throw two red errors on load, maybe it doesn't work at all, can't say. If you want to know, you'll have to test it yourself. My suggestion: If you play on the 1.5, just use the original version with HugsLib. You don't gain too much removing HugsLib, I did it mostly because without the lib, the mod becomes easier to maintain or port to other version in the future.

HugsLib is not as bad for performance as many people say. I had to look at the code to port this mod, and it is quite well done. It's just that it hooks things in weird places, because it came from a time where the Vanilla rimworld code wasn't as friendly or convenient for modders. Currently, most if not all functions could be easily done with vanilla hooks.
Thetaprime 24 Aug @ 12:59pm 
Any reason this fork wouldn't work with 1.5?
月空 24 Aug @ 9:20am 
That's great. I wish the personnel selection using Ctrl+number keys could also be saved.
GonDragon  [author] 23 Aug @ 12:24pm 
@月空: That's because you're landing on a new map, every map saves their own formations. That issue should be fixed in an Update later today, if a pawn have a position set on the ship, the position will move with him.
月空 23 Aug @ 12:19pm 
The mod is great, but the formation resets every time the ship lands
GonDragon  [author] 20 Aug @ 5:23am 
@Captain Shitface: Fixed, thanks! Although I put the fix directly inside the ViewingWorldMap, as it's also used in a another instance and i'll guess it needs the fix there too.

And about the hotkeys, if you mean all the instances about holding alt or control, all of those are now Event.current checks.
Captain Shitface 19 Aug @ 4:27pm 
@GonDragon When in space, Rimworld renders the world in the background while displaying the local map in the foreground. This creates a hybrid rendering state where;

`WorldRendererUtility.WorldSelected = true` (world is being rendered in background)
`Find.CurrentMap != null` (local map exists and is active)

But we're actually interacting with the map, not the world.
My fix was to use 'WorldRendererUtility.DrawingMap' to tell us whether we're actively interacting with a map as opposed to the world view, regardless of the background rendering state.

On line 68 of the PawnSquadHandler.cs, this is what you currently have;
if (ViewingWorldMap) {

My fix was;

if (ViewingWorldMap && !WorldRendererUtility.DrawingMap) {

Also for some performance gains; you could look into changing the Hotkeychecks to be every 3 ticks instead of every tick, possibly look into moving away from event polling and use direct unity input key state checking.
GonDragon  [author] 19 Aug @ 3:57pm 
@My Github Repository: I'm not really aware of any issues with the squad hotkey, so it's most likely not fixed in my version. What is the issue?

Also, I added a link to my github repo in the description, In case you want to see what I'm making. In short, I moved most things to a MapComp to have positions being saved on per map basis, and I'm in the middle of simplifying a few functions to ease any future maintenance task.
Captain Shitface 19 Aug @ 3:30pm 
@GonDragon

Ayy lets go! I was actually in the process of doing this myself too, but got caught up in other things. I did already have a working fix for the gravship in place for the hugslib version that I never uploaded since the OG version updated. Wanted to save it for the non-hugslib version.

If you'd like to compare, feel free! Also, I'm unsure if you fixed the issue with squad hotkeys in space that the original Defensive Positions upload has that I had fixed in my 1.6 version, but I can help you with that if it's not.