Learning to make a mod. Trying to make a flaming sword. Need a little help

Started by KuRRi, January 04, 2019, 09:27:49 AM

Previous topic - Next topic

KuRRi

Hi! I'm very new to modding for Rimworld and modding in general. My programming skill is somewhere between beginer and immediate (C# and HTML/CSS).

I'm trying to make a flaming sword that set the opponent on fire when attacking (as the title have suggest). After reading some tutorial I was able to create a sword that apply burn to people when hit (create a new toolcapacityDef and ManueverDef). That not entirely what i wanted. So I go back to done some more research, which help me founded the DamageDef "Flame". Unfotunately it's an enviromental damage, not meleeweapon damage, so it didn't work.

To this point I've just using XML, no C# script yet. So my question is: how do i apply the "Flame" to my attack? And is it possible to do it by just using XML ?

John Midnight

I used flame in a shotgun, and works (https://steamcommunity.com/sharedfiles/filedetails/?id=1602796764). It sets on fire pawns and give burn damage. It doesn´t set on fire plants or structures.

KuRRi

Might if you share me how to do it ? And btw i can easily find the method that detect when a projectile hit something thank to jecrell tutorial, but the codes for melee attack (couldn't find individual weapon ) are entirely different, which till out I still haven't firgue it out yet. And there is no legitimate source for melee weapon, strangely enough.

John Midnight

This is the bullet definition (weapon definition is vanilla):
  <ThingDef ParentName="BaseBullet">
    <defName>MAC_Bullet_Incendiary_Shotgun</defName>
    <label>shotgun fire</label>
    <graphicData>
      <texPath>Things/Projectile/Bullet_Shotgun</texPath>
      <graphicClass>Graphic_Single</graphicClass>
    </graphicData>
    <projectile>
      <damageDef>Flame</damageDef>
      <damageAmountBase>8</damageAmountBase>
      <stoppingPower>2</stoppingPower>
      <armorPenetrationBase>0.05</armorPenetrationBase>
      <speed>38</speed>
    </projectile>
  </ThingDef>

Just change damage type to "Flame". The definition of flame is in DamageDefs. For a melee weapon I supose that you have to change <capacities><li>Blunt</li></capacities> to <capacities><li>Flame</li></capacities>.
I discovered it by tinkering a little.

KuRRi

Unfortunately it doesn't work with melee weapon, since they have a seperate tag called <meleeDamageDef> which doesn't reconigze Flame.

Canute

Take a look at Rimsenal mod, they got a  Torch sword which do what you want to do.
Maybe you can learn from it.

KuRRi


Razuhl

You just need to use an armor category in the flame damage definition that defines a melee weapon damage multiplier.

Like this:


<DamageDef ParentName="Flame">
<defName>MyFlame</defName>
<armorCategory>Sharp</armorCategory><!-- armor category must have the multiplier stat which heat doesn't have-->
</DamageDef>


Then you can proceed with tool, capacities and maneuver. Simple example.


<ToolCapacityDef>
    <defName>MyFlame</defName>
</ToolCapacityDef>

<ManeuverDef>
<defName>MyFlame</defName>
<requiredCapacity>MyFlame</requiredCapacity>
<verb>
<verbClass>Verb_MeleeAttackDamage</verbClass>
<meleeDamageDef>MyFlame</meleeDamageDef>
</verb>
<logEntryDef>MeleeAttack</logEntryDef>
<combatLogRulesHit>Maneuver_Slash_MeleeHit</combatLogRulesHit>
<combatLogRulesDeflect>Maneuver_Slash_MeleeDeflect</combatLogRulesDeflect>
<combatLogRulesMiss>Maneuver_Slash_MeleeMiss</combatLogRulesMiss>
<combatLogRulesDodge>Maneuver_Slash_MeleeDodge</combatLogRulesDodge>
</ManeuverDef>


Adding a tool to a melee weapon with the capacity MyFlame will now give you a melee attack that sets pawns on fire.

KuRRi

OMG it work! Thank you so much. But how do you know about these thing. Like who would have thought the problem is with the armorCategory.

Razuhl

When you originally used "Flame" you got an error and a corresponding stacktrace in the console. Which said it failed to resolve a stat in the method "Verse.Tool.AdjustedBaseMeleeDamageAmount". If you look at the sourcecode from AdjustedBaseMeleeDamageAmount it contains two stat requests. First is for the items melee weapon damage multiplier and the second is for the materials multiplier stat. And which stat to use is defined in "damageDef.armorCategory.multStat".

KuRRi

OK thank you very much. Look like I have to learn how to read the console log porperly.