Author Topic: seven's (sniper)spotting script (ACCEPTED)  (Read 3707 times)

0 Members and 1 Guest are viewing this topic.

Offline [seven]

  • Members
  • *
seven's (sniper)spotting script (ACCEPTED)
« on: 05 Jun 2007, 01:18:51 »
Originally I made this script for myself so I didn't have to take too long to perfect my marksmanship skills, but after posting about it in the ubisoft forums a few weeks back I had a some requests to release it.  :scratch:

This is a link to that thread:

The spotting script can be applied to any single player sniping mission to help you you nail the target by providing crucial (and some non crucial) sniping data.   I don't know if it will work for multi but once I know the SP works fine I'll try to work on MP.  :good:

It requires a sniping team of more than one soldier OR you can use just one soldier if you wish to add his targets via scripting.

; WIND HEADING - direction of the wind (shown in degrees and compass direction)
; WIND SPEED - speed of the wind
; OVERCAST - displays how much cloud cover is obscuring the sunlight
; PECIPITATION - displays how much rain is in the air
; VISIBILITY - visibility detemines at what distance the ability to cleary see objects degrades, NOT the distance it can be seen from.  this measurement is fairly accurate.
; RANGED@ - the distance which a weapon is ranged at.  if the rifle is ranged at 300m then the bullet will hit the center of the crosshairs at this range.  any further and
; the bullet will drop below the center, any closer and ythe bullet will hit above the center.
; EFFECTIVE - the effective range of the weapon.  accuracy is reduced substantially beyond this range.
; TGTDIST - distance to the target
; TGTSPEED - speed the target is moving at
; TGTHEADING - the heading of the target (shown in degrees and compass direction)
; TARGETDIR - the direction to the target (shown in degrees and compass direction)
; TARGETANG - the angle to the target from the player
; BALLISTIC LAG - an approximation of how long it will take your bullet to hit it's assigned target, very useful for moving targets.  should be accurate down to 1/10 sec.

Works for rifles and smg's only.

I'm not sure if the wind/weather actually has an effect on the bullets but it adds a degree of realism since real snipers use this stuff.

More information on it's usage can be found when you open up sniperspotter.sqs in notepad.

I have two archives here, one is just the main script plus the scripts that go with it.  The second is a Paraiso airport converted to a targetting range, not really demo missions but they do showcase what the script does.  One example has pop-up targets, the other has live ones.  I find the live targets are more illustrative of how the script can be used in missions while the pop-up are excellent for testing your skills and gives you an idea of how well you are doing.

Feedback is appreciated.  Enjoy!  :yes:

Now you see them...

Now they are dead...
« Last Edit: 21 Mar 2008, 15:09:57 by [seven] »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: seven's spotting script
« Reply #1 on: 05 Jun 2007, 01:39:41 »
Press Print Screen key and then paste in Paint as save as jpg.

Offline [seven]

  • Members
  • *
Re: seven's spotting script
« Reply #2 on: 05 Jun 2007, 01:59:40 »
Pics added, thanks mandoble!

Offline DucusSumus

  • Members
  • *
  • I'm a llama!
Re: seven's (sniper)spotting script
« Reply #3 on: 05 Jun 2007, 07:02:31 »
Very cool.

Offline [seven]

  • Members
  • *
Re: seven's (sniper)spotting script (ADDONLESS MISSIONS REQ)
« Reply #4 on: 21 Sep 2007, 05:50:52 »
Demo mission now fixed so no addon is required as per Mandobles request.  :)
« Last Edit: 21 Sep 2007, 06:56:12 by [seven] »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: seven's (sniper)spotting script (ADDONLESS MISSIONS REQ)
« Reply #5 on: 21 Sep 2007, 12:38:18 »
Thanks [seven]  :good:

Now some questions and dirty proposals  :D

