Find help on the FRENCH REFORGER MOD discord if you need ✅ Check our progress about this wiki here 📜
Skip to main content

Make a landinggear for a chopper

The idea is to use the basic car trunk script from Ed Bohemia's tutorial, modifying it to move (translate/rotate) a bone in the skeleton.
(you can download the basic car and see how the make the trunk function:https://github.com/BohemiaInteractive/Arma-Reforger-Samples/tree/main/SampleMod_NewCar) you can go see the vertex part here: tutorial vertex and anim

First part: skeleton + bone.

image.png


nous allons utilsier le componenet carprocanim

image.png

comment le carproc anim amrche

il y a 1 signal le .siga et le fichier d'anim et .pap

image.png

1er partie le .siga

image.png

l'input sera le lanceur du signal

value sera la position de depart

image.png

2eme partie le .pap

image.png

3 Action manager

a. action manager

image.png

b. additional info

image.png

l'additional info va appeler le fichier script dans lequel il y a plusieur contenu

image.png

signal Name will be the name in the .siga input


here is the content of the script file

class SCR_TrunkUserAction : ScriptedUserAction
{
	[Attribute(defvalue: "Drawer 1", uiwidget: UIWidgets.EditBox, desc: "Signal name of trunk action in procedural animation project")]
	protected string m_sSignalName;	//for pairing with the user action
	
	[Attribute(defvalue: "0", uiwidget: UIWidgets.EditBox, desc: "Value of signal when trunk is closed")]
	protected float m_fSignalMin;
	
	[Attribute(defvalue: "1", uiwidget: UIWidgets.EditBox, desc: "Value of signal when trunk is opened")]
	protected float m_fSignalMax;

	[Attribute(defvalue: "Open", uiwidget: UIWidgets.EditBox, desc: "Text for the 'Open' action")]
	protected string m_sOpenText;  // Texte pour l'action "Open"
	
	[Attribute(defvalue: "Close", uiwidget: UIWidgets.EditBox, desc: "Text for the 'Close' action")]
	protected string m_sCloseText;  // Texte pour l'action "Close"

	[Attribute(defvalue: "SOUND_CONTAINER_OPEN", uiwidget: UIWidgets.EditBox, desc: "Sound event name when opening")]
	protected string m_sOpenSoundEvent;  // Événement sonore pour l'ouverture
	
	[Attribute(defvalue: "SOUND_CONTAINER_CLOSE", uiwidget: UIWidgets.EditBox, desc: "Sound event name when closing")]
	protected string m_sCloseSoundEvent;  // Événement sonore pour la fermeture

	protected int m_iSignalIndex = -1;

	//! Signal manager to pass signals into proc anim
	private SignalsManagerComponent m_SignalsManager;
	//! Sound component
	private SCR_VehicleSoundComponent m_SoundComponent;

	//------------------------------------------------------------------------------------------------
	override bool CanBeShownScript(IEntity user)
	{
		return CanBePerformedScript(user);
	}

	//------------------------------------------------------------------------------------------------
	override bool CanBePerformedScript(IEntity user)
	{
		if(!m_SignalsManager)
			return false;

		if (m_iSignalIndex < 0)
		{
			m_iSignalIndex = m_SignalsManager.FindSignal(m_sSignalName);
			return false;
		}

		return true;
	}

	//---------------------------------------------------------
	override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
	{
		float targetValue = Math.AbsFloat((m_SignalsManager.GetSignalValue(m_iSignalIndex)) - m_fSignalMax);
		m_SignalsManager.SetSignalValue(m_iSignalIndex, targetValue);

		// Play sound
		if (m_SoundComponent)
		{
			if(targetValue > 0)
			{
				m_SoundComponent.SoundEvent(m_sOpenSoundEvent);  // Utilise l'événement sonore défini pour l'ouverture
			}
			else
			{
				m_SoundComponent.SoundEvent(m_sCloseSoundEvent);  // Utilise l'événement sonore défini pour la fermeture
			}
		}
	}

	//------------------------------------------------------------------------------------------------
	override bool GetActionNameScript(out string outName)
	{
		if((m_SignalsManager.GetSignalValue(m_iSignalIndex)) == 0)
		{
			outName = m_sOpenText;  // Utilise le texte défini pour l'ouverture
		} else
		{
			outName = m_sCloseText;  // Utilise le texte défini pour la fermeture
		}
		return true;
	}

	//------------------------------------------------------------------------------------------------
	override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
	{
		m_SignalsManager = SignalsManagerComponent.Cast(pOwnerEntity.FindComponent(SignalsManagerComponent));
		m_SoundComponent = SCR_VehicleSoundComponent.Cast(pOwnerEntity.FindComponent(SCR_VehicleSoundComponent));
	}
}