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

Function M_TryM2MHit

Source/monster.cpp:2000–2033  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1998}
1999
2000void M_TryM2MHit(int i, int mid, int hper, int mind, int maxd)
2001{
2002 BOOL ret;
2003
2004 if ((DWORD)mid >= MAXMONSTERS) {
2005 app_fatal("M_TryM2MHit: Invalid monster %d", mid);
2006 }
2007 if (monster[mid].MType == NULL)
2008 app_fatal("M_TryM2MHit: Monster %d \"%s\" MType NULL", mid, monster[mid].mName);
2009 if (monster[mid]._mhitpoints >> 6 > 0 && (monster[mid].MType->mtype != MT_ILLWEAV || monster[mid]._mgoal != MGOAL_RETREAT)) {
2010 int hit = random_(4, 100);
2011 if (monster[mid]._mmode == MM_STONE)
2012 hit = 0;
2013 if (!CheckMonsterHit(mid, &ret) && hit < hper) {
2014 int dam = (mind + random_(5, maxd - mind + 1)) << 6;
2015 monster[mid]._mhitpoints -= dam;
2016 if (monster[mid]._mhitpoints >> 6 <= 0) {
2017 if (monster[mid]._mmode == MM_STONE) {
2018 M2MStartKill(i, mid);
2019 monster[mid]._mmode = MM_STONE;
2020 } else {
2021 M2MStartKill(i, mid);
2022 }
2023 } else {
2024 if (monster[mid]._mmode == MM_STONE) {
2025 M2MStartHit(mid, i, dam);
2026 monster[mid]._mmode = MM_STONE;
2027 } else {
2028 M2MStartHit(mid, i, dam);
2029 }
2030 }
2031 }
2032 }
2033}
2034
2035void M_TryH2HHit(int i, int pnum, int Hit, int MinDam, int MaxDam)
2036{

Callers 2

M_TryH2HHitFunction · 0.85
MissToMonstFunction · 0.85

Calls 5

app_fatalFunction · 0.85
random_Function · 0.85
CheckMonsterHitFunction · 0.85
M2MStartKillFunction · 0.85
M2MStartHitFunction · 0.85

Tested by

no test coverage detected