All pastes #829816 Raw Edit

Someone

public text v1 · immutable
#829816 ·published 2007-12-23 14:40 UTC
rendered paste body
#define stomp 6432
#define hammer_buff 6436
class MrSmiteAI : public CreatureAIScript
{
public:
    ADD_CREATURE_FACTORY_FUNCTION(MrSmiteAI);

    MrSmiteAI(Creature * pCreature) : CreatureAIScript(pCreature) 
	{
		smite_stomp = dbcSpell.LookupEntry(stomp);
		smite_buff = dbcSpell.LookupEntry(hammer_buff);
	}

    void OnCombatStart(Unit * mTarget)
    {
        phase = 0;
	move = 0;
	looting = 0;
	position = 0;
    }

    void OnDamageTaken(Unit * mAttacker, float fAmount)
    {
        if(_unit->GetHealthPct() <= 66 && phase == 0)
        {
	    _unit->GetMapMgr()->GetInterface()->SpawnCreature(1, 2.69086f, -781.633f,  0.0f, 0, false, false, 0, 0);
	    waypoint = _unit->GetMapMgr()->GetInterface()->GetCreatureNearestCoords(2.69086f, -781.633f, 0.0f, 1);
	    waypoint->GetAIInterface()->disable_melee = true;
	    waypoint->m_canMove = false;
	    Playr = _unit->GetAIInterface()->GetNextTarget();

            _unit->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "You landlubbers are tougher than I thought. I'll have to improvise!");
            _unit->PlaySoundToSet(5778);
	    _unit->Emote(EMOTE_ONESHOT_STOMP);
	    _unit->CastSpell(Playr, smite_stomp, true);
            phase++;
	    move = 1;
	    position = 1;
            RegisterAIUpdateEvent(800);
        }
        else if(_unit->GetHealthPct() <= 33 && phase == 1)
        {
	    Playr = _unit->GetAIInterface()->GetNextTarget();
			
            _unit->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "D'ah! Now you're making me angry!");
            _unit->PlaySoundToSet(5779);
	    _unit->Emote(EMOTE_ONESHOT_STOMP);
	    _unit->CastSpell(Playr, smite_stomp, true);
            phase++;
	    move = 1;
	    position = 1;
            RegisterAIUpdateEvent(800);
        }
    }

    void OnCombatStop(Unit * mTarget)
    {
        _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL);
        _unit->GetAIInterface()->SetAIState(STATE_IDLE);
        RemoveAIUpdateEvent();
        phase = 0;
	looting = 0;
	move = 0;
	position = 0;
        weapons();
    }

    void OnDied(Unit * mKiller)
    {
        phase = 0;
	looting = 0;
	move = 0;
	position = 0;
        RemoveAIUpdateEvent();
    }

    void AIUpdate()
    {
		if(looting == 1)
		{
			_unit->GetAIInterface()->SetNextTarget(_unit->GetAIInterface()->GetMostHated());
			looting = 0;
			weapons();
			_unit->Emote(EMOTE_ONESHOT_NONE); // maybe EMOTE_STATE_STAND if its crashing
			_unit->GetAIInterface()->SetAIState(STATE_ATTACKING);
		}

		if(_unit->GetPositionX() == 1.100060f && _unit->GetPositionY() == -780.026367f && _unit->GetPositionZ() == 9.811194f && position == 1)
		{
	        _unit->Emote(EMOTE_ONESHOT_KNEEL);
			looting = 1;
			position = 0;
			ModifyAIUpdateEvent(3000);
		}

		if(move == 1)
		{
			move = 0;
			movetochest();
		}
    }

	void movetochest()
	{
		_unit->GetAIInterface()->SetNextTarget(waypoint);
		_unit->GetAIInterface()->SetAIState(STATE_SCRIPTMOVE);
		_unit->GetAIInterface()->MoveTo(1.100060f, -780.026367f, 9.811194f, 5.452218f);
	}

    void weapons()
    {
        switch(phase)
        {
        case 0:
            _unit->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 7420);
            _unit->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO, 33490690);
            _unit->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO_01, 768);
            _unit->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_01, 0);
            _unit->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO_02, 0);
            _unit->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO_03, 0);
	    _unit->SetUInt32Value(UNIT_FIELD_BASEATTACKTIME, 1483);   // 1483 is taken from NCDB creature_proto
            break;
        case 1:
            _unit->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_01, 7419);
            _unit->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO_02, 33490690);
            _unit->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO_03, 781);
	    _unit->SetUInt32Value(UNIT_FIELD_BASEATTACKTIME, _unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME) / 2);
            break;
        case 2:
            _unit->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 19610);
            _unit->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO, 33488898);
            _unit->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO_01, 0);
            _unit->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_01, 0);
            _unit->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO_02, 0);
            _unit->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO_03, 0);
            _unit->SetUInt32Value(UNIT_FIELD_BYTES_2, 1);
	    _unit->SetUInt32Value(UNIT_FIELD_BASEATTACKTIME, _unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME) * 2);
	    _unit->CastSpell(_unit, smite_buff, true);
        }
        RemoveAIUpdateEvent();
    }

protected:
	SpellEntry * smite_stomp;
	SpellEntry * smite_buff;
	Unit * Playr;
	Unit * waypoint;
        int phase , move, looting, position;
};