Esempio n. 1
0
    void CheckAltars()
    {
        GameObject* pSladRanAltar = instance->GetGameObject(uiSladRanAltar);
        GameObject* pMoorabiAltar = instance->GetGameObject(uiMoorabiAltar);
        GameObject* pDrakkariColossusAltar = instance->GetGameObject(uiDrakkariColossusAltar);

        if (pSladRanAltar && pSladRanAltar->GetGoState() == GO_STATE_ACTIVE &&
            pMoorabiAltar && pMoorabiAltar->GetGoState() == GO_STATE_ACTIVE &&
            pDrakkariColossusAltar && pDrakkariColossusAltar->GetGoState() == GO_STATE_ACTIVE)
        {
            HandleGameObject(uiBridge,false);
            HandleGameObject(uiCollision,false);
        }
    }
void BattlegroundRV::UpdatePillars()
{
    GameObject* test = GetBgMap()->GetGameObject(BgObjects[BG_RV_OBJECT_PILAR_1]);
    if (!test)
        return;

    if (test->GetGoState() == GO_STATE_READY)
    {
        for (uint8 i = BG_RV_OBJECT_PILAR_1; i <= BG_RV_OBJECT_GEAR_2; ++i)
            if (GameObject* go = GetBgMap()->GetGameObject(BgObjects[i]))
                go->SetGoState(GO_STATE_ACTIVE);
        for (uint8 i = BG_RV_OBJECT_PILAR_2; i <= BG_RV_OBJECT_PULLEY_2; ++i)
            if (GameObject* go = GetBgMap()->GetGameObject(BgObjects[i]))
                go->SetGoState(GO_STATE_READY);
    }
    else
    {
        for (uint8 i = BG_RV_OBJECT_PILAR_1; i <= BG_RV_OBJECT_GEAR_2; ++i)
            if (GameObject* go = GetBgMap()->GetGameObject(BgObjects[i]))
                go->SetGoState(GO_STATE_READY);
        for (uint8 i = BG_RV_OBJECT_PILAR_2; i <= BG_RV_OBJECT_PULLEY_2; ++i)
            if (GameObject* go = GetBgMap()->GetGameObject(BgObjects[i]))
                go->SetGoState(GO_STATE_ACTIVE);
    }
}
Esempio n. 3
0
bool instance_onyxias_lair::FissureSurge(Creature *onyxia)
{
	if (m_liveLavaFissures[0].empty() && m_liveLavaFissures[1].empty() && m_liveLavaFissures[2].empty())
		return false;

    GameObject *firstFissure = NULL;
    GameObject *secondFissure = NULL;
	for (int liveList=0; liveList < 3; liveList++)
	{
		if (!m_liveLavaFissures[liveList].empty())
		{
			GameObject *fissure = m_liveLavaFissures[liveList].front();
			m_liveLavaFissures[liveList].pop_front();

            if (liveList == 1 && firstFissure != NULL && firstFissure->IsWithinDist2d(fissure->GetPositionX(),fissure->GetPositionY(),10))
                continue;

            if (liveList == 2 && secondFissure != NULL && secondFissure->IsWithinDist2d(fissure->GetPositionX(),fissure->GetPositionY(),10))
                continue;

            if (fissure->GetGoState() == GO_STATE_READY)
            {
				onyxia->CastSpell(fissure->GetPositionX(),fissure->GetPositionY(),fissure->GetPositionZ(),SPELL_ERUPTION,true);

                if (liveList == 0)
                    firstFissure = fissure;
                else if (liveList == 1)
                    secondFissure = fissure;
            } else
                m_liveLavaFissures[liveList].push_back(fissure);
		}
	}

	return true;
}
Esempio n. 4
0
    void OnUpdate(GameObject* go, uint32 diff)
    {
        if (opened == 1)
        {
            if (tQuestCredit <= ((float)diff/8))
            {
                opened = 0;
                aPlayer->KilledMonsterCredit(35830, 0);
                if (spawnKind == 3)
                {
                    if (Creature* spawnedCreature = go->SummonCreature(NPC_RAMPAGING_WORGEN_2, wx, wy, z, angle, TEMPSUMMON_TIMED_DESPAWN, SUMMON1_TTL))
                    {
                        spawnedCreature->SetPhaseMask(6, 1);
                        spawnedCreature->Respawn(1);
                        spawnedCreature->getThreatManager().resetAllAggro();
                        aPlayer->AddThreat(spawnedCreature, 1.0f);
                        spawnedCreature->AddThreat(aPlayer, 1.0f);
                    }
                }
            }
            else tQuestCredit -= ((float)diff/8);
        }
        if (DoorTimer <= diff)
            {
                if (go->GetGoState() == GO_STATE_ACTIVE)
                    go->SetGoState(GO_STATE_READY);

                DoorTimer = DOOR_TIMER;
            }
        else
            DoorTimer -= diff;
    }
