Home   Help Search Login Register  

Author Topic: gun elevation  (Read 4457 times)

0 Members and 1 Guest are viewing this topic.

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: gun elevation
« Reply #15 on: 11 Nov 2007, 16:37:48 »
Code: [Select]
_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.
Campaigns are hard, I'll stick with scripting for now!

Offline Hellbender

  • Members
  • *
Re: gun elevation
« Reply #16 on: 11 Nov 2007, 17:14:18 »
Okay!

Quote
[this,30] execVM "repeatedfire.sqf";

This won't work in the init field! I get the errormessage
Quote
"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?

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: gun elevation
« Reply #17 on: 11 Nov 2007, 17:52:04 »
execVM is for sqf scripts and functions.

exec is for sqs scripts


Planck
I know a little about a lot, and a lot about a little.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: gun elevation
« Reply #18 on: 11 Nov 2007, 17:53:49 »
Code: [Select]
[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:
Code: [Select]
res = [this,30] execVM "repeatedfire.sqf";

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: gun elevation
« Reply #19 on: 11 Nov 2007, 18:01:04 »
i usually use call {[parameters] execVM "script.sqf"}

you cant really go wrong with that.
Campaigns are hard, I'll stick with scripting for now!

Offline trooper543

  • Members
  • *
Re: gun elevation
« Reply #20 on: 03 Dec 2007, 21:02:43 »
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

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: gun elevation
« Reply #21 on: 03 Dec 2007, 21:11:39 »
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.
Campaigns are hard, I'll stick with scripting for now!

Offline trooper543

  • Members
  • *
Re: gun elevation
« Reply #22 on: 03 Dec 2007, 22:33:28 »
Surdus Priest

Thanks for the fast response but unfortunetly i am not very good at scripting.

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: gun elevation
« Reply #23 on: 04 Dec 2007, 01:47:46 »
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.

Code: [Select]
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
Code: (BigBaraBoom.sqs by Bohemia Interactive Studios) [Select]
; 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;
« Last Edit: 16 Jan 2011, 18:02:35 by Walter_E_Kurtz »
Campaigns are hard, I'll stick with scripting for now!

Offline trooper543

  • Members
  • *
Re: gun elevation
« Reply #24 on: 05 Dec 2007, 18:38:56 »
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


Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: gun elevation
« Reply #25 on: 05 Dec 2007, 19:15:56 »
ok, put this in the init file for each arty gun (example has 4 guns):

Code: [Select]
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).

Code: [Select]
//_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.
« Last Edit: 05 Dec 2007, 19:20:03 by Surdus Priest »
Campaigns are hard, I'll stick with scripting for now!

Offline trooper543

  • Members
  • *
Re: gun elevation
« Reply #26 on: 07 Dec 2007, 19:47:52 »
@  Surdus Priest

Thanks a million for that mate!! Really appreciate the help


Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: gun elevation
« Reply #27 on: 07 Dec 2007, 22:56:48 »
Quote
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.
"When 900 years YOU reach, look as good you will not!"

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: gun elevation
« Reply #28 on: 14 Dec 2007, 19:53:09 »
true, but imagine if someone released a script you werent finished making lol
Campaigns are hard, I'll stick with scripting for now!