Page 1 of 16 1234511 ... LastLast
Results 1 to 10 of 158

Thread: Ai suppression script help

  1. #1
    Master Gunnery Sergeant -Coulum-'s Avatar
    Join Date
    Dec 8 2010
    Location
    Canada
    Posts
    1,075

    Ai Suppression Script Development

    From 20120209 - 20120618 Outdated
    Spoiler:

    From 20120618Updated

    There are three versions of the script available:

    Basic (stance modifier)
    Spoiler:


    -Units react to bullets passing within 10m
    -Affects all units, in vehicles or not
    -Units react identically to any kind of bullet fired from more than 25m away
    -Units react to identically bullets from any side
    -1-5 bullets -->kneel/crouch
    ->5 bullets --> drop/crawl
    -Units regain previous stance after 10 seconds without nearby bullets

    Light (stance modifier)
    Spoiler:


    -Units react to bullets passing within 10m
    -Only units not in vehicles are affected
    -Bullets fired from less than 25m away are ignored
    -Bullets from small calibre pistols and SMG are ignored
    -Units react differently according to the side of the shooter
    -1-5 bullets --> kneel/crouch
    ->5 bullets --> drop/crawl only if enemy shooter fired bullets
    -Units regain previous stance after 10 seconds without nearby bullets

    Full (stance and skill modifier)
    Spoiler:



    -Units react to bullets passing within 10m
    -Only units not in vehicles are affected
    -Bullets fired from less than 25m away are ignored
    -Bullets from small calibre pistols and SMG are ignored
    -Units react differently according to the side of the shooter
    -Friendly shooter: >0 bullets --> kneel/crouch
    -Enemy shooter: 1-5 bullets --> kneel/crouch, >5 bullets -->drop/crawl
    -Friendly shooter: no skill reduction
    -Enemy shooter: skills reduced according to number of bullets
    -Units regain previous stance after 10 seconds without nearby bullets
    -Units gradually regain skills after 5 or so seconds without bullets

    Each script only needs to be initialized once per mission. CBA is required.

    Oh and I almost forgot to mention:

    tpw is the one responsible for the magority of the script. Credit should really go to him. He's done an excellent job, and I believe he plans to release this as a mod soon.

  2. #2
    Master Gunnery Sergeant Variable's Avatar
    Join Date
    Feb 5 2005
    Location
    Israel
    Posts
    1,317
    Wow man if you manage to make such add-on it can literally change the game for the better. Right now no infantry tactics that incorporate suppression can work since the AI simply don't react to it, and I don't know much tactics that don't include any form of suppressing.
    I wish I could help myself but all I can do is ask around and let you know if I come up with anything.
    Good luck!

  3. #3
    First Lieutenant Kremator's Avatar
    Join Date
    Jun 8 2007
    Location
    Cambridge, UK
    Posts
    5,075
    Does sound promising as the current suppression effects don't REALLY work! Can the eventhandler be applied to the bullet (or would that be too CPU intensive)?

  4. #4
    Master Gunnery Sergeant -Coulum-'s Avatar
    Join Date
    Dec 8 2010
    Location
    Canada
    Posts
    1,075
    Author of the Thread
    Don't get your hopes up too much. Even if I can get this to work it would be very simplistic and like kremator said, very system intensive.

    Now how exactly would I go about creating an event handler? I believe this is what the first script above has done but it seems to only apply when rounds pass near the player. How can I make an event handler that tracks when rounds pass the ai as well.

  5. #5
    Hi,

    You should be able to set the AI aimingaccuracy, aimingspeed and aimingshake very low for a period of time, which will make him a terrible shot. See this page in the Wiki.

    I am also making an addon which will affect such things on the fly. You can see how changing the values of these arrays affects the AI's ability to shoot straight in a video I posted at the end of my thread here
    Jedra's Addons
    Arma 2 : Enhanced Skills Slider
    Take On Helicopters : Take On Taxi | Jedra's Time Trials | Weapon Indicators | No Radar

  6. #6
    Master Gunnery Sergeant -Coulum-'s Avatar
    Join Date
    Dec 8 2010
    Location
    Canada
    Posts
    1,075
    Author of the Thread
    Thanks Jedra. I was going to set the accuracy of the ai down by using setunitability, but it turns out it doesn't work anymore.I used
    setskill ["aimingAccuracy",0.1];
    setskill ["aimingShake",0.1];
    in a quick editor test and it makes the ai a lot less accurate. It does require a bit of time at the start of the mission before the new skills kick in.
    I also used
    setunitpos "DOWN";
    to make the ai go prone and that works fine and dandy too. Now does anybody have any ideas on how to make the ai skills and posture return to normal after a certain amount of time?
    And of course I still can't figure out how to use an eventhandler to track when a round comes close to an ai so if anyone has any tips on how to use eventhandlers your advice would be much appreciated. Thanks.

  7. #7
    You could have something like;

    Code:
    // Save current skill
    _saveAccuracy = _unit skill "aimingAccuracy";
    _saveShake = _unit skill "aimingshake";
    
    // make AI stupid
    _unit setskill ["aimingAccuracy",0.1];
    _unit setskill ["aimingShake",0.1];
    
    
    // put him in position
    setunitpos "DOWN";
    
    sleep 30  // Sleep for 30 seconds (roughly speaking)
    
    // Restore AI
    _unit setskill ["aimingAccuracy",_saveAccuracy];
    _unit setskill ["aimingShake",_saveShake];
    
    // Stand him up again
    setunitpos "UP";  // Or whatever
    Eventhandler would look something like this...

    Code:
    _EHFiredIdx1 = badguy1 addEventHandler ["firednear", {STARTTIME = time; badguy1 removeeventhandler ["firednear",0];}];
    This runs the stuff in the braces if someone fired within 60 meters of badguy1. I just use it to set a flag, but you could run a .sqf in there.

    Firednear passes in an array to the handler;

    [unit, firer, distance, weapon, muzzle, mode, ammo]

    You can use distance to decide when supression is appropriate. See this page on the Wiki. I guess your challenge here is that the unit firing could be some distance away, yet you can still be surpressed as the rounds themselves are close. There is probably a more appropriate EH for this - I will see if I can find one tomorrow, but you may has well have a scooch round yourself at the wiki.
    Last edited by Jedra; Feb 9 2012 at 21:45.

  8. #8
    Master Gunnery Sergeant -Coulum-'s Avatar
    Join Date
    Dec 8 2010
    Location
    Canada
    Posts
    1,075
    Author of the Thread
    Thanks Jedra.

    I was able to get the "effects" working thanks to your help. I didn't know that you could create a variable like that and then sub it in later for a number. probably common knowledge for most scripters, but that just proves how very little I know about this stuff.

    As for the event handler. I couldn't get the one you described to work when I tried to exec a script from it but I didn't have much time to play around with it and try to figure out what I have done wrong so when I do get time I will give it some more research.

    Your right that the "firednear" isn't exactly ideal for this type of thing because it is limited to detecting shooters within 69 m of the unit according to the wiki. Also the distance returned by the handler would be from the shooter to the target rather than from the round to the shooter, which is more relevant when dealing with suppression. Problem is there isn't many other event handlers suitable. After reading through the wiki list, the fired event handler it probably the best bet

    I could use it to detect who shot and what ammo he shot,
    Then I could use "nearestobject" to detect the ammo of that type nearest the shooter to find the round,
    then actively measure the distance between the round and the target,
    and apply effects if the distance becomes small enough.

    I don't know if this kind of thing would work, or if it even makes sense. one problem I can foresee is that the script wouldn't know which unit is the target. Anyways I will try working on it soon when I have more time.

    Your help is much appreciated Jedra, thanks.
    Last edited by -Coulum-; Feb 10 2012 at 02:09.

  9. #9
    Quote Originally Posted by -Coulum- View Post
    Thanks Jedra.

    I could use it to detect who shot and what ammo he shot,
    Then I could use "nearestobject" to detect the ammo of that type nearest the shooter to find the round,
    then actively measure the distance between the round and the target,
    and apply effects if the distance becomes small enough.

    I don't know if this kind of thing would work, or if it even makes sense. one problem I can foresee is that the script wouldn't know which unit is the target. Anyways I will try working on it soon when I have more time.

    Your help is much appreciated Jedra, thanks.
    This is probably your best bet to play around with. If you use firednear and add the event handler to the AI you could probably get a good approximation of supression if you are also checking for nearest object. I guess it doesn't matter who fired as in reality you could also be supressed by rounds from your own side - a bullet's a bullet at the end of the day and still hurts whoever fired it!!

    I might have a play later on. I have a mod of my own to write, a mission to finish, the crap hit the fan with work as well this week, oh and there's the kids to look after - but hey you've got me interested now and it's a cool project! Anyway, I'll have a proper think about it later once I have got the kids to school!

  10. #10
    Master Gunnery Sergeant Variable's Avatar
    Join Date
    Feb 5 2005
    Location
    Israel
    Posts
    1,317
    Isn't this solution of using the "Fired" EH will suppress the AI even when nearby AI fire on the enemy?

    Suppression must occur when bullets IMPACT in close proximity to the AI. Can't that be checked somehow?

Page 1 of 16 1234511 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •