These are something I added to my server that people can buy in the shop so they can spawn an enemy, if you are adding to a public server, you probably will want to add code that prevents you from spawning it anywhere, and etc. or else people will be killing other people by spawning on top of them lol
What I would do: Make it so you can only use it an a map you add, called "Spawn Room" or something, and on spawn the entity has stasis effect for X seconds or so, so people have time to react just in case, even though when in the "Spawn Room" everyone should know the danger they are in since anyone in there could be capable of spawning something.
In Db>Data>Descriptors.cs in the ActivateEffects enum (ctrl+f to find it easily) add "
SpawnMedusa" for example at the bottom and don't forget to add a comma after the 2nd to last one since you're adding a new ActivateEffect
Then in Player.UseItem.cs add this code somewhere with the other ActivateEffects as long as its not interfering with another one
Code:
case ActivateEffects.SpawnMedusa:
{
Entity entity = Entity.Resolve(Manager, 0x654); //"0x654" is the object ID of what you want to spawn when you consume item
entity.Move(X, Y); //this spawns the item wherever you are
Owner.EnterWorld(entity); //this makes it spawn basically in the world you are in
}
break;
now add the xml of the item, lets name is "Medusa Egg" for example, this xml should work its just using the health potion texture lol
the bolded line in the XML is what you must add if adding more spawner items, thats what makes it activate the code youll add in useitem which spawns the enemy, youll also need </consumable> in the xml, you're better off just copying this xml and changing the name in <Activate> to the name of your code in ActivateEffect enum and the desc. and texture and name and id obviously.
Code:
<Object type="0xba29" id="Medusa Egg">
<Class>Equipment</Class>
<Item/>
<Texture>
<File>lofiObj2</File>
<Index>0x32</Index>
</Texture>
<SlotType>10</SlotType>
<Tier>1</Tier>
<Description>An egg that spawns a Medusa on consume!</Description>
<Sound>use_potion</Sound>
<Activate>SpawnMedusa</Activate>
<Consumable/>
<Potion/>
<BagType>0</BagType>
<feedPower>5</feedPower>
<DisplayId>Medusa Egg</DisplayId>
</Object>