aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/updates/world/2012_11_24_00_conditions.sql34
-rwxr-xr-xsrc/server/game/Conditions/ConditionMgr.cpp24
-rwxr-xr-xsrc/server/game/Conditions/ConditionMgr.h2
-rwxr-xr-xsrc/server/game/Miscellaneous/Language.h3
-rwxr-xr-xsrc/server/game/Spells/Spell.cpp15
-rw-r--r--src/server/scripts/Commands/cs_misc.cpp22
6 files changed, 70 insertions, 30 deletions
diff --git a/sql/updates/world/2012_11_24_00_conditions.sql b/sql/updates/world/2012_11_24_00_conditions.sql
new file mode 100644
index 00000000000..1a5e5963c8e
--- /dev/null
+++ b/sql/updates/world/2012_11_24_00_conditions.sql
@@ -0,0 +1,34 @@
+ALTER TABLE `conditions`
+ ADD COLUMN `ErrorType` MEDIUMINT(8) UNSIGNED DEFAULT 0 NOT NULL AFTER `NegativeCondition`;
+
+/*
+ * trinity_string
+ * 63 - You can't do that right now. -> SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW = 173
+ * 64 - You cannot use that item here. -> SPELL_CUSTOM_ERROR_CANT_USE_THAT_ITEM = 56
+ * SPELL_FAILED_INCORRECT_AREA = 39
+ * SPELL_CUSTOM_ERROR_CANT_CALL_WINTERGARDE_HERE = 26
+ * SPELL_CUSTOM_ERROR_MUST_TARGET_ICE_HEART_JORMUNGAR = 21
+ * SPELL_FAILED_BAD_TARGETS = 12
+ * 65 - You must reach level 58 to use this portal. -> SPELL_CUSTOM_ERROR_REQUIRES_LEVEL_58 = 66
+ * 97 - don't exist
+ * 1334 - Requires Maiden of Winter's Breath Lake -> SPELL_CUSTOM_ERROR_MUST_BE_CLOSE_TO_MAIDEN = 61
+ * 1335 - You can't use that right now -> SPELL_FAILED_INCORRECT_AREA = 39
+ * SPELL_FAILED_TARGET_AURASTATE = 111
+ */
+
+UPDATE `conditions` SET `ErrorType`=173, `ErrorTextId`=0 WHERE `ErrorType`=0 AND `ErrorTextId`=63;
+
+UPDATE `conditions` SET `ErrorType`=172, `ErrorTextId`=26 WHERE `SourceTypeOrReferenceId`=17 AND `SourceEntry`=48388;
+UPDATE `conditions` SET `ErrorType`= 39, `ErrorTextId`= 0 WHERE `SourceTypeOrReferenceId`=17 AND `SourceEntry`=43209;
+UPDATE `conditions` SET `ErrorType`=172, `ErrorTextId`=21 WHERE `SourceTypeOrReferenceId`=17 AND `SourceEntry`=47431;
+UPDATE `conditions` SET `ErrorType`= 12, `ErrorTextId`= 0 WHERE `SourceTypeOrReferenceId`=17 AND `SourceEntry`=34367;
+
+UPDATE `conditions` SET `ErrorType`=172, `ErrorTextId`=66 WHERE `ErrorType`=0 AND `ErrorTextId`=65;
+UPDATE `conditions` SET `ErrorType`=172, `ErrorTextId`=61 WHERE `ErrorType`=0 AND `ErrorTextId`=1334;
+UPDATE `conditions` SET `ErrorType`= 39, `ErrorTextId`=0 WHERE `ErrorType`=0 AND `ErrorTextId`=1335 AND `ConditionTypeOrReference`=23;
+UPDATE `conditions` SET `ErrorType`=111, `ErrorTextId`=0 WHERE `ErrorType`=0 AND `ErrorTextId`=1335 AND `ConditionTypeOrReference`=1;
+
+UPDATE `conditions` SET `ErrorTextId`=0 WHERE `ErrorType`=0 AND `ErrorTextId`=97;
+UPDATE `conditions` SET `ErrorTextId`=0 WHERE `ErrorType`=0 AND `SourceTypeOrReferenceId`=13;
+
+DELETE FROM `trinity_string` WHERE `entry` IN (63,64,65,97,1334,1335);
diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp
index 2f3cb0fbaaf..a27ddeda8ed 100755
--- a/src/server/game/Conditions/ConditionMgr.cpp
+++ b/src/server/game/Conditions/ConditionMgr.cpp
@@ -720,12 +720,11 @@ void ConditionMgr::LoadConditions(bool isReload)
}
QueryResult result = WorldDatabase.Query("SELECT SourceTypeOrReferenceId, SourceGroup, SourceEntry, SourceId, ElseGroup, ConditionTypeOrReference, ConditionTarget, "
- " ConditionValue1, ConditionValue2, ConditionValue3, NegativeCondition, ErrorTextId, ScriptName FROM conditions");
+ " ConditionValue1, ConditionValue2, ConditionValue3, NegativeCondition, ErrorType, ErrorTextId, ScriptName FROM conditions");
if (!result)
{
sLog->outError(LOG_FILTER_SQL, ">> Loaded 0 conditions. DB table `conditions` is empty!");
-
return;
}
@@ -736,19 +735,20 @@ void ConditionMgr::LoadConditions(bool isReload)
Field* fields = result->Fetch();
Condition* cond = new Condition();
- int32 iSourceTypeOrReferenceId = fields[0].GetInt32();
+ int32 iSourceTypeOrReferenceId = fields[0].GetInt32();
cond->SourceGroup = fields[1].GetUInt32();
cond->SourceEntry = fields[2].GetInt32();
cond->SourceId = fields[3].GetInt32();
cond->ElseGroup = fields[4].GetUInt32();
- int32 iConditionTypeOrReference = fields[5].GetInt32();
+ int32 iConditionTypeOrReference = fields[5].GetInt32();
cond->ConditionTarget = fields[6].GetUInt8();
cond->ConditionValue1 = fields[7].GetUInt32();
cond->ConditionValue2 = fields[8].GetUInt32();
cond->ConditionValue3 = fields[9].GetUInt32();
cond->NegativeCondition = fields[10].GetUInt8();
- cond->ErrorTextId = fields[11].GetUInt32();
- cond->ScriptId = sObjectMgr->GetScriptId(fields[12].GetCString());
+ cond->ErrorType = fields[11].GetUInt32();
+ cond->ErrorTextId = fields[12].GetUInt32();
+ cond->ScriptId = sObjectMgr->GetScriptId(fields[13].GetCString());
if (iConditionTypeOrReference >= 0)
cond->ConditionType = ConditionTypes(iConditionTypeOrReference);
@@ -825,6 +825,18 @@ void ConditionMgr::LoadConditions(bool isReload)
continue;
}
+ if (cond->ErrorType && cond->SourceType != CONDITION_SOURCE_TYPE_SPELL)
+ {
+ sLog->outError(LOG_FILTER_SQL, "Condition type %u entry %i can't have ErrorType (%u), set to 0!", uint32(cond->SourceType), cond->SourceEntry, cond->ErrorType);
+ cond->ErrorType = 0;
+ }
+
+ if (cond->ErrorTextId && !cond->ErrorType)
+ {
+ sLog->outError(LOG_FILTER_SQL, "Condition type %u entry %i has any ErrorType, ErrorTextId (%u) is set, set to 0!", uint32(cond->SourceType), cond->SourceEntry, cond->ErrorTextId);
+ cond->ErrorTextId = 0;
+ }
+
if (cond->SourceGroup)
{
bool valid = false;
diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h
index 7b0dc1f20bf..7ffb6ff584c 100755
--- a/src/server/game/Conditions/ConditionMgr.h
+++ b/src/server/game/Conditions/ConditionMgr.h
@@ -180,6 +180,7 @@ struct Condition
uint32 ConditionValue1;
uint32 ConditionValue2;
uint32 ConditionValue3;
+ uint32 ErrorType;
uint32 ErrorTextId;
uint32 ReferenceId;
uint32 ScriptId;
@@ -198,6 +199,7 @@ struct Condition
ConditionValue2 = 0;
ConditionValue3 = 0;
ReferenceId = 0;
+ ErrorType = 0;
ErrorTextId = 0;
ScriptId = 0;
NegativeCondition = false;
diff --git a/src/server/game/Miscellaneous/Language.h b/src/server/game/Miscellaneous/Language.h
index 5321202b256..df5f45622f8 100755
--- a/src/server/game/Miscellaneous/Language.h
+++ b/src/server/game/Miscellaneous/Language.h
@@ -86,8 +86,7 @@ enum TrinityStrings
LANG_CONNECTED_PLAYERS = 60,
LANG_ACCOUNT_ADDON = 61,
LANG_IMPROPER_VALUE = 62,
- LANG_CANT_DO_NOW = 63,
- // Room for more level 0 64-99 not used
+ // Room for more level 0 63-99 not used
// level 1 chat
LANG_GLOBAL_NOTIFY = 100,
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index cd1197dca86..867fa47977a 100755
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -4866,17 +4866,12 @@ SpellCastResult Spell::CheckCast(bool strict)
ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_SPELL, m_spellInfo->Id);
if (!conditions.empty() && !sConditionMgr->IsObjectMeetToConditions(condInfo, conditions))
{
- // send error msg to player if condition failed and text message available
- // TODO: using WorldSession::SendNotification is not blizzlike
- if (Player* playerCaster = m_caster->ToPlayer())
+ // mLastFailedCondition can be NULL if there was an error processing the condition in Condition::Meets (i.e. wrong data for ConditionTarget or others)
+ if (condInfo.mLastFailedCondition && condInfo.mLastFailedCondition->ErrorType)
{
- // mLastFailedCondition can be NULL if there was an error processing the condition in Condition::Meets (i.e. wrong data for ConditionTarget or others)
- if (playerCaster->GetSession() && condInfo.mLastFailedCondition
- && condInfo.mLastFailedCondition->ErrorTextId)
- {
- playerCaster->GetSession()->SendNotification(condInfo.mLastFailedCondition->ErrorTextId);
- return SPELL_FAILED_DONT_REPORT;
- }
+ if (condInfo.mLastFailedCondition->ErrorType == SPELL_FAILED_CUSTOM_ERROR)
+ m_customError = SpellCustomErrors(condInfo.mLastFailedCondition->ErrorTextId);
+ return SpellCastResult(condInfo.mLastFailedCondition->ErrorType);
}
if (!condInfo.mLastFailedCondition || !condInfo.mLastFailedCondition->ConditionTarget)
return SPELL_FAILED_CASTER_AURASTATE;
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
index 5e54778b14a..c701c4f350c 100644
--- a/src/server/scripts/Commands/cs_misc.cpp
+++ b/src/server/scripts/Commands/cs_misc.cpp
@@ -937,16 +937,9 @@ public:
//No args required for players
if (handler->GetSession() && AccountMgr::IsPlayerAccount(handler->GetSession()->GetSecurity()))
{
- Player* player = handler->GetSession()->GetPlayer();
- if (player->isInFlight() || player->isInCombat())
- {
- handler->SendSysMessage(LANG_CANT_DO_NOW);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- //7355: "Stuck"
- player->CastSpell(player, 7355, false);
+ // 7355: "Stuck"
+ if (Player* player = handler->GetSession()->GetPlayer())
+ player->CastSpell(player, 7355, false);
return true;
}
@@ -967,8 +960,13 @@ public:
if (player->isInFlight() || player->isInCombat())
{
- handler->SendSysMessage(LANG_CANT_DO_NOW);
- handler->SetSentErrorMessage(true);
+ SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(7355);
+ if (!spellInfo)
+ return false;
+
+ if (Player* caster = handler->GetSession()->GetPlayer())
+ Spell::SendCastResult(caster, spellInfo, 0, SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW);
+
return false;
}