[A13] The Holy Hand Grenade of Antioch - JuliaEllie - A13Update

Started by milon, June 06, 2016, 06:01:12 PM

Previous topic - Next topic

milon

Quote from: joaonunes on June 08, 2016, 09:42:52 AM
EDIT 3: There is a damage type called "IgnoreArmor", which does exactly what it sounds like. It acts as if there wasn't any armor at all and the pawn receives full damage from the attack. Making the rabbit resistant to all damage types (except IgnoreArmor of course) either by making him invulnerable or by boosting his armor stats by ridiculous amounts should work :D

The IgnoreArmor thing sounds useful, but the term "IgnoreArmor" doesn't show up in the xml for A12 or A13 (I keep a concatenated copy for easy searching & reference).  And "ignore" doesn't find anything armor-related.  I really can't find what you're referring to.  Are you maybe thinking of a different game or a different term?

joaonunes

"IgnoreArmor" is a damage type that exists in the damage types enumeration in the game engine (c# side, not xml), and is both used in the vanilla engine and in the Combat Realism damage handling. It is there, and it should be recognized if any weapon uses that damage type.
        public enum DamageArmorCategory : byte
{
IgnoreArmor, //  <--- This damage type exists and works!
Blunt,
Sharp,
Heat,
Electric
}


By inspecting some Combat Realism xml and dll files I have reached some conclusions...
I have no idea what to do next, but this could be a start:

<DamageDef ParentName="LocalInjuryBase">
    <defName>Bullet</defName>
    <label>bullet</label>
    <externalViolence>true</externalViolence>
    <battleWound>true</battleWound>
    <deathMessage>{0} has been shot to death.</deathMessage>
    <hediff>Gunshot</hediff>
    <harmAllLayersUntilOutside>true</harmAllLayersUntilOutside>
    <impactSoundType>Bullet</impactSoundType>
    <armorCategory>Sharp</armorCategory>
</DamageDef>


Replace "Sharp" by "IgnoreArmor"
Do you want your colonists to look manlier?
Get a free mustache sample here!

milon

Ooh, nice find!  A 5th armorCategory!

Okay, so here's how this works.  <armorCategory> is a bit of a misnomer from my perspective.  None of those DamageArmorCategory things are actually armors, but rather the type of damage it causes.  For example, "Bullet" falls into the "Sharp" damage category and is affected by the <ArmorRating_Sharp> of the thing it hits.  Some <DamageDef> entries don't even have an <armorCategory>, notably the Repair and various Operation actions.

What you want to do is create a new <DamageDef> that ignores armor, and you want to assign that to the holy hand grenade.  There are 2 ways to try it: 1) is to replace Sharp with IgnoreArmor like you said, and 2) is to just delete the armorCategory line (untested, may work or fail or act strangely).

Either way, we need a little more code to make a complete DamageDef file, and we need to know exactly where put it - RimWorld is super picky about where to find all its definitions.  In the Antioch\Defs folder, make a new folder called DamageDefs.  Now you have DamageDefs, RecipeDefs, ResearchProjectDefs, etc all side-by-side.

Inside the DamageDefs folder, create a file with an .xml extension.  You can name it whatever you want, but for sanity choose a sensible name like "DamageDefs.xml".  This is what goes in that file:

Code (Mods\Antioch\Defs\DamageDefs\DamageDefs.xml) Select

<?xml version="1.0" encoding="utf-8" ?>
<Defs>

<DamageDef Name="LocalInjuryBase" Abstract="True">
<workerClass>DamageWorker_AddInjury</workerClass>
</DamageDef>

<DamageDef ParentName="LocalInjuryBase">
<defName>Bullet</defName>
<label>bullet</label>
<externalViolence>true</externalViolence>
<battleWound>true</battleWound>
<deathMessage>{0} has been shot to death.</deathMessage>
<hediff>Gunshot</hediff>
<harmAllLayersUntilOutside>true</harmAllLayersUntilOutside>
<impactSoundType>Bullet</impactSoundType>
<armorCategory>IgnoreArmor</armorCategory>
</DamageDef>
</Defs>


This is just a start.  Since you've modded before (I think?), I'm sure you can work out most of the rationale here.  The file is in the correct folder, has an xml header, and is in the correct "container" element (<DamageDef> items are always defined within a <Defs> container).

The <defName> needs to be replaced with a unique name, like how a variable name must be unique, and it's what you'll use in the holy hand grenade to link it to this new damage type.  I haven't extensively tested what's acceptable for a defName, but I generally just stick to alphabet names.  I think alphanumeric (potentially starting with a letter) is fine too.  The <Label> and <deathMessage> text still needs to be updated.  The <hediff> and <impactSoundType> elements could be changed to something more appropriate (your call, see my auto-documentation file for acceptable examples).

Finally, note that the following is equivalent to the above:

Code (Mods\Antioch\Defs\DamageDefs\DamageDefs.xml) Select

<?xml version="1.0" encoding="utf-8" ?>
<Defs>

<DamageDef>
<workerClass>DamageWorker_AddInjury</workerClass>
<defName>Bullet</defName>
<label>bullet</label>
<externalViolence>true</externalViolence>
<battleWound>true</battleWound>
<deathMessage>{0} has been shot to death.</deathMessage>
<hediff>Gunshot</hediff>
<harmAllLayersUntilOutside>true</harmAllLayersUntilOutside>
<impactSoundType>Bullet</impactSoundType>
<armorCategory>IgnoreArmor</armorCategory>
</DamageDef>
</Defs>


Rather than inherit 1 property from a parent abstract, we can just define it all in 1 block.  This makes more sense for a single-item mod, but if you want to expand into multiple definitions, it's less/cleaner code to inherit some stuff from a parent.  Anything inherited can be overwritten in the child, FYI.


So, now the damage type is defined.  To add it to the holy hand grenade, open up the file Mods\Antioch\Defs\ThingDefs\Weapons_Grenades.xml, and look at line 22: "<damageDef>Bomb</damageDef>"

Replace the word "Bomb" with whatever you called the new damage type in its <defName> tag.  Save, and you're all set!  Try it out!  And feel free to post results here or in a new mod thread if that's the direction you're going (and if so, stick a link here so I can find it).  :)

joaonunes

Nicely done :) will put my hands on it right after I finish my mod, or whenever I have the time.

About me being a modder, no I never modded before except my mustache mod which I created about a couple of months ago and it wasn't even my full creation, all the code was made by someone else (go to my mod page and see the credits), only now I am trying to create new functionalities on my own, the only thing I do know is a bit of c# programming and basic understanding on how xml files work. My biggest problem at this moment is for me to understand how exactly this game works and what to change/use to reach my goal... I am slowly getting there though (I hope xD)

Off-topic, if you'd like to know how is the development of my mod going or if you want to lend a hand visit this:
https://ludeon.com/forums/index.php?topic=20561.0
Do you want your colonists to look manlier?
Get a free mustache sample here!

milon

I'll take a look at it.

One more tidbit that took me a while to figure out: in XML modding, you can't overwrite individual Core parameters (except through Parent/inheritance as stated above). You overwrite & replace an entire Def. For example, if I wanted to add Boom Rats to the Ice Sheet biome, I'd have to rewrite the entire Ice Sheet biome.  (Knowing this from the start of my modding would have saved me hours.)

NephilimNexus

You laugh but I've had a colonist killed by a mad squirrel before.