Erreurs de compilation "TrinityCore 5.1.0" Debian
Bonsoir à tous,

J'ai un problème l'ors de la compilation de Trinitycore 5.1.0 sous linux Debian.

j'obtiens ses erreurs:

/home/concept/serveurmop/mop-5.1.0-master/src/server/scripts/Pandaria/zone_wandering_isle.cpp: In member function ‘virtual bool boss_li_fei::OnQuestAccept(Player*, Creature*, const Quest*)’:
/home/concept/serveurmop/mop-5.1.0-master/src/server/scripts/Pandaria/zone_wandering_isle.cpp:1336:207: error: ‘0’ cannot be used as a function
make[2]: *** [src/server/scripts/CMakeFiles/scripts.dir/Pandaria/zone_wandering_isle.cpp.o] Erreur 1
make[1]: *** [src/server/scripts/CMakeFiles/scripts.dir/all] Erreur 2
make: *** [all] Erreur 2

J'ai compilé la même source sous Windows avec Visual studio 2012 et je

n'ais aucune erreur.

Si quelqu’un a déjà eu se genre d'erreurs merci.
Étrange que cela ne le fasse pas sous Windows.. Pour commencer, tu pourrais ouvrir le fichier concerné et vérifier qu'il n'y à pas d'erreurs dans le code? Wink

Cela n'a peut être rien à voir mais je sais que Windows est insensible à la casse pour de nombreuses choses mais que Linux lui différencie une lettre majuscule et minuscule..
Salut merci pour cette réponse mais je ne vois rien de spécial voici le script :

/*
 * Copyright © 2008-2013 TrinityCore <http://www.trinitycore.org/>
 * Copyright © 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program. If not, see <http://www.gnu.org/licenses/>.
 */


#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "ScriptedGossip.h"
#include "Player.h"
#include "SpellInfo.h"

enum Wandering_Isle_Quests //just for phase-checks
{
	QUEST_THE_LESSON_OF_STIFLED_PRIDE = 29524, //starting with phasemask 2
	QUEST_THE_LESSON_OF_THE_BURNING_SCROLL = 29408,
	QUEST_DISCIPLE_CHALLENGE = 29409,

};
// npc_first_quest_pandaren
class npc_first_quest_pandaren : public CreatureScript
{
public:
    npc_first_quest_pandaren() : CreatureScript("npc_first_quest_pandaren") { }

    CreatureAI* GetAI(Creature* pCreature) const
    {
        return new npc_first_quest_pandarenAI (pCreature);
    }

    struct npc_first_quest_pandarenAI : public ScriptedAI
    {
        npc_first_quest_pandarenAI(Creature *c) : ScriptedAI©
        {
        }

        uint32 timer;

        void Reset()
        {
            timer = 0;
        }


        void UpdateAI(const uint32 diff)
        {
            if (timer < diff)
            {
                Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers();
                if (!PlayerList.isEmpty())
                {
                    for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
                    {
                        Player *p = i->getSource();
                        if (p)
                        {
                            if (me->GetExactDist(p) < 40)
								if(p->getRace() == RACE_PANDAREN)
								{
									uint32 questId = 0;

									switch(p->getClass())
									{
									case CLASS_MONK:
										questId = 30039;
										break;
									case CLASS_MAGE:
										questId = 30040;
										break;
									case CLASS_HUNTER:
										questId = 30041;
										break;
									case CLASS_PRIEST:
										questId = 30042;
										break;
									case CLASS_ROGUE:
										questId = 30043;
										break;
									case CLASS_SHAMAN:
										questId = 30044;
										break;
									case CLASS_WARRIOR:
										questId = 30045;
										break;
									default: // Not supposed to happen but in case of
										questId = 30044;
										break;
									}

									Quest const* quest = sObjectMgr->GetQuestTemplate(questId);
									if (quest && !p->hasQuest(questId) && p->CanAddQuest(quest, true) && (p->GetQuestStatus(questId) != QUEST_STATUS_COMPLETE) && (p->GetQuestStatus(questId) != QUEST_STATUS_REWARDED))
									{
										p->AddQuest(quest, NULL);
										p->CompleteQuest(questId);
									}
								}
                        }
                    }
                }

                timer = 2000;
            }
            else
                timer -=diff;
        }
    };
};

/*******************************/
/**The Lesson of Stifled Pride**/
/*******************************/

