Page MenuHomeFeedback Tracker

New Scripting Command "createUnitIdle"
Acknowledged, WishlistPublic

Description

REQUEST:

    New scripting command for creating a unit with all simulation/AI features disabled

REASON:

    This can greatly optimize the spawning of AI in missions if the mission designer uses this "createUnitIdle" (example command name) command instead of createObjectArray

HOW IT WORKS:

    Just like createObjectArray, but for units specifically.  When the unit is spawned, it will be without its simulation enabled, and without it's AI features enabled.  Perhaps even have it be optionally spawned as invisible (hideObjectGlobal true/false?).

    It is important to note that this command should spawn the unit with these features all turned off already, NOT spawn them with the features enabled and then turn it off after spawned.

    If you spawn in units with all this turned off already, this will greatly reduce the stutter and desync in missions, especially in MP.

    The mission designer is then given the opportunity when and how they re-enable the AI simulation and features for that spawned unit.  The most efficient way would be to re-enable the features gradually over time.

HOW TO USE IT:
//example command:
_unit=_this select 0;
if(isServer) then {

_unit createUnitIdle [_unitType, _Pos, [], 6, "FORM"];
_unit hideObjectGlobal true;
_unit setBehaviour "CARELESS"; //prevents AI from aggressing while hidden/invisible

sleep 3;

_unit enableSimulationGlobal true;

sleep 3;

_unit enableAI "ANIM";

sleep 3;

_unit enableAI "FSM";

sleep 3;

_unit enableAI "MOVE";

sleep 3;

_unit enableAI "CHECKVISIBLE";

sleep 3;

_unit enableAI "TARGET";

sleep 2;

_unit enableAI "AUTOTARGET";

sleep 2;

_unit enableAI "AIMINGERROR";

sleep 2;

_unit enableAI "SUPPRESSION";

sleep 2;

_unit enableAI "TEAMSWITCH";

sleep 1;

_unit hideObjectGlobal false; //if createUnitIdle also hides spawned unit
_unit setBehaviour "SAFE";

};

Details

Legacy ID
3244367504
Severity
None
Resolution
Open
Reproducibility
Have Not Tried
Category
Feature Request
Additional Information

YouTube Proof of Concept (no gameplay footage, just going over the code):
https://www.youtube.com/watch?v=Jw72UBl3yYI

Event Timeline

Phronk edited Additional Information. (Show Details)Dec 21 2015, 12:03 AM
Phronk set Category to Feature Request.
Phronk set Reproducibility to Have Not Tried.
Phronk set Severity to None.
Phronk set Resolution to Open.
Phronk set Legacy ID to 3244367504.May 8 2016, 1:21 PM
Phronk added a subscriber: Phronk.

Updated on December 8th, 2016:
Added a check for isServer, included newer AI features to list, and correctly executed the command hideObjectGlobal in the code.

Also included setBehaviour "CARELESS" and "SAFE" so that the unit doesn't become hostile while he's invisible (hideObjectGlobal)

R3vo added a subscriber: R3vo.May 8 2016, 1:21 PM
R3vo added a comment.Jan 10 2016, 11:25 AM

Very nice find, however, I don't think the mission builder should enable those features manually. In my opinion it would be better if the "createUnitIdle" would handle that aswell.

_unit createUnitIdle [_unitType, _Pos, [], 6, "FORM",_sleep];

_sleep would then be the time it takes for the AI to have all features fully enabled. This could be of course optional, for example if one enters -1 as sleep value then the automatic enabling would be deactivated.

I agree. I'd only say "leave it up to the mission designer" because I personally don't know the optimal amount of time the sleeps should be in between reactivating each AI feature/simulation. If BI figures out a sweet spot, then it'd be ideal they set that as a default sleep time.

I think it'd be counterproductive to have a shorter performance sleep than they'd recommend (I think about 3 or 5 seconds works fine for now), but being able to still adjust that sleep time like you mentioned would still be nice freedom to have with the command.

PiepMGI added a subscriber: PiepMGI.May 8 2016, 1:21 PM

No advantage:

  • You can spawn units when you need it. It's better than hiding units at start;
  • Your "reanimation" script is very heavy!
R3vo removed a subscriber: R3vo.Jul 21 2021, 6:07 PM