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

Function AddObjTraps

Source/objects.cpp:465–518  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

463}
464
465void AddObjTraps()
466{
467 char oi_trap, oi;
468 int i, j;
469 int xp, yp;
470 int rndv;
471
472 if (currlevel == 1)
473 rndv = 10;
474 if (currlevel >= 2)
475 rndv = 15;
476 if (currlevel >= 5)
477 rndv = 20;
478 if (currlevel >= 7)
479 rndv = 25;
480 for (j = 0; j < MAXDUNY; j++) {
481 for (i = 0; i < MAXDUNX; i++) {
482 if (dObject[i][j] <= 0 || random_(144, 100) >= rndv)
483 continue;
484
485 oi = dObject[i][j] - 1;
486 if (!AllObjects[object[oi]._otype].oTrapFlag)
487 continue;
488
489 if (random_(144, 2) == 0) {
490 xp = i - 1;
491 while (!nSolidTable[dPiece[xp][j]])
492 xp--;
493
494 if (!TorchLocOK(xp, j) || i - xp <= 1)
495 continue;
496
497 AddObject(OBJ_TRAPL, xp, j);
498 oi_trap = dObject[xp][j] - 1;
499 object[oi_trap]._oVar1 = i;
500 object[oi_trap]._oVar2 = j;
501 object[oi]._oTrapFlag = TRUE;
502 } else {
503 yp = j - 1;
504 while (!nSolidTable[dPiece[i][yp]])
505 yp--;
506
507 if (!TorchLocOK(i, yp) || j - yp <= 1)
508 continue;
509
510 AddObject(OBJ_TRAPR, i, yp);
511 oi_trap = dObject[i][yp] - 1;
512 object[oi_trap]._oVar1 = i;
513 object[oi_trap]._oVar2 = j;
514 object[oi]._oTrapFlag = TRUE;
515 }
516 }
517 }
518}
519
520void AddChestTraps()
521{

Callers 1

InitObjectsFunction · 0.85

Calls 3

random_Function · 0.85
TorchLocOKFunction · 0.85
AddObjectFunction · 0.85

Tested by

no test coverage detected