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

Function CheckPlayerNearby

SourceX/controls/plrctrls.cpp:308–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306}
307
308void CheckPlayerNearby()
309{
310 int distance, newDdistance, rotations;
311
312 if (pcursmonst != -1)
313 return;
314
315 int spl = plr[myplr]._pRSpell;
316 if (FriendlyMode && spl != SPL_RESURRECT && spl != SPL_HEALOTHER)
317 return;
318
319 for (int i = 0; i < MAX_PLRS; i++) {
320 if (i == myplr)
321 continue;
322 const int mx = plr[i].WorldX;
323 const int my = plr[i].WorldY;
324 if (dPlayer[mx][my] == 0
325 || !(dFlags[mx][my] & BFLAG_LIT)
326 || (plr[i]._pHitPoints == 0 && spl != SPL_RESURRECT))
327 continue;
328
329 if (plr[myplr]._pwtype == WT_RANGED || HasRangedSpell() || spl == SPL_HEALOTHER) {
330 newDdistance = GetDistanceRanged(mx, my);
331 } else {
332 newDdistance = GetDistance(mx, my, distance);
333 if (newDdistance == 0)
334 continue;
335 }
336
337 if (pcursplr != -1 && distance < newDdistance)
338 continue;
339 const int newRotations = GetRotaryDistance(mx, my);
340 if (pcursplr != -1 && distance == newDdistance && rotations < newRotations)
341 continue;
342
343 distance = newDdistance;
344 rotations = newRotations;
345 pcursplr = i;
346 }
347}
348
349void FindActor()
350{

Callers 1

FindActorFunction · 0.85

Calls 4

HasRangedSpellFunction · 0.85
GetDistanceRangedFunction · 0.85
GetDistanceFunction · 0.85
GetRotaryDistanceFunction · 0.85

Tested by

no test coverage detected