|
|
|
@ -1818,11 +1818,11 @@ bool RandomWalk(int monsterId, Direction md) |
|
|
|
Monster &monster = Monsters[monsterId]; |
|
|
|
Monster &monster = Monsters[monsterId]; |
|
|
|
|
|
|
|
|
|
|
|
bool ok = DirOK(monsterId, md); |
|
|
|
bool ok = DirOK(monsterId, md); |
|
|
|
if (GenerateRnd(2) != 0) |
|
|
|
if (FlipCoin()) |
|
|
|
ok = ok || (md = Left(mdtemp), DirOK(monsterId, md)) || (md = Right(mdtemp), DirOK(monsterId, md)); |
|
|
|
ok = ok || (md = Left(mdtemp), DirOK(monsterId, md)) || (md = Right(mdtemp), DirOK(monsterId, md)); |
|
|
|
else |
|
|
|
else |
|
|
|
ok = ok || (md = Right(mdtemp), DirOK(monsterId, md)) || (md = Left(mdtemp), DirOK(monsterId, md)); |
|
|
|
ok = ok || (md = Right(mdtemp), DirOK(monsterId, md)) || (md = Left(mdtemp), DirOK(monsterId, md)); |
|
|
|
if (GenerateRnd(2) != 0) { |
|
|
|
if (FlipCoin()) { |
|
|
|
ok = ok |
|
|
|
ok = ok |
|
|
|
|| (md = Right(Right(mdtemp)), DirOK(monsterId, md)) |
|
|
|
|| (md = Right(Right(mdtemp)), DirOK(monsterId, md)) |
|
|
|
|| (md = Left(Left(mdtemp)), DirOK(monsterId, md)); |
|
|
|
|| (md = Left(Left(mdtemp)), DirOK(monsterId, md)); |
|
|
|
@ -1842,7 +1842,7 @@ bool RandomWalk2(int monsterId, Direction md) |
|
|
|
|
|
|
|
|
|
|
|
Direction mdtemp = md; |
|
|
|
Direction mdtemp = md; |
|
|
|
bool ok = DirOK(monsterId, md); // Can we continue in the same direction
|
|
|
|
bool ok = DirOK(monsterId, md); // Can we continue in the same direction
|
|
|
|
if (GenerateRnd(2) != 0) { // Randomly go left or right
|
|
|
|
if (FlipCoin()) { // Randomly go left or right
|
|
|
|
ok = ok || (mdtemp = Left(md), DirOK(monsterId, Left(md))) || (mdtemp = Right(md), DirOK(monsterId, Right(md))); |
|
|
|
ok = ok || (mdtemp = Left(md), DirOK(monsterId, Left(md))) || (mdtemp = Right(md), DirOK(monsterId, Right(md))); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ok = ok || (mdtemp = Right(md), DirOK(monsterId, Right(md))) || (mdtemp = Left(md), DirOK(monsterId, Left(md))); |
|
|
|
ok = ok || (mdtemp = Right(md), DirOK(monsterId, Right(md))) || (mdtemp = Left(md), DirOK(monsterId, Left(md))); |
|
|
|
@ -2052,7 +2052,7 @@ void AiAvoidance(int monsterId) |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (v < 2 * monster.intelligence + 23) { |
|
|
|
} else if (v < 2 * monster.intelligence + 23) { |
|
|
|
monster.direction = md; |
|
|
|
monster.direction = md; |
|
|
|
if (IsAnyOf(monster.ai, AI_GOATMC, AI_GARBUD) && monster.hitPoints < (monster.maxHitPoints / 2) && GenerateRnd(2) != 0) |
|
|
|
if (IsAnyOf(monster.ai, AI_GOATMC, AI_GARBUD) && monster.hitPoints < (monster.maxHitPoints / 2) && FlipCoin()) |
|
|
|
StartSpecialAttack(monster); |
|
|
|
StartSpecialAttack(monster); |
|
|
|
else |
|
|
|
else |
|
|
|
StartAttack(monster); |
|
|
|
StartAttack(monster); |
|
|
|
@ -2337,7 +2337,7 @@ void SkeletonBowAi(int monsterId) |
|
|
|
|
|
|
|
|
|
|
|
std::optional<Point> ScavengerFindCorpse(const Monster &scavenger) |
|
|
|
std::optional<Point> ScavengerFindCorpse(const Monster &scavenger) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool lowToHigh = GenerateRnd(2) != 0; |
|
|
|
bool lowToHigh = FlipCoin(); |
|
|
|
int first = lowToHigh ? -4 : 4; |
|
|
|
int first = lowToHigh ? -4 : 4; |
|
|
|
int last = lowToHigh ? 4 : -4; |
|
|
|
int last = lowToHigh ? 4 : -4; |
|
|
|
int increment = lowToHigh ? 1 : -1; |
|
|
|
int increment = lowToHigh ? 1 : -1; |
|
|
|
@ -2632,7 +2632,7 @@ void BatAi(int monsterId) |
|
|
|
RandomWalk(monsterId, Opposite(md)); |
|
|
|
RandomWalk(monsterId, Opposite(md)); |
|
|
|
monster.goalVar1++; |
|
|
|
monster.goalVar1++; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (GenerateRnd(2) != 0) |
|
|
|
if (FlipCoin()) |
|
|
|
RandomWalk(monsterId, Left(md)); |
|
|
|
RandomWalk(monsterId, Left(md)); |
|
|
|
else |
|
|
|
else |
|
|
|
RandomWalk(monsterId, Right(md)); |
|
|
|
RandomWalk(monsterId, Right(md)); |
|
|
|
@ -2763,7 +2763,7 @@ void SneakAi(int monsterId) |
|
|
|
md = GetDirection(monster.position.tile, Players[monster.enemy].position.last); |
|
|
|
md = GetDirection(monster.position.tile, Players[monster.enemy].position.last); |
|
|
|
md = Opposite(md); |
|
|
|
md = Opposite(md); |
|
|
|
if (monster.type().type == MT_UNSEEN) { |
|
|
|
if (monster.type().type == MT_UNSEEN) { |
|
|
|
if (GenerateRnd(2) != 0) |
|
|
|
if (FlipCoin()) |
|
|
|
md = Left(md); |
|
|
|
md = Left(md); |
|
|
|
else |
|
|
|
else |
|
|
|
md = Right(md); |
|
|
|
md = Right(md); |
|
|
|
@ -3094,7 +3094,7 @@ void MegaAi(int monsterId) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (GenerateRnd(100) < 10 * (monster.intelligence + 4)) { |
|
|
|
if (GenerateRnd(100) < 10 * (monster.intelligence + 4)) { |
|
|
|
monster.direction = md; |
|
|
|
monster.direction = md; |
|
|
|
if (GenerateRnd(2) != 0) |
|
|
|
if (FlipCoin()) |
|
|
|
StartAttack(monster); |
|
|
|
StartAttack(monster); |
|
|
|
else |
|
|
|
else |
|
|
|
StartRangedSpecialAttack(monster, MIS_FLAMEC, 0); |
|
|
|
StartRangedSpecialAttack(monster, MIS_FLAMEC, 0); |
|
|
|
@ -3776,7 +3776,7 @@ void InitMonsters() |
|
|
|
} |
|
|
|
} |
|
|
|
while (ActiveMonsterCount < totalmonsters) { |
|
|
|
while (ActiveMonsterCount < totalmonsters) { |
|
|
|
int mtype = scattertypes[GenerateRnd(numscattypes)]; |
|
|
|
int mtype = scattertypes[GenerateRnd(numscattypes)]; |
|
|
|
if (currlevel == 1 || GenerateRnd(2) == 0) |
|
|
|
if (currlevel == 1 || !FlipCoin()) |
|
|
|
na = 1; |
|
|
|
na = 1; |
|
|
|
else if (currlevel == 2 || leveltype == DTYPE_CRYPT) |
|
|
|
else if (currlevel == 2 || leveltype == DTYPE_CRYPT) |
|
|
|
na = GenerateRnd(2) + 2; |
|
|
|
na = GenerateRnd(2) + 2; |
|
|
|
|