OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: NightJay0044 on 10 Feb 2009, 10:14:46

Title: testing an attack script (help)
Post by: NightJay0044 on 10 Feb 2009, 10:14:46
Hi all, I'm trying to get the idea of scripting down, I really don't know how yet, but I have the idea of varialbes down I just don't know how to use them and command the script to do what I want it to do.

I know this is not correct but this is just an idea of an attack by a simple west soldier against and east soldier, this is what I want to happen..

Quote
_throw = _this select 0
_Detect = _this select 1
_Attack = _this select 2
_Soldier1 = _this select 3
_enemy1 = _this select 4

If _soldier1 detects _enemy1 then throw "grenade" at _enemy1 if _soldier1 is close enough to _enemy1

As you can see it's pretty straight forward, if west detects east then throw grenade if close enough.

Well I really don't know how to use this, anyone help and please keep it simple like this as close as you can or atleast so I can understand it and I really only know about variables and doing simple things with soldiers and stuff. 

thanks..




Title: Re: testing an attack script (help)
Post by: Rommel92 on 13 Feb 2009, 10:45:15
Code: [Select]
//execution: [<soldier1_unit>, <enemy_unit>] spawn compile preprocessfile "this_script.sqf"
_Soldier1 = _this select 0;
_enemy1 = _this select 1;

If (_soldier1 knowsAbout _enemy1) then {
if (_soldier distance _enemy1) then {
_soldier1 dowatch _enemy1;
sleep 2.667;
_soldier1 Fire ["throw","HandGrenade","GrenadeHand"];
//_soldier1 Fire ["throw","HandGrenadeTimed","GrenadeHandTimed"];
};
};

Hope that helps/works.