Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • Need help?

    Create a topic in the appropriate section
    Don't write everything in the chat!
  • Take a look at the marketplace

    There you can buy
    everything related to game servers
  • Don't want a ban?

    Please read our rules
    Don't disturb the order!
  • Sell or buy?

    Use services of the guarantor
    We will make your deal safe
  • 0
Sign in to follow this  
FreddyCruger

Инсерт агента Холеры

На примере скрипта обыска трупов (из модa SearchTheCorpes), хочу добавить возможность чтобы при обыске без перчаток, персонаж заболевал холерой.
На мой взгляд вроде все сделал правильно, но сервер не запускается с ошибкой "Cant compile...."

Вот сам код, то что добавил я, помечено комментом  //ДОБАВИЛ//

class ActionSearchTheCorpseCB : ActionContinuousBaseCB
{
    override void CreateActionComponent()
    {
    	float timer = GetTimer(m_ActionData.m_Player, PlayerBase.Cast(m_ActionData.m_Target.GetObject() ) );
        m_ActionData.m_ActionComponent = new CAContinuousTime(timer);
    }

    float GetTimer(PlayerBase _player, PlayerBase _target)
	{
		int cargoCount = 0;
		int timeForEachItem = 0;

		GetItemCargoCount(cargoCount, _target);

		if(_player.stcConfig)
		{
			if(_player.stcConfig.AddTimeForEachItem)
			{
				timeForEachItem = _player.stcConfig.TimeForEachItem;
			}

			return _player.stcConfig.DefaultTimeToSearchPlayer + (timeForEachItem * cargoCount);
		}

		return 10;
	}

	void GetItemCargoCount(out int cargoCount, PlayerBase _player )
	{
		int attCount = _player.GetHumanInventory().AttachmentCount();
		CargoBase cargo = null;
		//! go thru the each attachment slot and check cargo count
		for(int attIdx = 0; attIdx < attCount; attIdx++)
		{
			EntityAI attachment = _player.GetInventory().GetAttachmentFromIndex(attIdx);
			int attachmentSlot = attachment.GetInventory().GetSlotId(0);
			if( attachment.GetInventory() )
			{
				cargo = attachment.GetInventory().GetCargo();
				if( cargo )
				{
					cargoCount += cargo.GetItemCount();
				}
			}
			
		}
		
		return;
	}
};
class ActionSearchTheCorpseZombieCB : ActionContinuousBaseCB
{
    override void CreateActionComponent()
    {
    	float timer = GetTimer(m_ActionData.m_Player, EntityAI.Cast(m_ActionData.m_Target.GetObject() ) );
        m_ActionData.m_ActionComponent = new CAContinuousTime(timer);
    }

    float GetTimer(PlayerBase _player, EntityAI _target)
	{
		int cargoCount = 0;
		int timeForEachItem = 0;
		
		GetItemCargoCount(cargoCount, _target);

		if(_player.stcConfig)
		{
			if(_player.stcConfig.AddTimeForEachItem)
			{
				timeForEachItem = _player.stcConfig.TimeForEachItem;
			}

			return _player.stcConfig.DefaultTimeToSearchZombie + (timeForEachItem * cargoCount);
		}

		return 10;
	}

	void GetItemCargoCount(out int cargoCount, EntityAI entity )
	{
		CargoBase cargo = null;
		if(entity.GetInventory())
		{
			cargo = entity.GetInventory().GetCargo();

			if (cargo)
			{
				cargoCount = cargo.GetItemCount();
				return;
			}
		}

	}
	
	override void ApplyModifiers( ActionData action_data ) //ДОБАВИЛ 
	{
	PluginLifespan module_lifespan = PluginLifespan.Cast( GetPlugin( PluginLifespan ) );//ДОБАВИЛ 
				if( module_lifespan )//ДОБАВИЛ 
				{
					module_lifespan.UpdateBloodyHandsVisibility( action_data.m_Player, true );//ДОБАВИЛ 
				}
			}
		}
	}//ДОБАВИЛ 
};

class ActionSearchTheCorpse : ActionContinuousBase
{
	
    
    void ActionSearchTheCorpse()
    {
       	m_CallbackClass = ActionSearchTheCorpseCB;
		m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_CRAFTING;
		m_FullBody = true;
		m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
    }
    
    override void CreateConditionComponents()  
    {   
        m_ConditionItem = new CCINone;
		m_ConditionTarget = new DeA_CCTMan(UAMaxDistances.DEFAULT,false);
    }

