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

Function Plr2PlrMHit

Source/missiles.cpp:833–944  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

831}
832
833BOOL Plr2PlrMHit(int pnum, int p, int mindam, int maxdam, int dist, int mtype, BOOLEAN shift)
834{
835 int tac, resper, dam, blk, blkper, hper, hit;
836
837 if (plr[p]._pInvincible) {
838 return FALSE;
839 }
840
841 if (mtype == MIS_HBOLT) {
842 return FALSE;
843 }
844
845 if (plr[p]._pSpellFlags & 1 && !missiledata[mtype].mType) {
846 return FALSE;
847 }
848
849 switch (missiledata[mtype].mResist) {
850 case MISR_FIRE:
851 resper = plr[p]._pFireResist;
852 break;
853 case MISR_LIGHTNING:
854 resper = plr[p]._pLghtResist;
855 break;
856 case MISR_MAGIC:
857 case MISR_ACID:
858 resper = plr[p]._pMagResist;
859 break;
860 default:
861 resper = 0;
862 break;
863 }
864 hper = random_(69, 100);
865 if (!missiledata[mtype].mType) {
866 hit = plr[pnum]._pIBonusToHit
867 + plr[pnum]._pLevel
868 - (dist * dist >> 1)
869 - plr[p]._pDexterity / 5
870 - plr[p]._pIBonusAC
871 - plr[p]._pIAC
872 + plr[pnum]._pDexterity + 50;
873 if (plr[pnum]._pClass == PC_ROGUE)
874 hit += 20;
875 if (plr[pnum]._pClass == PC_WARRIOR)
876 hit += 10;
877 } else {
878 hit = plr[pnum]._pMagic
879 - (plr[p]._pLevel << 1)
880 - dist
881 + 50;
882 if (plr[pnum]._pClass == PC_SORCERER)
883 hit += 20;
884 }
885 if (hit < 5)
886 hit = 5;
887 if (hit > 95)
888 hit = 95;
889 if (hper < hit) {
890 if ((plr[p]._pmode == PM_STAND || plr[p]._pmode == PM_ATTACK) && plr[p]._pBlockFlag) {

Callers 1

CheckMissileColFunction · 0.85

Calls 6

random_Function · 0.85
NetSendCmdDamageFunction · 0.85
PlaySfxLocFunction · 0.85
StartPlrBlockFunction · 0.85
GetDirectionFunction · 0.85
StartPlrHitFunction · 0.85

Tested by

no test coverage detected