Home   Help Search Login Register  

Author Topic: For the pros.  (Read 6465 times)

0 Members and 1 Guest are viewing this topic.

Zahael

  • Guest
For the pros.
« on: 05 Mar 2003, 03:08:11 »
Hey everybody, I have got a request that hopefully someone can help me with.

I have got a great mission in the works that takes advantage of the Winter Kolg. and it is almost done, but there are a few things that I need for it to be perfect.  Put simply, it is automatic firing.

What I have is a number of situations.  First is at an artillery base, where using an the m46 fieldgun addon, I have a pretty cool firebase going.  What I want however, is for the fieldguns to be pounding away as though they were on a firemission, with their guns elevated and firing say every 20 seconds.  But I just can't do it.  Is there a script that someone can help me with?

Secondly, there is the front line scenerio, where I want heavy machine machine guns firing up and down the line, now at any target in particular, just making a lot of racket.

I am at a loss on how to achieve these aims.  If anyone knows, and any pro hs an idea, cold they please helP?  It would be very valuable to me, and I guarantee it would make the mission better.

Regards, and thanks

Zahael

Offline Archangel Scream

  • Former Staff
  • ****
  • OFPEC Former Staff: Audio editing & mission review
    • Britecorp
Re:For the pros.
« Reply #1 on: 05 Mar 2003, 19:30:40 »
Check the ed depot for artillery scripts.

If you'd like the guns firing as well then set up an elevated game logic and use the "dotarget" and/or the "dofire" command.

Same with the other guns - set up logic points and use a combination of "dofire" commands.

Offline Blanco

  • Former Staff
  • ****
Re:For the pros.
« Reply #2 on: 05 Mar 2003, 23:43:56 »
There are also some invisble targets available for every side but I can't tell you were I found them.

Search or search or search before you ask.

Zahael

  • Guest
Re:For the pros.
« Reply #3 on: 10 Mar 2003, 17:37:53 »
Hey, thanks for the response.

I am not sure what script exactly you are talking about that might help me.  I had a browse, but am not familar enough to know what I am looking for.  Could you be more specific in how I migh achieve what I want to achieve?

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:For the pros.
« Reply #4 on: 10 Mar 2003, 17:52:33 »
Ok. The dofire command is simple. Just put this in a init line/on act line

NameOfTheOneWhoFires dofire NameOfTheTarget

The other one I think require a script, I can do it for you if you wish ;)

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:For the pros.
« Reply #5 on: 10 Mar 2003, 21:53:51 »
I just made a simple script for you in 5 min. ItÂ's not advanced cause I made it in 5 min but what the heck.

I hope you know how to use a script or you will not understand this

[shooter,markername1,markername2,markername3,markername4,markername5,markername6,markername7,markername8,markername9,markername10,keyword] exec "pinneddownscript.sqs"

shooter is the one who fires.
markername is invisible markers that will act like "targets". If you donÂ't want 10 markers then you can name take some of the markers the same name, example:

markername1 = marker
markername2 = marker2
markername3 = marker.

However I do not recommend you do this.

keyword is a keyword and when you turn it true the guns will stop firing in a while. I will update this script soon so itÂ'll stop directly but I havenÂ't got the time. ;)

Have fun! :joystick:

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:For the pros.
« Reply #6 on: 10 Mar 2003, 21:56:06 »
DOH! Forgot to attatch!

One more thing though:
NOTE that I havenÂ't tested the script so there can be some bugs.

EDIT: updated it now. If you make the keyword tru they will stop firing in about 5 sec. Still no advanced script though. And I ahvenÂ't even tested it so it perhaps doesnÂ't even work! ;D
« Last Edit: 11 Mar 2003, 08:03:58 by The real Armstrong »

Zahael

  • Guest
Re:For the pros.
« Reply #7 on: 12 Mar 2003, 10:24:54 »
Sorry mate, not even close.  I placed three markers through the editor (I deleted the rest) and deleted the keyword just to see if it would fire (I deleted the keyword from teh script as well)  Absolutely nothing.  Not a peep.  Maybe you could pay with it a little more and see if you can get it to work.

Thnks for trying.

Any more ideas?

Zahael

Ace

  • Guest
