Page MenuHomeFeedback Tracker

CombatMode doesn't return the correct combat mode of units
Closed, ResolvedPublic

Description

There's no way to return the exact combat mode of units using the CombatMode command. It only works if you use setCombatMode, which will change combat mode for an entire group, not just individual units.

To set combat mode for individual units, the trick that mod-makers (and I'm assuming the vanilla commanding menus) use is this:

  1. Create a new group,
  2. Temporarily move the units to this new group,
  3. Set combat mode for the new group,
  4. Rejoin units back into their original group.

But this method breaks the combatMode command; which is (most likely) because it's associated with groups, not units.

Details

Severity
Minor
Resolution
Not A Bug
Reproducibility
Always
Operating System
Windows 8 x64
Category
AI Issues
Steps To Reproduce

Method 1 (script):

  1. Create a new group,
  2. Temporarily move the units to this new group,
  3. Set combat mode for the new group,
  4. Rejoin units back into their original group.
  5. Use the combatMode command on one of those units.
  6. It always returns "YELLOW"
_units = groupSelectedUnits player; // just some array of units
_sideUnits = side (_units#0);
_originalGrp = group (_units#0);
_tempGrp = createGroup _sideUnits;
_units joinSilent _tempGrp;
_tempGrp setCombatMode _desiredCombatMode; //e.g "RED"
_units joinSilent _originalGrp;

combatMode (_units#0)

Method 2 (engine commanding menus):

  1. While being the leader of a group, use the commanding menus to order a certain unit to hold fire.
  2. Use the combatMode command on that unit.
  3. It always returns "YELLOW"

Event Timeline

Leopard20 changed Category from AI Control / Commanding to AI Issues.
BIS_fnc_KK added a subscriber: BIS_fnc_KK.EditedNov 24 2019, 3:37 PM

The command sets combat mode for a group, not individual AI units.
https://community.bistudio.com/wiki/combatMode

BIS_fnc_KK closed this task as Resolved.Nov 24 2019, 3:39 PM
BIS_fnc_KK changed Resolution from Open to Not A Bug.

The command sets combat mode for a group, not individual AI units.
https://community.bistudio.com/wiki/combatMode

I know that. But how does one even get the combatMode for a unit?! There's no way at all. That means this command needs to be improved.

BIS_fnc_KK added a comment.EditedNov 25 2019, 8:12 AM

A combat mode of a unit depends on a combat of the group the unit is in, so in order to get combat mode of the unit you can get the combat mode of the current group the unit is in. When you move unit to another group, the unit behaviour is set by the new group, this is why combat mode you set on temp group won’t affect the unit in the new group. In short, "combatMode unit" does what you want already, returns combat mode the unit is subject to currently. I hope I made it clearer.

rev 146576 Added unitCombatMode/setUnitCombatMode