Skip to content

Commit 7087acd

Browse files
committed
forceequip: docs and cleanup
update docs update remaining messaging to use debug logger
1 parent 383ffe2 commit 7087acd

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

docs/changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Template for new versions:
5252
# Future
5353

5454
## New Tools
55+
- `forceequip`: (reinstated) Forcibly move items into a unit's inventory
5556

5657
## New Features
5758
- `tweak`: ``realistic-melting``: change melting return for inorganic armor parts, shields, weapons, trap components and tools to stop smelters from creating metal, bring melt return for adamantine in line with other metals to ~95% of forging cost. wear reduces melt return by 10% per level

docs/plugins/forceequip.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ forceequip
33

44
.. dfhack-tool::
55
:summary: Move items into a unit's inventory.
6-
:tags: unavailable
6+
:tags: adventure fort animals items military units
77

88
This tool is typically used to equip specific clothing/armor items onto a dwarf,
99
but can also be used to put armor onto a war animal or to add unusual items

plugins/forceequip.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ command_result df_forceequip(color_ostream &out, vector <string> & parameters)
321321
// must be followed by bodypart code (e.g. NECK)
322322
if(i == parameters.size()-1 || parameters[i+1].size() == 0)
323323
{
324-
out.printerr("The bp switch must be followed by a bodypart code!\n");
324+
WARN(log).print("The bp switch must be followed by a bodypart code!\n");
325325
return CR_FAILURE;
326326
}
327327
targetBodyPartCode = parameters[i+1];
@@ -337,7 +337,7 @@ command_result df_forceequip(color_ostream &out, vector <string> & parameters)
337337
// Ensure that the map information is available (e.g. a game is actually in-progress)
338338
if (!Maps::IsValid())
339339
{
340-
out.printerr("Map is not available!\n");
340+
WARN(log).print("Map is not available!\n");
341341
return CR_FAILURE;
342342
}
343343

@@ -348,7 +348,7 @@ command_result df_forceequip(color_ostream &out, vector <string> & parameters)
348348
// needs a cursor
349349
if (!Gui::getCursorCoords(cx,cy,cz))
350350
{
351-
out.printerr("Cursor position not found. Please enable the cursor.\n");
351+
WARN(log).print("Cursor position not found. Please enable the cursor.\n");
352352
return CR_FAILURE;
353353
}
354354
pos_cursor = DFCoord(cx,cy,cz);
@@ -369,7 +369,7 @@ command_result df_forceequip(color_ostream &out, vector <string> & parameters)
369369

370370
if (!targetUnit)
371371
{
372-
out.printerr("No unit found at cursor!\n");
372+
WARN(log).print("No unit found at cursor!\n");
373373
return CR_FAILURE;
374374
}
375375

@@ -385,21 +385,21 @@ command_result df_forceequip(color_ostream &out, vector <string> & parameters)
385385
if (targetBodyPart->token.compare(targetBodyPartCode) == 0)
386386
{
387387
// It is indeed a match; exit the loop (while leaving the variable populated)
388-
if (verbose) { out.print("Matching bodypart (%s) found.\n", targetBodyPart->token.c_str()); }
388+
if (verbose) { INFO(log).print("Matching bodypart (%s) found.\n", targetBodyPart->token.c_str()); }
389389
break;
390390
}
391391
else
392392
{
393393
// Not a match; nullify the variable (it will get re-populated on the next pass through the loop)
394-
if (verbose) { out.printerr("Bodypart \"%s\" does not match \"%s\".\n", targetBodyPart->token.c_str(), targetBodyPartCode.c_str()); }
394+
if (verbose) { WARN(log).print("Bodypart \"%s\" does not match \"%s\".\n", targetBodyPart->token.c_str(), targetBodyPartCode.c_str()); }
395395
targetBodyPart = NULL;
396396
}
397397
}
398398

399399
if (!targetBodyPart)
400400
{
401401
// Loop iteration is complete but no match was found.
402-
out.printerr("The unit does not possess a bodypart of type \"%s\". Please check the spelling or choose a different unit.\n", targetBodyPartCode.c_str());
402+
WARN(log).print("The unit does not possess a bodypart of type \"%s\". Please check the spelling or choose a different unit.\n", targetBodyPartCode.c_str());
403403
return CR_FAILURE;
404404
}
405405
}
@@ -437,7 +437,7 @@ command_result df_forceequip(color_ostream &out, vector <string> & parameters)
437437
else if (currentItem->flags.bits.forbid == 1)
438438
{
439439
// The item is forbidden; skip it
440-
if (verbose) { out.printerr("Forbidden item encountered; skipping to next item.\n"); }
440+
if (verbose) { WARN(log).print("Forbidden item encountered; skipping to next item.\n"); }
441441
}
442442

443443
}
@@ -446,7 +446,7 @@ command_result df_forceequip(color_ostream &out, vector <string> & parameters)
446446
if (currentItem->flags.bits.in_inventory == 1)
447447
{
448448
// The item is in a unit's inventory; skip it
449-
if (verbose) { out.printerr("Inventory item encountered; skipping to next item.\n"); }
449+
if (verbose) { WARN(log).print("Inventory item encountered; skipping to next item.\n"); }
450450
}
451451
else
452452
{
@@ -455,21 +455,21 @@ command_result df_forceequip(color_ostream &out, vector <string> & parameters)
455455
{
456456
// // TODO TEMP EXPERIMENTAL - try to alter the item size in order to conform to its wearer
457457
// currentItem->getRace();
458-
// out.print("Critter size: %d| %d | Armor size: %d", world->raws.creatures.all[targetUnit->race]->caste[targetUnit->caste]->body_size_1, world->raws.creatures.all[targetUnit->race]->caste[targetUnit->caste]->body_size_2, currentItem->getTotalDimension());
458+
// INFO(log).print("Critter size: %d| %d | Armor size: %d", world->raws.creatures.all[targetUnit->race]->caste[targetUnit->caste]->body_size_1, world->raws.creatures.all[targetUnit->race]->caste[targetUnit->caste]->body_size_2, currentItem->getTotalDimension());
459459

460460
itemsEquipped++; // Track the number of items successfully processed (for feedback purposes)
461461
}
462462
}
463463
}
464464

465465
if (itemsFound == 0) {
466-
out.printerr("No usable items found at the cursor position. Please choose a different location and try again.\n");
466+
WARN(log).print("No usable items found at the cursor position. Please choose a different location and try again.\n");
467467
return CR_OK;
468468
}
469469

470470

471-
if (itemsEquipped == 0 && !verbose) { out.printerr("Some items were found but no equipment changes could be made. Use the /verbose switch to display the reasons for failure.\n"); }
472-
if (itemsEquipped > 0) { out.print("%d items equipped.\n", itemsEquipped); }
471+
if (itemsEquipped == 0 && !verbose) { WARN(log).print("Some items were found but no equipment changes could be made. Use the /verbose switch to display the reasons for failure.\n"); }
472+
if (itemsEquipped > 0) { INFO(log).print("%d items equipped.\n", itemsEquipped); }
473473

474474
// Note: we might expect to recalculate the unit's weight at this point, in order to account for the
475475
// added items. In fact, this recalculation occurs automatically during each dwarf's "turn".

0 commit comments

Comments
 (0)