/*class npc_trainee_stifled_pride : public CreatureScript
{
public :
    npc_trainee_stifled_pride() : CreatureScript("npc_trainee_stifled_pride")
    {
        m_gossipHelloMessage = "Null gossip option" ;
    }

    bool OnGossipHello(Player *p, Creature *c)
    {
        if(p && p->hasQuest(QUEST_THE_LESSON_OF_STIFLED_PRIDE) && !p->isInCombat() && p->GetQuestStatus(QUEST_THE_LESSON_OF_STIFLED_PRIDE) == QUEST_STATUS_INCOMPLETE)
        {
            m_gossipHelloMessage = "Je vous defie !";
            p->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, m_gossipHelloMessage, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);

            p->PlayerTalkClass->SendGossipMenu(NPC_QUEST_REWARD, c->GetGUID());

            return true ;
        }
        else if(p && (!p->hasQuest(QUEST_THE_LESSON_OF_STIFLED_PRIDE) || p->GetQuestStatus(QUEST_THE_LESSON_OF_STIFLED_PRIDE) != QUEST_STATUS_INCOMPLETE))
        {
            m_gossipHelloMessage = "Il y a erreur... je vous prie de m'excuser" ;
            p->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, m_gossipHelloMessage, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);

            p->PlayerTalkClass->SendGossipMenu(NPC_QUEST_REWARD, c->GetGUID());
            return true ;
        }
        else if(!p)
            return false;

		return false ;
    }

    bool OnGossipSelect(Player *p, Creature *c, uint32 sender, uint32 action)
    {
        p->PlayerTalkClass->ClearMenus();

        if(action == GOSSIP_ACTION_INFO_DEF + 1)
            StartQuestEvent(c, p);

        p->CLOSE_GOSSIP_MENU();

		return true ;
    }

    struct npc_trainee_stifled_prideAI : public ScriptedAI
    {
    public :
        npc_trainee_stifled_prideAI(Creature* c) : ScriptedAI©
        {

        }

        void Reset()
        {
            events.Reset();
        }

        void EnterCombat(Unit *who)
        {
            ScheduleTraineeEvents();
        }

        void UpdateAI(uint32 diff)
        {
            if(!UpdateVictim())
            {
                switch(me->getFaction())
                {
                case 14 :
                    ResetToNormal(NULL);
                    break ;
                case 35 :
                    return ;
                }
            }

            events.Update(diff);

            if(me->HasUnitState(UNIT_STATE_CASTING))
                return ;

            if(events.ExecuteEvent() == EVENT_TRAINEE_SPELL)
            {
                switch(me->GetEntry())
                {
                case HUOJIN_TRAINEE_1 :
                case HUOJIN_TRAINEE_2 :
                    if(me->getVictim())
                        DoCast(me->getVictim(), SPELL_JAB, true);
                    break ;

                case TUSHUI_TRAINEE_1 :
                case TUSHUI_TRAINEE_2 :
                    if(me->getVictim())
                        DoCast(me->getVictim(), SPELL_BLACKOUT_KICK, true);
                    break ;

                }
                ScheduleTraineeEvents();
            }
        }

        void DamageTaken(Unit *attacker, uint32 &amount)
        {
            float tenPercent = me->GetMaxHealth() / 10 ;
            if((me->GetHealth() - amount) <= tenPercent)
            {
                amount = 0 ;
                me->SetHealth(uint32(tenPercent));
                ResetToNormal(attacker);
            }
        }

    private :
        EventMap events;

        inline void ScheduleTraineeEvents()
        {
            events.ScheduleEvent(EVENT_TRAINEE_SPELL, urand(3500, 5500));
        }

        void ResetToNormal(Unit* attacker)
        {
            switch(me->GetEntry())
            {
            case HUOJIN_TRAINEE_1 :
            case HUOJIN_TRAINEE_2 :
                if(attacker)
                    me->Say(irand(SAY_HUOJIN_DEFEAT_1, SAY_HUOJIN_DEFEAT_8), LANG_COMMON, attacker->GetGUID());
                break ;
            case TUSHUI_TRAINEE_1 :
            case TUSHUI_TRAINEE_2 :
                if(attacker)
                    me->Say(irand(SAY_TUSHUI_DEFEAT_1, SAY_TUSHUI_DEFEAT_8), LANG_COMMON, attacker->GetGUID());
                break ;
            }
            events.Reset();
            me->setFaction(35);
            me->SetFullHealth();
            me->DisappearAndDie();
        }
    };

    CreatureAI* GetAI(Creature *c) const
    {
        return new npc_trainee_stifled_prideAI©;
    }

private :

    // Enums
    enum Quests
    {
        QUEST_THE_LESSON_OF_STIFLED_PRIDE = 29524
    };

    enum Npcs
    {
        HUOJIN_TRAINEE_1 = 54586,
        HUOJIN_TRAINEE_2 = 65470,
        TUSHUI_TRAINEE_1 = 54587,
        TUSHUI_TRAINEE_2 = 65471,
        NPC_QUEST_REWARD = 54789 // Spell 102384
    };

    enum Spells
    {
        SPELL_JAB               = 109079, // Huojin
        SPELL_BLACKOUT_KICK     = 109080, // Tushui
        SPELL_QUEST_KILL_CREDIT = 102384
    };

    enum Says
    {
        SAY_HUOJIN_DEFEAT_1 = -5458607,
        SAY_HUOJIN_DEFEAT_2,
        SAY_HUOJIN_DEFEAT_3,
        SAY_HUOJIN_DEFEAT_4,
        SAY_HUOJIN_DEFEAT_5,
        SAY_HUOJIN_DEFEAT_6,
        SAY_HUOJIN_DEFEAT_7,
        SAY_HUOJIN_DEFEAT_8,

        SAY_TUSHUI_DEFEAT_1 = -5458707,
        SAY_TUSHUI_DEFEAT_2,
        SAY_TUSHUI_DEFEAT_3,
        SAY_TUSHUI_DEFEAT_4,
        SAY_TUSHUI_DEFEAT_5,
        SAY_TUSHUI_DEFEAT_6,
        SAY_TUSHUI_DEFEAT_7,
        SAY_TUSHUI_DEFEAT_8
    };

    enum Events
    {
        EVENT_TRAINEE_SPELL = 1
    };

    // Functions
    void StartQuestEvent(Creature* me, Player* quester)
    {
        if(!me || !quester)
            return ;

        if(me->isInCombat())
            return ;

        me->setFaction(14);
        if(me->GetAI())
        {
            me->SetInCombatWith(quester);
            me->GetAI()->AttackStart(quester);
        }
    }

    // Variables
    const char* m_gossipHelloMessage;
*/
    // SQL
    /* UPDATE creature_template SET npcflag = npcflag | 1, gossip_menu_id = 1, ScriptName = "npc_trainee_stifled_pride" WHERE entry IN (54586, 54587, 65470, 65471) ;
     *
     * INSERT INTO script_texts (npc_entry, entry, content_default, content_loc2, type, language, comment) VALUES
     * (54586, -5458607, "I have never seen a trainee with skills such as yours. I must tell the others.", "Je n'ai jamais vu une recrue avant autant d'adresse que vous. Je dois prÃvenir les autres.", 1, 7, "Trainee of stifled pride - defeat"),
     * (54586, -5458606, "My skills are no match for yours. I admit defeat.", "Mes capacites n'egalent pas les votres. J'admets ma defaite.", 1, 7, "Trainee of stifled pride - defeat"),
     * (54586, -5458605, "Thank you for reminding me that I must train more diligently.", "Merci de m'avoir rappele que je dois m'entraÃner avec discernement.", 1, 7, "Trainee of stifled pride - defeat"),
     * (54586, -5458604, "That was a good match. Thank you.", "C'etait un bon combat. Merci a vous.", 1, 7, "Trainee of stifled pride - defeat"),
     * (54586, -5458603, "You are an honorable opponent.", "Vous êtes un adversaire honorable.", 1, 7, "Trainee of stifled pride - defeat"),
     * (54586, -5458602, "You fight honorably, friend.", "Vous avez combattu honorablement mon ami.", 1, 7, "Trainee of stifled pride - defeat"),
     * (54586, -5458601, "You fought well. I must learn more from you in the future.", "Vous vous êtes bien battu. Je dois apprendre plus de vous dans l'avenir.", 1, 7, "Trainee of stifled pride - defeat"),
     * (54586, -5458600, "Your skills are too great. I yield.", "Vos capacites sont impressionnantes. Je m'incline.", 1, 7, "Trainee of stifled pride - defeat"),
     * (54587, -5458707, "I have never seen a trainee with skills such as yours. I must tell the others.", "Je n'ai jamais vu une recrue avant autant d'adresse que vous. Je dois prÃvenir les autres.", 1, 7, "Trainee of stifled pride - defeat"),
     * (54587, -5458706, "My skills are no match for yours. I admit defeat.", "Mes capacites n'egalent pas les votres. J'admets ma defaite.", 1, 7, "Trainee of stifled pride - defeat"),
     * (54587, -5458705, "Thank you for reminding me that I must train more diligently.", "Merci de m'avoir rappele que je dois m'entraÃner avec discernement.", 1, 7, "Trainee of stifled pride - defeat"),
     * (54587, -5458704, "That was a good match. Thank you.", "C'etait un bon combat. Merci a vous.", 1, 7, "Trainee of stifled pride - defeat"),
     * (54587, -5458703, "You are an honorable opponent.", "Vous êtes un adversaire honorable.", 1, 7, "Trainee of stifled pride - defeat"),
     * (54587, -5458702, "You fight honorably, friend.", "Vous avez combattu honorablement mon ami.", 1, 7, "Trainee of stifled pride - defeat"),
     * (54587, -5458701, "You fought well. I must learn more from you in the future.", "Vous vous êtes bien battu. Je dois apprendre plus de vous dans l'avenir.", 1, 7, "Trainee of stifled pride - defeat"),
     * (54587, -5458700, "Your skills are too great. I yield.", "Vos capacites sont impressionnantes. Je m'incline.", 1, 7, "Trainee of stifled pride - defeat") ;
     */
//};


/*************************************/
/********The Way of the Tushui********/
/*************************************/

class CheckAysaQuestPredicate
{
public :
    CheckAysaQuestPredicate(uint32 questId, uint32 spellId) : id(questId) { }

    bool operator()(Player* p)
    {
        if(p)
            return (p->HasAura(spell) && p->hasQuest(id)) ;
        return false ;
    }

private:
    uint32 id;
    uint32 spell;
};

