OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: sharkattack on 31 Jul 2009, 13:23:06

Title: Animation woes
Post by: sharkattack on 31 Jul 2009, 13:23:06
hi guys 
trying to bring some life to enemy bases but im having trouble ending a conversation when a condition is set ..

have a simple script to loop the animations

Code: [Select]
#chat
w1 playMove "ActsPercMstpSnonWnonDnon_talking01";
~2
w2 playMove "ActsPercMstpSnonWnonDnon_talking02";
goto "chat";

this works fine however i cant get them to stop when the camp is alerted
have tried using a trigger with
condition : alert
activation : w1 playMove "NULL";w2 playMove "NULL";

The bots stop for a second  but then continue with the animation ...
i have  tried  making a code to deal with it  but as you know  my scripting talents are nil 

anyone correct me or point me in the right direction  this is my attempt  which (heres the suprise) dosnt work ..  ???   

Code: [Select]
#chat

? alert : goto "endloop"

w1 playMove "ActsPercMstpSnonWnonDnon_talking01";
~2
w2 playMove "ActsPercMstpSnonWnonDnon_talking02";

goto "chat";

#endloop

w1 playMove "NULL";
~1
w2 playMove "NULL";

exit


many thanks  and best wishes 
Title: Re: Animation woes
Post by: Planck on 31 Jul 2009, 13:34:44
Hmmmm, did you try?

w1 playMove "";w2 playMove "";


Planck
Title: Re: Animation woes
Post by: sharkattack on 31 Jul 2009, 13:51:34
hi mate
i tried that  didnt work ..  also tried switchmove ""

probably best if i try to do this in sqf format  anyway  ... can anyone explain how to the break loop
when alert=true

Code: [Select]
while { true } do
{
w1 playMove "ActsPercMstpSnonWnonDnon_talking01";
sleep 1;
w2 playMove "ActsPercMstpSnonWnonDnon_talking02";
};

thanks in advance    :good:
Title: Re: Animation woes
Post by: laggy on 31 Jul 2009, 14:09:47
In init.sqs or .sqf:

alert = false;

Then:
Code: [Select]
while { !(alert) } do
{
w1 playMove "ActsPercMstpSnonWnonDnon_talking01";
sleep 1;
w2 playMove "ActsPercMstpSnonWnonDnon_talking02";
};

Just make sure this script is run after the "alert=false" is initiated.

Maybe having a longer sleep would be an idea since 1 sec is probably much less than the length of the animation sequence. Maybe the animation commands get "packed" and after only 20 seconds, 20 playMove commands are waiting in line to be executed. Not sure about this, but might be worth a try. I would see how long the actual animation sequence is, and have a total sleep that is 1 sec longer than that.

Something like:
Code: [Select]
while { !(alert) } do
{
w1 playMove "ActsPercMstpSnonWnonDnon_talking01";
sleep 1;
w2 playMove "ActsPercMstpSnonWnonDnon_talking02";
sleep (animation sequence length);
};

I doubt that the units will stop the animation until it's over, even if you have a switchMove "" command executed. In Armed Assault they wouldn't break an ongoing animation even if they were dead. Consequently, having very long animations in the mission itself (not cutscene) was often useless.

In my mission "One Shot One Kill" I abandoned the idea of having a good looking animation for a politician that you had to assassinate during a speech. Even after a lethal, gory headshot, he continued his "talking" animation until it was finished (10 seconds later), and only then would he drop dead. It looked silly and was very confusing for the assassin players.

Laggy
Title: Re: Animation woes
Post by: sharkattack on 31 Jul 2009, 18:08:43
hi laggy 

thanks for the advice and the code mate ... ill give it  a try
might have to use it in a cutscence  rather than  ingame

best wishes mate
Title: Re: Animation woes
Post by: Inkompetent on 31 Jul 2009, 19:08:44
If nothing else you can use a script handle when executing the talkingscript (like talking = []exec "talk.sqs"; and then use terminate (http://community.bistudio.com/wiki/terminate) to end the script when you wish to? Still won't cure the problem with long animations, but should work to stop the loop whenever you wish.
Title: Re: Animation woes
Post by: sharkattack on 31 Jul 2009, 19:47:48
having decent results  using event handlers ...  not sure if im using them correctly though ..

this works a treat  stops animations dead  as soon as unit is killed
(anygood for one shot kill laggy ?)

in animated units  init field
Code: [Select]
this addEventHandler ["killed",{w1 switchmove "";}]
then ive added the following  to the animated units init field
not sure if im doing this correctly probably a more efficient way but it seems to work
 
Code: [Select]
"alert" addPublicVariableEventHandler {w1 playMove ""}

have attached a demo  if anyone would like  to take a look

best wishes  lads  ... long live ofpec  :good:
Title: Re: Animation woes
Post by: laggy on 01 Aug 2009, 13:10:17
Code: [Select]
this works a treat  stops animations dead  as soon as unit is killed
(anygood for one shot kill laggy ?)

Wait... are you saying that the long ongoing animation is cancelled/aborted/intercepted/broken with this eventhandler solution?

Or is the loop just exited, meaning the last active animation is finished first?
Title: Re: Animation woes
Post by: sharkattack on 02 Aug 2009, 10:51:48
@laggy

this addEventHandler ["killed",{unitname switchmove "";}]

stops it dead  as far as i can tell  mate  :good:
Title: Re: Animation woes
Post by: laggy on 02 Aug 2009, 11:18:26
Great, have to try it, thanks a bunch!

Laggy