Home   Help Search Login Register  

Author Topic: High dispersion Fire Script  (Read 2774 times)

0 Members and 1 Guest are viewing this topic.

CptBravo

  • Guest
High dispersion Fire Script
« on: 01 Sep 2006, 02:46:06 »
Hey everyone,

There used to be a High dispersion Fire Script but I can no longer find it in the scripts section.  ???

Anyone has it or has similar one :scratch:

Thanks in advance for your help :)

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re: High dispersion Fire Script
« Reply #1 on: 01 Sep 2006, 02:58:22 »
Maybe you'd better give JAM a try - JAM is an addon which gives you standard ammo for
weapons of same ammo type (depending on the calibre of the weapon).

All weapons with e.g: 5.56 calibre can use the same ammo so that you could take magazines
from dead soldiers not wearing the same weapon but the same calibre like you.

There are some other effects too like weapon sounds / debris / bullets on ground.

And the most interesting thing for you is: all weapons appear in a second version featuring
HD (high dispersion). No need to add any scripts - all is done automatically for you and
well explained in document files.

Available here: http://ofp.gamepark.cz/index.php?showthis=8810

~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 Wadmann

  • OFPEC Patron
  • ****
  • I'm the next evolutionary step after a llama!
Re: High dispersion Fire Script
« Reply #2 on: 01 Sep 2006, 06:51:27 »
As CD pointed out, you can use JAM but if you do not want to use addons you do have some options.

1) The easiest way to to add dispersion to any unit is to setdammge any unit to -1. I do not believe that this will work for armour or mounted/static weapons though. If this is want you want, see #2.

2) Use the script in the copy of the post by General Coder below:

Quote
Maybe you can use a temporaly fire dispersion script... They shoot but they don't hit anything.At least that's how I should solve the problem.

Put this in your V80's init :
Code:
This addeventhandler ["fired",{_this exec "fd.sqs"}]
 

And this in a init.sqs

dispersionoff = false


When you want to stop the dispersion script put
dispersionoff = true
in a waypoint, trigger or script.

Here is fd.sqs by GeneralCoder
Code:
;;fd.sqs

_shooter = _this select 0
_projectile = nearestObject [vehicle(_shooter), _this select 4]

?dispersionoff : _shooter removeEventHandler ["fired",0];exit
?(_shooter == player): exit
?((_this select 2) == "throw"): exit

_vel = velocity _projectile
_speed = speed _projectile

_disp = (_speed * (0.03 - (skill _shooter)/100) )
_dispX2 = _disp*2

_projectile SetVelocity [(_vel select 0) - _disp + Random(_dispX2),(_vel select 1) - _disp + Random(_dispX2),(_vel select 2) - _disp + Random(_dispX2)]
 


If you want more dispersion change 0.03 in this line
Code:
_disp = (_speed * (0.03 - (skill _shooter)/100) )
 

...in a higher value

3) Another dispersion script, author unknown.

Code: [Select]
;If your unit is called "MG42" you can write the following in the Init.sqs file, in a trigger, or in any script:

;MG42 AddEventHandler ["fired",{_this Exec "scriptname.sqs"}]

;If you are going to use it in the unit's init line then:

;this AddEventHandler ["fired",{_this Exec "scriptname.sqs"}]

_shooter = _this select 0
_weapon  = _this select 1
_muzzle  = _this select 2
_mode    = _this select 3
_shell   = _this select 4

;Obtain the bullet and details.
_bullet = NearestObject [_shooter,_shell]

;Creating velocity array.
_velocity = Velocity _bullet
_x1 = _velocity Select 0
_y1 = _velocity Select 1
_z1 = _velocity Select 2


;New x value.
_variable1 = Random 10

?(_variable1 > 5): _polarity1 = -2
?(_variable1 < 5): _polarity1 = +2

_x2 = _x1 + ((Random 20) * _polarity1)


;New y value.
_variable2 = Random 10

?(_variable2 > 5): _polarity2 = -2
?(_variable2 < 5): _polarity2 = +2

_y2 = _y1 + ((Random 20) * _polarity2)


;New y value.
_variable3 = Random 10

?(_variable3 > 5): _polarity3 = -1
?(_variable3 < 5): _polarity3 = +1

_z2 = _z1 + ((Random 30) * _polarity3)


;New velocity.
_velocity2 = [_x2,_y2,_z2]

_bullet SetVelocity _velocity2
~0

Exit

If you have any question, feel free to ask but as I did not write them, I may not be able to help.

Enjoy!

Note: Scripts posted as text instead of attachment due to the numerous lost attachments when OFPEC last went down. If such a terrible thing were to happen again, posts such as this one will still contain the desired information.

Wadmann
Check out my Camouflage Collection! New items added 31 July 2005.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: High dispersion Fire Script
« Reply #3 on: 01 Sep 2006, 17:08:34 »
Much better would be to use a short function instead of an sqs..

And never ever 'catch' the fired bullet in the script/function, always 'catch' it in the eventHandler..
This way even under FPS of 1 the bullet gets 'caught', when 'catching' it in a script when the FPS is lower than 15 the chances of actually 'catching' it become pretty low (lotsa experience with this..)..

The init.sqs
Code: [Select]
myTAG_dispersion = preprocessFile "dispersion.sqf"
The eventHandler:
Code: [Select]
this addEventHandler ["fired",{_bul = (nearestObject [(vehicle this), _this select 4)]; [_this select 0,_bul,(velocity _bul),(speed _bul)] call myTAG_dispersion}]
The dispersion.sqf:
Code: [Select]
private ["_sht","_prj","_vel","_spd","_dispA","_dispB"];

_sht = _this select 0;
_prj = _this select 1;
_vel = _this select 2;
_spd = _this select 3;

_dispA = (_spd*(0.03-(skill _sht)/100));
_dispB = _dispA*2;

_prj setVelocity [(_vel select 0) - _disp + random(_dispB),(_vel select 1) - _disp + random(_dispB),(_vel select 2) - _disp + random(_dispB)];


Not tested so no guarantees it will work 'out of the box'..

 :2c:
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Walter_E_Kurtz

  • Guest
Re: High dispersion Fire Script
« Reply #4 on: 22 Feb 2011, 21:26:21 »
As has been pointed out elsewhere, h- was wise to offer no guarantees. There are problems with the EventHandler and the sqf function. The following should be correct:

Code: (Init.sqs) [Select]
myTAG_dispersion = preprocessFile "dispersion.sqf"

Code: (EventHandler) [Select]
this addEventHandler ["fired",{_bul = (nearestObject [_this select 0, _this select 4]); [_this select 0,_bul,(velocity _bul),(speed _bul)] call myTAG_dispersion}]
Code: (EventHandler for groups) [Select]
"_x addEventHandler [""fired"",{_bul = (nearestObject [_this select 0, _this select 4]); [_this select 0,_bul,(velocity _bul),(speed _bul)] call myTAG_dispersion}]" forEach units this

Code: (Dispersion.sqf) [Select]
private ["_sht","_prj","_vel","_spd","_dispA","_dispB"];

_sht = _this select 0;
_prj = _this select 1;
_vel = _this select 2;
_spd = _this select 3;

_dispA = (_spd*(0.03-(skill _sht)/100));
_dispB = _dispA*2;

_prj setVelocity [(_vel select 0) - _dispA + random(_dispB),(_vel select 1) - _dispA + random(_dispB),(_vel select 2) - _dispA + random(_dispB)];

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: High dispersion Fire Script
« Reply #5 on: 23 Feb 2011, 08:26:22 »
Quite embarrassing errors/typos I made back then..  :D
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.