Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement support for training dummy #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 46 additions & 0 deletions scripts/world/npcs_special.cpp
Expand Up @@ -30,6 +30,7 @@ EndScriptData

/* ContentData
npc_air_force_bots 80% support for misc (invisible) guard bots in areas where player allowed to fly. Summon guards after a preset time if tagged by spell
npc_training_dummy 100% Used for training dummy
npc_chicken_cluck 100% support for quest 3861 (Cluck!)
npc_dancing_flames 100% midsummer event NPC
npc_guardian 100% guardianAI used to prevent players from accessing off-limits areas. Not in use by SD2
Expand Down Expand Up @@ -244,6 +245,46 @@ CreatureAI* GetAI_npc_air_force_bots(Creature* pCreature)
return new npc_air_force_botsAI(pCreature);
}

/*########
# npc_training_dummy
#########*/

#define OUT_OF_COMBAT_TIME 5000

struct MANGOS_DLL_DECL npc_training_dummy : public Scripted_NoMovementAI
{
npc_training_dummy(Creature* pCreature) : Scripted_NoMovementAI(pCreature) {Reset();}

uint32 combat_timer;

void Reset()
{
combat_timer = 0;
}

void DamageTaken(Unit* pDoneBy, uint32 &uiDamage)
{
combat_timer = 0;
}

void UpdateAI(const uint32 uiDiff)
{
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
return;

m_creature->SetHealth(m_creature->GetMaxHealth());

combat_timer += uiDiff;
if (combat_timer > OUT_OF_COMBAT_TIME)
EnterEvadeMode();
}
};

CreatureAI* GetAI_npc_training_dummy(Creature* pCreature)
{
return new npc_training_dummy(pCreature);
}

/*########
# npc_chicken_cluck
#########*/
Expand Down Expand Up @@ -1366,6 +1407,11 @@ void AddSC_npcs_special()
pNewScript->GetAI = &GetAI_npc_air_force_bots;
pNewScript->RegisterSelf();

pNewScript = new Script;
pNewScript->Name = "npc_training_dummy";
pNewScript->GetAI = &GetAI_npc_training_dummy;
pNewScript->RegisterSelf();

pNewScript = new Script;
pNewScript->Name = "npc_chicken_cluck";
pNewScript->GetAI = &GetAI_npc_chicken_cluck;
Expand Down