Home   Help Search Login Register  

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

0 Members and 1 Guest are viewing this topic.

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.