MCPcopy Create free account
hub / github.com/diasurgical/devilution / FindClosest

Function FindClosest

Source/missiles.cpp:218–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218int FindClosest(int sx, int sy, int rad)
219{
220 int j, i, mid, tx, ty, cr;
221 int CrawlNum[19] = { 0, 3, 12, 45, 94, 159, 240, 337, 450, 579, 724, 885, 1062, 1255, 1464, 1689, 1930, 2187, 2460 };
222
223 if (rad > 19)
224 rad = 19;
225
226 for (i = 1; i < rad; i++) {
227 cr = CrawlNum[i] + 2;
228 for (j = (BYTE)CrawlTable[CrawlNum[i]]; j > 0; j--) {
229 tx = sx + CrawlTable[cr - 1];
230 ty = sy + CrawlTable[cr];
231 if (tx > 0 && tx < MAXDUNX && ty > 0 && ty < MAXDUNY) {
232 mid = dMonster[tx][ty];
233 if (mid > 0 && !CheckBlock(sx, sy, tx, ty))
234 return mid - 1;
235 }
236 cr += 2;
237 }
238 }
239 return -1;
240}
241
242int GetSpellLevel(int id, int sn)
243{

Callers 2

MI_ElementFunction · 0.85
MI_BonespiritFunction · 0.85

Calls 1

CheckBlockFunction · 0.85

Tested by

no test coverage detected