Jump to content
Sign in to follow this  
PlacidPaul

How to use ModuleCAS_F

Recommended Posts

This is a new module in the effects category.

Doesn't seem that this module can be synced, so is there a way to create it on a position?

Share this post


Link to post
Share on other sites

I'd like to know the same.

Edited by RTEK

Share this post


Link to post
Share on other sites

Modules are basically just game logic units that run scripts automatically. You can create one at anytime with createUnit.

Share this post


Link to post
Share on other sites
Modules are basically just game logic units that run scripts automatically. You can create one at anytime with createUnit.

I tried it, and it failed to work. It creates it but it doesn't trigger the module

Share this post


Link to post
Share on other sites

Hi all,

Give this a go in a trigger:

0 = [] spawn {
_center = createCenter sideLogic;
_group = createGroup _center;
_pos = getpos player; 
_CAS = _group createUnit ["ModuleCAS_F",_pos , [], 0, ""];
};

For a real good time dont change the _pos. :cool:

---------- Post added at 02:01 ---------- Previous post was at 01:54 ----------

By the way does anybody know where this module is located? I checked Modules_F and all the other modules under addons. Maybe Im blind.

Share this post


Link to post
Share on other sites

Nope I mean where is the module located under the addons folder so I can look at the script? I'm just being lazy I will search for it later tonight. The script I posted above works but it only spawns in a NATO plane. I need to find the variables so we can do the other planes.

---------- Post added at 04:30 ---------- Previous post was at 03:43 ----------

Okay so the CAS module is under modules_f_curator.

If you want to use differrent CAS planes you would do this:

_center = createCenter sideLogic;   
_group = createGroup _center;   
_pos = getpos player;    
_cas = _group createUnit ["ModuleCAS_F",_pos , [], 0, ""];  
_cas setVariable ["vehicle","I_Plane_Fighter_03_CAS_F"];
_cas setVariable ["type", 1];

You can use these planes:

B_Plane_CAS_01_F

O_Plane_CAS_02_F

I_Plane_Fighter_03_CAS_F

_cas setVariable ["vehicle","I_Plane_Fighter_03_CAS_F"];

If you want to change ammo type:

0 = guns

1 = missiles

2 = guns and missiles

_cas setVariable ["type", 1];

Edited by cobra4v320
  • Like 1

Share this post


Link to post
Share on other sites

Thank you for doing the research, Cobra4v320. You will save some people a lot of time. This might come in handy for me in the future. If you figure out how to minipluate any more scripted Zues modules, post the results up!

Thanks again!

Edited by Fight9
Rewording

Share this post


Link to post
Share on other sites

Thanks for the above code Cobra. Just what I was looking for. A couple of wee questions if that's ok?

1) When placing the module in the editor, you can control the direction from which the aircraft attacks from by rotating the module. Do you know if there is a variable we can set in the above script so we can do the same? Perhaps _vectorDir?

2) Im also wondering if its possible to supress the little radio message that plays to say the strike is inbound.

I'll try and figure this out myself but don't fancy my chances.

Edited by *TCF*Jackal

Share this post


Link to post
Share on other sites
Thanks for the above code Cobra. Just what I was looking for. A couple of wee questions if that's ok?

1) When placing the module in the editor, you can control the direction from which the aircraft attacks from by rotating the module. Do you know if there is a variable we can set in the above script so we can do the same? Perhaps _vectorDir?

2) Im also wondering if its possible to supress the little radio message that plays to say the strike is inbound.

I'll try and figure this out myself but don't fancy my chances.

We just need to set the direction of the logic after it is created. The direction is based on the direction of the logic like you said but there is no variable to change. We should be able to just do this:

_dir = [_cas, _pos] call BIS_fnc_dirTo;
_cas setDir _dir;

This is not tested I dont have time at the moment. I will later tonight unless someone beats me to it. Posted another version of the script below:

_center = createCenter sideLogic;    
_group = createGroup _center;    
_pos = getpos player;     
_cas = _group createUnit ["ModuleCAS_F",_pos , [], 0, ""];   
_dir = [_cas, _pos] call BIS_fnc_dirTo;
_cas setDir _dir;
_cas setVariable ["vehicle","I_Plane_Fighter_03_CAS_F"]; 
_cas setVariable ["type", 1];

