Cast Spell Based on Gender.

Hi all, I am fixing a quest that needs to cast one of 2 spells on a user based on their gender. I don’t know if this can be achieved through smart AI or the quest_template but I know I can be done using the core. this spell needs to be cast when a player completes a quest. The quest is http://www.wowhead.com/quest=20438.

I think this has to be done using creature AI but how do you handle the event when the player clicks the Complete quest button?

Nope, gender checks can not be done in any DB scripting right now.

– Brian

thank you, I thought as much but the question I was hoping to get answered.

I think this has to be done using creature AI, but how do you handle the event when the player clicks the Complete quest button?

Reading comprehension for the LOSE /emoticons/default_sad.png

Sorry about that…


if (player->CanCompleteQuest(quest))

Make sure whatever other checks you add that you also complete the quest with:


player->CompleteQuest(quest);

– Brian

I am a newby at C++ and trinity core, but those seem like ways to check weather you can complete a quest and a way to complete a quest this is not what I need in this case, I simply need to run some code when a player completes a quest and I don’t know what is the correct procedure Event handler, delegate, some other way ? and where to do this in a script, in AI.

Please i’m talking under assumption, please correct me if i’m wrong.

You will need to build the entire quest gossip into a creature script. You can’t just override part the part that happens after you push the “complete” button /emoticons/default_smile.png

There should be some examples in the scripts dir. Search for CompleteQuest…

– Brian

ah, I found what I was looking for thanks, so what I need to do is create a creature script for my npc with the gossip script and if I didn’t look at the creature script class I probably still would be lost.


       // Called when a player completes a quest with the creature.

        virtual bool OnQuestComplete(Player* /*player*/, Creature* /*creature*/, Quest const* /*quest*/) { return false; }

this is what i need! ^^

one tiny unrelated question

How can you have a argument like Player* and then a comment ? that doesn’t make any sense. I take this has some special meaning in C++

Comments is for unused variables, uncomment they and you can use it /emoticons/default_biggrin.png

WTB SAI + conditions 5 gold

I can see how to do it when a user completes a quest, but how to make a SAI that checks if the player has a quest and cast a spell based on gender ?

As Brian said, you cannot do it at this moment. For now, only core scripts can do that.

I assume you’re talking about “Sunreaver Disguise”. There are 3 spells, 2 for male/female (70973/70974) and 69672 for custom script what will cast 70973/70974 depending on gender, thus the correct fix for this would be casting 69672 and scripting it

so this fix is partially correct ? because I don’t see a way that you can stop being teleported out without some type of check, like I did. And where do you script a spell like this ? I figured it would probably be in spelleffects.cpp but there are so many methods I have no idea in which one and there is probably another place where I have to script, I know that would be like 10 lines of code at the most, but I want to learn it myself.

server\scripts\Spells\spell_quest.cpp using the spell system hook