Fixed instant 'Failed attempt' on gathering

This commit is contained in:
katz1 2018-04-13 09:32:08 +01:00 committed by Antz
parent ef91e6f31c
commit 4185e88803
2 changed files with 10 additions and 9 deletions

View File

@ -304,7 +304,7 @@ Spell::Spell(Unit* caster, SpellEntry const* info, bool triggered, ObjectGuid or
for (int i = 0; i < MAX_EFFECT_INDEX; ++i) for (int i = 0; i < MAX_EFFECT_INDEX; ++i)
{ m_currentBasePoints[i] = m_spellInfo->CalculateSimpleValue(SpellEffectIndex(i)); } { m_currentBasePoints[i] = m_spellInfo->CalculateSimpleValue(SpellEffectIndex(i)); }
m_spellState = SPELL_STATE_PREPARING; m_spellState = SPELL_STATE_CREATED;
m_castPositionX = m_castPositionY = m_castPositionZ = 0; m_castPositionX = m_castPositionY = m_castPositionZ = 0;
m_TriggerSpells.clear(); m_TriggerSpells.clear();
@ -2550,8 +2550,6 @@ void Spell::prepare(SpellCastTargets const* targets, Aura* triggeredByAura)
{ {
m_targets = *targets; m_targets = *targets;
m_spellState = SPELL_STATE_PREPARING;
m_castPositionX = m_caster->GetPositionX(); m_castPositionX = m_caster->GetPositionX();
m_castPositionY = m_caster->GetPositionY(); m_castPositionY = m_caster->GetPositionY();
m_castPositionZ = m_caster->GetPositionZ(); m_castPositionZ = m_caster->GetPositionZ();
@ -2595,6 +2593,8 @@ void Spell::prepare(SpellCastTargets const* targets, Aura* triggeredByAura)
return; return;
} }
m_spellState = SPELL_STATE_PREPARING;
// Prepare data for triggers // Prepare data for triggers
prepareDataForTriggerSystem(); prepareDataForTriggerSystem();
@ -4930,7 +4930,7 @@ SpellCastResult Spell::CheckCast(bool strict)
{ return SPELL_FAILED_SKILL_NOT_HIGH_ENOUGH; } { return SPELL_FAILED_SKILL_NOT_HIGH_ENOUGH; }
// chance for fail at orange skinning attempt // chance for fail at orange skinning attempt
if ((m_selfContainer && (*m_selfContainer) == this) && if (m_spellState != SPELL_STATE_CREATED &&
skillValue < sWorld.GetConfigMaxSkillValue() && skillValue < sWorld.GetConfigMaxSkillValue() &&
(ReqValue < 0 ? 0 : ReqValue) > irand(skillValue - 25, skillValue + 37)) (ReqValue < 0 ? 0 : ReqValue) > irand(skillValue - 25, skillValue + 37))
{ return SPELL_FAILED_TRY_AGAIN; } { return SPELL_FAILED_TRY_AGAIN; }
@ -4994,7 +4994,7 @@ SpellCastResult Spell::CheckCast(bool strict)
// chance for fail at orange mining/herb/LockPicking gathering attempt // chance for fail at orange mining/herb/LockPicking gathering attempt
// second check prevent fail at rechecks // second check prevent fail at rechecks
// Check must be executed at the end of the cast. // Check must be executed at the end of the cast.
if (m_executedCurrently && skillId != SKILL_NONE) if (m_spellState != SPELL_STATE_CREATED && skillId != SKILL_NONE)
{ {
bool canFailAtMax = skillId != SKILL_HERBALISM && skillId != SKILL_MINING; bool canFailAtMax = skillId != SKILL_HERBALISM && skillId != SKILL_MINING;

View File

@ -194,10 +194,11 @@ inline ByteBuffer& operator>> (ByteBuffer& buf, SpellCastTargetsReader const& ta
enum SpellState enum SpellState
{ {
SPELL_STATE_PREPARING = 0, // cast time delay period, non channeled spell SPELL_STATE_CREATED = 0, // just created
SPELL_STATE_CASTING = 1, // channeled time period spell casting state SPELL_STATE_PREPARING = 1, // cast time delay period, non channeled spell
SPELL_STATE_FINISHED = 2, // cast finished to success or fail SPELL_STATE_CASTING = 2, // channeled time period spell casting state
SPELL_STATE_DELAYED = 3 // spell casted but need time to hit target(s) SPELL_STATE_FINISHED = 3, // cast finished to success or fail
SPELL_STATE_DELAYED = 4 // spell casted but need time to hit target(s)
}; };
enum SpellTargets enum SpellTargets