Page 4 of 16 FirstFirst 1234567814 ... LastLast
Results 31 to 40 of 158

Thread: Ai suppression script help

  1. #31
    Thanks for showing me how to add an EH to a script, as opposed to looking cluelessly at previously-completed scripts

    I thought some more about this over breakfast. Maybe firedNear would be better? - according to the BiKi, max range is "~69m" so a smaller range could be used to exclude nearby allies (only, or obviously CQB would be even more FU'd than in vanilla).

    Also thought about suppression of a unit that is firing - tpw's post seems to confirm that timing is the key. In any event, IRL would, say, a soldier with even an LMG be aware of bullets passing whilst firing? I've never heard an MG IRL, but a shotgun blast from a few m away is pretty damned loud. I guess the interval between bursts plus the rate of passing bullets plus timing factors in the script will determine whether the unit is suppressed. Less of an issue for units with non-auto firing weapons, perhaps. In any event, perfection isn't necessary, as long as the proportion of units that do not react is reasonably small. Hell, even a 50% efficiency would be a huge improvement.

    Other problems: setunitpos does not change the stance of units who've been commanded into a stance or position. That's not a limitation of the script, it's a limitation of setunitpos. Not sure how to get around it.
    Is it possible use setunitpos Auto before the setunitpos down or setunitpos middle

    e.g.

    Code:
    _shots = _unit getVariable "Shots";
            if (_shots == 0) then {_unit setunitpos "auto"};
            if (_shots > 0) then {{_unit setunitpos "auto"};{_unit setunitpos "middle"}};
            if (_shots > 5) then {{_unit setunitpos "auto"};{_unit setunitpos "down"}};
    Probably syntax wrong, but anyway..

    I'm >90% certain it can be done. IIRC Gibson's fine Gib_Copy_My_Stance does override previous stance commands issued to a unit via the normal menu.

    Heh, if you're a "shit coder" I'm a donkey

    The stuff you are doing with Coulomb here & with SaOK et al on LOS (to mention just 2 projects) is really innovative, greatly needed, & most importantly it is all going in the right directions.

    EDIT: Also think it should be possible to exclude silenced weapons. A check on what the unit is firing would best (quickest? - easiest, anyway) be done by Cfg class if there is a separate class for 'silenced' (or whatever), otherwise excluding via an array of classnames. Skipping the script for that unit if so would reduce CPU load a bit, but only if a lot of units are using silenced weapons.
    Last edited by Orcinus; Jun 17 2012 at 11:32.

  2. #32
    First Sergeant
    Join Date
    Oct 30 2009
    Location
    Brisbane, Australia
    Posts
    980
    Thanks for the encouragement mate!

    Setunitpos really is subordinate to player issued stance commands unfortunately. CMS actually doesn't override stance commands (I know, I looked closely a few days ago). From Gib's readme:
    The scripts Detect Changes in the player's stance and issue updated stance rules to the
    players group.Any unit in the players group that is under stance rule "AUTO",
    'Keep Low' in menu 7,will act on these rule changes.Any unit that has been given any
    other stance rule via menu 7 will retain those rules over those issued by the scripts.
    Great idea re silenced weapons, I will look into it.

    I'll look a bit further into firednear, it might also help with the baove point.

    Thanks again Orcinus, your help and feedback is valuable, and exactly why I like being part of this community.

  3. #33
    My pleasure, glad to be of some small assistance.

    SetUnitPos - hmm - but that should not be a problem with the AI other than in a player's group (apart from squads following mission-designer waypoint-mediated commands like stealth plus crawl, which form a fairly limited sub-set); and the player can always tell their units to drop down or crouch. As I almost always use CMS, I rarely use the menu 7 options and so 'my' units simply get switched between CMS and auto, whether individually or as a group.

    I would have no problem at all if this development ends up as one best to be used in combination with CMS. Anyone who differs could use it standalone (mod or script) & accept that they have to give stance orders to any of their units not in auto mode. Even with those limitations unresolved, it would still be a big boost to game-play quality

    Also occurs to me that it might be worth at least coordinating with Robalo at some stage, given the cool stance-changing enhancements he's developing for ASR_AI. Would be a great pity if there was an irreconcilable conflict.

    Back to work!

  4. #34
    Master Gunnery Sergeant -Coulum-'s Avatar
    Join Date
    Dec 8 2010
    Location
    Canada
    Posts
    1,067
    Author of the Thread
    Quote Originally Posted by tpw
    Like I said previously, cba_fnc_addPerFrameHandler is a bit of a black art, trial and error affair to me, so in all probablilty I've just implemented the whole thing wrong. I only put the code ideas up there for consideration, not a finished product! Oh, and sleep commands are not compatible with cba_fnc_addPerFrameHandle, hence the diag_ticktime.
    I see.

    Quote Originally Posted by tpw
    I tried the script with about 60 units on Aliabad taking pot shots at each other. I switched on an fps counter and sat back. With the identical mission, it ran at about 45 fps without the script, and maybe 40-42 fps with it. Not too bac considering the amount of bullets flying and how poor my computer is. You are only calling the script the once right? It doesn't need to be called for each unit.
    I feel like an idiot. Yeah I was calling it for every unit. But I see now its already foreach allunits at the end. Damn I feel stupid. [edit]Okay I feel pretty dumb. I still can't get this to work even when I call it once. In my init I have Spoiler:
    Then in the tpwsuppress.sqf I have copied your script. When I start the mission I am notified that "tpw / -Coulum- suppress active", but my shots don't seem to affect the ai... I have CBA, CBA_A2, and CBA_OA running. Am I missing something?[/edit]
    [edit2]aha! I found out why it wasn't working. When I changed the line
    PHP Code:
    if ((_bc 0) and !(tpw_fired == _id))then 
    to
    PHP Code:
    if ((_bc 0) and (tpw_fired != _id))then 
    It started working like a charm. I have no idea why that was or why it would work with you but not me, but I have gotten it to work. And it works great! very good job tpw!

    Quote Originally Posted by tpw
    I'm not at all sure that my fired event handler is the most effective solution, but it was the only one I could think of. The idea is that tpw_fired is a global variable available to all units, but one which changes depending on who just fired their weapon. At some stage, each unit is assigned a random ID, which lasts for the duration of play. Let's say a unit was setvariabled an ID of 123. When he fires, tpw_fired becomes 123. So if the script catches bullets around unit 123, and tpw_fired is 123, then it assumes that at least some of those bullets are from 123's weapon, and doesn't suppress 123. If an enemy with ID 456 is also firing at 123, then it's down to which event handler is fired first. But because the whole thing happens so quickly 456 can still definitely suppress the firing unit 123 because at some stage tpw_fired will be 456. As I said, probably not elegant.
    I see, this makes so much more sense now that you explained it. Thanks.

    Quote Originally Posted by tpw
    You've also identified the problem of bullet speed. A faster projectile is simply harder to "catch" inside the specified volume around the player. The only real way around it is to make the volume bigger, but then that means units will be suppressed from bullets passing a long way away from them. So I'm not sure how to proceed there.
    Well like you said earlier, bullet speed does add a bit of randomness which is good. The only time I see it being a problem is when pistol rounds are more effective than rifle rounds. Maybe making it so that a bullet is only counted if it is going over a certain speed would eliminate that problem.

    Quote Originally Posted by tpw
    Lastly, I think you've correctly identified the biggest problem - I am a shit coder.
    Hell No! Not at all man. In no way am I trying to say that. I am the shit coder. And thanks alot for answering all my questions. I am learning a ton in this thread thanks to you. You've done a great job.

    Quote Originally Posted by Orcinus
    I thought some more about this over breakfast. Maybe firedNear would be better? - according to the BiKi, max range is "~69m" so a smaller range could be used to exclude nearby allies (only, or obviously CQB would be even more FU'd than in vanilla).
    Good idea. I am not sure how it would be done though...

    Quote Originally Posted by Orcinus
    Also occurs to me that it might be worth at least coordinating with Robalo at some stage, given the cool stance-changing enhancements he's developing for ASR_AI. Would be a great pity if there was an irreconcilable conflict.
    Yes good point. I believe the stances in this would overide any stances ASR assigns, because I believe he sets stance using setunitposweak.

    Quote Originally Posted by Robalo
    I tried to keep scripts as simple and optimized as possible. There should not be any noticeable impact on performance.
    There are limits to how many animations are processed and this not only saves performance but also makes it less predictable. I am OK with sometimes AI doing stupid things because humans do them too.
    How I do it ? I'm plugging into the AnimDone EH, detect if a unit knows about enemies, if yes, select "Middle" stance with setUnitPosWeak, otherwise revert to "AUTO".
    There's a special case if the animation was a stop and the unit is carrying MG, AR or sniper rifle, then selects the prone stance.
    This is the lowest priority way so all other methods take over when it comes to player commanding AI stance, scripted setUnitPos or the game's default "micro-AI" when AI is close to things.
    --edit--
    Here's an idea. It probably wouldn't be too good if suppression was applied for ai in CQB. It would look bad if a unit were to go prone right infront of an enemy. So maybe something that detects whether there are nearby units, like this
    Spoiler:

    Anyways, I've gotta get some work done but hopefully I'll get some time to attempt some new stuff later.

  5. #35
    Hi -Coulum-

    Firstly, I hereby assert my right to the title of shittiest coder in this thread, so let's close that topic

    nearestEnemy is a really good idea - but perhaps nearestObjects might be better?
    Code:
    nearestObjects [firer, ["Man"], 25]
    would enable all units within 25 m to be excluded, so the firing unit's allies wouldn't get suppressed at any time (by the firing unit, that is). Allies more than 25 m away might, but that is far from unrealistic, & might reduce friendly fire casualties. To cut down the CPU time, perhaps only run nearestObjects on group leaders. That may result in failure to exclude some units, but could be worth it in terms of reducing CPU load. Either approach would certainly be better than firedNear which, the more I consider it, I suspect would not work at all well.

    Lastly:

    -apologies for getting your name wrong earlier. That's what comes with trying to catch up with Arma while dealing with way too many work emails.
    - thanks for your initiative with this - having the idea is more than 50% of the battle, The creativity of people here continually surprises and delights me.
    - and as for anyone learning a lot, that definitely includes me.

    Cheers

    Orcinus

  6. #36
    Master Gunnery Sergeant -Coulum-'s Avatar
    Join Date
    Dec 8 2010
    Location
    Canada
    Posts
    1,067
    Author of the Thread
    Quote Originally Posted by Orcinus
    nearestEnemy is a really good idea - but perhaps nearestObjects might be better?

    nearestObjects [firer, ["Man"], 25]
    would enable all units within 25 m to be excluded, so the firing unit's allies wouldn't get suppressed at any time (by the firing unit, that is). Allies more than 25 m away might, but that is far from unrealistic, & might reduce friendly fire casualties. To cut down the CPU time, perhaps only run nearestObjects on group leaders. That may result in failure to exclude some units, but could be worth it in terms of reducing CPU load. Either approach would certainly be better than firedNear which, the more I consider it, I suspect would not work at all well.
    Well if you made it so any "men" near a unit caused that unit to be impervious to suppression basically everyone on the map would be unsepressable as long as they have a buddy beside them. I just suggested that if an enemy is 25 m away that would make it so no Suppression effects would be dealt in order to not messup CQB behaviour like that in tpw's LOS addon. It would prevent an enemy from going prone 5 metres away from you when they should just turn and blast your head off...

    But I think you are on to something. Would it be possible to have a fired eventhandler that defines the shooter as, lets say "shooter", and then use nearestObjects to detect if any units are close to "shooter". Then units that test positive for being close will not suffer from suppression effects. I don't know I am going to have to try and test it out when I get on my computer.
    Quote Originally Posted by Orcinus
    Lastly:

    -apologies for getting your name wrong earlier. That's what comes with trying to catch up with Arma while dealing with way too many work emails.
    - thanks for your initiative with this - having the idea is more than 50% of the battle, The creativity of people here continually surprises and delights me.
    - and as for anyone learning a lot, that definitely includes me.
    -Pfft, its not my real name. Know worries, I don't care.
    -I'd say more like 5% but thanks anyways thank you (and tpw of course) for contributing to it so much.
    -and me too!
    Last edited by -Coulum-; Jun 17 2012 at 22:57.

  7. #37
    Quote Originally Posted by -Coulum- View Post
    Well if you made it so any "men" near a unit caused that unit to be impervious to suppression basically everyone on the map would be unsepressable as long as they have a buddy beside them. I just suggested that if an enemy is 25 m away that would make it so no Suppression effects would be dealt in order to not messup CQB behaviour like that in tpw's LOS addon. It would prevent an enemy from going prone 5 metres away from you when they should just turn and blast your head off...

    But I think you are on to something. Would it ber possible to have a fired eventhandler that defines the shooter as, lets say "shooter", and then use nearestObjects to detect if any units are close to "shooter". Then units that test positive for being close will not suffer from suppression effects. I don't know I am going to have to try and test it out when I get on my computer.
    That's exactly what I was trying to convey, however imperfectly. What I thought nearestObjects would achieve, rather than nearestEnemy, would be to enable exclusion of all units <25 m from the firer (or his group leader, perhaps) from suppression by that firer's bullets - and only from suppression by that firer; not that the firing unit becomes impervious to suppression (apologies if my inexperience with scripting led to confusion).

    AIUI, the only difference between using nearestEnemy and nearestObjects would be that allies <25m away would be excluded from suppression by the firing unit's bullets as well as enemies. Or have I completely misunderstood how nearestObjects works?

  8. #38
    Master Gunnery Sergeant -Coulum-'s Avatar
    Join Date
    Dec 8 2010
    Location
    Canada
    Posts
    1,067
    Author of the Thread
    No confusion at all, Initially I was just suggesting nearest enemy for a seperate reason, totally unrelated to "friendly suppression". But your idea is really great I am giving it a try right now.

  9. #39
    Quote Originally Posted by -Coulum- View Post
    No confusion at all, Initially I was just suggesting nearest enemy for a seperate reason, totally unrelated to "friendly suppression". But your idea is really great I am giving it a try right now.
    Cool - but I'll have to wait til tomorrow to see the result, I have a conf call in less than six hours time & I need some sleep first!

  10. #40
    Master Gunnery Sergeant -Coulum-'s Avatar
    Join Date
    Dec 8 2010
    Location
    Canada
    Posts
    1,067
    Author of the Thread
    Yeah it might be a good idea to get some sleep then. See ya later.

    --edit--7:31
    Ah I was hopeing I could still catch you but I guess you'll see this in six hours..
    It worked!
    here's what I used..
    PHP Code:
    // UNITS WILL DROP IF SHOT AT   
    // Original code idea by -Coulum-  
    // TPW 20120617   

    private ["_unit","_near","_bc","_shots","_id","_randid","_nearestenemy","_distoenemy","distoshooter"];   

    //Start hint  
    sleep 1;  
    hintsilent "TPW / -Coulum- suppress active";  

    //Main function  
    tpw_sup =    
    {   
        { 
        
    _unit _x;   
           
    _nearestenemy _unit findnearestenemy (getposatl _unit); 
            
    _distoenemy _unit distance _nearestenemy
            if (
    _distoenemy 25then  
            
    {  

                   
    _nextTime _unit getVariable ["NextTime", -1];   
                    if (
    _nextTime == -1then   
                           
    {  
                           
    _unit setVariable ["NextTime"diag_tickTime];    
                           
    _unit addeventhandler ["Fired",{shooter = (_this select 0)}];  
                };  
            if (
    diag_tickTime >= _nextTimethen {_unit setVariable ["Shots"0]};     
            
    _bc count ((getposatl _unitnearobjects ["Bulletbase",10]);  
            
    _distoshooter _unit distance shooter;
        if ((
    _bc 0) and _distoshooter >15)then   
                
    {  
                
    _unit setVariable ["NextTime"diag_tickTime random 5];  
                
    _shots _unit getVariable "Shots";  
                
    _unit setVariable ["Shots"_shots _bc];  
                };  
              
            
    _shots _unit getVariable "Shots";  
            if (
    _shots == 0then {_unit setunitpos "auto"};  
            if (
    _shots 0then {_unit setunitpos "middle";};  
            if (
    _shots 5then {_unit setunitpos "down";};  
              };    
        } forEach 
    allunits;  
    };   

    [
    tpw_sup,0.05call cba_fnc_addPerFrameHandler
    Instead of using Nearbyunits I actually just measured the distance from the unit in question to the shooter. If the distance whas more than 15 metres apply suppression otherwise don't. Haven't tried it in a big fight yet but with just a few units it works fine. Great work Orcinus.

    I have a feeling that the nearestobject method might be more efficient so I am going to try that as well.
    Last edited by -Coulum-; Jun 18 2012 at 03:04.

Page 4 of 16 FirstFirst 1234567814 ... 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
  •