// Function to search for new rookery egg in range
    void DoFindNewEgg()
    {
        GameObjectList lEggsInRange;
        GetGameObjectListWithEntryInGrid(lEggsInRange, m_creature, GO_ROOKERY_EGG, 20.0f);

        if (lEggsInRange.empty())   // No GO found
            return;

        lEggsInRange.sort(ObjectDistanceOrder(m_creature));
        GameObject* pNearestEgg = nullptr;

        // Always need to find new ones
        for (GameObjectList::const_iterator itr = lEggsInRange.begin(); itr != lEggsInRange.end(); ++itr)
        {
            if (!((*itr)->HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE)))
            {
                pNearestEgg = *itr;
                break;
            }
        }

        if (!pNearestEgg)
            return;

        float fX, fY, fZ;
        pNearestEgg->GetContactPoint(m_creature, fX, fY, fZ, 1.0f);
        m_creature->SetWalk(false);
        m_creature->GetMotionMaster()->MovePoint(1, fX, fY, fZ);
        m_bIsMovementActive = true;
    }
    // Function to search for new tubber in range
    void DoFindNewTubber()
    {
        GameObjectList lTubbersInRange;
        GetGameObjectListWithEntryInGrid(lTubbersInRange, m_creature, GO_BLUELEAF_TUBBER, 40.0f);

        if (lTubbersInRange.empty())
            return;

        lTubbersInRange.sort(ObjectDistanceOrder(m_creature));
        GameObject* pNearestTubber = nullptr;

        // Always need to find new ones
        for (GameObjectList::const_iterator itr = lTubbersInRange.begin(); itr != lTubbersInRange.end(); ++itr)
        {
            if (!(*itr)->IsSpawned() && (*itr)->HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_INTERACT_COND) && (*itr)->IsWithinLOSInMap(m_creature))
            {
                pNearestTubber = *itr;
                break;
            }
        }

        if (!pNearestTubber)
            return;
        m_targetTubberGuid = pNearestTubber->GetObjectGuid();

        float fX, fY, fZ;
        pNearestTubber->GetContactPoint(m_creature, fX, fY, fZ);
        m_creature->GetMotionMaster()->MovePoint(1, fX, fY, fZ);
        m_bIsMovementActive = true;
    }
Exemple #3
0
void TimerSystem::update(Register &reg, const double dt) {
	HandleManager* handleManager = reg.getHandleManager();
	GameObjectManager* gameObjectManager = reg.getGameObjectManager();

	GameObjectList gameObjectList = gameObjectManager->getGameObjectsWithComponents(componentList);
	GameObject* gameObject;
	TimerComponent* timerComponent;
	for (gameObject = gameObjectList.next(); gameObject; gameObject = gameObjectList.next()) {
		timerComponent = gameObject->getComponent<TimerComponent>(*handleManager, TIMER_COMPONENT);
		if (timerComponent) {
			timerComponent->tick(dt);
		}
	}
}
    // Function to respawn GOs
    void DoRespawnObjects(uint32 uiEntry, float fRange)
    {
        GameObjectList lBarrelsInRange;
        m_lExplosivesGuidsList.clear();
        GetGameObjectListWithEntryInGrid(lBarrelsInRange, m_creature, uiEntry, fRange);

        if (lBarrelsInRange.empty())
        {
            script_error_log("Bloodmyst Isle: ERROR Failed to find any gameobjects of entry %u in range.", uiEntry);
            return;
        }

        // respawn explosives and store for future use
        for (GameObjectList::const_iterator itr = lBarrelsInRange.begin(); itr != lBarrelsInRange.end(); ++itr)
        {
            (*itr)->SetRespawnTime(5 * MINUTE);
            (*itr)->Refresh();
            m_lExplosivesGuidsList.push_back((*itr)->GetObjectGuid());
        }
    }
    // function to cleanup the world states and GO flags
    void DoEncounterCleanup()
    {
        // remove world state
        if (Player* pSummoner = m_creature->GetMap()->GetPlayer(m_summonerGuid))
            pSummoner->SendUpdateWorldState(WORLD_STATE_TETHYR_SHOW, 0);

        // reset all cannons
        GameObjectList lCannonsInRange;
        GetGameObjectListWithEntryInGrid(lCannonsInRange, m_creature, GO_COVE_CANNON, 100.0f);

        for (GameObjectList::const_iterator itr = lCannonsInRange.begin(); itr != lCannonsInRange.end(); ++itr)
            (*itr)->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT);

        // despawn all marksmen
        CreatureList lMarksmenInRange;
        GetCreatureListWithEntryInGrid(lMarksmenInRange, m_creature, NPC_THERAMORE_MARKSMAN, 100.0f);

        for (CreatureList::const_iterator itr = lMarksmenInRange.begin(); itr != lMarksmenInRange.end(); ++itr)
            (*itr)->ForcedDespawn(30000);
    }
    // Function to respawn fire GOs
    void DoRespawnFires(bool bFirstEvent)
    {
        GameObjectList lFiresInRange;
        GetGameObjectListWithEntryInGrid(lFiresInRange, m_creature, GO_COIL_FIRE_L, 110.0f);
        GetGameObjectListWithEntryInGrid(lFiresInRange, m_creature, GO_COIL_FIRE_S, 110.0f);

        if (lFiresInRange.empty())
        {
            script_error_log("Bloodmyst Isle: ERROR Failed to find any gameobjects of entry %u and %u in range.", GO_COIL_FIRE_L, GO_COIL_FIRE_S);
            return;
        }

        for (GameObjectList::const_iterator itr = lFiresInRange.begin(); itr != lFiresInRange.end(); ++itr)
        {
            if ((bFirstEvent && (*itr)->GetPositionZ() < 150.0f) || (!bFirstEvent && (*itr)->GetPositionZ() > 150.0f))
            {
                (*itr)->SetRespawnTime(5 * MINUTE);
                (*itr)->Refresh();
            }
        }
    }
Exemple #7
0
void Demo::Render()
{
	//Clear screen
	SDL_RenderClear( renderer_ );

	//Render texture to screen
	//SDL_RenderCopy( renderer_, gTexture, NULL, NULL );
	gameObjects.Draw( renderer_ );

	//Update screen
	SDL_RenderPresent( renderer_ );
}
Exemple #8
0
void Ore::OnCollision(const GameObjectList& objects)
{
    SmartPtr<GameObject> object;
    GameObjectType const* type = NULL;

    GameObjectList::const_iterator it = objects.begin();
    GameObjectList::const_iterator end = objects.end();

    for (; it != end; ++it)
    {
        object = *it;
        type = &(object->GetType());

        // Compare Object type
        if((*type) == GameObjectType("Spaceship"))
        {
            mWorld->RemoveObject(this);
            cout << "ORE COLIDES WITH SPACESHIP\n";
        }
    }
}
    void MovementInform(uint32 uiMotionType, uint32 uiPointId) override
    {
        if (uiMotionType == WAYPOINT_MOTION_TYPE)
        {
            // start attacking
            if (uiPointId == 12)
            {
                // make cannons usable
                GameObjectList lCannonsInRange;
                GetGameObjectListWithEntryInGrid(lCannonsInRange, m_creature, GO_COVE_CANNON, 100.0f);

                for (GameObjectList::const_iterator itr = lCannonsInRange.begin(); itr != lCannonsInRange.end(); ++itr)
                    (*itr)->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT);

                // attack all marksmen
                CreatureList lMarksmenInRange;
                GetCreatureListWithEntryInGrid(lMarksmenInRange, m_creature, NPC_THERAMORE_MARKSMAN, 100.0f);

                for (CreatureList::const_iterator itr = lMarksmenInRange.begin(); itr != lMarksmenInRange.end(); ++itr)
                {
                    (*itr)->AI()->AttackStart(m_creature);
                    AttackStart(*itr);
                }
            }
        }
        else if (uiMotionType == POINT_MOTION_TYPE)
        {
            // Spout on cannon point reach
            if (uiPointId)
            {
                if (DoCastSpellIfCan(m_creature, urand(0, 1) ? SPELL_SPOUT_LEFT : SPELL_SPOUT_RIGHT, CAST_INTERRUPT_PREVIOUS) == CAST_OK)
                {
                    // Remove the target focus
                    m_creature->SetTarget(nullptr);
                    m_uiPhase = PHASE_SPOUT;
                }
            }
        }
    }