- It seems to me that you are using absolute dirs instead of relative ones. What about using relative ones? I mean, the direction of the wind is relative to the direction of the current weapon, so what you get is a deviation in degrees where 0 means the wind is aligned with the weapon. For example, -10 means the wind is traveling 10 degress to the left of where my weapon is pointing. Same for target. A target going west, north or whatever is important only if you know which is the direction, at least, of your weapon, else what you want is the relative heading with the heading of the weapon (target closing, moving to left, right, etc, but not North, Weast, etc).

- About weapons info, how about reading the config to get the values?

- Would you like to get rid of the hint box and use a detailed display instead?

If you were willing to incorportate any of these and you need any help with it, just tell us  ;)

Offline [seven]

  • Members
  • *
Re: seven's (sniper)spotting script (DELAYED)
« Reply #6 on: 21 Sep 2007, 15:50:22 »
Thank you Mandoble for reviewing my work.  I never played ofp and this was my first attempt to create something for arma that can be shared with others, truth be told, the first piece of code I've written since the commodore 64 was in style! :o  So I hope I can be forgiven if the structure is a bit crude.

To address your first point: If you looked over the script you can probably see I like having different options, so this is a no brainer.  I didn't fathom giving relative degrees, but I like the idea of it.  I'll add this.

Second point: This seems like a good idea since addon weapons would be auto recognized, BUT I'm not sure that the config file shows the effective range of a weapon (my values for effective range came from weapon websites etc).  Perhaps we can have it read the config and then afterwards check to see if the weapon is in the predefined list in the script, if so it could also show the effective range, if not in the predefined list we could have it simply omit the effective range and carry on as usual. 

So sounds good, I just need a piece of code as an example of the best way to check the weapon configs and convert the info for display.

Lastly: The hint box I never liked, but I only have so much time and being a novice at this it was all I really could do.  I'd like something fancier and I'm sure anyone else interested in using it will appreciate not having half of their screen eaten up by that ugly monster of a box!  :D

I have no clue how to do this one, so I'll need a bit of help with this as well.

Cheers  ;)
« Last Edit: 21 Sep 2007, 15:52:23 by [seven] »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: seven's (sniper)spotting script (DELAYED)
« Reply #7 on: 21 Sep 2007, 15:53:26 »
Ok, I'll proceed to test and submit your current version as it is now, then we'll talk about next improvements ;)

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: seven's (sniper)spotting script (DELAYED)
« Reply #8 on: 21 Sep 2007, 16:09:19 »
Code: [Select]
Following is a copy of the class Default from the ArmA cfgWeapons section of the ArmA bin.pbo.

 class Default
  access = 3;
  scope = 0;
  value = 2;
  picture = "";
  uiPicture = "";
  ammo = "";
  cursor = "";
  cursorAim = "";
  cursorSize = 1;
  showAimCursorInternal = 1;
  cursorAimOn = "";
  laser = 0;
  type = 65536;
  displayName = "";
  nameSound = "";
  count = 0;
  multiplier = 1;
  burst = 1;
  magazineReloadTime = 0;
  reloadTime = 1;
  sound[] = {"",1,1};
  soundContinuous = 0;
  soundBurst = 1;
  drySound[] = {"",1,1};
  reloadSound[] = {"",1,1};
  reloadMagazineSound[] = {"",1,1};
  initSpeed = 0;
  dispersion = 0.002;
  aiDispersionCoefX = 1;
  aiDispersionCoefY = 1;
  canLock = 2;
  enableAttack = 1;
  ffMagnitude = 0;
  ffFrequency = 1;
  ffCount = 1;
  recoil = "empty";
  recoilProne = "";
  model = "";
  modelSpecial = "";
  modelMagazine = "";
  muzzlePos = "usti hlavne";
  muzzleEnd = "konec hlavne";
  cartridgePos = "nabojnicestart";
  cartridgeVel = "nabojniceend";
  selectionFireAnim = "zasleh";
  memoryPointCamera = "eye";
  modelOptics = "";
  opticsFlare = 1;
  optics = 1;
  forceOptics = 0;
  useAsBinocular = 0;
  opticsDisablePeripherialVision = 0.67;
  opticsZoomMin = 0.35;
  opticsZoomMax = 0.35;
  opticsZoomInit = 0.35;
  distanceZoomMin = 400;
  distanceZoomMax = 400;
  primary = 10;
  showSwitchAction = 0;
  showEmpty = 1;
  autoFire = 0;
  autoReload = 1;
  autoAimEnabled = 1;
  showToPlayer = 1;
  aiRateOfFire = 5;
  aiRateOfFireDistance = 500;
  fireLightDuration = 0.05;
  fireLightIntensity = 0.012;
  backgroundReload = 0;
  reloadAction = "";
  muzzles[] = {"this"};
  magazines[] = {};
  modes[] = {"this"};
  useAction = 0;
  useActionTitle = "";
  canDrop = 1;
  minRange = 1;
  minRangeProbab = 0.3;
  midRange = 150;
  midRangeProbab = 0.58;
  maxRange = 500;
  maxRangeProbab = 0.04;
  class Library
   libTextDesc = "";