Esempio n. 5
0
inline void Map::_ScriptProcessDoor(Object* source, Object* target, const ScriptInfo* scriptInfo) const
{
    bool bOpen = false;
    ObjectGuid::LowType guid = scriptInfo->ToggleDoor.GOGuid;
    int32 nTimeToToggle = std::max(15, int32(scriptInfo->ToggleDoor.ResetDelay));
    switch (scriptInfo->command)
    {
        case SCRIPT_COMMAND_OPEN_DOOR: bOpen = true; break;
        case SCRIPT_COMMAND_CLOSE_DOOR: break;
        default:
            TC_LOG_ERROR("scripts", "%s unknown command for _ScriptProcessDoor.", scriptInfo->GetDebugInfo().c_str());
            return;
    }
    if (!guid)
        TC_LOG_ERROR("scripts", "%s door guid is not specified.", scriptInfo->GetDebugInfo().c_str());
    else if (!source)
        TC_LOG_ERROR("scripts", "%s source object is NULL.", scriptInfo->GetDebugInfo().c_str());
    else if (!source->isType(TYPEMASK_UNIT))
    {
        TC_LOG_ERROR("scripts", "%s source object is not unit (TypeId: %u, Entry: %u, %s), skipping.", scriptInfo->GetDebugInfo().c_str(),
            source->GetTypeId(), source->GetEntry(), source->GetGUID().ToString().c_str());
    }
    else
    {
        WorldObject* wSource = dynamic_cast <WorldObject*> (source);
        if (!wSource)
        {
            TC_LOG_ERROR("scripts", "%s source object could not be cast to world object (TypeId: %u, Entry: %u, %s), skipping.",
                scriptInfo->GetDebugInfo().c_str(), source->GetTypeId(), source->GetEntry(), source->GetGUID().ToString().c_str());
        }
        else
        {
            GameObject* pDoor = _FindGameObject(wSource, guid);
            if (!pDoor)
                TC_LOG_ERROR("scripts", "%s gameobject was not found (guid: " UI64FMTD ").", scriptInfo->GetDebugInfo().c_str(), guid);
            else if (pDoor->GetGoType() != GAMEOBJECT_TYPE_DOOR)
            {
                TC_LOG_ERROR("scripts", "%s gameobject is not a door (GoType: %u, Entry: %u, %s).",
                    scriptInfo->GetDebugInfo().c_str(), pDoor->GetGoType(), pDoor->GetEntry(), pDoor->GetGUID().ToString().c_str());
            }
            else if (bOpen == (pDoor->GetGoState() == GO_STATE_READY))
            {
                pDoor->UseDoorOrButton(nTimeToToggle);

                if (target && target->isType(TYPEMASK_GAMEOBJECT))
                {
                    GameObject* goTarget = target->ToGameObject();
                    if (goTarget && goTarget->GetGoType() == GAMEOBJECT_TYPE_BUTTON)
                        goTarget->UseDoorOrButton(nTimeToToggle);
                }
            }
        }
    }
}
Esempio n. 6
0
 bool CheckContainmentSpheres(bool removePrison = false)
 {
     for (uint32 i = ANOMALUS_CONTAINMET_SPHERE; i < (ANOMALUS_CONTAINMET_SPHERE + DATA_CONTAINMENT_SPHERES); ++i)
     {
         GameObject* containmentSpheres = ObjectAccessor::GetGameObject(*me, instance->GetGuidData(i));
         if (!containmentSpheres || containmentSpheres->GetGoState() != GO_STATE_ACTIVE)
             return false;
     }
     if (removePrison)
         RemovePrison(true);
     return true;
 }
Esempio n. 7
0
    //show info of gameobject
    static bool HandleGameObjectInfoCommand(ChatHandler* handler, char const* args)
    {
        uint32 entry = 0;
        uint32 type = 0;
        uint32 displayId = 0;
        std::string name;
        uint32 lootId = 0;
        GameObject* gameObject = nullptr;

        if (!*args)
        {
            if (WorldObject* object = handler->getSelectedObject())
            {
                entry = object->GetEntry();
                if (object->GetTypeId() == TYPEID_GAMEOBJECT)
                    gameObject = object->ToGameObject();
            }
        }
        else
            entry = atoi((char*)args);

        GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(entry);

        if (!gameObjectInfo)
            return false;

        type = gameObjectInfo->type;
        displayId = gameObjectInfo->displayId;
        name = gameObjectInfo->name;
        if (type == GAMEOBJECT_TYPE_CHEST)
            lootId = gameObjectInfo->chest.lootId;
        else if (type == GAMEOBJECT_TYPE_FISHINGHOLE)
            lootId = gameObjectInfo->fishinghole.lootId;

        handler->PSendSysMessage(LANG_GOINFO_ENTRY, entry);
        handler->PSendSysMessage(LANG_GOINFO_TYPE, type);
        handler->PSendSysMessage(LANG_GOINFO_LOOTID, lootId);
        handler->PSendSysMessage(LANG_GOINFO_DISPLAYID, displayId);
        if (gameObject)
        {
            handler->PSendSysMessage("LootMode: %u", gameObject->GetLootMode());
            handler->PSendSysMessage("LootState: %u", gameObject->getLootState());
            handler->PSendSysMessage("GOState: %u", gameObject->GetGoState());
            handler->PSendSysMessage("PhaseMask: %u", gameObject->GetPhaseMask());
            handler->PSendSysMessage("IsLootEmpty: %u", gameObject->loot.empty());
            handler->PSendSysMessage("IsLootLooted: %u", gameObject->loot.isLooted());
        }

        handler->PSendSysMessage(LANG_GOINFO_NAME, name.c_str());

        return true;
    }
Esempio n. 8
0
bool GameObjectModel::initialize(const GameObject& go, const GameObjectDisplayInfoEntry& info)
{
    ModelList::const_iterator it = model_list.find(info.Displayid);
    if (it == model_list.end())
        return false;

    G3D::AABox mdl_box(it->second.bound);
    // ignore models with no bounds
    if (mdl_box == G3D::AABox::zero())
    {
        sLog->outError("GameObject model %s has zero bounds, loading skipped", it->second.name.c_str());
        return false;
    }

    iModel = ((VMAP::VMapManager2*)VMAP::VMapFactory::createOrGetVMapManager())->acquireModelInstance(sWorld->GetDataPath() + "vmaps/", it->second.name);

    if (!iModel)
        return false;

    name = it->second.name;
    //flags = VMAP::MOD_M2;
    //adtId = 0;
    //ID = 0;
    iPos = Vector3(go.GetPositionX(), go.GetPositionY(), go.GetPositionZ());

	// pussywizard: 
	phasemask = (go.GetGoState() == GO_STATE_READY || go.IsTransport()) ? go.GetPhaseMask() : 0;

    iScale = go.GetFloatValue(OBJECT_FIELD_SCALE_X);
    iInvScale = 1.f / iScale;

    G3D::Matrix3 iRotation = G3D::Matrix3::fromEulerAnglesZYX(go.GetOrientation(), 0, 0);
    iInvRot = iRotation.inverse();
    // transform bounding box:
    mdl_box = AABox(mdl_box.low() * iScale, mdl_box.high() * iScale);
    AABox rotated_bounds;
    for (int i = 0; i < 8; ++i)
        rotated_bounds.merge(iRotation * mdl_box.corner(i));

    iBound = rotated_bounds + iPos;
#ifdef SPAWN_CORNERS
    // test:
    for (int i = 0; i < 8; ++i)
    {
        Vector3 pos(iBound.corner(i));
        const_cast<GameObject&>(go).SummonCreature(1, pos.x, pos.y, pos.z, 0, TEMPSUMMON_MANUAL_DESPAWN);
    }
#endif

    owner = &go;
    return true;
}
Esempio n. 9
0
bool GOHello_go_door_lever_dm(Player *player, GameObject* _GO)
{
    ScriptedInstance* pInstance = (ScriptedInstance*)_GO->GetInstanceData();

    if (!pInstance)
        return false;

    GameObject *go = GameObject::GetGameObject(*player,pInstance->GetData64(DATA_DEFIAS_DOOR));
    if (go && go->GetGoState() == 1)
        return false;

    return true;
}
Esempio n. 10
0
bool GOUse_go_door_lever_dm(Player* pPlayer, GameObject* pGo)
{
    ScriptedInstance* pInstance = (ScriptedInstance*)pGo->GetInstanceData();

    if (!pInstance)
        return false;

    GameObject* pGoDoor = pInstance->instance->GetGameObject(pInstance->GetData64(DATA_DEFIAS_DOOR));

    if (pGoDoor && pGoDoor->GetGoState() == 1)
        return false;

    return true;
}
Esempio n. 11
0
// some doors aren't despawned so we cannot handle their closing in gameobject::update()
// it would be nice to correctly implement GO_ACTIVATED state and open/close doors in gameobject code
void BattleGround::DoorClose(ObjectGuid guid)
{
    GameObject* obj = GetBgMap()->GetGameObject(guid);
    if (obj)
    {
        // if doors are open, close it
        if (obj->getLootState() == GO_ACTIVATED && obj->GetGoState() != GO_STATE_READY)
        {
            // change state to allow door to be closed
            obj->SetLootState(GO_READY);
            obj->UseDoorOrButton(RESPAWN_ONE_DAY);
        }
    }
    else
        sLog.outError("BattleGround: Door %s not found (cannot close doors)", guid.GetString().c_str());
}
Esempio n. 12
0
   void Aggro(Unit* who)
{
   DoScriptText(SAY_MALGANIS_AGGRO, m_creature);
   if (Creature* pArthas = GetClosestCreatureWithEntry(m_creature, NPC_ARTHAS, 150.0f))
      Arthas = pArthas;

   if (m_pInstance)
         {
           GameObject* pGate = m_pInstance->instance->GetGameObject(m_pInstance->GetData64(DATA_GO_MAL_GATE2));
           if (pGate && !pGate->GetGoState())
              {
                 pGate->SetGoState(GO_STATE_READY);
              }
          }

}
            bool CheckContainmentSpheres(bool remove_prison = false)
            {
                ContainmentSphereGUIDs[0] = instance->GetGuidData(ANOMALUS_CONTAINMENT_SPHERE);
                ContainmentSphereGUIDs[1] = instance->GetGuidData(ORMOROKS_CONTAINMENT_SPHERE);
                ContainmentSphereGUIDs[2] = instance->GetGuidData(TELESTRAS_CONTAINMENT_SPHERE);

                for (uint8 i = 0; i < DATA_CONTAINMENT_SPHERES; ++i)
                {
                    GameObject* ContainmentSphere = ObjectAccessor::GetGameObject(*me, ContainmentSphereGUIDs[i]);
                    if (!ContainmentSphere)
                        return false;
                    if (ContainmentSphere->GetGoState() != GO_STATE_ACTIVE)
                        return false;
                }
                if (remove_prison)
                    RemovePrison(true);
                return true;
            }
Esempio n. 14
0
//some doors aren't despawned so we cannot handle their closing in gameobject::update()
//it would be nice to correctly implement GO_ACTIVATED state and open/close doors in gameobject code
void BattleGround::DoorClose(uint32 type)
{
    GameObject *obj = HashMapHolder<GameObject>::Find(m_BgObjects[type]);
    if(obj)
    {
        //if doors are open, close it
        if( obj->getLootState() == GO_ACTIVATED && !obj->GetGoState() )
        {
            //change state to allow door to be closed
            obj->SetLootState(GO_READY);
            obj->UseDoorOrButton(RESPAWN_ONE_DAY);
        }
    }
    else
    {
        sLog.outError("BattleGround: Door object not found (cannot close doors)");
    }
}
Esempio n. 15
0
		bool CheckSpheres() {
			if (!instance)
				return false;

			uint64 uiSphereGuids[2];
			uiSphereGuids[0] = instance->GetData64(DATA_SPHERE1);
			uiSphereGuids[1] = instance->GetData64(DATA_SPHERE2);

			for (uint8 i = 0; i < 2; ++i) {
				GameObject *pSpheres = instance->instance->GetGameObject(
						uiSphereGuids[i]);
				if (!pSpheres)
					return false;
				if (pSpheres->GetGoState() != GO_STATE_ACTIVE)
					return false;
			}
			RemovePrison();
			return true;
		}
