Jump to content

The way official servers handle special spells.


Guest Toinan67

Recommended Posts

Hello,

I'm currently really (really, really) bored. And when I'm bored, I ask myself existential questions.

I'd like to know, if someone knows or is experienced enough to suppose it, how official servers handle "special spells". By "special spells" I mean spells which have a "Apply Aura : Dummy" or "Effect : Script Effect" or whatever that is not precise (such as "Effect : Modify Health, value : 8").

I've seen that the official core was written in C++, too. Do they handle it the way MaNGOS handles it? Like "case spellId : code; break;" ?

If they don't, why does MaNGOS does it like that? Wouldn't be a LOT better to have a really complete

list of SCRIPT_EFFECT_SOMETHING, and an automatic behavior even for "Apply Aura : Dummy" or "Effect : Script Effect" kind of spells?

I'm asking this because I'm quite...let's say "impressed" when I look at files such as SpellAuras.cpp or SpellEffects.cpp, with hundreds of "case spellId : specific behavior for this spell; break;"

I mean, I'm sure 80% of those "case" could be avoided with a "spell_aura_dummy" table or something like that.

Well, I just figured out there's a spell_scripts table (don't laugh.), for SPELL_EFFECT_SCRIPT_EFFECT. Anyway, why is there still "case" for script effects?

Thanks for sharing your knowledge!

Link to comment
Share on other sites

Basically what you are asking is : " Is MaNGOS coded the right way".... well if the devs knew all you asked i think MaNGOS would be at version 1.0 for quite some times.

What i mean is everybody here is "guessing" the core code looking at what we can (DBC, sniffer....).

I believe that some thing here are more efficient that the heavy snowfall did it and they have some code far better than here (obviously their core is complete....).

Link to comment
Share on other sites

Well, the general question was not really "Is MaNGOS coded the right way" (even if I understand you can think this).

I think that on this particular point, there are clear improvements that could be done on something that is very important to the game (spells).

I know devs have no idea how the official core is written, it was more like a rhetorical question ^^

Let's take an example in SpellAuras.cpp :

           case 32051:                                     // Soul Charge
           {
               if (m_removeMode == AURA_REMOVE_BY_EXPIRE)
                   target->CastSpell(target, 32057, true, NULL, this);

               return;
           }
           case 32052:                                     // Soul Charge
           {
               if (m_removeMode == AURA_REMOVE_BY_EXPIRE)
                   target->CastSpell(target, 32053, true, NULL, this);

               return;
           }
           case 32286:                                     // Focus Target Visual
           {
               if (m_removeMode == AURA_REMOVE_BY_EXPIRE)
                   target->CastSpell(target, 32301, true, NULL, this);

               return;
           }

Or in SpellEffects.cpp :

case 23074:                                 // Arcanite Dragonling
               {
                   if (!m_CastItem)
                       return;

                   m_caster->CastSpell(m_caster, 19804, true, m_CastItem);
                   return;
               }
               case 23075:                                 // Mithril Mechanical Dragonling
               {
                   if (!m_CastItem)
                       return;

                   m_caster->CastSpell(m_caster, 12749, true, m_CastItem);
                   return;
               }
               case 23076:                                 // Mechanical Dragonling
               {
                   if (!m_CastItem)
                       return;

                   m_caster->CastSpell(m_caster, 4073, true, m_CastItem);
                   return;
               }
               case 23133:                                 // Gnomish Battle Chicken
               {
                   if (!m_CastItem)
                       return;

                   m_caster->CastSpell(m_caster, 13166, true, m_CastItem);
                   return;
               }

I could find a lot more examples.

Is there no way to avoid such little "case", for example adding a spell_dummy table or something like that?

The core would be lighter, and implementing a new dummy spell would be no more than a SQL patch. Easier, no?

Link to comment
Share on other sites

Maybe you're right...

But I think the "perfect" way would be to have 0 hardcoded things (quite impossible at the moment I imagine).

The core should be there to execute what "something else" (opcodes, DB, ...) asks him to do. For opcodes, we have a sender, the client, and a receiver, the core, which acts according to them.

For creatures, we have a "sender", the DB (creature_* tables), and a receiver, the core, which creates creatures according to the DB content.

For those spells, we do not really have a sender...the core works with the core itself.

Look at all this :

EffectSchoolDMG, EffectDummy, EffectTriggerSpell, EffectTeleportUnits, EffectWeaponDmg, TriggerSpell, HandleAuraDummy, HandlePeriodicDamage, ...

All those methods have a specific harcoded behavior for dozens of spells, imo it is much more easy (to fix, create, modify, adjust, replace, delete) with a DB table well designed, which would become the "sender" in the example above. The problem is that this table may be huge and increase the ram-consumption of the core I believe.

I also believe that MaNGOS devs started this way (hardcoded things I mean), and today they don't want to "lose" time by modifying something that works well for everyone.

But someday we'll have a 50,000 lines "SpellEffects.cpp"...

Link to comment
Share on other sites

ok how u expect code to be in db? i mean srsly u cant put c++ scripts there... I tried once to group few similar spells (Spell::SelectMountByAreaAndSkill) but each spell still needed it's own special support - in this case related spell ids for different mounts..maybe spells need to have their own scripts in some way but i don't think it is related in any way to DB

I also believe that MaNGOS devs started this way (hardcoded things I mean),

hardcoded is done only when there is no other visible option to fix something..

and today they don't want to "lose" time by modifying something that works well for everyone.

really? why not look at commit log first?

Link to comment
Share on other sites

"Right from the horse's mouth", as the old saying goes. I've read where others have said Vladimir knows more of the MaNGOS code than anyone else, if not the entire core.

C++ might seem a bit cumbersome with so many CASE statements in the core code, but it really is the best possible way to implement it with the server structure being what it is. It might be better if you try not to think of Spell.cpp, SpellEffects.cpp, and SpellAuras.cpp so much as program code as something more like C++ scripts. ScriptDev2 uses C++ for scripting bosses and instances, but I suppose it's counter-intuitive to think MaNGOS might have its own internal scripting for some things.

Perhaps retail might use some sort of external script plug-ins, but I doubt it.

Link to comment
Share on other sites

ok how u expect code to be in db? i mean srsly u cant put c++ scripts there... I tried once to group few similar spells (Spell::SelectMountByAreaAndSkill) but each spell still needed it's own special support - in this case related spell ids for different mounts..maybe spells need to have their own scripts in some way but i don't think it is related in any way to DB

hardcoded is done only when there is no other visible option to fix something..

really? why not look at commit log first?

:o sorry i didn't want to make you react like that, it was really not criticism

I was not saying that you don't fix spells, I was saying that maybe you think the way those spells are handled is the best it could be at the moment. I know you recently made a huge commit (talking about this one).

I was just asking questions, and give my (noob?) opinion to this.

I look at commit log 3 times a day, I know you work very hard and again sorry if you felt "offensed"

"I mean srsly u cant put c++ scripts there" -> for me this would be the best! (not C++ scripts in DB, but data that the core could handle exactly how we want it)

dummy effects/auras named in like way because it not have standard implementation, and each spellid (or group) expected special code, this is not only just call another spell but often something different. In like case any DB table useless and not help.

I agree, not a standard implementation, each spell need special code. All I was saying is that maybe some part could be automatic. Of course a lot of spells would still need hardcoded things.

but I suppose it's counter-intuitive to think MaNGOS might have its own internal scripting for some things.

Perhaps retail might use some sort of external script plug-ins, but I doubt it.

Imo it's not counter-intuitive, but it is just my opinion and I wanted to know the "guys-who-know"'s opinion :)

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