Home   Help Search Login Register  

Author Topic: blind AI sniper  (Read 4032 times)

0 Members and 1 Guest are viewing this topic.

voodzia

  • Guest
blind AI sniper
« on: 09 Apr 2005, 19:43:52 »
Hello,
I have a problem with AI sniper. I mean I can't make him shoot at enemy units :(
Here's my code:
Code: [Select]
; makes sniper to shoot at spotted enemy

"sniper1 reveal _x" foreach sniperTargets

_n = count Units alfa
_random = random _n
_random = _random - (_random % 1)
_target = Units alfa select _random
sniper1 doTarget _target
sniper1 doFire _target

exit
And I didn't forget to place a trigger (West present) on the map with activation field:
sniperTargets=thislist

Could you tell me what's wrong with this script?
Thanks in advance for your reply.
Kind regards,
voodzia

ps.
Sniper has in the init field those commends:

this disableAI "move"
this setUnitPos "up"
this setBehaviour "combat"
this setCombatMode "red"

One more thing - you can see it for yourself - there's a screenshot on my site.

Offline Blanco

  • Former Staff
  • ****
Re:blind AI sniper
« Reply #1 on: 09 Apr 2005, 20:05:04 »
Try to raise his skill.

Here's an old script for multiple snipers and targets :

Code: [Select]
_shoters=[sniper1,sniper2,sniper3]
_Targets=[group West_Leader1,group West_Leader2,group West_Leader3]

#repeat
_i=0;_j=0
#loop1
~10
#loop2
"(_shoters select _i) reveal _x; (_shoters select _i) dofire _x" foreach units (_Targets select _j)
_i=_i+1
~3
?(_i<count _targets): goto "loop2"
_j=_j+1;_i=0
?(_j<count _shoters): goto "loop1"

?("alive _X" count (units (_Targets select 0)+units (_targets select 1)+units (_targets select 2))>0): goto "repeat"



« Last Edit: 09 Apr 2005, 20:08:55 by Blanco »
Search or search or search before you ask.

voodzia

  • Guest
Re:blind AI sniper
« Reply #2 on: 09 Apr 2005, 20:08:44 »
But it's already on the max point :(

1st Edit: Thanks Blanco for the script. I'm gonna try it out in a minute.

2nd Edit: OK - I made some tests and must say that this script works but similarly to mine. Namely sniper shoots at my group but not always. Sometimes he fires when I'm 300m away but sometimes he doesn't shoot when I stand 100m in front of him. I just can't get it :( And btw, this script gives me one error:

'("alive _X" count (units (_Targets select 0)+units (_targets select 1)+units (_targets select 2))>|#|0)': Error Zero divisor

Could you tell me what's wrong with that?

Now I'm gonna make that little change that Planck has mentioned in his post.
« Last Edit: 09 Apr 2005, 20:56:11 by voodzia »

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:blind AI sniper
« Reply #3 on: 09 Apr 2005, 20:18:57 »
 Maybe you could try changing this line:

_target = Units alfa select _random

to this:

_target = sniperTargets select _random


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

voodzia

  • Guest
Re:blind AI sniper
« Reply #4 on: 09 Apr 2005, 21:25:53 »
I changed this line as you aptly suggested me but it still ain't working :( I just have no clue why this sniper doesn't shoot? I mean he shoots sometimes but not always. It's really very odd.

CrashnBurn

  • Guest
Re:blind AI sniper
« Reply #5 on: 09 Apr 2005, 23:09:02 »
I've found the best results can sometimes come from simplicity. Just place the sniper on the map. In his ini- this setunitpos "DOWN". Don't give him any waypoints or scripts. Let him do things on his own.

By scripting his targets, you're interfering with his AI. His AI is telling him to target one thing and your script is telling him to target another, most likely confusing him. All the while you and your units are moving, causing him to change the priority of his targets, and then your script changes things again. It's no wonder he won't shoot anything...lol.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:blind AI sniper
« Reply #6 on: 09 Apr 2005, 23:44:51 »
Still.....I wonder if using disableAI "target" or "autotarget" would stop him from choosing his own targets.



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

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:blind AI sniper
« Reply #7 on: 09 Apr 2005, 23:51:39 »
I am with CrashnBurn on this.  Keep it simple.  I have some snipers in my latest mission and the beta testers crying foul over how good they are.  All I have done is set their skill to maximum, grouped several of them together and put this in their init fields:

doStop this; this addweapon "NVGoggles"; this addweapon "binocular"; this setbehaviour "COMBAT";this doWatch (object XXXX)

The XXXX is chosen to make sure they watch the direction I want them to.

I also put them in some well chosen bushes.

But that is all.  No scripting.

Seriously, they are deadly.


Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:blind AI sniper
« Reply #8 on: 10 Apr 2005, 00:38:50 »
OFP is a sophisticated game.   Sniper units are smart.    They don't necessarily go shooting straightaway just because you told them to.      Give them a  minute or two to absorb the situation.      Make the target easier to spot by making him move.   (Movement is a HUGE deal in this game in terms of spotability.)

Remember that a sniper who can see an enemy unit that fits his AI parameters will shoot.  

Quote
Sometimes he fires when I'm 300m away but sometimes he doesn't shoot when I stand 100m in front of him.
Excellent!    Good mission design, well done.   :thumbsup:

That's exactly what makes this such a good game.    Sometimes he sees you and sometimes he doesn't.   Sometimes, when he sees you, he decides against attempting the shot.   Design your mission around these unbelievably complex, sophisticated and wonderful AI routines.    Do not try and beat them out of him.

If you want to play a loser corridor game where the AI always behaves in exactly the same way then do so:  do not expect a quality game like OFP to behave in such a pointlessly dreary fashion.
Plenty of reviewed ArmA missions for you to play

voodzia

  • Guest
Re:blind AI sniper
« Reply #9 on: 10 Apr 2005, 01:51:22 »
Wow - thanks guys for your response. I'll try out all your tips after I get some sleep ;)
For now I just would like to describe this issue from the very beginning.
Initially when I placed snipers in the watch towers I wasn't using any scripts and wanted to find out how they react to enemy presence. And they response didn't satisfy me at all. I wanted them to shoot almost immediately when they spot unfriendly units in certain areas. What's more I spent almost half a day marking these "killing fields" on the map because I wanted to be sure that nobody will make his way through these special zones. And that's way I started to look around for some scripts. I searched this forum and found some very useful hints which helped me to write this tiny script. I wrote it to make sure that snipers will fire as soon as enemy enters these special zones. And I'm sure that snipers do see unfriendly units - they ain't hiding behind trees or bushes. I just don't understand why they don't fire when they are forced to do so?

@ macguba
Quote
Sometimes he fires when I'm 300m away but sometimes he doesn't shoot when I stand 100m in front of him.
Excellent!    Good mission design, well done.  Well done!
I disagree with you. If this sniper doesn't fire at me when I'm 100m in front of him that means that he is a looser. I run almost 200m and he didn't shoot me. I'd say that such situation is completely unrealistic and I just can't let this happen in my mission - otherwise this mission is crap.
Quote
If you want to play a loser corridor game where the AI always behaves in exactly the same way then do so:  do not expect a quality game like OFP to behave in such a pointlessly dreary fashion.
Of course I don't expect this game (its AI to be more precise) to be predictable but in this specific case I'd like to make it happen - the problem is I can't make this AI sniper to act as I want him to act :( I don't want to depend on these "unbelievably complex, sophisticated and wonderful AI routines" as you nicely described this awful nature of OFP's AI.
But anyway thanks for all your suggestions.
Kind regards,
voodzia

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:blind AI sniper
« Reply #10 on: 10 Apr 2005, 04:13:15 »
Something I forgot to mention is that it is sometimes helpful to give the sniper a team mate:  a spotter.    It is my impression (though not thorougly tested) that a sniper with some pals is more likely to shoot you.  Use doStop and/or disableAI commands to keep loons in place.

If all else fails use reveal commands.    As you rightly point out the "complex, sophisticated and wonderful AI routines" do sometimes produce a bag of shit.  ;D   The problem is that they are just not quite sophisticated enough.....
Plenty of reviewed ArmA missions for you to play

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:blind AI sniper
« Reply #11 on: 10 Apr 2005, 08:42:12 »
Quote
that a sniper with some pals is more likely to shoot you.
My experience also.  If you put several snipers around an area so they can see it from several angles and then group them together they are each able to tell the others what they have seen, maybe the AI for one of them is asleep, but it won't be for all of them.

Quote
If all else fails use reveal commands.
IMHO reveal is evil, it is almost in the same category as: doMove getPos player.  They are both terrible cheats if used in the mission - in cutscenes is fine.  Reveal does have one redeeming/non-cheat use and that is to help the ai of one side know about enemy units that its side already knows about and it should already be aware of.  In otherwords to help the OFP engine.  

If you really want absolute no-go areas why not play the sounds of gun fire and bodies being hit and setDammage 1 the intruding unit(s)?  It would achieve what you want and be easy to do, but it would be boring.

« Last Edit: 10 Apr 2005, 09:58:28 by THobson »

voodzia

  • Guest
Re:blind AI sniper
« Reply #12 on: 10 Apr 2005, 11:41:11 »
Quote
Something I forgot to mention is that it is sometimes helpful to give the sniper a team mate:  a spotter.
I guess you're right but in this case unfortunately it's impossible to do it - snipers are in watch towers and there's no room for the second guy. But I don't know if these snipers have binoculars - and if they do I'll give them command "doWatch" - maybe then they be more eager to fire.

Quote
If all else fails use reveal commands.
But the point is that I use it all the time and nevertheless they act sometimes as if were blind :( Besides I made some tests without this script. And results amazed me much. There's almost no difference whether I use the script or I don't use it. How can it be possible?

Quote
If you put several snipers around an area so they can see it from several angles and then group them together they are each able to tell the others what they have seen, maybe the AI for one of them is asleep, but it won't be for all of them.
Undoubtedly you're right but I don't want to place more than two snipers. One of them is to observe SE area while the other one must watch SW region. So in most cases they won't see each other. And placing more than two snipers is redundant in this particular situation.

Quote
Reveal does have one redeeming/non-cheat use and that is to help the ai of one side know about enemy units that its side already knows about and it should already be aware of. In otherwords to help the OFP engine.
I must disagree with you. I mean you're right that this command is a kind of cheat but sometimes it's just essential and extremely helpful - as you noticed this for yourself ;) For example - if these AI snipers could engage enemy when spotted running somewhere 500m - 800m in front of them I wouldn't have to use this cheat. But the fact is that OFP engine leaves a lot to be desired and sometimes you just have to give it a hand.

Quote
If you really want absolute no-go areas why not play the sounds of gun fire and bodies being hit and setDammage 1 the intruding unit(s)?  It would achieve what you want and be easy to do, but it would be boring.
Actually you found the answer by yourself. Using command setDammage 1 would be boring for me I mean mission maker but that's not a real problem. The point is that such situation would be very irritating for players. I don't want to make these snipers 100% accurate - I just would like to help them a bit be more aggressive, to see and hear better and to shoot faster - and that's all I want. I hope you can see the difference between these two situations.
But it's enough this talking - I get back to my mission ;)
Thank you all for your help.
Kind regards,
voodzia


Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:blind AI sniper
« Reply #13 on: 10 Apr 2005, 12:47:36 »
Quote
snipers are in watch towers and there's no room for the second guy.
You can group them even if they are nowhere near each other.  Just give them a doStop and make sure they are not In Formation.

Quote
I don't know if these snipers have binoculars - and if they do I'll give them command "doWatch"
Did you read Reply#7?

I would never use reveal to tell a unit about some enemy it cannot know about, and just because a unit is in front of him doesn't mean he must know about it, real people miss things.  It creates unpredictability.  Also I hate playing missions where things like this are  done, if I detect it happening I stop playing and go and spend my time on something else.

Are there really no possibilities of having other friendlies in the area that the snipers can be grouped with?  That way anything one of them knows - they all know.

voodzia

  • Guest
Re:blind AI sniper
« Reply #14 on: 10 Apr 2005, 14:28:17 »
Quote
You can group them even if they are nowhere near each other.  Just give them a doStop and make sure they are not In Formation.
They are already grouped but I'm not sure if it changes anything in their behavior. But could you tell my why I'm to give them doStop command?

Quote
Did you read Reply#7?
Yes, I read it but haven't tried it out yet. I'm still trying to figure out my script and make some changes there.

Quote
I would never use reveal to tell a unit about some enemy it cannot know about, and just because a unit is in front of him doesn't mean he must know about it, real people miss things.  It creates unpredictability.
I guess you don't understand my situation. AI in OFP is rather weak I'd say and that's way I'm trying to make it a little bit better. Real people who play OFP are much more smarter than AI soldiers and I'd like to make player to feel a little less comfortable while playing my mission. And I disagree with you that real sniper who stands in the watch tower would miss a squad of 9 soldiers when they run 300m in front of him. He could miss some enemy movements if they were somewhere 1km away of his position but anything closer than 500m should be spotted and shot (I'm talking about some open field - not a forest or woods or some bushes).

Quote
Are there really no possibilities of having other friendlies in the area that the snipers can be grouped with?  That way anything one of them knows - they all know.
Unfortunately there are none. I'm not gonna make any patrols near the base since Russians think they're safe there. So these two snipers are their eyes and ears and also the first line of defense. I just would like them to be also the last one for some careless players ;)