Re:For the pros.
« Reply #8 on: 12 Mar 2003, 23:44:21 »
Armstrons script was good.
Problem was you were ordering people to fire at markers( they're not entities)

Use game logics instead.

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:For the pros.
« Reply #9 on: 13 Mar 2003, 15:32:36 »
Armstrons script was good.
Problem was you were ordering people to fire at markers( they're not entities)

Use game logics instead.

Was my script good?! ;D Thx, m8 :-* I made it in 5 min :P

Zahael

  • Guest
Re:For the pros.
« Reply #10 on: 13 Mar 2003, 16:20:21 »
I think I have tried game logic before. I will try it again, but I am pretty sure that soldiers don't target game logic either.

Ace

  • Guest
Re:For the pros.
« Reply #11 on: 13 Mar 2003, 16:53:34 »
I guarentee they do, use the dofire command

Zahael

  • Guest
Re:For the pros.
« Reply #12 on: 14 Mar 2003, 02:30:06 »
Sorry ace, but even though they seem to target the game logic units, they don't actually fire at it.  They face the logic objects, but they don't actually fire at it.  I used Amstrongs script with the dofire command.  I've tried it a few times with different units with no joy.  Maybe you could try it and get back to me.  

Thanks anyway.

Zahael

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:For the pros.
« Reply #13 on: 14 Mar 2003, 07:49:03 »
Hmmm... Can you skip the dofire command and place out 10 enemies? Just to see if the script is correct.

Offline MI_Fred

  • Members
  • *
  • AA
    • OFP Team Finlanders
Re:For the pros.
« Reply #14 on: 14 Mar 2003, 14:48:00 »
Here's my example mission for 3 of those field guns, you don't need no markers nor gamelogics. I haven't set the dispersion values adjustable (clearly anyho) since all you wan't is the effect of a fire mission right  :)

I've set up some checks for dead crew and low ammo. Don't know if they work. They should. The first rounds come at the same time due to the initial loading... I put in a 3 sec pause there, increase it if that bother you.

Hmm, if there's anything wrong, don't expect me to answer before next friday, I'm off to dig some foxholes again sigh...  :D

There's gooks over there, there's mines over there, and watch out those goddamn monkeys talk, I'll bite ya.

Zahael

  • Guest
Re:For the pros.
« Reply #15 on: 18 Mar 2003, 07:11:54 »
That was FANTASTIC!!! That was exactly what I wanted in regards to the artillery fire mission effect.  I thouroughly recommend you sumbit that to the coding scripts section!

Is there any way to manipulate that script to get the machine gune fire effect?

Thanks again

Zahael

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:For the pros.
« Reply #16 on: 18 Mar 2003, 15:14:58 »
@MI_Fred

Well done, only one thing i had to change:

The guns didn't stop firing, so i've changed your script
and included a firing round counter to be passed with
the exec statement.

MIF_FieldGunArty.sqs:

Code: [Select]
;==MIF_FieldGunArty v.0.5==;
;**original script by MI_Fred
;**additional changes by Chris Death
;**firing round counter added by passing a 4th segment with
;**the exec statement
;**[gun1,gun2,gun3,rounds] exec "MIF_FieldGunArty.sqs"
;**the following was added
;**_rmax (=rounds to fire)
;**_rcount (=counter to check actual firing round)

_gun1 = _this select 0
_gun2 = _this select 1
_gun3 = _this select 2
_guns = [_gun1,_gun2,_gun3]
_rmax = _this select 3

_gnr1 = (gunner _gun1)
_gnr2 = (gunner _gun2)
_gnr3 = (gunner _gun3)
_gnrs = [_gnr1,_gnr2,_gnr3]
_gmax = count _gnrs
_g = 0
_rcount = 0
{_x setCombatMode "RED"} forEach _gnrs


;--the aimpoint, 100 meters in front of middle gun, 30 meters above
_aimpoint = [(getPos _gun2 select 0)+100*(sin(getDir _gun2)),(getPos _gun2 select 1)+100*(cos(getDir _gun2)),(getPos _gun2 select 2)+30]
_ax = _aimpoint select 0
_ay = _aimpoint select 1
_az = _aimpoint select 2


;--makes all gunners watch a random point near the aimpoint
#aimloop
(_gnrs select _g) doWatch [(_ax)-5+(random 5*2),(_ay)-5+(random 5*2),(_az)-2+(random 2*2)]
~.1
_g = _g + 1
? _g == _gmax : goto "prefire"
goto "aimloop"

;--makes the vehicles fire their weapons
#prefire
_gmax = count _gnrs
_g = 0
~3
#fireloop
? ((_guns select _g) ammo (weapons (_guns select _g) select 0)) < 1 : _guns = _guns - [(_guns select _g)]
? (getDammage (_guns select _g)) >= 1 : _guns = _guns - [(_guns select _g)]
(_guns select _g) fire (weapons (_guns select _g) select 0)
~1
_g = _g + 1
? _g == _gmax : goto "reload"
goto "fireloop"

;--the reload
#reload
_rcount = _rcount + 1
? _rcount == _rmax : exit
~20
_g = 0
goto "aimloop"

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:For the pros.
« Reply #17 on: 18 Mar 2003, 16:26:15 »
Quote
Is there any way to manipulate that script to get the machine gune fire effect?

Thanks again

Zahael

OK Zahael, if you can't wait until friday for MI_Fred's
return; I've altered the script to be used by single machineguns.

You need to run the script seperate for every machinegun you want.
To run the script, you just need:
[mg_name,number_of_rounds] exec "MG_salves.sqs"

MG_salves.sqs:

Code: [Select]
;==>MG_salves.sqs<==

;**credits to MI_Fred @OFPEC forum**
;**original script by MI_Fred
;**original script name below**
;==MIF_FieldGunArty v.0.5==;

;**additional changes by Chris Death
;**altered the script to be used by a single machinegun
;[machinegun,rounds_to_fire] exec "MG_salves.sqs"

_gun1 = _this select 0

_g = 0
_rmax = _this select 1
_rcount = 0
{_x setCombatMode "RED"} forEach _gnrs


;--the aimpoint, 100 meters in front of the gun, 30 meters above
_aimpoint = [(getPos _gun1 select 0)+100*(sin(getDir _gun1)),(getPos _gun1 select 1)+100*(cos(getDir _gun1)),(getPos _gun1 select 2)+30]
_ax = _aimpoint select 0
_ay = _aimpoint select 1
_az = _aimpoint select 2


;--makes machinegun watch a random point near the aimpoint

_gun1 doWatch [(_ax)-5+(random 5*2),(_ay)-5+(random 5*2),(_az)-2+(random 2*2)]
~3

;--makes the vehicles fire their weapons

#fireloop

;gunner-check
?!(alive gunner _gun1) : goto "emptygun"

;ammo-check
? _gun1 ammo (weapons _gun1 select 0) < 1 : goto "lowammo"

;gun-functionality-check
? (getDammage _gun1) >= 1 : goto "dammaged"
_gun1 doWatch [(_ax)-5+(random 5*2),(_ay)-5+(random 5*2),(_az)-2+(random 2*2)]
~0.05
_gun1 fire (weapons (_gun1) select 0)
~0.05
_rcount = _rcount + 1
? _rcount < _rmax : goto "fireloop"

goto "endseq"

#emptygun
hint "no gunner in mg"
goto "endseq"

#lowammo
hint "mg out of ammo"
goto "endseq"

#dammaged
hint "mg doesn't work properly anymore"

#endseq
;enable hint for end of script by deleting the ;
;hint "end of firing"
exit

btw - while testing i noticed that the script even works,
if the gunner is the player  ;)

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Zahael

  • Guest