const Position SummonPositions[] =
{
    {0.0f, 0.0f, 0.0f, 0.0f},
    {0.0f, 0.0f, 0.0f, 0.0f},
    {0.0f, 0.0f, 0.0f, 0.0f},
    {0.0f, 0.0f, 0.0f, 0.0f},
    {0.0f, 0.0f, 0.0f, 0.0f}
};

const Position MeditationPosition = {0.0f, 0.0f, 0.0f, 0.0f} ;
const Position ShangXiPosition = {0.0f, 0.0f, 0.0f, 0.0f} ;

const Position LiFeiPosition[2] =
{
    {0.0f, 0.0f, 0.0f, 0.0f},
    {0.0f, 0.0f, 0.0f, 0.0f}
};

class npc_aysa_cloudsinger_quest29414 : public CreatureScript
{
public :
    npc_aysa_cloudsinger_quest29414() : CreatureScript("npc_aysa_cloudsinger_29414") {    }

    struct npc_aysa_cloudsinger_quest29414_AI : public ScriptedAI
    {
    public :
        npc_aysa_cloudsinger_quest29414_AI(Creature* c) : ScriptedAI©
        {

        }

        void Reset()
        {
            isStarted = false ;
        }

        void DamageTaken(Unit *doneby, uint32 &/*amount*/)
        {
            if(doneby->GetTypeId() != TYPEID_PLAYER)
            {
                events.RescheduleEvent(EVENT_ADD_POWER, 1300);
                events.RescheduleEvent(EVENT_SUMMON_NPCS, 1500);
            }
        }

        void UpdateAI(uint32 diff)
        {
            if(!isStarted)
            {
                if(isAPlayerWithQuestInDist())
                {
                    StartEvent();
                    isStarted = true ;
                }
                else
                    return ;
            }

            events.Update(diff);

            while(uint32 eventId = events.ExecuteEvent())
            {
                switch(eventId)
                {
                case EVENT_INTRO :
                    DoIntro();
                    break ;

                case EVENT_ADD_POWER :
                    AddPowerToPlayersOnMap();
                    events.ScheduleEvent(EVENT_ADD_POWER, 1300);
                    break ;

                case EVENT_SUMMON_NPCS :
                    SummonNpcs();
                    events.ScheduleEvent(EVENT_SUMMON_NPCS, 3500);
                    break ;

                case EVENT_LOOK_PLAYERS :
                    if(isAPlayerWithQuestInDist())
                        events.ScheduleEvent(EVENT_LOOK_PLAYERS, 1000);
                    else
                        EndEvent();
                    break ;

                default :
                    break ;
                }
            }

        }

    private :
        // Functions
        inline void StartEvent()
        {
            events.ScheduleEvent(EVENT_INTRO, 3000);
            events.ScheduleEvent(EVENT_ADD_POWER, 1300);
            events.ScheduleEvent(EVENT_SUMMON_NPCS, 5000);
            events.ScheduleEvent(EVENT_LOOK_PLAYERS, 1000);
        }

        void EndEvent()
        {
            events.CancelEvent(EVENT_ADD_POWER);
            events.CancelEvent(EVENT_INTRO);
            events.CancelEvent(EVENT_SUMMON_NPCS);
            events.CancelEvent(EVENT_LOOK_PLAYERS);
            isStarted = false ;
            if(LiFei)
                LiFei->DespawnOrUnsummon();
            Reset();
        }

        bool isAPlayerWithQuestInDist()
        {
            Map* map = me->GetMap();
            if(map)
            {
                Map::PlayerList const& players = map->GetPlayers();

                if(players.isEmpty()) return false ;

                CheckAysaQuestPredicate predicate((uint32)QUEST_THE_WAY_OF_THE_TUSHUI, (uint32)SPELL_PHASE);
                for(Map::PlayerList::const_iterator iter = players.begin() ; iter != players.end() ; ++iter)
                {
                    if(Player* p = iter->getSource())
                    {
                        if(predicate(p))
                            return true ;
                    }
                }
            }

            return false ;
        }

        void AddPowerToPlayersOnMap()
        {
            if(Map* map = me->GetMap())
            {
                Map::PlayerList const& pl = map->GetPlayers();

                if(pl.isEmpty()) return ;

                CheckAysaQuestPredicate predi((uint32)QUEST_THE_WAY_OF_THE_TUSHUI, (uint32)SPELL_PHASE);

                for(Map::PlayerList::const_iterator iter = pl.begin() ; iter != pl.end() ; ++iter)
                    if(predi(iter->getSource()))
                        AddPower(iter->getSource());
            }
        }

        void AddPower(Player* p)
        {
            if(p)
            {
                p->ModifyPower(POWER_ALTERNATE_POWER, 1);
                switch(p->GetPower(POWER_ALTERNATE_POWER))
                {
                case 20 :
                    LiFeiSpeech(LI_FEI_SPEECH_1, p);
                    break;
                case 40 :
                    LiFeiSpeech(LI_FEI_SPEECH_2, p);
                    break ;
                case 60 :
                    LiFeiSpeech(LI_FEI_SPEECH_3, p);
                    break ;
                case 70 :
                    LiFeiSpeech(LI_FEI_SPEECH_4, p);
                    break;
                case 80 :
                    LiFeiSpeech(LI_FEI_SPEECH_5, p);
                    break ;
                case 90 :
                    LiFeiSpeech(LI_FEI_SPEECH_6, p);
                    break ;
                case 100 :
                    p->KilledMonsterCredit(NPC_MASTER_LI_FEI);
                    p->RemoveAura(SPELL_MEDITATION_BAR_2);
                    me->PlayDirectSound(SOUND_END_CAVE, p);
                    me->Say(AYSA_SAY_OUTRO, LANG_COMMON, p->GetGUID());
                    p->RemoveAura(SPELL_PHASE);
                    me->SummonCreature(NPC_MASTER_SHANG_XI, ShangXiPosition);
                    break ;

                default :
                    break ;
                }
            }
        }

        void LiFeiSpeech(int32 id, Player* target)
        {
            if(LiFei && target)
                LiFei->MonsterSay(id, LANG_COMMON, target->GetGUID());
        }

        void SummonNpcs()
        {
            uint8 number = (1 + (rand() % 4));

            for(uint8 i = 0 ; i < number ; ++i)
            {
                Creature * scamp = me->SummonCreature(MOB_SCAMP, SummonPositions[i]);
                if(scamp)
                    scamp->AI()->AttackStart(me);
            }
        }

        void DoIntro()
        {
            LiFei = me->SummonCreature(NPC_MASTER_LI_FEI, LiFeiPosition[0]);
            if(LiFei)
            {
                LiFei->GetMotionMaster()->MovePoint(0, LiFeiPosition[1]);
                LiFei->SetOrientation(me->GetOrientation() - M_PI);
            }
        }

        // Vars
        bool isStarted ;
        EventMap events ;
        Creature* LiFei;
    };

    CreatureAI* GetAI(Creature *c) const
    {
        return new npc_aysa_cloudsinger_quest29414_AI©;
    }

private :

    // Enums
    enum Quests
    {
        QUEST_THE_WAY_OF_THE_TUSHUI = 29414
    };

    enum Events
    {
        EVENT_ADD_POWER = 1,
        EVENT_SUMMON_NPCS,
        EVENT_INTRO,
        EVENT_LOOK_PLAYERS
    };