	override typename GetInputType()
	{
		return ContinuousInteractActionInput;
	}
	
    override string GetText()
    {
        return "#STR_DeA_ActionSearchTheCorpse";
    }

    override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
    {
        EntityAI targetEntity = EntityAI.Cast(target.GetObject());

        if (targetEntity && targetEntity.IsPlayer())
        {
            PlayerBase targetPlayer = PlayerBase.Cast(target.GetObject());

            if (!targetEntity.IsAlive() && !targetPlayer.GetDeAIsSearching(player.GetID()))
            {
                return true;
            }
        }
		
        return false;
    }

    override void OnFinishProgressServer(ActionData action_data)
    {
        PlayerBase targetPlayer = PlayerBase.Cast(action_data.m_Target.GetObject());
		targetPlayer.SetDeAArraySeatchingId(action_data.m_Player.GetID());
		
    }

    override void OnFinishProgressClient(ActionData action_data) //ДОБАВИЛ 
    {
        PlayerBase targetPlayer = PlayerBase.Cast(action_data.m_Target.GetObject()); //ДОБАВИЛ 
		targetPlayer.SetDeAArraySeatchingId(action_data.m_Player.GetID()); //ДОБАВИЛ 
		if ( action_data.m_Player.HasBloodyHands() && !action_data.m_Player.GetInventory().FindAttachment( InventorySlots.GLOVES ) ) //ДОБАВИЛ 
		{
			action_data.m_Player.SetBloodyHandsPenalty(); //ДОБАВИЛ 
		}
    }
};

class ActionSearchTheCorpseZombie : ActionContinuousBase
{
    
    void ActionSearchTheCorpseZombie()
    {
       	m_CallbackClass = ActionSearchTheCorpseZombieCB;
		m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_CRAFTING;
		m_FullBody = true;
		m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
    }
    
    override void CreateConditionComponents()  
    {   
        m_ConditionItem = new CCINone;
		m_ConditionTarget = new DeA_CCTZombie(UAMaxDistances.DEFAULT);
    }

	override typename GetInputType()
	{
		return ContinuousInteractActionInput;
	}
	
    override string GetText()
    {
        return "#STR_DeA_ActionSearchTheCorpse";
    }

    override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
    {
        EntityAI targetEntity = EntityAI.Cast(target.GetObject());

		if (targetEntity && (targetEntity.IsZombie() || targetEntity.IsZombieMilitary() ) )
        {
			ZombieBase targetZombie = ZombieBase.Cast(target.GetObject());
            
            if (!targetZombie.IsAlive() && !targetZombie.GetDeAIsSearching(player.GetID()))
            {
                return true;
            }
        }
        return false;
    }

    override void OnFinishProgressServer(ActionData action_data)
    {
        ZombieBase targetZombie = ZombieBase.Cast(action_data.m_Target.GetObject());
		targetZombie.SetDeAArraySeatchingId(action_data.m_Player.GetID());
		
    }
	override void OnEndAnimationLoopServer( ActionData action_data ) //ДОБАВИЛ 
	{
		//Print("OnEndAnimationLoopServer");  //ДОБАВИЛ 
		if(action_data.m_Player.HasBloodyHands()) //ДОБАВИЛ 
		{
			action_data.m_Player.InsertAgent(eAgents.CHOLERA, 10); //ДОБАВИЛ 
		}
	}
};

class DeA_CCTZombie : CCTBase
{
	protected float m_MaximalActionDistanceSq;
	protected bool m_MustBeAlive;
	
	void DeA_CCTZombie ( float maximal_target_distance )
	{
		m_MaximalActionDistanceSq = maximal_target_distance * maximal_target_distance;	
	}
	
	override bool Can( PlayerBase player, ActionTarget target )
	{	
		if( !target )
			return false;
		
		Object targetObject = target.GetObject();
		if ( !player || !targetObject || targetObject == player || !targetObject.IsMan() )
		{
			EntityAI entityAI = EntityAI.Cast(targetObject);
			if( !entityAI.IsZombie() && !entityAI.IsZombieMilitary())
				return false;
		}
		
		return ( vector.DistanceSq(targetObject.GetPosition(), player.GetPosition()) <= m_MaximalActionDistanceSq );
	}
};

class DeA_CCTMan : CCTBase
{
	protected float m_MaximalActionDistanceSq;
	protected bool m_MustBeAlive;
	
