Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Golem fixes #6430

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Source/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,12 @@ void DrawInfoBox(const Surface &out)
const auto &monster = Monsters[pcursmonst];
InfoColor = UiFlags::ColorWhite;
InfoString = monster.name();
if (IsGolemId(pcursmonst)) {
const auto &player = Players[pcursmonst];
string_view formatString = _(/* TRANSLATORS: Player name followed by the word Golem. Format: {Player}'s {Golem} */ "{0}'s {1}");
std::string golemName = fmt::format(fmt::runtime(formatString), player._pName, InfoString.str());
InfoString = std::move(golemName);
}
if (monster.isUnique()) {
InfoColor = UiFlags::ColorWhitegold;
PrintUniqueHistory();
Expand Down
2 changes: 1 addition & 1 deletion Source/controls/plrctrls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ bool CanTargetMonster(const Monster &monster)
{
if ((monster.flags & MFLAG_HIDDEN) != 0)
return false;
if (monster.isPlayerMinion())
if (monster.isPlayerMinion() && (MyPlayer->friendlyMode || IsMyGolem(pcursmonst)))
return false;
if (monster.hitPoints >> 6 <= 0) // dead
return false;
Expand Down
6 changes: 3 additions & 3 deletions Source/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ void CheckCursMove()
pcursmonst = -1;
cursPosition = { mx, my };
}
if (pcursmonst != -1 && Monsters[pcursmonst].isPlayerMinion()) {
if (pcursmonst != -1 && Monsters[pcursmonst].isPlayerMinion() && (MyPlayer->friendlyMode || IsMyGolem(pcursmonst))) {
pcursmonst = -1;
}
if (pcursmonst != -1) {
Expand Down Expand Up @@ -616,7 +616,7 @@ void CheckCursMove()
pcursmonst = -1;
cursPosition = { mx, my };
}
if (pcursmonst != -1 && (Monsters[pcursmonst].isPlayerMinion() || IsAnyOf(pcurs, CURSOR_HEALOTHER, CURSOR_RESURRECT))) {
if (pcursmonst != -1 && (Monsters[pcursmonst].isPlayerMinion() && (MyPlayer->friendlyMode || IsMyGolem(pcursmonst)) || IsAnyOf(pcurs, CURSOR_HEALOTHER, CURSOR_RESURRECT))) {
pcursmonst = -1;
}
} else {
Expand Down Expand Up @@ -765,7 +765,7 @@ void CheckCursMove()
pcursitem = -1;
cursPosition = { mx, my };
}
if (pcursmonst != -1 && leveltype != DTYPE_TOWN && Monsters[pcursmonst].isPlayerMinion()) {
if (pcursmonst != -1 && leveltype != DTYPE_TOWN && Monsters[pcursmonst].isPlayerMinion() && (MyPlayer->friendlyMode || IsMyGolem(pcursmonst))) {
pcursmonst = -1;
}
}
Expand Down
6 changes: 3 additions & 3 deletions Source/missiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ bool MonsterMHit(int pnum, int monsterId, int mindam, int maxdam, int dist, Miss
dam += player._pDamageMod;
else
dam += player._pDamageMod / 2;
if (monster.data().monsterClass == MonsterClass::Demon && HasAnyOf(player._pIFlags, ItemSpecialEffect::TripleDemonDamage))
if (monster.data().monsterClass == MonsterClass::Demon && monster.type().type != MT_GOLEM && HasAnyOf(player._pIFlags, ItemSpecialEffect::TripleDemonDamage))
dam *= 3;
}
bool resist = monster.isResistant(t, damageType);
Expand Down Expand Up @@ -656,7 +656,7 @@ bool GuardianTryFireAt(Missile &missile, Point target)
if (mid < 0)
return false;
const Monster &monster = Monsters[mid];
if (monster.isPlayerMinion())
if (monster.isPlayerMinion() && (missile.sourcePlayer()->friendlyMode || missile.sourcePlayer()->getId() == mid))
return false;
if (monster.hitPoints >> 6 <= 0)
return false;
Expand Down Expand Up @@ -3781,7 +3781,7 @@ void ProcessApocalypse(Missile &missile)
int mid = dMonster[k][j] - 1;
if (mid < 0)
continue;
if (Monsters[mid].isPlayerMinion())
if (Monsters[mid].isPlayerMinion() && (MyPlayer->friendlyMode || missile.sourcePlayer()->getId() == mid))
continue;
if (TileHasAny(dPiece[k][j], TileProperties::Solid))
continue;
Expand Down
2 changes: 1 addition & 1 deletion Source/monstdat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const MonsterData MonstersData[] = {
/* MT_MAGISTR */ { P_("monster", "Magistrate"), "mage\\mage", nullptr, "mage\\cnselg", MonsterAvailability::Retail, 128, 2000, true, false, { 12, 1, 20, 8, 28, 20 }, { 1, 1, 1, 1, 1, 1 }, 14, 15, 27, 85, 85, MonsterAIID::Counselor, MFLAG_CAN_OPEN_DOOR, 1, 100, 8, 10, 24, 0, 0, 0, 0, 0, MonsterClass::Demon, RESIST_MAGIC | IMMUNE_FIRE | RESIST_LIGHTNING, IMMUNE_MAGIC | IMMUNE_FIRE | RESIST_LIGHTNING, 7, 0, 4478 },
/* MT_CABALIST*/ { P_("monster", "Cabalist"), "mage\\mage", nullptr, "mage\\cnselgd", MonsterAvailability::Retail, 128, 2000, true, false, { 12, 1, 20, 8, 28, 20 }, { 1, 1, 1, 1, 1, 1 }, 15, 16, 29, 120, 120, MonsterAIID::Counselor, MFLAG_CAN_OPEN_DOOR, 2, 110, 8, 14, 30, 0, 0, 0, 0, 0, MonsterClass::Demon, RESIST_MAGIC | RESIST_FIRE | IMMUNE_LIGHTNING, IMMUNE_MAGIC | RESIST_FIRE | IMMUNE_LIGHTNING, 7, 0, 4929 },
/* MT_ADVOCATE*/ { P_("monster", "Advocate"), "mage\\mage", nullptr, "mage\\cnselbk", MonsterAvailability::Retail, 128, 2000, true, false, { 12, 1, 20, 8, 28, 20 }, { 1, 1, 1, 1, 1, 1 }, 16, 16, 30, 145, 145, MonsterAIID::Counselor, MFLAG_CAN_OPEN_DOOR, 3, 120, 8, 15, 25, 0, 0, 0, 0, 0, MonsterClass::Demon, IMMUNE_MAGIC | RESIST_FIRE | IMMUNE_LIGHTNING, IMMUNE_MAGIC | IMMUNE_FIRE | IMMUNE_LIGHTNING, 7, 0, 4968 },
/* MT_GOLEM */ { P_("monster", "Golem"), "golem\\golem", "golem\\golm", nullptr, MonsterAvailability::Never, 96, 386, true, false, { 0, 16, 12, 0, 12, 20 }, { 1, 1, 1, 1, 1, 1 }, 1, 1, 12, 1, 1, MonsterAIID::Golem, MFLAG_CAN_OPEN_DOOR, 0, 0, 7, 1, 1, 0, 0, 0, 0, 1, MonsterClass::Demon, 0, 0, 0, 0, 0 },
/* MT_GOLEM */ { P_("monster", "Golem"), "golem\\golem", "golem\\golm", nullptr, MonsterAvailability::Never, 96, 386, true, false, { 0, 16, 12, 0, 12, 20 }, { 1, 1, 1, 1, 1, 1 }, 1, 1, 12, 1, 1, MonsterAIID::Golem, MFLAG_CAN_OPEN_DOOR, 0, 0, 7, 1, 1, 0, 0, 0, 0, 1, MonsterClass::Demon, 0, 0, 3, 0, 0 },
/* MT_DIABLO */ { P_("monster", "The Dark Lord"), "diablo\\diablo", nullptr, nullptr, MonsterAvailability::Never, 160, 2000, true, true, { 16, 6, 16, 6, 16, 16 }, { 1, 1, 1, 1, 1, 1 }, 26, 26, 45, 3333, 3333, MonsterAIID::Diablo, MFLAG_KNOCKBACK | MFLAG_SEARCH | MFLAG_CAN_OPEN_DOOR, 3, 220, 4, 30, 60, 0, 11, 0, 0, 90, MonsterClass::Demon, IMMUNE_MAGIC | RESIST_FIRE | RESIST_LIGHTNING, IMMUNE_MAGIC | RESIST_FIRE | RESIST_LIGHTNING, 7, 0, 31666 },
/* MT_DARKMAGE*/ { P_("monster", "The Arch-Litch Malignus"), "darkmage\\dmage", "darkmage\\dmag", nullptr, MonsterAvailability::Never, 128, 1060, true, false, { 6, 1, 21, 6, 23, 18 }, { 1, 1, 1, 1, 1, 1 }, 21, 21, 30, 160, 160, MonsterAIID::Counselor, MFLAG_CAN_OPEN_DOOR, 3, 120, 8, 20, 40, 0, 0, 0, 0, 70, MonsterClass::Demon, RESIST_MAGIC | RESIST_FIRE | RESIST_LIGHTNING, IMMUNE_MAGIC | IMMUNE_FIRE | IMMUNE_LIGHTNING, 7, 0, 4968 },
/* MT_HELLBOAR*/ { P_("monster", "Hellboar"), "fork\\fork", "newsfx\\hboar", nullptr, MonsterAvailability::Retail, 188, 800, false, false, { 10, 10, 15, 6, 16, 0 }, { 2, 1, 1, 1, 1, 1 }, 17, 18, 23, 80, 100, MonsterAIID::SkeletonMelee, MFLAG_KNOCKBACK | MFLAG_SEARCH, 2, 70, 7, 16, 24, 0, 0, 0, 0, 60, MonsterClass::Demon, 0, RESIST_FIRE | RESIST_LIGHTNING, 3, 0, 750 },
Expand Down
22 changes: 18 additions & 4 deletions Source/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,8 +646,11 @@ void UpdateEnemy(Monster &monster)
continue;
if (otherMonster.talkMsg != TEXT_NONE && M_Talker(otherMonster))
continue;
if (isPlayerMinion && otherMonster.isPlayerMinion()) // prevent golems from fighting each other
continue;
if (isPlayerMinion && otherMonster.isPlayerMinion()) {
auto playerId = monster.getId();
if (Players[playerId].friendlyMode) // prevent golem from attacking other golems if owner is friendly
continue;
}

const int dist = otherMonster.position.tile.WalkingDistance(position);
if (((monster.flags & MFLAG_GOLEM) == 0
Expand Down Expand Up @@ -4238,12 +4241,13 @@ void M_FallenFear(Point position)
void PrintMonstHistory(int mt)
{
if (*sgOptions.Gameplay.showMonsterType) {
AddPanelString(fmt::format(fmt::runtime(_("Type: {:s} Kills: {:d}")), GetMonsterTypeText(MonstersData[mt]), MonsterKillCounts[mt]));
auto monsterType = (mt != MT_GOLEM) ? GetMonsterTypeText(MonstersData[mt]) : _("Golem");
AddPanelString(fmt::format(fmt::runtime(_("Type: {:s} Kills: {:d}")), monsterType, MonsterKillCounts[mt]));
} else {
AddPanelString(fmt::format(fmt::runtime(_("Total kills: {:d}")), MonsterKillCounts[mt]));
}

if (MonsterKillCounts[mt] >= 30) {
if (MonsterKillCounts[mt] >= 30 && mt != MT_GOLEM) {
int minHP = MonstersData[mt].hitPointsMinimum;
int maxHP = MonstersData[mt].hitPointsMaximum;
if (!gbIsHellfire && mt == MT_DIABLO) {
Expand Down Expand Up @@ -4460,6 +4464,16 @@ bool IsGoat(_monster_id mt)
MT_NGOATBW, MT_BGOATBW, MT_RGOATBW, MT_GGOATBW);
}

bool IsGolemId(int mid)
{
return (abs(mid) >= 0 && abs(mid) < MAX_PLRS);
}

bool IsMyGolem(int mid)
{
return (abs(mid) == MyPlayerId);
}

void ActivateSkeleton(Monster &monster, Point position)
{
if (IsTileAvailable(position)) {
Expand Down
2 changes: 2 additions & 0 deletions Source/monster.h
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,8 @@ Monster *FindUniqueMonster(UniqueMonsterType monsterType);
bool IsTileAvailable(const Monster &monster, Point position);
bool IsSkel(_monster_id mt);
bool IsGoat(_monster_id mt);
bool IsGolemId(int mid);
bool IsMyGolem(int mid);
/**
* @brief Reveals a monster that was hiding in a container
* @param monster instance returned from a previous call to PreSpawnSkeleton
Expand Down
41 changes: 21 additions & 20 deletions Source/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,27 +625,28 @@ bool PlrHitMonst(Player &player, Monster &monster, bool adjacentDamage = false)
if (player.InvBody[INVLOC_HAND_LEFT]._itype == ItemType::Mace || player.InvBody[INVLOC_HAND_RIGHT]._itype == ItemType::Mace) {
phanditype = ItemType::Mace;
}

switch (monster.data().monsterClass) {
case MonsterClass::Undead:
if (phanditype == ItemType::Sword) {
dam -= dam / 2;
} else if (phanditype == ItemType::Mace) {
dam += dam / 2;
}
break;
case MonsterClass::Animal:
if (phanditype == ItemType::Mace) {
dam -= dam / 2;
} else if (phanditype == ItemType::Sword) {
dam += dam / 2;
}
break;
case MonsterClass::Demon:
if (HasAnyOf(player._pIFlags, ItemSpecialEffect::TripleDemonDamage)) {
dam *= 3;
if (monster.type().type != MT_GOLEM) {
switch (monster.data().monsterClass) {
case MonsterClass::Undead:
if (phanditype == ItemType::Sword) {
dam -= dam / 2;
} else if (phanditype == ItemType::Mace) {
dam += dam / 2;
}
break;
case MonsterClass::Animal:
if (phanditype == ItemType::Mace) {
dam -= dam / 2;
} else if (phanditype == ItemType::Sword) {
dam += dam / 2;
}
break;
case MonsterClass::Demon:
if (HasAnyOf(player._pIFlags, ItemSpecialEffect::TripleDemonDamage)) {
dam *= 3;
}
break;
}
break;
}

if (HasAnyOf(player.pDamAcFlags, ItemSpecialEffectHf::Devastation) && GenerateRnd(100) < 5) {
Expand Down
Loading