Esempio n. 16
0
void instance_violet_hold::UpdateCellForBoss(uint32 uiBossEntry, bool bForceClosing /*= false*/)
{
    BossToCellMap::const_iterator itrCellLower = m_mBossToCellMap.lower_bound(uiBossEntry);
    BossToCellMap::const_iterator itrCellUpper = m_mBossToCellMap.upper_bound(uiBossEntry);

    if (itrCellLower == itrCellUpper)
        return;

    for (BossToCellMap::const_iterator itr = itrCellLower; itr != itrCellUpper; ++itr)
    {
        if (!bForceClosing)
            DoUseDoorOrButton(itr->second);
        else
        {
            GameObject* pGo = instance->GetGameObject(itr->second);
            if (pGo && pGo->GetGoType() == GAMEOBJECT_TYPE_DOOR && pGo->GetGoState() == GO_STATE_ACTIVE)
                pGo->ResetDoorOrButton();
        }
    }
}
Esempio n. 17
0
void instance_maraudon::Update(uint32 uiDiff)
{
	if (m_uiSpawnTimer <= uiDiff)
	{
		m_uiSpawnTimer = 5000;
		GameObject* pGo = instance->GetGameObject(m_uiLarvaSpewerGUID);
		if (!pGo || pGo->GetGoState() == GO_STATE_ACTIVE)
			return;
		Map::PlayerList const& L = instance->GetPlayers();
		if (L.isEmpty())
			return;
		bool spawn = false;
		for (Map::PlayerList::const_iterator i = L.begin(); i != L.end(); ++i)
		{
			Player* P = i->getSource();
			if (P && P->isAlive() && P->GetDistance(pGo) <= 45.0f)
			{
				spawn = true;
				break;
			}
		}
		if (spawn)
		{
			float coord_dif[2];
			for (int i = 0; i < 2; i++)
				coord_dif[i] = (float)urand(-3,4);
			if (Creature* C = pGo->SummonCreature(NPC_LARVA,pGo->GetPositionX()+coord_dif[0],pGo->GetPositionY()+coord_dif[1],pGo->GetPositionZ(),pGo->GetOrientation(),TEMPSUMMON_CORPSE_TIMED_DESPAWN,3000))
				C->SetInCombatWithZone();
			//Unit* target = C->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0);
			//if (target && C->AI())
			//	C->AI()->AttackStart(target);
		}
	}
	else
	  m_uiSpawnTimer -= uiDiff;
}
        void Dragonspireroomcheck()
        {
            Creature* mob = NULL;
            GameObject* rune = NULL;

            for (uint8 i = 0; i < 7; ++i)
            {
                bool _mobAlive = false;
                rune = instance->GetGameObject(go_roomrunes[i]);
                if (!rune)
                    continue;

                if (rune->GetGoState() == GO_STATE_ACTIVE)
                {
                    for (uint8 ii = 0; ii < 5; ++ii)
                    {
                        mob = instance->GetCreature(runecreaturelist[i][ii]);
                        if (mob && mob->IsAlive())
                            _mobAlive = true;
                    }
                }

                if (!_mobAlive && rune->GetGoState() == GO_STATE_ACTIVE)
                {
                    HandleGameObject(ObjectGuid::Empty, false, rune);

                    switch (rune->GetEntry())
                    {
                        case GO_HALL_RUNE_1:
                            SetBossState(DATA_HALL_RUNE_1, DONE);
                            break;
                        case GO_HALL_RUNE_2:
                            SetBossState(DATA_HALL_RUNE_2, DONE);
                            break;
                        case GO_HALL_RUNE_3:
                            SetBossState(DATA_HALL_RUNE_3, DONE);
                            break;
                        case GO_HALL_RUNE_4:
                            SetBossState(DATA_HALL_RUNE_4, DONE);
                            break;
                        case GO_HALL_RUNE_5:
                            SetBossState(DATA_HALL_RUNE_5, DONE);
                            break;
                        case GO_HALL_RUNE_6:
                            SetBossState(DATA_HALL_RUNE_6, DONE);
                            break;
                        case GO_HALL_RUNE_7:
                            SetBossState(DATA_HALL_RUNE_7, DONE);
                            break;
                        default:
                            break;
                    }
                }
            }

            if (GetBossState(DATA_HALL_RUNE_1) == DONE && GetBossState(DATA_HALL_RUNE_2) == DONE && GetBossState(DATA_HALL_RUNE_3) == DONE &&
                GetBossState(DATA_HALL_RUNE_4) == DONE && GetBossState(DATA_HALL_RUNE_5) == DONE && GetBossState(DATA_HALL_RUNE_6) == DONE &&
                GetBossState(DATA_HALL_RUNE_7) == DONE)
            {
                SetBossState(DATA_DRAGONSPIRE_ROOM, DONE);
                if (GameObject* door1 = instance->GetGameObject(go_emberseerin))
                    HandleGameObject(ObjectGuid::Empty, true, door1);
                if (GameObject* door2 = instance->GetGameObject(go_doors))
                    HandleGameObject(ObjectGuid::Empty, true, door2);
            }
        }
