[1.4] JecsTools [10/21/2022]

Started by jecrell, May 26, 2017, 10:16:37 AM

Previous topic - Next topic

jecrell








Adds components to RimWorld: vehicles, spell casting, weapon slots, oversized weapons, and more!








**Note to players:** This mod will not change your game, but rather it lets modders do more, so you can have an even more amazing RimWorld experience.
   
**Note to modders:** This mod contains components that allow you to do many new and different things in RimWorld. Check out RoxxPloxx's guide for more info here: https://github.com/roxxploxx/RimWorldModGuide/wiki
   
Total list of components:

*CompAbilityUser*
- Adds spell/ability casting to humanlikes.

*CompActivatableEffect*
- Adds an activation graphic for weapons (e.g. lightsaber beam).

*CompDeflector*
- Allows the ability to knock projectiles away with melee weapons.

*CompExtraSounds*
- Adds extra melee sounds to weapons.

*CompLumbering*
- Gives pawns a staggered walking animation that cycles between two images. (e.g. ATST walking effect)

*CompOversizedWeapon*
- Allows weapons to have graphic sizes that can be bigger than RimWorld's vanilla limits.

*CompSlotLoadable*
- Adds slots to objects, weapons, apparel, etc that can be filled to have effects. (e.g. an ammo slot for guns with different kinds of ammunition, crystal slots for lightsabers, etc)

*CompVehicle* (Experimental)
- Allows for a pawn to be treated as a vehicle that can be loaded with pilots, gunners, crew, and passengers

*CompInstalledPart*
- Allows for a part to be installable and uninstallable onto another thing. This is particularly useful for vehicle weapons.

*CompToggleDef*
- Allows for a thing to despawn, change its def, and respawn.

*CompAnimated*
- Allows for animating various things.

*CompDelayedSpawner*
- Allows many customizable options for spawning one or many things into RimWorld -- similar to the vanilla spawner with more options.

*CompOverlays*
- Allows modders to add graphics on top of existing ones -- for example, a dozen lit candles can have overlays of tiny fires.

*PawnShields*
- Adds shields to RimWorld.

Total List of Classes

JecsTools.Hediff_TransformedPart
- Similar to added part, however, transformed parts will not remove the original parts when removed from the character. This allows for us to "transform" pawn parts. Such as having a colonists' hands turn into deadly claws.

JecsTools.JobGiver_AIFirelessTrashColonyClose
JecsTools.JobGiver_AIFirelessTrashColonyDistant

- These classes lets us call a special jobgiver for raiders that does not include setting fire to objects. This is good for monstrous creatures that do not have the ability to start fires but still want to break things.

JecsTools.DamageWorker_Cleave
JecsTools.DamageDefCleave

- Adds a new damage worker called "cleave" that allows for an attack to swipe multiple targets in front of a user based on XML settings defined in a new damage def. This update is in the preparation of the upcoming Werewolves mod.

JecsTools.HediffCompDamageOverTime
- Causes damage over time to a target.

JecsTools.HediffComp_DamageSoak
- Shrugs off certain types of damage.

JecsTools.HediffComp_ExtraMeleeDamages
- Adds extra melee damages.

JecsTools.HediffComp_Knockback
- Adds knockback, optionally explosive, to attacks.

JecsTools.PlaceWorker_Outline
- Adds outlines to objects when placing their blueprints.

JecsTools.ApparelExtension
- Allows apparel, such as glasses, earrings, nose-rings, or whatever more you can imagine, to be worn alongside hats. Let's accessorize!

Additions by ChJees
Additions by roxxploxx
Additions by Swenzi
Additions and transpilers by Erdelf
Extensive hours of testing, debugging, and fixes by Xen.
"Hey, should we make this into a public toolset for people to take advantage of all this cool stuff?" - Jecrell
"Hell yes - this is awesome stuff - people will love it!" - Xen

Special thanks to Pardeike's amazing non-destructive patching library, Harmony. Without his work, none of this would be possible.





...Psst. Still there? If you'd like to support
me and my works, do check out my Patreon.
Someday, I could work for RimWorld full time!

https://www.patreon.com/jecrell

kaptain_kavern


Katarumi

The tools are amazing! Thank you so much for releasing them for general use, and thank you for the comprehensive documentation too.

Razzoriel

Is there a documentation file for what kinds of stats can be loaded in the compslotloadable, besides the vanilla? I saw something called vampiric healing, and damage bonuses, but is there support for things like reducing weapon cooldown, increasing range or messing with anything in their stats, including their graphic or fire sound (for those willing to use a suppressor, for instance)?

jecrell

#4
Quote from: Razzoriel on May 26, 2017, 12:10:21 PM
Is there a documentation file for what kinds of stats can be loaded in the compslotloadable, besides the vanilla? I saw something called vampiric healing, and damage bonuses, but is there support for things like reducing weapon cooldown, increasing range or messing with anything in their stats, including their graphic or fire sound (for those willing to use a suppressor, for instance)?

Yes. StatModifiers! Simply load in an array of StatModifiers on the ThingDef that goes in the slot. Check out a bit of lightsaber crystal code for an example.


  <ThingDef ParentName="KyberCrystalBaseSynthetic">
    <defName>PJ_KyberCrystalRed</defName>
    <label>synthetic crystal (red)</label>
    <description>This synthesized crystal has been further enhanced, giving it a slightly more powerful blade, and it's trademark red hue. Synthetic crystals like this are often favored by the Sith.</description>
    <graphicData>
      <texPath>Items/KyberCrystal</texPath>
      <graphicClass>Graphic_Single</graphicClass>
  <drawSize>(1,1)</drawSize>
  <color>(206,12,44)</color>
    </graphicData>
  <statBases>
  <Beauty>5</Beauty>
      <MarketValue>1800</MarketValue>
      <Mass>0.3</Mass>  
</statBases>
  <comps>
<li Class="CompSlotLoadable.CompProperties_SlottedBonus">
<color>(206,12,44)</color>
<statModifiers>
<MeleeWeapon_DamageAmount>28</MeleeWeapon_DamageAmount>
</statModifiers>
</li>
</comps>
  </ThingDef>


This one adds 28 melee damage to the weapon. If you know the stat and want to apply it, it should work for nearly everything.

Currently I have CompActivatableEffect that adds a graphic, but I imagine it wouldn't be too hard to add to CompSlotLoadable a "LoadedGraphicAddon" in the form of GraphicData.
...Psst. Still there? If you'd like to support
me and my works, do check out my Patreon.
Someday, I could work for RimWorld full time!

https://www.patreon.com/jecrell

Razzoriel

So, this is what I could gather from this: the StatDef does not allow me to add my own modifiers for modded damage types, weapon range, projectile, soundcast or even muzzleflashscale. Is that correct? I tried creating a custom statdef, but it seems it needs to be coded in the assembly.

jecrell

Quote from: Razzoriel on May 27, 2017, 01:37:27 AM
So, this is what I could gather from this: the StatDef does not allow me to add my own modifiers for modded damage types, weapon range, projectile, soundcast or even muzzleflashscale. Is that correct? I tried creating a custom statdef, but it seems it needs to be coded in the assembly.

Okiedokie.
It's a bit tough to do, but I'll try to do it this weekend.
...Psst. Still there? If you'd like to support
me and my works, do check out my Patreon.
Someday, I could work for RimWorld full time!

https://www.patreon.com/jecrell

Wishmaster

I just tried to make my own vehicule: an ambulance.  I've used your code from AT-AT and modified it but does not what I want.
I basically want it to have one pilot seat and 4 passengers seat. I could create my own pawn, with body and kind. that wasn't a problem.

There is way for vanilla pawns to get in the vehicle and drive it right ? When I right click on my ambulance, I don't see anything like "get in" or "load". nothing happens.
Also I use the built-in think tree you made so the vehicle wanders even when it says "movements systems: offline".


  <!-- Ambulance -->
  <ThingDef ParentName="WMVehicleBase">
    <defName>WM_Medivac_Ambulance</defName>
    <label>Ambulance</label>
    <description>amblance...ambubulance ??!</description>
    <statBases>
      <MoveSpeed>6</MoveSpeed>
      <ArmorRating_Blunt>0.1</ArmorRating_Blunt>
      <ArmorRating_Sharp>0.3</ArmorRating_Sharp>
      <MeatAmount>0</MeatAmount>
    </statBases>
    <verbs>
    </verbs>
    <race>
      <intelligence>ToolUser</intelligence>
      <thinkTreeMain>CompVehicle_Simple</thinkTreeMain>
      <body>WM_Medivac_AmbulanceBody</body>
      <baseBodySize>1.0</baseBodySize>
      <baseHealthScale>10.0</baseHealthScale>
      <lifeStageAges>
        <li>
          <def>MechanoidFullyFormed</def>
          <minAge>0</minAge>
          <soundWounded>Pawn_Mech_Scyther_Wounded</soundWounded>
          <soundDeath>Pawn_Mech_Scyther_Death</soundDeath>
          <soundCall>Pawn_Mech_Scyther_Call</soundCall>
        </li>
      </lifeStageAges>
      <soundCallIntervalRange>
        <min>1000</min>
        <max>2000</max>
      </soundCallIntervalRange>
      <soundMeleeHitPawn>Pawn_Melee_MechanoidSlash_HitPawn</soundMeleeHitPawn>
      <soundMeleeHitBuilding>Pawn_Melee_MechanoidSlash_HitBuilding</soundMeleeHitBuilding>
      <soundMeleeMiss>Pawn_Melee_MechanoidSlash_Miss</soundMeleeMiss>
    </race>
<!--    <recipes>
      <li>SWFactions_RepairsATST</li>
    </recipes>
-->
    <butcherProducts>
      <Steel>40</Steel>
      <Plasteel>25</Plasteel>
      <Component>1</Component>
    </butcherProducts>
<comps>
  <li Class="CompVehicle.CompProperties_Vehicle">
    <soundEntry>Pawn_Mech_Centipede_Wounded</soundEntry>
<soundEject>Pawn_Mech_Centipede_Wounded</soundEject>
<ejectIfBelowHealthPercent>0.25</ejectIfBelowHealthPercent>
<seatHitDamageFactor>1.75</seatHitDamageFactor>
<seatHitCriticalHitChance>0.03</seatHitCriticalHitChance>
<canBeDowned>true</canBeDowned>
<canWiggleWhenDowned>false</canWiggleWhenDowned>
<canMoveWithoutHandler>false</canMoveWithoutHandler>
<canFireWithoutHandler>false</canFireWithoutHandler>
<roles>
  <li>
    <label>pilot</label>
<labelPlural>pilots</labelPlural>
<handlesMovement>true</handlesMovement>
<slots>1</slots>
<slotsToOperate>1</slotsToOperate>
<slotTag>PilotSeat</slotTag>
  </li>
<!--   <li>
    <label>gunner</label>
<labelPlural>gunners</labelPlural>
<handlesWeapons>true</handlesWeapons>
<slots>1</slots>
<slotsToOperate>1</slotsToOperate>
<slotTag>GunnerSeat</slotTag>
  </li>
-->
  <li>
    <label>passenger</label>
<labelPlural>passengers</labelPlural>
<slots>4</slots>
<slotTag>PassengerSeat</slotTag>
  </li>
</roles>
  </li>
<!--   <li Class="CompLumbering.CompProperties_Lumbering">
    <cycledGraphic>