	void DeA_CCTMan ( float maximal_target_distance, bool must_be_alive = true )
	{
		m_MaximalActionDistanceSq = maximal_target_distance * maximal_target_distance;	
		m_MustBeAlive = must_be_alive;
	}
	
	override bool Can( PlayerBase player, ActionTarget target )
	{	
		if( !target )
			return false;
		
		Object targetObject = target.GetObject();
		if ( !player || !targetObject || targetObject == player || !targetObject.IsMan() || ( m_MustBeAlive && targetObject.IsDamageDestroyed() ) )
			return false;
		
		return ( vector.DistanceSq(targetObject.GetPosition(), player.GetPosition()) <= m_MaximalActionDistanceSq );
	}
};

Знатоки скриптинга, дайте пожалуйста хотя бы намек, чяднт?

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

А тебя не смутило?

action_data.m_Player.SetBloodyHandsPenalty

 

Share this post


Link to post
Share on other sites



  • 0

1082154802_.png.0327f047990d94c844ac0b09c2e4df82.png
Тут такой же прикол, с кровавыми руками + фигурные скобки закрыты, но не открыты.

Попробуй паковать микерой, насколько я помню, то там такую дичь легко палит.

Share this post


Link to post
Share on other sites
  • 0
6 часов назад, Yuki сказал:

Попробуй паковать микерой

давно думал разобраться с ней, спасибо за наводку

Share this post


Link to post
Share on other sites
  • 0

поправил в общем скрипт, сервер запускается без ошибки, но при обыске без перчаток перс не заболевает холерой, сколько бы раз этого не делал и пропало отображение инвентаря зомби после обыска). В общем взялся я за дело, в котором мало еще чего понимаю. Прошу помочь.

class ActionSearchTheCorpseCB : ActionContinuousBaseCB
{
    override void CreateActionComponent()
    {
    	float timer = GetTimer(m_ActionData.m_Player, PlayerBase.Cast(m_ActionData.m_Target.GetObject() ) );
        m_ActionData.m_ActionComponent = new CAContinuousTime(timer);
    }

    float GetTimer(PlayerBase _player, PlayerBase _target)
	{
		int cargoCount = 0;
		int timeForEachItem = 0;

		GetItemCargoCount(cargoCount, _target);

		if(_player.stcConfig)
		{
			if(_player.stcConfig.AddTimeForEachItem)
			{
				timeForEachItem = _player.stcConfig.TimeForEachItem;
			}

			return _player.stcConfig.DefaultTimeToSearchPlayer + (timeForEachItem * cargoCount);
		}

		return 10;
	}

	void GetItemCargoCount(out int cargoCount, PlayerBase _player )
	{
		int attCount = _player.GetHumanInventory().AttachmentCount();
		CargoBase cargo = null;
		//! go thru the each attachment slot and check cargo count
		for(int attIdx = 0; attIdx < attCount; attIdx++)
		{
			EntityAI attachment = _player.GetInventory().GetAttachmentFromIndex(attIdx);
			int attachmentSlot = attachment.GetInventory().GetSlotId(0);
			if( attachment.GetInventory() )
			{
				cargo = attachment.GetInventory().GetCargo();
				if( cargo )
				{
					cargoCount += cargo.GetItemCount();
				}
			}
			
		}
		
		return;
	}
};
class ActionSearchTheCorpseZombieCB : ActionContinuousBaseCB
{
    override void CreateActionComponent()
    {
    	float timer = GetTimer(m_ActionData.m_Player, EntityAI.Cast(m_ActionData.m_Target.GetObject() ) );
        m_ActionData.m_ActionComponent = new CAContinuousTime(timer);
    }

    float GetTimer(PlayerBase _player, EntityAI _target)
	{
		int cargoCount = 0;
		int timeForEachItem = 0;
		
		GetItemCargoCount(cargoCount, _target);

		if(_player.stcConfig)
		{
			if(_player.stcConfig.AddTimeForEachItem)
			{
				timeForEachItem = _player.stcConfig.TimeForEachItem;
			}

			return _player.stcConfig.DefaultTimeToSearchZombie + (timeForEachItem * cargoCount);
		}

		return 10;
	}