Edited by cobra4v320

Share this post


Link to post
Share on other sites

I got it to work, but for some reason the plane always enjoys coming from NE and SW only.

Share this post


Link to post
Share on other sites

I forgot the module is the attack position so using that first version above wouldnt work. You can also set your own direction.

_center = createCenter sideLogic;    
_group = createGroup _center;    
_pos = getpos player;     
_cas = _group createUnit ["ModuleCAS_F",_pos , [], 0, ""];   
_cas setDir 180;
_cas setVariable ["vehicle","I_Plane_Fighter_03_CAS_F"]; 
_cas setVariable ["type", 1];

Share this post


Link to post
Share on other sites

The above one worked fine for me, just decided it only wanted to fly in 2 directions.

Share this post


Link to post
Share on other sites

Im thinking about a dialog, here is a picture of one that I threw together really quick.

Untitled_zps388daf5d.jpg

Share this post


Link to post
Share on other sites

This could be a mod if you set it right if not just a basic script to release.

Share this post


Link to post
Share on other sites

Cool dialog, Cobra. Simple, but definitely gets the job done. Are you able to set incoming direction with that?

I was skeptical about Zues because it seem like a MCC clone at first. Now, however, all these new functions and modules seem like pretty cool new toys for us who like to script. Plus, the new MCC with Zues integration is bad ass.

You could easy create a list and map dialog with all the new Modules and Functions from Zues and have a pretty cool in-game dialog without giving the player as much power as Zues does.

The fact that all these new things are available for all players, and not just those with the addon, make it so much better.

I look forward to working with this stuff in the future. Keep up the good work, for all of us Armaholics.

Share this post


Link to post
Share on other sites

_center = createCenter sideLogic;    
_group = createGroup _center;    
_pos = getpos player;     
_cas = _group createUnit ["ModuleCAS_F",_pos , [], 0, ""];   
_cas setDir 180;
_cas setVariable ["vehicle","I_Plane_Fighter_03_CAS_F"]; 
_cas setVariable ["type", 1];

On a dedicated server the missiles for "type" 2 do not fire, only the guns. They do though in the editor-preview. What could be causing this?

Share this post


Link to post
Share on other sites

Here is the entire script:

_logic = _this select 0;
_units = _this select 1;
_activated = _this select 2;

//--- Terminate on client (unless it's curator who created the module)
if (!isserver && {local _x} count (objectcurators _logic) == 0) exitwith {};

