Jump to content

Trying to understand where are spells defined


Guest lordfrikk

Recommended Posts

Hey,

new guy. I was trying to delve a little into Mangos source. I would like to do simple fixes, which would allow other power C++ coders to focus on those really important things.

This is how I thought I'd start - I'll find a spell I know does work, then I'll find it in the Mangos source and try to understand what needs to be written where for the spell to function properly. I chose 1659 (Noggenfogger effect, which makes you small). I found and understood how the spell is randomly chosen when you drink the elixir, but I can't seem to find how it's done that it makes you small! What I found so far is only one comment next to SPELL_AURA_MOD_SCALE and then in SpellMgr.cpp. I THINK this particular spells work in generic way, ie. there is no code needed for similar spells, you just need to tell the client to apply the scale aura and parameter which says how much it will make you smaller/bigger. But that has to be defines somewhere, right?

Another spell I know that works is 18661, but I don't understand how.

Link to comment
Share on other sites

If you look to the entry for the Noggenfogger Elixir's spell (http://www.wowhead.com/?spell=16589) you will see that it has the effect Dummy. If you look through SpellEffects.cpp, you will eventually come across void Spell::EffectDummy(uint32 i) scroll through this, and you will find this code:

                case 16589:                                 // Noggenfogger Elixir
               {
                   if(m_caster->GetTypeId() != TYPEID_PLAYER)
                       return;

                   uint32 spell_id = 0;
                   switch(urand(1, 3))
                   {
                       case 1: spell_id = 16595; break;
                       case 2: spell_id = 16593; break;
                       default:spell_id = 16591; break;
                   }

                   m_caster->CastSpell(m_caster, spell_id, true, NULL);
                   return;
               }

As you can see, it randomly selects one of the effects spells for the Noggenfogger Elixir and applies it to the player. This is basically how it's done: spells that need server-side scripting are scattered about in the spell files of the server. You can usually find them by looking up their effects.

There are a few exceptions, however. Spells with the effect Script are done in the database. Dummy spells can be scripted with an external scripting module (only master branch, not mangos-0.12)

Link to comment
Share on other sites

THANK YOU for you reply. I get the code you posted and I also managed to find it before I posted. Effects are randomly chosen and then cast. Ok. If I understand It right, then spells like 16595, which have for examle Apply Aura: Mod Scale

in their description are always working because they're defined in DBC files?

What I wanted to know how are working spells that require some item to be used on something/somewhere? Do they fail to send quest credit?

Example: 45995

This spell does NOTHING. It has to apply 2 auras (stun and scale) and then it will trigger another spell which (I guess) will make the quest complete (let's not discuss how to make the character bend over etc. as written in quest comments). I see that 45997 is supposed to apply Quest Complete (11719), but it just doesn't. So how do I go about this?

Link to comment
Share on other sites

As you may have already discovered, wowhead says that "Requires You to be standing next to Bloodmage Laurith at the Bloodspore Plains."

You also get this message ingame if you try to cast it while not standing near a gameobject that it needs.

It is due to a field called RequireSpellFocus that is defined for this spell in Spell.dbc.

The check related to this you'll find in Spell::CheckItems() in Spell.cpp but you might need to add the gameobject for it on the right place to solve the problem. Anyway to show how it actually works i paste the code here:

    // check spell focus object
   if(m_spellInfo->RequiresSpellFocus)
   {
       CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY()));
       Cell cell(p);
       cell.data.Part.reserved = ALL_DISTRICT;

       GameObject* ok = NULL;
       MaNGOS::GameObjectFocusCheck go_check(m_caster,m_spellInfo->RequiresSpellFocus);
       MaNGOS::GameObjectSearcher<MaNGOS::GameObjectFocusCheck> checker(m_caster, ok, go_check);

       TypeContainerVisitor<MaNGOS::GameObjectSearcher<MaNGOS::GameObjectFocusCheck>, GridTypeMapContainer > object_checker(checker);
       CellLock<GridReadGuard> cell_lock(cell, p);
       cell_lock->Visit(cell_lock, object_checker, *m_caster->GetMap());

       if(!ok)
           return SPELL_FAILED_REQUIRES_SPELL_FOCUS;

       focusObject = ok;                                   // game object found in range
   }

Well, finding this will still not solve your problem. If you don't have you'll probably have to place the gamobject there, but you still don't have the id so let's take a look at the code that 'defines' the gamobject to be searched. It is actaully a searcher class:

    class GameObjectFocusCheck
   {
       public:
           GameObjectFocusCheck(Unit const* unit,uint32 focusId) : i_unit(unit), i_focusId(focusId) {}
           bool operator()(GameObject* go) const
           {
               if(go->GetGOInfo()->type != GAMEOBJECT_TYPE_SPELL_FOCUS)
                   return false;

               if(go->GetGOInfo()->spellFocus.focusId != i_focusId)
                   return false;

               float dist = go->GetGOInfo()->spellFocus.dist;

               return go->IsWithinDistInMap(i_unit, dist);
           }
       private:
           Unit const* i_unit;
           uint32 i_focusId;
   };

GAMEOBJET_TYPE_SPELLFOCUS = 8. This means that you'll have to search your gameobject template for a gamobject of type 8 and for the corresponding SpellFocusId which is data0 and in this case equals 1499 (from Spell.dbc).

So, by a query like:

SELECT entry FROM gameobject_template WHERE type=8 AND data0=1499;

You'll surely get the gamobject that you need to place there to make the quest working as intended.

Hopefully this solves it, and was enough detailed.

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use