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

Function determineCurse

plugins/cursecheck.cpp:77–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77curses determineCurse(df::unit * unit)
78{
79 curses cursetype = curses::None;
80
81 if (unit->curse_year != -1)
82 {
83 cursetype = curses::Unknown;
84 }
85
86 // ghosts: ghostly, duh
87 // as of DF 34.05 and higher vampire ghosts and the like should not be possible
88 // if they get reintroduced later it will become necessary to watch 'ghostly' seperately
89 if(unit->flags3.bits.ghostly)
90 cursetype = curses::Ghost;
91
92 // zombies: undead or hate life (according to ag), not bloodsuckers
93 if( (unit->uwss_add_caste_flag.bits.OPPOSED_TO_LIFE || unit->uwss_add_caste_flag.bits.NOT_LIVING)
94 && !unit->uwss_add_caste_flag.bits.BLOODSUCKER)
95 cursetype = curses::Zombie;
96
97 // necromancers: alive, don't eat, don't drink, don't age
98 if (!unit->uwss_add_caste_flag.bits.NOT_LIVING
99 && unit->uwss_add_caste_flag.bits.NO_EAT
100 && unit->uwss_add_caste_flag.bits.NO_DRINK
101 && unit->uwss_add_property.bits.NO_AGING
102 )
103 cursetype = curses::Necromancer;
104
105 // werecreatures: subjected to a were syndrome. The curse effects are active only when
106 // in were form.
107 for (auto active_syndrome : unit->syndromes.active) {
108 auto syndrome = df::syndrome::find(active_syndrome->type);
109 if (syndrome) {
110 for (auto classname : syndrome->syn_class)
111 if (classname && *classname == "WERECURSE") {
112 cursetype = curses::Werebeast;
113 break;
114 }
115 }
116 }
117
118 // vampires: bloodsucker (obvious enough)
119 if (unit->uwss_add_caste_flag.bits.BLOODSUCKER)
120 cursetype = curses::Vampire;
121
122 return cursetype;
123}
124
125command_result cursecheck(color_ostream& out, vector <string>& parameters)
126{

Callers 1

cursecheckFunction · 0.85

Calls 1

findFunction · 0.50

Tested by

no test coverage detected