Exemple #10
0
void Drone::OnCollision(const GameObjectList& objects)
{
    SmartPtr<GameObject> object;
    GameObjectType const* type = NULL;

    GameObjectList::const_iterator it = objects.begin();
    GameObjectList::const_iterator end = objects.end();

    for (; it != end; ++it)
    {
//        const GameObjectType * type = &((*it)->GetType() );

        object = *it;
        type = &(object->GetType());
//        const char * type_name = object->GetType().GetTypeName();
//        cout << type_name << ";" << endl;

        // Compare Object type
        if((*type) == GameObjectType("Bullet"))
        {
            // TODO add damage related stuff to GameObject which should allow you to bypass this whole awkward pointer stuff here...
            Bullet* b = (Bullet*) object.GetPtr();
//            cout << "colision with bullet" << endl;
//            Bullet* b = dynamic_cast<Bullet*>(object.GetPtr());

            int damage = b->GetDamage();
            int health = mHealth;
            int newHealth = mHealth - damage;

            DealDamage(b->GetDamage());
            //cout << "HEALTH " << mHealth << endl;
            // Check if alive
            if(mHealth <= 0) mWorld->RemoveObject(this);
        }
    }
}
Exemple #11
0
void Asteroid::OnCollision(const GameObjectList& objects)
{
    SmartPtr<GameObject> object;
    GameObjectType const* type = NULL;

    GameObjectList::const_iterator it = objects.begin();
    GameObjectList::const_iterator end = objects.end();

    for (; it != end; ++it)
    {
//        const GameObjectType * type = &((*it)->GetType() );
        object = *it;
        type = &(object->GetType());
//        const char * type_name = object->GetType().GetTypeName();
//        cout << type_name << ";" << endl;

        // Compare Object type
        if((*type) == GameObjectType("Bullet"))
        {
            mWorld->RemoveObject(this);
            // @todo mWorld-> see if you can do the spliting of asteroids from here rather than the asteroids.cpp
        }
    }
}
void
GameObjectInfo_Boat::createAllBoats( GameObjectList& gameObjects )
{
	GameObjectInfo_Boat* veh = 0;

	// Patrolboat
	veh = dynamic_cast<GameObjectInfo_Boat*>(createVehicle(GameObjectInfo::GO_CAT_BOAT));
	veh->descriptiveName_ =	"Patrolboat";
	veh->tinyName_ = "PBR31";
	veh->modelName_ = "pbr31mk2";
	veh->gameSet_ = MF_GAMESET_MODERN;
	veh->category_ = GameObjectInfo::GO_CAT_BOAT;
	veh->class_ = CLASS_BOAT_PATROL;
	veh->flags_ = 0;
	veh->caps_ = HC_DUALGUNS;
	veh->renderFlags_ = 0;	
    VectorSet( veh->turnSpeed_, 50, 100, 20 );		
	VectorSet( veh->camDist_, 0, 100, 70 );
	VectorSet( veh->camHeight_ , 0, 100, 20);		
    veh->maxHealth_ = 350;		
	veh->shadowShader_ = SHADOW_DEFAULT;	
	Vector4Set( veh->shadowCoords_, 4, 0, 34, 24 );	
	Vector4Set( veh->shadowAdjusts_, 0, 0, 0, 0 );	
	VectorSet( veh->gunoffset_, 5, 0, 8 );		
	VectorSet( veh->cockpitview_, 0, 0, 6 );	
	veh->airRadar_ = new VehicleRadarInfo(-1, 8000, CAT_PLANE|CAT_HELO);		
	veh->groundRadar_ = new VehicleRadarInfo(0, 7000, CAT_GROUND|CAT_BOAT);			
	veh->minThrottle_ = -5;
	veh->maxThrottle_ = 10;
	veh->acceleration_ = 15;
	veh->maxFuel_ = 150;
	veh->sonarInfo_ = new VehicleRadarInfo(0, 3000, CAT_BOAT); 		
    veh->maxSpeed_ = 50;		
	gameObjects.push_back(veh);
	//8,							// max angle to lean when turning <- gearheight
	//-5,							// bowangle (depends on speeed) <-tailangle 
}
Exemple #13
0
    // Function to search for new tubber in range
    void DoFindNewCrystal(Player* pMaster)
    {
        GameObjectList lCrystalsInRange;
        for (unsigned int i : aGOList)
        {
            GetGameObjectListWithEntryInGrid(lCrystalsInRange, m_creature, i, 40.0f);
            // If a crystal was found in range, stop the search here, else try with another GO
            if (!lCrystalsInRange.empty())
                break;
        }

        if (lCrystalsInRange.empty())   // Definely no GO found
        {
            m_creature->PlayDirectSound(SOUND_GROWL);
            return;
        }
        lCrystalsInRange.sort(ObjectDistanceOrder(m_creature));
        GameObject* pNearestCrystal = nullptr;

        // Always need to find new ones
        for (GameObjectList::const_iterator itr = lCrystalsInRange.begin(); itr != lCrystalsInRange.end(); ++itr)
        {
            if ((*itr)->HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_INTERACT_COND))
            {
                pNearestCrystal = *itr;
                break;
            }
        }

        if (!pNearestCrystal)
        {
            m_creature->PlayDirectSound(SOUND_GROWL);
            return;
        }
        float fX, fY, fZ;
        pNearestCrystal->GetContactPoint(m_creature, fX, fY, fZ, 3.0f);
        m_creature->SetWalk(false);
        m_creature->GetMotionMaster()->MovePoint(1, fX, fY, fZ);
        m_bIsMovementActive = true;
    }