Esempio n. 19
0
bool TerrainInfo::CheckPathAccurate(float srcX, float srcY, float srcZ, float& dstX, float& dstY, float& dstZ, Unit* mover, bool onlyLOS ) const
{

    float tstX = dstX;
    float tstY = dstY;
    float tstZ = dstZ;
    // check by standart way. may be not need path checking?
    if (!mover && CheckPath(srcX, srcY, srcZ, tstX, tstY, tstZ) && IsNextZcoordOK(tstX, tstY, tstZ, 5.0f))
    {
        DEBUG_LOG("TerrainInfo::CheckPathAccurate vmaps hit! delta is %f %f %f",dstX - tstX,dstY - tstY,dstZ - tstZ);
        dstX = tstX;
        dstY = tstY;
        dstZ = tstZ + 0.1f;
        return true;
    }

    const float distance = sqrt((dstY - srcY)*(dstY - srcY) + (dstX - srcX)*(dstX - srcX));
    const float DELTA    = 0.5f;
    const uint8 numChecks = ceil(fabs(distance/DELTA));
    const float DELTA_X  = (dstX-srcX)/numChecks;
    const float DELTA_Y  = (dstY-srcY)/numChecks;
    const float DELTA_Z  = (dstZ-srcZ)/numChecks;

    float lastGoodX = srcX;
    float lastGoodY = srcY;
    float lastGoodZ = srcZ;

    uint32 errorsCount = 0;
    uint32 goodCount   = 0;
    uint32 vmaperrorsCount   = 0;

    std::set<GameObject*> inLOSGOList;
    bool bGOCheck = false;
    if (mover)
    {
        std::list<GameObject*> tempTargetGOList;
        MaNGOS::GameObjectInRangeCheck check(mover, tstX, tstY, tstZ, distance + 2.0f *mover->GetObjectBoundingRadius());
        MaNGOS::GameObjectListSearcher<MaNGOS::GameObjectInRangeCheck> searcher(tempTargetGOList, check);
        Cell::VisitAllObjects(mover, searcher, 2*mover->GetObjectBoundingRadius());
        if (!tempTargetGOList.empty())
        {
            for(std::list<GameObject*>::iterator iter = tempTargetGOList.begin(); iter != tempTargetGOList.end(); ++iter)
            {
                GameObject* pGo = *iter;

                if (!pGo || !pGo->IsInWorld())
                    continue;

                // Not require check GO's, if his not in path
                // first fast check
                if (pGo->GetPositionX() > std::max(srcX, dstX)
                    || pGo->GetPositionX() < std::min(srcX, dstX)
                    || pGo->GetPositionY() > std::max(srcY, dstY)
                    || pGo->GetPositionY() < std::min(srcY, dstY))
                    continue;

                // don't check very small and very large objects
                if (pGo->GetDeterminativeSize(true) < mover->GetObjectBoundingRadius() * 0.5f ||
                    pGo->GetDeterminativeSize(false) > mover->GetObjectBoundingRadius() * 100.0f)
                    continue;

                // second check by angle
                float angle = mover->GetAngle(pGo) - mover->GetAngle(dstX, dstY);
                if (abs(sin(angle)) * pGo->GetExactDist2d(srcX, srcY) > pGo->GetObjectBoundingRadius() * 0.5f)
                    continue;

                bool bLOSBreak = false;
                switch (pGo->GetGoType())
                {
                        case GAMEOBJECT_TYPE_TRAP:
                        case GAMEOBJECT_TYPE_SPELL_FOCUS:
                        case GAMEOBJECT_TYPE_MO_TRANSPORT:
                        case GAMEOBJECT_TYPE_CAMERA:
                        case GAMEOBJECT_TYPE_FISHINGNODE:
                        case GAMEOBJECT_TYPE_SUMMONING_RITUAL:
                        case GAMEOBJECT_TYPE_SPELLCASTER:
                        case GAMEOBJECT_TYPE_FISHINGHOLE:
                        case GAMEOBJECT_TYPE_CAPTURE_POINT:
                            break;
                        case GAMEOBJECT_TYPE_DOOR:
                            if (pGo->isSpawned() && pGo->GetGoState() == GO_STATE_READY)
                                bLOSBreak = true;
                            break;
                        case GAMEOBJECT_TYPE_TRANSPORT:
                            if (pGo->isSpawned() && pGo->GetGoState() == GO_STATE_ACTIVE)
                                bLOSBreak = true;
                            break;
                        case GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING:
                            if (!pGo->HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_DESTROYED))
                                bLOSBreak = true;
                            break;
                        default:
                            if (pGo->isSpawned())
                                bLOSBreak = true;
                            break;
                }
                if (bLOSBreak)
                    inLOSGOList.insert(pGo);
            }
        }
        if (!inLOSGOList.empty())
            bGOCheck = true;
    }

    //Going foward until max distance
    for (uint8 i = 1; i < numChecks; ++i)
    {
        float prevX = srcX + (float(i-1)*DELTA_X);
        float prevY = srcY + (float(i-1)*DELTA_Y);
        float prevZ = GetHeight(prevX, prevY, srcZ + 5.0f);

        tstX = srcX + (float(i)*DELTA_X);
        tstY = srcY + (float(i)*DELTA_Y);
        tstZ = GetHeight(tstX, tstY, srcZ + 5.0f);

        MaNGOS::NormalizeMapCoord(tstX);
        MaNGOS::NormalizeMapCoord(tstY);

        if (tstZ <= INVALID_HEIGHT)
            break;
        tstZ += (0.5f + DELTA_Z);

        if (!CheckPath(prevX, prevY, prevZ, tstX, tstY, tstZ))
        {
            ++vmaperrorsCount;
            ++errorsCount;
            goodCount = 0;
        }
        else if (!IsNextZcoordOK(tstX, tstY, tstZ, 5.0f))
        {
            ++errorsCount;
            goodCount = 0;
        }
        else if (mover && bGOCheck)
        {
            bool bError = false;
            for(std::set<GameObject*>::const_iterator iter = inLOSGOList.begin(); iter != inLOSGOList.end(); ++iter)
            {
                if (!(*iter) || (*iter)->GetDistance2d(tstX, tstY) > (*iter)->GetObjectBoundingRadius())
                    continue;

//                DEBUG_LOG("TerrainInfo::CheckPathAccurate GO %s in LOS found, %f %f %f ",(*iter)->GetObjectGuid().GetString().c_str(),tstX,tstY,tstZ);
                bError = true;
                break;
            }

            if (bError)
            {
                ++errorsCount;
                goodCount = 0;
            }
            else
                ++goodCount;
        }
        else
        {
            ++goodCount;
        }

//        DEBUG_LOG("TerrainInfo::CheckPathAccurate test data %f %f %f good=%u, errors=%u vmap=%u",tstX,tstY,tstZ, goodCount, errorsCount, vmaperrorsCount);

        if (!errorsCount)
        {
            lastGoodX = prevX;
            lastGoodY = prevY;
            lastGoodZ = prevZ;
        }
        else
            if (onlyLOS)
                break;

        if (errorsCount && goodCount > 10)
        {
            --errorsCount;
            goodCount -= 10;
        }
    }

    if (errorsCount)
    {
        dstX = lastGoodX;
        dstY = lastGoodY;
        dstZ = GetHeight(lastGoodX, lastGoodY, lastGoodZ+2.0f) + 0.5f;
    }
    else
    {
        dstX = tstX;
        dstY = tstY;
        dstZ = GetHeight(tstX, tstY, tstZ+2.0f) + 0.5f;
    }

    return (errorsCount == 0);
}
Esempio n. 20
0
void instance_zulfarrak::Update(uint32 uiDiff)
{
    // Pyramide Trash
    if (GetData(TYPE_PYRAMIDE) == IN_PROGRESS || GetData(TYPE_PYRAMIDE) == SPECIAL)
    {
		if (GetData(TYPE_PYRAMIDE) == IN_PROGRESS && m_uiPyramideTrash.size() <= 15 && m_uiPyramideTrashTemp.empty())
			SetData(TYPE_PYRAMIDE, SPECIAL);	//Make Bly's crew walk downstairs

        if (m_uiCheckPyramideTrash_Timer <= uiDiff && m_uiWave < 6)
        {
            debug_log("SD0: Instance Zul'Farrak: Pyramide event: Sending 2 trolls up stairs.");

			for (uint32 i = 0; i < 5; i++) {
            if (!m_uiPyramideNPCs[i].empty())
			{
                for(GUIDList::iterator itr = m_uiPyramideNPCs[i].begin(); itr != m_uiPyramideNPCs[i].end(); ++itr)
				{
                    if (Creature* pTroll = instance->GetCreature(*itr))
					{
                        if (!pTroll->isDead() || pTroll->isAlive())
                        {
                            if (++m_uiTrollsMovedCount > spawnNumber[m_uiWave][i])
                            {
                                m_uiTrollsMovedCount = 0;
                                break;
                            }

                            // Move troll up Stairs
                            if (!pTroll->getVictim())
                            {
                                pTroll->GetMotionMaster()->Clear();
                                pTroll->GetMotionMaster()->MovePoint(1, 1886.31f, 1269.72f, 42.f);
								CreatureCreatePos pos(pTroll->GetMap(), 1886.31f, 1269.72f, 42.f, 0.0f);
								pTroll->SetSummonPoint(pos);
                            }

							m_uiPyramideTrashTemp.push_back(pTroll->GetObjectGuid());
                            itr = m_uiPyramideNPCs[i].erase(itr);
                        }
					}
				}
			}
			}
			m_uiWave++;
			m_uiCheckPyramideTrash_Timer = 40000;
		}
        else m_uiCheckPyramideTrash_Timer -= uiDiff;
	}

    // Nekrum death state checker
    if (GetData(TYPE_PYRAMIDE) != DONE)
	{
	    Creature* pNekrum = GetSingleCreatureFromStorage(NPC_NEKRUM_GUTCHEWER);
        if (pNekrum && pNekrum->isDead())
        {
            SetData(TYPE_PYRAMIDE, DONE);
            m_uiPyramideTrash.clear();
        }
	}

    // Bomb explodation
    if (m_uiBombExplodationExpire_Timer)
    {
        if (m_uiBombExplodationExpire_Timer <= uiDiff)
        {
            // Bomb explodation
            GameObject* DoorExplosive = GetSingleGameObjectFromStorage(GO_DOOR_EXPLOSIVE);
			if (DoorExplosive && DoorExplosive->GetGoState() != GO_STATE_ACTIVE_ALTERNATIVE)
				DoorExplosive->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE);
            // Door opened by exploding bomb
            GameObject* EndDoor = GetSingleGameObjectFromStorage(GO_END_DOOR);
			if (EndDoor && EndDoor->GetGoState() != GO_STATE_ACTIVE_ALTERNATIVE)
				EndDoor->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE);
        }
        else
			m_uiBombExplodationExpire_Timer -= uiDiff;
    }

    // Bly's crew use Heartstone after defeating trolls
    //if (m_uiBlysBandHeartstone_Timer)
    //    if ( (GetData(TYPE_PYRAMIDE) == DONE) && (m_uiBlysBandHeartstone_Timer <= uiDiff) )
    //    {
    //        Creature* pBly = GetSingleCreatureFromStorage(NPC_SERGEANT_BLY);
    //        if (pBly && pBly->isAlive() && !pBly->getVictim())
    //            pBly->CastSpell(pBly, SPELL_BLYS_BANDS_ESCAPE, false);
    //        Creature* pRaven = GetSingleCreatureFromStorage(NPC_RAVEN);
    //        if (pRaven && pRaven->isAlive() && !pRaven->getVictim())
    //            pRaven->CastSpell(pRaven, SPELL_BLYS_BANDS_ESCAPE, false);
    //        Creature* pOro = GetSingleCreatureFromStorage(NPC_ORO_EYEGOUGE);
    //        if (pOro && pOro->isAlive() && !pOro->getVictim())
    //            pOro->CastSpell(pOro, SPELL_BLYS_BANDS_ESCAPE, false);
    //        Creature* pMurta = GetSingleCreatureFromStorage(NPC_MURTA_GRIMGUT);
    //        if (pMurta && pMurta->isAlive() && !pMurta->getVictim())
    //            pMurta->CastSpell(pMurta, SPELL_BLYS_BANDS_ESCAPE, false);
    //
    //        m_uiBlysBandHeartstone_Timer = 0;
    //    }
    //    else m_uiBlysBandHeartstone_Timer -= uiDiff;
}
Esempio n. 21
0
    bool OnGossipHello(Player* player, GameObject* go)
    {
        if (player->GetQuestStatus(QUEST_EVAC_MERC_SQUA) == QUEST_STATUS_INCOMPLETE && go->GetGoState() == GO_STATE_READY)
        {
            aPlayer          = player;
            opened           = 1;
            tQuestCredit     = 2500;
            go->SetGoState(GO_STATE_ACTIVE);
            DoorTimer = DOOR_TIMER;
            spawnKind = urand(1, 3); //1, 2=citizen, 3=citizen&worgen (66%, 33%)
            angle = go->GetOrientation();
            x = go->GetPositionX()-cos(angle)*2;
            y = go->GetPositionY()-sin(angle)*2;
            z = go->GetPositionZ();
            wx = x-cos(angle)*2;
            wy = y-sin(angle)*2;

            if (spawnKind < 3)
            {
                if (Creature* spawnedCreature = go->SummonCreature(NPC_FRIGHTENED_CITIZEN_1, x, y, z, angle, TEMPSUMMON_TIMED_DESPAWN, SUMMON1_TTL))
                {
                    spawnedCreature->SetPhaseMask(6, 1);
                    spawnedCreature->Respawn(1);
                }
            }
            else
            {
                if (Creature* spawnedCreature = go->SummonCreature(NPC_FRIGHTENED_CITIZEN_2, x, y, z, angle, TEMPSUMMON_TIMED_DESPAWN, SUMMON1_TTL))
                {
                    spawnedCreature->SetPhaseMask(6, 1);
                    spawnedCreature->Respawn(1);
                }
            }
            return true;
        }
        return false;
    }