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

Function MAI_RR2

Source/monster.cpp:3816–3889  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3814}
3815
3816void MAI_RR2(int i, int mistype, int dam)
3817{
3818 MonsterStruct *Monst;
3819 int mx, my, fx, fy;
3820 int dist, v, md;
3821
3822 if ((DWORD)i >= MAXMONSTERS)
3823 app_fatal("MAI_RR2: Invalid monster %d", i);
3824
3825 Monst = monster + i;
3826 mx = Monst->_mx - Monst->_menemyx;
3827 my = Monst->_my - Monst->_menemyy;
3828 if (abs(mx) >= 5 || abs(my) >= 5) {
3829 MAI_SkelSd(i);
3830 return;
3831 }
3832
3833 if (Monst->_mmode == MM_STAND && Monst->_msquelch != 0) {
3834 fx = Monst->_menemyx;
3835 fy = Monst->_menemyy;
3836 mx = Monst->_mx - fx;
3837 my = Monst->_my - fy;
3838 md = GetDirection(Monst->_mx, Monst->_my, Monst->_lastx, Monst->_lasty);
3839 if (Monst->_msquelch < UCHAR_MAX)
3840 MonstCheckDoors(i);
3841 v = random_(121, 100);
3842 if ((abs(mx) >= 2 || abs(my) >= 2) && Monst->_msquelch == UCHAR_MAX && dTransVal[Monst->_mx][Monst->_my] == dTransVal[fx][fy]) {
3843 if (Monst->_mgoal == MGOAL_MOVE || (abs(mx) >= 3 || abs(my) >= 3)) {
3844 if (Monst->_mgoal != MGOAL_MOVE) {
3845 Monst->_mgoalvar1 = 0;
3846 Monst->_mgoalvar2 = random_(123, 2);
3847 }
3848 Monst->_mgoal = MGOAL_MOVE;
3849 Monst->_mgoalvar3 = 4;
3850 if (abs(mx) > abs(my)) {
3851 dist = abs(mx);
3852 } else {
3853 dist = abs(my);
3854 }
3855 if (Monst->_mgoalvar1++ < 2 * dist || !DirOK(i, md)) {
3856 if (v < 5 * (Monst->_mint + 16))
3857 M_RoundWalk(i, md, &Monst->_mgoalvar2);
3858 } else
3859 Monst->_mgoal = MGOAL_NORMAL;
3860 }
3861 } else
3862 Monst->_mgoal = MGOAL_NORMAL;
3863 if (Monst->_mgoal == MGOAL_NORMAL) {
3864 if (((abs(mx) >= 3 || abs(my) >= 3) && v < 5 * (Monst->_mint + 2) || v < 5 * (Monst->_mint + 1) || Monst->_mgoalvar3 == 4) && LineClear(Monst->_mx, Monst->_my, fx, fy)) {
3865 M_StartRSpAttack(i, mistype, dam);
3866 } else if (abs(mx) >= 2 || abs(my) >= 2) {
3867 v = random_(124, 100);
3868 if (v < 2 * (5 * Monst->_mint + 25)
3869 || (Monst->_mVar1 == MM_WALK || Monst->_mVar1 == MM_WALK2 || Monst->_mVar1 == MM_WALK3)
3870 && Monst->_mVar2 == 0
3871 && v < 2 * (5 * Monst->_mint + 40)) {
3872 M_CallWalk(i, md);
3873 }

Callers 1

MAI_MegaFunction · 0.85

Calls 12

app_fatalFunction · 0.85
MAI_SkelSdFunction · 0.85
GetDirectionFunction · 0.85
MonstCheckDoorsFunction · 0.85
random_Function · 0.85
DirOKFunction · 0.85
M_RoundWalkFunction · 0.85
LineClearFunction · 0.85
M_StartRSpAttackFunction · 0.85
M_CallWalkFunction · 0.85
M_StartAttackFunction · 0.85
M_StartDelayFunction · 0.85

Tested by

no test coverage detected