    enum Sounds
    {
        SOUND_QUEST_ACCEPT = 0,
        SOUND_START_CAVE = 0,
        SOUND_END_CAVE = 0
    };

    enum Spells
    {
        SPELL_MEDITATION_BAR_2 = 105274,
        SPELL_PHASE = 68243
    };

    enum Npcs
    {
        NPC_MASTER_LI_FEI = 54856,
        NPC_MASTER_SHANG_XI = 54608,
        MOB_SCAMP = 59637,
        NPC_AYSA_QUESTENDER = 0
    };

    enum Areas
    {
        AREA_CAVERN_OF_MEDITATION = 5848
    };

    enum Says
    {
        LI_FEI_SPEECH_1 = -5485605,
        LI_FEI_SPEECH_2,
        LI_FEI_SPEECH_3,
        LI_FEI_SPEECH_4,
        LI_FEI_SPEECH_5,
        LI_FEI_SPEECH_6,

        AYSA_SAY_INTRO = -5964201,
        AYSA_SAY_OUTRO = -5964200
    };

    // Functions

    // Variables
};

/********************************/
/**The Lesson of the Iron Bough**/
/********************************/

class EquippedItemCheckPredicate // this is totally wrong and memory-hungry implementation I'll rescript it later.
{
public :
    EquippedItemCheckPredicate(uint32 questId, uint32 itemId, uint32 itemId2) : item1(itemId), item2(itemId2), quest(questId)
    {
        if(itemId2) twice = true ;
    }

    bool operator()(Player* p)
    {
        if(!p) return false ;

        if(!twice)
        {
            if(p->hasQuest(quest) && p->GetQuestStatus(quest) == QUEST_STATUS_INCOMPLETE && p->GetItemByEntry(item1))
                return(p->GetItemByEntry(item1)->IsEquipped());
        }
        else
        {
            if(p->hasQuest(quest) && p->GetQuestStatus(quest) == QUEST_STATUS_INCOMPLETE && p->GetItemByEntry(item1) && p->GetItemByEntry(item2))
                return(p->GetItemByEntry(item1)->IsEquipped() && p->GetItemByEntry(item2)->IsEquipped());
        }

		return false ;
    }

    bool isTwiced()
    {
        return twice;
    }

private :
    uint32 item1, item2, quest ;
    bool twice ;
};

struct QuestAndItems
{
    uint8 playerClass;
    uint32 quest;
    uint32 questItems[2];
};

QuestAndItems items[] =
{
    {1, 30037, 76391, 72313},
    {2, 30038, 73210, 0},
    {3, 30034, 73211, 0},
    {4, 30036, 73208, 73212},
    {5, 30035, 73207, 76393},
    {8, 30033, 76390, 76392},
    {10, 30027, 73209, 0}
};

class stalker_item_equiped : public CreatureScript
{
public :
    stalker_item_equiped() : CreatureScript("stalker_item_equipped")
    {

    }

    struct stalker_item_equipedAI : public ScriptedAI
    {
    public :
        stalker_item_equipedAI(Creature* c) : ScriptedAI©
        {

        }

        void Reset()
        {
            checkTimer = 1000 ;
        }

        void UpdateAI(uint32 diff)
        {
            if(checkTimer <= diff)
            {
                Check();
                checkTimer = 1000 ;
            }
            else checkTimer -= diff ;
        }

    private :
        uint32 checkTimer;

        void Check()
        {
            Map* map = me->GetMap();
            if(!map) return ;

            Map::PlayerList const& pl = map->GetPlayers();

            if(pl.isEmpty()) return ;


            for(Map::PlayerList::const_iterator iter = pl.begin() ; iter != pl.end() ; ++iter)
            {
                if(Player* p = iter->getSource())
                {
                    uint8 pClass = p->getClass();
                    uint8 i = 0 ;
                    for(; i < 7 ; ++i)
                    {
                        if(pClass = items[i].playerClass)
                        {
                            EquippedItemCheckPredicate predicate(items[i].quest, items[i].questItems[0], items[i].questItems[1]);
                            if(predicate(p))
                            {
                                p->KilledMonsterCredit(REWARD_1);
                                if(predicate.isTwiced())
                                        p->KilledMonsterCredit(REWARD_2);
                            }
                            break ;
                        }
                    }
                }
            }
        }

        enum NPCS
        {
            REWARD_1 = 0,
            REWARD_2 = 0
        };
    };

    CreatureAI* GetAI(Creature *c) const
    {
        return new stalker_item_equipedAI©;
    }
};

/**********************************/
/*****The Disciple's Challenge*****/
/**********************************/
class mob_jaomin_ro : public CreatureScript
{
public:
    mob_jaomin_ro() : CreatureScript("mob_jaomin_ro") { }
    
    CreatureAI* GetAI(Creature* creature) const
    {
        return new mob_jaomin_roAI(creature);
    }
    
    struct mob_jaomin_roAI : public ScriptedAI
    {
        mob_jaomin_roAI(Creature* creature) : ScriptedAI(creature)
        {
            me->SetReactState(REACT_DEFENSIVE);
            me->SetDisplayId(39755);
            me->setFaction(14); //mechant!
        }

        enum eEvents
        {
            EVENT_JAOMIN_JUMP   = 1,
            EVENT_HIT_CIRCLE    = 2,
            EVENT_FALCON        = 3,
            EVENT_RESET         = 4,
            EVENT_CHECK_AREA    = 5,
        };
        
        EventMap events;
        bool isInFalcon;

        void EnterCombat(Unit* unit)
        {
            Talk(0);
            events.ScheduleEvent(EVENT_JAOMIN_JUMP, 1000);
            events.ScheduleEvent(EVENT_HIT_CIRCLE, 2000);
            events.ScheduleEvent(EVENT_CHECK_AREA, 2500);
        }
        
        void Reset()
        {
            isInFalcon = false;
            me->SetReactState(REACT_DEFENSIVE);
            me->SetDisplayId(39755);
            me->setFaction(2357); //mechant!
            me->CombatStop(true);

            me->GetMotionMaster()->MovePoint(1, 1380.35f, 3170.68f, 136.93f);
        }
        
        void DamageTaken(Unit* attacker, uint32& damage)
        {
            if (me->HealthBelowPctDamaged(30, damage) && !isInFalcon)
            {
                isInFalcon = true;
                me->SetDisplayId(39796); //faucon
                events.ScheduleEvent(EVENT_FALCON, 1000);
                events.CancelEvent(EVENT_JAOMIN_JUMP);
                events.CancelEvent(EVENT_HIT_CIRCLE);
            }

            if (me->HealthBelowPctDamaged(5, damage))
            {
                me->SetDisplayId(39755);

                 if(attacker->ToPlayer())
                    attacker->ToPlayer()->KilledMonsterCredit(me->GetEntry(), 0);

                me->CombatStop();
                me->setFaction(35);
                me->SetFullHealth();
                Talk(1);
                me->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE);
                events.Reset();
                events.ScheduleEvent(EVENT_RESET, 5000);
                damage = 0;
            }

            if (damage > me->GetHealth())
                damage = 0;
        }
        
