[1.0] Swimming Kit

Started by Pyrce, October 21, 2018, 08:45:52 PM

Previous topic - Next topic

Pyrce

[1.0] Swimming Kit

A RimWorld mod which adds swimming attribute for pawns to change speeds while in water tiles.



The mod acts as a toolkit for adding swimming statistics to the game. It makes pawns respect a new SwimSpeed baseStat for both moving through water and for planning pathing through water.

In working on another mod it took the better part of a long weekend to get all the various places that needed changing correct, so to save other modders time and to enable adding actual aquatic gear / pawns I put the changes together in this mod.


Change in Terrain

This mod makes Ocean and DeepWater tiles accessible. Normal pawns will move very very slow through ocean, but it is possible for pawns and items to now be in Ocean. If a pawn has SwimSpeed it will travel much quicker through ocean tiles.


Links
Steam
Github


How to Use

Adding the `SwimSpeed` to any `ThingDef`'s `statBases` will apply swim speed when in water tiles.


<ThingDef ParentName="AnimalThingBase" ADogSaidBody="Tail">
    <defName>Turtle</defName>
    <label>turtle</label>
    <description>A tortoise that likes water</description>
    <statBases>
        <MoveSpeed>1</MoveSpeed>
        <!-- This makes turtle have a base speed of 4 in water -->
        <SwimSpeed>4</SwimSpeed>
    </statBases>
</ThingDef>


If you want to conditionally set a SwimSpeed only if this mod is present you can do the following:


// Dynamically set the SwimSpeed to avoid requiring SwimmingKit
StatDef swimDef = DefDatabase<StatDef>.GetNamed("SwimSpeed", false);
if (swimDef != null)
{
    ThingDef turtle = ThingDef.Named("Turtle");
    turtle.SetStatBaseValue(swimDef, 4.0f);
}


You can also effect SwimSpeed by modifying equipment.


<ThingDef ParentName="ArmorMachineableBase">
    <defName>Apparel_HydroPowerArmor</defName>
    <label>hydro plate armor</label>
    <description>Augmented power armor with built-in water-jets for fast traversal underwater.</description>
    </statBases>
    <equippedStatOffsets>
        <MoveSpeed>-1.0</MoveSpeed>
        <SwimSpeed>3.5</SwimSpeed>
    </equippedStatOffsets>
</ThingDef>


Code issues / questions also welcome on the SwimmingKit Github page.


License (MIT)

If you're a modder and want to use or extend this mod I ask only that you let me know (here or on steam). Otherwise feel free to use the mod in the making of further mods.


Credits

Icon Graphic Base
Powered by Harmony Patch Library

Jiro

Alright! I've been looking for something like this. Will "drowning" and "water rescue" ever be added?

vandal

Wow this is very cool.

Quote from: 中村ジロ on November 15, 2018, 09:21:22 AM
Alright! I've been looking for something like this. Will "drowning" and "water rescue" ever be added?
i like this idea. Maybe a variation of space refugee, a castaway too?

Jiro


eksynn

can i swim in the ocean with this?
man we really need boats

Ruisuki

if the authors of yes vehicles ever figure out how to add vehicles(waiting on jecrells tools to update last i heard), it may be possible to do the same for boats