Jump to content
Sign in to follow this  
Mr. Perkson

Action Skinning Moddification Problem

Recommended Posts

So here's my code i tried to create a script that overrides action skinning for defined creatures animal and zombie like allowing to skin them and start a random loot spawner without destroying the body of a animal, and taking the loot from their cargo, which allowed to leave body behind where all good stuff you got on yourself. It worked previously, but now on the newest version of DayZ it seem to partially work. It's start with calling ActionCondition() and after animal is skinned OnFinishProgressServer() seem to not start up, thus making the entire script not work at all, but still animal spawn standard loot.

 


class ActionSkinningRand : ActionContinuousBaseCB
{
	override void CreateActionComponent()
	{
		m_ActionData.m_ActionComponent = new CAContinuousTime(4); //Change number for speed of skinning. More = Slower, Lower = Faster
	}
};
modded class ActionSkinning
{	

	void ActionSkinning()
	{
		m_CallbackClass = ActionSkinningRand;
		m_SpecialtyWeight = UASoftSkillsWeight.PRECISE_MEDIUM;
		
		m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_ANIMALSKINNING;
		m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH;
		m_FullBody = true;
		m_Text = "#skin";
	}
    override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
	{	
		
		Object targetObject = target.GetObject();
		EntityAI target_EAI;
		if (targetObject.IsInherited(AnimalBase)) //If Target is Animal like.
		{
		AnimalBase target_animal = AnimalBase.Cast(targetObject);
		if ( targetObject != NULL && (target_animal.m_skinned == false))
		{
			if ( targetObject.CanBeSkinned() && !targetObject.IsAlive() )
			{
				MessageAll("Target Not Alive: " + target_animal.m_skinned);
				
				Class.CastTo(target_EAI,  targetObject );
				
				if (!GetGame().IsServer()) // Temporal hackfix for skinning not working in multiplayer. Waiting for DAYZ-28269 to be resolved.
					{
					MessageAll("Action Condition3: "+ target_animal.m_skinned );
					return true;
					}
				if ( target_EAI.CanBeSkinnedWith(item) ) 
				{
				MessageAll("Action Condition5: " + target_animal.m_skinned);
					return true;
				}
			}
			}
		
		}
		else if(targetObject.IsInherited(ZombieBase)){ //If Target is Zombie like.
		
		ZombieBase target_infected = ZombieBase.Cast(targetObject);
		if ( targetObject != NULL && target_infected.m_skinned == false)
		{
			if ( targetObject.CanBeSkinned() && !targetObject.IsAlive() )
			{
				MessageAll("Action Zombie2: " + target_infected.m_skinned);
				
				Class.CastTo(target_EAI,  targetObject );
				
				if (!GetGame().IsServer()) // Temporal hackfix for skinning not working in multiplayer. Waiting for DAYZ-28269 to be resolved.
					{
					MessageAll("Action Zombie3: "+ target_infected.m_skinned );
					return true;
					}
				if ( target_EAI.CanBeSkinnedWith(item) ) 
				{
				MessageAll("Action Zombie5: " + target_infected.m_skinned);
					return true;
				}
			}
		}
		
		}
		MessageAll("Action Condition6: " + target_infected.m_skinned);
		return false;
	}
	
	override void OnFinishProgressServer( ActionData action_data )
	{
	Object targetObject = action_data.m_Target.GetObject();
	
		EntityAI body;
		Class.CastTo(body,  targetObject );
		vector body_pos = body.GetPosition();
		body.SetAsSkinned();

		MessageAll("Got into OnFinishProgressServer-1");
    if ( action_data.m_Target )
    	{
		MessageAll("Got into OnFinishProgressServer IF-1");
			if (targetObject.IsInherited(AnimalBase))
			{
				AnimalBase target_animal = AnimalBase.Cast(targetObject);
					target_animal.SetInventoryVisible(true);
					//target_animal.RandomLootOnDead();
					MessageAll("TYPE: " + target_animal.GetType());	
			
			}else if (targetObject.IsInherited(ZombieBase))
				{
			ZombieBase target_infected = ZombieBase.Cast(targetObject);
					target_infected.SetInventoryVisible(true);
					//target_infected.RandomLootOnDead();
					MessageAll("TYPE: " + target_infected.GetType());
				
				//target_animal.RandomLootOnDead();
			
			
			}
				MessageAll("Got into OnFinishProgressServer IF-1");
			
				MessageAll("SetInventoryVisible");
			
   		}
			MiscGameplayFunctions.DealAbsoluteDmg(action_data.m_MainItem, UADamageApplied.SKINNING);
		
		PluginLifespan module_lifespan = PluginLifespan.Cast( GetPlugin( PluginLifespan ) );
		module_lifespan.UpdateBloodyHandsVisibility( action_data.m_Player, true );
		
		action_data.m_Player.GetSoftSkillsManager().AddSpecialty( m_SpecialtyWeight );
		
		
	}

	override void OnFinishProgressClient( ActionData action_data )
	{
	
		MessageAll("OnFinishProgressClient: Done")
		super.OnFinishProgressClient(action_data);
	}



	override ItemBase CreateOrgan( PlayerBase player, vector body_pos, string item_to_spawn, string cfg_skinning_organ_class, ItemBase tool)
	{
		return NULL;
	}

	// Debug purposes
	void PlayerMessage(PlayerBase player, string message) 
	{
    	if ((player) && (message != "")) 
		{
      		Param1 < string > Msgparam;
      		Msgparam = new Param1 < string > (message);
      		GetGame().RPCSingleParam(player, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, player.GetIdentity());
    		
		}
	}
 	void MessageAll(string globalmessage) 
	{
    	array < Man > players = new array < Man > ;
    	GetGame().GetPlayers(players);
    	for (int i = 0; i < players.Count(); i++)
    	{
      		PlayerBase player = PlayerBase.Cast(players[i]);
      		if (!player) 
			{
        		//! No player, no check
        		return;
      		}
      		PlayerIdentity identity = player.GetIdentity();
      		if (!identity) 
			{
        		//Its strange having this check.
      			Print(player.GetIdentity().GetName() + " has no identity");
      			return;
      		}
      		PlayerMessage(player, globalmessage);
    	}
  	}
};

 

