Skip to content

Drop on Death

juanosarg edited this page Jun 9, 2021 · 1 revision

CompDropOnDeath is a comp class that makes an animal drop a resource on death, with a configurable drop chance. It is also customizable to produce a random item.

    //CompDropOnDeath makes an animal drop a resource when killed

    public int resourceAmount = 1;
    public string resourceDef = null;
    public float dropChance = 1f;

    //CompProperties_DropOnDeath allows an animal to produce random items

    public bool isRandom = false;
    public List<string> randomItems = null;

How do I use this code?

It is a comp class, so you just add it in XML in the <comps> tag.

You will ALSO need to add a DeathActionWorker, or the comp class by itself won't do anything at all. The comp class is merely used to pass parameters.

For example, this allows an Agaripawn to sometimes drop agarilux mushrooms on death

<comps>
	<li Class="AnimalBehaviours.CompProperties_DropOnDeath">
		<resourceDef>AA_AgariluxRawFungus</resourceDef>
		<resourceAmount>1</resourceAmount>
		<dropChance>0.5</dropChance>			
	</li>
</comps>

It also needs AnimalBehaviours.DeathActionWorker_DropOnDeath on its tag

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