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

Function PlayerMHit

Source/missiles.cpp:672–831  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

670}
671
672BOOL PlayerMHit(int pnum, int m, int dist, int mind, int maxd, int mtype, BOOLEAN shift, int earflag)
673{
674 int hit, hper, tac, dam, blk, blkper, resper;
675
676 if (plr[pnum]._pHitPoints >> 6 <= 0) {
677 return FALSE;
678 }
679
680 if (plr[pnum]._pInvincible) {
681 return FALSE;
682 }
683
684 if (plr[pnum]._pSpellFlags & 1 && !missiledata[mtype].mType) {
685 return FALSE;
686 }
687
688 hit = random_(72, 100);
689#ifdef _DEBUG
690 if (debug_mode_dollar_sign || debug_mode_key_inverted_v)
691 hit = 1000;
692#endif
693 if (!missiledata[mtype].mType) {
694 tac = plr[pnum]._pIAC + plr[pnum]._pIBonusAC + plr[pnum]._pDexterity / 5;
695 if (m != -1) {
696 hper = monster[m].mHit
697 + ((monster[m].mLevel - plr[pnum]._pLevel) * 2)
698 + 30
699 - (dist << 1) - tac;
700 } else {
701 hper = 100 - (tac >> 1) - (dist << 1);
702 }
703 } else {
704 if (m != -1) {
705 hper = +40 - (plr[pnum]._pLevel << 1) - (dist << 1) + (monster[m].mLevel << 1);
706 } else {
707 hper = 40;
708 }
709 }
710
711 if (hper < 10)
712 hper = 10;
713 if (currlevel == 14 && hper < 20) {
714 hper = 20;
715 }
716 if (currlevel == 15 && hper < 25) {
717 hper = 25;
718 }
719 if (currlevel == 16 && hper < 30) {
720 hper = 30;
721 }
722
723 if ((plr[pnum]._pmode == PM_STAND || plr[pnum]._pmode == PM_ATTACK) && plr[pnum]._pBlockFlag) {
724 blk = random_(73, 100);
725 } else {
726 blk = 100;
727 }
728
729 if (shift == TRUE)

Callers 2

BreakBarrelFunction · 0.85
CheckMissileColFunction · 0.85

Calls 6

random_Function · 0.85
SyncPlrKillFunction · 0.85
PlaySfxLocFunction · 0.85
GetDirectionFunction · 0.85
StartPlrBlockFunction · 0.85
StartPlrHitFunction · 0.85

Tested by

no test coverage detected