Skip to content

Commit

Permalink
Core/Spells: Fix Aspect of the Beast
Browse files Browse the repository at this point in the history
Closes #462
Closes #2814
  • Loading branch information
Warpten authored and tobmaps committed Aug 30, 2011
1 parent aa85553 commit 5d0a2b6
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 4 deletions.
3 changes: 3 additions & 0 deletions sql/updates/world/2011_08_30_00_world_spell_script_names.sql
@@ -0,0 +1,3 @@
DELETE FROM `spell_script_names` WHERE `spell_id`=13161;
INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES
(13161, 'spell_hun_aspect_of_the_beast');
4 changes: 2 additions & 2 deletions src/server/game/Entities/Unit/Unit.h
Expand Up @@ -174,7 +174,7 @@ enum UnitStandFlags
{
UNIT_STAND_FLAGS_UNK1 = 0x01,
UNIT_STAND_FLAGS_CREEP = 0x02,
UNIT_STAND_FLAGS_UNK3 = 0x04,
UNIT_STAND_FLAGS_UNTRACKABLE = 0x04,
UNIT_STAND_FLAGS_UNK4 = 0x08,
UNIT_STAND_FLAGS_UNK5 = 0x10,
UNIT_STAND_FLAGS_ALL = 0xFF
Expand All @@ -185,7 +185,7 @@ enum UnitBytes1_Flags
{
UNIT_BYTE1_FLAG_ALWAYS_STAND = 0x01,
UNIT_BYTE1_FLAG_UNK_2 = 0x02,
UNIT_BYTE1_FLAG_UNTRACKABLE = 0x04,
UNIT_BYTE1_FLAG_UNK_3 = 0x04,
UNIT_BYTE1_FLAG_ALL = 0xFF
};

Expand Down
4 changes: 2 additions & 2 deletions src/server/game/Spells/Auras/SpellAuraEffects.cpp
Expand Up @@ -2751,13 +2751,13 @@ void AuraEffect::HandleAuraUntrackable(AuraApplication const* aurApp, uint8 mode
Unit* target = aurApp->GetTarget();

if (apply)
target->SetByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_UNTRACKABLE);
target->SetByteFlag(UNIT_FIELD_BYTES_1, 2, UNIT_STAND_FLAGS_UNTRACKABLE);
else
{
// do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
if (target->HasAuraType(GetAuraType()))
return;
target->RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_UNTRACKABLE);
target->RemoveByteFlag(UNIT_FIELD_BYTES_1, 2, UNIT_STAND_FLAGS_UNTRACKABLE);
}
}

Expand Down
53 changes: 53 additions & 0 deletions src/server/scripts/Spells/spell_hunter.cpp
Expand Up @@ -39,6 +39,58 @@ enum HunterSpells
HUNTER_SPELL_CHIMERA_SHOT_SERPENT = 53353,
HUNTER_SPELL_CHIMERA_SHOT_VIPER = 53358,
HUNTER_SPELL_CHIMERA_SHOT_SCORPID = 53359,
HUNTER_SPELL_ASPECT_OF_THE_BEAST_PET = 61669,
};

// 13161 Aspect of the Beast
class spell_hun_aspect_of_the_beast : public SpellScriptLoader
{
public:
spell_hun_aspect_of_the_beast() : SpellScriptLoader("spell_hun_aspect_of_the_beast") { }

class spell_hun_aspect_of_the_beast_AuraScript : public AuraScript
{
PrepareAuraScript(spell_hun_aspect_of_the_beast_AuraScript)
bool Validate(SpellInfo const* /*entry*/)
{
if (!sSpellMgr->GetSpellInfo(HUNTER_SPELL_ASPECT_OF_THE_BEAST_PET))
return false;
return true;
}

void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (!GetCaster())
return;

Unit* caster = GetCaster();
if (caster->ToPlayer())
if (Pet* pet = caster->ToPlayer()->GetPet())
pet->RemoveAurasDueToSpell(HUNTER_SPELL_ASPECT_OF_THE_BEAST_PET);
}

void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (!GetCaster())
return;

Unit* caster = GetCaster();
if (caster->ToPlayer())
if (Pet* pet = caster->ToPlayer()->GetPet())
caster->CastSpell(caster, HUNTER_SPELL_ASPECT_OF_THE_BEAST_PET, true);
}

void Register()
{
AfterEffectApply += AuraEffectApplyFn(spell_hun_aspect_of_the_beast_AuraScript::OnApply, EFFECT_0, SPELL_AURA_UNTRACKABLE, AURA_EFFECT_HANDLE_REAL);
AfterEffectRemove += AuraEffectRemoveFn(spell_hun_aspect_of_the_beast_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_UNTRACKABLE, AURA_EFFECT_HANDLE_REAL);
}
};

AuraScript *GetAuraScript() const
{
return new spell_hun_aspect_of_the_beast_AuraScript();
}
};

// 53209 Chimera Shot
Expand Down Expand Up @@ -512,6 +564,7 @@ class spell_hun_pet_carrion_feeder : public SpellScriptLoader

void AddSC_hunter_spell_scripts()
{
new spell_hun_aspect_of_the_beast();
new spell_hun_chimera_shot();
new spell_hun_invigoration();
new spell_hun_last_stand_pet();
Expand Down

5 comments on commit 5d0a2b6

@fredimachado
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx @kapoeira

@Warpten
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks to QAston for his tip about the unit flag and Shauren by giving a hint I couldn't exploit since I didn't know how to exploit it the good way :p

@obot
Copy link

@obot obot commented on 5d0a2b6 Aug 30, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  •            if (Pet\* pet = caster->ToPlayer()->GetPet())
    
    80
  •                caster->CastSpell(caster, HUNTER_SPELL_ASPECT_OF_THE_BEAST_PET, true);
    
    And another typo-fix commit =)

(Why do you call 'GetCaster' twice ?)

@Warpten
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the typo.

About GetCaster() it's an old habit, true i could use:

Unit* caster = GetCaster();
if (!caster) return;

But the difference is nearly non existent.

@obot
Copy link

@obot obot commented on 5d0a2b6 Aug 30, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or
if (Unit* caster = GetCaster())
if (caster->ToPlayer())
if (...)
...

And for the typo, I think it should be :
if (Pet* pet = caster->ToPlayer()->GetPet())
pet->CastSpell(...)
And not
caster->CastSpell(...)

at line 80.
And thank you for your work !

EDIT: I finaly understood this part, you are right !

Please sign in to comment.