Home   Help Search Login Register  

Author Topic: How to script a sniper?  (Read 2206 times)

0 Members and 1 Guest are viewing this topic.

mikko

  • Guest
How to script a sniper?
« on: 06 Jun 2006, 21:45:37 »
This is noob question, but have to ask, cause there is no manual anywhere.

How do I script a simple action, that a sniper starts to shoot as soon as he sees enemy. (Maybe from 400-500 meters)
I have not found any tutorial how to script and use variables and those "this", "_this" -things?

I found one finnish tutorial, good because I am a Finn, but that is very short. And I don't get everything from it.

Command reference manual I have.

Thanks! ::)

Offline Speeder

  • Members
  • *
    • OFP.nu
Re: How to script a sniper?
« Reply #1 on: 06 Jun 2006, 21:48:03 »
you could try and use the "reveal" command from the command reff
There are 10 kinds of people in this world. Those who get it, and those who don't.

mikko

  • Guest
Re: How to script a sniper?
« Reply #2 on: 06 Jun 2006, 22:38:03 »
Yes, that could work. How to use it against any enemy? Not just the specific named enemy.

Offline Baddo

  • Former Staff
  • ****
  • Reservist Jaeger
Re: How to script a sniper?
« Reply #3 on: 06 Jun 2006, 22:51:39 »
Increase the skill level of the sniper to full. Also you could put something like 3 snipers around the area where you expect their enemies to be. Group the snipers together and put them into their firing positions and make them stay there (not walk around but lay down and watch the area, you know). This way the snipers will report their targets to others in the group and will make it even more harder for players to pass that area without getting a bullett between their eyes.

Edit: A word of warning: you can easily make it too difficult for players so be careful with these kinds of instructions. Chances are good that a player has no clue where the shot came from if there are snipers well hidden around the place and the firing distance is relatively high.
« Last Edit: 06 Jun 2006, 22:54:16 by Baddo »

Offline DeanosBeano

  • Addons Depot Staff
  • *****
  • SirDeanosbeano bstowed on me by sui ;)
    • Fraghaus
Re: How to script a sniper?
« Reply #4 on: 06 Jun 2006, 23:20:43 »
here is one i use works with mg well , but also with sniper :)

 make a trigger  select side of the one you want to be shot at i.e east or west etc.
 make it on repeat . make the size to your requirements.remember he canmaybe onlu see 400 meters like someone said.
 if name of your sniper is different to mine which is sniper, then change the name in code where it says sniper

 conditoin east present /if east are nme. west if its west nme :). etc
 
Code: [Select]
{sniper reveal _x} forEach thisList;{sniper DoFire _x} forEach thisList
I love ofp

SgtSlick

  • Guest
Re: How to script a sniper?
« Reply #5 on: 07 Jun 2006, 02:54:02 »
Well, i guess that works too. I use a similar approach. I use a trigger just like he said but instead of DoReveal I do:

Code: [Select]
{sniper dotarget _x; sniper dofire _x} foreach this list
It works the same... I guess (it looks like it would). but only with different commands. But like he said, the sniper will fire in the area within the trigger. So put it over the area you want the sniper to cover. Remember: have the trigger on present and repeat, specified to the appropriate side.

Offline SniperAndy

  • Members
  • *
    • VBS Community
Re: How to script a sniper?
« Reply #6 on: 07 Jun 2006, 08:21:38 »
I remember a sniper script that would make the sniper shoot once, then wait for a give amount of time before he fires again. anyone knows this script? has it around or knows how I would script this?

the thing is, OPFOR snipers tend to fire like crazy once they got eyes on you.
In my opinion it is much harder to find the shooter if he only fires once and then waits for XX time before he shoots again.

mikko

  • Guest
