Jump to content
--MUXOMOR--

привет всем, помогите с хп одеждой при спавне на персонаже. где менять целостность одежды? с лутом вроде разобрался всё работает.а где и как хп вещей поправить незнаю(

Recommended Posts

Spoiler

void main()
{
	//INIT ECONOMY--------------------------------------
	Hive ce = CreateHive();
	if ( ce )
		ce.InitOffline();

	//DATE RESET AFTER ECONOMY INIT-------------------------
	int year, month, day, hour, minute;
	int reset_month = 9, reset_day = 20;
	GetGame().GetWorld().GetDate(year, month, day, hour, minute);

	if ((month == reset_month) && (day < reset_day))
	{
		GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
	}
	else
	{
		if ((month == reset_month + 1) && (day > reset_day))
		{
			GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
		}
		else
		{
			if ((month < reset_month) || (month > reset_month + 1))
			{
				GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
			}
		}
	}
}

class CustomMission: MissionServer
{
	void SetRandomHealth(EntityAI itemEnt)
	{
		if ( itemEnt )
		{
			float rndHlt = Math.RandomFloat( 0.45, 0.65 );
			itemEnt.SetHealth01( "", "", rndHlt );
		}
	}

	override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
	{
		Entity playerEnt;
        playerEnt = GetGame().CreatePlayer(identity, characterName, pos, 0, "NONE");//Creates random player
        Class.CastTo(m_player, playerEnt);

        GetGame().SelectPlayer(identity, m_player);

        m_player.SetHealth("GlobalHealth", "Health", 35); //в процентах
        m_player.SetHealth("GlobalHealth", "Blood", 3500);//кровь
        m_player.GetStatEnergy().Set(400);//еда
        m_player.GetStatWater().Set(500);//вода
        
        return m_player;
	}

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

		itemClothing = player.FindAttachmentBySlotName( "Body" );
		if ( itemClothing )
			player.RemoveAllItems();
		player.GetInventory().CreateInInventory("GP5GasMask");// противогаз
		player.GetInventory().CreateInInventory("NBCHoodYellow"); //Капюшон NBC желтый
		player.GetInventory().CreateInInventory("NBCGlovesYellow");//Перчатки NBC желтые
        player.GetInventory().CreateInInventory("NBCJacketYellow");//Куртка NBC желтая
        player.GetInventory().CreateInInventory("NBCPantsYellow");//Брюки NBC Желтые
        player.GetInventory().CreateInInventory("NBCBootsYellow");//Ботинки NBC Желтые
		{
			SetRandomHealth( itemClothing );
			
			string chemlightArray[] = { "Chemlight_White", "Chemlight_Yellow", "Chemlight_Green", "Chemlight_Red" };
			int rndIndex = Math.RandomInt( 0, 4 );
			itemEnt = itemClothing.GetInventory().CreateInInventory( chemlightArray[rndIndex] );
			SetRandomHealth( itemEnt );
			player.SetQuickBarEntityShortcut(itemEnt, 1);

			rand = Math.RandomFloatInclusive( 0.0, 1.0 );
			if ( rand < 0.35 )
				itemEnt = player.GetInventory().CreateInInventory( "Apple" );
			else if ( rand > 0.65 )
				itemEnt = player.GetInventory().CreateInInventory( "Pear" );
			else
				itemEnt = player.GetInventory().CreateInInventory( "Plum" );

			player.SetQuickBarEntityShortcut(itemEnt, 3);
						// нож
                itemEnt = player.GetInventory().CreateInInventory("SteakKnife");
				        //НАВИГАТОР
				itemEnt = player.GetInventory().CreateInInventory("GPSReceiver");
                itemEnt = player.GetInventory().CreateInInventory("BandageDressing");
			SetRandomHealth( itemEnt );
		}
		
		itemClothing = player.FindAttachmentBySlotName( "Legs" );
		if ( itemClothing )
			SetRandomHealth( itemClothing );
		
		itemClothing = player.FindAttachmentBySlotName( "Feet" );
	}
};

Mission CreateCustomMission(string path)
{
	return new CustomMission();
}

 

 

Share this post


Link to post
Share on other sites
On 7/23/2024 at 4:30 PM, --MUXOMOR-- said:
  Hide contents


void main()
{
	//INIT ECONOMY--------------------------------------
	Hive ce = CreateHive();
	if ( ce )
		ce.InitOffline();

	//DATE RESET AFTER ECONOMY INIT-------------------------
	int year, month, day, hour, minute;
	int reset_month = 9, reset_day = 20;
	GetGame().GetWorld().GetDate(year, month, day, hour, minute);

	if ((month == reset_month) && (day < reset_day))
	{
		GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
	}
	else
	{
		if ((month == reset_month + 1) && (day > reset_day))
		{
			GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
		}
		else
		{
			if ((month < reset_month) || (month > reset_month + 1))
			{
				GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
			}
		}
	}
}

class CustomMission: MissionServer
{
	void SetRandomHealth(EntityAI itemEnt)
	{
		if ( itemEnt )
		{
			float rndHlt = Math.RandomFloat( 0.45, 0.65 );
			itemEnt.SetHealth01( "", "", rndHlt );
		}
	}