	void GetItemCargoCount(out int cargoCount, EntityAI entity )
	{
		CargoBase cargo = null;
		if(entity.GetInventory())
		{
			cargo = entity.GetInventory().GetCargo();

			if (cargo)
			{
				cargoCount = cargo.GetItemCount();
				return;
			}
		}

	}
	
	void ApplyModifiers( ActionData action_data ) //ДОБАВИЛ 
	{
	PluginLifespan module_lifespan = PluginLifespan.Cast( GetPlugin( PluginLifespan ) );//ДОБАВИЛ 
				if( module_lifespan )//ДОБАВИЛ 
				{
					module_lifespan.UpdateBloodyHandsVisibility( action_data.m_Player, true );//ДОБАВИЛ 
				}
	}
		
	//ДОБАВИЛ 
};

class ActionSearchTheCorpse : ActionContinuousBase
{
	
    
    void ActionSearchTheCorpse()
    {
       	m_CallbackClass = ActionSearchTheCorpseCB;
		m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_CRAFTING;
		m_FullBody = true;
		m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
    }
    
    override void CreateConditionComponents()  
    {   
        m_ConditionItem = new CCINone;
		m_ConditionTarget = new DeA_CCTMan(UAMaxDistances.DEFAULT,false);
    }

	override typename GetInputType()
	{
		return ContinuousInteractActionInput;
	}
	
    override string GetText()
    {
        return "#STR_DeA_ActionSearchTheCorpse";
    }

    override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
    {
        EntityAI targetEntity = EntityAI.Cast(target.GetObject());

        if (targetEntity && targetEntity.IsPlayer())
        {
            PlayerBase targetPlayer = PlayerBase.Cast(target.GetObject());

            if (!targetEntity.IsAlive() && !targetPlayer.GetDeAIsSearching(player.GetID()))
            {
                return true;
            }
        }
		
        return false;
    }

    override void OnFinishProgressServer(ActionData action_data)
    {
        PlayerBase targetPlayer = PlayerBase.Cast(action_data.m_Target.GetObject());
		targetPlayer.SetDeAArraySeatchingId(action_data.m_Player.GetID());
		
    }

    override void OnFinishProgressClient(ActionData action_data) //ДОБАВИЛ 
    {
        PlayerBase targetPlayer = PlayerBase.Cast(action_data.m_Target.GetObject()); //ДОБАВИЛ 
		targetPlayer.SetDeAArraySeatchingId(action_data.m_Player.GetID()); //ДОБАВИЛ 
		if ( action_data.m_Player.HasBloodyHands() && !action_data.m_Player.GetInventory().FindAttachment( InventorySlots.GLOVES ) ) //ДОБАВИЛ 
		{
			action_data.m_Player.SetBloodyHandsPenalty(); //ДОБАВИЛ 
		}
    }
};

class ActionSearchTheCorpseZombie : ActionContinuousBase
{
    
    void ActionSearchTheCorpseZombie()
    {
       	m_CallbackClass = ActionSearchTheCorpseZombieCB;
		m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_CRAFTING;
		m_FullBody = true;
		m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
    }
    
    override void CreateConditionComponents()  
    {   
        m_ConditionItem = new CCINone;
		m_ConditionTarget = new DeA_CCTZombie(UAMaxDistances.DEFAULT);
    }

	override typename GetInputType()
	{
		return ContinuousInteractActionInput;
	}
	
    override string GetText()
    {
        return "#STR_DeA_ActionSearchTheCorpse";
    }

    override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
    {
        EntityAI targetEntity = EntityAI.Cast(target.GetObject());

		if (targetEntity && (targetEntity.IsZombie() || targetEntity.IsZombieMilitary() ) )
        {
			ZombieBase targetZombie = ZombieBase.Cast(target.GetObject());
            
            if (!targetZombie.IsAlive() && !targetZombie.GetDeAIsSearching(player.GetID()))
            {
                return true;
            }
        }
        return false;
    }

    override void OnFinishProgressServer(ActionData action_data)
    {
        ZombieBase targetZombie = ZombieBase.Cast(action_data.m_Target.GetObject());
		targetZombie.SetDeAArraySeatchingId(action_data.m_Player.GetID());
		
    }
	override void OnEndAnimationLoopServer( ActionData action_data ) //ДОБАВИЛ 
	{
		//Print("OnEndAnimationLoopServer");  //ДОБАВИЛ 
		if(action_data.m_Player.HasBloodyHands()) //ДОБАВИЛ 
		{
			action_data.m_Player.InsertAgent(eAgents.CHOLERA, 10); //ДОБАВИЛ 
		}
	}
};

class DeA_CCTZombie : CCTBase
{
	protected float m_MaximalActionDistanceSq;
	protected bool m_MustBeAlive;
	
	void DeA_CCTZombie ( float maximal_target_distance )
	{
		m_MaximalActionDistanceSq = maximal_target_distance * maximal_target_distance;	
	}
	
	override bool Can( PlayerBase player, ActionTarget target )
	{	
		if( !target )
			return false;
		
		Object targetObject = target.GetObject();
		if ( !player || !targetObject || targetObject == player || !targetObject.IsMan() )
		{
			EntityAI entityAI = EntityAI.Cast(targetObject);
			if( !entityAI.IsZombie() && !entityAI.IsZombieMilitary())
				return false;
		}
		
		return ( vector.DistanceSq(targetObject.GetPosition(), player.GetPosition()) <= m_MaximalActionDistanceSq );
	}
};

class DeA_CCTMan : CCTBase
{
	protected float m_MaximalActionDistanceSq;
	protected bool m_MustBeAlive;
	
	void DeA_CCTMan ( float maximal_target_distance, bool must_be_alive = true )
	{
		m_MaximalActionDistanceSq = maximal_target_distance * maximal_target_distance;	
		m_MustBeAlive = must_be_alive;
	}
	
	override bool Can( PlayerBase player, ActionTarget target )
	{	
		if( !target )
			return false;
		
		Object targetObject = target.GetObject();
		if ( !player || !targetObject || targetObject == player || !targetObject.IsMan() || ( m_MustBeAlive && targetObject.IsDamageDestroyed() ) )
			return false;
		
		return ( vector.DistanceSq(targetObject.GetPosition(), player.GetPosition()) <= m_MaximalActionDistanceSq );
	}
};

 

Share this post


Link to post
Share on other sites
  • 0

Поменял функцию, подскажите почему она не срабатывает? Не открывается кровотечение без перчаток и не появляется рвота без маски?

override void OnFinishProgressServer(ActionData action_data)
    {
        PlayerBase targetPlayer = PlayerBase.Cast(action_data.m_Target.GetObject());
		targetPlayer.SetDeAArraySeatchingId(action_data.m_Player.GetID());
		
		EntityAI gloves = action_data.m_Player.GetInventory().FindAttachment(InventorySlots.GLOVES);

			if( gloves && gloves.GetHealthLevel() < 4 )
			{
				gloves.AddHealth("","", -3);	
					
				action_data.m_Player.GetSoftSkillsManager().AddSpecialty( m_SpecialtyWeight );
			}
				
			if ( !gloves || gloves.IsRuined() )
			{
				if(	Math.RandomFloat01() < 0.50) //0.25 default
				{
					if(Math.RandomFloat01() < 0.75)
					{
						if(action_data.m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("LeftForeArmRoll"))
						{
							//SendSoundEvent(EPlayerSoundEventID.INJURED_LIGHT);
						}
					}
					else
					{
						if(action_data.m_Player.GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("RightForeArmRoll"))
						{
							//SendSoundEvent(EPlayerSoundEventID.INJURED_LIGHT);
						}
					}
				}	
			}	
		//Chance to vomit from if no Gasmask on
		EntityAI mask = action_data.m_Player.GetInventory().FindAttachment(InventorySlots.MASK);

		if ( !mask || mask.IsRuined() )
		{
			if( Math.RandomFloat01() < 0.20 ) //Less than 20% chance to vomit if not wearing a mask 
			{
				SymptomBase symptom = action_data.m_Player.GetSymptomManager().QueueUpPrimarySymptom(SymptomIDs.SYMPTOM_VOMIT);
			
				if( symptom )
				{
					symptom.SetDuration(5);

					if (action_data.m_Player.GetStatWater().Get() > (70))
						action_data.m_Player.GetStatWater().Add(-1 * 70);
					if (action_data.m_Player.GetStatEnergy().Get() > (55))
						action_data.m_Player.GetStatEnergy().Add(-1 * 55);
				
				}
	
			string messageSick = string.Format("Такая ужасная вонь, что тебя стошнило!");
			sendPlayerMessage(action_data.m_Player, messageSick);
			}
		}
		action_data.m_Player.GetSoftSkillsManager()
			
    }

 

Edited by FreddyCruger (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you automaticly agree to our Guidelines and Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.