        void UpdateAI(const uint32 diff)
        {            
            events.Update(diff);
            
            while (uint32 eventId = events.ExecuteEvent())
            {
                switch(eventId)
                {
                    case EVENT_JAOMIN_JUMP: //on monte
                        if (me->getVictim())
                            me->CastSpell(me->getVictim(), 108938, true);
                            events.ScheduleEvent(EVENT_JAOMIN_JUMP, 30000);
                        break;
                    case EVENT_HIT_CIRCLE: //baffe
                        if (me->getVictim())
                            me->CastSpell(me->getVictim(), 119301, true);

                        events.ScheduleEvent(EVENT_HIT_CIRCLE, 3000);
                        break;
                    case EVENT_FALCON: //attaque du faucon
                        if (me->getVictim())
                            me->CastSpell(me->getVictim(), 108935, true);

                        events.ScheduleEvent(EVENT_FALCON, 4000);
                        break;
                    case EVENT_RESET: //remechant
                        Reset();
                    	break;
                    case EVENT_CHECK_AREA:
                        if (me->GetAreaId() != 5843) // Grotte Paisible
                            Reset();
                        break;
                }
            }
            
            DoMeleeAttackIfReady();
        }
    };
};


/****************************/
/*****The Missing Driver*****/
/****************************/

class MissingDriverCheckPredicate
{
public :
    MissingDriverCheckPredicate(uint32 questId) : quest(questId)
    {

    }

    bool operator()(Player* p)
    {
        if(!p) return false ;

        return(p->hasQuest(quest) && p->GetQuestStatus(quest) == QUEST_STATUS_INCOMPLETE);
    }

private :
    uint32 quest;
};

class mob_attacker_dimwind : public CreatureScript
{
public :
    mob_attacker_dimwind() : CreatureScript("mob_attacker_dimwind")
    {

    }

    struct mob_attacker_dimwind_AI : public ScriptedAI
    {
    public :
        mob_attacker_dimwind_AI(Creature* c) : ScriptedAI©
        {

        }

        void EnterCombat(Unit* who)
        {
            me->GetPosition(&homePosition);
            MissingDriverCheckPredicate predicate(29419);
            if(who->ToPlayer() && predicate(who->ToPlayer()))
            {
                me->GetMotionMaster()->MoveFleeing(who, 0);
                me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE);
                Talk(YELL_FLEE_1);
                canAttack = false ;
                who->ToPlayer()->KilledMonsterCredit(me->GetEntry(), 0);
            }
            else
                me->AI()->AttackStart(who);
        }

        void Reset()
        {
            canAttack = true ;
            takeThisTimer = 3500 ;
            returnTimer = 7500 ;
        }

        void UpdateAI(uint32 diff)
        {
            if(!UpdateVictim() && canAttack) return ;

            if(!canAttack)
            {
                if(returnTimer <= diff)
                {
                    me->GetMotionMaster()->MovePoint(0, homePosition);
                    me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE);
                    canAttack = true ;
                    returnTimer = 7500 ;
                }
                else returnTimer -= diff ;
            }
            else
            {
                if(takeThisTimer <= diff)
                {
                    if(me->getVictim())
                    DoCast(me->getVictim(), 109081, false);
                    takeThisTimer = 3000;
                }
                else takeThisTimer -= diff ;
            }
        }

    private :
        uint32 takeThisTimer;
        uint32 returnTimer;
        Position homePosition;
        bool canAttack;

        enum Yells
        {
            YELL_FLEE_1 = 0
        };
    };

    CreatureAI* GetAI(Creature *c) const
    {
        return new mob_attacker_dimwind_AI©;
    }
};

 enum dimwind
  {
       SAY_THANKS = 0
  };

class mob_min_dimwind : public CreatureScript
{
public:
    mob_min_dimwind() : CreatureScript("mob_min_dimwind") { }
    
    CreatureAI* GetAI(Creature* creature) const
    {
        return new mob_min_dimwindAI(creature);
    }



    struct mob_min_dimwindAI : public ScriptedAI
    {
        EventMap events;
        uint64 guidMob[4];

        enum eEvents
        {
            EVENT_CHECK_MOBS    = 1,
            EVENT_RESET         = 2
        };
        
        mob_min_dimwindAI(Creature* creature) : ScriptedAI(creature)
        {
            for(int i = 0; i < 4; i++)
                guidMob[i] = 0;

            ResetMobs();
            me->HandleEmoteCommand(EMOTE_STATE_READY2H);
        }
        
        void DamageTaken(Unit* pDoneBy, uint32 &uiDamage)
        {
            if(me->GetHealthPct() < 25 && pDoneBy && pDoneBy->ToCreature() && pDoneBy->ToCreature()->GetEntry() == 54130)
                uiDamage = 0;
        }
        
        
        bool VerifyMobs()
        {
            bool HasRemainingAttacker = false;
            for(int i = 0; i < 4; i++)
            {
                if(guidMob[i])
                {
                    if (Unit* unit = sObjectAccessor->FindUnit(guidMob[i]))
                    {
                        if(unit->isAlive())
                            HasRemainingAttacker = true;
                    }
                    else
                        guidMob[i] = 0;
                }
            }

            return !HasRemainingAttacker;
        }
        
        void ResetMobs()
        {
            events.ScheduleEvent(EVENT_CHECK_MOBS, 1000);
            me->HandleEmoteCommand(EMOTE_STATE_READY2H);

            for(int i = 0; i < 4; i++)
            {
                if(guidMob[i])
                    if (Unit* unit = sObjectAccessor->FindUnit(guidMob[i]))
                        if (unit->ToCreature())
                            unit->ToCreature()->DespawnOrUnsummon();

                guidMob[i] = 0;

                if(TempSummon* temp = me->SummonCreature(54130, me->GetPositionX()-3+rand()%6, me->GetPositionY() + 4 + rand()%4, me->GetPositionZ()+2, 3.3f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000))
                {
                    guidMob[i] = temp->GetGUID();
                    
                    temp->SetFacingToObject(me);
                    temp->HandleEmoteCommand(EMOTE_STATE_READY2H);
                    
                    temp->GetMotionMaster()->Clear(false);
                    temp->GetMotionMaster()->MoveChase(me);
                    temp->Attack(me, true);
                    temp->getThreatManager().addThreat(me, 250.0f);
                }
            }
        }
               
        void UpdateAI(const uint32 diff)
        {
            events.Update(diff);
            while (uint32 eventId = events.ExecuteEvent())
            {
                switch (eventId)
                {
                    case EVENT_CHECK_MOBS:
                    {
                        if(VerifyMobs()) //plus de mobs, win!
                        {
                    	    me->HandleEmoteCommand(EMOTE_STATE_STAND);
                    	    Talk(SAY_THANKS);
                           
                            //std::list<Player*> PlayerList;
                            //GetPlayerListInGrid(PlayerList, me, 20.0f);
                            //for (auto player: PlayerList)
                            //    player->KilledMonsterCredit(54855, 0);

                            events.ScheduleEvent(EVENT_RESET, 30000);
                        }
                        else
                            events.ScheduleEvent(EVENT_CHECK_MOBS, 1000);

                        break;
                    }
                    case EVENT_RESET:
                    {
                        ResetMobs();
                    }
                }
            }
        }
    };
};


/****************************/
/*****Fanning the Flames*****/
/****************************/

class spell_summon_living_air : public SpellScriptLoader
{
public :
    spell_summon_living_air() : SpellScriptLoader("spell_quest29523_summon_living_air")
    {

    }

    class spell_summon_living_airSpellScript : public SpellScript
    {
        PrepareSpellScript(spell_summon_living_airSpellScript)