	override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
	{
		Entity playerEnt;
        playerEnt = GetGame().CreatePlayer(identity, characterName, pos, 0, "NONE");//Creates random player
        Class.CastTo(m_player, playerEnt);

        GetGame().SelectPlayer(identity, m_player);

        m_player.SetHealth("GlobalHealth", "Health", 35); //в процентах
        m_player.SetHealth("GlobalHealth", "Blood", 3500);//кровь
        m_player.GetStatEnergy().Set(400);//еда
        m_player.GetStatWater().Set(500);//вода
        
        return m_player;
	}

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

		itemClothing = player.FindAttachmentBySlotName( "Body" );
		if ( itemClothing )
			player.RemoveAllItems();
		player.GetInventory().CreateInInventory("GP5GasMask");// противогаз
		player.GetInventory().CreateInInventory("NBCHoodYellow"); //Капюшон NBC желтый
		player.GetInventory().CreateInInventory("NBCGlovesYellow");//Перчатки NBC желтые
        player.GetInventory().CreateInInventory("NBCJacketYellow");//Куртка NBC желтая
        player.GetInventory().CreateInInventory("NBCPantsYellow");//Брюки NBC Желтые
        player.GetInventory().CreateInInventory("NBCBootsYellow");//Ботинки NBC Желтые
		{
			SetRandomHealth( itemClothing );
			
			string chemlightArray[] = { "Chemlight_White", "Chemlight_Yellow", "Chemlight_Green", "Chemlight_Red" };
			int rndIndex = Math.RandomInt( 0, 4 );
			itemEnt = itemClothing.GetInventory().CreateInInventory( chemlightArray[rndIndex] );
			SetRandomHealth( itemEnt );
			player.SetQuickBarEntityShortcut(itemEnt, 1);

			rand = Math.RandomFloatInclusive( 0.0, 1.0 );
			if ( rand < 0.35 )
				itemEnt = player.GetInventory().CreateInInventory( "Apple" );
			else if ( rand > 0.65 )
				itemEnt = player.GetInventory().CreateInInventory( "Pear" );
			else
				itemEnt = player.GetInventory().CreateInInventory( "Plum" );

			player.SetQuickBarEntityShortcut(itemEnt, 3);
						// нож
                itemEnt = player.GetInventory().CreateInInventory("SteakKnife");
				        //НАВИГАТОР
				itemEnt = player.GetInventory().CreateInInventory("GPSReceiver");
                itemEnt = player.GetInventory().CreateInInventory("BandageDressing");
			SetRandomHealth( itemEnt );
		}
		
		itemClothing = player.FindAttachmentBySlotName( "Legs" );
		if ( itemClothing )
			SetRandomHealth( itemClothing );
		
		itemClothing = player.FindAttachmentBySlotName( "Feet" );
	}
};

Mission CreateCustomMission(string path)
{
	return new CustomMission();
}

 

 

[EN]

First of all, use English on this forum! If you are not familiar with English - Yandex/Google translate will help you.

2nd - you can process it inside init.c  (event StartingEquipSetup) where you're assigned it to the player unit. The simplest way is using Slots approach. What do I mean: get item from players slot, if item is not NULL -> change health, else -> do nothing or create new item I just don't know it's your business.
The variant with the solution based on yours code will be beelow.

[RU]

Во-первых, используй только английский на этом форуме! Если не знаешь языка - Google/Yandex переводчики тебе в помощь.

Во-вторых, ты можешь обработать это (одежду) через init.c (событие StartingEquipSetup), где ты можешь обработать инвентарь игрока. Самый простой подход - использовать систему Слотов. То есть - берёшь предмет из слота, если он не NULL (существует) -> делаешь с ним что хочешь, иначе -> ничего с ним не делаешь или создаёшь нужный по твоему мнению предмет, но я не знаю что тебе конкретно нужно будет сделать - это уже твои проблемы. пример варианта решения проблемы на базе твоего кода ниже.

// Change Health of objects / даём жизнь объектам на персонаже
EntityAI object = player.FindAttachmentBySlotName("Feet"); // will start from bottom so slot Feets / начнм сконца - слот ноги
object.SetHealth(itemClothing.GetMaxHealth("", ""));    // set max health / ставим макс состояние
object.SetHealth01("", "", itemClothing.GetMaxHealth("", "")); // and we also need add health to damage zones. / уменьшим урон у дамаг зон

object = player.FindAttachmentBySlotName("Legs");    // fix the pants / фиксим штаны
object.SetHealth(itemClothing.GetMaxHealth("", ""));    // set max health / ставим макс состояние
object.SetHealth01("", "", itemClothing.GetMaxHealth("", "")); // and we also need add health to damage zones. / уменьшим урон у дамаг зон

object = player.FindAttachmentBySlotName("Body");    // set max health / ставим макс состояние
object.SetHealth(itemClothing.GetMaxHealth("", ""));    // set max health / ставим макс состояние
object.SetHealth01("", "", itemClothing.GetMaxHealth("", ""));

// And so on, so on, go on... / И тд и тп.

Edited by Sid Debian

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

×