PHP Code:
/*
 * Copyright (C) 2011-2015 Project SkyFire <http://www.projectskyfire.org/>
 * Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/>
 * Copyright (C) 2005-2015 MaNGOS <http://getmangos.com/>
 * Copyright (C) 2006-2014 ScriptDev2 <https://github.com/scriptdev2/scriptdev2/>
 *
 * 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 3 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"

/*####
## npc_defiant_troll (http://www.wowhead.com/quest=14069)
####*/

enum DefiantTrollEnum
{
    
DEFFIANT_KILL_CREDIT               34830,
    
SPELL_LIGHTNING_VISUAL             45870,
    
SPELL_ENRAGE                       45111,
    
QUEST_GOOD_HELP_IS_HARD_TO_FIND    14069,
    
GO_DEPOSIT                         195489,
    
SAY_WORK                           0
};

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

    
CreatureAIGetAI(Creaturecreature) const override
    
{
        return new 
npc_defiant_trollAI(creature);
    }

    
struct npc_defiant_trollAI : public ScriptedAI
    
{
        
npc_defiant_trollAI(Creaturecreature) : ScriptedAI(creature) { }

        
uint32 rebuffTimer;
        
bool work;

        
void Reset() override
        
{
            
rebuffTimer 0;
            
work false;
            
me->CastSpell(meSPELL_ENRAGEtrue);
        }

        
void MovementInform(uint32 /*type*/uint32 idoverride
        
{
            if (
id == 1)
                
work true;
        }

        
bool IsWorking() const { return work; }

        
void UpdateAI(uint32 diffoverride
        
{
            if (
IsWorking())
                
me->HandleEmoteCommand(EMOTE_ONESHOT_WORK_MINING);

            if (
rebuffTimer <= diff)
            {
                
Reset();

                switch (
urand(02))
                {
                    case 
0:
                        
me->HandleEmoteCommand(EMOTE_STATE_EXCLAIM);
                        break;
                    case 
1:
                        
me->HandleEmoteCommand(EMOTE_STATE_DANCE);
                        break;
                    case 
2:
                        
me->HandleEmoteCommand(EMOTE_ONESHOT_NONE);
                        break;
                }
                
rebuffTimer 120000// Rebuff again in 2 minutes
            
}
            else
                
rebuffTimer -= diff;

            if (!
UpdateVictim())
                return;

            
//DoMeleeAttackIfReady();
        
}
    };

    
bool OnGossipHello(PlayerplayerCreaturecreatureoverride
    
{
        if (
player->GetQuestStatus(QUEST_GOOD_HELP_IS_HARD_TO_FIND) == QUEST_STATUS_INCOMPLETE && !CAST_AI(npc_defiant_troll::npc_defiant_trollAIcreature->AI())->IsWorking())
        {
            
player->CastSpell(creatureSPELL_LIGHTNING_VISUALtrue);
            
player->KilledMonsterCredit(DEFFIANT_KILL_CREDITcreature->GetGUID());
            
creature->AI()->Talk(SAY_WORK);
            
creature->RemoveAllAuras();

            if (
GameObjectdeposit creature->FindNearestGameObject(GO_DEPOSIT20))
                
creature->GetMotionMaster()->MovePoint(1deposit->GetPositionX() - 1.0fdeposit->GetPositionY(), deposit->GetPositionZ());

            if (
player->GetQuestStatus(QUEST_GOOD_HELP_IS_HARD_TO_FIND) == QUEST_STATUS_COMPLETE)
                
player->RemoveAura(SPELL_LIGHTNING_VISUAL);

            
player->CLOSE_GOSSIP_MENU();

            return 
true;
        }

        
player->CLOSE_GOSSIP_MENU();

        return 
false;
    }
};

void AddSC_kezan()
{
    new 
npc_defiant_troll();

PHP Code:
UPDATE `creature_templateSET `ScriptName` = 'npc_defiant_troll' WHERE `entry` = 34830;

DELETE FROM `creature_textWHERE `entry` = 34830;
INSERT INTO `creature_text`(`entry`, `groupid`, `id`, `text`, `type`, `language`, `probability`, `emote`, `duration`, `sound`, `comment`) VALUES 
(3483000'Oops, break''s over.'140100000'defiant troll says'),
(
3483001'Don''t tase me, mon!'140100000'defiant troll says'),
(
3483002'I report you to HR!'140100000'defiant troll says'),
(
3483003'Work was bettah in da Undermine!'140100000'defiant troll says'),
(
3483004'I''m going. I''m going!'140100000'defiant troll says'),
(
3483005'Sorry, mon. It won''t happen again.'140100000'defiant troll says'),
(
3483006'What I doin'' wrong? Don''t I get a lunch and two breaks a day, mon?'140100000'defiant troll says'),
(
3483007'Ouch! Dat hurt!'140100000'defiant troll says'); 





› See More: [C++] Kezahn.cpp Patch 4.3.4