OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Silverfoot on 23 Apr 2003, 18:30:05

Title: ReArming M2 Machine Gun?
Post by: Silverfoot on 23 Apr 2003, 18:30:05
Hi,  I've written a script which causes the ruskie to constantly fire his M2 across the sea front..this works fine, but after a couple of minuites he runs out of ammo!  ;D  

How can I rearm him?  Ive tried a few addMagazine"<whatever>" commands but I dont know what type of ammo to use.  Will I need to reinitialise the gun instead? (if so how would I do that!?)

Much obliged,

SIlverfoot  :)
Title: Re:ReArming M2 Machine Gun?
Post by: titan on 23 Apr 2003, 18:38:28
what u cld do, is in the script keep giving the guy ammo...

#loop

_unitname addmagazine "browning"

goto "loop"



this will keep giving him mags, but he will have to reload each mag!
Title: Re:ReArming M2 Machine Gun?
Post by: Knut Erik on 23 Apr 2003, 21:38:19
That script is no good  :(
If you add it to many Mg's it will probably cause lags because it adds magazines over and over again for ever...
(Not getting to you, titan)

I'll try to create a simple script:

Ammo.sqs :


_Mgun = _This select 0

#start
?_Mgun ammo "Browning" == 5 : goto moreammo << When the Mg is out of ammo, the script adds a new magazine
?!alive _Mgun : exit << If the Mg is dead, the script exits.
goto "start"

#MoreAmmo
_Mgun addmagazine "Browning"
goto "Start"


Then write this in the init field of the MachineGun
[This] exec "Ammo.sqs"

Not sure about the syntax, but at least this will give you a hint...  8)

*Edit*
Fixed script!
Title: Re:ReArming M2 Machine Gun?
Post by: titan on 23 Apr 2003, 22:48:23
remember that u can only have a certain amount of mags!
Title: Re:ReArming M2 Machine Gun?
Post by: Knut Erik on 23 Apr 2003, 22:54:30
Whooohaaa!! Just tested out the script I wrote, and it adds magazines indeed! It never stops adding magazines before we reload, so you'll have to make the Mg reload when the magazines is added  ;D
Title: Re:ReArming M2 Machine Gun?
Post by: Silverfoot on 24 Apr 2003, 00:48:34
Thanks gents...I think I can use that script  ;)

Though my idea of moving a bicycle across the landscape (below sea level) and getting the gunner to target it has fallen through  :(  (I need to have the targeted object on the shore as well as in the sea, thus a bicycle would look stupid  ::)
I think this problem has been adressed before, but I havent read anywhere the answer I need, so...

Whats the best way to simulate sweeping MG fire, d-day style that is not aimed at anyone?

Game logic cannot be fired upon...neither can markers.  I once tried using bottles of Jack Daniels as targets!  This worked well and required no scripting since the bottle bounced all over the shop!  But after a while went out of range, a simple setPos did not resolve it, since the object retained all its previous velocity and immediatly bounced out of range again  :P

Well, any ideas?

Title: Re:ReArming M2 Machine Gun?
Post by: Knut Erik on 24 Apr 2003, 14:04:37
Look here (http://www.ofpec.com/yabbse/index.php?board=9;action=display;threadid=6999;start=0) at this tread. I've tested the script they made, and it works like a charm!  ;D

And.. Think I've fixed the script up there                                                                                                
Title: Re:ReArming M2 Machine Gun?
Post by: Silverfoot on 24 Apr 2003, 17:56:27
Thanks Knut, and what a script!  D-day here we come...(dam that sounds sick.....<hangs head in shame>  >:( )

By the way has this snippet been submitted to the Editor's Depot yet?   It should be, cos there are loads of people wanting to use this kind of thing  ;).....the OPFEC does it again!  ;D
Title: Re:ReArming M2 Machine Gun?
Post by: Knut Erik on 25 Apr 2003, 13:40:50
By the way has this snippet been submitted to the Editor's Depot yet?   It should be, cos there are loads of people wanting to use this kind of thing  ;).....the OPFEC does it again!  ;D

Yeah right. It is a great script after all. I'll ask the peps that made it.

*Erik runs to the thred to invastigate