Re:For the pros.
« Reply #18 on: 21 Mar 2003, 02:07:52 »
Awesome. THanks so much.  That post gave me an incredible amount of assistance and shows just why these forums are so handy!!.

I was thinking, is there any way to incorporate it into the script a possible scenerio where say, every 4 seconds, the position of the player (or his squad) is fed into the script as the target and then the machine gun then targets that area?

Just an idea.  I don't want to get to demanding, especially after all the help I have recieved.!!

Mnay thanks

Zahael

p.s have you submitted these to the scripts section??

Offline MI_Fred

  • Members
  • *
  • AA
    • OFP Team Finlanders
Re:For the pros.
« Reply #19 on: 23 Mar 2003, 00:00:28 »
Ufff heh, I have a flu, my eyes are deep in my head, last night was the first time I slept more than  3-4 hours so I can only say it would demand some difficult calculations to get the right heading and elevation for the barrels. That would be prolly a first, real arty aiming at the player... I bet just a doWatch player won't work, atleast without the reveal command. With the reveal you'd make the arty hit as accurately as its skill and rank indicates, which is not a good thing. You'd wan't a lot of randomness. maybe even avoiding direct hits, just to lay some brown substance into the players pants  ;D

Maybe you need to unpbo it, find out the trajectories and that kind of stuff if there is, it has to be calculatable (a word?) Ofcourse, the 20 sec lifetime of a round will come to play here. So you'd only wan't this script running while the player is about 1,5km or less away from this arty.

