MCPcopy Create free account
hub / github.com/DFHack/dfhack / df_forceequip

Function df_forceequip

plugins/forceequip.cpp:252–477  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

250
251
252command_result df_forceequip(color_ostream &out, vector <string> & parameters)
253{
254 // The "here" option is hardcoded to true, because the plugin currently doesn't support
255 // equip-at-a-distance (e.g. grab items within 10 squares of the targeted unit)
256 bool here = true;
257 (void)here;
258 // For balance (anti-cheating) reasons, the plugin applies a limit on the number of
259 // item that can be equipped on any bodypart. This limit defaults to 1 but can be
260 // overridden with cmdline switches.
261 int multiEquipLimit = 1;
262 // The plugin applies several pre-checks in order to reduce the risk of conflict
263 // and unintended side-effects. Most of these checks can be disabled via cmdline
264 bool ignore = false;
265 // By default, the plugin uses all gear piled on the selected square. Optionally,
266 // it can target only a single item (selected on the k menu) instead
267 bool selected = false;
268 // Most of the plugin's text output is suppressed by default. It can be enabled
269 // to provide insight into errors, and/or for debugging purposes.
270 bool verbose = false;
271 // By default, the plugin will mate each item to an appropriate bodypart. This
272 // behaviour can be skipped if the user specifies a particular BP in the cmdline input.
273 std::string targetBodyPartCode;
274
275 // Parse the input
276 for (size_t i = 0; i < parameters.size(); i++)
277 {
278 string & p = parameters[i];
279
280 if (p == "help" || p == "?" || p == "h" || p == "/?" || p == "info" || p == "man")
281 {
282 return CR_WRONG_USAGE;
283 }
284 else if (p == "here" || p == "h")
285 {
286 here = true;
287 }
288 else if (p == "ignore" || p == "i")
289 {
290 ignore = true;
291 }
292 else if (p == "multi" || p == "m")
293 {
294 multiEquipLimit = INT_MAX;
295 }
296 else if (p == "m2")
297 {
298 multiEquipLimit = 2;
299 }
300 else if (p == "m3")
301 {
302 multiEquipLimit = 3;
303 }
304 else if (p == "m4")
305 {
306 multiEquipLimit = 4;
307 }
308 else if (p == "selected" || p == "s")
309 {

Callers

nothing calls this directly

Calls 4

getSelectedItemFunction · 0.85
moveToInventoryFunction · 0.85
sizeMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected