-
Notifications
You must be signed in to change notification settings - Fork 9
SHORTUTORIAL: CompSlotLoadable
"Allows modders to create slotted items that can be loaded with various items (ammo, crystals, Diablo style melee stat boosters, you name it)."
Github Location: jecrell/CompSlotLoadable
Use: drop in the CompSlotLoadable.dll into your mod's Assemblies folder
NOTE: Currently this is weapon-oriented so don't try to add stats that don't fit in the StatCategoryDefOf.Weapon. I have a green light from jecrell to refactor this so stay tuned.
<SlottedThing> - (see MeleeWeapon_Knife_Warrior_Slot in XML below) - Your thing with a slot.
<MySlotDef> - (see SlotWarriorGem in XML below) - Your newly created slot.
<SlotFiller> - (see MeleeWeapon_Gem_Berserker in XML below) - Your newly created thing that goes into a slot.
SlotLoadableDef / SlotLoadable - This ThingDef/Thing duo in XML is used to create a Slot that can be added to a SlottedThing and filled by a Slottable (i.e. the slottableThingdefs).
<ThingDef Class="CompSlotLoadable.SlotLoadableDef">
<defName>SlotWarriorGem</defName>
<thingClass>CompSlotLoadable.SlotLoadable</thingClass>
<Label>Warrior Gem</Label>
<description>A fierce looking slot that is capible of holding warrior gems.</description>
<slottableThingDefs>
<li>MeleeWeapon_Gem_Berserker</li>
</slottableThingDefs>
<doesChangeStats>true</doesChangeStats>
</ThingDef>
CompProperties_SlotLoadable / CompSlotLoadable - This component is added to a SlottedThing (MeleeWeapon_Knife_Warrior_Slot below) and shows which slots are on the SlottedThing. Notice how MeleeWeapon_Knife_Warrior_Slot has SlottableTestBase as a parent. Most weapons and apparel inherit from Thing and not ThingDef, which is required to have tags. So, you'll have to change your Thing hierarchy.
<ThingDef ParentName="SlottableTestBase">
<defName>MeleeWeapon_Knife_Warrior_Slotted</defName>
<label>slotted warrior knife ababababababaababababababa</label>
<description>A knife with a slot in it for warrior gems.</description>
<tickerType>Normal</tickerType>
<comps>
<li Class="CompSlotLoadable.CompProperties_SlotLoadable">
<slots>
<li>SlotWarriorGem</li>
</slots>
</li>
</comps>
</ThingDef>
CompProperties_SlottedBonus / CompSlottedBonus - Stores the bonuses of the Slottable item. When the Slottable is added to a Slot on a SlottedThing, the slotted bonuses will be added.
NOTE: this example will not work in jecrell's current code for MoveSpeed and GlobalLearningFactor
<ThingDef ParentName="SlottableTestBase">
<defName>MeleeWeapon_Gem_Berserker</defName>
<label>warrior berserker gem ababababababababababa</label>
<description>A gem that heals, increases movement and does damage.</description>
<tickerType>Normal</tickerType>
<comps>
<li Class="CompSlotLoadable.CompProperties_SlottedBonus">
<statModifiers>
<MoveSpeed>10.00</MoveSpeed>
<MeleeWeapon_DamageAmount>10</MeleeWeapon_DamageAmount>
</statModifiers>
<defensiveHealChance>
<chance>1.0</chance>
<woundLimit>7</woundLimit>
</defensiveHealChance>
</li>
</comps>
</ThingDef>