Refactor message functions

This commit is contained in:
Akkadius
2019-08-11 00:14:02 -05:00
parent 57354579aa
commit 9f25c9070c
38 changed files with 814 additions and 579 deletions
+102 -96
View File
@@ -180,9 +180,9 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot,
Log(Logs::Detail, Logs::Spells, "Spell casting canceled: not able to cast now. Valid? %d, casting %d, waiting? %d, spellend? %d, stunned? %d, feared? %d, mezed? %d, silenced? %d, amnesiad? %d",
IsValidSpell(spell_id), casting_spell_id, delaytimer, spellend_timer.Enabled(), IsStunned(), IsFeared(), IsMezzed(), IsSilenced(), IsAmnesiad() );
if(IsSilenced() && !IsDiscipline(spell_id))
Message_StringID(Chat::Red, SILENCED_STRING);
MessageString(Chat::Red, SILENCED_STRING);
if(IsAmnesiad() && IsDiscipline(spell_id))
Message_StringID(Chat::Red, MELEE_SILENCE);
MessageString(Chat::Red, MELEE_SILENCE);
if(IsClient())
CastToClient()->SendSpellBarEnable(spell_id);
if(casting_spell_id && IsNPC())
@@ -197,7 +197,7 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot,
int chance = CastToClient()->GetFocusEffect(focusFcMute, spell_id);//Client only
if (zone->random.Roll(chance)) {
Message_StringID(Chat::Red, SILENCED_STRING);
MessageString(Chat::Red, SILENCED_STRING);
if(IsClient())
CastToClient()->SendSpellBarEnable(spell_id);
return(false);
@@ -205,7 +205,7 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot,
}
if(IsDetrimentalSpell(spell_id) && !zone->CanDoCombat()){
Message_StringID(Chat::Red, SPELL_WOULDNT_HOLD);
MessageString(Chat::Red, SPELL_WOULDNT_HOLD);
if(IsClient())
CastToClient()->SendSpellBarEnable(spell_id);
if(casting_spell_id && IsNPC())
@@ -257,7 +257,7 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot,
database.SetHackerFlag(CastToClient()->AccountName(), CastToClient()->GetCleanName(), "Clicking equip-only item with an invalid class");
}
else {
Message_StringID(Chat::Red, MUST_EQUIP_ITEM);
MessageString(Chat::Red, MUST_EQUIP_ITEM);
}
return(false);
}
@@ -276,7 +276,7 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot,
}
else
{
Message_StringID(Chat::Red, CANNOT_USE_ITEM);
MessageString(Chat::Red, CANNOT_USE_ITEM);
}
}
return(false);
@@ -289,7 +289,7 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot,
database.SetHackerFlag(CastToClient()->AccountName(), CastToClient()->GetCleanName(), "Clicking equip-only item without equiping it");
}
else {
Message_StringID(Chat::Red, MUST_EQUIP_ITEM);
MessageString(Chat::Red, MUST_EQUIP_ITEM);
}
return(false);
}
@@ -370,18 +370,18 @@ bool Mob::DoCastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot,
Mob::SetMana(GetMana() - use_mana); // We send StopCasting which will update mana
StopCasting();
Message_StringID(Chat::SpellFailure, fizzle_msg);
MessageString(Chat::SpellFailure, fizzle_msg);
/**
* Song Failure message
*/
entity_list.FilteredMessageClose_StringID(
entity_list.FilteredMessageCloseString(
this,
true,
RuleI(Range, SpellMessages),
RuleI(Range, SpellMessages),
Chat::SpellFailure,
(IsClient() ? FilterPCSpells : FilterNPCSpells),
(fizzle_msg == MISS_NOTE ? MISSED_NOTE_OTHER : SPELL_FIZZLE_OTHER),
(fizzle_msg == MISS_NOTE ? MISSED_NOTE_OTHER : SPELL_FIZZLE_OTHER),
/*
MessageFormat: You miss a note, bringing your song to a close! (if missed note)
MessageFormat: A missed note brings %1's song to a close!
@@ -428,7 +428,7 @@ bool Mob::DoCastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot,
Log(Logs::Detail, Logs::Spells, "Spell Error: no target. spell=%d", spell_id);
if(IsClient()) {
//clients produce messages... npcs should not for this case
Message_StringID(Chat::Red, SPELL_NEED_TAR);
MessageString(Chat::Red, SPELL_NEED_TAR);
InterruptSpell();
} else {
InterruptSpell(0, 0, 0); //the 0 args should cause no messages
@@ -461,7 +461,7 @@ bool Mob::DoCastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot,
Log(Logs::Detail, Logs::Spells, "Spell Error not enough mana spell=%d mymana=%d cost=%d\n", spell_id, my_curmana, mana_cost);
if(IsClient()) {
//clients produce messages... npcs should not for this case
Message_StringID(Chat::Red, INSUFFICIENT_MANA);
MessageString(Chat::Red, INSUFFICIENT_MANA);
InterruptSpell();
} else {
InterruptSpell(0, 0, 0); //the 0 args should cause no messages
@@ -518,7 +518,7 @@ bool Mob::DoCastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot,
if (IsClient() && slot == CastingSlot::Item && item_slot != 0xFFFFFFFF) {
auto item = CastToClient()->GetInv().GetItem(item_slot);
if (item && item->GetItem())
Message_StringID(Chat::Spells, BEGINS_TO_GLOW, item->GetItem()->Name);
MessageString(Chat::Spells, BEGINS_TO_GLOW, item->GetItem()->Name);
}
if (!DoCastingChecks()) {
@@ -575,13 +575,13 @@ bool Mob::DoCastingChecks()
if (spell_target && spells[spell_id].targettype != ST_Self && !spell_target->CheckSpellLevelRestriction(spell_id)) {
Log(Logs::Detail, Logs::Spells, "Spell %d failed: recipient did not meet the level restrictions", spell_id);
if (!IsBardSong(spell_id))
Message_StringID(Chat::SpellFailure, SPELL_TOO_POWERFUL);
MessageString(Chat::SpellFailure, SPELL_TOO_POWERFUL);
return false;
}
}
if (spells[spell_id].zonetype == 1 && !zone->CanCastOutdoor()) {
Message_StringID(Chat::Red, CAST_OUTDOORS);
MessageString(Chat::Red, CAST_OUTDOORS);
return false;
}
@@ -680,7 +680,7 @@ void Client::CheckSongSkillIncrease(uint16 spell_id){
if (GetRawSkill(EQEmu::skills::SkillPercussionInstruments) > 0) // no skill increases if not trained in the instrument
CheckIncreaseSkill(EQEmu::skills::SkillPercussionInstruments, nullptr, -15);
else
Message_StringID(Chat::Red,NO_INSTRUMENT_SKILL); // tell the client that they need instrument training
MessageString(Chat::Red,NO_INSTRUMENT_SKILL); // tell the client that they need instrument training
}
else
CheckIncreaseSkill(EQEmu::skills::SkillSinging, nullptr, -15);
@@ -690,7 +690,7 @@ void Client::CheckSongSkillIncrease(uint16 spell_id){
if (GetRawSkill(EQEmu::skills::SkillStringedInstruments) > 0)
CheckIncreaseSkill(EQEmu::skills::SkillStringedInstruments, nullptr, -15);
else
Message_StringID(Chat::Red,NO_INSTRUMENT_SKILL);
MessageString(Chat::Red,NO_INSTRUMENT_SKILL);
}
else
CheckIncreaseSkill(EQEmu::skills::SkillSinging, nullptr, -15);
@@ -700,7 +700,7 @@ void Client::CheckSongSkillIncrease(uint16 spell_id){
if (GetRawSkill(EQEmu::skills::SkillWindInstruments) > 0)
CheckIncreaseSkill(EQEmu::skills::SkillWindInstruments, nullptr, -15);
else
Message_StringID(Chat::Red,NO_INSTRUMENT_SKILL);
MessageString(Chat::Red,NO_INSTRUMENT_SKILL);
}
else
CheckIncreaseSkill(EQEmu::skills::SkillSinging, nullptr, -15);
@@ -710,7 +710,7 @@ void Client::CheckSongSkillIncrease(uint16 spell_id){
if (GetRawSkill(EQEmu::skills::SkillBrassInstruments) > 0)
CheckIncreaseSkill(EQEmu::skills::SkillBrassInstruments, nullptr, -15);
else
Message_StringID(Chat::Red,NO_INSTRUMENT_SKILL);
MessageString(Chat::Red,NO_INSTRUMENT_SKILL);
}
else
CheckIncreaseSkill(EQEmu::skills::SkillSinging, nullptr, -15);
@@ -861,7 +861,7 @@ void Mob::InterruptSpell(uint16 message, uint16 color, uint16 spellid)
}
if(casting_spell_aa_id && IsClient()) { //Rest AA Timer on failed cast
CastToClient()->Message_StringID(Chat::SpellFailure, ABILITY_FAILED);
CastToClient()->MessageString(Chat::SpellFailure, ABILITY_FAILED);
CastToClient()->ResetAlternateAdvancementTimer(casting_spell_aa_id);
}
@@ -940,7 +940,7 @@ void Mob::StopCasting()
if (IsClient()) {
auto c = CastToClient();
if (casting_spell_aa_id) { //Rest AA Timer on failed cast
c->Message_StringID(Chat::SpellFailure, ABILITY_FAILED);
c->MessageString(Chat::SpellFailure, ABILITY_FAILED);
c->ResetAlternateAdvancementTimer(casting_spell_aa_id);
}
@@ -969,7 +969,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo
if(IsClient() && slot != CastingSlot::Item && slot != CastingSlot::PotionBelt && spells[spell_id].recast_time > 1000) { // 10 is item
if(!CastToClient()->GetPTimers().Expired(&database, pTimerSpellStart + spell_id, false)) {
//should we issue a message or send them a spell gem packet?
Message_StringID(Chat::Red, SPELL_RECAST);
MessageString(Chat::Red, SPELL_RECAST);
Log(Logs::Detail, Logs::Spells, "Casting of %d canceled: spell reuse timer not expired", spell_id);
StopCasting();
return;
@@ -983,7 +983,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo
if(itm && itm->GetItem()->RecastDelay > 0)
{
if(!CastToClient()->GetPTimers().Expired(&database, (pTimerItemStart + itm->GetItem()->RecastType), false)) {
Message_StringID(Chat::Red, SPELL_RECAST);
MessageString(Chat::Red, SPELL_RECAST);
Log(Logs::Detail, Logs::Spells, "Casting of %d canceled: item spell reuse timer not expired", spell_id);
StopCasting();
return;
@@ -1015,7 +1015,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo
if (casting_spell_id != spell_id)
{
Log(Logs::Detail, Logs::Spells, "Casting of %d canceled: already casting", spell_id);
Message_StringID(Chat::Red,ALREADY_CASTING);
MessageString(Chat::Red,ALREADY_CASTING);
InterruptSpell();
return;
}
@@ -1133,8 +1133,14 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo
}
// if we got here, we regained concentration
regain_conc = true;
Message_StringID(Chat::Spells, REGAIN_AND_CONTINUE);
entity_list.MessageClose_StringID(this, true, RuleI(Range, SpellMessages), Chat::Spells, OTHER_REGAIN_CAST, this->GetCleanName());
MessageString(Chat::Spells, REGAIN_AND_CONTINUE);
entity_list.MessageCloseString(
this,
true,
RuleI(Range, SpellMessages),
Chat::Spells,
OTHER_REGAIN_CAST,
this->GetCleanName());
}
}
@@ -1170,7 +1176,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo
case 13000:
if(itembonuses.percussionMod == 0) { // check for the appropriate instrument type
HasInstrument = false;
c->Message_StringID(Chat::Red, SONG_NEEDS_DRUM); // send an error message if missing
c->MessageString(Chat::Red, SONG_NEEDS_DRUM); // send an error message if missing
}
break;
@@ -1178,7 +1184,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo
case 13001:
if(itembonuses.windMod == 0) {
HasInstrument = false;
c->Message_StringID(Chat::Red, SONG_NEEDS_WIND);
c->MessageString(Chat::Red, SONG_NEEDS_WIND);
}
break;
@@ -1186,7 +1192,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo
case 13011:
if(itembonuses.stringedMod == 0) {
HasInstrument = false;
c->Message_StringID(Chat::Red, SONG_NEEDS_STRINGS);
c->MessageString(Chat::Red, SONG_NEEDS_STRINGS);
}
break;
@@ -1194,7 +1200,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo
case 13012:
if(itembonuses.brassMod == 0) {
HasInstrument = false;
c->Message_StringID(Chat::Red, SONG_NEEDS_BRASS);
c->MessageString(Chat::Red, SONG_NEEDS_BRASS);
}
break;
@@ -1222,13 +1228,13 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo
{
if (!missingreags)
{
c->Message_StringID(Chat::Red, MISSING_SPELL_COMP);
c->MessageString(Chat::Red, MISSING_SPELL_COMP);
missingreags=true;
}
const EQEmu::ItemData *item = database.GetItem(component);
if(item) {
c->Message_StringID(Chat::Red, MISSING_SPELL_COMP_ITEM, item->Name);
c->MessageString(Chat::Red, MISSING_SPELL_COMP_ITEM, item->Name);
Log(Logs::Detail, Logs::Spells, "Spell %d: Canceled. Missing required reagent %s (%d)", spell_id, item->Name, component);
}
else {
@@ -1324,7 +1330,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo
if(IsClient() && fromaug && recastdelay > 0)
{
if(!CastToClient()->GetPTimers().Expired(&database, (pTimerItemStart + recasttype), false)) {
Message_StringID(Chat::Red, SPELL_RECAST);
MessageString(Chat::Red, SPELL_RECAST);
Log(Logs::Detail, Logs::Spells, "Casting of %d canceled: item spell reuse timer not expired", spell_id);
StopCasting();
return;
@@ -1502,7 +1508,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce
targetType = ST_Target;
if (spell_target && !spell_target->PassCastRestriction(true, spells[spell_id].CastRestriction)){
Message_StringID(Chat::Red,SPELL_NEED_TAR);
MessageString(Chat::Red,SPELL_NEED_TAR);
return false;
}
@@ -1512,7 +1518,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce
if (spell_target &&
((spell_target->IsNPC() && spell_target->IsEngaged()) ||
(spell_target->IsClient() && spell_target->CastToClient()->GetAggroCount()))) {
Message_StringID(Chat::Red, SPELL_NO_EFFECT); // Unsure correct string
MessageString(Chat::Red, SPELL_NO_EFFECT); // Unsure correct string
return false;
}
}
@@ -1520,9 +1526,9 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce
else if (IsBeneficialSpell(spell_id)) {
if ((IsNPC() && IsEngaged()) || (IsClient() && CastToClient()->GetAggroCount())) {
if (IsDiscipline(spell_id))
Message_StringID(Chat::Red, NO_ABILITY_IN_COMBAT);
MessageString(Chat::Red, NO_ABILITY_IN_COMBAT);
else
Message_StringID(Chat::Red, NO_CAST_IN_COMBAT);
MessageString(Chat::Red, NO_CAST_IN_COMBAT);
return false;
}
@@ -1535,7 +1541,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce
if (spell_target &&
((spell_target->IsNPC() && !spell_target->IsEngaged()) ||
(spell_target->IsClient() && !spell_target->CastToClient()->GetAggroCount()))) {
Message_StringID(Chat::Red, SPELL_NO_EFFECT); // Unsure correct string
MessageString(Chat::Red, SPELL_NO_EFFECT); // Unsure correct string
return false;
}
}
@@ -1543,9 +1549,9 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce
else if (IsBeneficialSpell(spell_id)) {
if ((IsNPC() && !IsEngaged()) || (IsClient() && !CastToClient()->GetAggroCount())) {
if (IsDiscipline(spell_id))
Message_StringID(Chat::Red, NO_ABILITY_OUT_OF_COMBAT);
MessageString(Chat::Red, NO_ABILITY_OUT_OF_COMBAT);
else
Message_StringID(Chat::Red, NO_CAST_OUT_OF_COMBAT);
MessageString(Chat::Red, NO_CAST_OUT_OF_COMBAT);
return false;
}
@@ -1582,9 +1588,9 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce
//invalid target
Log(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target of body type %d (undead)", spell_id, mob_body);
if(!spell_target)
Message_StringID(Chat::Red,SPELL_NEED_TAR);
MessageString(Chat::Red,SPELL_NEED_TAR);
else
Message_StringID(Chat::Red,CANNOT_AFFECT_NPC);
MessageString(Chat::Red,CANNOT_AFFECT_NPC);
return false;
}
CastAction = SingleTarget;
@@ -1596,7 +1602,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce
{
//invalid target
Log(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target of body type %d (summoned)", spell_id, mob_body);
Message_StringID(Chat::Red,SPELL_NEED_TAR);
MessageString(Chat::Red,SPELL_NEED_TAR);
return false;
}
CastAction = SingleTarget;
@@ -1611,7 +1617,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce
Log(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target of body type %d (summoned pet)",
spell_id, mob_body);
Message_StringID(Chat::Red, SPELL_NEED_TAR);
MessageString(Chat::Red, SPELL_NEED_TAR);
return false;
}
@@ -1635,9 +1641,9 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce
//invalid target
Log(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target of body type %d (want body Type %d)", spell_id, mob_body, target_bt);
if(!spell_target)
Message_StringID(Chat::Red,SPELL_NEED_TAR);
MessageString(Chat::Red,SPELL_NEED_TAR);
else
Message_StringID(Chat::Red,CANNOT_AFFECT_NPC);
MessageString(Chat::Red,CANNOT_AFFECT_NPC);
return false;
}
CastAction = SingleTarget;
@@ -1652,7 +1658,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce
if(!spell_target)
{
Log(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target (ldon object)", spell_id);
Message_StringID(Chat::Red,SPELL_NEED_TAR);
MessageString(Chat::Red,SPELL_NEED_TAR);
return false;
}
else
@@ -1660,14 +1666,14 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce
if(!spell_target->IsNPC())
{
Log(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target (normal)", spell_id);
Message_StringID(Chat::Red,SPELL_NEED_TAR);
MessageString(Chat::Red,SPELL_NEED_TAR);
return false;
}
if(spell_target->GetClass() != LDON_TREASURE)
{
Log(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target (normal)", spell_id);
Message_StringID(Chat::Red,SPELL_NEED_TAR);
MessageString(Chat::Red,SPELL_NEED_TAR);
return false;
}
}
@@ -1676,7 +1682,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce
if(!spell_target)
{
Log(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target (normal)", spell_id);
Message_StringID(Chat::Red,SPELL_NEED_TAR);
MessageString(Chat::Red,SPELL_NEED_TAR);
return false; // can't cast these unless we have a target
}
CastAction = SingleTarget;
@@ -1692,7 +1698,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce
if(!spell_target) message = SPELL_NEED_TAR;
else if(!spell_target->IsCorpse()) message = ONLY_ON_CORPSES;
else if(!spell_target->IsPlayerCorpse()) message = CORPSE_NOT_VALID;
Message_StringID(Chat::Red, message);
MessageString(Chat::Red, message);
return false;
}
CastAction = SingleTarget;
@@ -1704,7 +1710,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce
if(!spell_target)
{
Log(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target (no pet)", spell_id);
Message_StringID(Chat::Red,NO_PET);
MessageString(Chat::Red,NO_PET);
return false; // can't cast these unless we have a target
}
CastAction = SingleTarget;
@@ -1775,7 +1781,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce
if(!spell_target)
{
Log(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target (AOE)", spell_id);
Message_StringID(Chat::Red,SPELL_NEED_TAR);
MessageString(Chat::Red,SPELL_NEED_TAR);
return false;
}
ae_center = spell_target;
@@ -1800,7 +1806,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce
}
if (spell_target && spell_target->IsPet() && spells[spell_id].targettype == ST_GroupNoPets){
Message_StringID(Chat::Red,NO_CAST_ON_PET);
MessageString(Chat::Red,NO_CAST_ON_PET);
return false;
}
@@ -1812,7 +1818,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce
if(!spell_target)
{
Log(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target (Group Required: Single Target)", spell_id);
Message_StringID(Chat::Red,SPELL_NEED_TAR);
MessageString(Chat::Red,SPELL_NEED_TAR);
return false;
}
@@ -1929,14 +1935,14 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce
if(group_id_caster == 0 || group_id_target == 0)
{
Log(Logs::Detail, Logs::Spells, "Spell %d canceled: Attempted to cast a Single Target Group spell on a ungrouped member.", spell_id);
Message_StringID(Chat::Red, TARGET_GROUP_MEMBER);
MessageString(Chat::Red, TARGET_GROUP_MEMBER);
return false;
}
if(group_id_caster != group_id_target)
{
Log(Logs::Detail, Logs::Spells, "Spell %d canceled: Attempted to cast a Single Target Group spell on a ungrouped member.", spell_id);
Message_StringID(Chat::Red, TARGET_GROUP_MEMBER);
MessageString(Chat::Red, TARGET_GROUP_MEMBER);
return false;
}
@@ -2030,7 +2036,7 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, CastingSlot slot, ui
if( spells[spell_id].zonetype == 1 && !zone->CanCastOutdoor()){
if(IsClient()){
if(!CastToClient()->GetGM()){
Message_StringID(Chat::Red, CAST_OUTDOORS);
MessageString(Chat::Red, CAST_OUTDOORS);
return false;
}
}
@@ -2112,14 +2118,14 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, CastingSlot slot, ui
if(!spells[spell_id].npc_no_los && spell_target && IsDetrimentalSpell(spell_id) && !CheckLosFN(spell_target) && !IsHarmonySpell(spell_id) && spells[spell_id].targettype != ST_TargetOptional)
{
Log(Logs::Detail, Logs::Spells, "Spell %d: cannot see target %s", spell_id, spell_target->GetName());
Message_StringID(Chat::Red,CANT_SEE_TARGET);
MessageString(Chat::Red,CANT_SEE_TARGET);
return false;
}
// check to see if target is a caster mob before performing a mana tap
if(spell_target && IsManaTapSpell(spell_id)) {
if(spell_target->GetCasterClass() == 'N') {
Message_StringID(Chat::Red, TARGET_NO_MANA);
MessageString(Chat::Red, TARGET_NO_MANA);
return false;
}
}
@@ -2143,13 +2149,13 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, CastingSlot slot, ui
if(dist2 > range2) {
//target is out of range.
Log(Logs::Detail, Logs::Spells, "Spell %d: Spell target is out of range (squared: %f > %f)", spell_id, dist2, range2);
Message_StringID(Chat::Red, TARGET_OUT_OF_RANGE);
MessageString(Chat::Red, TARGET_OUT_OF_RANGE);
return(false);
}
else if (dist2 < min_range2){
//target is too close range.
Log(Logs::Detail, Logs::Spells, "Spell %d: Spell target is too close (squared: %f < %f)", spell_id, dist2, min_range2);
Message_StringID(Chat::Red, TARGET_TOO_CLOSE);
MessageString(Chat::Red, TARGET_TOO_CLOSE);
return(false);
}
@@ -2164,13 +2170,13 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, CastingSlot slot, ui
if(dist2 > range2) {
//target is out of range.
Log(Logs::Detail, Logs::Spells, "Spell %d: Spell target is out of range (squared: %f > %f)", spell_id, dist2, range2);
Message_StringID(Chat::Red, TARGET_OUT_OF_RANGE);
MessageString(Chat::Red, TARGET_OUT_OF_RANGE);
return(false);
}
else if (dist2 < min_range2){
//target is too close range.
Log(Logs::Detail, Logs::Spells, "Spell %d: Spell target is too close (squared: %f < %f)", spell_id, dist2, min_range2);
Message_StringID(Chat::Red, TARGET_TOO_CLOSE);
MessageString(Chat::Red, TARGET_TOO_CLOSE);
return(false);
}
@@ -2520,7 +2526,7 @@ bool Mob::ApplyNextBardPulse(uint16 spell_id, Mob *spell_target, CastingSlot slo
if(spell_target && IsDetrimentalSpell(spell_id) && !CheckLosFN(spell_target))
{
Log(Logs::Detail, Logs::Spells, "Bard Song Pulse %d: cannot see target %s", spell_target->GetName());
Message_StringID(Chat::Red, CANT_SEE_TARGET);
MessageString(Chat::Red, CANT_SEE_TARGET);
return(false);
}
@@ -2535,7 +2541,7 @@ bool Mob::ApplyNextBardPulse(uint16 spell_id, Mob *spell_target, CastingSlot slo
if(dist2 > range2) {
//target is out of range.
Log(Logs::Detail, Logs::Spells, "Bard Song Pulse %d: Spell target is out of range (squared: %f > %f)", spell_id, dist2, range2);
Message_StringID(Chat::Red, TARGET_OUT_OF_RANGE);
MessageString(Chat::Red, TARGET_OUT_OF_RANGE);
return(false);
}
}
@@ -2894,7 +2900,7 @@ int Mob::CheckStackConflict(uint16 spellid1, int caster_level1, uint16 spellid2,
if (spellbonuses.Screech == 1) {
if (effect2 == SE_Screech && sp2.base[i] == -1) {
Message_StringID(Chat::SpellFailure, SCREECH_BUFF_BLOCK, sp2.name);
MessageString(Chat::SpellFailure, SCREECH_BUFF_BLOCK, sp2.name);
return -1;
}
}
@@ -3425,7 +3431,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r
if(IsDetrimentalSpell(spell_id) && !IsAttackAllowed(spelltar, true) && !IsResurrectionEffects(spell_id)) {
if(!IsClient() || !CastToClient()->GetGM()) {
Message_StringID(Chat::SpellFailure, SPELL_NO_HOLD);
MessageString(Chat::SpellFailure, SPELL_NO_HOLD);
return false;
}
}
@@ -3590,7 +3596,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r
{
if(spelltar->invisible)
{
spelltar->Message_StringID(Chat::SpellFailure, ALREADY_INVIS, GetCleanName());
spelltar->MessageString(Chat::SpellFailure, ALREADY_INVIS, GetCleanName());
safe_delete(action_packet);
return false;
}
@@ -3600,7 +3606,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r
{
if(spelltar->invisible_undead)
{
spelltar->Message_StringID(Chat::SpellFailure, ALREADY_INVIS, GetCleanName());
spelltar->MessageString(Chat::SpellFailure, ALREADY_INVIS, GetCleanName());
safe_delete(action_packet);
return false;
}
@@ -3610,7 +3616,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r
{
if(spelltar->invisible_animals)
{
spelltar->Message_StringID(Chat::SpellFailure, ALREADY_INVIS, GetCleanName());
spelltar->MessageString(Chat::SpellFailure, ALREADY_INVIS, GetCleanName());
safe_delete(action_packet);
return false;
}
@@ -3690,7 +3696,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r
Log(Logs::Detail, Logs::Spells, "Beneficial ae bard song %d can't take hold %s -> %s, IBA? %d", spell_id, GetName(), spelltar->GetName(), IsBeneficialAllowed(spelltar));
} else {
Log(Logs::Detail, Logs::Spells, "Beneficial spell %d can't take hold %s -> %s, IBA? %d", spell_id, GetName(), spelltar->GetName(), IsBeneficialAllowed(spelltar));
Message_StringID(Chat::SpellFailure, SPELL_NO_HOLD);
MessageString(Chat::SpellFailure, SPELL_NO_HOLD);
}
safe_delete(action_packet);
return false;
@@ -3700,7 +3706,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r
else if ( !IsAttackAllowed(spelltar, true) && !IsResurrectionEffects(spell_id)) // Detrimental spells - PVP check
{
Log(Logs::Detail, Logs::Spells, "Detrimental spell %d can't take hold %s -> %s", spell_id, GetName(), spelltar->GetName());
spelltar->Message_StringID(Chat::SpellFailure, YOU_ARE_PROTECTED, GetCleanName());
spelltar->MessageString(Chat::SpellFailure, YOU_ARE_PROTECTED, GetCleanName());
safe_delete(action_packet);
return false;
}
@@ -3737,7 +3743,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r
focus = CalcFocusEffect(focusBlockNextSpell, buffs[b].spellid, spell_id);
if(focus) {
CheckNumHitsRemaining(NumHit::MatchingSpells, b);
Message_StringID(Chat::SpellFailure, SPELL_WOULDNT_HOLD);
MessageString(Chat::SpellFailure, SPELL_WOULDNT_HOLD);
safe_delete(action_packet);
return false;
}
@@ -3786,7 +3792,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r
if (reflect_chance) {
if (RuleB(Spells, ReflectMessagesClose)) {
entity_list.MessageClose_StringID(
entity_list.MessageCloseString(
this, /* Sender */
false, /* Skip Sender */
RuleI(Range, SpellMessages), /* Range */
@@ -3797,7 +3803,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r
);
}
else {
Message_StringID(Chat::Spells, SPELL_REFLECT, GetCleanName(), spelltar->GetCleanName());
MessageString(Chat::Spells, SPELL_REFLECT, GetCleanName(), spelltar->GetCleanName());
}
CheckNumHitsRemaining(NumHit::ReflectSpell);
@@ -3829,12 +3835,12 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r
Log(Logs::Detail, Logs::Spells, "Spell %d was completely resisted by %s", spell_id, spelltar->GetName());
if (spells[spell_id].resisttype == RESIST_PHYSICAL){
Message_StringID(Chat::SpellFailure, PHYSICAL_RESIST_FAIL,spells[spell_id].name);
spelltar->Message_StringID(Chat::SpellFailure, YOU_RESIST, spells[spell_id].name);
MessageString(Chat::SpellFailure, PHYSICAL_RESIST_FAIL,spells[spell_id].name);
spelltar->MessageString(Chat::SpellFailure, YOU_RESIST, spells[spell_id].name);
}
else {
Message_StringID(Chat::SpellFailure, TARGET_RESISTED, spells[spell_id].name);
spelltar->Message_StringID(Chat::SpellFailure, YOU_RESIST, spells[spell_id].name);
MessageString(Chat::SpellFailure, TARGET_RESISTED, spells[spell_id].name);
spelltar->MessageString(Chat::SpellFailure, YOU_RESIST, spells[spell_id].name);
}
if (spelltar->IsAIControlled()) {
@@ -3899,7 +3905,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r
{
Log(Logs::Detail, Logs::Spells, "Spell %d failed: recipient did not meet the level restrictions", spell_id);
if(!IsBardSong(spell_id))
Message_StringID(Chat::SpellFailure, SPELL_TOO_POWERFUL);
MessageString(Chat::SpellFailure, SPELL_TOO_POWERFUL);
safe_delete(action_packet);
return false;
}
@@ -3911,7 +3917,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r
// spell. It's most likely a buff that can't stack.
Log(Logs::Detail, Logs::Spells, "Spell %d could not apply its effects %s -> %s\n", spell_id, GetName(), spelltar->GetName());
if(casting_spell_aa_id)
Message_StringID(Chat::SpellFailure, SPELL_NO_HOLD);
MessageString(Chat::SpellFailure, SPELL_NO_HOLD);
safe_delete(action_packet);
return false;
}
@@ -3998,7 +4004,7 @@ void Corpse::CastRezz(uint16 spellid, Mob* Caster)
/*
if(!can_rez) {
if(Caster && Caster->IsClient())
Caster->Message_StringID(Chat::WhiteSmoke, CORPSE_TOO_OLD);
Caster->MessageString(Chat::WhiteSmoke, CORPSE_TOO_OLD);
return;
}
*/
@@ -4226,7 +4232,7 @@ bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster)
{
if(GetSpecialAbility(UNMEZABLE)) {
Log(Logs::Detail, Logs::Spells, "We are immune to Mez spells.");
caster->Message_StringID(Chat::SpellFailure, CANNOT_MEZ);
caster->MessageString(Chat::SpellFailure, CANNOT_MEZ);
int32 aggro = caster->CheckAggroAmount(spell_id, this);
if(aggro > 0) {
AddToHateList(caster, aggro);
@@ -4244,7 +4250,7 @@ bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster)
(!caster->IsNPC() || (caster->IsNPC() && !RuleB(Spells, NPCIgnoreBaseImmunity))))
{
Log(Logs::Detail, Logs::Spells, "Our level (%d) is higher than the limit of this Mez spell (%d)", GetLevel(), spells[spell_id].max[effect_index]);
caster->Message_StringID(Chat::SpellFailure, CANNOT_MEZ_WITH_SPELL);
caster->MessageString(Chat::SpellFailure, CANNOT_MEZ_WITH_SPELL);
AddToHateList(caster, 1,0,true,false,false,spell_id);
return true;
}
@@ -4254,7 +4260,7 @@ bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster)
if(GetSpecialAbility(UNSLOWABLE) && IsEffectInSpell(spell_id, SE_AttackSpeed))
{
Log(Logs::Detail, Logs::Spells, "We are immune to Slow spells.");
caster->Message_StringID(Chat::Red, IMMUNE_ATKSPEED);
caster->MessageString(Chat::Red, IMMUNE_ATKSPEED);
int32 aggro = caster->CheckAggroAmount(spell_id, this);
if(aggro > 0) {
AddToHateList(caster, aggro);
@@ -4270,7 +4276,7 @@ bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster)
effect_index = GetSpellEffectIndex(spell_id, SE_Fear);
if(GetSpecialAbility(UNFEARABLE)) {
Log(Logs::Detail, Logs::Spells, "We are immune to Fear spells.");
caster->Message_StringID(Chat::Red, IMMUNE_FEAR); // need to verify message type, not in MQ2Cast for easy look up
caster->MessageString(Chat::Red, IMMUNE_FEAR); // need to verify message type, not in MQ2Cast for easy look up
int32 aggro = caster->CheckAggroAmount(spell_id, this);
if(aggro > 0) {
AddToHateList(caster, aggro);
@@ -4281,13 +4287,13 @@ bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster)
} else if(IsClient() && caster->IsClient() && (caster->CastToClient()->GetGM() == false))
{
Log(Logs::Detail, Logs::Spells, "Clients cannot fear eachother!");
caster->Message_StringID(Chat::Red, IMMUNE_FEAR); // need to verify message type, not in MQ2Cast for easy look up
caster->MessageString(Chat::Red, IMMUNE_FEAR); // need to verify message type, not in MQ2Cast for easy look up
return true;
}
else if(GetLevel() > spells[spell_id].max[effect_index] && spells[spell_id].max[effect_index] != 0)
{
Log(Logs::Detail, Logs::Spells, "Level is %d, cannot be feared by this spell.", GetLevel());
caster->Message_StringID(Chat::Shout, FEAR_TOO_HIGH);
caster->MessageString(Chat::Shout, FEAR_TOO_HIGH);
int32 aggro = caster->CheckAggroAmount(spell_id, this);
if (aggro > 0) {
AddToHateList(caster, aggro);
@@ -4300,7 +4306,7 @@ bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster)
{
Message(Chat::Red, "Your are immune to fear.");
Log(Logs::Detail, Logs::Spells, "Clients has WarCry effect, immune to fear!");
caster->Message_StringID(Chat::Red, IMMUNE_FEAR); // need to verify message type, not in MQ2Cast for easy look up
caster->MessageString(Chat::Red, IMMUNE_FEAR); // need to verify message type, not in MQ2Cast for easy look up
return true;
}
}
@@ -4310,7 +4316,7 @@ bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster)
if(GetSpecialAbility(UNCHARMABLE))
{
Log(Logs::Detail, Logs::Spells, "We are immune to Charm spells.");
caster->Message_StringID(Chat::Red, CANNOT_CHARM); // need to verify message type, not in MQ2Cast for easy look up
caster->MessageString(Chat::Red, CANNOT_CHARM); // need to verify message type, not in MQ2Cast for easy look up
int32 aggro = caster->CheckAggroAmount(spell_id, this);
if(aggro > 0) {
AddToHateList(caster, aggro);
@@ -4336,7 +4342,7 @@ bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster)
if(GetLevel() > spells[spell_id].max[effect_index] && spells[spell_id].max[effect_index] != 0)
{
Log(Logs::Detail, Logs::Spells, "Our level (%d) is higher than the limit of this Charm spell (%d)", GetLevel(), spells[spell_id].max[effect_index]);
caster->Message_StringID(Chat::Red, CANNOT_CHARM_YET); // need to verify message type, not in MQ2Cast for easy look up<Paste>
caster->MessageString(Chat::Red, CANNOT_CHARM_YET); // need to verify message type, not in MQ2Cast for easy look up<Paste>
AddToHateList(caster, 1,0,true,false,false,spell_id);
return true;
}
@@ -4351,7 +4357,7 @@ bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster)
{
if(GetSpecialAbility(UNSNAREABLE)) {
Log(Logs::Detail, Logs::Spells, "We are immune to Snare spells.");
caster->Message_StringID(Chat::Red, IMMUNE_MOVEMENT);
caster->MessageString(Chat::Red, IMMUNE_MOVEMENT);
int32 aggro = caster->CheckAggroAmount(spell_id, this);
if(aggro > 0) {
AddToHateList(caster, aggro);
@@ -4367,7 +4373,7 @@ bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster)
if(this == caster)
{
Log(Logs::Detail, Logs::Spells, "You cannot lifetap yourself.");
caster->Message_StringID(Chat::SpellFailure, CANT_DRAIN_SELF);
caster->MessageString(Chat::SpellFailure, CANT_DRAIN_SELF);
return true;
}
}
@@ -4377,7 +4383,7 @@ bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster)
if(this == caster)
{
Log(Logs::Detail, Logs::Spells, "You cannot sacrifice yourself.");
caster->Message_StringID(Chat::SpellFailure, CANNOT_SAC_SELF);
caster->MessageString(Chat::SpellFailure, CANNOT_SAC_SELF);
return true;
}
}