Browse Source

Clean up MAI_Counselor.

pull/114/head
Sergey Semushin 7 years ago committed by Anders Jenbo
parent
commit
1fa1db2a63
  1. 202
      Source/monster.cpp

202
Source/monster.cpp

@ -4129,159 +4129,73 @@ void MAI_Rhino(int i)
void MAI_Counselor(int i) void MAI_Counselor(int i)
{ {
int v1; // ebx int mx, my, fx, fy;
int v2; // esi int dist, md, v;
int v3; // ecx MonsterStruct *Monst;
int v4; // edi
int v5; // edx
int v6; // ebp
char v9; // al
int v10; // ecx
BOOLEAN v11; // zf
BOOLEAN v12; // sf
//unsigned char v13; // of
int v14; // edx
int v15; // ecx
int v16; // ebx
int v17; // eax
int v18; // ebx
int v19; // edx
int v20; // ecx
//int v21; // eax
int v22; // eax
//int v23; // ST1C_4
int v25; // eax
//int v26; // ST1C_4
int v27; // edx
int v28; // eax
int v29; // eax
int v30; // ecx
//int v31; // eax
int v32; // eax
int v33; // eax
int v34; // eax
int md; // [esp+8h] [ebp-14h]
int arglist; // [esp+Ch] [ebp-10h]
int y2; // [esp+10h] [ebp-Ch]
int x2; // [esp+14h] [ebp-8h]
int v39; // [esp+18h] [ebp-4h]
v1 = i;
arglist = i;
if ((DWORD)i >= MAXMONSTERS) if ((DWORD)i >= MAXMONSTERS)
app_fatal("MAI_Counselor: Invalid monster %d", i); app_fatal("MAI_Counselor: Invalid monster %d", i);
v2 = v1; if (monster[i]._mmode == MM_STAND && monster[i]._msquelch != 0) {
if (monster[v1]._mmode == MM_STAND && monster[v2]._msquelch != 0) { Monst = monster + i;
v3 = monster[v2]._mx; fx = Monst->_menemyx;
x2 = (unsigned char)monster[v2]._menemyx; fy = Monst->_menemyy;
v4 = v3 - x2; mx = Monst->_mx - fx;
v5 = monster[v2]._my; my = Monst->_my - fy;
y2 = (unsigned char)monster[v2]._menemyy; md = GetDirection(Monst->_mx, Monst->_my, Monst->_lastx, Monst->_lasty);
v6 = v5 - y2; if (Monst->_msquelch < UCHAR_MAX)
md = GetDirection(v3, v5, monster[v2]._lastx, monster[v2]._lasty); MonstCheckDoors(i);
if (monster[v2]._msquelch < UCHAR_MAX) /* check sign */ v = random(121, 100);
MonstCheckDoors(v1); if (Monst->_mgoal == MGOAL_RETREAT) {
v39 = random(121, 100); if (Monst->_mgoalvar1++ <= 3)
v9 = monster[v2]._mgoal; M_CallWalk(i, opposite[md]);
if (v9 == MGOAL_RETREAT) { else {
v10 = monster[v2]._mgoalvar1; Monst->_mgoal = MGOAL_NORMAL;
//v13 = __OFSUB__(v10, 3); M_StartFadein(i, md, TRUE);
v11 = v10 == 3;
v12 = v10 - 3 < 0;
v14 = v10 + 1;
v15 = v1;
monster[v2]._mgoalvar1 = v14;
if (v12 | v11) { //if ((unsigned char)(v12 ^ v13) | v11) {
M_CallWalk(v1, opposite[md]);
goto LABEL_39;
} }
goto LABEL_21; } else if (Monst->_mgoal == MGOAL_MOVE) {
} if (abs(mx) > abs(my))
if (v9 == MGOAL_MOVE) { dist = abs(mx);
v16 = abs(v6);
if (abs(v4) <= v16)
v17 = abs(v6);
else else
v17 = abs(v4); dist = abs(my);
v18 = v17; if ((abs(mx) >= 2 || abs(my) >= 2) && Monst->_msquelch == UCHAR_MAX && dTransVal[Monst->_mx][Monst->_my] == dTransVal[fx][fy]) {
if (abs(v4) < 2 && abs(v6) < 2 if (Monst->_mgoalvar1++ < 2 * dist || !DirOK(i, md)) {
|| monster[v2]._msquelch != UCHAR_MAX M_RoundWalk(i, md, &Monst->_mgoalvar2);
|| dTransVal[monster[v2]._mx][monster[v2]._my] != dTransVal[x2][y2]) { } else {
v1 = arglist; Monst->_mgoal = MGOAL_NORMAL;
LABEL_20: M_StartFadein(i, md, TRUE);
v15 = v1;
LABEL_21:
_LOBYTE(monster[v2]._mgoal) = MGOAL_NORMAL;
M_StartFadein(v15, md, TRUE);
goto LABEL_39;
}
v19 = 2 * v18;
v1 = arglist;
v20 = monster[v2]._mgoalvar1;
monster[v2]._mgoalvar1 = v20 + 1;
if (v20 >= v19) {
//_LOBYTE(v21) = DirOK(arglist, md);
if (DirOK(arglist, md))
goto LABEL_20;
}
M_RoundWalk(arglist, md, &monster[v2]._mgoalvar2);
LABEL_39:
if (monster[v2]._mmode == MM_STAND) {
v34 = random(125, 10);
M_StartDelay(v1, v34 + 5);
}
return;
}
if (v9 != MGOAL_NORMAL)
goto LABEL_39;
v22 = abs(v4);
//v24 = v23;
if (v22 >= 2 || (v25 = abs(v6), v25 >= 2)) /* v24 = v26, */
{
if (v39 < 5 * ((unsigned char)monster[v2]._mint + 10)) {
//_LOBYTE(v31) = LineClear(monster[v2]._mx, monster[v2]._my, x2, y2);
if (LineClear(monster[v2]._mx, monster[v2]._my, x2, y2)) {
v32 = random(
77,
(unsigned char)monster[v2].mMaxDamage - (unsigned char)monster[v2].mMinDamage + 1);
M_StartRAttack(
v1,
(unsigned char)counsmiss[(unsigned char)monster[v2]._mint], /* counsmiss is local */
(unsigned char)monster[v2].mMinDamage + v32);
goto LABEL_39;
} }
} else {
Monst->_mgoal = MGOAL_NORMAL;
M_StartFadein(i, md, TRUE);
} }
if (random(124, 100) < 30) { } else if (Monst->_mgoal == MGOAL_NORMAL) {
v27 = md; if (abs(mx) >= 2 || abs(my) >= 2) {
_LOBYTE(monster[v2]._mgoal) = MGOAL_MOVE; if (v < 5 * (Monst->_mint + 10) && LineClear(Monst->_mx, Monst->_my, fx, fy)) {
goto LABEL_29; M_StartRAttack(i, counsmiss[Monst->_mint], Monst->mMinDamage + random(77, Monst->mMaxDamage - Monst->mMinDamage + 1));
} } else if (random(124, 100) < 30) {
} else { Monst->_mgoal = MGOAL_MOVE;
v27 = md; Monst->_mgoalvar1 = 0;
v28 = monster[v2]._mmaxhp >> 1; M_StartFadeout(i, md, FALSE);
//v13 = __OFSUB__(monster[v2]._mhitpoints, v28); } else
v12 = monster[v2]._mhitpoints - v28 < 0; M_StartDelay(i, random(105, 10) + 2 * (5 - Monst->_mint));
monster[v2]._mdir = md; } else {
if (v12) { //if (v12 ^ v13) { Monst->_mdir = md;
_LOBYTE(monster[v2]._mgoal) = MGOAL_RETREAT; if (Monst->_mhitpoints < (Monst->_mmaxhp >> 1)) {
LABEL_29: Monst->_mgoal = MGOAL_RETREAT;
monster[v2]._mgoalvar1 = 0; Monst->_mgoalvar1 = 0;
M_StartFadeout(v1, v27, FALSE); M_StartFadeout(i, md, FALSE);
goto LABEL_39; } else if (Monst->_mVar1 == MM_DELAY
} || random(105, 100) < 2 * Monst->_mint + 20) {
if (monster[v2]._mVar1 == MM_DELAY M_StartRAttack(i, -1, 0);
|| (v29 = random(105, 100), AddMissile(Monst->_mx, Monst->_my, 0, 0, Monst->_mdir, MIS_FLASH, 1, i, 4, 0);
v30 = 2 * (unsigned char)monster[v2]._mint + 20, AddMissile(Monst->_mx, Monst->_my, 0, 0, Monst->_mdir, MIS_FLASH2, 1, i, 4, 0);
v29 < v30)) { } else
M_StartRAttack(v1, -1, 0); M_StartDelay(i, random(105, 10) + 2 * (5 - Monst->_mint));
AddMissile(monster[v2]._mx, monster[v2]._my, 0, 0, monster[v2]._mdir, MIS_FLASH, 1, v1, 4, 0);
AddMissile(monster[v2]._mx, monster[v2]._my, 0, 0, monster[v2]._mdir, MIS_FLASH2, 1, v1, 4, 0);
goto LABEL_39;
} }
} }
v33 = random(105, 10); if (Monst->_mmode == MM_STAND) {
M_StartDelay(v1, v33 + 2 * (5 - (unsigned char)monster[v2]._mint)); M_StartDelay(i, random(125, 10) + 5);
goto LABEL_39; }
} }
} }

Loading…
Cancel
Save