dfhack/tools/playground/skillmodify.cpp

758 lines
25 KiB
C++

2011-04-11 04:41:12 -06:00
/*********************************************
* skillmodify.cpp
2011-04-11 04:41:12 -06:00
*
* Purpose:
*
* - Display creatures
* - Modify skills and labors of creatures
*
* Version: 0.1.1
2011-04-11 04:41:12 -06:00
* Date: 2011-04-07
2011-04-11 04:41:12 -06:00
* Todo:
* - Option to add/remove single skills
* - Ghosts/Merchants/etc. should be tagged as not own creatures
2011-04-11 04:41:12 -06:00
* - Filter by nickname with -n
* - Filter by first name with -fn
* - Filter by last name with -ln
* - Add pattern matching (or at least matching) to -n/-fn/-ln
* - Set nickname with --setnick (only if -i is given)
2011-04-11 04:41:12 -06:00
* - Kill/revive creature(s) with --kill/--revive
* - Show skills/labors only when -ss/-sl/-v is given or a skill/labor is changed
* - Allow multiple -i switches
* - Hide skills with level 0 and 0 experience points
2011-04-11 04:41:12 -06:00
* Done:
2011-04-12 17:47:15 -06:00
* - Add switch -1 to only display one line for every creature. Good for an overview.
* - Display current job (has been there all the time, but not shown in Windows due to missing memory offsets)
* - Remove magic numbers
* - Show social skills only when -ss is given
* - Hide hauler labors when +sh is given
* - Add -v for verbose
* - Override forbidden mass-designation with -f
2011-04-11 04:41:12 -06:00
* - Option to add/remove single labors
* - Switches -ras and rl should only be possible with -nn or -i
* - Switch -rh removes hauler jobs
* - Dead creatures should not be displayed
* - Childs should not get labors assigned to
* - Babies should not get labors assigned to
* - Switch -al <n> adds labor number n
* - Switch -rl <n> removes labor number n
* - Switch -ral removes all labors
* - Switch -ll lists all available labors
*********************************************
*/
#include <iostream>
#include <climits>
#include <string.h>
#include <vector>
#include <stdio.h>
using namespace std;
#define DFHACK_WANT_MISCUTILS
#include <DFHack.h>
#include <dfhack/modules/Creatures.h>
/* Note about magic numbers:
* If you have an idea how to better solve this, tell me. Currently I'd be
* either dependent on Toady One's implementation (#defining numbers) or
* Memory.xml (#defining text). I voted for Toady One's numbers to be more
* stable, but could be wrong.
*/
#define SKILL_PERSUASION 72
#define SKILL_NEGOTIATION 73
#define SKILL_JUDGING_INTENT 74
#define SKILL_INTIMIDATION 79
#define SKILL_CONVERSATION 80
#define SKILL_COMEDY 81
#define SKILL_FLATTERY 82
#define SKILL_CONSOLING 83
#define SKILL_PACIFICATION 84
#define LABOR_STONE_HAULING 1
#define LABOR_WOOD_HAULING 2
#define LABOR_BURIAL 3
#define LABOR_FOOD_HAULING 4
#define LABOR_REFUSE_HAULING 5
#define LABOR_ITEM_HAULING 6
#define LABOR_FURNITURE_HAULING 7
#define LABOR_ANIMAL_HAULING 8
#define LABOR_CLEANING 9
#define LABOR_FEED_PATIENTS_PRISONERS 22
#define LABOR_RECOVERING_WOUNDED 23
#define NOT_SET INT_MIN
#define MAX_MOOD 4
#define NO_MOOD -1
2011-04-12 17:47:15 -06:00
bool quiet=true;
bool verbose = false;
bool showhauler = true;
bool showsocial = false;
2011-04-12 17:47:15 -06:00
bool showfirstlineonly = false;
int hauler_labors[] = {
LABOR_STONE_HAULING
,LABOR_WOOD_HAULING
,LABOR_BURIAL
,LABOR_FOOD_HAULING
,LABOR_REFUSE_HAULING
,LABOR_ITEM_HAULING
,LABOR_FURNITURE_HAULING
,LABOR_ANIMAL_HAULING
,LABOR_CLEANING
,LABOR_FEED_PATIENTS_PRISONERS
,LABOR_RECOVERING_WOUNDED
};
int social_skills[] =
{
SKILL_PERSUASION
,SKILL_NEGOTIATION
,SKILL_JUDGING_INTENT
,SKILL_INTIMIDATION
,SKILL_CONVERSATION
,SKILL_COMEDY
,SKILL_FLATTERY
,SKILL_CONSOLING
,SKILL_PACIFICATION
};
2011-04-11 04:41:12 -06:00
void usage(int argc, const char * argv[])
{
cout
2011-04-11 05:15:51 -06:00
<< "Usage:" << endl
<< argv[0] << " [option 1] [option 2] [...]" << endl
<< "-q : Suppress \"Press any key to continue\" at program termination" << endl
<< "-v : Increase verbosity" << endl
2011-04-11 05:15:51 -06:00
<< "-c creature : Only show/modify this creature type instead of dwarfes" << endl
<< "-1 : Only display one line per creature" << endl
2011-04-11 05:15:51 -06:00
<< "-i id : Only show/modify creature with this id" << endl
<< "-nn : Only show/modify creatures with no custom nickname (migrants)" << endl
<< "--nicks : Only show/modify creatures with custom nickname" << endl
2011-04-11 05:15:51 -06:00
<< "-ll : List available labors" << endl
<< "-al <n> : Add labor <n> to creature" << endl
<< "-rl <n> : Remove labor <n> from creature" << endl
<< "-ras : Remove all skills from creature" << endl
<< "-ral : Remove all labors from creature" << endl
<< "-ah : Add hauler labors (stone hauling, etc.) to creature" << endl
<< "-rh : Remove hauler labors (stone hauling, etc.) from creature" << endl
2011-04-12 17:47:15 -06:00
<< "--setmood <n> : Set mood to n (-1 = no mood, max=4, buggy!)" << endl
2011-04-11 05:15:51 -06:00
// Doesn't work, because hapiness is recalculated
//<< "--sethappiness <n> : Set happiness to n" << endl
<< "-f : Force an action" << endl
<< endl
<< "Example 1: Show all dwarfs" << endl
<< argv[0] << " -c Dwarf" << endl
2011-04-11 05:15:51 -06:00
<< endl
<< "Example 2: Show all Yaks" << endl
<< argv[0] << " -c Yak" << endl
2011-04-11 05:15:51 -06:00
<< endl
<< "Example 3: Remove all skills from dwarf with id 32" << endl
2011-04-11 05:15:51 -06:00
<< argv[0] << " -i 32 -ras" << endl
<< endl
<< "Example 4: Remove all skills and labors from dwarfs with no custom nickname" << endl
<< argv[0] << " -c DWARF -nn -ras -ral" << endl
<< endl
<< "Example 5: Add hauling labors to all migrants" << endl
<< argv[0] << " -c DWARF -nn -ah" << endl
<< endl
<< "Example 6: Show list of labor ids" << endl
<< argv[0] << " -c DWARF -ll" << endl
<< endl
<< "Example 7: Add engraving labor to all migrants (get the id from the list of labor ids)" << endl
<< argv[0] << " -c DWARF -nn -al 13" << endl
2011-04-11 05:15:51 -06:00
;
2011-04-12 05:51:20 -06:00
if (quiet == false) {
cout << "Press any key to continue" << endl;
cin.ignore();
}
2011-04-11 04:41:12 -06:00
}
DFHack::Materials * Materials;
DFHack::VersionInfo *mem;
DFHack::Creatures * Creatures = NULL;
// Note that toCaps() changes the string itself and I'm using it a few times in
// an unsafe way below. Didn't crash yet however.
std::string toCaps(std::string s)
{
const int length = s.length();
if (length == 0) {
2011-04-11 05:15:51 -06:00
return s;
2011-04-11 04:41:12 -06:00
}
s[0] = std::toupper(s[0]);
for(int i=1; i!=length ; ++i)
{
2011-04-11 05:15:51 -06:00
s[i] = std::tolower(s[i]);
2011-04-11 04:41:12 -06:00
}
return s;
}
int strtoint(const string &str)
{
stringstream ss(str);
int result;
return ss >> result ? result : -1;
}
// A C++ standard library function should be used instead
bool is_in(int m, int set[], int set_size)
{
for (int i=0; i<set_size; i++)
{
if (m == set[i])
return true;
}
return false;
}
2011-04-11 04:41:12 -06:00
void printCreature(DFHack::Context * DF, const DFHack::t_creature & creature, int index)
{
2011-04-12 17:47:15 -06:00
2011-04-11 04:41:12 -06:00
DFHack::Translation *Tran = DF->getTranslation();
DFHack::VersionInfo *mem = DF->getMemoryInfo();
2011-04-12 17:47:15 -06:00
string name="(no name)";
2011-04-11 04:41:12 -06:00
if(creature.name.nickname[0])
{
2011-04-12 17:47:15 -06:00
name = creature.name.nickname;
2011-04-11 04:41:12 -06:00
}
else
{
2011-04-11 05:15:51 -06:00
if(creature.name.first_name[0])
{
name = toCaps(creature.name.first_name);
string transName = Tran->TranslateName(creature.name,false);
if(!transName.empty())
{
name += " " + toCaps(transName);
}
}
2011-04-11 04:41:12 -06:00
}
2011-04-12 17:47:15 -06:00
string profession="";
2011-04-11 04:41:12 -06:00
try {
2011-04-12 17:47:15 -06:00
profession = mem->getProfession(creature.profession);
2011-04-11 04:41:12 -06:00
}
catch (exception& e)
{
2011-04-11 05:15:51 -06:00
cout << "Error retrieving creature profession: " << e.what() << endl;
2011-04-11 04:41:12 -06:00
}
if(creature.custom_profession[0])
{
profession = creature.custom_profession;
2011-04-11 04:41:12 -06:00
}
2011-04-12 17:47:15 -06:00
string job="No Job";
2011-04-11 04:41:12 -06:00
if(creature.current_job.active)
{
job=mem->getJob(creature.current_job.jobId);
2011-04-11 04:41:12 -06:00
}
2011-04-12 17:47:15 -06:00
if (showfirstlineonly)
{
printf("%3d", index);
printf(" %-32s", name.c_str());
printf(" %-15s", toCaps(profession).c_str());
printf(" %-30s", job.c_str());
printf(" %d", creature.happiness);
2011-04-12 17:47:15 -06:00
return;
2011-04-12 17:47:15 -06:00
}
else
{
printf("ID: %d", index);
printf(", %s", name.c_str());
printf(", %s", toCaps(profession).c_str());
printf(", Job: %s", job.c_str());
printf(", Happiness: %d", creature.happiness);
printf("\n");
2011-04-12 17:47:15 -06:00
}
2011-04-11 04:41:12 -06:00
if((creature.mood != NO_MOOD) && (creature.mood<=MAX_MOOD))
2011-04-11 04:41:12 -06:00
{
2011-04-11 05:15:51 -06:00
cout << "Creature is in a strange mood (mood=" << creature.mood << "), skill: " << mem->getSkill(creature.mood_skill) << endl;
vector<DFHack::t_material> mymat;
if(Creatures->ReadJob(&creature, mymat))
{
for(unsigned int i = 0; i < mymat.size(); i++)
{
printf("\t%s(%d)\t%d %d %d - %.8x\n", Materials->getDescription(mymat[i]).c_str(), mymat[i].itemType, mymat[i].subType, mymat[i].subIndex, mymat[i].index, mymat[i].flags);
}
}
2011-04-11 04:41:12 -06:00
}
if(creature.has_default_soul)
{
2011-04-11 05:15:51 -06:00
// Print out skills
int skillid;
int skillrating;
int skillexperience;
string skillname;
cout << setiosflags(ios::left);
for(unsigned int i = 0; i < creature.defaultSoul.numSkills;i++)
{
skillid = creature.defaultSoul.skills[i].id;
bool is_social = is_in(skillid, social_skills, sizeof(social_skills)/sizeof(social_skills[0]));
if (!is_social || (is_social && showsocial))
2011-04-11 05:15:51 -06:00
{
skillrating = creature.defaultSoul.skills[i].rating;
skillexperience = creature.defaultSoul.skills[i].experience;
try
{
skillname = mem->getSkill(skillid);
}
catch(DFHack::Error::AllMemdef &e)
{
skillname = "Unknown skill";
cout << e.what() << endl;
}
if (skillrating > 0 || skillexperience > 0)
{
cout << "(Skill " << int(skillid) << ") " << setw(16) << skillname << ": "
<< skillrating << "/" << skillexperience << endl;
}
2011-04-11 05:15:51 -06:00
}
}
for(unsigned int i = 0; i < NUM_CREATURE_LABORS;i++)
{
if(!creature.labors[i])
continue;
string laborname;
try
{
laborname = mem->getLabor(i);
}
catch(exception &e)
{
laborname = "(Undefined)";
}
bool is_labor = is_in(i, hauler_labors, sizeof(hauler_labors)/sizeof(hauler_labors[0]));
if (!is_labor || (is_labor && showhauler))
cout << "(Labor " << i << ") " << setw(16) << laborname << endl;
2011-04-11 05:15:51 -06:00
}
2011-04-11 04:41:12 -06:00
}
/* FLAGS 1 */
2011-04-11 05:15:51 -06:00
if(creature.flags1.bits.dead) { cout << "Flag: Dead" << endl; }
if(creature.flags1.bits.on_ground) { cout << "Flag: On the ground" << endl; }
if(creature.flags1.bits.skeleton) { cout << "Flag: Skeletal" << endl; }
if(creature.flags1.bits.zombie) { cout << "Flag: Zombie" << endl; }
if(creature.flags1.bits.tame) { cout << "Flag: Tame" << endl; }
2011-04-11 04:41:12 -06:00
if(creature.flags1.bits.royal_guard){ cout << "Flag: Royal_guard" << endl; }
if(creature.flags1.bits.fortress_guard){cout<<"Flag: Fortress_guard" << endl; }
/* FLAGS 2 */
2011-04-11 05:15:51 -06:00
if(creature.flags2.bits.killed) { cout << "Flag: Killed by kill function" << endl; }
if(creature.flags2.bits.resident) { cout << "Flag: Resident" << endl; }
if(creature.flags2.bits.gutted) { cout << "Flag: Gutted" << endl; }
if(creature.flags2.bits.slaughter) { cout << "Flag: Marked for slaughter" << endl; }
2011-04-11 04:41:12 -06:00
if(creature.flags2.bits.underworld) { cout << "Flag: From the underworld" << endl; }
if(creature.flags1.bits.had_mood && (creature.mood == -1 || creature.mood == 8 ) )
{
2011-04-11 05:15:51 -06:00
string artifact_name = Tran->TranslateName(creature.artifact_name,false);
cout << "Artifact: " << artifact_name << endl;
2011-04-11 04:41:12 -06:00
}
}
int main (int argc, const char* argv[])
{
// let's be more useful when double-clicked on windows
2011-04-11 05:15:51 -06:00
#ifndef LINUX_BUILD
2011-04-11 04:41:12 -06:00
quiet = false;
2011-04-11 05:15:51 -06:00
#endif
2011-04-11 04:41:12 -06:00
string creature_type = "Dwarf";
string creature_id = "";
int creature_id_int = 0;
bool find_nonicks = false;
bool find_nicks = false;
bool remove_skills = false;
bool remove_labors = false;
bool make_hauler = false;
bool remove_hauler = false;
bool add_labor = false;
int add_labor_n = NOT_SET;
2011-04-11 04:41:12 -06:00
bool remove_labor = false;
int remove_labor_n = NOT_SET;
2011-04-11 04:41:12 -06:00
bool set_happiness = false;
int set_happiness_n = NOT_SET;
2011-04-11 04:41:12 -06:00
bool set_mood = false;
int set_mood_n = NOT_SET;
2011-04-11 04:41:12 -06:00
bool list_labors = false;
bool force_massdesignation = false;
if (argc == 1) {
2011-04-11 05:15:51 -06:00
usage(argc, argv);
return 1;
2011-04-11 04:41:12 -06:00
}
for(int i = 1; i < argc; i++)
{
string arg_cur = argv[i];
string arg_next = "";
int arg_next_int = NOT_SET;
2011-04-11 05:15:51 -06:00
/* Check if argv[i+1] is a number >= 0 */
if (i < argc-1) {
arg_next = argv[i+1];
arg_next_int = strtoint(arg_next);
if (arg_next != "0" && arg_next_int == 0) {
arg_next_int = NOT_SET;
2011-04-11 05:15:51 -06:00
}
}
2011-04-11 04:41:12 -06:00
if(arg_cur == "-q")
{
quiet = true;
}
else if(arg_cur == "+q")
{
quiet = false;
}
else if(arg_cur == "-v")
{
verbose = true;
}
2011-04-12 17:47:15 -06:00
else if(arg_cur == "-1")
{
showfirstlineonly = true;
}
else if(arg_cur == "-ss" || arg_cur == "--showsocial")
{
showsocial = true;
}
else if(arg_cur == "+sh" || arg_cur == "-nosh" || arg_cur == "--noshowhauler")
{
showhauler = false;
}
2011-04-11 05:15:51 -06:00
else if(arg_cur == "-ras")
{
remove_skills = true;
}
else if(arg_cur == "-f")
{
force_massdesignation = true;
}
// list labors
else if(arg_cur == "-ll")
{
list_labors = true;
}
// add single labor
else if(arg_cur == "-al" && i < argc-1)
{
if (arg_next_int == NOT_SET || arg_next_int >= NUM_CREATURE_LABORS) {
2011-04-11 05:15:51 -06:00
usage(argc, argv);
return 1;
}
add_labor = true;
add_labor_n = arg_next_int;
i++;
}
// remove single labor
else if(arg_cur == "-rl" && i < argc-1)
{
if (arg_next_int == NOT_SET || arg_next_int >= NUM_CREATURE_LABORS) {
2011-04-11 05:15:51 -06:00
usage(argc, argv);
return 1;
}
remove_labor = true;
remove_labor_n = arg_next_int;
i++;
}
else if(arg_cur == "--setmood" && i < argc-1)
{
if (arg_next_int < NO_MOOD || arg_next_int > MAX_MOOD) {
2011-04-11 05:15:51 -06:00
usage(argc, argv);
return 1;
}
set_mood = true;
set_mood_n = arg_next_int;
i++;
}
else if(arg_cur == "--sethappiness" && i < argc-1)
{
if (arg_next_int < 1 || arg_next_int >= 2000) {
usage(argc, argv);
return 1;
}
set_happiness = true;
set_happiness_n = arg_next_int;
i++;
}
else if(arg_cur == "-ral")
{
remove_labors = true;
}
else if(arg_cur == "-ah")
{
make_hauler = true;
}
else if(arg_cur == "-rh")
{
remove_hauler = true;
}
else if(arg_cur == "-nn")
{
find_nonicks = true;
}
else if(arg_cur == "--nicks")
{
find_nicks = true;
}
else if(arg_cur == "-c" && i < argc-1)
{
creature_type = argv[i+1];
i++;
}
else if(arg_cur == "-i" && i < argc-1)
{
creature_id = argv[i+1];
sscanf(argv[i+1], "%d", &creature_id_int);
i++;
}
else
{
if (arg_cur != "-h") {
cout << "Unknown option '" << arg_cur << "'" << endl;
cout << endl;
}
usage(argc, argv);
return 1;
}
2011-04-11 04:41:12 -06:00
}
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context* DF;
try
{
DF = DFMgr.getSingleContext();
DF->Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
2011-04-11 05:15:51 -06:00
if (quiet == false)
{
2011-04-11 04:41:12 -06:00
cin.ignore();
2011-04-11 05:15:51 -06:00
}
2011-04-11 04:41:12 -06:00
return 1;
}
2011-04-11 05:15:51 -06:00
2011-04-11 04:41:12 -06:00
Creatures = DF->getCreatures();
Materials = DF->getMaterials();
DFHack::Translation * Tran = DF->getTranslation();
2011-04-11 05:15:51 -06:00
2011-04-11 04:41:12 -06:00
uint32_t numCreatures;
if(!Creatures->Start(numCreatures))
{
cerr << "Can't get creatures" << endl;
2011-04-11 05:15:51 -06:00
if (quiet == false)
{
2011-04-11 04:41:12 -06:00
cin.ignore();
2011-04-11 05:15:51 -06:00
}
2011-04-11 04:41:12 -06:00
return 1;
}
if(!numCreatures)
{
cerr << "No creatures to print" << endl;
2011-04-11 05:15:51 -06:00
if (quiet == false)
{
2011-04-11 04:41:12 -06:00
cin.ignore();
2011-04-11 05:15:51 -06:00
}
2011-04-11 04:41:12 -06:00
return 1;
}
mem = DF->getMemoryInfo();
Materials->ReadInorganicMaterials();
Materials->ReadOrganicMaterials();
Materials->ReadWoodMaterials();
Materials->ReadPlantMaterials();
Materials->ReadCreatureTypes();
Materials->ReadCreatureTypesEx();
Materials->ReadDescriptorColors();
if(!Tran->Start())
{
cerr << "Can't get name tables" << endl;
return 1;
}
// List all available labors (reproduces contents of Memory.xml)
if (list_labors == true) {
2011-04-11 05:15:51 -06:00
string laborname;
for (int i=0; i < NUM_CREATURE_LABORS; i++) {
try {
laborname = mem->getLabor(i);
cout << "Labor " << int(i) << ": " << laborname << endl;
2011-04-11 05:15:51 -06:00
}
catch (exception& e) {
if (verbose)
{
laborname = "Unknown";
cout << "Labor " << int(i) << ": " << laborname << endl;
}
2011-04-11 05:15:51 -06:00
}
}
2011-04-11 04:41:12 -06:00
}
else
{
if (showfirstlineonly)
{
printf("ID Name/nickname Job title Current job Happiness\n");
printf("--- -------------------------------- --------------- ------------------------------ ---------\n");
}
2011-04-12 17:47:15 -06:00
2011-04-11 05:15:51 -06:00
vector<uint32_t> addrs;
for(uint32_t creature_idx = 0; creature_idx < numCreatures; creature_idx++)
{
DFHack::t_creature creature;
Creatures->ReadCreature(creature_idx,creature);
/* Check if we want to display/change this creature or skip it */
bool hasnick = (creature.name.nickname[0] != '\0');
if (
// Check for -i <num>
(creature_id.empty() || creature_idx == creature_id_int)
// Check for -c <type>
&& (creature_type.empty() || toCaps(string(Materials->raceEx[creature.race].rawname)) == toCaps(creature_type))
// Check for -nn
&& ((find_nonicks == true && hasnick == false)
|| (find_nicks == true && hasnick == true)
|| (find_nicks == false && find_nonicks == false))
&& (find_nonicks == false || creature.name.nickname[0] == '\0')
&& (!creature.flags1.bits.dead)
)
{
printCreature(DF,creature,creature_idx);
addrs.push_back(creature.origin);
bool dochange = (
remove_skills
|| remove_labors || add_labor || remove_labor
|| make_hauler || remove_hauler
|| set_happiness
|| set_mood
);
// 96=Child, 97=Baby
if (creature.profession == 96 || creature.profession == 97)
{
dochange = false;
}
bool allow_massdesignation =
!creature_id.empty() || toCaps(creature_type) != "Dwarf" || find_nonicks == true || force_massdesignation;
if (dochange == true && allow_massdesignation == false)
{
cout
<< "Not changing creature because none of -c (other than dwarf), -i or -nn was" << endl
<< "selected. Add -f to still do mass designation." << endl;
dochange = false;
}
if (dochange)
{
if(creature.has_default_soul)
{
if (set_mood)
{
cout << "Setting mood to " << set_mood_n << "..." << endl;
Creatures->WriteMood(creature_idx, set_mood_n);
}
if (set_happiness)
{
cout << "Setting happiness to " << set_happiness_n << "..." << endl;
Creatures->WriteHappiness(creature_idx, set_happiness_n);
}
if (remove_skills)
{
DFHack::t_soul & soul = creature.defaultSoul;
cout << "Removing skills..." << endl;
for(unsigned int sk = 0; sk < soul.numSkills;sk++)
{
soul.skills[sk].rating=0;
soul.skills[sk].experience=0;
}
// Doesn't work anyways, so better leave it alone
//soul.numSkills=0;
if (Creatures->WriteSkills(creature_idx, soul) == true) {
cout << "Success writing skills." << endl;
} else {
cout << "Error writing skills." << endl;
}
}
if (add_labor || remove_labor || remove_labors || make_hauler || remove_hauler)
2011-04-11 05:15:51 -06:00
{
if (add_labor) {
cout << "Adding labor " << add_labor_n << "..." << endl;
creature.labors[add_labor_n] = 1;
}
if (remove_labor) {
cout << "Removing labor " << remove_labor_n << "..." << endl;
creature.labors[remove_labor_n] = 0;
}
if (remove_labors) {
cout << "Removing labors..." << endl;
for(unsigned int lab = 0; lab < NUM_CREATURE_LABORS; lab++) {
2011-04-12 05:51:20 -06:00
creature.labors[lab] = 0;
2011-04-11 05:15:51 -06:00
}
}
2011-04-11 05:15:51 -06:00
if (remove_hauler) {
for (int labs=0;
labs < sizeof(hauler_labors)/sizeof(hauler_labors[0]);
labs++)
{
2011-04-12 05:51:20 -06:00
creature.labors[hauler_labors[labs]] = 0;
}
2011-04-11 05:15:51 -06:00
}
2011-04-11 05:15:51 -06:00
if (make_hauler) {
cout << "Setting hauler labors..." << endl;
for (int labs=0;
labs < sizeof(hauler_labors)/sizeof(hauler_labors[0]);
labs++)
{
2011-04-12 05:51:20 -06:00
creature.labors[hauler_labors[labs]] = 1;
}
2011-04-11 05:15:51 -06:00
}
if (Creatures->WriteLabors(creature_idx, creature.labors) == true) {
cout << "Success writing labors." << endl;
} else {
cout << "Error writing labors." << endl;
}
}
}
else
{
cout << "Error removing skills: Creature has no default soul." << endl;
}
printCreature(DF,creature,creature_idx);
} /* End remove skills/labors */
cout << endl;
} /* if (print creature) */
} /* End for(all creatures) */
2011-04-11 04:41:12 -06:00
} /* End if (we need to walk creatures) */
Creatures->Finish();
DF->Detach();
if (quiet == false)
{
2011-04-11 05:15:51 -06:00
cout << "Done. Press any key to continue" << endl;
cin.ignore();
2011-04-11 04:41:12 -06:00
}
return 0;
}