OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Surdus Priest on 07 Nov 2007, 15:04:55
-
i know this sort of thing has been asked before several times. and i have searched them all.
but all i need is a way of making arty guns aim into the sky.
it would be easy if the invisible H about 20 meters up worked. but the guns will respond to nothing in the sky other than a chopper.
is there an easier way?
-
I tried the following in one of my scripts:
_x doWatch [(getPos _x select 0),(getPos _x select 1),1000];
Sadly, it didn't work out that well. Should be possible to use something this easy. Could be that the command gets easily overridden by enemy forces for example.
-
try the "do commands
http://www.ofpec.com/COMREF/index.php?action=list&game=All&letter=d#doWatch (http://www.ofpec.com/COMREF/index.php?action=list&game=All&letter=d#doWatch)
This would have the gun look straight up.
_x = (getpos _unit) select 0;
_y = (getpos _unit) select 1;
_unit Dowatch [_x, _y, 1000};
This would get the unit to look foward and up 500 meters.
_apos = ( position _unit );
_posa = ( _apos select 0 ) ;
_posb = ( _apos select 1 ) + 500;
_posc = ( _apos select 2 ) + 500;
_cpos = [ _posa, _posb, _posc ];
_unit Do Watch _cpos;
Mind you I haven't actually tested it but I belive it would work.
i am not sure exactl what you are trying to accomplish if you were more specific you could probably get abetter answer.
-
I tried the following in one of my scripts:
_x doWatch [(getPos _x select 0),(getPos _x select 1),1000];
Sadly, it didn't work out that well. Should be possible to use something this easy. Could be that the command gets easily overridden by enemy forces for example.
i've been trying that. but when i make the target an invisible object, or even just a wooden fence. it targets the ground where the object is above.
-
Well I didn't use an object to look at. Tried to make the gun look at a position 1 km into the air (_x is the artillery piece).
-
right, it all works fine now.
all i need now it to know how to make a unit completely ignore enemies.
i know theres the setcomabtmode "blue".
but even that will allow the unit to sometimes aim at units and then continue aiming in the sky.
-
have you tried running the script in a loop? this might prevent the unit from changing it's behaviour.
-
My experience with using a loop to achieve this is the same as mentioned
but even that will allow the unit to sometimes aim at units and then continue aiming in the sky.
.
Guess the only way is to turn off the AI's thinking.
-
DisableAi "FIRE"
I think thats right.
May I ask what you did to get the artillery to face into the sky?
-
i dont use disableai in my missions, because the saveGame bug ruins it.
and to get the arty guns aiming into the sky, cheetahs idea worked:
_x doWatch [(getPos _x select 0),(getPos _x select 1),1000];
-
So what if someone also wanted these guns to fire repeatedly while aiming at the sky? (Replacing doWatch with doFire doesn't work her!)
-
u shud probably use da fire (http://www.ofpec.com/COMREF/index.php?action=list&game=All&letter=f#fire) comand....
ull need 2 figure out wat shells 2 use tho...
LCD OUT
-
_gun action ["useWeapon", _gun,gunner _gun,0];
will make the gun fire
-
Alright, that works!
Thanks!
One more thing though! How do I get it to fire again and again by using a trigger?
-
easier 2 use a script...
create a file called "repeatedfire.sqf" and in it put
_arty = _this select 0;
_delay = _this select 1;
while {alive _arty} do
{
_arty action ["useWeapon", _arty ,gunner _arty ,0];
sleep _delay;
};
if (true) exitwith{};
now in da init of da arty put
[this,30] execVM "repeatedfire.sqf";
u can change da number 2 have more or less delay between shots...
LCD OUT
-
_arty = _this select 0;
_delay = _this select 1;
while {alive _arty} do
{
_arty action ["useWeapon", _arty ,gunner _arty ,0];
sleep _delay;
};
if (true) exitwith{};
this will also work with a number of arty guns, by putting the names of the guns in the script. but you would need to forget about putting the guns name in the parameter. unless you formated the names in a loop.
-
Okay!
[this,30] execVM "repeatedfire.sqf";
This won't work in the init field! I get the errormessage "Type Script, expected Nothing"
Can't get it to work by placing it in a waypoint script field either.
I'm such a noob with scripting! Can you tell me what's wrong?
-
execVM is for sqf scripts and functions.
exec is for sqs scripts
Planck
-
[this,30] execVM "repeatedfire.sqf";
will work fine in any init field, wp activation field or trigger action as long as you use the form:
res = [this,30] execVM "repeatedfire.sqf";
-
i usually use call {[parameters] execVM "script.sqf"}
you cant really go wrong with that.
-
Hi there
Could someone please explain on how i can use this script /or perhaps provide the rest of the script
What i am trying too do for a cutscene is have 4 AI guns fire repeatedley at a nearby town
Any help would be most appreciated
Thanks in advance
-
well, if you have read the script and understand it, its just a matter of making the arty gun aim in the direction of the town, then use trial and error to get the correct height. as for firing repeatedly, just run a loop. but make sure you at a shell to the units ammo, otherwise the gun will eventually run out.
-
Surdus Priest
Thanks for the fast response but unfortunetly i am not very good at scripting.
-
call the gun arty1, then put this line in init.sqs (or unit init field).
arty1 dowatch [(getPos artytarget select 0),(getPos artytarget select 1),1000];
create a game logic and call it artytarget. then put the game logic over the place your want the gun to aim.
the 1000 in the dowatch will make the gun aim straight up. if you set it to 500 or 200 it will aim lower (you will need to play about with it).
so far you have a gun which aims where you want it to, and it has its gun raised.
now, for the repeated fire.
while {firing == 1} do
{
arty1 action ["useWeapon",arty1,gunner arty1,0];
arty1 addmagazine "<magazine>";
sleep 5;
};
you will need a 5 second delay, otherwise the gun will attempt to fire while reloading, which will cause it to wait until the next firing.
the addmagazine will ensure that the arty gun always has the same amount of ammo.
so that is literally how its done. but, that will only make the gun aim and fire. to make the explosions (and randomly realistic ones. you will need to study an old script made in ofp, bigbaraboom.sqs.
Edit: attached script (BigBaraBoom.sqs) lost in the crash of 2009; re-quoted here - WEK; Bombarding
; Run from mission:
; [who, A, B, C, "Name"] exec "BigBaraBoom.sqs"
; who - who runs the script (can be anybody)
; A - how many bombs
; B - diameter of "Area bombed"
; C - timout between two bombs
; D - name of the marker, which is in the middle of the "Area bombed"
_pos = getmarkerpos (_this select 4);
_bomb = "Bomb" createVehicle _pos;
_i = 0;
_j = _this select 1;
_k = _this select 2;
_t = _this select 3;
#LOOP
_u = random _k;
_bomb setpos [(_pos select 0) - _k/2 + random _k, (_pos select 1) - _k/2 + random _k]
_bomb setdammage 1;
~(random _t)
_bomb setdammage 0;
~(random _t)
_i = _i+1;
? prijeli : exit
? _i < _j : goto "LOOP"
deleteVehicle _bomb;
-
Surdus Priest
Thanks a lot mate for the help but like i said i am really bad at scripting and i would not know where to start.
Could i ask that you take me step by step through this ( Sorry for my newbieness) but my only experience with script is viewing a script and then working out how it all works and then altering it.
Your assisstance would be most appreciated
what i am trying to do is have a battery of A1 guns fire repeatedly on a traget so that i can make a movie clip and then it is also required for a sp mission that i am in the process of creating.
Your assistance will be credited in the final release of the clip and mission
I have taken the liberty to credit you already for the assistance if that is okay with you
-
ok, put this in the init file for each arty gun (example has 4 guns):
arty1 dowatch [(getPos artytarget select 0),(getPos artytarget select 1),1000];
arty2 dowatch [(getPos artytarget select 0),(getPos artytarget select 1),1000];
arty3 dowatch [(getPos artytarget select 0),(getPos artytarget select 1),1000];
arty4 dowatch [(getPos artytarget select 0),(getPos artytarget select 1),1000];
place 4 D-30s in the game, name each of the 4 guns arty, then the number; arty1.
then make a game logic and call it artytarget. put the gamelogic on the location of target area.
then make a marker on the map where you want to be bombarded, call it artytarget aswell (put it next to gamelogic).
//_a = area size of bombardment
//_m = marker of bombardment
_a = _this select 0;
_m = getmarkerpos (_this select 1);
firing = 1;
_gunsNo = [arty1, arty2, arty3, arty4];
sleep 5;
while {firing == 1} do
{
arty1 action ["useWeapon",arty1,gunner arty1,0];
sleep 1;
arty2 action ["useWeapon",arty1,gunner arty1,0];
sleep 1;
arty3 action ["useWeapon",arty1,gunner arty1,0];
sleep 1;
arty4 action ["useWeapon",arty1,gunner arty1,0];
{_x addmagazine "30Rnd_122mmHE_D30"} foreach _gunsNo;
sleep 3;
_exp = "R_S8T_AT" createVehicle [(_m select 0) - _a/2 + random _a, (_m select 1) - _a/2 + random _a];
sleep 1;
_exp = "R_S8T_AT" createVehicle [(_m select 0) - _a/2 + random _a, (_m select 1) - _a/2 + random _a];
sleep 1;
_exp = "R_S8T_AT" createVehicle [(_m select 0) - _a/2 + random _a, (_m select 1) - _a/2 + random _a];
sleep 1;
_exp = "R_S8T_AT" createVehicle [(_m select 0) - _a/2 + random _a, (_m select 1) - _a/2 + random _a];
sleep 3;
};
exit;
put this code into an sqf file and call it worldofpain.sqf
then in the init file put: call {[150, "artytarget"] execVM "worldofpain.sqf"};
and thats it.
surdus
ps. this script is based on a script i created, however it was updated for enhanced performance by a member of MMU and thus has become MMU property and cannot be shown here.
-
@ Surdus Priest
Thanks a million for that mate!! Really appreciate the help
-
ps. this script is based on a script i created, however it was updated for enhanced performance by a member of MMU and thus has become MMU property and cannot be shown here.
:confused: Remember the slogan of OFPEC: "By the community, for the community". We give some, you give some back. In most cases we give advice and support (or maths), and you give scripts, resources or missions for us and everybody else to enjoy. It's all a very happy circle, in fact.
Talking about scripting "property" really seems a bit...unnecessary, to be honest. Scripts are there to be used and shared and modified and enjoyed, not to be the sole right of any one grouping. :)
Each to his own though...
Wolfrug out.
-
true, but imagine if someone released a script you werent finished making lol