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

Function do_tele

plugins/fastdwarf.cpp:116–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114}
115
116static void do_tele(color_ostream &out, df::unit * unit) {
117 // skip dwarves that are dragging creatures or being dragged
118 if ((unit->relationship_ids[df::unit_relationship_type::Draggee] != -1) ||
119 (unit->relationship_ids[df::unit_relationship_type::Dragger] != -1))
120 return;
121
122 // skip dwarves that are following other units
123 if (unit->following != 0)
124 return;
125
126 // skip unconscious units
127 if (unit->counters.unconscious > 0)
128 return;
129
130 // don't do anything if the dwarf isn't going anywhere
131 if (!unit->pos.isValid() || !unit->path.dest.isValid() || unit->pos == unit->path.dest)
132 return;
133
134 // skip units with no current job so they can still meander and fulfill needs
135 if (!unit->job.current_job)
136 return;
137
138 // don't do anything if the destination is in a different pathability group or is unrevealed
139 if (!Maps::canWalkBetween(unit->pos, unit->path.dest))
140 return;
141 if (!Maps::isTileVisible(unit->path.dest))
142 return;
143
144 DEBUG(cycle,out).print("teleporting unit {}\n", unit->id);
145
146 if (!Units::teleport(unit, unit->path.dest))
147 return;
148
149 unit->path.path.clear();
150}
151
152DFhackCExport command_result plugin_onupdate(color_ostream &out) {
153 DEBUG(cycle,out).print("running {} cycle\n", plugin_name);

Callers 1

Calls 4

isTileVisibleFunction · 0.85
isValidMethod · 0.45
printMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected