Jump to content
Sign in to follow this  
Sharpshooter221

Cancelling a units animation when shooting happens

Recommended Posts

First of all I apologise if this has been covered before. I searched but couldn't find anything.

So here's my problem:

I've got a unit outside a house doing an animation. Thing is that no matter what happens, they continue to stand there smoking their cigarette, totally ignorant of whatever happens in front of them. So what I'd like is for that animation to stop if someone nearby fires a weapon and then seek cover. Is this possible?

I've placed the following code into a waypoint to initiate the animation:

monique_wade playMove "ActsPercMstpSnon_damsel_smoking"

Any help is much appreciated.

- Sharpshooter.

Share this post


Link to post
Share on other sites

try

unit switchMove "";

this should immediately cancel any current animation

Share this post


Link to post
Share on other sites

just a note to add to killzone_kid's comment. if your doing this animation in multiplayer then the "switchmove" code will have to be broadcast for anyone else to see it as its a local command.

Share this post


Link to post
Share on other sites

I think his question resolves around how to detect someone shooting to actually interrupt the animation of the AI.

But first things first: switchMove is not a "local" command, it's effect is global so you don't have to worry about MP issues (just image how many problems you'd have if this command wasn't global in the first place ^^).

The first thing coming into my mind is to attach an event handler to the AI with "firedNear" as the event. Something like:

monique_wade addEventHandler ["firedNear", {
  (_this select 0) switchMove "";
}];

Look into the "firedNear" event to learn more about the parameters you can use in the handler.

You should probably delete the eventhandler afterwards because everytime someone shoots, their animation will get reverted back and could cause unwanted behaviour.

Share this post


Link to post
Share on other sites

Nimrod_Z is correct in ArmA 2 switchMove doesnt broadcast, and if it supposed to then it is way too slow.

Share this post


Link to post
Share on other sites

Lol I feel like a complete idiot now, having confused the Effects and Arguments Icon in the description xD

But this really is fucked up, one has to keep track over every client to syncronize special movements or animations instead of just executing that command... could have been easier to use ^^

Good thing we have some experienced developers in here to refute my blabber :D

btw @Sharpshooter221, is your question answered now or do you need further help?

Share this post


Link to post
Share on other sites

Animus is right as far as what I'm trying to do. This is for multiplayer and the idea is that if anyone shoots nearby, she'll stop whatever animation she's doing and seek cover.

I'll check out the event handler later on and get back to you. Your help is much appreciated.

- Sharpshooter.

Share this post


Link to post
Share on other sites
Lol I feel like a complete idiot now, having confused the Effects and Arguments Icon in the description xD

But this really is fucked up, one has to keep track over every client to syncronize special movements or animations instead of just executing that command... could have been easier to use ^^

;) it's all good buddy. I've had those days myself. and I agree that it makes NO sence NOT to broadcast this command.. "playmove" and "playactionnow" are global though, but sometimes "switchmove" is very handy. just a lil more pain to set up for MP.

@sharpshooter

while your checking out the eventhandlers, look at publicVariable event handlers as well. I've used it to broadcast switchmove before for a hostage in a mission I was making. im sure there are other ways as well though. another easier way is if you use CBA. they have a command "CBA_fnc_globalExecute" .

https://dev-heaven.net/docs/cba/files/network/fnc_globalExecute-sqf.html#CBA_fnc_globalExecute

Edited by Nimrod_Z

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  

×