if (_activated) then {

//--- Wait for params to be set
if (_logic call bis_fnc_isCuratorEditable) then {
	waituntil {!isnil {_logic getvariable "vehicle"} || isnull _logic};
};
if (isnull _logic) exitwith {};

//--- Show decal
if ({local _x} count (objectcurators _logic) > 0) then {
	//--- Reveal the circle to curators
	_logic hideobject false;
	_logic setpos position _logic;
};
if !(isserver) exitwith {};

_planeClass = _logic getvariable ["vehicle","B_Plane_CAS_01_F"];
_planeCfg = configfile >> "cfgvehicles" >> _planeClass;
if !(isclass _planeCfg) exitwith {["Vehicle class '%1' not found",_planeClass] call bis_fnc_error; false};

//--- Restore custom direction
_dirVar = _fnc_scriptname + typeof _logic;
_logic setdir (missionnamespace getvariable [_dirVar,direction _logic]);

//--- Detect gun
_weaponTypesID = _logic getvariable ["type",getnumber (configfile >> "cfgvehicles" >> typeof _logic >> "moduleCAStype")];
_weaponTypes = switch _weaponTypesID do {
	case 0: {["machinegun"]};
	case 1: {["missilelauncher"]};
	case 2: {["machinegun","missilelauncher"]};
	default {[]};
};
_weapons = [];
{
	if (tolower ((_x call bis_fnc_itemType) select 1) in _weaponTypes) then {
		_modes = getarray (configfile >> "cfgweapons" >> _x >> "modes");
		if (count _modes > 0) then {
			_mode = _modes select 0;
			if (_mode == "this") then {_mode = _x;};
			_weapons set [count _weapons,[_x,_mode]];
		};
	};
} foreach getarray (_planeCfg >> "weapons");
if (count _weapons == 0) exitwith {["No weapon of type 'MachineGun' wound on '%1'",_planeClass] call bis_fnc_error; false};

_posATL = getposatl _logic;
_pos = +_posATL;
_pos set [2,(_pos select 2) + getterrainheightasl _pos];
_dir = direction _logic;

_dis = 3000;
_alt = 1000;
_pitch = atan (_alt / _dis);
_speed = 400 / 3.6;
_duration = ([0,0] distance [_dis,_alt]) / _speed;

//--- Create plane
_planePos = [_pos,_dis,_dir + 180] call bis_fnc_relpos;
_planePos set [2,(_pos select 2) + _alt];
_planeSide = (getnumber (_planeCfg >> "side")) call bis_fnc_sideType;
_planeArray = [_planePos,_dir,_planeClass,_planeSide] call bis_fnc_spawnVehicle;
_plane = _planeArray select 0;
_plane setposasl _planePos;
_plane move ([_pos,_dis,_dir] call bis_fnc_relpos);
_plane disableai "move";
_plane disableai "target";
_plane disableai "autotarget";
_plane setcombatmode "blue";

_vectorDir = [_planePos,_pos] call bis_fnc_vectorFromXtoY;
_velocity = [_vectorDir,_speed] call bis_fnc_vectorMultiply;
_plane setvectordir _vectorDir;
[_plane,-90 + atan (_dis / _alt),0] call bis_fnc_setpitchbank;
_vectorUp = vectorup _plane;

//--- Remove all other weapons
_currentWeapons = weapons _plane;
{
	if !(tolower ((_x call bis_fnc_itemType) select 1) in (_weaponTypes + ["countermeasureslauncher"])) then {
		_plane removeweapon _x;
	};
} foreach _currentWeapons;

//--- Cam shake
_ehFired = _plane addeventhandler [
	"fired",
	{
		_this spawn {
			_plane = _this select 0;
			_plane removeeventhandler ["fired",_plane getvariable ["ehFired",-1]];
			_projectile = _this select 6;
			waituntil {isnull _projectile};
			[[0.005,4,[_plane getvariable ["logic",objnull],200]],"bis_fnc_shakeCuratorCamera"] call bis_fnc_mp;
		};
	}
];
_plane setvariable ["ehFired",_ehFired];
_plane setvariable ["logic",_logic];

//--- Show hint
[[["Curator","PlaceOrdnance"],nil,nil,nil,nil,nil,nil,true],"bis_fnc_advHint",objectcurators _logic] call bis_fnc_mp;

//--- Play radio
[_plane,"CuratorModuleCAS"] call bis_fnc_curatorSayMessage;

//--- Debug - visualize tracers
if (false) then {
	BIS_draw3d = [];
	//{deletemarker _x} foreach allmapmarkers;
	_m = createmarker [str _logic,_pos];
	_m setmarkertype "mil_dot";
	_m setmarkersize [1,1];
	_m setmarkercolor "colorgreen";
	_plane addeventhandler [
		"fired",
		{
			_projectile = _this select 6;
			[_projectile,position _projectile] spawn {
				_projectile = _this select 0;
				_posStart = _this select 1;
				_posEnd = _posStart;
				_m = str _projectile;
				_mColor = "colorred";
				_color = [1,0,0,1];
				if (speed _projectile < 1000) then {
					_mColor = "colorblue";
					_color = [0,0,1,1];
				};
				while {!isnull _projectile} do {
					_posEnd = position _projectile;
					sleep 0.01;
				};
				createmarker [_m,_posEnd];
				_m setmarkertype "mil_dot";
				_m setmarkersize [1,1];
				_m setmarkercolor _mColor;
				BIS_draw3d set [count BIS_draw3d,[_posStart,_posEnd,_color]];
			};
		}
	];
	if (isnil "BIS_draw3Dhandler") then {
		BIS_draw3Dhandler = addmissioneventhandler ["draw3d",{{drawline3d _x;} foreach (missionnamespace getvariable ["BIS_draw3d",[]]);}];
	};
};

//--- Approach
_fire = [] spawn {waituntil {false}};
_fireNull = true;
_time = time;
_offset = if ({_x == "missilelauncher"} count _weaponTypes > 0) then {20} else {0};
waituntil {
	_fireProgress = _plane getvariable ["fireProgress",0];

	//--- Update plane position when module was moved / rotated
	if ((getposatl _logic distance _posATL > 0 || direction _logic != _dir) && _fireProgress == 0) then {
		_posATL = getposatl _logic;
		_pos = +_posATL;
		_pos set [2,(_pos select 2) + getterrainheightasl _pos];
		_dir = direction _logic;
		missionnamespace setvariable [_dirVar,_dir];

		_planePos = [_pos,_dis,_dir + 180] call bis_fnc_relpos;
		_planePos set [2,(_pos select 2) + _alt];
		_vectorDir = [_planePos,_pos] call bis_fnc_vectorFromXtoY;
		_velocity = [_vectorDir,_speed] call bis_fnc_vectorMultiply;
		_plane setvectordir _vectorDir;
		//[_plane,-90 + atan (_dis / _alt),0] call bis_fnc_setpitchbank;
		_vectorUp = vectorup _plane;

		_plane move ([_pos,_dis,_dir] call bis_fnc_relpos);
	};

	//--- Set the plane approach vector
	_plane setVelocityTransformation [
		_planePos, [_pos select 0,_pos select 1,(_pos select 2) + _offset + _fireProgress * 12],
		_velocity, _velocity,
		_vectorDir,_vectorDir,
		_vectorUp, _vectorUp,
		(time - _time) / _duration
	];
	_plane setvelocity velocity _plane;

	//--- Fire!
	if ((getposasl _plane) distance _pos < 1000 && _fireNull) then {
		_fireNull = false;
		terminate _fire;
		_fire = [_plane,_weapons] spawn {
			_plane = _this select 0;
			_planeDriver = driver _plane;
			_weapons = _this select 1;
			_duration = 3;
			_time = time + _duration;
			waituntil {
				{
					//_plane selectweapon (_x select 0);
					_planeDriver forceweaponfire _x;
				} foreach _weapons;
				_plane setvariable ["fireProgress",(1 - ((_time - time) / _duration)) max 0 min 1];
				sleep 0.1;
				time > _time || isnull _plane
			};
			sleep 1;
		};
	};

	sleep 0.01;
	scriptdone _fire || isnull _logic || isnull _plane
};
_plane setvelocity velocity _plane;
_plane flyinheight _alt;

if !(isnull _logic) then {
	sleep 1;
	deletevehicle _logic;
	waituntil {_plane distance _pos > _dis};
};

//--- Delete plane
if (alive _plane) then {
	_group = group _plane;
	_crew = crew _plane;
	deletevehicle _plane;
	{deletevehicle _x} foreach _crew;
	deletegroup _group;
};
};

