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

Function PlrHitPlr

Source/player.cpp:2538–2629  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2536}
2537
2538BOOL PlrHitPlr(int pnum, char p)
2539{
2540 BOOL rv;
2541 int hit, hper, blk, blkper, dir, mind, maxd, dam, lvl, skdam, tac;
2542
2543 if ((DWORD)p >= MAX_PLRS) {
2544 app_fatal("PlrHitPlr: illegal target player %d", p);
2545 }
2546
2547 rv = FALSE;
2548
2549 if (plr[p]._pInvincible) {
2550 return rv;
2551 }
2552
2553 if (plr[p]._pSpellFlags & 1) {
2554 return rv;
2555 }
2556
2557 if ((DWORD)pnum >= MAX_PLRS) {
2558 app_fatal("PlrHitPlr: illegal attacking player %d", pnum);
2559 }
2560
2561 hit = random_(4, 100);
2562
2563 hper = (plr[pnum]._pDexterity >> 1) + plr[pnum]._pLevel + 50 - (plr[p]._pIBonusAC + plr[p]._pIAC + plr[p]._pDexterity / 5);
2564
2565 if (plr[pnum]._pClass == PC_WARRIOR) {
2566 hper += 20;
2567 }
2568 hper += plr[pnum]._pIBonusToHit;
2569 if (hper < 5) {
2570 hper = 5;
2571 }
2572 if (hper > 95) {
2573 hper = 95;
2574 }
2575
2576 if ((plr[p]._pmode == PM_STAND || plr[p]._pmode == PM_ATTACK) && plr[p]._pBlockFlag) {
2577 blk = random_(5, 100);
2578 } else {
2579 blk = 100;
2580 }
2581
2582 blkper = plr[p]._pDexterity + plr[p]._pBaseToBlk + (plr[p]._pLevel << 1) - (plr[pnum]._pLevel << 1);
2583 if (blkper < 0) {
2584 blkper = 0;
2585 }
2586 if (blkper > 100) {
2587 blkper = 100;
2588 }
2589
2590 if (hit < hper) {
2591 if (blk < blkper) {
2592 dir = GetDirection(plr[p].WorldX, plr[p].WorldY, plr[pnum].WorldX, plr[pnum].WorldY);
2593 StartPlrBlock(p, dir);
2594 } else {
2595 mind = plr[pnum]._pIMinDam;

Callers 1

PM_DoAttackFunction · 0.85

Calls 6

app_fatalFunction · 0.85
random_Function · 0.85
GetDirectionFunction · 0.85
StartPlrBlockFunction · 0.85
NetSendCmdDamageFunction · 0.85
StartPlrHitFunction · 0.85

Tested by

no test coverage detected