Skip to content

Swallow Whole

juanosarg edited this page Aug 20, 2021 · 1 revision

Swallow Whole is a comp that allowws an animal to swallow any pawn in a single attack, "storing" it in its stomach. If the animal is killed, it will drop the pawns it has stored inside, albeit damaged. If it fills its stomach and a digestion time passes, everything inside it will die and the pawns will be dropped as skeletons.

To make this code work you'll need to add three things. First of all, the animal needs to have a thingClass tag:

       <thingClass>AnimalBehaviours.Pawn_SwallowWhole</thingClass>

Secondly, you'll need a custom damage for the animal, and remember that you'll need a Maneuvers and a ToolCapacityDef too to link them to the creature's attacks. Alpha Animals example:

        <DamageDef>
		<defName>AA_SwallowWhole</defName>
		<label>swallow whole</label>
		<workerClass>AnimalBehaviours.DamageWorker_SwallowWhole</workerClass>
		<externalViolence>true</externalViolence>
		<deathMessage>{0} has been bitten to death.</deathMessage>
		<hediff>Stab</hediff>
		<hediffSolid>Crack</hediffSolid>
		<harmAllLayersUntilOutside>true</harmAllLayersUntilOutside>
		<impactSoundType>Slice</impactSoundType>
		<armorCategory>Sharp</armorCategory>
	</DamageDef>

Finally, you'll need to add the comp itself to the animal. A lot of configuration options:

        //A comp class that provides parameters for Pawn_SwallowWhole and DamageWorker_SwallowWhole

        //The total amount of prey it can hold inside
        public int stomachCapacity = 5;

        //Animals above this max body size won't be swallowed whole
        public float maximumBodysize = 30;

        //Amount of nutrition the animal will gain by swallowing prey (5 is basically all filled)
        public int nutritionGained = 5;

        //DefName of a Sound played when eating. If null, no sound will play
        public string soundPlayedWhenEating = null;

        //Send a letter when the animal devours a colony-owned pawn
        public bool sendLetterWhenEating = false;
        public string letterLabel = "";
        public string letterText = "";

        //Digestion time in rare ticks
        public int digestionPeriod = 240; // 1 day

        //Create filth around it if killed or otherwise destroyed
        public bool createFilthWhenKilled = false;
        public ThingDef filthToMake = ThingDefOf.Filth_AmnioticFluid;
        //Play sound if killed or otherwise destroyed
        public bool playSoundWhenKilled = false;
        public string soundToPlay = "Hive_Spawn";

How do I use this code?

Besides from all the things mentioned above, to add the comp itself:

<comps>
	<li Class="AnimalBehaviours.CompProperties_SwallowWhole">	
		Whatever configuration tags you want here
	</li>			
</comps>

VFE Core

General Comp classes

General DefModExtensions

Item Processor

PipeSystem

Custom Structure Generation

Multi Verb Combat Framework - MVCF

Animal Behaviours

Genes

Apparel

Cuisine

Furniture

Plants

Deprecated

Clone this wiki locally