OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting Multiplayer => Topic started by: Ghost644 on 05 Jul 2009, 03:43:56

Title: My Artillery Script
Post by: Ghost644 on 05 Jul 2009, 03:43:56
I made an Artillery script which I am pretty satisfied with the results. I plane on making it better and more customizable but for now it is fine. Few issues:


I am still learning how to do this scripting stuff and understand some of it but global, local still gets me. To use create an empty marker named whatever you like. Create Functions and Artillery Modules naming the Artillery Module. Create artillery pieces and add artillery ammo to them and name leader. create radio trigger, repeatedly, onact put
Code: [Select]
arty = [artmodule,"marker",rounds in # format,leader name] execVM "dta\scripts\artillery.sqf";make sure to adjust array for what you named your stuff

Code: [Select]
/*script by: Ghost    designed for 3 arty triggers of 4,8,16 rounds setup: create marker type: empty, create 3 radio triggers repeat onact: arty = [firebase,"arty",4,gun1] execVM "dta\scripts\artillery.sqf"; Make sure you have the Functions and ArtilleryModule on map as well. Name Arty Module Whatever you like ie firebase and link module to your arty pieces.
*/

if (!isServer) exitWith {};

waituntil {!isnil "bis_fnc_init"};

_battery = _this select 0;
_marker = _this select 1;
_rnds = _this select 2;
_artleader = _this select 3;

_hetemplate = ["IMMEDIATE", "HE", 0.5, _rnds];

hint "Left click on map to set target coordinates";

_map = [_battery, "HE"] call BIS_ARTY_F_LoadMapRanges;

mapclick = false;

onMapSingleClick """arty"" setMarkerPos _pos; clickpos = _pos; mapclick = true; onMapSingleClick """";true;";

waituntil {mapclick};
_pos = clickpos;

if ([_battery, _hetemplate] call BIS_ARTY_F_StillViable) then
{

_marker setmarkertype "mil_destroy";

1 setRadioMsg "NULL"; radio1=false;
2 setRadioMsg "NULL"; radio2=false;
3 setRadioMsg "NULL"; radio3=false;

sleep 2;

// Check to see if position is in range before we fire.
// Second item in _fmTemplate is the ordType (HE, ILLUM, etc)
if ([_battery, _pos, _hetemplate select 1] call BIS_ARTY_F_PosInRange) then
{
_disp = [_battery, 200] call BIS_ARTY_F_SetDispersion;
sleep 1;
_fire = [_battery, _pos, _hetemplate] call BIS_ARTY_F_ExecuteTemplateMission;
waitUntil {_battery getVariable "ARTY_ONMISSION"};
_artleader sidechat "Artillery Firing.";

waitUntil {_battery getVariable "ARTY_SPLASH"};
_artleader sidechat "Incoming!";

waitUntil {_battery getVariable "ARTY_COMPLETE"};

sleep 30;

_marker setmarkertype "empty";
1 setRadioMsg "Artillery 4rnds HE"; radio1=true;
2 setRadioMsg "Artillery 8rnds HE"; radio2=true;
3 setRadioMsg "Artillery 16rnds HE"; radio3=true;

_artleader sidechat "Artillery Ready.";
} else
{
_artleader sidechat "Target out of range! Try again.";
_marker setmarkertype "empty";
1 setRadioMsg "Artillery 4rnds HE"; radio1=true;
2 setRadioMsg "Artillery 8rnds HE"; radio2=true;
3 setRadioMsg "Artillery 16rnds HE"; radio3=true;
};
} else
{
hint "Artillery Dead";
1 setRadioMsg "NULL"; radio1=false;
2 setRadioMsg "NULL"; radio2=false;
3 setRadioMsg "NULL"; radio3=false;
};

if (true) exitWith {};
Title: Re: My Artillery Script
Post by: kju on 05 Jul 2009, 07:45:46
1. To avoid overwriting other peoples gvs:
Code: [Select]
arty =
=>
Code: [Select]
YourTag_Arty =
http://www.ofpec.com/tags/

2. Extract the modules.pbo and study the arty scripts.
Maybe you can disable its communication.

3. Check existing arty functions to study and learn:

Real Artillery by Jones (http://www.armaholic.com/page.php?id=2121)
Fire Control Calculator by Blake (http://www.armaholic.com/page.php?id=2892)
Chops Artillery by Chops Updated to 1.3 by Viper169th (http://www.armaholic.com/page.php?id=2130)
OnMapClick Artillery by SoLo  (http://www.armaholic.com/page.php?id=1166)
Viper Artillery by Viper169th (http://www.armaholic.com/page.php?id=4043)
Physics-based Artillery by Luke (http://www.ofpec.com/forum/index.php?topic=32347.0)

 :good: