Jump to content

Snake Trap


Guest _VENOM_

Recommended Posts

  • 3 weeks later...
  • 3 weeks later...

src/game/Pet.cpp
@@ -1219,6 +1219,17 @@ bool Pet::InitStatsForLevel(uint32 petlevel, Unit* owner)
        SetModifierValue(UnitMods(UNIT_MOD_RESISTANCE_START + i), BASE_VALUE, float(createResistance[i]));

    UpdateAllStats();
+    
+    if(getPetType() == GUARDIAN_PET)
+        switch (GetEntry())
+    {
+        case 19833: //Snake Trap - Venomous Snake
+            SetMaxHealth(94);
+            break;
+        case 19921: //Snake Trap - Viper
+            SetMaxHealth(96);
+            break;
+    }

    SetHealth(GetMaxHealth());
    SetPower(POWER_MANA, GetMaxPower(POWER_MANA));

The function UpdateAllStats() modify maxhealth with the different stats, you must define the maxhealth after that.

Link to comment
Share on other sites

src/game/Pet.cpp
@@ -1219,6 +1219,17 @@ bool Pet::InitStatsForLevel(uint32 petlevel, Unit* owner)
        SetModifierValue(UnitMods(UNIT_MOD_RESISTANCE_START + i), BASE_VALUE, float(createResistance[i]));

    UpdateAllStats();
+    
+    if(getPetType() == GUARDIAN_PET)
+        switch (GetEntry())
+    {
+        case 19833: //Snake Trap - Venomous Snake
+            SetMaxHealth(94);
+            break;
+        case 19921: //Snake Trap - Viper
+            SetMaxHealth(96);
+            break;
+    }

    SetHealth(GetMaxHealth());
    SetPower(POWER_MANA, GetMaxPower(POWER_MANA));

The function UpdateAllStats() modify maxhealth with the different stats, you must define the maxhealth after that.

But snakes are still attacking me, this only fixes the maxhealth.

Link to comment
Share on other sites

capturyhy.png

capturntn.png

capturaza.png

/*####
## npc_snake_trap_serpents - Summonned snake id are 19921 and 19833
####*/

#define SPELL_MIND_NUMBING_POISON    25810   //Viper
#define SPELL_CRIPPLING_POISON       30981    //Viper
#define SPELL_DEADLY_POISON          34655   //Venomous Snake

#define MOB_VIPER 19921

#define VENOMOUS_SNAKE_TIMER 1500
#define VIPER_TIMER 3000

struct MANGOS_DLL_DECL npc_snake_trap_serpentsAI : public ScriptedAI
{
   npc_snake_trap_serpentsAI(Creature *c) : ScriptedAI(c) {}

   uint32 SpellTimer;
   bool IsViper;

   void EnterCombat(Unit *who) {}

   void Reset()
   {
       SpellTimer = 0;

       Unit *Owner = m_creature->GetOwner();
       if (!m_creature->isPet() || !Owner) return;

       CreatureInfo const *Info = m_creature->GetCreatureInfo();

       if (Info->Entry == MOB_VIPER)
           IsViper = true;
       else
           IsViper = false;

   }

   //Redefined for random target selection:
   void MoveInLineOfSight(Unit *who)
   {
       if (!m_creature->getVictim() && who->isTargetableForAttack() && (m_creature->IsHostileTo(who)) && who->isInAccessablePlaceFor(m_creature))
       {
           if (m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
               return;

           float attackRadius = m_creature->GetAttackDistance(who);
           if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who))
           {
               if (!(rand() % 5))
               {
                   m_creature->setAttackTimer(BASE_ATTACK, (rand() % 10) * 100);
                   SpellTimer = (rand() % 10) * 100;
                   AttackStart(who);
               }
           }
       }
   }

   void UpdateAI(const uint32 diff)
   {
       Unit *Owner = m_creature->GetOwner();

       if (!m_creature->isPet() || !Owner) return;

       if (!m_creature->getVictim())
       {
           if (m_creature->isInCombat())
               DoStopAttack();

           if (Owner->getAttackerForHelper())
               AttackStart(Owner->getAttackerForHelper());
           return;
       }

       if (SpellTimer <= diff)
       {
           if (IsViper) //Viper - 19921
           {
               if (urand(0,2) == 0) //33% chance to cast
               {
                   uint32 spell;
                   if (urand(0,1) == 0)
                       spell = SPELL_MIND_NUMBING_POISON;
                   else
                       spell = SPELL_CRIPPLING_POISON;

                   m_creature->CastSpell(m_creature->getVictim(), spell, true);
               }

               SpellTimer = VIPER_TIMER;
           }
           else //Venomous Snake - 19833
           {
               if (urand(0,2) == 0) //80% chance to cast
                   m_creature->CastSpell(m_creature->getVictim(), SPELL_DEADLY_POISON, true);
               SpellTimer = VENOMOUS_SNAKE_TIMER + (rand() %5)*100;
           }
       } else SpellTimer -= diff;
       DoMeleeAttackIfReady();
   }
};

CreatureAI* GetAI_npc_snake_trap_serpents(Creature* pCreature)
{
   return new npc_snake_trap_serpentsAI(pCreature);
}

Link to comment
Share on other sites

I have added the Milk13 script into my SD2, with the lastest revisions of MaNGOS. I have used this SQL:

UPDATE creature_template SET scriptname=npc_snake_trap_serpents WHERE entry IN (19921, 19833);

and also added this:

newscript = new Script;    
   newscript->Name = "npc_snake_trap_serpents";    
   newscript->GetAI = &GetAI_npc_snake_trap_serpents;
   newscript->RegisterSelf();

Now the snakes are green for the owner, but they do nothing, they appear, they don't attack mobs or enemy players, and they disappear. Could someone help me?

Link to comment
Share on other sites

Or another solution that works very well without script:

UPDATE `creature_template` SET `faction_A` = 1802,`faction_H` = 1801, `family` = 35 WHERE `entry` = 19833;         
UPDATE `creature_template` SET `faction_A` = 1802,`faction_H` = 1801, `family` = 35 WHERE `entry` = 19921;

Link to comment
Share on other sites

Or another solution that works very well without script:

UPDATE `creature_template` SET `faction_A` = 1802,`faction_H` = 1801, `family` = 35 WHERE `entry` = 19833;         
UPDATE `creature_template` SET `faction_A` = 1802,`faction_H` = 1801, `family` = 35 WHERE `entry` = 19921;

does this work on arena system or pvp? or does it work only in pve?

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