[Bug] Snake Trap

Issue #622 invalid
Flywithme created an issue

http://tbc.wowroad.info/?spell=34600 - not working properly.

Snakes break players out of stealth, if the snakes pass near the stealthed character

Information from wowwiki: Patch 2.4.3 (2008-07-15): Snake Trap will no longer break players out of stealth if the snakes pass near the stealthed character.

Comments (3)

  1. Alexander

    Our script:

    /*####
    ## npc_snake_trap_serpents
    ####*/
    
    #define SPELL_MIND_NUMBING_POISON    8692    //Viper
    #define SPELL_DEADLY_POISON          34655   //Venomous Snake
    #define SPELL_CRIPPLING_POISON       3409    //Viper
    
    #define VENOMOUS_SNAKE_TIMER 1200
    #define VIPER_TIMER 3000
    
    #define C_VIPER 19921
    
    struct npc_snake_trap_serpentsAI : public ScriptedAI
    {
        npc_snake_trap_serpentsAI(Creature *c) : ScriptedAI(c) {}
    
        uint32 SpellTimer;
        bool IsViper;
        bool Spawn;
    
        void EnterCombat(Unit * /*who*/) {}
    
        void Reset()
        {
           Spawn = true;
           SpellTimer = 0;
    
            CreatureInfo const *Info = me->GetCreatureInfo();
    
            if (Info->Entry == C_VIPER)
                IsViper = true;
            else
                IsViper = false;
    
            //Add delta to make them not all hit the same time
            uint32 delta = (rand() % 7) * 100;
            me->SetStatFloatValue(UNIT_FIELD_BASEATTACKTIME, Info->baseattacktime + delta);
            me->SetStatFloatValue(UNIT_FIELD_RANGED_ATTACK_POWER , Info->attackpower);
        }
    
        //Redefined for random target selection:
        void MoveInLineOfSight(Unit *who)
        {
            if (!me->getVictim() && who->isTargetableForAttack() && (me->IsHostileTo(who)) && who->isInAccessiblePlaceFor(me))
            {
                if (me->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
                    return;
    
                float attackRadius = me->GetAttackDistance(who);
                if (me->IsWithinDistInMap(who, attackRadius) && me->IsWithinLOSInMap(who))
                {
                    if (!(rand() % 5))
                    {
                        me->setAttackTimer(BASE_ATTACK, (rand() % 10) * 100);
                        SpellTimer = (rand() % 10) * 100;
                        AttackStart(who);
                    }
                }
            }
        }
    
        void UpdateAI(const uint32 diff)
        {
            if (Spawn)
            {
              Spawn = false;
                   // Start attacking attacker of owner on first ai update after spawn - move in line of sight may choose better target
                   if (!me->getVictim() && me->isSummon())
                   if (Unit * Owner = CAST_SUM(me)->GetSummoner())
                           if (Owner->getAttackerForHelper())
                           AttackStart(Owner->getAttackerForHelper());  
            }
    
            if (!me->getVictim())
            {
                if (me->isInCombat())
                    DoStopAttack();
                return;
            }
    
            if (SpellTimer <= diff)
            {
                if (IsViper) //Viper
                {
                    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;
    
                        DoCast(me->getVictim(), spell);
                    }
    
                    SpellTimer = VIPER_TIMER;
                }
                else //Venomous Snake
                {
                    if (urand(0,2) == 0) //33% chance to cast
                        DoCast(me->getVictim(), SPELL_DEADLY_POISON);
                    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);
    }
    
  2. LordUsagi

    Add in a check who->isVisibleFor or me->canseeordetect

    Otherwise this is not the script oregon uses, so I'll be closing it.

  3. Log in to comment