Or err did you mean MGs? well then this would still be a way to go... aww crap I need to take my medication and goto "bed".  ;D

And Zahael you are demanding, but how else would we get the über scripts out there?  ;D Oh and let's see about that submitting as soon as the above is dealt with. And CD, great work polishing this  ;)
« Last Edit: 23 Mar 2003, 00:04:52 by MI_Fred »
There's gooks over there, there's mines over there, and watch out those goddamn monkeys talk, I'll bite ya.

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:For the pros.
« Reply #20 on: 23 Mar 2003, 01:18:10 »
Quote
And CD, great work polishing this  

lol - the great work still remains to you m8,
just been altering summit "for the pros"  ;)

btw - Zahael - if you mean the "mg's", you just
need to replace the _aimpoint's random calculation
by the payer's position (or by leader player's pos).
And then refer to the aimpoint every 4th second.

If you haf no clu, just say "i hav no clu" or so and me or
Fred gonna show ya how 2 do so.

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Zahael

  • Guest
Re:For the pros.
« Reply #21 on: 23 Mar 2003, 05:52:56 »
Thanks guys.  Yeah, I was actually referring to the machine guns and not the artillery.  The idea I have for my mission is actually a probe mission at night.  The idea is if the player and his small squad get detected, a trigger is tripped and a number of machine gun post (that the player has tried this far to avoid) open up in his general area and lay down the hate.  Its a winter kolguchev mission, and thus far it is pretty cool.

Anyway, I will try to play with the player position thing, but despite the fact that I did programing at uni for 2 years, it has been a long time and I tend to get a lot of errors.  If it isn't too much trouble, and you've got some spare time CD, do ya reakin you could alter it for me?

Thanks for everything. And I hope you feel better Fred.  It takes 1 second of bad health to appreciate 10 seconds of good health.

Thanks guys, and sorry if I am being a pain in the ass.  Oh and by the way, this mission I am talking aout occurs at night.  I wanted to use the default machine guns (the m2) but the light on the things is always on, which doesn't help me.  I am using a user made addon (the heavy KORD 12.7 mm mg) which is pretty cool, but when I design my missions, I like there to be as few addons as possible so as to be available to a wider spectrum.  Is there any way to turn that damn light off ??

Thanks guys.

Zahael

Zahael

  • Guest
Re:For the pros.
« Reply #22 on: 01 Apr 2003, 05:31:35 »
Hey all, anyone know how to turn that freakin light off?

bmgarcangel

  • Guest
Re:For the pros.
« Reply #23 on: 01 Apr 2003, 06:46:45 »
Darn you guys are really into this scripting stuff.  I'm just curious, is it real hard to use it and stuff?

bmgarcangel

  • Guest
Re:For the pros.
« Reply #24 on: 01 Apr 2003, 06:47:16 »
I mean is it really hard to make the scripts and stuff?

Zahael

  • Guest
Re:For the pros.
« Reply #25 on: 01 Apr 2003, 18:16:23 »
Not really.  There are some fantastic tutorials where you can really hook your teeth into them.  I use scripting all the time in regards to cutscenes that I use.  And I mean, the above script, which I would be unable to make, proved to be exactly, exactly what I was after.  Scripts are a real versatile tool for making your mission better.  

If only I could turn off that freakin light.

Zahael

Silverfoot

  • Guest
Re:For the pros.
« Reply #26 on: 25 Apr 2003, 11:49:55 »
Well done for this script, its a real gem...and advanced to!  Makes my experiments with using bycicles in the sea as targets look real amatur!
Having said that I have managed to tweak the script to suit my purposes:

Quote
;==>MG_salves.sqs<==

;**credits to MI_Fred @OFPEC forum**
;**original script by MI_Fred
;**original script name below**
;==MIF_FieldGunArty v.0.5==;