Most weapons inherit from the default class unless they specifically alter the value to suit the weapon being configured.

I know a little about a lot, and a lot about a little.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: seven's (sniper)spotting script (DELAYED)
« Reply #9 on: 21 Sep 2007, 16:13:10 »
Good info, [seven] you may find dispersion and aiRateOfFireDistance (as effective range) interesting for your script. Will show you how to get these parameters later.


Example to read a config parameter of a weapon
Code: [Select]
hint format["Dispersion: %1", getNumber (configFile >> "CfgWeapons" >> "M16A2" >> "dispersion")];

About the way you get wind information, you might simplify it a lot while making it way more accurate using the wind command. It returns the current velocity vector of the wind, so you have immediately the direction and speed without needing any particle.
« Last Edit: 21 Sep 2007, 16:42:14 by Mandoble »

Offline [seven]

  • Members
  • *
Re: seven's (sniper)spotting script (ACCEPTED)
« Reply #10 on: 24 Sep 2007, 01:20:32 »
Okay, I've been doing some work and the script now uses the wind command to detemine wind conditions.  I've also retooled some of the math so that the script no longer needs functions and can stand on it's own.

Now, what I'm looking for at the moment is a calculation to detemine the relative degrees. :scratch:  Any suggestions on the best way to do this?

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: seven's (sniper)spotting script (ACCEPTED)
« Reply #11 on: 17 Oct 2007, 15:40:21 »
I think what Mandoble was asking for when he asked for relative direction was "I am facing 170 degrees and the target is facing 180 degrees, so they are travelling +10 degrees relative to me (so, slightly to the right of the direction I'm looking)". You could use two techniques to give that info to the player:
- show the difference between target's heading (getDir) and the player's weaponDirection (aiming direction), rather than the target's absolute heading. Only thing to remember is that 350 to 0 degrees is +10, not -350 degrees.
- additionally show the player's absolute weaponDirection angle, so they can compare that with the target's absolute direction themselves.

As well as calculating the bullet lag time, you could show the bullet lag distance (based on current target heading and speed) in absolute or relative metres (or mils and direction within the scope). If you went crazy, it would even be possible to show a "shoot here" marker on the screen, but that takes all the fun out of it :P OFPEC ILS does some work to do something like this, in showing the position on the airport on the HUD.

You might find useful formulae in a post I made about wind direction.

By the way, it is km/h, not k/h.
« Last Edit: 17 Oct 2007, 15:46:48 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline [seven]

  • Members
  • *
Re: seven's (sniper)spotting script (ACCEPTED)
« Reply #12 on: 21 Mar 2008, 15:11:02 »
New version uploaded.  Some of the requested options have been added.  Wind stats now use wind command.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: seven's (sniper)spotting script (ACCEPTED)
« Reply #13 on: 21 Mar 2008, 17:21:02 »
May you include a version inside the script to keep track to it? Also, if possible, make example missions without spaces in the name of the folders.