Re: How to script a sniper?
« Reply #7 on: 07 Jun 2006, 09:52:51 »
Okay, I got my sniper to target me, but he don't stay still. He starts to run towards me, and does not shoot until my team member AI shoots him.
My code is like this:  :-[
Code: [Select]
_unit = _this select 0
_trigger = _this select 1
{_unit dotarget _x; _unit dofire _x} forEach thislist

Could it be that I am playing FDF mod WW2? So the sniper really has only scoped SVT Tokarev or Mosin nagant. I tried normal mosin nagant fighter, didn't work. Am I doing something wrong? Thanks again...

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Re: How to script a sniper?
« Reply #8 on: 07 Jun 2006, 10:53:16 »
I usually have my sniper in the place where I want him and a spotter closer to where you think the enemy will be. Like what Baddo said.
I made a diagram ages ago. 1 is the sniper, 3 is the spotter 2 is the target.



Also, here's a little sniping script I found in one of my missions.

Code: [Select]
;sniper script by Pica
;put this in the snipers init field
;this addeventhandler ["fired",{_this exec "snipe.sqs"}]

;will make sniper move between positions after each shot.
;just place gamelogics in the positions you wnat him to move to
;and replace the array below with their names


;replace this array with the names of the gamelogics you have placed.
_LogicArray = [logic1,logic2,logic3,logic4]


_sniper = _this select 0

_sniper allowfleeing 0
_sniper setunitpos "down"

_sniper setcombatmode "blue"
~5 + random 5
_sniper setspeedmode "full"

_number = Random count _LogicArray
? ((_number mod 1) >= 0.5): _number = _number + 1
_number = _number - (_number mod 1)
_position = _LogicArray select _number
_sniper domove getpos _position
@unitready _sniper
_sniper SetCombatMode "yellow"
exit
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: How to script a sniper?
« Reply #9 on: 07 Jun 2006, 11:43:34 »
To make the sniper stay put in one place, you have a number of alternatives;

doStop sniper (stops sniper, a bit of a hassle to make him move again though)

sniper stop TRUE (I think the same as the "Halt" command a player can issue. To make them move again, just use <unit> stop FALSE.)

or, if you really can't make the bastard stop moving :

sniper DisableAI "Move"

However, there's really no way to enable the AI again, and I hear the disableAI stops working if you save the game and then load it again.

And then, to make the sniper lie down constantly :

sniper SetUnitPos "Down"

So. Just add something like : doStop sniper; sniper setUnitPost "down"; somewhere in your script, and the bugger will be lying down and staying put forever. :)

You might want to experiment with the weapons though : I don't know what the AI firing distance of the WW2 mod sniper rifles are. If you still can't get it to work, try giving them a modern rifle and see if that's the problem.  8)

Good luck!

Wolfrug out.

"When 900 years YOU reach, look as good you will not!"

Offline Honcho Black

  • Members
  • *
Re: How to script a sniper?
« Reply #10 on: 07 Jun 2006, 12:19:21 »
The awareness and accuracy is defiened in the config of the sniper unit.  So to actually get a "Enhanced AI sniper" unit you would have to make an addon.  Or use the "Enhanced AI snipers" addon made by Sanctuary.  These Snipers engage at large distances and have a few second break between each shot to simulate the reloading and reaiming.  Because of the large engagement distances they are excellent for covering choke points in a mission, e.g. somewhere the player is not suppossed to go.

Get the "Enhanced AI snipers" here: http://ofpc.de/dma/download.php?view.12

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Re: How to script a sniper?
« Reply #11 on: 07 Jun 2006, 14:54:05 »
The DisableAI "Move" commands are reset after a retry point is reached (SaveGame command). No need to load afterwards.
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

Offline Blanco

  • Former Staff
  • ****
Re: How to script a sniper?
« Reply #12 on: 08 Jun 2006, 10:25:04 »
I remember a sniper script that would make the sniper shoot once, then wait for a give amount of time before he fires again. anyone knows this script? has it around or knows how I would script this?

Yup, snipershots By bluelikeu I always loved that script. See attachment...



[attachment deleted by admin]
« Last Edit: 08 Jun 2006, 17:52:17 by Blanco »
Search or search or search before you ask.

Offline SniperAndy

  • Members
  • *
    • VBS Community
Re: How to script a sniper?
« Reply #13 on: 08 Jun 2006, 11:51:02 »
thanks a million for the script...

mikko

  • Guest
Re: How to script a sniper?
« Reply #14 on: 08 Jun 2006, 22:40:54 »
Thanks! Those will help me in my sniper issue.  ;D