Home   Help Search Login Register  

Author Topic: gun elevation  (Read 5187 times)

0 Members and 1 Guest are viewing this topic.

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
gun elevation
« 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?
Campaigns are hard, I'll stick with scripting for now!

Offline Cheetah

  • Former Staff
  • ****
Re: gun elevation
« Reply #1 on: 07 Nov 2007, 15:09:44 »
I tried the following in one of my scripts:

Code: [Select]
_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.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline jones

  • Members
  • *
Re: gun elevation
« Reply #2 on: 07 Nov 2007, 15:10:50 »
try the "do commands 

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.
« Last Edit: 07 Nov 2007, 15:24:39 by jones »

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: gun elevation
« Reply #3 on: 07 Nov 2007, 15:17:11 »
I tried the following in one of my scripts:

Code: [Select]
_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.
Campaigns are hard, I'll stick with scripting for now!

Offline Cheetah

  • Former Staff
  • ****
Re: gun elevation
« Reply #4 on: 07 Nov 2007, 16:26:16 »
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).
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: gun elevation
« Reply #5 on: 07 Nov 2007, 16:55:58 »
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.
Campaigns are hard, I'll stick with scripting for now!

Offline jones

  • Members
  • *
Re: gun elevation
« Reply #6 on: 08 Nov 2007, 15:09:04 »
have you tried running the script in a loop? this might prevent the unit from changing it's behaviour.

Offline Cheetah

  • Former Staff
  • ****
Re: gun elevation
« Reply #7 on: 08 Nov 2007, 15:30:59 »
My experience with using a loop to achieve this is the same as mentioned
Quote
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.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Re: gun elevation
« Reply #8 on: 09 Nov 2007, 17:11:04 »
DisableAi "FIRE"

I think thats right.

May I ask what you did to get the artillery to face into the sky?

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: gun elevation
« Reply #9 on: 09 Nov 2007, 19:04:37 »
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];
Campaigns are hard, I'll stick with scripting for now!

Offline Hellbender

  • Members
  • *
Re: gun elevation
« Reply #10 on: 10 Nov 2007, 20:32:12 »
So what if someone also wanted these guns to fire repeatedly while aiming at the sky? (Replacing doWatch with doFire doesn't work her!)

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: gun elevation
« Reply #11 on: 10 Nov 2007, 21:53:14 »
u shud probably use da fire comand....

ull need 2 figure out wat shells 2 use tho...

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: gun elevation
« Reply #12 on: 11 Nov 2007, 02:34:43 »
_gun action ["useWeapon", _gun,gunner _gun,0];

will make the gun fire
Campaigns are hard, I'll stick with scripting for now!

Offline Hellbender

  • Members
  • *
Re: gun elevation
« Reply #13 on: 11 Nov 2007, 04:40:22 »
Alright, that works!

Thanks!

One more thing though! How do I get it to fire again and again by using a trigger?
« Last Edit: 11 Nov 2007, 04:47:56 by Hellbender »

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: gun elevation
« Reply #14 on: 11 Nov 2007, 14:14:44 »
easier 2 use a script...

create a file called "repeatedfire.sqf" and in it put

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{};

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
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

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!