Jump to content
xendance

CCIP script for aircrafts

Recommended Posts

arma-ccip

Arma-ccip is a CCIP (continously computed impact point) solver for aircrafts in ArmA 3. It is a client side script that only runs on clients.

The script calculates the approximate impact point of the currently selected weapon in the aircraft.

It is an approximation, so there will be a small degree of error between the calculated impact point and the real impact point.

Current stable release: https://github.com/jonimake/arma-ccip/releases

I no longer support this. It was more of a proof of concept thing. eRazeri has forked the repo and is supporting it: https://github.com/eRazeri/CCIP

Network view of all forks: https://github.com/jonimake/arma-ccip/network

Sample mission, includes two jets with the script running and some targets: http://steamcommunity.com/sharedfiles/filedetails/?id=270145257

Development branch, might be broken and has been only tested on arma 3 dev: https://github.com/jonimake/arma-ccip/tree/arma-dev

Who it is for?

  • Vehicle authors
  • Other modders
  • Other enthusiastic people

The script only calculates the impact point. There is just a crude cross on the HUD along with distance text to indicate the computed impact point.

HUD development was never a focus of this project but that might change.

The script provides two variables that can be accessed to get the impact point information:

//these are subject to change
ccip_impactPos    - contains the impact position in ASL format
ccip_resultIndex  - Value will be -1 if no impact point could be solved during the iteration.
             Otherwise the value will indicate which step of the Euler's method was below the ground.

These variables are calculated on each frame and the ccip_impactPos variable is a moving average of the past ten frames. This is done to minimize jittering of the position.

Vehicle authors and other mod makers should only need to read these two variables in order to create a proper HUD for their aircraft. Of course suggestions for additional variables are welcome.

How does it work?

Approximation is done by using Euler's method to solve the projectile motion.

The following ammo types are supported more or less:

  • MissileCore and its sub-types.
  • BulletCore and its sub-types.
  • BombCore and its sub-types.

Installing and usage

Note that you currently need to run this on the ArmA 3 dev branch due to the required vector functions that aren't yet on the main version.

You just need to download the script files into your mission root so that the main function is in jonimake_ccip folder inside the mission root.

The script package has been tested with the following folder structure:

missionRoot
│   mission.sqm 
│
└───jonimake_ccip
   │   getImpactPos.sqf        - BulletCore solver
   │   getImpactPosBomb.sqf    - BombCore solver
   │   getImpactPosRocket.sqf  - MissileCore solver
   │   includes.sqf            - contains pre-processor defs for debugging 
   │   jonimake_ccip.sqf       - main script file
   │
   └───ccipProviders - place additional ccipProvider.sqf files here
           B_Plane_CAS_01_F_ccipProvider.sqf
           O_Plane_CAS_02_F_ccipProvider.sqf
           I_Plane_Fighter_03_CAS_F_ccipProvider.sqf

Run the script by writing the following script into the vehicle init:

handle = this execVM "jonimake_ccip\jonimake_ccip.sqf"

This event handlers to the vehicle that will enable and disable the ccip solver as needed.

Configuring allowed weapons

In order to enable CCIP on a certain aircraft, you have to define all CCIP compatible weapons in a file that uses the vehicle type name suffixed with _ccipProvider.sqf.

For example, the BLUFOR jet would use a file called B_Plane_CAS_01_F_ccipProvider.sqf of which you can find an example below.

_allowedWeapons = [
"Rocket_04_HE_Plane_CAS_01_F",
"Rocket_04_AP_Plane_CAS_01_F",
"Gatling_30mm_Plane_CAS_01_F",
"Bomb_04_Plane_CAS_01_F"];

//These functions will be called in the jonimake_ccip.sqf file.
//The current plane is passed as _this parameter and the function
//has to return the position of the weapon in model space. This means
//you can either call _this selectionPosition "memoryposname" or just
//return the position as a three index array like the _heRocketInfo for example.
_gatlinInfo = {
 _this selectionPosition "Gatling_barrels_end";
};

_heRocketInfo = {
 [5.3,1.5,-0.5];
};

_apRocketInfo = {
 [-5.3,1.5,-0.5];
};

_bombInfo = {
 [0,0,-1];
};

_pairs = [];
_pairs = [_pairs,"Bomb_04_Plane_CAS_01_F",_bombInfo,false] call BIS_fnc_addToPairs;
_pairs = [_pairs,"Gatling_30mm_Plane_CAS_01_F",_gatlinInfo,false] call BIS_fnc_addToPairs;
_pairs = [_pairs,"Rocket_04_HE_Plane_CAS_01_F",_heRocketInfo,false] call BIS_fnc_addToPairs;
_pairs = [_pairs,"Rocket_04_AP_Plane_CAS_01_F",_apRocketInfo,false] call BIS_fnc_addToPairs;

[_allowedWeapons , _pairs]; //return as an array that contains the allowed weapons list and the pairs data structure

License

MIT License (yes, anyone can use this in any project they want, including Make ArmA Not War contest):

Copyright © 2014 Joni Mäkelä

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Edited by Xendance
  • Like 1

Share this post


Link to post
Share on other sites

Nice, thanks alot for your hard work!

Share this post


Link to post
Share on other sites
Guest

Release frontpaged on the Armaholic homepage.

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

You are not registered on Armaholic, or at least not that we are aware of. In the future we offer the possibility to authors to maintain their own pages.

If you wish to be able to do this as well please register on Armaholic and let me know about it.

This is not mandatory at all! Only if you wish to control your own content you are welcome to join, otherwise we will continue to follow your work like we have always done ;)

When you have any questions already feel free to PM or email me!

Share this post


Link to post
Share on other sites

I haven't tried it yet but if it works then it is a hell of a job.

Just out of curiosity, does the accuracy change much if you would use higher order approximation than Euler's approximation? And how did you acquire the correlation to the BIS config data, just by trial and error?

Share this post


Link to post
Share on other sites

This is really needed... Any chance for an MP compatible client side addon version?

Edited by Variable

Share this post


Link to post
Share on other sites
Just out of curiosity, does the accuracy change much if you would use higher order approximation than Euler's approximation? And how did you acquire the correlation to the BIS config data, just by trial and error?
Well you can always use a smaller step size. But the real question is, can you increase accuracy without more computing effort, or put in another way, can you achieve the same accuracy with less CPU strain? As long as the CPU is not so greatly stressed at all by the script that it becomes an issue, this point is certainly moot. But we have to keep in mind that Intel (and even less AMD, unfortunately) don't really build much faster CPUs anymore now and in the foreseeable future, so we'll have to cope with what is available for quite some time.

If the error is always to the same direction and with the same scale, then plainly a fixed factor would already do a good job. But something like that is certainly already in place. After all, this is much, much better than having nothing at all, and I think with some practice you can drop your ordnance very precisely with this solution.

Share this post


Link to post
Share on other sites
This is really needed... Any chance for an MP compatible client side addon version?

It should be fully MP compatible.

I haven't tried it yet but if it works then it is a hell of a job.

Just out of curiosity, does the accuracy change much if you would use higher order approximation than Euler's approximation? And how did you acquire the correlation to the BIS config data, just by trial and error?

Yes, there is bit of error at vast distances (2+ km distances). I'm looking into using some other kind of method, maybe the midpoint or some else.

Regarding config data, it was just trial and error and I'm pretty sure the projectile simulation in my code isn't 100% correct. See list of issues on github: https://github.com/jonimake/arma-ccip/issues?state=open

Share this post


Link to post
Share on other sites

Video is just B-E-A-utiful !

Have you considered putting it into an addon Xendance, so that it is always available ? A userconfig could be used to add/remove certain aircraft as they come along.

Share this post


Link to post
Share on other sites

This would be great in addon form, I honestly wouldn't even know where to start with configuring this for 3rd party aircraft and weapons, or for example aircraft armed with weapons found on opposite faction's aircraft.

Share this post


Link to post
Share on other sites

Thanks for the video, it looks good! As soon as you say this will work with the non-dev .exe I will add this into the BECTI mission.

Share this post


Link to post
Share on other sites
Thanks for the video, it looks good! As soon as you say this will work with the non-dev .exe I will add this into the BECTI mission.

Actually with today's update the script works on stable. Updated first post to reflect this.

Share this post


Link to post
Share on other sites

Is it possible that this could be made as an addon? Would love to be able to use it with existing missions :)

Share this post


Link to post
Share on other sites
Is it possible that this could be made as an addon? Would love to be able to use it with existing missions :)

I would also be very much interested in an addon version :) I would also suggest that in CCIP mode a line will connect the piper with the center of the HUD.

Share this post


Link to post
Share on other sites
I would also be very much interested in an addon version :) I would also suggest that in CCIP mode a line will connect the piper with the center of the HUD.

I have no idea how to alter the stock aircraft HUDs. I will accept help but I'd prefer if people just forked the project on github and sent me a pull request to incorporate changes ;)

I'll look into the addon version though, shouldn't be too hard.

Share this post


Link to post
Share on other sites

Awesome news on the addon. Will be placed in my modline forever.

Share this post


Link to post
Share on other sites

Has anyone did presets for other planes? Not sure where to get selection names for different planes. So I can't do it myself.

---------- Post added at 13:01 ---------- Previous post was at 12:51 ----------

Also, what about jets where you can change loadouts? Are they gonna work with this, because positions of bombs may vary.

Share this post


Link to post
Share on other sites
Has anyone did presets for other planes? Not sure where to get selection names for different planes. So I can't do it myself.

---------- Post added at 13:01 ---------- Previous post was at 12:51 ----------

Also, what about jets where you can change loadouts? Are they gonna work with this, because positions of bombs may vary.

You just need to define the *ccipProvider.sqf file. If you look at the example, you'll see how I have defined a _pairs data structure using the BIS_fnc_addToPairs. The key is the weapon name and the value is a function.

