Jump to content

Training Dummy


Guest deviljohn

Recommended Posts

Mangos Version: 9527

Custom Patches: Blueboy's Playerbot, Naicisum's AHBot

SD2 Version: 1631

Database Name and Version : YTDB 0.11.0 rev. 537

How it SHOULD work: Train on the dummy and walk away.

How it DOES work: Train on the dummy, when you walk away it then follows you around pissed off. :)

This happened in Stormwind building SI:7 on a level 10 human rogue.

Link to comment
Share on other sites

you can use this script:

#include "precompiled.h"

#define OUT_OF_COMBAT_TIME 5000

struct MANGOS_DLL_DECL npc_training_dummyAI : public Scripted_NoMovementAI
{
   uint32 combat_timer;

   npc_training_dummyAI(Creature* pCreature) : Scripted_NoMovementAI(pCreature)
   {
       Reset();
   }

   void Reset()
   {
       combat_timer = 0;
   }

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

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

       m_creature->ModifyHealth(m_creature->GetMaxHealth());

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

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

void AddSC_npc_training_dummy()
{
   Script *newscript = new Script;
   newscript->Name = "npc_training_dummy";
   newscript->GetAI = &GetAI_npc_training_dummy;
   newscript->RegisterSelf();
}

still need to avoid it turning to the player (so you can use backstab-like moves)

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

-- Heroic Training Dummy (31146)

UPDATE creature_template SET
AIName='EventAI'
WHERE entry=31146;

-- No movement and attack
DELETE FROM creature_ai_scripts WHERE id=3114601;
INSERT INTO creature_ai_scripts VALUES
(3114601,31146,4,0,100,0,0,0,0,0,21,0,0,0,20,0,0,0,0,0,0,0,'Heroic Training Dummy - No movement and attack');

Makes training dummy no attack, no movement.

Link to comment
Share on other sites

  • 4 months later...
I think the easiest will be to just stun the mob

Stun do not work.

to prevent a creature from spinning around:

m_creature->SetTargetGUID(0);

must be executed on each Update

Thanks mate, thats it!

If someone need mine, here it is :)

Index: scripts/world/npcs_special.cpp
===================================================================
--- scripts/world/npcs_special.cpp    (revision 1828)
+++ scripts/world/npcs_special.cpp    (working copy)
@@ -1750,6 +1750,52 @@
    return true;
}

+/*######
+## npc_training_dummy
+######*/
+#define OUT_OF_COMBAT_TIME 5000
+
+struct MANGOS_DLL_DECL npc_training_dummyAI : public Scripted_NoMovementAI
+{
+    npc_training_dummyAI(Creature* pCreature) : Scripted_NoMovementAI(pCreature)
+    {
+        Reset();
+    }
+
+    uint32 combat_timer;
+
+    void Reset()
+    {
+        //m_creature->addUnitState(UNIT_STAT_STUNNED);
+        combat_timer = 0;
+    }
+
+    void DamageTaken(Unit* pDoneBy, uint32 &uiDamage)
+    {
+        combat_timer = 0;
+    }
+
+    void UpdateAI(const uint32 diff)
+    {
+        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
+        return;
+      
+        if (m_creature->GetHealthPercent() < 10.0f) // allow players using finishers
+        m_creature->ModifyHealth(m_creature->GetMaxHealth());
+
+        m_creature->SetTargetGUID(0); // prevent from rotating
+        combat_timer += diff;
+
+        if (combat_timer > OUT_OF_COMBAT_TIME)
+        EnterEvadeMode();
+    }
+};
+
+CreatureAI* GetAI_npc_training_dummy(Creature* pCreature)
+{
+return new npc_training_dummyAI(pCreature);
+}
+
void AddSC_npcs_special()
{
    Script* newscript;
@@ -1839,4 +1885,9 @@
    newscript->pGossipHello =  &GossipHello_npc_locksmith;
    newscript->pGossipSelect = &GossipSelect_npc_locksmith;
    newscript->RegisterSelf();
+
+    newscript = new Script;
+    newscript->Name = "npc_training_dummy";
+    newscript->GetAI = &GetAI_npc_training_dummy;
+    newscript->RegisterSelf();
}
Index: sql/Training Dummy.sql
===================================================================
--- sql/Training Dummy.sql    (revision 0)
+++ sql/Training Dummy.sql    (revision 0)
@@ -0,0 +1 @@
+update creature_template set AiName = '', Scriptname = 'npc_training_dummy' where entry in (17578, 24792, 32543, 32546, 32542, 32545, 30527, 31143, 31144, 31146, 32541, 32666, 32667);
\\ No newline at end of file

Link to comment
Share on other sites

  • 11 months later...

you must figure a few things:

- should these mobs enter combat?

- if they do, when/ how should they evade.

For the rest you mainly just need to add a minimalistic UpdateAI function and an empty AttackStart function;

However in my view there are similar problems with lots of trigger mobs, so I really think a more generic solution should be tried to figure.

Link to comment
Share on other sites

you must figure a few things:

- should these mobs enter combat?

- if they do, when/ how should they evade.

For the rest you mainly just need to add a minimalistic UpdateAI function and an empty AttackStart function;

However in my view there are similar problems with lots of trigger mobs, so I really think a more generic solution should be tried to figure.

The mobs should enter combat i think, and leave combat after 5 sec, but they need to "keep orientation" so you can backstab them etc... without them facing you, if you see what i mean

- LilleCarl

Link to comment
Share on other sites

struct SD2 ScriptedAI
{
 <constructor> {m_uiEvadeTimer = 0;}

 uint32 m_uiEvadeTimer;

 void Reset() {}

 void MoveInLineOfSight(Unit*) {}
 void AttackStart(Unit*) {}
 void AttackedBy(Unit*) { m_uiEvadeTimer = 5000; }
 void UpdateAI(uint32 const uiDiff)
 {
    if (m_creature->IsInCombat())
    {
        if (m_uiEvadeTimer < uiDiff)
             EnterEvadeMode();
        else
            m_uiEvadeTimer -= uiDiff;
    }
 }
};

This should be the reqired structure for such things, assuming that the mob should really enter combat.

Link to comment
Share on other sites

If you can tell me a damage spell that takes longer than 5s to cast... ^^

And yes, you do enter combat, and leave about 5s after you stop attacking, just tried retail.

Offtopic: Actually i think most "normal" mobs have timer based combat reset, they don't seem to unconditionally reset once you crossed a certain radius from their spawn location...

Link to comment
Share on other sites

I have a good training dummy. at this dummy players can also use finisher. and no rotation^^

/*######
## npc_training_dummy
######*/
#define OUT_OF_COMBAT_TIME 5000
#define AFK_TIME 300000

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

   uint32 afk_timer;
   uint32 combat_timer;

   void Reset()
   {
       //m_creature->addUnitState(UNIT_STAT_STUNNED);
       combat_timer = 0;
       afk_timer = 0;
   }

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

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

       if (m_creature->GetHealthPercent() < 10.0f) // allow players using finishers
       m_creature->ModifyHealth(m_creature->GetMaxHealth());

       m_creature->SetTargetGuid(ObjectGuid()); // prevent from rotating
       combat_timer += diff;
       afk_timer += diff;

       if (combat_timer > OUT_OF_COMBAT_TIME || afk_timer > AFK_TIME)
       EnterEvadeMode();
   }
};

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

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use