Jump to content
Sign in to follow this  
mcnools

Make AI-unit shoot themselves.

Recommended Posts

Ok, this is pretty grim, but I'm working a mission where a AI-unit is supposed to shoot himself rather than get captured etc, I've searched far and wide for a script but I haven't found anything that works. Does anyone know of a script for this? I do believe that there are animations for this ingame but maybe I'm mistaken. Best thing would be if the script is activated when we close in on the unit, it plays the animation and the gun fires, killing the unit.

Share this post


Link to post
Share on other sites

I just can't do the proper search here to create an example now, but I believe your objective is pretty plausible and relatively easy to do! 😎 (that said, I am not actually good at SQF scripts, but love to copy and mix stuff from the guys in the Arma kitchen here)

My step-by-step would be:

1-) create a script/trigger that identifies when the undesirable enemies of your soldier come closer to him;
2-) get the amount of damage of your soldier, so the script could act upon him only when, let's say, his damage is above 70%;
3-) when that happens, use a getPos upon the soldier to serve as the exact point of a createVehicle;
4-) immediately use a forced animation upon soldier, something like throwing a grenade;
5-) immediately create a grenade and explode it at the soldiers getPos .


--------
EDIT: all the grenade part was just as a dramatization 😁 . You could perfectly use a "silent" stuff like "_unit setDamage 1;" after one of your original suggested animations to have the self-inflicted-thing 🙈

  • Like 1

Share this post


Link to post
Share on other sites

This is just copied and edited from one of my scripts, which performs an animation and knocks out the enemy in front.

Give your unit the name of "unit1".
Try to create a script TRIGGER that executes this code once your unit's enemy comes within it:

 

removeAllWeapons unit1;	//optional, of course, just for the purpouse of NOT having a gun durint the animation;
unit1 playMoveNow "AwopPercMstpSgthWnonDnon_end";
sleep 1.5;	// you might need to remove this if returns "sleep/wait not accepted in this context";

unit1 setDamage 1;	//this will k1ll the unit;
/*/ OR! /*/
unit1 setUnconscious true;	//this would just put him uncounscious instead;


If that begins to get closer to what you want, you could spend some time in the "Animation Viewer" menu, inside EdenEditor, and search for an animation that suits what you want. But keep in mind that you will probably need to experiment with different animation commands instead of "playMoveNow", because not all of them work for any animation.

https://community.bistudio.com/wiki/playMoveNow

Edited by JCataclisma
  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the replies, I will give it a try!

 

Couldn't find suitable animations so I made a little workaround. I hide the unit inside a room with a pistol in his hand and when anyone gets nere it this script executes:

 

unit1 fire currentMuzzle unit1;
sleep 0.2;
unit1 setDamage 1;

 

That way we hear a gunshot when we approach and he's dead when we enter the room, seems to work okay!

  • Like 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
Sign in to follow this  

×