The various functions are defined before adding them to the pairs. The main script checks the current weapon of the plane and then retrieves the correct function from the pairs data structure.

That function is then called with the current plane as parameter. The return value of that function has to be the weapon muzzle location in model space. The place is passed as a parameter if you need special evaluation of the weapon position. With it you can check how much ammo the current weapon has left and so on, enabling you to switch the position depending on the ammo count for example.

Share this post


Link to post
Share on other sites

This is great, if this could be translated to an actual reticle on the HUD or the pilots vizor that would be awesome.

Share this post


Link to post
Share on other sites
You just need to define the *ccipProvider.sqf file. If you look at the example, you'll see how I have defined a _pairs data structure using the BIS_fnc_addToPairs. The key is the weapon name and the value is a function.
Yeah, I get that. I don't understand where I'm suppose to get selection names, like "Gatling_barrels_end", "Rocket_2", "Rocket_1". Also, I have no idea which function are you talking about, that returns position of weapons. :\

Share this post


Link to post
Share on other sites
Yeah, I get that. I don't understand where I'm suppose to get selection names, like "Gatling_barrels_end", "Rocket_2", "Rocket_1". Also, I have no idea which function are you talking about, that returns position of weapons. :\

You can find the memory/proxy positions in the config.

All bolded things below are functions. The function values are put into the pairs data structure with their keys. These functions have to return the model space gun pos. It's up to you if you use selectionPos or not. You can just return a vector with three elements if you want.

[b][font=Arial Black]_gatlinInfo[/font][/b] = {
 _this selectionPosition "Gatling_barrels_end"; //this is found in the config (check the config viewer in game
};

[b][font=Arial Black]_heRocketInfo[/font][/b] = {
 [5.3,1.5,-0.5];
};

[b][font=Arial Black]_apRocketInfo[/font][/b] = {
 [-5.3,1.5,-0.5];
};

[b][font=Arial Black]_bombInfo[/font][/b] = {
 [0,0,-1];
};

_pairs = [];
_pairs = [_pairs,"Bomb_04_Plane_CAS_01_F",[font=Arial Black][b]_bombInfo[/b][/font],false] call BIS_fnc_addToPairs;
_pairs = [_pairs,"Gatling_30mm_Plane_CAS_01_F",[b][font=Arial Black]_gatlinInfo[/font][/b],false] call BIS_fnc_addToPairs;
_pairs = [_pairs,"Rocket_04_HE_Plane_CAS_01_F",[b][font=Arial Black]_heRocketInfo[/font][/b],false] call BIS_fnc_addToPairs;
_pairs = [_pairs,"Rocket_04_AP_Plane_CAS_01_F",[b][font=Arial Black]_apRocketInfo[/font][/b],false] call BIS_fnc_addToPairs;

[_allowedWeapons , _pairs]; //return as an array that contains the allowed weapons list and the pairs data structure

Now, if you'll check the main script file (jonimake_ccip.sqf), you'll notice the following from line 65 onward (notice the comments below) :



//if currentWeapon equals "Gatling_30mm_Plane_CAS_01_F" the following two lines will return an
//array where the first element is "Gatling_30mm_Plane_CAS_01_F" and the second element is
//the [b][font=Arial Black]_gatlinInfo[/font][/b] function.
_providerInfoPos = [_providerPairs, (currentWeapon _plane)] call BIS_fnc_findInPairs;  
_providerInfo = _providerPairs select _providerInfoPos;

//getting the function from the array
_fnGetWeaponModelSpacePos = _providerInfo select 1;

//calls the function. Will call  [b][font=Arial Black]_gatlinInfo[/font][/b] function with the _plane parameter (assuming Gatling_30mm_Plane_CAS_01_F indeed is the currentWeapon). 
//This will in turn call '_this selectionPosition "Gatling_barrels_end"; '. Note that the _plane was passed as parameter and is accessible in the function as _this.
_modelSpaceGunPos = _plane call _fnGetWeaponModelSpacePos;           

Share this post


Link to post
Share on other sites

I found selection name, but I guess not every weapon has it.

JS_JC_FA18E_ccipProvider.sqf

_allowedWeapons = [
"js_w_fa18_m61",
"js_w_fa18_GBU12LGBLaucher",
"js_w_fa18_GBU38BombLauncher"];

_gatlinInfo = {_this selectionPosition "nosegun"};
_gbu12 = {[0,0,0]};
_gbu38 = {[0,0,0]};

_pairs = [];

_pairs = [_pairs,"js_w_fa18_m61",_gatlinInfo,false] call BIS_fnc_addToPairs;
_pairs = [_pairs,"js_w_fa18_GBU12LGBLaucher",_gbu12,false] call BIS_fnc_addToPairs;
_pairs = [_pairs,"js_w_fa18_GBU38BombLauncher",_gbu38,false] call BIS_fnc_addToPairs;

[_allowedWeapons, _pairs];

You can just return a vector with three elements if you want.
How do I do that?

I thought I have some basic understanding of scripts, but what you are saying doesn't make any sense to me. lol

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

×