Share this post


Link to post
Share on other sites
47 minutes ago, Mr. Perkson said:

So here's my code i tried to create a script that overrides action skinning for defined creatures animal and zombie like allowing to skin them and start a random loot spawner without destroying the body of a animal, and taking the loot from their cargo, which allowed to leave body behind where all good stuff you got on yourself. It worked previously, but now on the newest version of DayZ it seem to partially work. It's start with calling ActionCondition() and after animal is skinned OnFinishProgressServer() seem to not start up, thus making the entire script not work at all, but still animal spawn standard loot.

 



class ActionSkinningRand : ActionContinuousBaseCB
{
	override void CreateActionComponent()
	{
		m_ActionData.m_ActionComponent = new CAContinuousTime(4); //Change number for speed of skinning. More = Slower, Lower = Faster
	}
};
modded class ActionSkinning
{	

	void ActionSkinning()
	{
		m_CallbackClass = ActionSkinningRand;
		m_SpecialtyWeight = UASoftSkillsWeight.PRECISE_MEDIUM;
		
		m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_ANIMALSKINNING;
		m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH;
		m_FullBody = true;
		m_Text = "#skin";
	}
    override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
	{	
		
		Object targetObject = target.GetObject();
		EntityAI target_EAI;
		if (targetObject.IsInherited(AnimalBase)) //If Target is Animal like.
		{
		AnimalBase target_animal = AnimalBase.Cast(targetObject);
		if ( targetObject != NULL && (target_animal.m_skinned == false))
		{
			if ( targetObject.CanBeSkinned() && !targetObject.IsAlive() )
			{
				MessageAll("Target Not Alive: " + target_animal.m_skinned);
				
				Class.CastTo(target_EAI,  targetObject );
				
				if (!GetGame().IsServer()) // Temporal hackfix for skinning not working in multiplayer. Waiting for DAYZ-28269 to be resolved.
					{
					MessageAll("Action Condition3: "+ target_animal.m_skinned );
					return true;
					}
				if ( target_EAI.CanBeSkinnedWith(item) ) 
				{
				MessageAll("Action Condition5: " + target_animal.m_skinned);
					return true;
				}
			}
			}
		
		}
		else if(targetObject.IsInherited(ZombieBase)){ //If Target is Zombie like.
		
		ZombieBase target_infected = ZombieBase.Cast(targetObject);
		if ( targetObject != NULL && target_infected.m_skinned == false)
		{
			if ( targetObject.CanBeSkinned() && !targetObject.IsAlive() )
			{
				MessageAll("Action Zombie2: " + target_infected.m_skinned);
				
				Class.CastTo(target_EAI,  targetObject );
				
				if (!GetGame().IsServer()) // Temporal hackfix for skinning not working in multiplayer. Waiting for DAYZ-28269 to be resolved.
					{
					MessageAll("Action Zombie3: "+ target_infected.m_skinned );
					return true;
					}
				if ( target_EAI.CanBeSkinnedWith(item) ) 
				{
				MessageAll("Action Zombie5: " + target_infected.m_skinned);
					return true;
				}
			}
		}
		
		}
		MessageAll("Action Condition6: " + target_infected.m_skinned);
		return false;
	}
	
	override void OnFinishProgressServer( ActionData action_data )
	{
	Object targetObject = action_data.m_Target.GetObject();
	
		EntityAI body;
		Class.CastTo(body,  targetObject );
		vector body_pos = body.GetPosition();
		body.SetAsSkinned();

		MessageAll("Got into OnFinishProgressServer-1");
    if ( action_data.m_Target )
    	{
		MessageAll("Got into OnFinishProgressServer IF-1");
			if (targetObject.IsInherited(AnimalBase))
			{
				AnimalBase target_animal = AnimalBase.Cast(targetObject);
					target_animal.SetInventoryVisible(true);
					//target_animal.RandomLootOnDead();
					MessageAll("TYPE: " + target_animal.GetType());	
			
			}else if (targetObject.IsInherited(ZombieBase))
				{
			ZombieBase target_infected = ZombieBase.Cast(targetObject);
					target_infected.SetInventoryVisible(true);
					//target_infected.RandomLootOnDead();
					MessageAll("TYPE: " + target_infected.GetType());
				
				//target_animal.RandomLootOnDead();
			
			
			}
				MessageAll("Got into OnFinishProgressServer IF-1");
			
				MessageAll("SetInventoryVisible");
			
   		}
			MiscGameplayFunctions.DealAbsoluteDmg(action_data.m_MainItem, UADamageApplied.SKINNING);
		
		PluginLifespan module_lifespan = PluginLifespan.Cast( GetPlugin( PluginLifespan ) );
		module_lifespan.UpdateBloodyHandsVisibility( action_data.m_Player, true );
		
		action_data.m_Player.GetSoftSkillsManager().AddSpecialty( m_SpecialtyWeight );
		
		
	}

	override void OnFinishProgressClient( ActionData action_data )
	{
	
		MessageAll("OnFinishProgressClient: Done")
		super.OnFinishProgressClient(action_data);
	}



	override ItemBase CreateOrgan( PlayerBase player, vector body_pos, string item_to_spawn, string cfg_skinning_organ_class, ItemBase tool)
	{
		return NULL;
	}

	// Debug purposes
	void PlayerMessage(PlayerBase player, string message) 
	{
    	if ((player) && (message != "")) 
		{
      		Param1 < string > Msgparam;
      		Msgparam = new Param1 < string > (message);
      		GetGame().RPCSingleParam(player, ERPCs.RPC_USER_ACTION_MESSAGE, Msgparam, true, player.GetIdentity());
    		
		}
	}
 	void MessageAll(string globalmessage) 
	{
    	array < Man > players = new array < Man > ;
    	GetGame().GetPlayers(players);
    	for (int i = 0; i < players.Count(); i++)
    	{
      		PlayerBase player = PlayerBase.Cast(players[i]);
      		if (!player) 
			{
        		//! No player, no check
        		return;
      		}
      		PlayerIdentity identity = player.GetIdentity();
      		if (!identity) 
			{
        		//Its strange having this check.
      			Print(player.GetIdentity().GetName() + " has no identity");
      			return;
      		}
      		PlayerMessage(player, globalmessage);
    	}
  	}
};

 

I won't bet but i guess that your trouble is hidden in OnFinishProgressServer(), it will no be called if it's not existing anymore. I sugg5you to checkout original script for workarounds same as class and subclasses of animals, it might be that event was removed or had been changed the types of construction. Coz in other way it shall working fine I guess.

Share this post


Link to post
Share on other sites

So i checked the newest version of DayZ Vanilla script and the only diffrence i saw was with the addition of a functions that returns crossbow/bow arrows to the ground after the animal is skinned.

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
Sign in to follow this  

×