<texPath>Imp/Walkers/ATSTCycle/ATST</texPath>
<graphicClass>Graphic_Multi</graphicClass>
<drawSize>4.3</drawSize>
<shadowData>
<volume>(0.4, 0.8, 0.4)</volume>
</shadowData>
</cycledGraphic>
<sound>PJ_ATST_Step</sound>
        <secondsPerStep>1.15</secondsPerStep>
<secondsBetweenSteps>0.5</secondsBetweenSteps>
  </li>
-->
</comps>
  </ThingDef>


jecrell

#8
Quote from: Wishmaster on June 01, 2017, 08:02:53 PM
I just tried to make my own vehicule: an ambulance.  I've used your code from AT-AT and modified it but does not what I want.
I basically want it to have one pilot seat and 4 passengers seat. I could create my own pawn, with body and kind. that wasn't a problem.

There is way for vanilla pawns to get in the vehicle and drive it right ? When I right click on my ambulance, I don't see anything like "get in" or "load". nothing happens.
Also I use the built-in think tree you made so the vehicle wanders even when it says "movements systems: offline".


  <!-- Ambulance -->
  <ThingDef ParentName="WMVehicleBase">
    <defName>WM_Medivac_Ambulance</defName>
    <label>Ambulance</label>
    <description>amblance...ambubulance ??!</description>
    <statBases>
      <MoveSpeed>6</MoveSpeed>
      <ArmorRating_Blunt>0.1</ArmorRating_Blunt>
      <ArmorRating_Sharp>0.3</ArmorRating_Sharp>
      <MeatAmount>0</MeatAmount>
    </statBases>
    <verbs>
    </verbs>
    <race>
      <intelligence>ToolUser</intelligence>
      <thinkTreeMain>CompVehicle_Simple</thinkTreeMain>
      <body>WM_Medivac_AmbulanceBody</body>
      <baseBodySize>1.0</baseBodySize>
      <baseHealthScale>10.0</baseHealthScale>
      <lifeStageAges>
        <li>
          <def>MechanoidFullyFormed</def>
          <minAge>0</minAge>
          <soundWounded>Pawn_Mech_Scyther_Wounded</soundWounded>
          <soundDeath>Pawn_Mech_Scyther_Death</soundDeath>
          <soundCall>Pawn_Mech_Scyther_Call</soundCall>
        </li>
      </lifeStageAges>
      <soundCallIntervalRange>
        <min>1000</min>
        <max>2000</max>
      </soundCallIntervalRange>
      <soundMeleeHitPawn>Pawn_Melee_MechanoidSlash_HitPawn</soundMeleeHitPawn>
      <soundMeleeHitBuilding>Pawn_Melee_MechanoidSlash_HitBuilding</soundMeleeHitBuilding>
      <soundMeleeMiss>Pawn_Melee_MechanoidSlash_Miss</soundMeleeMiss>
    </race>
<!--    <recipes>
      <li>SWFactions_RepairsATST</li>
    </recipes>
-->
    <butcherProducts>
      <Steel>40</Steel>
      <Plasteel>25</Plasteel>
      <Component>1</Component>
    </butcherProducts>
<comps>
  <li Class="CompVehicle.CompProperties_Vehicle">
    <soundEntry>Pawn_Mech_Centipede_Wounded</soundEntry>
<soundEject>Pawn_Mech_Centipede_Wounded</soundEject>
<ejectIfBelowHealthPercent>0.25</ejectIfBelowHealthPercent>
<seatHitDamageFactor>1.75</seatHitDamageFactor>
<seatHitCriticalHitChance>0.03</seatHitCriticalHitChance>
<canBeDowned>true</canBeDowned>
<canWiggleWhenDowned>false</canWiggleWhenDowned>
<canMoveWithoutHandler>false</canMoveWithoutHandler>
<canFireWithoutHandler>false</canFireWithoutHandler>
<roles>
  <li>
    <label>pilot</label>
<labelPlural>pilots</labelPlural>
<handlesMovement>true</handlesMovement>
<slots>1</slots>
<slotsToOperate>1</slotsToOperate>
<slotTag>PilotSeat</slotTag>
  </li>
