Jump to content

Forums Announcement

Read-Only Mode for Announcements & Changelogs

Dear Survivors, we'd like to inform you that this forum will transition to read-only mode. From now on, it will serve exclusively as a platform for official announcements and changelogs.

For all community discussions, debates, and engagement, we encourage you to join us on our social media platforms: Discord, Twitter/X, Facebook.

Thank you for being a valued part of our community. We look forward to connecting with you on our other channels!

Stay safe out there,
Your DayZ Team

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

×