Jump to content
Blitzen88

Need Help with Ambient Animation Script

Recommended Posts

Greetings,
 

Im having some problems with a script (provided below) that I am using in an attempt to improve upon the default BIS_fnc_ambientAnim function.  What the script does is place the unit in a stance, waits until that unit is in combat, and then has the unit either guard their location (via BIS_fnc_taskDefend) or stay in place (for a unit in a guard tower, etc.).  Since certain animations remove the unit's weapon, the script also gives the unit their weapon back when they enter combat mode.

 

I am having some issues getting this script to work with some other scripts/things that I am trying to do.  

 

Setup

  1. I placed a CSAT Rifleman in the editor and executed the script via the unit's init.  From my understanding, the unit's script should execute/run before the Init.  The script should save the unit's initial starting weapon.
  2. I use the Init script to apply a loadout script to all of the East Units on the map.  This loadout script also changes the unit's weapon to an AK12.
  3. I also use the Init script to run another script which, based upon the user's input, removes or applies nightvision goggles to units a particular side.  This script also gives a weapon flashlight to units which do not have nightvision goggles.  In this case, the CSAT Rifleman should receive a flashlight.  

 

Order of Execution

  1. Animation script executes via the CSAT unit's init.  The CSAT unit's original rifle is saved by the script
  2. Loadout Script executes via Init.  The CSAT's unit's weapon is changed to an AK12
  3. Nightvision/Flashlight script executes via Init.  The CSAT unit's Ak12 now has a flashlight

 

Problems

  1. The script uses a waituntil loop to check if the unit has entered combat.  Once the unit enters combat, he is weapon is given back to him.  For whatever reason, the unit is being given his weapon back before he enters combat
  2. There is a weird interaction between the unit receiving a weapon and the built in loadouts of the BIS_fnc_ambientAnim function.  If the unit's loadout is set to "None" via the BIS_fnc_ambientAnim function then he will use his original, pre-Init weapon.  If the unit's loadout is set to "ASIS" then the unit will use the post-init weapon.  I have no idea as to why...

 

Is there anyway to fix to the unit receiving their weapon before entering combat mode?  Is there any way to build in a check that "updates" the unit's weapon ( and weapon attachements, ie the flashlight) and then gives that weapon to the unit when they enter combat mode?

/*==========================================================================================

				Arma III - AI Ambient Stances

===========================================================================================

* Places units in an ambient animation (sitting, watching, etc) and makes them respond to combat

* Units will respond to combat by either (based upon input) call Bis_Fnc_Defend, or remain at their placed position.

* Unit Stances and "Loadout" inputs are Case Sensitive!

* Any unit loadout script must be executed before the animation script!!!

* Possible "Loadouts":

	- NONE - no goggles, headgear, vest, weapon

	- LIGHT - no goggles, headgear, vest

	- MEDIUM - no goggles, headgear

	- FULL - no goggles

	- ASIS - no changes to the unit's gear

	- RANDOM (default) - gear is randomized according to the animation set

* Possible Stances:

	- STAND - standing still, slightly turning to the sides, with rifle weapon

	- STAND_IA - standing still, slightly turning to the sides, with rifle weapon

	- STAND_U1-3 - standing still, slightly turning to the sides, no weapon

	- WATCH1- - standing and turning around, with rifle weapon

	- GUARD - standing still, like on guard with hands behing the body

	- LISTEN_BRIEFIN - standing still, hands behind back, recieving briefing / commands, no rifle.

	- LEAN_ON_TABLE - standing while leaning on the table

	- LEAN - standing while leaning (on wall)

	- BRIEFING - standing, playing ambient briefing loop with occasional random moves

	- BRIEFING_POINT_LEFT - contains 1 extra pointing animation, pointing left & high

	- BRIEFING_POINT_RIGHT - contains 1 extra pointing animation, pointing right & high

	- BRIEFING_POINT_TABLE - contains 1 extra pointing animation, pointing front & low, like at table

	- SIT1-3 - sitting on chair or bench, with rifle weapon

	- SIT_U1-3 - sitting on chair or bench, without weapon

	- SIT_AT_TABLE - sitting @ table, hands on table

	- SIT_HIGH1-2 - sitting on taller objects like a table or wall, legs not touching the ground. Needs a rifle!

	- SIT_LOW - sitting on the ground, with weapon.

	- SIT_LOW_U - sitting on the ground, without weapon.

	- SIT_SAD1-2 - sitting on a chair, looking very sad.

	- KNEEL - kneeling, with weapon.

	- PRONE_INJURED_U1-2 - laying wounded, back on the ground, without weapon

	- PRONE_INJURED - laying wounded & still, back on the ground, with or without weapon

	- KNEEL_TREAT - kneeling while treating the wounded

	- REPAIR_VEH_PRONE - repairing vehicle while laying on the ground (under the vehicle)

	- REPAIR_VEH_KNEEL - repairing vehicle while kneeling (like changing a wheel)

	- REPAIR_VEH_STAND - repairing/cleaning a vehicle while standing

* Call with: [this, "SIT3", "ASIS", True] execVM "Scripts\AI_AmbientStances.sqf"

==========================================================================================*/

//Define Variables/Input
_unit = _this select 0;

_stance = _this select 1;

_loadout = _this select 2;

_GuardMode = _this select 3;

_OriginalPosition = position (_this select 0);

_UnitsGroup = group (_this select 0);

_UnitsPrimaryWeapon = primaryWeapon _unit;

//Put the Unit in the Designated Position
[_unit, _stance, _loadout] call BIS_fnc_ambientAnim;

//Wait until the unit is in combat and then terminate the animation
0 = _unit spawn {waitUntil

	{behaviour _this == "combat"};
	
	Sleep 1;
	
	_this call BIS_fnc_ambientAnim__terminate;
};

Sleep 3;

_unit setunitpos "Auto";

//Some animations remove the unit's primary weapon.  Lets give the weapon back to him.
[_unit, _UnitsPrimaryWeapon, 6] call BIS_fnc_addWeapon;

_unit selectweapon (primaryweapon _unit);

//The unit will either move/defend or remain at their position (useful for guardtowers, etc.)
if (_GuardMode) then {

[_UnitsGroup, _OriginalPosition] call bis_fnc_taskDefend;

} else {

_unit disableAI "Path";

};


 

Thank you for your help!

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

×