        bool Validate(const SpellInfo *spellInfo)
        {
            if(!sSpellMgr->GetSpellInfo(106999) || !sSpellMgr->GetSpellInfo(102207))
                return false ;

            return true ;
        }

        void HandleDummy(SpellEffIndex effIndex)
        {
            if(Unit* caster = GetCaster())
            {
                caster->CastSpell((Unit*)NULL, 102207, true);
            }
        }

        void Register()
        {
            OnEffectLaunch += SpellEffectFn(spell_summon_living_airSpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
        }
    };

    SpellScript* GetSpellScript() const
    {
        return new spell_summon_living_airSpellScript();
    }
};

class boss_living_air : public CreatureScript
{
public:
    boss_living_air() : CreatureScript("boss_living_air") { }
    
    CreatureAI* GetAI(Creature* creature) const
    {
        return new boss_living_airAI(creature);
    }
    
    struct boss_living_airAI : public ScriptedAI
    {
        boss_living_airAI(Creature* creature) : ScriptedAI(creature)
        {
            me->SetReactState(REACT_AGGRESSIVE);
        }
        
        EventMap events;
        
        void EnterCombat(Unit* unit)
        {
            events.ScheduleEvent(1, 3000);
            events.ScheduleEvent(2, 5000);
        }
        
        void UpdateAI(const uint32 diff)
        {
            if (!UpdateVictim())
                return;
            
            events.Update(diff);
            
            while (uint32 eventId = events.ExecuteEvent())
            {
                switch(eventId)
                {
                    case 1:
                    	me->CastSpell(me->getVictim(), 108693);
                    	break;
                    case 2:
                    	me->CastSpell(me->getVictim(), 73212);
                    	events.ScheduleEvent(2, 5000);
                    	break;
                }
            }
            
            DoMeleeAttackIfReady();
        }
    };
};

/********************************/
/*****The Challenger's Fires*****/
/********************************/

class TorchEquippedPredicate
{
public :
    TorchEquippedPredicate(uint32 questId, uint32 itemId) : quest(questId), item(itemId)
    {

    }

    bool operator()(Player* p)
    {
        if(!p || !p->GetItemByEntry(item) || !p->hasQuest(quest) || p->GetQuestStatus(quest) != QUEST_STATUS_INCOMPLETE)
            return false ;

        return(p->GetItemByEntry(item)->IsInBag());
    }

private:
    uint32 quest, item;
};

class go_brazier_of_flickering_flames : public GameObjectScript
{
public :
    go_brazier_of_flickering_flames() : GameObjectScript("go_brazier_of_flickering_flames")
    {

    }

    bool OnGossipHello(Player *p, GameObject *go)
    {
        if(!p->hasQuest(29664) || p->GetQuestStatus(29664) != QUEST_STATUS_INCOMPLETE)
            return false ;
        else if(p->hasQuest(29664) && p->GetQuestStatus(29664) == QUEST_STATUS_INCOMPLETE)
        {
            go->CastSpell(p, 105151);
            return true;
        }

		return false ;
    }
};

#define QUEST_PARCHEMIN_VOLANT  29421

class boss_li_fei : public CreatureScript
{
public:
    boss_li_fei() : CreatureScript("boss_li_fei") {}

    bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest)
    {
        if (quest->GetQuestId() == QUEST_PARCHEMIN_VOLANT) // La lecon du parchemin brulant
        {	    
            if (Creature* tempSummon = creature->SummonCreature(54856, creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation(), TEMPSUMMON_MANUAL_DESPAWN, 0()))
            {
                tempSummon->SetPhaseMask(1024, true);
                tempSummon->AI()->AttackStart(player);
                tempSummon->AI()->SetGUID(player->GetGUID());
            }
        }

        return true;
    }
};

class boss_li_fei_fight : public CreatureScript
{
public:
    boss_li_fei_fight() : CreatureScript("boss_li_fei_fight") { }
    
    CreatureAI* GetAI(Creature* creature) const
    {
        return new boss_li_fei_fightAI(creature);
    }
    
    struct boss_li_fei_fightAI : public ScriptedAI
    {
        EventMap events;
        std::list<Player*> playersInvolved;
        uint64 playerGuid;

        boss_li_fei_fightAI(Creature* creature) : ScriptedAI(creature)
        {}

        enum eEvents
        {
            EVENT_CHECK_PLAYER      = 1,
            EVENT_FEET_OF_FURY      = 2,
            EVENT_SHADOW_KICK       = 3,
            EVENT_SHADOW_KICK_STUN  = 4,
        };

        void Reset()
        {
            // This particular entry is also spawned on an other event
            if (me->GetAreaId() != 5849) // Cavern areaid
                return;

            playerGuid = 0;
            me->SetReactState(REACT_AGGRESSIVE);
            me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_IMMUNE_TO_PC);
            me->setFaction(16);
            events.ScheduleEvent(EVENT_CHECK_PLAYER, 2500);
            events.ScheduleEvent(EVENT_FEET_OF_FURY, 5000);
            events.ScheduleEvent(EVENT_SHADOW_KICK,  1000);
        }

        void SetGUID(uint64 guid, int32 /*type*/)
        {
            playerGuid = guid;
        }
        
        void DamageTaken(Unit* attacker, uint32& damage)
        {
            if (me->HealthBelowPctDamaged(10, damage))
            {
                damage = 0;
                me->setFaction(35);
                me->CombatStop();
                me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
                me->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE);

                if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
                    player->KilledMonsterCredit(54734, 0);
            }
        }

        void KilledUnit(Unit* victim)
        {
            if (victim->GetTypeId() == TYPEID_PLAYER)
            {
                victim->ToPlayer()->SetQuestStatus(QUEST_PARCHEMIN_VOLANT, QUEST_STATUS_FAILED);

                if (victim->GetGUID() == playerGuid)
                    me->DespawnOrUnsummon(3000);
            }
        }
        
        void UpdateAI(const uint32 diff)
        {
            events.Update(diff);
            
            while (uint32 eventId = events.ExecuteEvent())
            {
                switch(eventId)
                {
                    case EVENT_CHECK_PLAYER:
                    {
                        bool checkPassed = true;
                        Player* player = ObjectAccessor::FindPlayer(playerGuid);

                        if (!player)
                        {
                            me->DespawnOrUnsummon(1000);
                            playerGuid = 0;
                            break;
                        }

                        if (!player->isAlive())
                        {
                            me->DespawnOrUnsummon(1000);
                            playerGuid = 0;
                            break;
                        }
                        
                        if (player->GetQuestStatus(QUEST_PARCHEMIN_VOLANT) != QUEST_STATUS_INCOMPLETE)
                        {
                            me->DespawnOrUnsummon(1000);
                            playerGuid = 0;
                            break;
                        }

                        events.ScheduleEvent(EVENT_CHECK_PLAYER, 2500);
                        break;
                    }
                    case EVENT_FEET_OF_FURY:
                        if(me->getVictim())
                    	    me->CastSpell(me->getVictim(), 108958);

                        events.ScheduleEvent(EVENT_FEET_OF_FURY, 5000);
                    	break;
                    case EVENT_SHADOW_KICK:
                        if(me->getVictim())
                    	    me->CastSpell(me->getVictim(), 108936);

                    	events.ScheduleEvent(EVENT_SHADOW_KICK_STUN, 2500);
                    	events.ScheduleEvent(EVENT_SHADOW_KICK, 30000);
                    	break;
                    case 4:
                        if(me->getVictim())
                           me->CastSpell(me->getVictim(), 108944);
                    	break;
                }
            }
            
            DoMeleeAttackIfReady();
        }
    };
};

class npc_shang_xi_begin : public CreatureScript //53566
{
public:
    npc_shang_xi_begin() : CreatureScript("npc_shang_xi_begin") { }
    
    bool OnGossipHello(Player *player, Creature *creature)
    {

        if (creature->isQuestGiver())
        {
            player->PrepareQuestMenu(creature->GetGUID());
            player->SendPreparedQuest(creature->GetGUID());
        }

        if(player->hasQuest(QUEST_THE_LESSON_OF_THE_BURNING_SCROLL))
		{
			/*if(!p->HasItemCount(FLAMME, 1)) // it's not blizz-like
			{
				p->CastSpell(p, SPELL_ANIM_TAKE_FLAME, true);
				p->CastSpell(p, SPELL_CREATE_THE_FLAMME, true);
				p->KilledMonsterCredit(KILL_CREDIT_FLAMME, 0);
				c->MonsterSay(SHANG_XI_TALK_FLAMME, 0, p->GetGUID());
			}*/

		} else if(player->GetQuestStatus(QUEST_THE_LESSON_OF_THE_BURNING_SCROLL) == QUEST_STATUS_COMPLETE) {
			player->PrepareQuestMenu(creature->GetGUID());
			player->PlayerTalkClass->SendGossipMenu(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
		}

		return true;
    }

    bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest)
        {
            if (quest->GetQuestId() == QUEST_THE_LESSON_OF_STIFLED_PRIDE)
            {
               player->SetPhaseMask(2, true); //open the gates, show huojin/tushui aggresive
            }
            if (quest->GetQuestId() == QUEST_THE_LESSON_OF_THE_BURNING_SCROLL)
            {
                //player->CastSpell(player, SPELL_ANIM_TAKE_FLAME, true); //missing opcodes to execute this ?
                player->CastSpell(player, SPELL_CREATE_THE_FLAMME, true);
                player->HandleEmoteCommand(51); //pure custom one - but looking cool - ONESHOT_SPELLCAST
                player->KilledMonsterCredit(KILL_CREDIT_FLAMME, 0);
                creature->AI()->Talk(SHANG_XI_TALK_FLAME, player->GetGUID());
                player->PlayDirectSound(27795, player); //play soundcreatureshangxi
                player->AddItem(FLAMME, 1);
            }
            if (quest->GetQuestId() == QUEST_DISCIPLE_CHALLENGE)
            {
               player->SetPhaseMask(8, true); //phasemask 8 show aggro Jaomin
            }
             return true;
        }

private: 
	enum enums
	{
		QUEST_THE_LESSON_OF_THE_BURNING_SCROLL = 29408,
		SPELL_ANIM_TAKE_FLAME = 114746,
		FLAMME = 80212,
		SPELL_CREATE_THE_FLAMME = 114610,
		//SPELL_CREATE_THE_FLAMME = 114611,
		SHANG_XI_TALK_FLAME = 0,
		KILL_CREDIT_FLAMME = 59591,
		// -------------------------
		QUEST_THE_LESSON_OF_STIFLED_PRIDE = 29524,
		// -------------------------
		QUEST_DISCIPLE_CHALLENGE = 29409
	};
};

class gob_edict_of_temperance_the_lesson_of_the_burning_scroll : public GameObjectScript
{
public:
	gob_edict_of_temperance_the_lesson_of_the_burning_scroll() : GameObjectScript("gob_edict_of_temperance_the_lesson_of_the_burning_scroll") { }

	bool OnGossipHello(Player* p, GameObject* gob)
	{
		if(p->HasItemCount(FLAMME, 1))
		{
			p->KilledMonsterCredit(KILL_CREDIT_BURN, 0);
			p->DestroyItemCount(FLAMME, 1, true);
			p->RemoveAurasDueToSpell(SPELL_CREATE_THE_FLAMME);
			// paper burn animation missing here, I used just a sound effect to more rpgish
           gob->PlayDirectSound(1484, 0); //soundID
		}

		return true;
	}
private:
	enum enums
	{
		TRACKER = 65490, //hardcoded wrong guid?
		EDICT_ID = 210986,
		FLAMME = 80212,
		SPELL_BURN = 88579,
		//SPELL_NEW_PHASE = 59074, // Tester si le changement de phase marche bien
		SPELL_CREATE_THE_FLAMME = 114610,
		KILL_CREDIT_BURN = 59570
	};
};

class vehicle_balance_pole : public VehicleScript
{
    public:
        vehicle_balance_pole() : VehicleScript("vehicle_balance_pole") {}

        void OnAddPassenger(Vehicle* veh, Unit* passenger, int8 /*seatId*/)
        {
            if (passenger->HasAura(102938))
                return;
        }
};

class mob_training_target : public CreatureScript //53714
{

    public:
		mob_training_target() : CreatureScript("mob_training_target"){}

		CreatureAI* GetAI(Creature* pCreature) const
		{
			return new mob_training_targetAI(pCreature);
		}


		struct mob_training_targetAI : public ScriptedAI
		{
			mob_training_targetAI(Creature* creature) : ScriptedAI(creature) { Reset(); }

			uint32 Reaggro_timer;

			void Reset()
			{
				Reaggro_timer = 0;
				Unit* Trainee = me->FindNearestCreature(53565, 1.2f); // ID, yard
				if (Trainee)
				{
					((Unit*)Trainee)->AddThreat(me, 1.0f);
					((Unit*)Trainee)->Attack(me, true);
				}

			}
			void JustRespawned(){ Reset(); }

			void UpdateAI(const uint32 diff)
			{
				if (Reaggro_timer <= diff) // cast on spawn
					{
						Unit* Trainee = me->FindNearestCreature(53565, 1.2f); // ID, yard
						if (Trainee)
						{
							((Unit*)Trainee)->AddThreat(me, 1.0f);
							((Unit*)Trainee)->Attack(me, true);
						}
						Reaggro_timer = 10*1000;
					} else Reaggro_timer -= diff;

			}
		};	
};

class mob_asp_trainee : public CreatureScript // 53565 65469
{

    public:
		mob_asp_trainee() : CreatureScript("mob_asp_trainee"){}

		CreatureAI* GetAI(Creature* pCreature) const
		{
			return new mob_asp_traineeAI(pCreature);
		}

		struct mob_asp_traineeAI : public ScriptedAI
		{
			mob_asp_traineeAI(Creature* creature) : ScriptedAI(creature) { Reset(); }

			uint32 Emote_Timer_1;
			uint32 Emote_Timer_2;
			uint32 Emote_Timer_3;
			uint32 Emote_Inst_Timer_1;
			uint32 Emote_Inst_Timer_2;
			uint32 Emote_Inst_Timer_3;		
			bool bag_puncher;

			void Reset()
			{
				Emote_Inst_Timer_1 = 5000;
				Emote_Timer_1 = 6000;
				Emote_Inst_Timer_2 = 11000;
				Emote_Timer_2 = 12000;
				Emote_Inst_Timer_3 = 17000;
				Emote_Timer_3 = 18000;

				bag_puncher = false;
			}

			void JustRespawned()
			{
				Reset();
			}