;**additional changes by Chris Death
;**altered the script to be used by a single machinegun
;**further additional tweaking by Silverfoot for crazy D-Day madness!
;[machinegun,rounds_to_fire, target_group] exec "MG_salves.sqs"
#aimit
_gun1 = _this select 0
_g = 0
_rmax = _this select 1
_tgit = _this select 2
_tgit = leader _tgit
_rcount = 0
{_x setCombatMode "RED"} forEach _gnrs


;--the aimpoint, 100 meters in front of the gun, 30 meters above
_aimpoint = [(getPos _tgit select 0)+10*(sin(getDir _gun1)),(getPos _tgit select 1)+10*(cos(getDir _gun1)),(getPos _tgit select 2)-5]
_ax = _aimpoint select 0
_ay = _aimpoint select 1
_az = _aimpoint select 2


;--makes machinegun watch a random point near the aimpoint

_gun1 doWatch [(_ax)-5+(random 5*2),(_ay)-5+(random 5*2),(_az)-2+(random 2*2)]
~1

;--makes the vehicles fire their weapons

#fireloop

;gunner-check
?!(alive gunner _gun1) : goto "emptygun"

;gun-functionality-check
? (getDammage _gun1) >= 1 : goto "dammaged"
_gun1 doWatch [(_ax)-5+(random 5*20),(_ay)-5+(random 5*20),(_az)-2+(random 2*20)]
~0.05
_gun1 fire (weapons (_gun1) select 0)
~0.05

;ammo-check
? _gun1 ammo (weapons _gun1 select 0) < 2 : goto "lowammo"

_rcount = _rcount + 1
? _rcount < _rmax : goto "fireloop"

goto "aimit"

#emptygun
hint "no gunner in mg"
goto "endseq"

#lowammo
hint "no ammo"
_gun1 addmagazine "Browning"
~.3
goto "aimit"

#dammaged
hint "mg doesn't work properly anymore"

#endseq
;enable hint for end of script by deleting the ;
;hint "end of firing"
exit

target_group is new.  The gunner(s) shall pick the leader of specified group and use Fred's random code (that has been modified for greater spread) to fire around a moving target.
[machinegun,rounds_to_fire, target_group] exec "MG_salves.sqs"
in this version rounds_to_fire is best set low, since it is used to allow the gunner to reaim on the target before firing again.  (This script will cause the gunners to shoot forever!) 100 rounds should be fine, maybe less?

I tried this script with 10 mgs on a cliff face and my group on the shore and my god was it intense!  :-X  Iam ever suprised though by the amount of near misses sustained though, its not normally something that happens in OFP I supose  ;D

Oh and has (a version of) this script been submitted yet, as this kind of thing will be wanted by loads of people.....Fred?



Knut Erik

  • Guest
Re:For the pros.
« Reply #27 on: 25 Apr 2003, 13:44:02 »
Yeah, yeah, yeah! Post it now, now, now!
 :D :D :D

There are tons of people wanting a script like this!  :-*

Offline Wadmann

  • OFPEC Patron
  • ****
  • I'm the next evolutionary step after a llama!
Re:For the pros.
« Reply #28 on: 29 Apr 2003, 01:59:15 »
Zahael,

                From the ComRef:

lamppost switchLight mode
Operand types:
    lamppost: Object
    mode: String
Type of returned value:
    Nothing
Description:
    Controls lamppost mode. Mode may be "ON", "OFF", "AUTO". "AUTO" is default, lampost is on only during nighttime.

Example:
    nearestObject [player, "StreetLamp"] switchLight "Off"

This should turn the light off of the MG but as I am at work, I cannot test it. I have used it in the past to turn the light off in a town by way of a trigger and even at the start of a mission by using it in the init.sqs. I look forward to trying this script out when I get a chance.

Note: After work I tried to turn off a light on a MG with this command but it did not work. Perhaps an addon on could be made without the light feature. The way the light shines from above their heads kinda looks like a miner's lamp without the light. Never looked that closely at MGs at night before.
« Last Edit: 29 Apr 2003, 17:43:45 by Wadmann »
Check out my Camouflage Collection! New items added 31 July 2005.

Offline MI_Fred

  • Members
  • *
  • AA
    • OFP Team Finlanders
Re:For the pros.
« Reply #29 on: 03 May 2003, 01:20:12 »
For the light prob I tried:
Quote
_gun setBehaviour "stealth"
_gun action ["light off",_gun]
in my newly revised version of this script, which is attached. Unfortunately it doesn't work fully. They just blink their lights off once and back on again... I must be missing something. Nevertheless it should fill in the role of both MG and arty... you decide. Warning! The MG part truly is...ghastly  ::)

Almost forgot but the example mission needs ofcourse the M46 by DKM mod and ofp v.1.91 due to the typeOf command, but it can be scripted differently if that's needed.
« Last Edit: 03 May 2003, 02:04:12 by MI_Fred »
There's gooks over there, there's mines over there, and watch out those goddamn monkeys talk, I'll bite ya.

B-2-0

  • Guest
Re:For the pros.
« Reply #30 on: 30 May 2003, 08:37:47 »
Keeping the light off......Tommy Cooper style ;D


Light on, light off....light off, light on....light on, light off, light on, light off....


------------------------------------------
;Lightoff.sqs
#A
_this select 0 action ["Light Off"]
goto "A"
------------------------------------------
------------------------------------------
Init field of M2:
[this] exec "Lightoff.sqs"
------------------------------------------

Just like that!! ;)

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:For the pros.
« Reply #31 on: 30 May 2003, 14:07:21 »
Quote
------------------------------------------
;Lightoff.sqs
#A
_this select 0 action ["Light Off"]
goto "A"
------------------------------------------
------------------------------------------
Init field of M2:
[this] exec "Lightoff.sqs"
------------------------------------------


Well - just another way to let the user press the reset
button on his PC  ;)

If you're running a looping script, then NEVER forget to
include some delay of time in there, or your pc will get stuck.

can be easily done with ~x, where x = time in seconds for
the delay - e.g: ~0.5 would make a half of a second delay.

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Offline Blanco

  • Former Staff
  • ****
Re:For the pros.
« Reply #32 on: 28 Apr 2004, 16:46:22 »
You're right Chris, but even with a ~0.000000000001 delay, the script wont work...

The only way to fix that damn lightbug is by changing the addon.
The invasion1944 mod did it, but you can't ask a user to download the whole mod for just one m2 without the lightbug. So make me happy and tell me there 's a standalone version somewhere :)

What's scarier than an M2 machinegun shooting you at night?


« Last Edit: 28 Apr 2004, 16:47:59 by Blanco »
Search or search or search before you ask.

Offline Blanco

  • Former Staff
  • ****
Re:For the pros.
« Reply #33 on: 29 Apr 2004, 16:12:08 »
He guys, this is a wonderfull script!
And I could make it even better... :D

Do you remember Manmg.sqs by General Baron?
AI man MG after gunner dies
I combinate his script with yours...

Here it is :

Code: [Select]
;==>MG_salves._manmg.sqs<==

;**credits to MI_Fred @OFPEC forum**
;**original script by MI_Fred
;**original script name below**
;==MIF_FieldGunArty v.0.5==;

;**additional changes by Chris Death
;**altered the script to be used by a single machinegun
;**further additional tweaking by Silverfoot for crazy D-Day madness!
;**An afterthought by Blanco, combination with General Barron's manmg script


;; THIS IS AN AMAZING SCRIPT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!



;[machinegun,rounds_to_fire, target_group,EXTRA_gunnersgroup] exec "MG_salves_manmg.sqs"
#aimit
_gun1 = _this select 0
_g = 0
_rmax = _this select 1
_tgit = _this select 2
_gnrs = _this select 3
_tgit = leader _tgit
_rcount = 0


#start
_gunner = gunner _gun1


;--the aimpoint, 100 meters in front of the gun, 30 meters above
_aimpoint = [(getPos _tgit select 0)+10*(sin(getDir _gun1)),(getPos _tgit select 1)+10*(cos(getDir _gun1)),(getPos _tgit select 2)-5]
_ax = _aimpoint select 0
_ay = _aimpoint select 1
_az = _aimpoint select 2


;--makes machinegun watch a random point near the aimpoint

_gun1 doWatch [(_ax)-5+(random 5*2),(_ay)-5+(random 5*2),(_az)-2+(random 2*2)]
~1

;--makes the vehicles fire their weapons

#fireloop

;gunner-check
?!alive _gunner : goto "emptygun"

;gun-functionality-check
? (getDammage _gun1) >= 1 : goto "dammaged"
_gun1 doWatch [(_ax)-5+(random 5*20),(_ay)-5+(random 5*20),(_az)-2+(random 2*20)]
~0.05
_gun1 fire (weapons (_gun1) select 0)
~0.05

