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

Function df_strangemood

plugins/strangemood.cpp:149–1123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147}
148
149command_result df_strangemood (color_ostream &out, vector <string> & parameters)
150{
151 if (!Core::getInstance().isMapLoaded() || !World::isFortressMode()) {
152 out.printerr("Cannot enable {} without a loaded fort.\n", plugin_name);
153 return CR_FAILURE;
154 }
155
156 bool force = false;
157 df::unit *unit = NULL;
158 df::mood_type type = mood_type::None;
159 df::job_skill skill = job_skill::NONE;
160
161 for (size_t i = 0; i < parameters.size(); i++)
162 {
163 if(parameters[i] == "help" || parameters[i] == "?")
164 return CR_WRONG_USAGE;
165 else if(parameters[i] == "--force")
166 force = true;
167 else if(parameters[i] == "--id")
168 {
169 i++;
170 if (i == parameters.size())
171 {
172 out.printerr("No unit id specified!\n");
173 return CR_WRONG_USAGE;
174 }
175 unit = df::unit::find(std::stoi(parameters[i]));
176 if (!unit)
177 return CR_FAILURE;
178 }
179 else if(parameters[i] == "--unit")
180 {
181 unit = DFHack::Gui::getSelectedUnit(out);
182 if (!unit)
183 return CR_FAILURE;
184 }
185 else if (parameters[i] == "--type")
186 {
187 i++;
188 if (i == parameters.size())
189 {
190 out.printerr("No mood type specified!\n");
191 return CR_WRONG_USAGE;
192 }
193 if (parameters[i] == "fey")
194 type = mood_type::Fey;
195 else if (parameters[i] == "secretive")
196 type = mood_type::Secretive;
197 else if (parameters[i] == "possessed")
198 type = mood_type::Possessed;
199 else if (parameters[i] == "fell")
200 type = mood_type::Fell;
201 else if (parameters[i] == "macabre")
202 type = mood_type::Macabre;
203 else
204 {
205 out.printerr("Mood type '{}' not recognized!\n", parameters[i]);
206 return CR_WRONG_USAGE;

Callers

nothing calls this directly

Calls 11

getSelectedUnitFunction · 0.85
isUnitMoodableFunction · 0.85
getMoodSkillFunction · 0.85
getCreatedMetalBarsFunction · 0.85
is_setMethod · 0.80
c_strMethod · 0.80
getTypeMethod · 0.80
findFunction · 0.50
sizeMethod · 0.45
df_trandomMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected