Jump to content
Floof

[Release] C-RAM Script

Recommended Posts

@Floof @kirumy

Would be awesome if this could be continued. I will try it out for sure.

Its very helpful if you need cram functionality but adding a mod to the modpack is not possible for that reason alone.

 

EDIT: So I tried it out and the script somehow now has several failures popping up but I am too inapt to identify the issues within the code.

Sofar I could only see that it got something to do with

_interceptor

and

_ammo? _ammoType?

 

Share this post


Link to post
Share on other sites

@Up i haven't had any problems, check your files contents and names

 

_fromTarget = _target getDir _cram;
_dirTarget = direction _target;
if(_dirTarget < _fromTarget + 25 && _dirTarget > _fromTarget - 25

 

is over complicated and sometimes does return unexpected values as the _target direction itself is not guaranteed. Use this instead:
 

_fromTarget = cram1 getDir _target < 0 + 25 || cram1 getDir _target > 360 - 25;
if(_fromTarget
 
  // Only works if C-RAM direction is 0! I'm working on a fix

 

Edited by Zbysiekk
double post

Share this post


Link to post
Share on other sites

Thank you Zby, I am currently rewriting the entire script with components from Fluff, Kirumy and Yax's ITC Land Mod.
I hope to be able to create a scripted, well working version comparable to the CRAM in ITC, but on a per mission basis.
This might take some weeks, I will post it in a new thread with a Link to this one.

Share this post


Link to post
Share on other sites

I used a wrong command, it only worked if the c-ram direction was 0 degrees, this works regardless of c-ram orientation:

_fromTarget = _cram getRelDir _target < 0 + 25 || _cram getRelDir _target > 360 - 25;
  if(_fromTarget

 

Share this post


Link to post
Share on other sites

Here's my take on this script:
C-RAM's now point forwards after they lost the target.
They don't all fire at the same target if there are multiple coming.
They fire in bursts. (can be disabled)
They don't fire at the ground at all.
There's a function that adds warning sound to an object.
Cone detection works all the time.

 

Spoiler

 

fn_cram.sqf


// syntax: [unit, range] call FF_fnc_CRAM
kbz_incomingSound = false;
params["_cram","_range"];
if(isServer) then{
    _null = [_cram,_range]spawn{
        private["_cram","_range","_incoming","_target","_targetTime"];
        _cram = _this select 0;
        _range = _this select 1;
        while{alive _cram}do{
                _incoming = _cram nearObjects["ShellBase",_range];
                _incoming = _incoming + (_cram nearObjects["MissileBase",_range]);
                _incoming = _incoming + (_cram nearObjects["RocketBase",_range]);
            if(count _incoming > 0)then{
                _avalibleTarget = _incoming - ({_x getVariable ["choosen", [objNull]]} forEach _incoming);
                _target = _avalibletarget call BIS_fnc_selectRandom;
                _target setVariable ["choosen", [_target], true]; 
                _fromTarget = _cram getRelDir _target < 0 + 25 || _cram getRelDir _target > 360 - 25;
                if(_fromTarget && ((getPos _target) select 2) > 20 && alive _target)then{
                    kbz_incomingSound = true;
                    _time = time + 2;
                    while {_time > time} do {
                        _cram doWatch _target;
                    }; // Do not shoot immediately
                     _time = time + 5; // set to 0 if you don't want bursts
                    while {alive _cram && alive _target && _time > time}do{  
                        _cram doWatch _target;
                        if ((_cram weaponDirection (currentWeapon _cram)) select 2 > 0.20) then { // increase this if the c-ram shoots at the ground
                            _cram fireAtTarget[_target,(currentWeapon _cram)];
                        };   
                    }; // No sleep because it would ruin the weapon firerate
                }else{
                    _cram doWatch objNull;
                    kbz_incomingSound = false;
                };
                if(alive _target && alive _cram && _target distance _cram < _range && _target distance _cram > 40 && ((getPos _target) select 2) > 20)then{
                    _null = [_target,_cram]spawn{
                    private["_target","_cram","_expPos","_exp"];
                    _target = _this select 0;
                    _cram = _this select 1;
                    _expPos = getPos _target;
                    deleteVehicle _target;
                    sleep 1;
                    _exp = "helicopterexplosmall" createVehicle _expPos;
                    };
                };
            }else{
                _cram doWatch objNull;
                kbz_incomingSound = false;
            };
            sleep 1; // For bursts AND not shooting imidietly, ALSO BECAUSE THIS IS A LOOP
        };
    };
};


fn_cramAlarm.sqf


// Syntax: object call FF_fnc_cramAlarm
params ["_object"];
_object spawn {
	params ["_object"];
	while {true} do {
		if (kbz_incomingSound) then {
			waitUntil {
				playSound3D [getMissionPath "cram.ogg", _object]; // to play a mission directory sound
				sleep 7;
				!kbz_incomingSound;
			};
		};
		sleep 1;
	};
};


cram.ogg
https://drive.google.com/file/d/1GWfBSfK9veW_X10u8miaNGUtfNDu8dJY/view?usp=sharing

 

 

Share this post


Link to post
Share on other sites

I understood correctly, praetorians shoot and destroy  bombs and rockets, but not helicopters as in default situation?

Share this post


Link to post
Share on other sites
On 11/24/2020 at 6:42 PM, asys said:

I understood correctly, praetorians shoot and destroy  bombs and rockets, but not helicopters as in default situation?

Nope. Praetorians in Vanilla sofar shot at Fixed Wing, Rotary Wing and strategic missiles when I placed them in editor.
 

This is what I have worked out so far. There is sofar no functionality for missle interception as that is being done just fine by the vanilla weapon system.
If anyone wants to participate, go right ahead.

 

https://github.com/PaxJaromeMalues/arma3_cram

Share this post


Link to post
Share on other sites

Hello,

 

tried the script from the first post.
I created folders and put everythink where it belong.

I put call compile preprocessFileLineNumbers "scripts\C-RAM\C-RAM.sqf"; _null = execVM"scripts\C-RAM\cram_init.sqf"; in the init from the cram.
And sometimes he tried to shoot something down but most of the times everythink explodes in the air without shooting.

 

Than i tried some codes from the other posts in this thread nothing worked 😄 
Can someone pls help me and send me a whole working script not pieces?
After 2 hours i give up 😄

Share this post


Link to post
Share on other sites

Hi,

Sorry for necroing this ancient thread but if you've still got that mission file on hand @Zerenco, please provide it to me, I think I've got a more performant work around, that utilises seperate recognise and engage threads; I think I also have a way to force the CRAM AI to orient the gun to a certain elevation and azimuth and fire the gun, in a more reliable way. I want to continue to avoid invoking dependencies on mods and even CBA.

Link to thread containing info on how to set elevation:


As time goes on, I'll try and port this logic to Reforger as well, for those interested 🙂

Edited by kirumy
added link

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

×