roriscrave
Advanced OT User
- Joined
- Dec 7, 2011
- Messages
- 1,210
- Solutions
- 35
- Reaction score
- 206
Hello, im using tfs 1.3 and has a really bad script and I do not know how to remove it.
if the players take a hit, everyone on the screen receives the message in the Server Log.
How can I remove this?
OBS: the minotaur archer is not my summon, he is a game monster.
edit: i think it can be removed in this 2 functions, but i dont know why..
at game.cpp
if the players take a hit, everyone on the screen receives the message in the Server Log.
Code:
21:44 Zewf loses 64 hitpoints due to an attack by a minotaur archer.
21:44 Player Test loses 33 hitpoints due to an attack by a minotaur archer.
21:44 Zoko loses 49 hitpoints due to an attack by a minotaur archer.
How can I remove this?
OBS: the minotaur archer is not my summon, he is a game monster.
edit: i think it can be removed in this 2 functions, but i dont know why..
at game.cpp
Code:
bool Game::combatChangeHealth(Creature* attacker, Creature* target, CombatDamage& damage)
{
const Position& targetPos = target->getPosition();
if (damage.primary.value > 0) {
if (target->getHealth() <= 0) {
return false;
}
Player* attackerPlayer;
if (attacker) {
attackerPlayer = attacker->getPlayer();
} else {
attackerPlayer = nullptr;
}
Player* targetPlayer = target->getPlayer();
if (attackerPlayer && targetPlayer && attackerPlayer->getSkull() == SKULL_BLACK && attackerPlayer->getSkullClient(targetPlayer) == SKULL_NONE) {
return false;
}
if (damage.origin != ORIGIN_NONE) {
const auto& events = target->getCreatureEvents(CREATURE_EVENT_HEALTHCHANGE);
if (!events.empty()) {
for (CreatureEvent* creatureEvent : events) {
creatureEvent->executeHealthChange(target, attacker, damage);
}
damage.origin = ORIGIN_NONE;
return combatChangeHealth(attacker, target, damage);
}
}
int32_t realHealthChange = target->getHealth();
target->gainHealth(attacker, damage.primary.value);
realHealthChange = target->getHealth() - realHealthChange;
if (realHealthChange > 0 && !target->isInGhostMode()) {
std::string damageString = std::to_string(realHealthChange) + (realHealthChange != 1 ? " hitpoints." : " hitpoint.");
std::string spectatorMessage;
if (!attacker) {
spectatorMessage += ucfirst(target->getNameDescription());
spectatorMessage += " was healed for " + damageString;
} else {
spectatorMessage += ucfirst(attacker->getNameDescription());
spectatorMessage += " healed ";
if (attacker == target) {
spectatorMessage += (targetPlayer ? (targetPlayer->getSex() == PLAYERSEX_FEMALE ? "herself" : "himself") : "itself");
} else {
spectatorMessage += target->getNameDescription();
}
spectatorMessage += " for " + damageString;
}
TextMessage message;
std::ostringstream strHealthChange;
strHealthChange << realHealthChange;
addAnimatedText(strHealthChange.str(), targetPos, TEXTCOLOR_MAYABLUE);
SpectatorHashSet spectators;
map.getSpectators(spectators, targetPos, false, true);
for (Creature* spectator : spectators) {
Player* tmpPlayer = spectator->getPlayer();
if (tmpPlayer == attackerPlayer && attackerPlayer != targetPlayer) {
message.type = MESSAGE_STATUS_DEFAULT;
message.text = "You heal " + target->getNameDescription() + " for " + damageString;
} else if (tmpPlayer == targetPlayer) {
message.type = MESSAGE_STATUS_DEFAULT;
if (!attacker) {
message.text = "You were healed for " + damageString;
} else if (targetPlayer == attackerPlayer) {
message.text = "You heal yourself for " + damageString;
} else {
message.text = "You were healed by " + attacker->getNameDescription() + " for " + damageString;
}
} else {
message.type = MESSAGE_STATUS_DEFAULT;
message.text = spectatorMessage;
}
tmpPlayer->sendTextMessage(message);
}
}
} else {
if (!target->isAttackable()) {
if (!target->isInGhostMode()) {
addMagicEffect(targetPos, CONST_ME_POFF);
}
return true;
}
Player* attackerPlayer;
if (attacker) {
attackerPlayer = attacker->getPlayer();
} else {
attackerPlayer = nullptr;
}
Player* targetPlayer = target->getPlayer();
if (attackerPlayer && targetPlayer && attackerPlayer->getSkull() == SKULL_BLACK && attackerPlayer->getSkullClient(targetPlayer) == SKULL_NONE) {
return false;
}
damage.primary.value = std::abs(damage.primary.value);
damage.secondary.value = std::abs(damage.secondary.value);
int32_t healthChange = damage.primary.value + damage.secondary.value;
if (healthChange == 0) {
return true;
}
TextMessage message;
SpectatorHashSet spectators;
if (target->hasCondition(CONDITION_MANASHIELD) && damage.primary.type != COMBAT_UNDEFINEDDAMAGE) {
int32_t manaDamage = std::min<int32_t>(target->getMana(), healthChange);
if (manaDamage != 0) {
if (damage.origin != ORIGIN_NONE) {
const auto& events = target->getCreatureEvents(CREATURE_EVENT_MANACHANGE);
if (!events.empty()) {
for (CreatureEvent* creatureEvent : events) {
creatureEvent->executeManaChange(target, attacker, healthChange, damage.origin);
}
if (healthChange == 0) {
return true;
}
manaDamage = std::min<int32_t>(target->getMana(), healthChange);
}
}
target->drainMana(attacker, manaDamage);
map.getSpectators(spectators, targetPos, true, true);
addMagicEffect(spectators, targetPos, CONST_ME_LOSEENERGY);
std::string damageString = std::to_string(manaDamage);
std::string spectatorMessage = ucfirst(target->getNameDescription()) + " loses " + damageString + " mana";
if (attacker) {
spectatorMessage += " due to ";
if (attacker == target) {
spectatorMessage += (targetPlayer ? (targetPlayer->getSex() == PLAYERSEX_FEMALE ? "her own attack" : "his own attack") : "its own attack");
} else {
spectatorMessage += "an attack by " + attacker->getNameDescription();
}
}
spectatorMessage += '.';
std::ostringstream strManaDamage;
strManaDamage << manaDamage;
addAnimatedText(strManaDamage.str(), targetPos, TEXTCOLOR_BLUE);
for (Creature* spectator : spectators) {
Player* tmpPlayer = spectator->getPlayer();
if (tmpPlayer->getPosition().z != targetPos.z) {
continue;
}
if (tmpPlayer == attackerPlayer && attackerPlayer != targetPlayer) {
message.type = MESSAGE_STATUS_DEFAULT;
message.text = ucfirst(target->getNameDescription()) + " loses " + damageString + " mana due to your attack.";
} else if (tmpPlayer == targetPlayer) {
message.type = MESSAGE_STATUS_DEFAULT;
if (!attacker) {
message.text = "You lose " + damageString + " mana.";
} else if (targetPlayer == attackerPlayer) {
message.text = "You lose " + damageString + " mana due to your own attack.";
} else {
message.text = "You lose " + damageString + " mana due to an attack by " + attacker->getNameDescription() + '.';
}
} else {
message.type = MESSAGE_STATUS_DEFAULT;
message.text = spectatorMessage;
}
tmpPlayer->sendTextMessage(message);
}
damage.primary.value -= manaDamage;
if (damage.primary.value < 0) {
damage.secondary.value = std::max<int32_t>(0, damage.secondary.value + damage.primary.value);
damage.primary.value = 0;
}
}
}
int32_t realDamage = damage.primary.value + damage.secondary.value;
if (realDamage == 0) {
return true;
}
if (damage.origin != ORIGIN_NONE) {
const auto& events = target->getCreatureEvents(CREATURE_EVENT_HEALTHCHANGE);
if (!events.empty()) {
for (CreatureEvent* creatureEvent : events) {
creatureEvent->executeHealthChange(target, attacker, damage);
}
damage.origin = ORIGIN_NONE;
return combatChangeHealth(attacker, target, damage);
}
}
int32_t targetHealth = target->getHealth();
if (damage.primary.value >= targetHealth) {
damage.primary.value = targetHealth;
damage.secondary.value = 0;
} else if (damage.secondary.value) {
damage.secondary.value = std::min<int32_t>(damage.secondary.value, targetHealth - damage.primary.value);
}
realDamage = damage.primary.value + damage.secondary.value;
if (realDamage == 0) {
return true;
} else if (realDamage >= targetHealth) {
for (CreatureEvent* creatureEvent : target->getCreatureEvents(CREATURE_EVENT_PREPAREDEATH)) {
if (!creatureEvent->executeOnPrepareDeath(target, attacker)) {
return false;
}
}
}
target->drainHealth(attacker, realDamage);
if (realDamage > 0) {
if (Monster* targetMonster = target->getMonster()) {
if (targetMonster->isRandomSteping()) {
targetMonster->setIgnoreFieldDamage(true);
targetMonster->updateMapCache();
}
}
}
if (spectators.empty()) {
map.getSpectators(spectators, targetPos, true, true);
}
addCreatureHealth(spectators, target);
message.primary.value = damage.primary.value;
message.secondary.value = damage.secondary.value;
uint8_t hitEffect;
if (message.primary.value) {
combatGetTypeInfo(damage.primary.type, target, message.primary.color, hitEffect);
if (hitEffect != CONST_ME_NONE) {
addMagicEffect(spectators, targetPos, hitEffect);
}
if (message.primary.color != TEXTCOLOR_NONE) {
std::ostringstream strPrimaryDamage;
strPrimaryDamage << message.primary.value;
addAnimatedText(strPrimaryDamage.str(), targetPos, message.primary.color);
}
}
if (message.secondary.value) {
combatGetTypeInfo(damage.secondary.type, target, message.secondary.color, hitEffect);
if (hitEffect != CONST_ME_NONE) {
addMagicEffect(spectators, targetPos, hitEffect);
}
if (message.secondary.color != TEXTCOLOR_NONE) {
std::ostringstream strSecondaryDamage;
strSecondaryDamage << message.secondary.value;
addAnimatedText(strSecondaryDamage.str(), targetPos, message.secondary.color);
}
}
if (message.primary.color != TEXTCOLOR_NONE || message.secondary.color != TEXTCOLOR_NONE) {
std::string damageString = std::to_string(realDamage) + (realDamage != 1 ? " hitpoints" : " hitpoint");
std::string spectatorMessage = ucfirst(target->getNameDescription()) + " loses " + damageString;
if (attacker) {
spectatorMessage += " due to ";
if (attacker == target) {
spectatorMessage += (targetPlayer ? (targetPlayer->getSex() == PLAYERSEX_FEMALE ? "her own attack" : "his own attack") : "its own attack");
} else {
spectatorMessage += "an attack by " + attacker->getNameDescription();
}
}
spectatorMessage += '.';
for (Creature* spectator : spectators) {
Player* tmpPlayer = spectator->getPlayer();
if (tmpPlayer->getPosition().z != targetPos.z) {
continue;
}
if (tmpPlayer == attackerPlayer && attackerPlayer != targetPlayer) {
message.type = MESSAGE_STATUS_DEFAULT;
message.text = ucfirst(target->getNameDescription()) + " loses " + damageString + " due to your attack.";
} else if (tmpPlayer == targetPlayer) {
message.type = MESSAGE_STATUS_DEFAULT;
if (!attacker) {
message.text = "You lose " + damageString + '.';
} else if (targetPlayer == attackerPlayer) {
message.text = "You lose " + damageString + " due to your own attack.";
} else {
message.text = "You lose " + damageString + " due to an attack by " + attacker->getNameDescription() + '.';
}
} else {
message.type = MESSAGE_STATUS_DEFAULT;
// TODO: Avoid copying spectatorMessage everytime we send to a spectator
message.text = spectatorMessage;
}
tmpPlayer->sendTextMessage(message);
}
}
}
return true;
}
bool Game::combatChangeMana(Creature* attacker, Creature* target, int32_t manaChange, CombatOrigin origin)
{
if (manaChange > 0) {
if (attacker) {
const Player* attackerPlayer = attacker->getPlayer();
if (attackerPlayer && attackerPlayer->getSkull() == SKULL_BLACK && target->getPlayer() && attackerPlayer->getSkullClient(target) == SKULL_NONE) {
return false;
}
}
if (origin != ORIGIN_NONE) {
const auto& events = target->getCreatureEvents(CREATURE_EVENT_MANACHANGE);
if (!events.empty()) {
for (CreatureEvent* creatureEvent : events) {
creatureEvent->executeManaChange(target, attacker, manaChange, origin);
}
return combatChangeMana(attacker, target, manaChange, ORIGIN_NONE);
}
}
target->changeMana(manaChange);
} else {
const Position& targetPos = target->getPosition();
if (!target->isAttackable()) {
if (!target->isInGhostMode()) {
addMagicEffect(targetPos, CONST_ME_POFF);
}
return false;
}
Player* attackerPlayer;
if (attacker) {
attackerPlayer = attacker->getPlayer();
} else {
attackerPlayer = nullptr;
}
Player* targetPlayer = target->getPlayer();
if (attackerPlayer && targetPlayer && attackerPlayer->getSkull() == SKULL_BLACK && attackerPlayer->getSkullClient(targetPlayer) == SKULL_NONE) {
return false;
}
int32_t manaLoss = std::min<int32_t>(target->getMana(), -manaChange);
BlockType_t blockType = target->blockHit(attacker, COMBAT_MANADRAIN, manaLoss);
if (blockType != BLOCK_NONE) {
addMagicEffect(targetPos, CONST_ME_POFF);
return false;
}
if (manaLoss <= 0) {
return true;
}
if (origin != ORIGIN_NONE) {
const auto& events = target->getCreatureEvents(CREATURE_EVENT_MANACHANGE);
if (!events.empty()) {
for (CreatureEvent* creatureEvent : events) {
creatureEvent->executeManaChange(target, attacker, manaChange, origin);
}
return combatChangeMana(attacker, target, manaChange, ORIGIN_NONE);
}
}
target->drainMana(attacker, manaLoss);
std::string damageString = std::to_string(manaLoss);
std::string spectatorMessage = ucfirst(target->getNameDescription()) + " loses " + damageString + " mana";
if (attacker) {
spectatorMessage += " due to ";
if (attacker == target) {
spectatorMessage += (targetPlayer ? (targetPlayer->getSex() == PLAYERSEX_FEMALE ? "her own attack" : "his own attack") : "its own attack");
} else {
spectatorMessage += "an attack by " + attacker->getNameDescription();
}
}
spectatorMessage += '.';
TextMessage message;
std::ostringstream strManaLoss;
strManaLoss << manaLoss;
addAnimatedText(strManaLoss.str(), targetPos, TEXTCOLOR_BLUE);
SpectatorHashSet spectators;
map.getSpectators(spectators, targetPos, false, true);
for (Creature* spectator : spectators) {
Player* tmpPlayer = spectator->getPlayer();
if (tmpPlayer == attackerPlayer && attackerPlayer != targetPlayer) {
message.type = MESSAGE_STATUS_DEFAULT;
message.text = ucfirst(target->getNameDescription()) + " loses " + damageString + " mana due to your attack.";
} else if (tmpPlayer == targetPlayer) {
message.type = MESSAGE_STATUS_DEFAULT;
if (!attacker) {
message.text = "You lose " + damageString + " mana.";
} else if (targetPlayer == attackerPlayer) {
message.text = "You lose " + damageString + " mana due to your own attack.";
} else {
message.text = "You lose " + damageString + " mana due to an attack by " + attacker->getNameDescription() + '.';
}
} else {
message.type = MESSAGE_STATUS_DEFAULT;
message.text = spectatorMessage;
}
tmpPlayer->sendTextMessage(message);
}
}
return true;
}
Last edited: