Jump to content
Sign in to follow this  
kocrachon

Loop playmove?

Recommended Posts

So right now I borrowed a script to repeat a playmove so that a guy repeats a playmove forever, here is the script I am using so far..

_unit = _this select 0;
_animation = _this select 1;
_noWeapons = _this select 2;

_unit setVariable ["BIS_noCoreConversations", true];
if (_noWeapons) then {removeAllWeapons _unit};

while {true} do {
_unit switchMove _animation;
waitUntil {!(animationState _unit == _animation)};
};

and in the init of that guy I have this

[this,"ActsPercSnonWnonDnon_carFixing2",true] execVM "animationLoop.sqf";

The problem is he stands there and the animation never starts. Any tips?

Share this post


Link to post
Share on other sites

Some of the animations are a little odd, in that they don't seem to do anything. A couple days ago I went through about 2,000 anims and there's quite a lot that just result in the guy standing there. I think some of them just have very specific conditions that must be fulfilled before they'll work, or something...

If you run the BIS_fnc_help thing, in the "Scenes" section there's a function BIS_fnc_miscanim which allegedly runs some of these animations, including that carfixing2 one. But I've not been able to get it to work, nor spent the time to decipher what it's actually doing. Makes my head hurt.

Share this post


Link to post
Share on other sites

That animation should work just fine. I have used it before.

You should however disable AI's ability to change animation by it self.

I would suggest something like this

_unit = _this select 0;
_animation = _this select 1;
_noWeapons = _this select 2;

_unit disableAI "ANIM";
_unit setVariable ["BIS_noCoreConversations", true];
if (_noWeapons) then {removeAllWeapons _unit};

while {true} do {
_unit switchMove _animation;
if (!alive _unit) exitWith {_unit enableAI "ANIM";_unit switchMove "";};
waitUntil {!(animationState _unit == _animation)};
};

Share this post


Link to post
Share on other sites

You may have to use "playMove" instead of "switchMove". Try this modfied version of my script:

_unit = _this select 0;
_animation = _this select 1;
_noWeapons = _this select 2;
_switchMove = _this select 3;

_unit allowDamage false;
_unit setDamage 0;
_unit setVariable ["BIS_noCoreConversations", true];
if (_noWeapons) then {removeAllWeapons _unit};

sleep random 30;

if (_switchMove) then {
while {true} do {
	_unit switchMove _animation;
	waitUntil {!(animationState _unit == _animation)};
};
} else {
while {true} do {
	_unit playMove _animation;
	waitUntil {!(animationState _unit == _animation)};
};
};

Now you can execute it via:

nil = [this,"animation",true,false] execVM "animLoop.sqf";

Oh, and you can cut out the sleep if you wish. I use this script for many units and it's a bit more dynamic if they don't start all at the same time.

Share this post


Link to post
Share on other sites

How strange... it does indeed work fine. It doesn't work if you try to play it in the unit's init field, but that doesn't explain why it didn't work in my previous attempt where it was cycling through animations using a radio trigger and switchMove.

You do need to disableAI "ANIM" first, which I had done... so I don't know. Maybe previous animations that were played had confused its state?

This one works fine with both playMove and switchMove.

Share this post


Link to post
Share on other sites

I've noticed so far that disabling "ANIM" don't work with this script because the unit doesn't get back to it's standard animation so the animation state doesn't change and the animation won't be run multiple times. I wrote this script to fill a camp with life, like working guys or talking civies and so on. Therefor they're running the same animation again and again during the whole mission. However, you won't regocnize it if you don't look too close at a specific unit. ;)

Share this post


Link to post
Share on other sites
I've noticed so far that disabling "ANIM" don't work with this script because the unit doesn't get back to it's standard animation so the animation state doesn't change and the animation won't be run multiple times.

So far animations have been looping for me.

Is there specific animations that won't loop unless unit gets into default position first?

Now that i think of it i have not used/tested any of those "only playmove" animations.

I use disableAI "ANIM" because without it AI unit reacts to anything it sees/hears (shots,explosions,enemy units) , stops the animation stands up and freezes. Just stands there unresponsive.

Share this post


Link to post
Share on other sites

Hm, maybe that's fixed. When i tested the script i had problems with turning "ANIM" ai off. And they won't stand up, that would change their animation state and forces them back into the animation. Anyway, if it works with disable "ANIM"...^^

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  

×