Jump to content
Futurist

Editing fresh spawn inventory in init.c?

Recommended Posts

I'm wanting to add a few items to the inventory of fresh spawns. Namely an orange taloon bag, hunting knife, bottle of water, and a can of beans. I've found a few guides for this but the code doesn't look at all the same and they're from pre 1.06 versions of the game. Anyone know how to do this or of a current guide or tool?

Share this post


Link to post
Share on other sites

It's contained within the init.c file. 

Just follow the structure of the code already there and use the types.xml file to track down the class names of the items you want and add them.

Using a program like sublime text editor will help with editing as it colours everything and makes it much easier to read.

Share this post


Link to post
Share on other sites

So I got all of the desired items added to fresh spawn inventory except the taloon bag.  I'm guessing its because the bag would need to go into the backpack slot and doesn't fit in either clothing article on the character.  I'll try the older string of code from previous versions and play around with it for the bag.  The important bits are working being the food and water.  Here's the code:  

override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
	{
		EntityAI itemTop;
		EntityAI itemEnt;
		ItemBase itemBs;
		float rand;

		itemTop = player.FindAttachmentBySlotName("Body");

		if ( itemTop )
		{
			itemEnt = itemTop.GetInventory().CreateInInventory("Rag");
			if ( Class.CastTo(itemBs, itemEnt ) )
				itemBs.SetQuantity(6);

			SetRandomHealth(itemEnt);

			itemEnt = itemTop.GetInventory().CreateInInventory("TaloonBag_Orange");
			if ( Class.CastTo(itemBs, itemEnt ) )
				itemBs.SetQuantity(1);

			itemEnt = itemTop.GetInventory().CreateInInventory("WaterBottle");
			if ( Class.CastTo(itemBs, itemEnt ) )
				itemBs.SetQuantity(1);

			itemEnt = itemTop.GetInventory().CreateInInventory("BakedBeansCan");
			if ( Class.CastTo(itemBs, itemEnt ) )
				itemBs.SetQuantity(1);

			itemEnt = itemTop.GetInventory().CreateInInventory("HuntingKnife");
			if ( Class.CastTo(itemBs, itemEnt ) )
				itemBs.SetQuantity(1);


			string chemlightArray[] = { "Chemlight_White", "Chemlight_Yellow", "Chemlight_Green", "Chemlight_Red" };
			int rndIndex = Math.RandomInt(0, 4);
			itemEnt = itemTop.GetInventory().CreateInInventory(chemlightArray[rndIndex]);
			SetRandomHealth(itemEnt);
		}
	}
};

 

Share this post


Link to post
Share on other sites

Hey @futurist

I've got the same task to accomplish myself, new to DayZ modding but modded before.

Do you just override `StartingEquipSetup` in a new file in a mod folder?

Cheers!

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×