Jump to content
Sign in to follow this  
SD_BOB

Reliable Animations - Dedicated Server

Recommended Posts

Hello,

this is just a general enquiry to those with experience using animations and also the ambientAnim function.

I have been playing around this evening trying to get something to work reliably on a dedicated server. I have had some luck with standard animations, found in the anim viewer. I'm happy with the results for these, but i would still like to see how others implement them.

Secondly and more importantly, this BIS_fnc_ambientAnim. I have had completely mixed results with this...

I have implemented it the "normal" way, by entering the function call into a unit's init field. This produces results such as,

- No animation at all.

- Animation, but unit turned around.

- Animation not synced for all clients. Some in animation some not.

- Units in and out animation states, but hovering way up in the air.

I have tried calling the function, then run it through the BIS_fnc_MP. But results are just as above...

I've also tried calling the function from an external script file, referencing the unit names... But have had little luck.

So, i'm giving up for the night. But i'm curious to see how others do this, i'm probably missing something really simple. All i want to do is create a little ambience around the mission.

Thankyou in advance for any help.

Share this post


Link to post
Share on other sites

Honestly...I try to never use any complex BIS functions if I can help it. This is my opinion, but they tend to be more complicated than they are worth and create unwanted results that can be hard to fix.

I usually open up their functions and see how they did it - and then recreate the script for myself, while stripping away anything unnecessary.

Are you just looking for a function to make random AI play animations? What exactly are you looking for? We might be able to write up function.

Share this post


Link to post
Share on other sites

I've the same problem, I tried to make AI do the sit on high thing animation, but it appears flying, or just doesn't even appears.

There is a way to make it working?

Share this post


Link to post
Share on other sites

Apologies for the late reply, i've been a bit busy.

Basically, i'm just looking for a way to give my missions a bit more life. The reason the ambientAnim appealed to me, was the fact there are some nice animations, its looks good to have AI hanging around a base or checkpoint etc.

Its always nice to have a guy repairing a vehicle as you walk by, or a guy sat on a wall. There are some good animations hidden away, but using them easily and without sync problems is what i'm having trouble with.

Ideally i'd like something which can be implemented in whatever situation i need a little extra ambience, also ideally that these animations would cease on the event of the unit becoming aware or being shot.

In answer to your question genesis, yeah basically... I mean an option to define an animation or have a unit play random animations. As some of the animations are in multiple states, for example most have an "in", "loop" and "out" states. It would be nice to use some of these aswell.

Edited by Shadow.D. ^BOB^

Share this post


Link to post
Share on other sites

Stay away from fn_ambientAnim for multiplayer missions.

There are certain BI Devs who COMPLETELY ignore the multiplayer side of things. Their functions are for SP only. This is one of them. Some of the BI functions have createVehicle without locality checks for example, it's crazy. I won't name names, but those devs have no idea about MP or locality AT ALL.

It's a shame because he obviously put a lot of work into this function and it's a nice approach... absolutely useless in MP.

You will have to do this on your own. Here's an example on how to loop basic animations for that.

Let's call it ambientAnim.sqf:

// Server only
if (!isServer) exitWith {};


// Init switchMove function for animation broadcasting
if (isNil "YOURTAG_fnc_switchMove") then {

YOURTAG_fnc_switchMove = {
	(_this select 0) switchMove (_this select 1);
};

publicVariable "YOURTAG_fnc_switchMove";

};


// Parameter
_unit = _this select 0; // Unit
_anim = _this select 1; // Animation name, string
_loop = _this select 2; // Loop?
_dir = if ((count _this) > 3) then { _this select 3; } else { (getDir _unit); }; // Dir is optional


// Store
_unit setVariable ["ambientAnim", _anim, false];


// Disable AI
_unit disableAI "TARGET";
_unit disableAI "AUTOTARGET";
_unit disableAI "MOVE";


// Switch move
[[_unit, _anim], "YOURTAG_fnc_switchMove", nil, true] call BIS_fnc_MP;


// Wait a moment
sleep 2;


// Loop animation
if (_loop) then {
_animEh = _unit addEventHandler ["AnimDone", { [[(_this select 0), ((_this select 0) getvariable 'ambientAnim')], "YOURTAG_fnc_switchMove", nil, true] call BIS_fnc_MP; }];
};


// Dir correction
_unit setDir _dir;
_unit setPosATL (getPosATL _unit);


// Snap out when hit
_damage = damage _unit;
waitUntil {sleep 0.2; ((damage _unit) != _damage)};

if (_loop) then { _unit removeEventHandler ["AnimDone", _animEh]; };
[[_unit, ""], "YOURTAG_fnc_switchMove", nil, true] call BIS_fnc_MP;

_unit enableAI "TARGET";
_unit enableAI "AUTOTARGET";
_unit enableAI "MOVE";

You can call this from a unit's init line for example:

