Scripting Questions

Hey guys,

I have couple of questions about the way trinity handles scripts.

The gossip scripts have a OnGossipSelect method which has a parameter uint32 sender what is the use of it? Furthermore, the gossip_example.cpp script sends a sender parameter as GOSSIP_SENDER_MAIN and then has a check in the OnGossipSelect method to make sure that sender is equal to GOSSIP_SENDER_MAIN. Why does the script have this check?

In the creature_example.cpp the UpdateAI method has a const parameter uiDiff. According to the comments UpdateAI is called on every single map update. What is the uiDiff value that the UpdateAI method receives? (From what I am understanding it’s number of ms passed since last call?)

http://www.trinitycore.org/f/topic/5347-deprecated-methods-of-coding/

Yes it is. I might be wrong but the value is usually around 50 ms.

The sender is an identifier that identifies the page where the player was when he clicked the option, its mostly used with multi-page gossip selection scripts.

The script has that check just for the sake of learning.

My next questions come with spell scripts. How come some spells are handled in the core and others as scripts?

There’s not a general rule for all the spells.

Spells that have dummy or script effects should be handled in the scripts, all the others should be handled in the “core”.

Picking a random example… spell 5 has SPELL_EFFECT_INSTAKILL. The core knows what to do with all the spells that have this effect; “hand”-making a script for it wouldn’t make a lot of sense.

Spell 62472 (Start the Engine) has SPELL_EFFECT_DUMMY; it’s not defined what the spell should do; a script needs to be crafted for it.

Thank you guys for your replies.

Spells that have dummy or script effects should be handled in the scripts, all the others should be handled in the “core”.
Picking a random example… spell 5 has SPELL_EFFECT_INSTAKILL. The core knows what to do with all the spells that have this effect; “hand”-making a script for it wouldn’t make a lot of sense.

Spell 62472 (Start the Engine) has SPELL_EFFECT_DUMMY; it’s not defined what the spell should do; a script needs to be crafted for it.

I see, but looking at spell_priest.cpp there is a spell Guardian Spirit. From what I am understanding this spell doesn’t have a dummy or script effect. So, why is it handled in this file?

I started by saying there’s no general rule.

Certain spells need to be tweaked (damage they do, heal they do, spell procs, etc) and for these special cases a script needs to be done

(anyway, it’s preferred to do scripts for special cases than change the core code to handle the special cases)

And if you are going to work with spells get Spellwork , it’s essential.