<!--   <li>
    <label>gunner</label>
<labelPlural>gunners</labelPlural>
<handlesWeapons>true</handlesWeapons>
<slots>1</slots>
<slotsToOperate>1</slotsToOperate>
<slotTag>GunnerSeat</slotTag>
  </li>
-->
  <li>
    <label>passenger</label>
<labelPlural>passengers</labelPlural>
<slots>4</slots>
<slotTag>PassengerSeat</slotTag>
  </li>
</roles>
  </li>
<!--   <li Class="CompLumbering.CompProperties_Lumbering">
    <cycledGraphic>
<texPath>Imp/Walkers/ATSTCycle/ATST</texPath>
<graphicClass>Graphic_Multi</graphicClass>
<drawSize>4.3</drawSize>
<shadowData>
<volume>(0.4, 0.8, 0.4)</volume>
</shadowData>
</cycledGraphic>
<sound>PJ_ATST_Step</sound>
        <secondsPerStep>1.15</secondsPerStep>
<secondsBetweenSteps>0.5</secondsBetweenSteps>
  </li>
-->
</comps>
  </ThingDef>



Right right. It's STILL a bit WIP, but it should work when you click your ambulance to have options to load characters.
You click the ambulance itself and you should have a list of buttons to load pawns and so forth.
Also, it needs to be your player's faction, otherwise those buttons can't appear.

*mutters to self about making a right click option*
...Psst. Still there? If you'd like to support
me and my works, do check out my Patreon.
Someday, I could work for RimWorld full time!

https://www.patreon.com/jecrell

jecrell

I just updated this for A17b fellows. The last hotfix that dropped changed a decompiled method name that caused a worldgen bug. This should be fixed now.

Bless
...Psst. Still there? If you'd like to support
me and my works, do check out my Patreon.
Someday, I could work for RimWorld full time!

https://www.patreon.com/jecrell

SurrealSadi

Hey.. I keep getting this error with the DRM-free version: Could not execute post-long-event action. Exception: System.TypeInitializationException: An exception was thrown by the type initializer for CompVehicle.HarmonyCompVehicle ---> System.ArgumentNullException: Argument cannot be null.
Parameter name: key
  at System.Collections.Generic.Dictionary`2[System.Reflection.MethodBase,System.Byte[]].TryGetValue (System.Reflection.MethodBase key, System.Byte[]& value) [0x00000] in <filename unknown>:0
  at Harmony.GeneralExtensions.GetValueSafe[MethodBase,Byte[]] (System.Collections.Generic.Dictionary`2 dictionary, System.Reflection.MethodBase key) [0x00000] in <filename unknown>:0
  at Harmony.HarmonySharedState.GetPatchInfo (System.Reflection.MethodBase method) [0x00000] in <filename unknown>:0
  at Harmony.PatchProcessor.Patch () [0x00000] in <filename unknown>:0
  at Harmony.HarmonyInstance.Patch (System.Reflection.MethodBase original, Harmony.HarmonyMethod prefix, Harmony.HarmonyMethod postfix, Harmony.HarmonyMethod transpiler) [0x00000] in <filename unknown>:0
  at CompVehicle.HarmonyCompVehicle..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at (wrapper managed-to-native) System.Runtime.CompilerServices.RuntimeHelpers:RunClassConstructor (intptr)
  at System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor (RuntimeTypeHandle type) [0x00000] in <filename unknown>:0
  at Verse.StaticConstructorOnStartupUtility.CallAll () [0x00000] in <filename unknown>:0
  at Verse.PlayDataLoader.<DoPlayLoad>m__80F () [0x00000] in <filename unknown>:0
  at Verse.LongEventHandler.ExecuteToExecuteWhenFinished () [0x00000] in <filename unknown>:0
Verse.Log:Error(String)
Verse.LongEventHandler:ExecuteToExecuteWhenFinished()
Verse.LongEventHandler:UpdateCurrentAsynchronousEvent()
Verse.LongEventHandler:LongEventsUpdate(Boolean&)
Verse.Root:Update_Patch1(Object)
Verse.Root_Entry:Update()


And yes, I updated to the newest version. Kinda prevents the game from generating a map.

Jonnymaxed

Yeah I can confirm this is broken. Same error as Sadi.

Could not execute post-long-event action. Exception: System.TypeInitializationException: An exception was thrown by the type initializer for CompVehicle.HarmonyCompVehicle ---> System.ArgumentNullException: Argument cannot be null.
Parameter name: key
  at System.Collections.Generic.Dictionary`2[System.Reflection.MethodBase,System.Byte[]].TryGetValue (System.Reflection.MethodBase key, System.Byte[]& value) [0x00000] in <filename unknown>:0
  at Harmony.GeneralExtensions.GetValueSafe[MethodBase,Byte[]] (System.Collections.Generic.Dictionary`2 dictionary, System.Reflection.MethodBase key) [0x00000] in <filename unknown>:0
  at Harmony.HarmonySharedState.GetPatchInfo (System.Reflection.MethodBase method) [0x00000] in <filename unknown>:0
  at Harmony.PatchProcessor.Patch () [0x00000] in <filename unknown>:0
  at Harmony.HarmonyInstance.Patch (System.Reflection.MethodBase original, Harmony.HarmonyMethod prefix, Harmony.HarmonyMethod postfix, Harmony.HarmonyMethod transpiler) [0x00000] in <filename unknown>:0
  at CompVehicle.HarmonyCompVehicle..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at (wrapper managed-to-native) System.Runtime.CompilerServices.RuntimeHelpers:RunClassConstructor (intptr)
  at System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor (RuntimeTypeHandle type) [0x00000] in <filename unknown>:0
  at Verse.StaticConstructorOnStartupUtility.CallAll () [0x00000] in <filename unknown>:0
  at Verse.PlayDataLoader.<DoPlayLoad>m__814 () [0x00000] in <filename unknown>:0
  at Verse.LongEventHandler.ExecuteToExecuteWhenFinished () [0x00000] in <filename unknown>:0
Verse.Log:Error(String)
Verse.LongEventHandler:ExecuteToExecuteWhenFinished()
Verse.LongEventHandler:UpdateCurrentAsynchronousEvent()
Verse.LongEventHandler:LongEventsUpdate(Boolean&)
Verse.Root:Update()
Verse.Root_Entry:Update()


Please fix this, I wanted to play the cults :(

jecrell

#12
Quote from: SurrealSadi on June 03, 2017, 10:44:18 PM
[...]
And yes, I updated to the newest version. Kinda prevents the game from generating a map.

Quote from: Jonnymaxed on June 04, 2017, 03:25:39 AM
Yeah I can confirm this is broken. Same error as Sadi.
[...]
Please fix this, I wanted to play the cults :(

My deepest apologies. I hate to see these sorts of errors pop up.
The DRM free version isn't updated to A17b yet then, I'm guessing. Please use the PREVIOUS version of JecsTools for A17.
Tynan released a hotfix that messed up the main set of tools.
https://github.com/jecrell/JecsTools/releases/tag/1.0.4.1
...Psst. Still there? If you'd like to support
me and my works, do check out my Patreon.
Someday, I could work for RimWorld full time!

https://www.patreon.com/jecrell

Canute

17b is even realeased for DRM-free, but no new email is send, so many people didn't notice this.

Jonnymaxed

#14
1.0.4.1 doesn't work either with the cult mod. But instead of actual tools breaking, its the cult mod, from looking at the debug log.

I'll update to the newest version of the game and i'll let you know. Your mods were pretty much the only reason I wanted to replay Rimworld so this has been kind of a bummer so far.

EDIT: IT WORKS! Now time to pay respects to the dark ones.