Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Jipit0

HoldAction repeatable

Recommended Posts

Hi, i started scripting in eden editor.

I have and holdaction in the int.sqf  and i don't understand why my holdaction is not repeatable ?

 

this is the holdaction :

[
	AIHeli,																// Object the action is attached to
	"Heli Transport",													// Title of the action
	"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_takeOff2_ca.paa",		// Idle icon shown on screen
	"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_takeOff2_ca.paa",		// Progress icon shown on screen
	"_this distance _target < 12",										// Condition for the action to be shown
	"_caller distance _target < 12",										// Condition for the action to progress
	{
		openMap true;
		_condition = true;
		//hint format["target Position: %1", getMarkerPos "targerMarker"];

		while {_condition} do {
								player onMapSingleClick {

														_mousePos = getMousePosition;
														_worldCoord = (findDisplay 12 displayCtrl 51) ctrlMapScreenToWorld _mousePos;
														_worldCoord = [_worldCoord select 0, _worldCoord select 1, 0];
														_arr = [0,0,0];

														//hint format["Mouse Position: %1 world coord : %2", _mousePos, _worldCoord];

														if (_arr isEqualTypeArray _worldCoord) then {
																										openMap false;
																										["B_Heli_Light_01_F", _worldCoord] call JP_fnc_taxiHeli;
																										_condition = nil;
																									};
														};
								};
	},																	// Code executed when action starts
	{},																	// Code executed on every progress tick
	{},																	// Code executed on completion
	{},																	// Code executed on interrupted
	[],																	// Arguments passed to the scripts as _this select 3
	5,																	// Action duration in seconds
	0,																	// Priority
	false,																// Remove on completion
	false																// Show in unconscious state
] call BIS_fnc_holdActionAdd;

someone have a solution ?

Share this post


Link to post
Share on other sites

Lots of things wrong with that... (see comments)

[
	AIHeli,                                                             // Object the action is attached to
	"Heli Transport",                                                   // Title of the action
	"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_takeOff2_ca.paa",    // Idle icon shown on screen
	"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_takeOff2_ca.paa",    // Progress icon shown on screen
	"_this distance _target < 12",                                      // Condition for the action to be shown
	"_caller distance _target < 12",                                    // Condition for the action to progress
	// Code executed when action starts
	//Why action start? Just use an addAction if your never waiting for a hold action to complete
	{
		openMap true;
		_condition = true;

		//This will loop multiple times per frame, possibly thousands of times
		while {_condition} do {
			
			//So this will be re-invoked possibly thousands of times per frame
			//Once added remains until removed or replaced( which it will be replaced because of while )
			player onMapSingleClick {
				
				//This is unneeded, just use _pos as supplied by onMapSingleClick
				_mousePos = getMousePosition;
				_worldCoord = (findDisplay 12 displayCtrl 51) ctrlMapScreenToWorld _mousePos;
				_worldCoord = [_worldCoord select 0, _worldCoord select 1, 0];
				
				
				_arr = [0,0,0];

				//This is always true
				//_arr is always EqualTypeArray _worldCoord
				//[ scalar, scalar, scalar ] == [ scalar, scalar, scalar ]
				if (_arr isEqualTypeArray _worldCoord) then {
					openMap false;
					["B_Heli_Light_01_F", _worldCoord] call JP_fnc_taxiHeli;
                  
					//While{ nil } would be an error
					//but _condition is out of scope here so while loop will never be effected
					_condition = nil;
					
					//onMapSingleClick is never removed
				};
			};
		};
	},																	
	{},             // Code executed on every progress tick
	{},             // Code executed on completion
	{},             // Code executed on interrupted
	[],             // Arguments passed to the scripts as _this select 3
	5,              // Action duration in seconds
	0,              // Priority
	false,          // Remove on completion
	false           // Show in unconscious state
] call BIS_fnc_holdActionAdd;

Just something like...

Spoiler

AIHeli addAction[ "Heli Transport", {
		params [ "_target", "_caller", "_id", "_args" ];
		
		openMap true;
		
		_transPos_MEH = addMissionEventHandler[ "MapSingleClick", {
			params[ "_units", "_pos", "_alt", "_shift" ];
			
			[ "B_Heli_Light_01_F", _pos ] call JP_fnc_taxiHeli;
			
			openMap false;
		}];
		
		waitUntil{ !visibleMap };
		removeMissionEventHandler[ "MapSingleClick", _transPos_MEH ];
	},
	[],
	0,      //priority
	true,   //Show on screen
	true,   //Hide on use
	"",
	//condition
	//_target (unit to which action is attached to) and _this (caller/executing unit)
	"",
	12,     //Distance to show
	false   // Show in unconscious state
];

 

...should be enough. Untested!

Share this post


Link to post
Share on other sites

×