;ammo-check
? _gun1 ammo (weapons _gun1 select 0) < 2 : goto "lowammo"

_rcount = _rcount + 1
? _rcount < _rmax : goto "fireloop"

goto "aimit"

#emptygun
;hint "no gunner in mg"
goto "nogunner"

#lowammo
;hint "no ammo"
_gun1 addmagazine "Browning"
~.3
goto "aimit"

#dammaged
;hint "mg doesn't work properly anymore"
exit


;; General Baron's manmg.sqs; modified by Blanco to make it all work

#nogunner
?"alive _x" count units _gnrs <= 0 :exit
;if the group manning the machine gun has no units left, exit the script

_gunner = units _gnrs select (count units _gnrs - 1)
;select the last unit in the group

_gunner assignAsGunner _gun1
[_gunner] orderGetIn TRUE
;make him get in the gun


;; when the new gunner got shot on his way to the mg, make sure a new gunner is selected!
#lifecheck
?!alive _gunner : goto "nogunner"
~1
?!(_gunner in _gun1) : goto "lifecheck"

;hint "gunner in"

;The new gunner must unjoin the EXTRA_gunners group,because if he dies the next man won't be selected anymore, i dunno why.
[_gunner] join grpnull
goto "start"

Params are [machinegun,rounds_to_fire, target_group,EXTRA_gunnersgroup] exec "MG_salves_manmg.sqs
PS : I renamed the script to avoid confusion

I even tried it with VIT's KORD en NSV from his APC pack and it works perfectly




« Last Edit: 29 Apr 2004, 18:48:36 by Blanco »
Search or search or search before you ask.

DBR_ONIX

  • Guest
Re:For the pros.
« Reply #34 on: 29 Apr 2004, 16:54:32 »
Just going back to the light prob...
What I think is wrong, is that your tring to make the machinegun turn it's own light off ::)
What (I'm sure) you have to do is
MGLO.sqs
Code: [Select]
_mg = this select 0
_mgop = driver _mg

#loop
_this select 0 action ["Light Off"]
~0.01
GOTO "loop"

And in the M2 INIT
Code: [Select]
this exec "MGLO.sqs"
(BTW MGLO stands for MG Light off, incase you were wondering :P)

Good luck
Will try out Blancos script tonight :)
- Ben

Offline Blanco

  • Former Staff
  • ****
Re:For the pros.
« Reply #35 on: 30 Apr 2004, 16:53:22 »
DBR_ONIX I tried your script, It doesn't work,but it's nice when you need a strobo effect :D

Btw, can somebody move this to the Beta-testing board?
This got nothing to do with Cutscene / sound editing imo ::)
« Last Edit: 30 Apr 2004, 16:56:33 by Blanco »
Search or search or search before you ask.

Offline libriut99

  • Members
  • *
  • 2b or not 2b, who cares ???
Re:For the pros.
« Reply #36 on: 11 Jun 2004, 11:08:27 »
hello to all... sorry to resurrect such an old thread but I have a question concerning the "MG_salves._manmg.sqs" script. how can I make the gunner stop shooting once the target is dead , or fled ?  ???

thanks in advance.
before 'Zee germans get there ...

Offline Blanco

  • Former Staff
  • ****
Re:For the pros.
« Reply #37 on: 16 Jun 2004, 16:38:20 »
once the target is dead the gunner chooses a new target in his firesector (trigger) When the triger is empty he stops shooting. Your trigger is probably too big.



Search or search or search before you ask.

Offline libriut99

  • Members
  • *
  • 2b or not 2b, who cares ???
Re:For the pros.
« Reply #38 on: 17 Jun 2004, 16:13:09 »
Of course ..... thank you Blanco , haven't thought about that .    8)
before 'Zee germans get there ...

Offline Blanco

  • Former Staff
  • ****
Re:For the pros.
« Reply #39 on: 18 Jun 2004, 19:03:19 »
Euh... Libriut99 we are talking about two different scripts.
The one I'm talking about is V2.0

Code: [Select]
;**credits to MI_Fred @OFPEC forum**
;**original script by MI_Fred
;**original script name below**
;==MIF_FieldGunArty v.0.5==;

;**additional changes by Chris Death
;**altered the script to be used by a single machinegun
;**further additional tweaking by Silverfoot for crazy D-Day madness!
;**An afterthought by Blanco, combined with General Barron's manmg script
; ** Further tweaking by Blanco

