Jump to content

Recommended Posts

Script Version 1 Released October 28, 2019.

Point-Blank-Melee-Demo.jpg

 

This script addresses problem where 2 enemy AI are too close together and they either do not shoot (and jerk around), or shoot through each other without hitting each other.  I encountered this a few times in my Scripted AI CQB Movement script, and decided it would be fun to solve it with a melee attack.

 

Videos:

Spoiler

 

 

I'm adding this to my Scripted AI CQB Movement script.  But someone else might want to use this for other purposes (AI scripts, cutscenes, etc.).  So here it is  if someone wants the whole thing or pieces of it.

 

Download V1 zip file and put unzip folder to your missions directory: 

 

Features:

  • Loop senses when AI within 2 meters of enemies, and chooses one AI to do melee attack.
  • AI uses Forehand/Backhand/Overhead strike animations with rifle attached to hand. 
  • Strike pushes near enemies back to give fighter some breathing room (very helpful when being ratpacked by zombies!)
  • Randomized Loser reactions:
    • Drop weapon
    • Ragdoll to ground after strike
    • Try and pull pistol after losing primary weapon
  • Striker executes victim after striking him.
  • Pain grunts and shouts using in-game voice files (all vanilla voice languages supported)


Thanks to @LSValmont, @GEORGE FLOROS GR, EO and others for suggestions and support.

 

  • Like 12
  • Thanks 3

Share this post


Link to post
Share on other sites

giphy.gif

 You did it again, bud!!!

I LOVE IT...!!!!HAHAHAHAHA..no wonder you've been quiet lately...hahaha hahaha

 

Ps: dunno why, but the "...you mother fuck*r..." part really got me ROFL by my self...

  • Haha 2

Share this post


Link to post
Share on other sites

Lame. Do they even karate?! 

Edited by Vandeanson
Just kidding mate, this is awesome XD
  • Haha 2
  • Confused 1

Share this post


Link to post
Share on other sites

Hey JB, nice to see you all fixed up and producing a sweet little script. :rthumb:

I haven't tried it yet but I'm straight away wondering if this would work with AI against Ravage zeds(agents)?  The same situation described in your OP often arises when AI are too close to Zeds, this script could potentially fix this immersion breaker too.....

I'd love to see this walking pile of pus get pistol whipped+execution.

Share this post


Link to post
Share on other sites
1 minute ago, EO said:

Hey JB, nice to see you all fixed up and producing a sweet little script. 

Thanks buddy!

2 minutes ago, EO said:

I'm straight away wondering if this would work with AI against Ravage zeds(agents)?

Not sure, but I could whip up a little test.  What zombie mod do I need, and how do I place a zombie (pick him from units in Editor?)?.

  • Like 1

Share this post


Link to post
Share on other sites

Ravage mod has placeable zeds in Eden, find them under Civilian. :icon_biggrin:

  • Thanks 1

Share this post


Link to post
Share on other sites
12 hours ago, EO said:

Ravage mod has placeable zeds in Eden, find them under Civilian

Hey EO.  The script works pretty good vs. Zombies:

 

However I did see cases where zombies move too close to shooter after being struck, and then shooter won't shoot.  This is because zombie agents do not obey forceSpeed 0 command.  So I probably need to attach them to an invisible object so they don't advance after being hit.  Or I have to add more code to repeat the shooter melee attacks to drive zombie back again (but this is more work and may not be worth it).

 

What I learned about zombie agents:

  • forceSpeed 0 does not work on zombie agents
  • zombies can still attack (swing arms) when in a forced crouch animation or when on the ground because of setUnconscious true.  I think this means that zombie attacks (arm swings) are implemented as gestures and not animations.  This was actually cool to see the zombie flailing at shooter after knocked to the ground.

 

  • Like 4

Share this post


Link to post
Share on other sites

God damn JB, your a wonderful man....are you single? 😍  The dudes over in the Ravage thread will freak out when they see this shit, you just given us a really authentic looking "DoubleTap" script.

 

 

  • Like 1

Share this post


Link to post
Share on other sites

It ll probably become clear once i can properly look at the code in atom, but is it correct that i could execute this somewhere in VA and it would be applied to all AI? Or does it need to executed for every AI at spawn? 

 

It would be awesome for e. G. Banditcamps, where it often happens that zombies get into close quarter combat with AI. 

 

 

Cheers

Vd

 

 

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, Vandeanson said:

It ll probably become clear once i can properly look at the code in atom, but is it correct that i could execute this somewhere in VA and it would be applied to all AI? Or does it need to executed for every AI at spawn? 

 

It would be awesome for e. G. Banditcamps, where it often happens that zombies get into close quarter combat with AI. 

Hey VD.  The sample code in op should be called when 2 enemy AI are near each other.  This means whoever wants to use it has to have a loop monitoring for that situation.  I have not written that loop.  So if someone wants to build that into Ravage AI, or LAMBS AI, or you run a loop on camp bandits, its there to be used.  It shouldn't be too hard though.

 

For my simple case, I am running on AI running my CQB movement scripts, so when they are clearing a building, this may occur.

Share this post


Link to post
Share on other sites
9 hours ago, EO said:

God damn JB, your a wonderful man....are you single? 😍  The dudes over in the Ravage thread will freak out when they see this shit, you just given us a really authentic looking "DoubleTap" script.

Haha, I'd take you up on that but you dress to frithified for me.  I do like the TWERP double/triple/quadruple taps as well (Terminate With ExtReme Prejudice).  Makes for a nice brutal ending to a close encounter.  If any Ravage AI guys want this they are welcome to it.  They just have to write some code to sense when 2 AI are within 2 meters of each other.

  • Like 1

Share this post


Link to post
Share on other sites

Just had a thought:  EpeContact eventhandler.  Supposedly, this event detects collisions between 2 objects.   If this idea works, then we can add an event handler to all AI units and zeds.  When this event fires, we check if 2nd object is an enemy, and if so call my script.  That would eliminate the need to monitor AI closeness via a script.  Hope to try this out tonight or tomorrow.

 

It might not work if units refuse to fire on each other when not close enough to fire a collision event.  We can hope though...

Share this post


Link to post
Share on other sites
6 minutes ago, johnnyboy said:

Just had a thought:  EpeContact eventhandler.  Supposedly, this event detects collisions between 2 objects. 

 

Only for PhysX simulated objects iirc, so cars and pretty much any kind of vehicle - but it won't trigger if the objects are foot units.

  • Thanks 1

Share this post


Link to post
Share on other sites
17 minutes ago, johnnyboy said:

Just had a thought:  EpeContact eventhandler.  Supposedly, this event detects collisions between 2 objects.   If this idea works, then we can add an event handler to all AI units and zeds.  When this event fires, we check if 2nd object is an enemy, and if so call my script.  That would eliminate the need to monitor AI closeness via a script.  Hope to try this out tonight or tomorrow.

 

It might not work if units refuse to fire on each other when not close enough to fire a collision event.  We can hope though...

 

CBA option:

meleeRangeAiCheck_fnc = {

{
	if (alive _x && !(lifeState _x isEqualTo "INCAPACITATED") && alive (assignedTarget _x) && !(lifeState (assignedTarget _x) isEqualTo "INCAPACITATED") && (_x distance (assignedTarget _x) < 4)) then {
		[_x,(assignedTarget _x)] spawn JBOY_fnc_pointBlankMelee;
	};
} forEach allUnits - allPlayers;

// loop	to check every 3 + random 3 seconds:
[
	meleeRangeAiCheck_fnc,
	[],
	(3 + (random 3))
] call CBA_fnc_waitAndExecute;

};

Not tested, should work for Ai vs. Ai and Ai vs. Player situations.

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
11 minutes ago, haleks said:

Only for PhysX simulated objects iirc, so cars and pretty much any kind of vehicle - but it won't trigger if the objects are foot units.

Bummer dude.  Thanks for saving me the research time!

 

So now the question is how to write a loop monitoring AI that doesn't bog the engine down. Some ideas:

  • Only monitor 2 of the 3 enemy factions (east, west, independent), which would still cover all possible enemy close contacts.
  • Start loops with long sleeps initially that detect when enemy ai within 10 meters of each other.  Once detected, cut sleeps down to .5 seconds until units within 2 meters of each other (or jack sleeps back up when one unit dies, or distance grows > 10 meters again).
  • Run one loop for all AI in 2 factions (i.e., not a loop per per ai unit which would be too many processes running).
  • In the loop, only check unique set of Enemy AI pairs so not redundantly testing EastUnit1 vs. WestUnit1 and WestUnit1 vs. EastUnit1.
  • Reduce set of AI to check to those within 200 meters of a player, and those whose simulation is enabled, and behaviour is not CARELESS.
  • What else?

Anybody have suggestions for such a monitoring loop?

Share this post


Link to post
Share on other sites
1 minute ago, LSValmont said:

CBA option:

Thanks LSValmont!  This is  a great start.  

 

What's the advantage of  CBA_fnc_waitAndExecute?  I'm not familiar with it.

Share this post


Link to post
Share on other sites
3 minutes ago, johnnyboy said:

Thanks LSValmont!  This is  a great start.  

 

What's the advantage of  CBA_fnc_waitAndExecute?  I'm not familiar with it.

 

I follow these guidelines for most of my scripts now: https://ace3mod.com/wiki/development/coding-guidelines.html#84-unscheduled-vs-scheduled

 

CBA_fnc_waitAndExecute is basically a sleep but for the unscheduled environment.

 

By the way assignedTarget won't fire if the simulation on the unit is disabled so you will only be checking on dynamic enabled units basically.

 

It seems pretty performance friendly if you ask me!

  • Like 2

Share this post


Link to post
Share on other sites
2 minutes ago, LSValmont said:

I follow these guidelines for most of my scripts now: https://ace3mod.com/wiki/development/coding-guidelines.html#84-unscheduled-vs-scheduled

 

CBA_fnc_waitAndExecute is basically a sleep but for the unscheduled environment.

 

By the way assignedTarget won't fire if the simulation on the unit is disabled so you will only be checking on dynamic enabled units basically.

 

It seems pretty performance friendly if you ask me!

I love it.  Gonna try it out later (need to focus on work now, instead of this stuff that is 1000 times more interesting to me).  Thanks for the guidelines.

  • Like 1

Share this post


Link to post
Share on other sites

Thought about this today (during work, because yeeep 1000 timers more interessting). 

I m trying to avoid loops wherever possible as in my project, they used to add up quite a bit and i started to notice it. Maybe a firednear EH would be something to combine it with. 

It only triggers if someone fires very close by... 69 m i think. 

 

However, i am not familiar with the cba EHs and they might be better fitted. 

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, Vandeanson said:

Thought about this today (during work, because yeeep 1000 timers more interessting). 

I m trying to avoid loops wherever possible as in my project, they used to add up quite a bit and i started to notice it. Maybe a firednear EH would be something to combine it with. 

It only triggers if someone fires very close by... 69 m i think. 

 

However, i am not familiar with the cba EHs and they might be better fitted. 

 

That is right @Vandeanson!

 

You could easily use a fired EH to check if the assignedTarget was closer than 4 meters and all the other checks of my loop.

You would need need to add the EH to all the units you wish to be able to melee but it would be even more performance friendly than any loop.

Share this post


Link to post
Share on other sites
5 minutes ago, LSValmont said:

You would need need to add the EH to all the units you wish to be able to melee but it would be even more performance friendly than any loop.

Its more performance friendly, but it may miss some cases of AI nearness, IMO.  If a zed approaches an AI from the rear, firedNear may never happen for the AI.

Share this post


Link to post
Share on other sites
2 hours ago, johnnyboy said:

Its more performance friendly, but it may miss some cases of AI nearness, IMO.  If a zed approaches an AI from the rear, firedNear may never happen for the AI.

 

The loop will also miss some targets if during the sleeps the unit steps away from the minimal range, changes target etc. but  this loop just needs to be called once on the server and would be far easier to implement on a mission as you just have to add the fnc to the initserver.sqf and call it from there. Since it runs on the unscheduled env. then it never misses its checks nor delays other scheduled scripts.

 

According to the ACE guidelines thou, an EH is most of the time the preferable way even if not as accurate. 

  • Like 1

Share this post


Link to post
Share on other sites

Great stuff as always johnnyboy !

 

Thank you very much for sharing your work ! 

You could use other animations as well , like :

acts_miller_knockout    AwopPknlMstpSgthWrflDnon_End     Acts_Executioner_Backhand

 

Keep it up !  :wave:

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
On 10/22/2019 at 6:06 PM, GEORGE FLOROS GR said:

Great stuff as always johnnyboy !

 

Thank you very much for sharing your work ! 

You could use other animations as well , like :

acts_miller_knockout    AwopPknlMstpSgthWrflDnon_End     Acts_Executioner_Backhand

 

Keep it up !  :wave:

 

I totally agree... 

 

The attachment of the weapon to the arm looks weird and perhaps unnecessary if you use an animation depending on if the Ai is holding a primaryWeapon, SecondaryWeapon or handGunWeapon. There are animations meant to be used with one of those particular weapons so they look good.

 

This is an example of what I am talking about:

 

        if (currentWeapon player isEqualTo "") then {
                [player, "AwopPercMstpSgthWnonDnon_end"] remoteExec ["switchMove", 0];
        } else {[player, "ThrowGrenade"] remoteExec ["playActionNow", 0];};

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×