[Solved]Help with custom melee damage.

Started by BrokenValkyrie, December 19, 2017, 05:23:08 AM

Previous topic - Next topic

BrokenValkyrie

I am trying to get custom melee damage to work on tool capacity.

XML verb tags still works as of following. The following code was intended for dragon mod. But the code is relevant to both animal and weapon melee damage. How ever combat log does not record it properly and having verbs and tool definition have produced bugs on occasion where the verbs damage definition would rapid fire.

<verbs>
     <li>
        <verbClass>Verb_MeleeAttack</verbClass>
        <defaultCooldownTime>3</defaultCooldownTime>
        <meleeDamageBaseAmount>28</meleeDamageBaseAmount>
        <meleeDamageDef>Burn</meleeDamageDef>
        <linkedBodyPartsGroup>Teeth</linkedBodyPartsGroup>
      </li>
</verbs>


I would like something like this.

<tool>
      <li>
        <cooldownTime>3</cooldownTime>
        <power>26</power>
        <capacities>
          <li>Bite</li>
          <meleeDamageDef>Burn</meleeDamageDef>
        </capacities>
<label>teeth</label>
        <linkedBodyPartsGroup>Teeth</linkedBodyPartsGroup>
      </li>
</tool>



I have tried adding burn definition to toolcapacity.xml, but it doesn't do anything. I am struggling to find how tool definition relates to Damages_MeleeWeapon.xml. I looked through rimworld source code and I'm lost. I know the old definition can apply environmental damage fine. If anyone know a mod that has its own custom tool capacity or used damage def on tool definition outside of Damage_MeleeWeapon.xml it would be a big help.

BrokenValkyrie

I found a solution to my own problem.

I am using not enough lethal weapon as an example here http://steamcommunity.com/sharedfiles/filedetails/?id=973309933. I currently don't need dragon to have fire melee attack anymore.

As I was looking attempting to trace back toolcapacity use I notice a class called maneuverDef.


namespace Verse
{
  public class ManeuverDef : Def
  {
    public ToolCapacityDef requiredCapacity;
    public VerbProperties verb;
    public RulePackDef combatLogRules;
  }
}


Maneuvers have their own definition in Core\Defs\Maneuvers\Maneuvers.xml

Lets take a look at Smash maneuver


  <ManeuverDef>
    <defName>Smash</defName>
    <requiredCapacity>Blunt</requiredCapacity>
    <verb>
      <verbClass>Verb_MeleeAttack</verbClass>
      <meleeDamageDef>Blunt</meleeDamageDef>
    </verb>
    <combatLogRules>Maneuver_Smash</combatLogRules>
  </ManeuverDef>


Here I can define custom melee damage type.

<requiredCapacity> refers to tool capacity found in \Core\Defs\ToolCapacityDefs\ToolCapacity.xml .
<combatLogRules> refers to rule pack which is found in Core\Defs\RulePackDefs\RulePacks_Combat.xml .


So here the step to create a custom melee damage using not enough lethal weapon as an example. First I need create a new capacity def.

<Defs>
  <ToolCapacityDef>
    <defName>ShockBlunt</defName>
    <label>paralyzingStrike</label>
  </ToolCapacityDef>
</Defs>


Now I need a new maneuver definition

<Defs>
<ManeuverDef>
    <defName>ShockSmash</defName>
    <requiredCapacity>ShockBlunt</requiredCapacity>
    <verb>
      <verbClass>Verb_MeleeAttack</verbClass>
      <meleeDamageDef>NNF_StunBaton</meleeDamageDef>
      <soundCast>NNF_SoundDef_StunBaton</soundCast>
    </verb>
    <combatLogRules>Maneuver_Smash</combatLogRules>
  </ManeuverDef>
</Defs>


<requiredCapacity>must match the name in toolCapacityDef.
The <meleeDamageDef> is a custom defined damage, it can be replaced with other damage type found in Core\Defs\DamageDefs.
For now vanilla combat log will do.

The melee weapon tag should look like this

    <tools>
      <li>
        <label>head</label>
        <labelUsedInLogging>false</labelUsedInLogging>
        <capacities>
          <li>ShockBlunt</li>
        </capacities>
        <power>5</power>
        <cooldownTime>2.15</cooldownTime>
      </li>
    </tools>


Basically created your own tool capacity for the melee weapon tool(melee) definition. Create a maneuver which matches the required tool capacity. The maneuver will help define the melee behavior and link it to the appropriate combat log rule.