			void UpdateAI(const uint32 diff)
			{		

				if (!me->getVictim())
				{
					if (bag_puncher) //bag killed
						{
							me->AttackStop();
							Talk(SAY_TRAINEE_RPG_TALK);
							bag_puncher = false;
							me->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0); //just stand
						}

						Unit* Training_bag = me->FindNearestCreature(53714, 1.2f);
						if (Training_bag)
						{
							me->AddThreat(Training_bag, 1.0f);
							AttackStart(Training_bag);
							bag_puncher = true;
							// heal by 1?
						}
				}

				if (me->getVictim()) { bag_puncher = true; }	//if I got the target that mean I'm punching Training Bag		

				if (!UpdateVictim()) //no changes on target
				{

					Unit* Training_bag = me->FindNearestCreature(53714, 1.2f);
					if (Training_bag)
						me->SetUInt32Value(UNIT_NPC_EMOTESTATE, 510); // near bag let's go "combat-state"


					Unit* Instructor_Qun = me->FindNearestCreature(57748, 10.0f); // -- DO I'm near Instructor Qun ??
					if (Instructor_Qun)
					{
						me->SetUInt32Value(UNIT_NPC_EMOTESTATE, 510); // near instructor let's go "combat-state"
						if (Emote_Inst_Timer_1 <= diff) 
						{
						((Unit*)Instructor_Qun)->HandleEmoteCommand(508); //force Qun to emote-play
						Emote_Inst_Timer_1 = 4*6000;
						} else Emote_Inst_Timer_1 -= diff;

						if (Emote_Inst_Timer_2 <= diff)
						{
						((Unit*)Instructor_Qun)->HandleEmoteCommand(439);
						Emote_Inst_Timer_2 = 4*6000;
						} else Emote_Inst_Timer_2 -= diff;

						if (Emote_Inst_Timer_3 <= diff)
						{
						((Unit*)Instructor_Qun)->HandleEmoteCommand(60);
						Emote_Inst_Timer_3 = 4*6000;
						} else Emote_Inst_Timer_3 -= diff;

						// ------------------------ TRAINEEs

						if (Emote_Timer_1 <= diff) 
						{
						me->HandleEmoteCommand(508);
						Emote_Timer_1 = 4*6000; 
						} else Emote_Timer_1 -= diff;

						if (Emote_Timer_2 <= diff)
						{
						me->HandleEmoteCommand(439);
						Emote_Timer_2 = 4*6000;
						} else Emote_Timer_2 -= diff;

						if (Emote_Timer_3 <= diff)
						{
						me->HandleEmoteCommand(60);
						Emote_Timer_3 = 4*6000;
						} else Emote_Timer_3 -= diff;

					}

				}
				else
				{
					if (me->getVictim())
					{
						uint32 health = me->getVictim()->GetHealth();
						if(health >= 80) // bag max. health 84HP
							me->DealHeal(me->getVictim(), 1); //heals 1 HP for victim on each 100? miliseconds
					}
				}

					DoMeleeAttackIfReady();
			}
		};	
private:
	enum Says
	{
		SAY_TRAINEE_RPG_TALK = 0
	};

};

	enum eTushui
	{
       SAY_DONE             = 0,
	   SPELL_BLACKOUT_KICK  = 109080
	};

class mob_tushui_trainee : public CreatureScript
{
    public:
        mob_tushui_trainee() : CreatureScript("mob_tushui_trainee") { }

        CreatureAI* GetAI(Creature* creature) const
        {
            return new mob_tushui_trainee_AI(creature);
        }

        struct mob_tushui_trainee_AI : public ScriptedAI
        {
            mob_tushui_trainee_AI(Creature* creature) : ScriptedAI(creature) {}

            uint32 Blackout_Kick_Timer;			

            void Reset()
            {
                me->SetReactState(REACT_DEFENSIVE);
                me->setFaction(2357);
                Blackout_Kick_Timer = 5000;
            }

            void DamageTaken(Unit* attacker, uint32& damage)
            {
                if (me->HealthBelowPctDamaged(5, damage))
                {
                    if(attacker && attacker->GetTypeId() == TYPEID_PLAYER)
                    attacker->ToPlayer()->KilledMonsterCredit(54586, 0);
                    me->CombatStop();
                    me->SetFullHealth();
                    Talk(SAY_DONE);
                    me->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE);
                    me->setFaction(35);

                    me->GetMotionMaster()->MovePoint(1, 1435.38f, 3353.87f, 173.79f);
                    me->DespawnOrUnsummon(3000);
                    damage = 0;
                }
            }

            void UpdateAI(const uint32 diff)
            {
                if (!UpdateVictim())
                    return;

                 if(Blackout_Kick_Timer<= diff)
                 {
                       DoCast(me->getVictim(), SPELL_BLACKOUT_KICK);
                       Blackout_Kick_Timer = 10000;
                 }else Blackout_Kick_Timer -= diff;					

                DoMeleeAttackIfReady();
            }
        };
};

class pandaria_global_playerlogin : public PlayerScript
{
public:
   pandaria_global_playerlogin() : PlayerScript("pandaria_global_playerlogin_script") { }

    void OnLogin(Player* player)
    //void OnPlayerLogin(Player* player)
    {
    current_mapid = player->GetMapId();
    if(current_mapid == WANDERING_ISLE)
    {
       //TODO: quest add on first login flag
        if(player->hasQuest(QUEST_THE_LESSON_OF_STIFLED_PRIDE) && player->GetQuestStatus(QUEST_THE_LESSON_OF_STIFLED_PRIDE) == QUEST_STATUS_INCOMPLETE)
           player->SetPhaseMask(2, true); //open the gates, show huojin/tushui aggro
        if(player->hasQuest(QUEST_THE_LESSON_OF_STIFLED_PRIDE) && player->GetQuestStatus(QUEST_THE_LESSON_OF_STIFLED_PRIDE) == QUEST_STATUS_COMPLETE)
           player->SetPhaseMask(4, true); //show master
        if(player->hasQuest(QUEST_DISCIPLE_CHALLENGE) && player->GetQuestStatus(QUEST_DISCIPLE_CHALLENGE) == QUEST_STATUS_INCOMPLETE)
           player->SetPhaseMask(8, true); //show aggro-type Jaomin
        if(player->hasQuest(QUEST_DISCIPLE_CHALLENGE) && player->GetQuestStatus(QUEST_DISCIPLE_CHALLENGE) == QUEST_STATUS_COMPLETE)
           player->SetPhaseMask(16, true); //Jaomin defeated, master appears on bridge
    }
  
    }

private:
int32 current_mapid;
    enum enums
    {
        WANDERING_ISLE = 860,  //pandaria starting-zone
    };
};

void AddSC_wandering_isle()
{
    new npc_first_quest_pandaren();

    //new npc_trainee_stifled_pride();
    new npc_aysa_cloudsinger_quest29414();
    new stalker_item_equiped();
    new mob_jaomin_ro();
    new mob_attacker_dimwind();
    new spell_summon_living_air();
    new go_brazier_of_flickering_flames();

    new npc_shang_xi_begin();
    new gob_edict_of_temperance_the_lesson_of_the_burning_scroll();
    new vehicle_balance_pole();
    new mob_training_target();
    new mob_asp_trainee();
    new mob_tushui_trainee();
    new mob_min_dimwind();

    new pandaria_global_playerlogin();
}
A la ligne 1336 il y a un appel à une fonction 0() ?!?

Retourner en haut WoW-Emu