_enemylist = _this select 0
_gun = _this select 1

; extra gunners are  ** OPTIONAL **
?count _this == 2 : goto "jump"

_xtra = _this select 2

#jump
_rmax = 50
_rcount = 0
_rmax = _rmax / 1.2 + random 10
_mag = (magazines (_gun) select 0)


#waitforenemies
@count _enemylist !=0
goto "pickavictim"

#reset
_rcount = 0
#fireloop
_gunner = gunner _gun
_aimpoint = [(getPos _sucker select 0)+10*(sin(getDir _gun)),(getPos _sucker select 1)+10*(cos(getDir _gun)),(getPos _sucker select 2)-5]

_ax = _aimpoint select 0
_ay = _aimpoint select 1
_az = _aimpoint select 2

_gun doWatch [(_ax)-5+(random 5*2),(_ay)-5+(random 5*2),(_az)-2+(random 2*2)]

;gunner-check
?count _enemylist == 0 : goto "waitforenemies"
?!alive _sucker : goto "pickavictim"
?!alive _gunner : goto "nogunner"

;gun-functionality-check
? (getDammage _gun) >= 1 : goto "dammaged"

_gun doWatch [(_ax)-5+(random 5*10),(_ay)-5+(random 5*10),(_az)-2+(random 2*10)]

~0.05

_gun fire (weapons (_gun) select 0)

~0.05
?random 10 < 0.2: goto "wait"

;ammo-check
?_gun ammo (weapons _gun select 0) < 2 :goto "lowammo"

_rcount = _rcount + 1
? _rcount < _rmax : goto "reset"

goto "fireloop"

#pickavictim
_r = random count _enemylist
_r =_r - _r %1
_sucker = _enemylist select _r
~1
goto "fireloop"

#lowammo
_gun addmagazine _mag
~3
goto "fireloop"

#wait
_r = random count _enemylist
_r =_r - _r %1

_sucker = _enemylist select _r
;hint format ["%1",_sucker]
~2 + random 3
goto "fireloop"

#nogunner
?"alive _x" count units _xtra <= 0 :exit
;if the group manning the machine gun has no units left, exit the script

_gunner = units _xtra select (count units _xtra - 1)
;select the last unit in the group

_gunner assignAsGunner _gun
[_gunner] orderGetIn TRUE
;make him get in the gun


;; when the new gunner got shot on his way to the mg, make sure a new gunner is selected!
#lifecheck
?!alive _gunner : goto "nogunner"
~1
?!(_gunner in _gun) && alive _gun: goto "lifecheck"

;hint "gunner in"

;The new gunner must unjoin the EXTRA_gunners group,because if he dies the next man won't be selected anymore, i dunno why.
[_gunner] join grpnull
goto "waitforenemies"

The use of it is different than the first version

Every machinegun need a trigger in front if it , it represent it's firesector. Since this is only meant for static machineguns, you can perfectly define his firesector. It's a pity we cant "draw" the shape of a trigger in OFP, maybe in OFP2 ... :)

That trigger should be :


Dimensions : It's up to you! Don't make it to big (wide)
Shape : mostly oval, in streetfights I use rectangle, just covering the street
Activation : (Opposite side of MG) detected by (side of MG),ONCE
condition : this
On activation : [thislist,MG1,Xgnrs] exec "MG_salves_manmg2.sqs"


- thislist, just leave it like that
- MG1 is the name of machinegun
- Xgrns is the group name of a group of soldiers seperate to the M2 machine gun. These guys will sieze control of the M2 if/when the gunner dies. This time it's optional.

** CHANGES **

- I removed the rounds parm, the salvo's are randomised and more realistic imo.
- It should work with all third party static machineguns without changing the script.
- The player is not always targetted like in the previous version, The gunner will pick a random victim in his sector adn he will pick another guy between every salvo or reload.
   
** TIPS **

- It works best when the machinegun is on higher ground;
- You can hide your mg's in bunkers, houses, treehouses, whatever... He will schoot every enemy target in his firesector, no matter what.

Known Issues :
- Works in SP and MP, but not recommended in MP, because it uses a tight loop (~0.05)
- The gunner will target every enemytype in his firesector. he will shoot men,tanks, planes, heli's... It think it should be better if he only target men and cars.
Not solved yet.
Search or search or search before you ask.