Share this post


Link to post
Share on other sites

Thanks Cobra, for your quick response. I have read thru the code above and can not find any reason for the difference in action between the editor-preview(SP) and on a dedicated server. I can only suspect that one of the called functions may be nonlocal or local-only, whichever for the missiles. The other thing I considered was the _weaponTypesID not being picked up due to the "moduleCAStype" stipulation.

Any other comments or suggestions?

Thanks

EDIT: Ok, got it to work. The setVariable cmds need to be set with the true Boolean in their array.

_cas setVariable ["vehicle","I_Plane_Fighter_03_CAS_F",true];

_cas setVariable ["type", 1,true];

Edited by tomturner

Share this post


Link to post
Share on other sites
Thanks Cobra, for your quick response. I have read thru the code above and can not find any reason for the difference in action between the editor-preview(SP) and on a dedicated server. I can only suspect that one of the called functions may be nonlocal or local-only, whichever for the missiles. The other thing I considered was the _weaponTypesID not being picked up due to the "moduleCAStype" stipulation.

Any other comments or suggestions?

Thanks

EDIT: Ok, got it to work. The setVariable cmds need to be set with the true Boolean in their array.

_cas setVariable ["vehicle","I_Plane_Fighter_03_CAS_F",true];

_cas setVariable ["type", 1,true];

yes the setvariable needs to be true for it to be public.

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  

×