Tweaks to the 'auto formation' feature.

- Add an option to control the 'null formation' override, so it can be
turned off/on independently of having a default formation set. It
defaults to "Walk/Patrol only".
- Make only 'walk' and 'patrol' orders use the default formation.

This makes the system more flexible, and easier to use for competitive
play.

Differential Revision: https://code.wildfiregames.com/D3413
This was SVN commit r24703.
This commit is contained in:
wraitii 2021-01-19 16:14:07 +00:00
parent f737831167
commit e10202d64d
4 changed files with 37 additions and 6 deletions

View File

@ -315,6 +315,7 @@ deselectgroup = Ctrl ; Modifier to deselect units when clicking group ic
rotate.cw = RightBracket ; Rotate building placement preview clockwise
rotate.ccw = LeftBracket ; Rotate building placement preview anticlockwise
snaptoedges = Ctrl ; Modifier to align new structures with nearby existing structure
toggledefaultformation = "" ; Switch between null default formation and the last default formation used (defaults to "box")
; Overlays
showstatusbars = Tab ; Toggle display of status bars
devcommands.toggle = "Alt+D" ; Toggle developer commands panel
@ -392,6 +393,7 @@ snaptoedges = "disabled" ; Possible values: disabled, enabled.
snaptoedgesdistancethreshold = 15 ; On which distance we don't snap to edges
disjointcontrolgroups = "true" ; Whether control groups are disjoint sets or entities can be in multiple control groups at the same time.
defaultformation = "special/formations/box" ; For walking orders, automatically put units into this formation if they don't have one already.
formationwalkonly = "true" ; Formations are disabled when giving gather/attack/... orders.
[gui.session.minimap]
blinkduration = 1.7 ; The blink duration while pinging

View File

@ -586,6 +586,24 @@
"tooltip": "Units and Structures can be part of multiple control groups. This is useful to keep control groups for distinct armies and a control group for the entire army simultaneously."
}
]
},
{
"type": "dropdown",
"label": "Formation control",
"tooltip": "Decide whether formations are enabled for all orders or only 'Walk' and 'Patrol'.",
"config": "gui.session.formationwalkonly",
"list": [
{
"value": "true",
"label": "Walk/Patrol Only",
"tooltip": "Other orders will disband existing formations."
},
{
"value": "false",
"label": "No Override",
"tooltip": "Units in formations stay in formations."
}
]
}
]
}

View File

@ -18,6 +18,14 @@ class AutoFormation
this.defaultFormation = Engine.ConfigDB_GetValue("user", "gui.session.defaultformation");
if (!this.defaultFormation)
this.setDefault(NULL_FORMATION);
this.lastDefault = this.defaultFormation === NULL_FORMATION ?
"special/formations/box" : this.defaultFormation;
Engine.SetGlobalHotkey("session.toggledefaultformation", "Press", () => {
if (this.defaultFormation === NULL_FORMATION)
this.setDefault(this.lastDefault);
else
this.setDefault(NULL_FORMATION);
});
}
/**
@ -28,6 +36,8 @@ class AutoFormation
setDefault(formation)
{
this.defaultFormation = formation;
if (formation !== NULL_FORMATION)
this.lastDefault = this.defaultFormation;
Engine.ConfigDB_CreateValue("user", "gui.session.defaultformation", this.defaultFormation);
// TODO: It's extremely terrible that we have to explicitly flush the config...
Engine.ConfigDB_SetChanges("user", true);
@ -50,10 +60,11 @@ class AutoFormation
}
/**
* @return the null formation, or "undefined" if the null formation is the default.
* @return the null formation, or "undefined", depending on "walkOnly" preference.
*/
getNull()
{
return this.defaultFormation == NULL_FORMATION ? undefined : NULL_FORMATION;
let walkOnly = Engine.ConfigDB_GetValue("user", "gui.session.formationwalkonly") === "true";
return walkOnly ? NULL_FORMATION : undefined;
}
}

View File

@ -104,7 +104,7 @@ var g_UnitActions =
"z": target.z,
"targetClasses": targetClasses,
"queued": queued,
"formation": g_AutoFormation.getDefault()
"formation": g_AutoFormation.getNull()
});
DrawTargetMarker(target);
@ -149,7 +149,7 @@ var g_UnitActions =
"target": action.target,
"allowCapture": true,
"queued": queued,
"formation": g_AutoFormation.getDefault()
"formation": g_AutoFormation.getNull()
});
Engine.GuiInterfaceCall("PlaySound", {
@ -195,7 +195,7 @@ var g_UnitActions =
"target": action.target,
"queued": queued,
"allowCapture": false,
"formation": g_AutoFormation.getDefault()
"formation": g_AutoFormation.getNull()
});
Engine.GuiInterfaceCall("PlaySound", {
@ -758,7 +758,7 @@ var g_UnitActions =
"entities": selection,
"target": action.target,
"queued": queued,
"formation": g_AutoFormation.getDefault()
"formation": g_AutoFormation.getNull()
});
Engine.GuiInterfaceCall("PlaySound", {