CombatExtendedRWMod / CombatExtended

Combat Extended mod for RimWorld
128 stars 91 forks source link

Create custom RulePackDefs for CE verbs #362

Open Alicecomma opened 6 years ago

Alicecomma commented 6 years ago

This can be done for many of the verbs and under several circumstances.

Alicecomma commented 4 years ago

XML: RulePackDefs should be written as indicated. See "RulePackDefs/DamageEvent_CookOff.xml" C#: new RulePackDefs should be referenced instead of vanilla RulePackDefs. See "Projectiles/BulletCE.cs":

//The following code excludes turrets etcetera from having cook off projectile impacts recorded in their combat log.
//If it is necessary to add cook off to turret logs, a new BattleLogEntry_ must be created, because BattleLogEntry_DamageTaken,
//which is the only method capable of handling cookoff and only using pawns, can not take !(hitThing is Pawn).
if (cookOff && hitThing is Pawn)
{
    logEntry =
        new BattleLogEntry_DamageTaken(
            (Pawn)hitThing,
            DefDatabase<RulePackDef>.GetNamed("DamageEvent_CookOff"));
    Find.BattleLog.Add(logEntry);
}