nul = [this, "Acts_A_M04_briefing", true] execVM "ambientAnim.sqf"; // Normal animation, looped
nul = [this, "Acts_A_M04_briefing", false] execVM "ambientAnim.sqf"; // Without loop (some anims are lopped autom.)
nul = [this, "Acts_A_M04_briefing", true, 90] execVM "ambientAnim.sqf"; // With optional dir correction, it's needed for some animations, as you noticed

Haven't tested this exact code, it's extracted from something I'm using though. It's not perfect, but it should give you a good basis to build upon.

  • Like 2

Share this post


Link to post
Share on other sites

Thankyou for that sxp2high.

I'll get stuck in this weekend see if i can get something together.

I really do wish BI would pay a little more attention to the MP side of things. Like you say, there are some very nice function/modules. The one's i have seen and thought, "yeah that could be useful". Seem to always have problems or flat out dont work in MP.

Edited by Shadow.D. ^BOB^

Share this post


Link to post
Share on other sites

Thank you very much sxp2high, just what I was looking for (after I too found out BIS functions aren't MP friendly).

Two small issues, the script gives an undefined variable error for 'animEh', which I fixed by adding '_animEh = {};' at the start of the script and it is better to use 'waitUntil {sleep 0.2; ((damage _unit) > 0)};' for the snap out, since there's a delay and if the unit gets killed at start, the animation never stops.

Haven't tried this yet on a dedicated, but looking forward to.

Share this post


Link to post
Share on other sites

No problem.

Be careful with this though, it's storing a lot of data for JIP synchronization. It shouldn't be used in long term missions, with a lot of traffic, like Domination. I wrote that mainly for short (< 2 hours) COOP missions.

If you want to add this to longer missions, you might want to disable the persistency of BIS_fnc_MP.

I.e. change:

[[_unit, _anim], "YOURTAG_fnc_switchMove", nil, true] call BIS_fnc_MP;

to:

[[_unit, _anim], "YOURTAG_fnc_switchMove", nil, false] call BIS_fnc_MP;

The last param becomes false instead of true.

Share this post


Link to post
Share on other sites

I only make <2 hour coop missions so I'm good. Will JIP players not see the animations if it's not persistent?

Share this post


Link to post
Share on other sites

They will, but starting from the next animation loop, not immediately. So it might take 30 sec. depending on the animation length.

Exception are animations that are loops by default, they will not work for JIP then.

I will make some improvements to the script sometime soon. :)

Share this post


Link to post
Share on other sites

Hi, guys. I can't seem to get this script to work in MP. That being said, I've simply copy-pasted EXACTLY what spx2high posted into a sqf-file. I haven't changed the "YOURTAG" part with anything. I'm quite new to this, so I don't really know what I'm supposed to do at all. The animations work fine in the editor thou.

Share this post


Link to post
Share on other sites

found out BIS functions aren't MP friendly.

Just a heads up, there are 2 differences between BIS and BI.

BIS - Bohemia Interactive Simulations.

BI - Bohemia Interactive. (This one your referring to...)

Share this post


Link to post
Share on other sites

Just a heads up, there are 2 differences between BIS and BI.

BIS - Bohemia Interactive Simulations.

BI - Bohemia Interactive. (This one your referring to...)

I think he was referring to the BI functions which all have the prefix BIS. :)

Share this post


Link to post
Share on other sites

Just a heads up, there are 2 differences between BIS and BI.

BIS - Bohemia Interactive Simulations.

BI - Bohemia Interactive. (This one your referring to...)

 

So why is your location underneath your avatar saying BIS Simulations? BISS?

 

The BIS in the function name most likely stands for Bohemia Interactive Studios.

Share this post


Link to post
Share on other sites

Check out this script:

https://forums.bistudio.com/topic/178334-shoters-animation-script/

 

Creator claims its JIP and multiplayer compatible.

Yes, thanks. I've been testing this out a bit and it works pretty well. Only thing I don't like about it is the looping. When placing units on structures they have a tendency to fall through the geometry when the loop resets. This did not happen with sxp2high's script. Although Shoters script actually work in MP.

 

EDIT:

Might be sxp2highs script work in MP aswell, only I'm not nearly clever enough to figure it out.  ^_^

 

 

Just a heads up, there are 2 differences between BIS and BI.

BIS - Bohemia Interactive Simulations.

BI - Bohemia Interactive. (This one your referring to...)

 

 

So you're saying BIS functions actually do work MP?

Share this post


Link to post
Share on other sites

Yes, thanks. I've been testing this out a bit and it works pretty well. Only thing I don't like about it is the looping. When placing units on structures they have a tendency to fall through the geometry when the loop resets. This did not happen with sxp2high's script. Although Shoters script actually work in MP.

 

EDIT:

Might be sxp2highs script work in MP aswell, only I'm not nearly clever enough to figure it out.  ^_^

 

 
 

 

So you're saying BIS functions actually do work MP?

 

hey guys need some help on applying ShoterAnimation working flawlessly on SP but how you do it for MP ? did you put the script on init.sqf or on editor mission.sqm on the unit ? do I need add BIS_fnc_MP ? I confused on this part 

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  

×