Exemple #14
0
void Demo::Update()
{
	gameObjects.Update();
}
void instance_gnomeregan::SetData(uint32 uiType, uint32 uiData)
{
    switch (uiType)
    {
        case TYPE_GRUBBIS:
            m_auiEncounter[0] = uiData;
            if (uiData == IN_PROGRESS)
            {
                // Sort the explosive charges if needed
                if (!m_luiExplosiveChargeGUIDs.empty())
                {
                    GameObjectList lExplosiveCharges;
                    for (GuidList::const_iterator itr = m_luiExplosiveChargeGUIDs.begin(); itr != m_luiExplosiveChargeGUIDs.end(); ++itr)
                    {
                        if (GameObject* pCharge = instance->GetGameObject(*itr))
                            lExplosiveCharges.push_back(pCharge);
                    }
                    m_luiExplosiveChargeGUIDs.clear();

                    // Sort from east to west
                    lExplosiveCharges.sort(sortFromEastToWest);

                    // Sort to south and north
                    uint8 uiCounterSouth = 0;
                    uint8 uiCounterNorth = 0;
                    GameObject* pCaveInSouth = GetSingleGameObjectFromStorage(GO_CAVE_IN_SOUTH);
                    GameObject* pCaveInNorth = GetSingleGameObjectFromStorage(GO_CAVE_IN_NORTH);
                    if (pCaveInSouth && pCaveInNorth)
                    {
                        for (auto& lExplosiveCharge : lExplosiveCharges)
                        {
                            if (lExplosiveCharge->GetDistanceOrder(pCaveInSouth, pCaveInNorth) && uiCounterSouth < MAX_EXPLOSIVES_PER_SIDE)
                            {
                                m_aExplosiveSortedGuids[0][uiCounterSouth] = lExplosiveCharge->GetObjectGuid();
                                ++uiCounterSouth;
                            }
                            else if (uiCounterNorth < MAX_EXPLOSIVES_PER_SIDE)
                            {
                                m_aExplosiveSortedGuids[1][uiCounterNorth] = lExplosiveCharge->GetObjectGuid();
                                ++uiCounterNorth;
                            }
                        }
                    }
                }
            }
            if (uiData == FAIL)
            {
                // Despawn possible spawned explosive charges
                SetData(TYPE_EXPLOSIVE_CHARGE, DATA_EXPLOSIVE_CHARGE_USE);
            }
            if (uiData == DONE)
            {
                for (GuidList::const_iterator itr = m_lRedRocketGUIDs.begin(); itr != m_lRedRocketGUIDs.end(); ++itr)
                    DoRespawnGameObject(*itr, HOUR);
            }
            break;
        case TYPE_EXPLOSIVE_CHARGE:
            switch (uiData)
            {
                case DATA_EXPLOSIVE_CHARGE_1:
                    DoRespawnGameObject(m_aExplosiveSortedGuids[0][0], HOUR);
                    m_luiSpawnedExplosiveChargeGUIDs.push_back(m_aExplosiveSortedGuids[0][0]);
                    break;
                case DATA_EXPLOSIVE_CHARGE_2:
                    DoRespawnGameObject(m_aExplosiveSortedGuids[0][1], HOUR);
                    m_luiSpawnedExplosiveChargeGUIDs.push_back(m_aExplosiveSortedGuids[0][1]);
                    break;
                case DATA_EXPLOSIVE_CHARGE_3:
                    DoRespawnGameObject(m_aExplosiveSortedGuids[1][0], HOUR);
                    m_luiSpawnedExplosiveChargeGUIDs.push_back(m_aExplosiveSortedGuids[1][0]);
                    break;
                case DATA_EXPLOSIVE_CHARGE_4:
                    DoRespawnGameObject(m_aExplosiveSortedGuids[1][1], HOUR);
                    m_luiSpawnedExplosiveChargeGUIDs.push_back(m_aExplosiveSortedGuids[1][1]);
                    break;
                case DATA_EXPLOSIVE_CHARGE_USE:
                    Creature* pBlastmaster = GetSingleCreatureFromStorage(NPC_BLASTMASTER_SHORTFUSE);
                    if (!pBlastmaster)
                        break;
                    for (GuidList::const_iterator itr = m_luiSpawnedExplosiveChargeGUIDs.begin(); itr != m_luiSpawnedExplosiveChargeGUIDs.end(); ++itr)
                    {
                        if (GameObject* pExplosive = instance->GetGameObject(*itr))
                            pExplosive->Use(pBlastmaster);
                    }
                    m_luiSpawnedExplosiveChargeGUIDs.clear();
                    break;
            }
            return;
        case TYPE_THERMAPLUGG:
            m_auiEncounter[1] = uiData;
            if (uiData == IN_PROGRESS)
            {
                // Make Door locked
                if (GameObject* pDoor = GetSingleGameObjectFromStorage(GO_THE_FINAL_CHAMBER))
                {
                    pDoor->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED);
                    if (pDoor->GetLootState() == GO_ACTIVATED)
                        pDoor->ResetDoorOrButton();
                }

                // Always directly activates this bomb-face
                DoActivateBombFace(2);
            }
            else if (uiData == DONE || uiData == FAIL)
            {
                // Make Door unlocked again
                if (GameObject* pDoor = GetSingleGameObjectFromStorage(GO_THE_FINAL_CHAMBER))
                {
                    pDoor->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED);
                    if (pDoor->GetLootState() == GO_READY)
                        pDoor->UseDoorOrButton();
                }

                // Deactivate all remaining BombFaces
                for (uint8 i = 0; i < MAX_GNOME_FACES; ++i)
                    DoDeactivateBombFace(i);
            }
            break;
    }

    if (uiData == DONE)
    {
        OUT_SAVE_INST_DATA;

        std::ostringstream saveStream;
        saveStream << m_auiEncounter[0] << " " << m_auiEncounter[1];

        m_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}