Skip to content

Projectile_RandomEffectBullet

flango edited this page Nov 27, 2022 · 4 revisions

×× Projectiles with random special effects ××

These projectiles can have following effects based on chance:


Type: ThingClass, ModExtension

XML Node: ThingDef/thingClass, ThingDef/modExtensions/li


<ThingDef>
    ...
    <thingClass>flangoCore.Projectile_RandomEffectBullet</thingClass>
    <modExtensions>
        <li Class="flangoCore.ModExt_ProjectileRandomEffect">
            <!-- Effects go here -->
	</li>
    </modExtensions>
    ...
</ThingDef>

List of effects:

Armor Penetration

<li Class="flangoCore.ModExt_ProjectileRandomEffect">
    <APs>
        <li>
            <chance>0.75</chance>
	    <value>0.20</value> <!-- 75% chance for 20% AP -->
	</li>
	<li>
	    <chance>0.25</chance>
	    <value>0.40</value> <!-- 25% chance for 40% AP -->
	</li>
    </APs>
</li>

Hediffs

<li Class="flangoCore.ModExt_ProjectileRandomEffect">
    <hediffs>
        <li>
	    <hediff>Test_SlowDown_I</hediff>
	    <chance>0.75</chance>
	    <severity>1</severity> <!-- If the hediff doesn't have any severity or stages, use any number -->
        </li>
	<li>
	    <hediff>Test_SlowDown_II</hediff>
	    <chance>0.25</chance>
	    <severity>1</severity>
	</li>
    </hediffs>
</li>

Extra Damage

<li Class="flangoCore.ModExt_ProjectileRandomEffect">
    <extras>
        <li> <!-- Extra damage -->
            <chance>0.75</chance>
            <extraDamage>
                <def>BurnRanged</def>
                <amount>5</amount>
                <armorPenetration>-1</armorPenetration> <!--   -1 means game decides   -->
            </extraDamage>
        </li>
        <li> <!-- Set on fire -->
            <chance>0.25</chance>
            <setOnFire>true</setOnFire>
            <fireSize>0.5</fireSize>
            <ignoreShields>false</ignoreShields>
       <!-- <affectedShields> -->
       <!--     <li>Apparel_DampeningBelt_Primitive</li>   	--> <!--  An example of adding a check for modded shields as well      		    -->
       <!--     <li>Apparel_DampeningBelt_Regular</li>     	--> <!--  BUT this will not check whether the shield is broken or not (Energy > 0)  -->
       <!--     <li>Apparel_DampeningBelt_Advanced</li>    	--> <!--  It only looks for a drafted pawn with any of these shields                -->
       <!--     <li>Apparel_DampeningBelt_Glitterworld</li> 	--> <!--  This would require making a harmony patch of some kind for every mod      -->
       <!-- </affectedShields> -->
        </li>
    </extras>
</li>
				
<!-- Either hardcode modded shields in the modExtension (assuming the mod adding them is required) or use the patch template below -->
<!--
<?xml version="1.0" encoding="utf-8" ?>
<Patch>
    <Operation Class="PatchOperationAdd">
        <xpath>/Defs/ThingDef[defName="Test_Bullet_Extra"]/Extras/li[IgnoreShields="false"]</xpath>
	<value>
	    <affectedShields>
		<li>Apparel_DampeningBelt_Primitive</li>
		<li>Apparel_DampeningBelt_Regular</li>
		<li>Apparel_DampeningBelt_Advanced</li>
	        <li>Apparel_DampeningBelt_Glitterworld</li>
	    </affectedShields>
	</value>
    </Operation>
</Patch>
-->

<!-- Example of a ranged burn DamageDef -->
<DamageDef ParentName="Flame">
    <defName>BurnRanged</defName>
    <label>burn</label>
    <workerClass>DamageWorker_AddInjury</workerClass>
    <isRanged>true</isRanged>
</DamageDef>

Example of a ThingDef with one of the effects:

<ThingDef ParentName="BaseBullet">
    <defName>Test_Bullet_Hediff</defName>
    <label>revolver bullet</label>
    <graphicData>
        <texPath>Things/Projectile/Bullet_Small</texPath>
        <graphicClass>Graphic_Single</graphicClass>
    </graphicData>
    <projectile>
        <damageDef>Bullet</damageDef>
        <damageAmountBase>12</damageAmountBase>
        <stoppingPower>1</stoppingPower>
        <speed>55</speed>
    </projectile>
                    <!-- fun stuff -->
    <thingClass>flangoCore.Projectile_RandomEffectBullet</thingClass>
    <modExtensions>
        <li Class="flangoCore.ModExt_ProjectileRandomEffect">
            <hediffs>
                <li>
                    <hediff>Test_SlowDown_I</hediff>
                    <chance>0.75</chance>
                    <severity>1</severity> <!-- Doesn't matter if there is no severity or stages -->
                </li>
                <li>
		    <hediff>Test_SlowDown_II</hediff>
                    <chance>0.25</chance>
		</li>
	    </hediffs>
	</li>
    </modExtensions>
</ThingDef>	

🦩 Home

🚧 - 404 Page not found.
🖼 - Preview needed.

🟡 - Works but has some TODOs.
🟠 - Basic functionality implemented.
🔴 - Not working properly.
❓ - Not tested.


--== XML ==--

💡 Abilities

General

Ability Givers

Equipment Abilities

🟡 Should recode some stuff 🟡

🌳 Skill Trees

🟠 WIP, work/kill XP gain not implemented 🟠

Defs

Comps

🏘 Buildings

⚙ Comps

🏹 Equipment

General

Weapons

Projectiles

🧪 Hediffs

🧍‍♂‍ Pawn behaviors

📊 Stats

🎲 Misc

🧔 Vanilla Expanded

✨ Debug (Dev Mode)


--== C# ==--

📂 Shared Classes

🧬 Patches


Clone this wiki locally