コード例 #1
0
void instance_gundrak::SetData(uint32 uiType, uint32 uiData)
{
    debug_log("SD2: Instance Gundrak: SetData received for type %u with data %u",uiType,uiData);

    switch(uiType)
    {
        case TYPE_SLADRAN:
            m_auiEncounter[0] = uiData;
            if (uiData == DONE)
                if (GameObject* pGo = instance->GetGameObject(m_uiAltarOfSladranGUID))
                    pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1);
            if (uiData == SPECIAL)
			{
                DoUseDoorOrButton(m_uiSnakeKeyGUID);
				DoSwitchBridgeIfCan();
			}
            break;
        case TYPE_MOORABI:
            m_auiEncounter[1] = uiData;
            if (uiData == DONE)
            {
                if (!instance->IsRegularDifficulty())
                    DoUseDoorOrButton(m_uiEckDoorGUID);
                if (GameObject* pGo = instance->GetGameObject(m_uiAltarOfMoorabiGUID))
                    pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1);
            }
            if (uiData == SPECIAL)
			{
                DoUseDoorOrButton(m_uiMammothKeyGUID);
				DoSwitchBridgeIfCan();
			}
            break;
        case TYPE_COLOSSUS:
            m_auiEncounter[2] = uiData;
            if (uiData == DONE)
                if (GameObject* pGo = instance->GetGameObject(m_uiAltarOfColossusGUID))
                    pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1);
            if (uiData == SPECIAL)
			{
                DoUseDoorOrButton(m_uiTrollKeyGUID);
				DoSwitchBridgeIfCan();
			}
            break;
        case TYPE_GALDARAH:
            m_auiEncounter[3] = uiData;
            DoUseDoorOrButton(m_uiGaldarahDoorGUID);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(m_uiExitDoorLeftGUID);
                DoUseDoorOrButton(m_uiExitDoorRightGUID);
            }
            break;
        case TYPE_ECK:
            m_auiEncounter[4] = uiData;
            if (uiData == DONE)
                DoUseDoorOrButton(m_uiEckUnderwaterDoorGUID);
            break;
        default:
            error_log("SD2: Instance Gundrak: ERROR SetData = %u for type %u does not exist/not implemented.",uiType,uiData);
            break;
    }

    if (uiData == DONE)
    {
        OUT_SAVE_INST_DATA;

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

        strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
コード例 #2
0
CanCastResult BossSpellWorker::_BSWSpellSelector(uint8 m_uiSpellIdx, Unit* pTarget)
{
    if (_bossSpellCount == 0) return CAST_FAIL_OTHER;
    SpellEntry const *spell;
    SpellTable* pSpell = &m_BossSpell[m_uiSpellIdx];
    Unit* pSummon = NULL;

        debug_log("BSW: Casting spell number %u type %u",pSpell->m_uiSpellEntry[currentDifficulty], pSpell->m_CastTarget);

        switch (pSpell->m_CastTarget) {

            case DO_NOTHING: 
                   return CAST_OK;

            case CAST_ON_SELF:
                   if (!pSpell->m_IsBugged) return _DoCastSpellIfCan(boss, pSpell->m_uiSpellEntry[currentDifficulty]);
                   else return _BSWDoCast(m_uiSpellIdx, boss);
                   break;

            case CAST_ON_SUMMONS:
                   if (!pTarget) return CAST_FAIL_OTHER;
                   else return _DoCastSpellIfCan(pTarget, pSpell->m_uiSpellEntry[currentDifficulty]);
                   break;

            case CAST_ON_VICTIM:
                   pTarget = boss->getVictim();
                   return _BSWCastOnTarget(pTarget, m_uiSpellIdx);
                   break;

            case CAST_ON_RANDOM:
                   pTarget = SelectUnit(SELECT_TARGET_RANDOM);
                   return _BSWCastOnTarget(pTarget, m_uiSpellIdx);
                   break;

            case CAST_ON_BOTTOMAGGRO:
                   pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0);
                   return _BSWCastOnTarget(pTarget, m_uiSpellIdx);
                   break;

            case CAST_ON_TARGET:
                   return _BSWCastOnTarget(pTarget, m_uiSpellIdx);
                   break;

            case APPLY_AURA_SELF:
                   if (spell = (SpellEntry *)GetSpellStore()->LookupEntry(pSpell->m_uiSpellEntry[currentDifficulty]))
                          if(boss->AddAura(pSpell->m_uiSpellEntry[currentDifficulty], boss))
                              return CAST_OK;
                          else return CAST_FAIL_OTHER;
                   break;

            case APPLY_AURA_TARGET:
                   if (!pTarget) return CAST_FAIL_OTHER;
                   if (spell = (SpellEntry *)GetSpellStore()->LookupEntry(pSpell->m_uiSpellEntry[currentDifficulty]))
                          if (pTarget->AddAura(pSpell->m_uiSpellEntry[currentDifficulty], pTarget))
                              return CAST_OK;
                          else return CAST_FAIL_OTHER;
                   break;

            case SUMMON_NORMAL:
                   pSummon = _doSummon(m_uiSpellIdx, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 5000);
                   if(pSummon) return CAST_OK;
                          else return CAST_FAIL_OTHER;
                   break;

            case SUMMON_TEMP:
                   pSummon = _doSummon(m_uiSpellIdx, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,
                                        urand(pSpell->m_uiSpellTimerMin[currentDifficulty],pSpell->m_uiSpellTimerMax[currentDifficulty]));
                   if(pSummon) return CAST_OK;
                          else return CAST_FAIL_OTHER;
                   break;

            case SUMMON_INSTANT:
                   pSummon = _doSummon(m_uiSpellIdx, TEMPSUMMON_MANUAL_DESPAWN,0);
                   if(pSummon) return CAST_OK;
                          else return CAST_FAIL_OTHER;
                   break;

            case CAST_ON_ALLPLAYERS:
            {
                    CanCastResult res1 = CAST_FAIL_OTHER;
                    Map::PlayerList const& pPlayers = pMap->GetPlayers();
                    for (Map::PlayerList::const_iterator itr = pPlayers.begin(); itr != pPlayers.end(); ++itr)
                    {
                        pTarget = itr->getSource();
                        if (pTarget && pTarget->isAlive() && pTarget->IsWithinDistInMap(boss, pSpell->LocData.x))
                                    if (!pSpell->m_IsBugged) {
                                         res1 = _DoCastSpellIfCan(pTarget, pSpell->m_uiSpellEntry[currentDifficulty]);
                                         }
                                         else {
                                          _BSWDoCast(m_uiSpellIdx, pTarget);
                                          res1 = CAST_OK;
                                          };
                            return res1;
                     }
                   break;
            }

            case CAST_ON_FRENDLY:
                   pTarget = SelectLowHPFriendly();
                   return _BSWCastOnTarget(pTarget, m_uiSpellIdx);
                   break;

            case CAST_ON_FRENDLY_LOWHP:
                   pTarget = SelectLowHPFriendly();
                   return _BSWCastOnTarget(pTarget, m_uiSpellIdx);
                   break;

            default:
                   return CAST_FAIL_OTHER;
                   break;
            };
    return CAST_FAIL_OTHER;
};
コード例 #3
0
void BossSpellWorker::LoadSpellTable()
{
    debug_log("BSW: Loading table of spells boss  %u difficulty %u", bossID , currentDifficulty);

      char query[MAX_QUERY_LEN];

      sprintf(query, "SELECT entry, spellID_N10, spellID_N25, spellID_H10, spellID_H25, timerMin_N10, timerMin_N25, timerMin_H10, timerMin_H25, timerMax_N10, timerMax_N25, timerMax_H10, timerMax_H25, data1, data2, data3, data4, locData_x, locData_y, locData_z, varData, StageMask_N, StageMask_H, CastType, isVisualEffect, isBugged, textEntry FROM `boss_spell_table` WHERE entry = %u;\r\n", bossID);

      QueryResult_AutoPtr Result = WorldDatabase.PQuery(query);

    if (Result)
    {
        uint32 uiCount = 0;
        do
        {
            Field* pFields = Result->Fetch();

            m_BossSpell[uiCount].id  = uiCount;

            int32 bossEntry          = pFields[0].GetInt32();

            for (uint8 j = 0; j < DIFFICULTY_LEVELS; ++j)
                 m_BossSpell[uiCount].m_uiSpellEntry[j]  = pFields[1+j].GetUInt32();

            for (uint8 j = 0; j < DIFFICULTY_LEVELS; ++j)
                 m_BossSpell[uiCount].m_uiSpellTimerMin[j]  = pFields[1+DIFFICULTY_LEVELS+j].GetUInt32();

            for (uint8 j = 0; j < DIFFICULTY_LEVELS; ++j)
                 m_BossSpell[uiCount].m_uiSpellTimerMax[j]  = pFields[1+DIFFICULTY_LEVELS*2+j].GetUInt32();

            for (uint8 j = 0; j < DIFFICULTY_LEVELS; ++j)
                 m_BossSpell[uiCount].m_uiSpellData[j]  = pFields[1+DIFFICULTY_LEVELS*3+j].GetUInt32();

            m_BossSpell[uiCount].LocData.x  = pFields[1+DIFFICULTY_LEVELS*4].GetFloat();
            m_BossSpell[uiCount].LocData.y  = pFields[2+DIFFICULTY_LEVELS*4].GetFloat();
            m_BossSpell[uiCount].LocData.z  = pFields[3+DIFFICULTY_LEVELS*4].GetFloat();

            m_BossSpell[uiCount].varData    = pFields[4+DIFFICULTY_LEVELS*4].GetInt32();

            m_BossSpell[uiCount].StageMaskN = pFields[5+DIFFICULTY_LEVELS*4].GetUInt32();
            m_BossSpell[uiCount].StageMaskH = pFields[6+DIFFICULTY_LEVELS*4].GetUInt32();

            m_BossSpell[uiCount].m_CastTarget = getBSWCastType(pFields[7+DIFFICULTY_LEVELS*4].GetUInt8());

            m_BossSpell[uiCount].m_IsVisualEffect = (pFields[8+DIFFICULTY_LEVELS*4].GetUInt8() == 0) ? false : true ;

            m_BossSpell[uiCount].m_IsBugged = (pFields[9+DIFFICULTY_LEVELS*4].GetUInt8() == 0) ? false : true ;

            m_BossSpell[uiCount].textEntry = pFields[10+DIFFICULTY_LEVELS*4].GetInt32();

            if (bossEntry != bossID) error_db_log("BSW: Unknown error while load boss_spell_table");

            ++uiCount;

        } while (Result->NextRow());

        _bossSpellCount = uiCount;

        _fillEmptyDataField();

        debug_log("BSW: Loaded %u boss spell data records for boss %u", uiCount, bossID);
    }
    else
    {
        error_db_log("BSW: Boss spell table for boss %u is empty.", bossID);
        _bossSpellCount = 0;
    };
}
コード例 #4
0
ファイル: ac_wpn.c プロジェクト: Comanche93/eech
aircraft_fire_result aircraft_fire_weapon (entity *en, unsigned int check_flags)
{
	entity
		*target;

	aircraft
		*raw;

	vec3d
		*target_pos,
		en_pos;

	int loal_mode = FALSE;

	ASSERT (en);

	raw = (aircraft *) get_local_entity_data (en);

	//
	// Fire suppressed
	//

	if (check_flags & AIRCRAFT_FIRE_SUPPRESSED)
	{
		if (get_local_entity_int_value (get_session_entity (), INT_TYPE_SUPPRESS_AI_FIRE))
		{
			return AIRCRAFT_FIRE_SUPPRESSED;
		}
	}

	//
	// check weapon
	//

	if (check_flags & AIRCRAFT_FIRE_NO_WEAPON)
	{
		if (get_local_entity_int_value (en, INT_TYPE_SELECTED_WEAPON) == ENTITY_SUB_TYPE_WEAPON_NO_WEAPON)
		{
			debug_log ("AC_WPN: Fire Weapon Error - NO WEAPON");

			return AIRCRAFT_FIRE_NO_WEAPON;
		}
	}

	//
	// weapon system_ready
	//

	if (check_flags & AIRCRAFT_FIRE_WEAPON_SYSTEM_NOT_READY)
	{
		if (!get_local_entity_int_value (en, INT_TYPE_SELECTED_WEAPON_SYSTEM_READY))
		{
			debug_log ("AC_WPN: Fire Weapon Error - WEAPON SYSTEM NOT READY");

			return AIRCRAFT_FIRE_WEAPON_SYSTEM_NOT_READY;
		}
	}

//	debug_log("%s: %d", get_sub_type_name(en), get_local_entity_int_value (en, INT_TYPE_SELECTED_WEAPON));

	//
	// find target
	//

	if (check_flags & AIRCRAFT_FIRE_NO_TARGET)
	{
		target = get_local_entity_parent (en, LIST_TYPE_TARGET);

		if (!target)
		{
			debug_log ("AC_WPN: Fire Weapon Error - NO TARGET");

			return AIRCRAFT_FIRE_NO_TARGET;
		}
	}

	//
	// line of sight checks
	//

	if (check_flags & AIRCRAFT_FIRE_NO_LOS)
	{
		int
			criteria;

		if (get_local_entity_int_value (target, INT_TYPE_PLAYER) != ENTITY_PLAYER_AI)
		{
			criteria = MOBILE_LOS_CHECK_ALL;
		}
		else
		{
			criteria = MOBILE_LOS_CHECK_COURSE_TERRAIN;
		}

		get_local_entity_vec3d (en, VEC3D_TYPE_POSITION, &en_pos);

		target_pos = get_local_entity_vec3d_ptr (target, VEC3D_TYPE_POSITION);

		en_pos.y -= (get_local_entity_float_value (en, FLOAT_TYPE_CENTRE_OF_GRAVITY_TO_GROUND_DISTANCE) + 2.0);

		if (!check_position_line_of_sight (en, target, &en_pos, target_pos, (mobile_los_check_criteria) criteria))
		{
			if (get_local_entity_int_value (en, INT_TYPE_SELECTED_WEAPON) == ENTITY_SUB_TYPE_WEAPON_AGM114L_LONGBOW_HELLFIRE
				&& get_2d_range(&en_pos, target_pos) > weapon_database[ENTITY_SUB_TYPE_WEAPON_AGM114L_LONGBOW_HELLFIRE].min_range_loal)
			{
				debug_log("AC_WPN: Switching to LOAL mode to fire at target without LOS ((Aircraft %s (%d), Target %s (%d))",
									get_local_entity_string (en, STRING_TYPE_FULL_NAME), get_local_entity_index (en),
									get_local_entity_string (target, STRING_TYPE_FULL_NAME), get_local_entity_index (target));

				loal_mode = TRUE;
			}
			else
			{
				debug_log ("AC_WPN: Fire Weapon Error - NO LOS (Aircraft %s (%d), Target %s (%d))",
									get_local_entity_string (en, STRING_TYPE_FULL_NAME), get_local_entity_index (en),
									get_local_entity_string (target, STRING_TYPE_FULL_NAME), get_local_entity_index (target));

				return AIRCRAFT_FIRE_NO_LOS;
			}
		}
	}

	//
	// Play Speech
	//

	play_aircraft_weapon_launched_speech (en, raw->selected_weapon);

	//
	// Fire weapon
	//

	set_local_entity_int_value(en, INT_TYPE_LOCK_ON_AFTER_LAUNCH, loal_mode);

	launch_client_server_weapon (en, raw->selected_weapon);

	return AIRCRAFT_FIRE_OK;
}
コード例 #5
0
ファイル: ScriptMgr.cpp プロジェクト: Toxicity/SD2243
/**
 * Function that does script text
 *
 * @param iTextEntry Entry of the text, stored in SD2-database
 * @param pSource Source of the text
 * @param pTarget Can be NULL (depending on CHAT_TYPE of iTextEntry). Possible target for the text
 */
void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget)
{
    if (!pSource)
    {
        error_log("SD2: DoScriptText entry %i, invalid Source pointer.", iTextEntry);
        return;
    }

    if (iTextEntry >= 0)
    {
        error_log("SD2: DoScriptText with source entry %u (TypeId=%u, guid=%u) attempts to process text entry %i, but text entry must be negative.",
            pSource->GetEntry(), pSource->GetTypeId(), pSource->GetGUIDLow(), iTextEntry);

        return;
    }

    const StringTextData* pData = pSystemMgr.GetTextData(iTextEntry);
    if (!pData)
    {
        error_log("SD2: DoScriptText with source entry %u (TypeId=%u, guid=%u) could not find text entry %i.",
            pSource->GetEntry(), pSource->GetTypeId(), pSource->GetGUIDLow(), iTextEntry);

        return;
    }

    debug_log("SD2: DoScriptText: text entry=%i, Sound=%u, Type=%u, Language=%u, Emote=%u",
        iTextEntry, pData->uiSoundId, pData->uiType, pData->uiLanguage, pData->uiEmote);

    if (pData->uiSoundId)
    {
        if (GetSoundEntriesStore()->LookupEntry(pData->uiSoundId))
        {
            if (pData->uiType == CHAT_TYPE_ZONE_YELL)
                pSource->GetMap()->PlayDirectSoundToMap(pData->uiSoundId, pSource->GetZoneId());
            else if (pData->uiType == CHAT_TYPE_WHISPER || pData->uiType == CHAT_TYPE_BOSS_WHISPER)
            {
                // An error will be displayed for the text
                if (pTarget && pTarget->GetTypeId() == TYPEID_PLAYER)
                    pSource->PlayDirectSound(pData->uiSoundId, (Player*)pTarget);
            }
            else
                pSource->PlayDirectSound(pData->uiSoundId);
        }
        else
            error_log("SD2: DoScriptText entry %i tried to process invalid sound id %u.", iTextEntry, pData->uiSoundId);
    }

    if (pData->uiEmote)
    {
        if (pSource->GetTypeId() == TYPEID_UNIT || pSource->GetTypeId() == TYPEID_PLAYER)
            ((Unit*)pSource)->HandleEmote(pData->uiEmote);
        else
            error_log("SD2: DoScriptText entry %i tried to process emote for invalid TypeId (%u).", iTextEntry, pSource->GetTypeId());
    }

    switch(pData->uiType)
    {
        case CHAT_TYPE_SAY:
            pSource->MonsterSay(iTextEntry, pData->uiLanguage, pTarget);
            break;
        case CHAT_TYPE_YELL:
            pSource->MonsterYell(iTextEntry, pData->uiLanguage, pTarget);
            break;
        case CHAT_TYPE_TEXT_EMOTE:
            pSource->MonsterTextEmote(iTextEntry, pTarget);
            break;
        case CHAT_TYPE_BOSS_EMOTE:
            pSource->MonsterTextEmote(iTextEntry, pTarget, true);
            break;
        case CHAT_TYPE_WHISPER:
        {
            if (pTarget && pTarget->GetTypeId() == TYPEID_PLAYER)
                pSource->MonsterWhisper(iTextEntry, pTarget);
            else
                error_log("SD2: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", iTextEntry);

            break;
        }
        case CHAT_TYPE_BOSS_WHISPER:
        {
            if (pTarget && pTarget->GetTypeId() == TYPEID_PLAYER)
                pSource->MonsterWhisper(iTextEntry, pTarget, true);
            else
                error_log("SD2: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", iTextEntry);

            break;
        }
        case CHAT_TYPE_ZONE_YELL:
            pSource->MonsterYellToZone(iTextEntry, pData->uiLanguage, pTarget);
            break;
    }
}
コード例 #6
0
void instance_stratholme::Update(uint32 uiDiff)
{
    if (m_uiBarthilasRunTimer)
    {
        if (m_uiBarthilasRunTimer <= uiDiff)
        {
            Creature* pBarthilas = GetSingleCreatureFromStorage(NPC_BARTHILAS);
            if (pBarthilas && pBarthilas->IsAlive() && !pBarthilas->IsInCombat())
                pBarthilas->NearTeleportTo(aStratholmeLocation[1].m_fX, aStratholmeLocation[1].m_fY, aStratholmeLocation[1].m_fZ, aStratholmeLocation[1].m_fO);

            SetData(TYPE_BARTHILAS_RUN, DONE);
            m_uiBarthilasRunTimer = 0;
        }
        else
            m_uiBarthilasRunTimer -= uiDiff;
    }

    if (m_uiBaronRunTimer)
    {
        if (m_uiYellCounter == 0 && m_uiBaronRunTimer <= 10 * MINUTE * IN_MILLISECONDS)
        {
            DoOrSimulateScriptTextForThisInstance(SAY_ANNOUNCE_RUN_10_MIN, NPC_BARON);
            ++m_uiYellCounter;
        }
        else if (m_uiYellCounter == 1 && m_uiBaronRunTimer <= 5 * MINUTE * IN_MILLISECONDS)
        {
            DoOrSimulateScriptTextForThisInstance(SAY_ANNOUNCE_RUN_5_MIN, NPC_BARON);
            ++m_uiYellCounter;
        }

        if (m_uiBaronRunTimer <= uiDiff)
        {
            SetData(TYPE_BARON_RUN, FAIL);

            DoOrSimulateScriptTextForThisInstance(SAY_ANNOUNCE_RUN_FAIL, NPC_BARON);

            m_uiBaronRunTimer = 0;
            debug_log("SD2: Instance Stratholme: Baron run event reached end. Event has state %u.", GetData(TYPE_BARON_RUN));
        }
        else
            m_uiBaronRunTimer -= uiDiff;
    }

    if (m_uiMindlessSummonTimer)
    {
        if (m_uiMindlessCount < 30)
        {
            if (m_uiMindlessSummonTimer <= uiDiff)
            {
                if (Creature* pBaron = GetSingleCreatureFromStorage(NPC_BARON))
                {
                    // Summon mindless skeletons and move them to random point in the center of the square
                    if (Creature* pTemp = pBaron->SummonCreature(NPC_MINDLESS_UNDEAD, aStratholmeLocation[4].m_fX, aStratholmeLocation[4].m_fY, aStratholmeLocation[4].m_fZ, aStratholmeLocation[4].m_fO, TEMPSUMMON_DEAD_DESPAWN, 0))
                    {
                        float fX, fY, fZ;
                        pBaron->GetRandomPoint(aStratholmeLocation[5].m_fX, aStratholmeLocation[5].m_fY, aStratholmeLocation[5].m_fZ, 20.0f, fX, fY, fZ);
                        pTemp->GetMotionMaster()->MovePoint(0, fX, fY, fZ);
                        m_luiUndeadGUIDs.push_back(pTemp->GetObjectGuid());
                        ++m_uiMindlessCount;
                    }
                }
                m_uiMindlessSummonTimer = 400;
            }
            else
                m_uiMindlessSummonTimer -= uiDiff;
        }
        else
            m_uiMindlessSummonTimer = 0;
    }

    if (m_uiSlaugtherSquareTimer)
    {
        if (m_uiSlaugtherSquareTimer <= uiDiff)
        {
            // Call next Abomnations
            for (GuidSet::const_iterator itr = m_sAbomnationGUID.begin(); itr != m_sAbomnationGUID.end(); ++itr)
            {
                Creature* pAbom = instance->GetCreature(*itr);
                // Skip killed and already walking Abomnations
                if (!pAbom || !pAbom->IsAlive() || pAbom->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE)
                    continue;

                // Let Move to somewhere in the middle
                if (!pAbom->IsInCombat())
                {
                    if (GameObject* pDoor = GetSingleGameObjectFromStorage(GO_PORT_SLAUGTHER))
                    {
                        float fX, fY, fZ;
                        pAbom->GetRandomPoint(pDoor->GetPositionX(), pDoor->GetPositionY(), pDoor->GetPositionZ(), 10.0f, fX, fY, fZ);
                        pAbom->GetMotionMaster()->MovePoint(0, fX, fY, fZ);
                    }
                }
                break;
            }

            // TODO - how fast are they called?
            m_uiSlaugtherSquareTimer = urand(15000, 30000);
        }
        else
            m_uiSlaugtherSquareTimer -= uiDiff;
    }
}
コード例 #7
0
void hna_global_add_orig(struct orig_node *orig_node,
			 unsigned char *hna_buff, int hna_buff_len)
{
	struct hna_global_entry *hna_global_entry;
	struct hna_local_entry *hna_local_entry;
	struct hashtable_t *swaphash;
	char hna_str[ETH_STR_LEN], orig_str[ETH_STR_LEN];
	int hna_buff_count = 0;
	unsigned long flags;
	unsigned char *hna_ptr;

	addr_to_string(orig_str, orig_node->orig);

	while ((hna_buff_count + 1) * ETH_ALEN <= hna_buff_len) {
		spin_lock_irqsave(&hna_global_hash_lock, flags);

		hna_ptr = hna_buff + (hna_buff_count * ETH_ALEN);
		hna_global_entry = (struct hna_global_entry *)
			hash_find(hna_global_hash, hna_ptr);

		if (hna_global_entry == NULL) {
			spin_unlock_irqrestore(&hna_global_hash_lock, flags);

			hna_global_entry =
				kmalloc(sizeof(struct hna_global_entry),
					GFP_ATOMIC);

			if (!hna_global_entry)
				break;

			memcpy(hna_global_entry->addr, hna_ptr, ETH_ALEN);

			addr_to_string(hna_str, hna_global_entry->addr);
			debug_log(LOG_TYPE_ROUTES, "Creating new global hna entry: %s (via %s)\n", hna_str, orig_str);

			spin_lock_irqsave(&hna_global_hash_lock, flags);
			hash_add(hna_global_hash, hna_global_entry);

		}

		hna_global_entry->orig_node = orig_node;
		spin_unlock_irqrestore(&hna_global_hash_lock, flags);

		/* remove address from local hash if present */
		spin_lock_irqsave(&hna_local_hash_lock, flags);

		hna_ptr = hna_buff + (hna_buff_count * ETH_ALEN);
		hna_local_entry = (struct hna_local_entry *)
			hash_find(hna_local_hash, hna_ptr);

		if (hna_local_entry != NULL)
			hna_local_del(hna_local_entry, "global hna received");

		spin_unlock_irqrestore(&hna_local_hash_lock, flags);

		hna_buff_count++;
	}

	orig_node->hna_buff_len = hna_buff_len;

	if (orig_node->hna_buff_len > 0) {
		orig_node->hna_buff = kmalloc(orig_node->hna_buff_len,
					      GFP_ATOMIC);
		memcpy(orig_node->hna_buff, hna_buff, orig_node->hna_buff_len);
	} else {
		orig_node->hna_buff = NULL;
	}

	spin_lock_irqsave(&hna_global_hash_lock, flags);

	if (hna_global_hash->elements * 4 > hna_global_hash->size) {
		swaphash = hash_resize(hna_global_hash,
				       hna_global_hash->size * 2);

		if (swaphash == NULL)
			debug_log(LOG_TYPE_CRIT, "Couldn't resize global hna hash table \n");
		else
			hna_global_hash = swaphash;
	}

	spin_unlock_irqrestore(&hna_global_hash_lock, flags);
}
コード例 #8
0
ファイル: boss_kaelthas.cpp プロジェクト: Aminxhm/OregonCore
    void UpdateAI(const uint32 diff)
    {
        //Phase 1
        switch (Phase)
        {
        case 1:
            {
                Unit* pTarget = NULL;
                Creature* Advisor = NULL;

                //Subphase switch
                switch (PhaseSubphase)
                {
                //Subphase 1 - Start
                case 0:
                    if (Phase_Timer <= diff)
                    {
                        DoScriptText(SAY_INTRO_THALADRED, me);

                        //start advisor within 7 seconds
                        Phase_Timer = 7000;

                        PhaseSubphase++;
                    }
                    else Phase_Timer -= diff;
                    break;

                //Subphase 1 - Unlock advisor
                case 1:
                    if (Phase_Timer <= diff)
                    {
                        Advisor = (Creature*)(Unit::GetUnit((*me), m_auiAdvisorGuid[0]));

                        if (Advisor)
                        {
                            Advisor->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                            Advisor->setFaction(me->getFaction());

                            pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0);
                            if (pTarget)
                                Advisor->AI()->AttackStart(pTarget);
                        }

                        PhaseSubphase++;
                    }
                    else Phase_Timer -= diff;
                    break;

                //Subphase 2 - Start
                case 2:
                    Advisor = (Creature*)(Unit::GetUnit((*me), m_auiAdvisorGuid[0]));

                    if (Advisor && (Advisor->getStandState() == UNIT_STAND_STATE_DEAD))
                    {
                        DoScriptText(SAY_INTRO_SANGUINAR, me);

                        //start advisor within 12.5 seconds
                        Phase_Timer = 12500;

                        PhaseSubphase++;
                    }
                    break;

                //Subphase 2 - Unlock advisor
                case 3:
                    if (Phase_Timer <= diff)
                    {
                        Advisor = (Creature*)(Unit::GetUnit((*me), m_auiAdvisorGuid[1]));

                        if (Advisor)
                        {
                            Advisor->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                            Advisor->setFaction(me->getFaction());

                            pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0);
                            if (pTarget)
                                Advisor->AI()->AttackStart(pTarget);
                        }

                        PhaseSubphase++;
                    }
                    else Phase_Timer -= diff;
                    break;

                //Subphase 3 - Start
                case 4:
                    Advisor = (Creature*)(Unit::GetUnit((*me), m_auiAdvisorGuid[1]));

                    if (Advisor && (Advisor->getStandState() == UNIT_STAND_STATE_DEAD))
                    {
                        DoScriptText(SAY_INTRO_CAPERNIAN, me);

                        //start advisor within 7 seconds
                        Phase_Timer = 7000;

                        PhaseSubphase++;
                    }
                    break;

                //Subphase 3 - Unlock advisor
                case 5:
                    if (Phase_Timer <= diff)
                    {
                        Advisor = (Creature*)(Unit::GetUnit((*me), m_auiAdvisorGuid[2]));

                        if (Advisor)
                        {
                            Advisor->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                            Advisor->setFaction(me->getFaction());

                            pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0);
                            if (pTarget)
                                Advisor->AI()->AttackStart(pTarget);
                        }

                        PhaseSubphase++;
                    }
                    else Phase_Timer -= diff;
                    break;

                //Subphase 4 - Start
                case 6:
                    Advisor = (Creature*)(Unit::GetUnit((*me), m_auiAdvisorGuid[2]));

                    if (Advisor && (Advisor->getStandState() == UNIT_STAND_STATE_DEAD))
                    {
                        DoScriptText(SAY_INTRO_TELONICUS, me);

                        //start advisor within 8.4 seconds
                        Phase_Timer = 8400;

                        PhaseSubphase++;
                    }
                    break;

                //Subphase 4 - Unlock advisor
                case 7:
                    if (Phase_Timer <= diff)
                    {
                        Advisor = (Creature*)(Unit::GetUnit((*me), m_auiAdvisorGuid[3]));

                        if (Advisor)
                        {
                            Advisor->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                            Advisor->setFaction(me->getFaction());

                            pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0);
                            if (pTarget)
                                Advisor->AI()->AttackStart(pTarget);
                        }

                        Phase_Timer = 3000;

                        PhaseSubphase++;
                    }
                    else Phase_Timer -= diff;
                    break;

                //End of phase 1
                case 8:
                    Advisor = (Creature*)(Unit::GetUnit((*me), m_auiAdvisorGuid[3]));

                    if (Advisor && (Advisor->getStandState() == UNIT_STAND_STATE_DEAD))
                    {
                        Phase = 2;
                        m_pInstance->SetData(DATA_KAELTHASEVENT, 2);

                        DoScriptText(SAY_PHASE2_WEAPON, me);
                        PhaseSubphase = 0;
                        Phase_Timer = 3500;
                        DoCast(me, SPELL_SUMMON_WEAPONS);
                    }
                    break;
                }
            }
            break;

        case 2:
            {
                if (PhaseSubphase == 0)
                {
                    if (Phase_Timer <= diff)
                        PhaseSubphase = 1;
                    else Phase_Timer -= diff;
                }

                //Spawn weapons
                if (PhaseSubphase == 1)
                {
                    me->CastSpell(me, SPELL_SUMMON_WEAPONS, false);

                    uint8 uiMaxWeapon = sizeof(m_auiSpellSummonWeapon) / sizeof(uint32);

                    for (uint32 i = 0; i < uiMaxWeapon; ++i)
                        me->CastSpell(me, m_auiSpellSummonWeapon[i], true);

                    PhaseSubphase = 2;
                    Phase_Timer = TIME_PHASE_2_3;
                }

                if (PhaseSubphase == 2)
                {
                    if (Phase_Timer < diff)
                    {
                        DoScriptText(SAY_PHASE3_ADVANCE, me);
                        m_pInstance->SetData(DATA_KAELTHASEVENT, 3);
                        Phase = 3;
                        PhaseSubphase = 0;
                    }
                    else Phase_Timer -= diff;
                }
            }
            break;

        case 3:
            {
                if (PhaseSubphase == 0)
                {
                    //Respawn advisors
                    Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0);

                    Creature* Advisor;
                    for (uint32 i = 0; i < MAX_ADVISORS; i++)
                    {
                        Advisor = (Creature*)(Unit::GetUnit((*me), m_auiAdvisorGuid[i]));
                        if (!Advisor)
                            error_log("OSCR: Kael'Thas Advisor %u does not exist. Possibly despawned? Incorrectly Killed?", i);
                        else if (pTarget)
                            ((advisorbase_ai*)Advisor->AI())->Revive(pTarget);
                    }

                    PhaseSubphase = 1;
                    Phase_Timer = TIME_PHASE_3_4;
                }

                if (Phase_Timer <= diff)
                {
                    DoScriptText(SAY_PHASE4_INTRO2, me);
                    Phase = 4;

                    m_pInstance->SetData(DATA_KAELTHASEVENT, 4);

                    // Sometimes people can collect Aggro in Phase 1-3. Reset threat before releasing Kael.
                    DoResetThreat();

                    me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                    me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);

                    if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                        AttackStart(pTarget);

                    Phase_Timer = 30000;
                }
                else Phase_Timer -= diff;
            }
            break;

        case 4:
        case 5:
        case 6:
            {
                //Return since we have no target
                if (!UpdateVictim())
                    return;

                //Fireball_Timer
                if (!InGravityLapse && !ChainPyros && Phase != 5)
                {
                    if (Fireball_Timer <= diff)
                    {
                        if (!IsCastingFireball)
                        {
                            if (!me->IsNonMeleeSpellCast(false))
                            {
                                //interruptable
                                me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_INTERRUPT_CAST, false);
                                int32 dmg = 20000 + rand() % 5000;
                                me->CastCustomSpell(me->getVictim(), SPELL_FIREBALL, &dmg, 0, 0, false);
                                IsCastingFireball = true;
                                Fireball_Timer = 2500;
                            }
                        }
                        else
                        {
                            //apply resistance
                            me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_INTERRUPT_CAST, true);
                            IsCastingFireball = false;
                            Fireball_Timer = 5000 + rand() % 10000;
                        }
                    }
                    else Fireball_Timer -= diff;

                    //ArcaneDisruption_Timer
                    if (ArcaneDisruption_Timer <= diff)
                    {
                        DoCastVictim( SPELL_ARCANE_DISRUPTION, true);

                        ArcaneDisruption_Timer = 60000;
                    }
                    else ArcaneDisruption_Timer -= diff;

                    if (FlameStrike_Timer <= diff)
                    {
                        if (Unit* pUnit = SelectUnit(SELECT_TARGET_RANDOM, 0))
                            DoCast(pUnit, SPELL_FLAME_STRIKE);

                        FlameStrike_Timer = 30000;
                    }
                    FlameStrike_Timer -= diff;

                    if (MindControl_Timer <= diff)
                    {
                        if (me->getThreatManager().getThreatList().size() >= 2)
                            for (uint32 i = 0; i < 3; i++)
                            {
                                debug_log("OSCR: Kael'Thas mind control not supported.");
                                //DoCast(pTarget, SPELL_MIND_CONTROL);
                            }

                        MindControl_Timer = 60000;
                    }
                    MindControl_Timer -= diff;
                }

                //Phoenix_Timer
                if (Phoenix_Timer <= diff)
                {
                    DoCast(me, SPELL_PHOENIX_ANIMATION);

                    if (Creature* pPhoenix = me->SummonCreature(NPC_PHOENIX, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45000))
                    {
                        if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                            pPhoenix->AI()->AttackStart(pTarget);
                    }
                    else
                        error_log("OSCR: Kael'Thas Phoenix could not be spawned");

                    switch (rand() % 2)
                    {
                    case 0:
                        DoScriptText(SAY_SUMMON_PHOENIX1, me);
                        break;
                    case 1:
                        DoScriptText(SAY_SUMMON_PHOENIX2, me);
                        break;
                    }

                    Phoenix_Timer = 60000;
                }
                else Phoenix_Timer -= diff;

                //Phase 4 specific spells
                if (Phase == 4)
                {
                    if (me->GetHealth() * 100 / me->GetMaxHealth() < 50)
                    {
                        m_pInstance->SetData(DATA_KAELTHASEVENT, 4);
                        Phase = 5;
                        Phase_Timer = 10000;

                        DoScriptText(SAY_PHASE5_NUTS, me);

                        me->StopMoving();
                        me->GetMotionMaster()->Clear();
                        me->GetMotionMaster()->MoveIdle();
                        me->Relocate(afGravityPos[0], afGravityPos[1], afGravityPos[2], 0);
                        Movement::MoveSplineInit init(*me);
                        init.MoveTo(afGravityPos[0], afGravityPos[1], afGravityPos[2], true);
                        init.Launch();

                        me->InterruptNonMeleeSpells(false);
                        DoCast(me, SPELL_FULLPOWER);
                        me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                    }

                    //ShockBarrier_Timer
                    if (ShockBarrier_Timer <= diff)
                    {
                        DoCast(me, SPELL_SHOCK_BARRIER);
                        ChainPyros = true;
                        PyrosCasted = 0;

                        ShockBarrier_Timer = 60000;
                    }
                    else ShockBarrier_Timer -= diff;

                    //Chain Pyros (3 of them max)
                    if (ChainPyros && !me->IsNonMeleeSpellCast(false))
                    {
                        if (PyrosCasted < 3)
                        {
                            DoCastVictim( SPELL_PYROBLAST);
                            PyrosCasted++;
                        }
                        else
                        {
                            ChainPyros = false;
                            Fireball_Timer = 2500;
                            ArcaneDisruption_Timer = 60000;
                        }
                    }
                }

                if (Phase == 5)
                {
                    if (Phase_Timer <= diff)
                    {
                        me->InterruptNonMeleeSpells(false);
                        me->RemoveAurasDueToSpell(SPELL_FULLPOWER);
                        DoCast(me, SPELL_EXPLODE);
                        me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                        Phase = 6;
                        AttackStart(me->getVictim());
                    }
                    else Phase_Timer -= diff;
                }

                //Phase 5
                if (Phase == 6)
                {

                    //GravityLapse_Timer
                    if (GravityLapse_Timer <= diff)
                    {
                        ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList();
                        ThreatContainer::StorageType::const_iterator i = threatlist.begin();

                        Movement::MoveSplineInit init(*me);
                        switch (GravityLapse_Phase)
                        {
                        case 0:
                            me->StopMoving();
                            me->GetMotionMaster()->Clear();
                            me->GetMotionMaster()->MoveIdle();
                            me->Relocate(afGravityPos[0], afGravityPos[1], afGravityPos[2], 0);
                            init.MoveTo(afGravityPos[0], afGravityPos[1], afGravityPos[2], true);
                            init.Launch();

                            // 1) Kael'thas will portal the whole raid right into his body
                            for (i = threatlist.begin(); i != threatlist.end(); ++i)
                            {
                                Unit* pUnit = Unit::GetUnit((*me), (*i)->getUnitGuid());
                                if (pUnit && (pUnit->GetTypeId() == TYPEID_PLAYER))
                                {
                                    //Use work around packet to prevent player from being dropped from combat
                                    DoTeleportPlayer(pUnit, afGravityPos[0], afGravityPos[1], afGravityPos[2], pUnit->GetOrientation());
                                }
                            }
                            GravityLapse_Timer = 500;
                            ++GravityLapse_Phase;
                            InGravityLapse = true;
                            ShockBarrier_Timer = 1000;
                            NetherBeam_Timer = 5000;
                            break;

                        case 1:
                            switch (rand() % 2)
                            {
                            case 0:
                                DoScriptText(SAY_GRAVITYLAPSE1, me);
                                break;
                            case 1:
                                DoScriptText(SAY_GRAVITYLAPSE2, me);
                                break;
                            }

                            // 2) At that point he will put a Gravity Lapse debuff on everyone
                            for (i = threatlist.begin(); i != threatlist.end(); ++i)
                            {
                                if (Unit* pUnit = Unit::GetUnit((*me), (*i)->getUnitGuid()))
                                {
                                    me->CastSpell(pUnit, SPELL_KNOCKBACK, true);
                                    //Gravity lapse - needs an exception in Spell system to work

                                    pUnit->CastSpell(pUnit, SPELL_GRAVITY_LAPSE, true, 0, 0, me->GetGUID());
                                    pUnit->CastSpell(pUnit, SPELL_GRAVITY_LAPSE_AURA, true, 0, 0, me->GetGUID());

                                    //Using packet workaround
                                    WorldPacket data(12);
                                    data.SetOpcode(SMSG_MOVE_SET_CAN_FLY);
                                    data << pUnit->GetPackGUID();
                                    data << uint32(0);
                                    pUnit->SendMessageToSet(&data, true);
                                }
                            }
                            GravityLapse_Timer = 10000;
                            GravityLapse_Phase++;
                            break;

                        case 2:
                            //Cast nether vapor aura on self
                            me->InterruptNonMeleeSpells(false);
                            DoCast(me, SPELL_NETHER_VAPOR);

                            GravityLapse_Timer = 20000;
                            GravityLapse_Phase++;
                            break;

                        case 3:
                            //Remove flight
                            for (i = threatlist.begin(); i != threatlist.end(); ++i)
                            {
                                if (Unit* pUnit = Unit::GetUnit((*me), (*i)->getUnitGuid()))
                                {
                                    //Using packet workaround
                                    WorldPacket data(12);
                                    data.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY);
                                    data << pUnit->GetPackGUID();
                                    data << uint32(0);
                                    pUnit->SendMessageToSet(&data, true);
                                }
                            }
                            me->RemoveAurasDueToSpell(SPELL_NETHER_VAPOR);
                            InGravityLapse = false;
                            GravityLapse_Timer = 60000;
                            GravityLapse_Phase = 0;
                            AttackStart(me->getVictim());
                            break;
                        }
                    }
                    else GravityLapse_Timer -= diff;

                    if (InGravityLapse)
                    {
                        //ShockBarrier_Timer
                        if (ShockBarrier_Timer <= diff)
                        {
                            DoCast(me, SPELL_SHOCK_BARRIER);
                            ShockBarrier_Timer = 20000;
                        }
                        else ShockBarrier_Timer -= diff;

                        //NetherBeam_Timer
                        if (NetherBeam_Timer <= diff)
                        {
                            if (Unit* pUnit = SelectUnit(SELECT_TARGET_RANDOM, 0))
                                DoCast(pUnit, SPELL_NETHER_BEAM);

                            NetherBeam_Timer = 4000;
                        }
                        else NetherBeam_Timer -= diff;
                    }
                }

                if (!InGravityLapse)
                    DoMeleeAttackIfReady();
            }
        }
    }
コード例 #9
0
    void SetData(uint32 type, uint32 data)
    {
        switch(type)
        {
            case DATA_RAGEWINTERCHILLEVENT: m_auiEncounter[0] = data; break;
            case DATA_ANETHERONEVENT:
                m_auiEncounter[1] = data;
                break;
            case DATA_KAZROGALEVENT:        m_auiEncounter[2] = data; break;
            case DATA_AZGALOREVENT:
                {
                    m_auiEncounter[3] = data;
                    if (data==DONE)
                    {
                        if (ArchiYell)break;
                        ArchiYell = true;

                        Creature* pCreature = instance->GetCreature(Azgalor);
                        if (pCreature)
                        {
                            Creature* pUnit = pCreature->SummonCreature(21987,pCreature->GetPositionX(),pCreature->GetPositionY(),pCreature->GetPositionZ(),0,TEMPSUMMON_TIMED_DESPAWN,10000);

                            Map* pMap = pCreature->GetMap();
                            if (pMap->IsDungeon() && pUnit)
                            {
                                pUnit->SetVisibility(VISIBILITY_OFF);
                                Map::PlayerList const &PlayerList = pMap->GetPlayers();
                                if (PlayerList.isEmpty())
                                     return;

                                for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
                                {
                                     if (i->getSource())
                                     {
                                        WorldPacket data(SMSG_MESSAGECHAT, 200);
                                        pUnit->BuildMonsterChat(&data,CHAT_MSG_MONSTER_YELL,YELL_EFFORTS,0,YELL_EFFORTS_NAME,i->getSource()->GetGUID());
                                        i->getSource()->GetSession()->SendPacket(&data);

                                        WorldPacket data2(SMSG_PLAY_SOUND, 4);
                                        data2 << 10986;
                                        i->getSource()->GetSession()->SendPacket(&data2);
                                     }
                                }
                            }
                        }
                    }
                }
                break;
            case DATA_ARCHIMONDEEVENT:      m_auiEncounter[4] = data; break;
            case DATA_RESET_TRASH_COUNT:    Trash = 0;            break;

            case DATA_TRASH:
                if (data) Trash = data;
                else     Trash--;
                DoUpdateWorldState(WORLD_STATE_ENEMYCOUNT, Trash);
                break;
            case TYPE_RETREAT:
                if (data == SPECIAL)
                {
                    if (!m_uiAncientGemGUID.empty())
                    {
                        for(std::list<uint64>::iterator itr = m_uiAncientGemGUID.begin(); itr != m_uiAncientGemGUID.end(); ++itr)
                        {
                            //don't know how long it expected
                            DoRespawnGameObject(*itr,DAY);
                        }
                    }
                }
                break;
            case DATA_ALLIANCE_RETREAT:
                allianceRetreat = data;
                HandleGameObject(HordeGate, true);
                SaveToDB();
                break;
            case DATA_HORDE_RETREAT:
                hordeRetreat = data;
                HandleGameObject(ElfGate, true);
                SaveToDB();
                break;
            case DATA_RAIDDAMAGE:
                RaidDamage += data;
                if (RaidDamage >= MINRAIDDAMAGE)
                    RaidDamage = MINRAIDDAMAGE;
                break;
            case DATA_RESET_RAIDDAMAGE:
                RaidDamage = 0;
                break;
        }

         debug_log("TSCR: Instance Hyjal: Instance data updated for event %u (Data=%u)",type,data);

        if (data == DONE)
        {
            OUT_SAVE_INST_DATA;

            std::ostringstream saveStream;
            saveStream << m_auiEncounter[0] << " " << m_auiEncounter[1] << " " << m_auiEncounter[2] << " "
                << m_auiEncounter[3] << " " << m_auiEncounter[4]
                << " " << allianceRetreat << " " << hordeRetreat
                << " " << RaidDamage;

            str_data = saveStream.str();

            SaveToDB();
            OUT_SAVE_INST_DATA_COMPLETE;
        }

    }
コード例 #10
0
ファイル: violet_hold.cpp プロジェクト: cbcs/ChgSD2
    void UpdateAI(const uint32 uiDiff){
        if(portalLoc != -1)
            StartMovement();

        if (IsWalking && WalkTimer)
        {
            if (WalkTimer <= uiDiff)
            {
                if (WayPoint != WayPointList.end())
                {
                    m_creature->GetMotionMaster()->MovePoint(WayPoint->id, WayPoint->x, WayPoint->y,WayPoint->z);
                    WalkTimer = 0;
                }
            }else WalkTimer -= uiDiff;
        }

        //Corrupt Seal

        if(Creature *pDoorSeal2 = GetClosestCreatureWithEntry(m_creature, NPC_DOOR_SEAL, 150.0f)){
            if(m_creature->IsWithinDist(pDoorSeal2, 27.0f, false) && !IsInCombat)
            {
                IsWalking = false;
                WayPointList.clear();
                m_creature->GetMotionMaster()->Clear(false);
                m_creature->RemoveSplineFlag(SPLINEFLAG_WALKMODE);
                DoCast(pDoorSeal2, SPELL_CORRUPT);
                m_pInstance->SetData(TYPE_DOOR,SPECIAL);
            }
        }
        if(!IsWalking && !IsInCombat) {
                if (Unit* m_uEmbraceTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0))
                m_creature->GetMotionMaster()->MoveChase(m_uEmbraceTarget);
                m_creature->SetInCombatWithZone();
                IsInCombat = true;
                }


        //Return since we have no target
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if(m_creature->getVictim())
            if(m_creature->getVictim()->GetEntry() == NPC_DOOR_SEAL)
                return;
        switch(creatureEntry)
        {
            case NPC_AZURE_CAPTAIN:
                AzureCaptain_UpdateAI(uiDiff);
                break;
            case NPC_AZURE_RAIDER:
                AzureRaider_UpdateAI(uiDiff);
                break;
            case NPC_AZURE_SORCEROR:
                AzureSorceror_UpdateAI(uiDiff);
                break;
            case NPC_AZURE_STALKER:
                AzureStalker_UpdateAI(uiDiff);
                break;
            case NPC_GUARDIAN:
            case NPC_KEEPER:
            case NPC_AZURE_BINDER:
            case NPC_AZURE_INVADER:
            case NPC_AZURE_MAGE_SLAYER:
            case NPC_AZURE_SPELLBREAKER:
                break;
            default:
                debug_log("重云垂� The Violet Hold: Unhandled dragon entry %u!", m_creature->GetEntry());
                break;
        }
        DoMeleeAttackIfReady();
    }
コード例 #11
0
    void SetData(uint32 uiType, uint32 uiData)
    {
        debug_log("DS: Instance Black Temple: SetData received for type %u with data %u",uiType,uiData);

        switch(uiType)
        {
            case TYPE_NAJENTUS:
                m_auiEncounter[0] = uiData;
                if (uiData == DONE)
                    DoUseDoorOrButton(m_uiNajentusGateGUID);
                break;
            case TYPE_SUPREMUS:
                m_auiEncounter[1] = uiData;
                if (uiData == DONE)
                    DoUseDoorOrButton(m_uiMainTempleDoorsGUID);
                break;
            case TYPE_SHADE:
                m_auiEncounter[2] = uiData;
                if (uiData == DONE && CanPreMotherDoorOpen())
                    DoUseDoorOrButton(m_uiShahrazPreDoorGUID);
                break;
            case TYPE_GOREFIEND:
                m_auiEncounter[3] = uiData;
                if (uiData == DONE && CanPreMotherDoorOpen())
                    DoUseDoorOrButton(m_uiShahrazPreDoorGUID);
                break;
            case TYPE_BLOODBOIL:
                m_auiEncounter[4] = uiData;
                if (uiData == DONE && CanPreMotherDoorOpen())
                    DoUseDoorOrButton(m_uiShahrazPreDoorGUID);
                break;
            case TYPE_RELIQUIARY:
                m_auiEncounter[5] = uiData;
                if (uiData == DONE && CanPreMotherDoorOpen())
                    DoUseDoorOrButton(m_uiShahrazPreDoorGUID);
                break;
            case TYPE_SHAHRAZ:
                if (uiData == DONE)
                {
                    DoUseDoorOrButton(m_uiCouncilDoorGUID);
                    DoUseDoorOrButton(m_uiShahrazPostDoorGUID);
                }
                m_auiEncounter[6] = uiData;
                break;
            case TYPE_COUNCIL:    m_auiEncounter[7] = uiData; break;
            case TYPE_ILLIDAN:    m_auiEncounter[8] = uiData; break;
            default:
                error_log("DS: Instance Black Temple: ERROR SetData = %u for type %u does not exist/not implemented.",uiType,uiData);
                break;
        }

        if (uiData == DONE)
        {
            OUT_SAVE_INST_DATA;

            std::ostringstream saveStream;
            saveStream << m_auiEncounter[0] << " " << m_auiEncounter[1] << " " << m_auiEncounter[2] << " "
                << m_auiEncounter[3] << " " << m_auiEncounter[4] << " " << m_auiEncounter[5] << " "
                << m_auiEncounter[6] << " " << m_auiEncounter[7] << " " << m_auiEncounter[8];

            strInstData = saveStream.str();

            SaveToDB();
            OUT_SAVE_INST_DATA_COMPLETE;
        }
    }
コード例 #12
0
ファイル: miner_api.cpp プロジェクト: doveman/akbash
void fetchASCStats(int gpu, PGA_Stats * stats)
{
	char command[256] = {0};
	char buf[RECVSIZE+1] = {0};

	sprintf_s(command, sizeof(command), "{ \"command\" : \"asc\" , \"parameter\" : \"%d\" }", gpu);

	if (sendCommand(command, buf, sizeof(buf)) == 1)
	{
		parsePGAStats(buf, stats);
		stats->id = gpu;
	}
} // end of fetchASCStats()

void parseMinerConfig(char * buf, Miner_Config * minerCfg)
{
	char temp[256] = {0};
	char * ptr = NULL;
	char * ptrEnd = NULL;

	memset(minerCfg, 0, sizeof(Miner_Config));

	//debug_log( LOG_SVR, "parseMinerConfig(): buf: %s", buf);

	ptr = strstr(buf,"\"ASC Count\":");
	if (ptr != NULL)
	{
		ptr += 12;

		ptrEnd = strstr(ptr, ",");

		if (ptrEnd != NULL)
		{
			memset(temp, 0, sizeof(temp));
			strncpy_s(temp, sizeof(temp), ptr, ptrEnd-ptr);
			minerCfg->ascCount = atoi(temp);

			//debug_log( LOG_SVR, "parseMinerConfig(): ASC count, minerCfg->ascCount: %d", minerCfg->ascCount);

			if (minerCfg->ascCount > MAX_ASC_DEVICES)
			{
				debug_log( LOG_SVR, 
							"parseMinerConfig(): number of ASICs defined in miner (%d) is greater than %d ASICs supported by akbash, only the first %d ASICs will be monitored.",
							minerCfg->ascCount,
							MAX_ASC_DEVICES,
							MAX_ASC_DEVICES
							);
				minerCfg->ascCount = MAX_ASC_DEVICES;
			}
		}
	}

	ptr = strstr(buf,"\"PGA Count\":");
	if (ptr != NULL)
	{
		ptr += 12;

		ptrEnd = strstr(ptr, ",");

		if (ptrEnd != NULL)
		{
			memset(temp, 0, sizeof(temp));
			strncpy_s(temp, sizeof(temp), ptr, ptrEnd-ptr);
			minerCfg->pgaCount = atoi(temp);
			
			//debug_log( LOG_SVR, "parseMinerConfig(): PGA count, minerCfg->pgaCount: %d", minerCfg->pgaCount);

			if (minerCfg->pgaCount > MAX_PGA_DEVICES)
			{
				debug_log( LOG_SVR, 
							"parseMinerConfig(): number of PGAs defined in cgminer (%d) is greater than %d PGAs supported by akbash, only the first %d PGAs will be monitored.",
							minerCfg->pgaCount,
							MAX_PGA_DEVICES,
							MAX_PGA_DEVICES
							);
				minerCfg->pgaCount = MAX_PGA_DEVICES;
			}
		}
	}

	ptr = strstr(buf,"\"GPU Count\":");
	if (ptr != NULL)
	{
		ptr += 12;

		ptrEnd = strstr(ptr, ",");

		if (ptrEnd != NULL)
		{
			memset(temp, 0, sizeof(temp));
			strncpy_s(temp, sizeof(temp), ptr, ptrEnd-ptr);
			minerCfg->gpuCount = atoi(temp);

			if (minerCfg->gpuCount > MAX_GPU_DEVICES)
			{
				debug_log( LOG_SVR, 
							"parseMinerConfig(): number of gpus defined in cgminer (%d) is greater than %d gpus supported by akbash, only the first %d gpus will be monitored.",
							minerCfg->gpuCount,
							MAX_GPU_DEVICES,
							MAX_GPU_DEVICES
							);
				minerCfg->gpuCount = MAX_GPU_DEVICES;
			}
		}
	}

	ptr = strstr(buf,"\"Pool Count\":");
	if (ptr != NULL)
	{
		ptr += 13;

		ptrEnd = strstr(ptr, ",");

		if (ptrEnd != NULL)
		{
			memset(temp, 0, sizeof(temp));
コード例 #13
0
ファイル: miner_api.cpp プロジェクト: doveman/akbash
void displayMinerInfoObject(Miner_Info * mi)
{
	int i = 0;

	debug_log( LOG_DBG, "displayMinerInfoObject(): status: %s, gpus: %d, pgas: %d, asics: %d a: %d, gw: %d, avg: %0.2f, hw: %d, since: %s, u: %0.2f, ver: %s, days: %d, hrs: %d, min: %d, secs: %d, found blocks: %d",
		       gpuStatusStr(mi->status),
			   mi->config.gpuCount,
			   mi->config.pgaCount,
			   mi->config.ascCount,
			   mi->summary.accepted,
			   mi->summary.getworks,
			   mi->summary.mhsAvg,
			   mi->summary.hw,
			   mi->summary.startedOn,
			   mi->summary.util,
			   mi->summary.version,
			   mi->summary.days,
			   mi->summary.hrs,
			   mi->summary.min,
			   mi->summary.secs,
			   mi->summary.foundBlocks
		     );

	for (i=0; i < mi->config.gpuCount; i++)	
		debug_log( LOG_DBG, "displayMinerInfoObject(): gpu %d, disabled: %s, status: %s, avg: %0.2f, %d/%d, %0.2fC@%d%% hw: %d, v: %0.2f, u: %0.2f",
		           mi->gpu[i].id,
				   mi->gpu[i].disabled ? "Y" : "N",
		           gpuStatusStr(mi->gpu[i].status),
				   mi->gpu[i].avg,
				   mi->gpu[i].engine,
				   mi->gpu[i].mem,
				   mi->gpu[i].temp,
				   mi->gpu[i].fan,
				   mi->gpu[i].hw,
				   mi->gpu[i].volt,
				   mi->gpu[i].util
		         );

	for (i=0; i < mi->config.pgaCount; i++)	
		debug_log( LOG_DBG, "displayMinerInfoObject(): pga %d, disabled: %s, status: %s, avg: %0.2f, %0.2fC hw: %d, u: %0.2f",
		           mi->pga[i].id,
				   mi->pga[i].disabled ? "Y" : "N",
		           gpuStatusStr(mi->pga[i].status),
				   mi->pga[i].avg,
				   mi->pga[i].temp,
				   mi->pga[i].hw,
				   mi->pga[i].util
		         );

	for (i=0; i < mi->config.ascCount; i++)	
		debug_log( LOG_DBG, "displayMinerInfoObject(): asc %d, disabled: %s, status: %s, avg: %0.2f, %0.2fC hw: %d, u: %0.2f",
		           mi->asc[i].id,
				   mi->asc[i].disabled ? "Y" : "N",
		           gpuStatusStr(mi->asc[i].status),
				   mi->asc[i].avg,
				   mi->asc[i].temp,
				   mi->asc[i].hw,
				   mi->asc[i].util
		         );

	for (i=0; i < mi->config.poolCount; i++)	
		debug_log( LOG_DBG, "displayMinerInfoObject(): pool %d, url: %s status: %s",
		           mi->pools[i].id,
		           mi->pools[i].url,
		           mi->pools[i].status
		         );

} // end of displayMinerInfoObject()
コード例 #14
0
ファイル: miner_api.cpp プロジェクト: doveman/akbash
void fetchGPUSummary(GPU_Summary * sum)
{
	char command[256] = {0};
	char buf[RECVSIZE+1] = {0};

	strcpy_s(command, sizeof(command), "{ \"command\" : \"summary\" }");

	if (sendCommand(command, buf, sizeof(buf)) == 1)
	{
		parseGPUSummary(buf, sum);
	}

} // end of fetchGPUSummary()

void fetchMinerInfo(Miner_Info * mi, CGMConfig * cfg)
{
	int i = 0;
	double maxTemp = 0;
	char diffStr[128];
	double difficulty = 0;

	resetMinerInfoObject(mi);	

	// ------------------------
	// Get miner configuration.
	// ------------------------
	fetchMinerConfig(&(mi->config));

	debug_log( LOG_DBG, "fetchMinerInfo(): gpu count: %d, pga count: %d, asic count: %d", mi->config.gpuCount, mi->config.pgaCount, mi->config.ascCount);
	
	// ------------------
	// Get miner summary.
	// ------------------
	fetchGPUSummary(&(mi->summary));

	if (mi->config.gpuCount > 0 || mi->config.pgaCount > 0 || mi->config.ascCount > 0)
		mi->status = ALIVE;


	// --------------
	// Get GPU Stats.
	// --------------
	for(i=0; i < mi->config.gpuCount; i++)
	{
		// -------------
		// Get GPU stat.
		// -------------
		fetchGPUStats(i, &(mi->gpu[i]));
		if (mi->gpu[i].temp > maxTemp)
			maxTemp = mi->gpu[i].temp;

		if (mi->gpu[i].disabled)
		{
			mi->summary.mhsAvg -= mi->gpu[i].avg;
			mi->summary.util -= mi->gpu[i].util;
			mi->gpu[i].avg = 0.0;
			mi->gpu[i].util = 0.0;
		}

		if (mi->gpu[i].status != ALIVE)
		{
			mi->status = mi->gpu[i].status;
			debug_log( LOG_INF, "fetchMinerInfo(): gpu %d: status: %s, setting miner status to: %s", 
				        i,
					    gpuStatusStr(mi->gpu[i].status), 
						gpuStatusStr(mi->status)       
					 );
		}
	}	

	// --------------
	// Get PGA Stats.
	// --------------
	for(i=0; i < mi->config.pgaCount; i++)
	{
		// -------------
		// Get PGA stat.
		// -------------
		fetchPGAStats(i, &(mi->pga[i]));

		if (mi->pga[i].temp > maxTemp)
			maxTemp = mi->pga[i].temp;

		if (mi->pga[i].status != ALIVE)
		{
			mi->status = mi->pga[i].status;
			debug_log( LOG_INF, "fetchMinerInfo(): pga %d: status: %s, setting miner status to: %s", 
				       i,
					   gpuStatusStr(mi->pga[i].status), 
					   gpuStatusStr(mi->status)       
					 );
		}
	}

	// --------------
	// Get ASC Stats.
	// --------------
	for(i=0; i < mi->config.ascCount; i++)
	{
		// -------------
		// Get ASC stat.
		// -------------
		fetchASCStats(i, &(mi->asc[i]));

		if (mi->asc[i].temp > maxTemp)
			maxTemp = mi->asc[i].temp;

		if (mi->asc[i].status != ALIVE)
		{
			mi->status = mi->asc[i].status;
			debug_log( LOG_INF, "fetchMinerInfo(): asc %d: status: %s, setting miner status to: %s", 
				       i,
					   gpuStatusStr(mi->asc[i].status), 
					   gpuStatusStr(mi->status)       
					 );
		}
	}

	mi->summary.maxTemp = maxTemp;

	// --------------
	// Get POOL Stats.
	// --------------
	fetchPoolStats(mi);

	// get target difficulty
	memset(diffStr, 0, sizeof(diffStr));

	net_get_url(cfg->minerTargetDifficultyUrl, diffStr, sizeof(diffStr));
			
コード例 #15
0
ファイル: escort_ai.cpp プロジェクト: bobazrh/Bobaz-RH
void npc_escortAI::UpdateAI(const uint32 uiDiff)
{
    //Waypoint Updating
    if (HasEscortState(STATE_ESCORT_ESCORTING) && !m_creature->getVictim() && m_uiWPWaitTimer && !HasEscortState(STATE_ESCORT_RETURNING))
    {
        if (m_uiWPWaitTimer <= uiDiff)
        {
            //End of the line
            if (CurrentWP == WaypointList.end())
            {
                debug_log("SD2: EscortAI reached end of waypoints");

                if (m_bCanReturnToStart)
                {
                    float fRetX, fRetY, fRetZ;
                    m_creature->GetRespawnCoord(fRetX, fRetY, fRetZ);

                    m_creature->GetMotionMaster()->MovePoint(POINT_HOME, fRetX, fRetY, fRetZ);

                    m_uiWPWaitTimer = 0;

                    debug_log("SD2: EscortAI are returning home to spawn location: %u, %f, %f, %f", POINT_HOME, fRetX, fRetY, fRetZ);
                    return;
                }

                if (m_bCanInstantRespawn)
                {
                    m_creature->setDeathState(JUST_DIED);
                    m_creature->Respawn();
                }
                else
                    m_creature->ForcedDespawn();

                return;
            }

            if (!HasEscortState(STATE_ESCORT_PAUSED))
            {
                m_creature->GetMotionMaster()->MovePoint(CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z);
                debug_log("SD2: EscortAI start waypoint %u (%f, %f, %f).", CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z);

                WaypointStart(CurrentWP->id);

                m_uiWPWaitTimer = 0;
            }
        }
        else
            m_uiWPWaitTimer -= uiDiff;
    }

    //Check if player or any member of his group is within range
    if (HasEscortState(STATE_ESCORT_ESCORTING) && m_uiPlayerGUID && !m_creature->getVictim() && !HasEscortState(STATE_ESCORT_RETURNING))
    {
        if (m_uiPlayerCheckTimer < uiDiff)
        {
            if (!IsPlayerOrGroupInRange())
            {
                debug_log("SD2: EscortAI failed because player/group was to far away or not found");

                if (m_bCanInstantRespawn)
                {
                    m_creature->setDeathState(JUST_DIED);
                    m_creature->Respawn();
                }
                else
                    m_creature->ForcedDespawn();

                return;
            }

            m_uiPlayerCheckTimer = 1000;
        }
        else
            m_uiPlayerCheckTimer -= uiDiff;
    }

    UpdateEscortAI(uiDiff);
}
コード例 #16
0
void instance_zulaman::SetData(uint32 uiType, uint32 uiData)
{
    debug_log("SD2: Instance Zulaman: SetData received for type %u with data %u",uiType,uiData);

    switch (uiType)
    {
        case TYPE_EVENT_RUN:
            if (uiData == SPECIAL)
            {
                ++m_uiGongCount;
                if (m_uiGongCount == 5)
                    m_auiEncounter[TYPE_EVENT_RUN] = uiData;
                return;
            }
            if (uiData == IN_PROGRESS)
            {
                DoTimeRunSay(RUN_START);
                DoUseDoorOrButton(GO_MASSIVE_GATE);
                if (m_auiEncounter[TYPE_RUN_EVENT_TIME])
                    SetData(TYPE_RUN_EVENT_TIME, m_auiEncounter[TYPE_RUN_EVENT_TIME]);
                else
                    SetData(TYPE_RUN_EVENT_TIME, 60);   // 20 Minutes as default time
                DoUpdateWorldState(WORLD_STATE_ID, 1);
            }
            if (uiData == FAIL)
            {
                DoTimeRunSay(RUN_FAIL);
                DoUpdateWorldState(WORLD_STATE_ID, 0);
                // Kill remaining Event NPCs
                for (uint8 i = 0; i < MAX_CHESTS; ++i)
                {
                    // Not yet rescued, so too late
                    if (!m_aEventNpcInfo[i].uiSavePosition)
                    {
                        if (Creature* pCreature = instance->GetCreature(m_aEventNpcInfo[i].npGuid))
                            pCreature->ForcedDespawn();
                    }
                }
            }
            if (uiData == DONE)
            {
                DoTimeRunSay(RUN_DONE);
                DoUpdateWorldState(WORLD_STATE_ID, 0);
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_AKILZON:
            DoUseDoorOrButton(GO_WIND_DOOR);
            if (uiData == DONE)
            {
                if (m_auiEncounter[TYPE_EVENT_RUN] == IN_PROGRESS)
                {
                    m_auiEncounter[TYPE_RUN_EVENT_TIME] += 10; // Add 10 minutes
                    SetData(TYPE_RUN_EVENT_TIME, m_auiEncounter[TYPE_RUN_EVENT_TIME]);
                    DoChestEvent(INDEX_AKILZON);
                }
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_NALORAKK:
            if (uiData == DONE)
            {
                if (m_auiEncounter[TYPE_EVENT_RUN] == IN_PROGRESS)
                {
                    m_auiEncounter[TYPE_RUN_EVENT_TIME] += 15; // Add 15 minutes
                    SetData(TYPE_RUN_EVENT_TIME, m_auiEncounter[TYPE_RUN_EVENT_TIME]);
                    DoChestEvent(INDEX_NALORAKK);
                }
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_JANALAI:
            if (uiData == DONE)
            {
                if (m_auiEncounter[TYPE_EVENT_RUN] == IN_PROGRESS)
                    DoChestEvent(INDEX_JANALAI);
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_HALAZZI:
            DoUseDoorOrButton(GO_LYNX_TEMPLE_ENTRANCE);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_LYNX_TEMPLE_EXIT);
                if (m_auiEncounter[TYPE_EVENT_RUN] == IN_PROGRESS)
                    DoChestEvent(INDEX_HALAZZI);
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_MALACRASS:
            DoUseDoorOrButton(GO_HEXLORD_ENTRANCE);
            if (uiData == DONE)
                DoUseDoorOrButton(GO_WOODEN_DOOR);
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_ZULJIN:
            DoUseDoorOrButton(GO_FIRE_DOOR);
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_RUN_EVENT_TIME:
            m_auiEncounter[uiType] = uiData;
            DoUpdateWorldState(WORLD_STATE_COUNTER, m_auiEncounter[uiType]);
            break;

        case TYPE_RAND_VENDOR_1:
            m_auiRandVendor[0] = uiData;
            break;
        case TYPE_RAND_VENDOR_2:
            m_auiRandVendor[1] = uiData;
            break;

        default:
            error_log("SD2: Instance Zulaman: ERROR SetData = %u for type %u does not exist/not implemented.", uiType, uiData);
            return;
    }

    if (uiData == DONE && GetKilledPreBosses() == 4 && (uiType == TYPE_AKILZON || uiType == TYPE_NALORAKK || uiType == TYPE_JANALAI || uiType == TYPE_HALAZZI))
    {
        DoUseDoorOrButton(GO_HEXLORD_ENTRANCE);
        if (m_auiEncounter[TYPE_EVENT_RUN] == IN_PROGRESS)
            SetData(TYPE_EVENT_RUN, DONE);
    }

    if (uiData == DONE || uiType == TYPE_RUN_EVENT_TIME || uiType == TYPE_EVENT_RUN)
    {
        OUT_SAVE_INST_DATA;

        std::ostringstream saveStream;
        saveStream << m_auiEncounter[0] << " " << m_auiEncounter[1] << " " << m_auiEncounter[2] << " "
            << m_auiEncounter[3] << " " << m_auiEncounter[4] << " " << m_auiEncounter[5] << " "
            << m_auiEncounter[6] << " " << m_auiEncounter[7];

        m_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
コード例 #17
0
void instance_stratholme::SetData(uint32 uiType, uint32 uiData)
{
    // TODO: Remove the hard-coded indexes from array accessing
    switch (uiType)
    {
        case TYPE_BARON_RUN:
            switch (uiData)
            {
                case IN_PROGRESS:
                    if (m_auiEncounter[uiType] == IN_PROGRESS || m_auiEncounter[uiType] == FAIL)
                        break;

                    DoOrSimulateScriptTextForThisInstance(SAY_ANNOUNCE_RUN_START, NPC_BARON);

                    m_uiBaronRunTimer = 45 * MINUTE * IN_MILLISECONDS;
                    debug_log("SD2: Instance Stratholme: Baron run in progress.");
                    break;
                case FAIL:
                    // may add code to remove aura from players, but in theory the time should be up already and removed.
                    break;
                case DONE:
                    m_uiBaronRunTimer = 0;
                    break;
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_BARONESS:
        case TYPE_NERUB:
        case TYPE_PALLID:
            m_auiEncounter[uiType] = uiData;
            if (uiData == DONE)
            {
                DoSortZiggurats();
                DoUseDoorOrButton(m_zigguratStorage[uiType - TYPE_BARONESS].m_doorGuid);
            }
            if (uiData == SPECIAL)
                StartSlaugtherSquare();
            break;
        case TYPE_RAMSTEIN:
            if (uiData == SPECIAL)
            {
                if (m_auiEncounter[uiType] != SPECIAL && m_auiEncounter[uiType] != DONE)
                {
                    m_uiSlaugtherSquareTimer = 20000;       // TODO - unknown, also possible that this is not the very correct place..
                    DoUseDoorOrButton(GO_PORT_GAUNTLET);
                }

                uint32 uiCount = m_sAbomnationGUID.size();
                for (GuidSet::iterator itr = m_sAbomnationGUID.begin(); itr != m_sAbomnationGUID.end();)
                {
                    if (Creature* pAbom = instance->GetCreature(*itr))
                    {
                        ++itr;
                        if (!pAbom->IsAlive())
                            --uiCount;
                    }
                    else
                    {
                        // Remove obsolete guid from set and decrement count
                        m_sAbomnationGUID.erase(itr++);
                        --uiCount;
                    }
                }

                if (!uiCount)
                {
                    // Old Comment: a bit itchy, it should close GO_ZIGGURAT_DOOR_4 door after 10 secs, but it doesn't. skipping it for now.
                    // However looks like that this door is no more closed
                    DoUseDoorOrButton(GO_ZIGGURAT_DOOR_4);

                    // No more handlng of Abomnations
                    m_uiSlaugtherSquareTimer = 0;

                    if (Creature* pBaron = GetSingleCreatureFromStorage(NPC_BARON))
                    {
                        DoScriptText(SAY_ANNOUNCE_RAMSTEIN, pBaron);
                        if (Creature* pRamstein = pBaron->SummonCreature(NPC_RAMSTEIN, aStratholmeLocation[2].m_fX, aStratholmeLocation[2].m_fY, aStratholmeLocation[2].m_fZ, aStratholmeLocation[2].m_fO, TEMPSUMMON_DEAD_DESPAWN, 0))
                            pRamstein->GetMotionMaster()->MovePoint(0, aStratholmeLocation[3].m_fX, aStratholmeLocation[3].m_fY, aStratholmeLocation[3].m_fZ);

                        debug_log("SD2: Instance Stratholme - Slaugther event: Ramstein spawned.");
                    }
                }
                else
                    debug_log("SD2: Instance Stratholme - Slaugther event: %u Abomnation left to kill.", uiCount);
            }
            // After fail aggroing Ramstein means wipe on Ramstein, so close door again
            if (uiData == IN_PROGRESS && m_auiEncounter[uiType] == FAIL)
                DoUseDoorOrButton(GO_PORT_GAUNTLET);
            if (uiData == DONE)
            {
                // Open side gate and start summoning skeletons
                DoUseDoorOrButton(GO_PORT_SLAUGHTER_GATE);
                // use this timer as a bool just to start summoning
                m_uiMindlessSummonTimer = 500;
                m_uiMindlessCount = 0;
                m_luiUndeadGUIDs.clear();

                // Summon 5 guards
                if (Creature* pBaron = GetSingleCreatureFromStorage(NPC_BARON))
                {
                    for (uint8 i = 0; i < 5; ++i)
                    {
                        float fX, fY, fZ;
                        pBaron->GetRandomPoint(aStratholmeLocation[6].m_fX, aStratholmeLocation[6].m_fY, aStratholmeLocation[6].m_fZ, 5.0f, fX, fY, fZ);
                        if (Creature* pTemp = pBaron->SummonCreature(NPC_BLACK_GUARD, aStratholmeLocation[6].m_fX, aStratholmeLocation[6].m_fY, aStratholmeLocation[6].m_fZ, aStratholmeLocation[6].m_fO, TEMPSUMMON_DEAD_DESPAWN, 0))
                            m_luiGuardGUIDs.push_back(pTemp->GetObjectGuid());
                    }

                    debug_log("SD2: Instance Stratholme - Slaugther event: Summoned 5 guards.");
                }
            }
            // Open Door again and stop Abomnation
            if (uiData == FAIL && m_auiEncounter[uiType] != FAIL)
            {
                DoUseDoorOrButton(GO_PORT_GAUNTLET);
                m_uiSlaugtherSquareTimer = 0;

                // Let already moving Abomnations stop
                for (GuidSet::const_iterator itr = m_sAbomnationGUID.begin(); itr != m_sAbomnationGUID.end(); ++itr)
                {
                    Creature* pAbom = instance->GetCreature(*itr);
                    if (pAbom && pAbom->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE)
                        pAbom->GetMotionMaster()->MovementExpired();
                }
            }

            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_BARON:
            if (uiData == IN_PROGRESS)
            {
                // Reached the Baron within time-limit
                if (m_auiEncounter[TYPE_BARON_RUN] == IN_PROGRESS)
                    SetData(TYPE_BARON_RUN, DONE);

                // Close Slaughterhouse door if needed
                if (m_auiEncounter[uiType] == FAIL)
                    DoUseDoorOrButton(GO_PORT_GAUNTLET);
            }
            if (uiData == DONE)
            {
                if (m_auiEncounter[TYPE_BARON_RUN] == DONE)
                {
                    Map::PlayerList const& players = instance->GetPlayers();

                    for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                    {
                        if (Player* pPlayer = itr->getSource())
                        {
                            if (pPlayer->HasAura(SPELL_BARON_ULTIMATUM))
                                pPlayer->RemoveAurasDueToSpell(SPELL_BARON_ULTIMATUM);

                            if (pPlayer->GetQuestStatus(QUEST_DEAD_MAN_PLEA) == QUEST_STATUS_INCOMPLETE)
                                pPlayer->AreaExploredOrEventHappens(QUEST_DEAD_MAN_PLEA);
                        }
                    }

                    // Open cage and finish rescue event
                    if (Creature* pYsidaT = GetSingleCreatureFromStorage(NPC_YSIDA_TRIGGER))
                    {
                        if (Creature* pYsida = pYsidaT->SummonCreature(NPC_YSIDA, pYsidaT->GetPositionX(), pYsidaT->GetPositionY(), pYsidaT->GetPositionZ(), pYsidaT->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN, 1800000))
                        {
                            DoScriptText(SAY_EPILOGUE, pYsida);
                            pYsida->GetMotionMaster()->MovePoint(0, aStratholmeLocation[7].m_fX, aStratholmeLocation[7].m_fY, aStratholmeLocation[7].m_fZ);
                        }
                        DoUseDoorOrButton(GO_YSIDA_CAGE);
                    }
                }

                // Open Slaughterhouse door again
                DoUseDoorOrButton(GO_PORT_GAUNTLET);
            }
            if (uiData == FAIL)
                DoUseDoorOrButton(GO_PORT_GAUNTLET);

            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_BARTHILAS_RUN:
            if (uiData == IN_PROGRESS)
            {
                Creature* pBarthilas = GetSingleCreatureFromStorage(NPC_BARTHILAS);
                if (pBarthilas && pBarthilas->IsAlive() && !pBarthilas->IsInCombat())
                {
                    DoScriptText(SAY_WARN_BARON, pBarthilas);
                    pBarthilas->SetWalk(false);
                    pBarthilas->GetMotionMaster()->MovePoint(0, aStratholmeLocation[0].m_fX, aStratholmeLocation[0].m_fY, aStratholmeLocation[0].m_fZ);

                    m_uiBarthilasRunTimer = 8000;
                }
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_BLACK_GUARDS:
            // Prevent double action
            if (m_auiEncounter[uiType] == uiData)
                return;

            // Restart after failure, close Gauntlet
            if (uiData == IN_PROGRESS && m_auiEncounter[uiType] == FAIL)
                DoUseDoorOrButton(GO_PORT_GAUNTLET);
            // Wipe case - open gauntlet
            if (uiData == FAIL)
                DoUseDoorOrButton(GO_PORT_GAUNTLET);
            if (uiData == DONE)
            {
                if (Creature* pBaron = GetSingleCreatureFromStorage(NPC_BARON))
                    DoScriptText(SAY_UNDEAD_DEFEAT, pBaron);
                DoUseDoorOrButton(GO_ZIGGURAT_DOOR_5);
            }
            m_auiEncounter[uiType] = uiData;

            // No need to save anything here, so return
            return;
        case TYPE_POSTMASTER:
            m_auiEncounter[uiType] = uiData;
            if (uiData == IN_PROGRESS)
            {
                ++m_uiPostboxesUsed;

                // After the second post box prepare to spawn the Post Master
                if (m_uiPostboxesUsed == 2)
                    SetData(TYPE_POSTMASTER, SPECIAL);
            }
            // No need to save anything here, so return
            return;
        case TYPE_TRUE_MASTERS:
            m_auiEncounter[uiType] = uiData;
            if (uiData == SPECIAL)
            {
                ++m_uiSilverHandKilled;

                // When the 5th paladin is killed set data to DONE in order to give the quest credit for the last paladin
                if (m_uiSilverHandKilled == MAX_SILVERHAND)
                    SetData(TYPE_TRUE_MASTERS, DONE);
            }
            // No need to save anything here, so return
            return;
    }

    if (uiData == DONE)
    {
        OUT_SAVE_INST_DATA;

        std::ostringstream saveStream;
        saveStream << m_auiEncounter[0] << " " << m_auiEncounter[1] << " " << m_auiEncounter[2] << " "
                   << m_auiEncounter[3] << " " << m_auiEncounter[4] << " " << m_auiEncounter[5] << " " << m_auiEncounter[6];

        m_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
コード例 #18
0
ファイル: fx_pack.c プロジェクト: Comanche93/eech
void pack_fixed_data (entity *en, fixed *raw, pack_modes mode)
{
	ASSERT ((mode >= 0) && (mode < NUM_PACK_MODES));

	switch (mode)
	{
		////////////////////////////////////////
		case PACK_MODE_SERVER_SESSION:
		case PACK_MODE_CLIENT_SESSION:
		////////////////////////////////////////
		{
			pack_vec3d (en, VEC3D_TYPE_POSITION, &raw->position);

			/////////////////////////////////////////////////////////////////
			if (mode == PACK_MODE_SERVER_SESSION)
			{

				if (raw->task_dependent_root.first_child)
				{

					pack_int_value (en, INT_TYPE_VALID, TRUE);

					pack_list_root (en, LIST_TYPE_TASK_DEPENDENT, &raw->task_dependent_root);
				}
				else
				{

					pack_int_value (en, INT_TYPE_VALID, FALSE);
				}
			}
			/////////////////////////////////////////////////////////////////

			/////////////////////////////////////////////////////////////////
			if (raw->target_root.first_child)
			{

				pack_int_value (en, INT_TYPE_VALID, TRUE);

				pack_list_root (en, LIST_TYPE_TARGET, &raw->target_root);
			}
			else
			{

				pack_int_value (en, INT_TYPE_VALID, FALSE);
			}
			/////////////////////////////////////////////////////////////////

			// gunship_target_link

			// sector_link

			pack_int_value (en, INT_TYPE_ENTITY_SUB_TYPE, raw->sub_type);

			pack_int_value (en, INT_TYPE_OBJECT_3D_SHAPE, raw->object_3d_shape);

			pack_int_value (en, INT_TYPE_ALIVE, raw->alive);

			pack_int_value (en, INT_TYPE_SIDE, raw->side);

			// gunship_radar_los_clear

			// object_drawn_once_this_frame

			pack_float_value (en, FLOAT_TYPE_HEADING, raw->heading);

			if (raw->heading == 0.0)
			{

				debug_log ("FX_PACK: heading = zero");
			}

			break;
		}
		////////////////////////////////////////
		case PACK_MODE_BROWSE_SESSION:
		////////////////////////////////////////
		{
			break;
		}
		////////////////////////////////////////
		case PACK_MODE_UPDATE_ENTITY:
		////////////////////////////////////////
		{
			//
			// cannot update entity at this level as the update may not apply to all entity types below
			//

			break;
		}
	}
}
コード例 #19
0
void instance_gundrak::SetData(uint32 uiType, uint32 uiData)
{
    debug_log("SD2: Instance Gundrak: SetData received for type %u with data %u", uiType, uiData);

    switch(uiType)
    {
        case TYPE_SLADRAN:
            m_auiEncounter[TYPE_SLADRAN] = uiData;
            if (uiData == DONE)
                if (GameObject* pGo = GetSingleGameObjectFromStorage(GO_ALTAR_OF_SLADRAN))
                    pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT);
            if (uiData == FAIL)
                m_uisWhySnakesAchievPlayers.clear();
            if (uiData == SPECIAL)
            {
                m_mAltarInProgress.insert(TypeTimerPair(TYPE_SLADRAN, TIMER_VISUAL_ALTAR));
                m_uiBridgeCounter++;
            }
            break;
        case TYPE_MOORABI:
            m_auiEncounter[TYPE_MOORABI] = uiData;
            if (uiData == DONE)
            {
                if (!instance->IsRegularDifficulty())
                    DoUseDoorOrButton(GO_ECK_DOOR);
                if (GameObject* pGo = GetSingleGameObjectFromStorage(GO_ALTAR_OF_MOORABI))
                    pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT);
            }
            if (uiData == IN_PROGRESS)
                SetLessRabiAchievementCriteria(true);
            if (uiData == SPECIAL)
            {
                m_mAltarInProgress.insert(TypeTimerPair(TYPE_MOORABI, TIMER_VISUAL_ALTAR));
                m_uiBridgeCounter++;
            }
            break;
        case TYPE_COLOSSUS:
            m_auiEncounter[TYPE_COLOSSUS] = uiData;
            if (uiData == DONE)
                if (GameObject* pGo = GetSingleGameObjectFromStorage(GO_ALTAR_OF_COLOSSUS))
                    pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT);
            if (uiData == FAIL)
            {
                for (GuidSet::const_iterator itr = m_sColossusMojosGuids.begin(); itr != m_sColossusMojosGuids.end(); ++itr)
                {
                    if (Creature* pMojo = instance->GetCreature(*itr))
                    {
                        pMojo->Respawn();
                        pMojo->GetMotionMaster()->MoveTargetedHome();
                    }
                }
            }
            if (uiData == SPECIAL)
            {
                m_mAltarInProgress.insert(TypeTimerPair(TYPE_COLOSSUS, TIMER_VISUAL_ALTAR));
                m_uiBridgeCounter++;
            }
            break;
        case TYPE_GALDARAH:
            m_auiEncounter[TYPE_GALDARAH] = uiData;
            DoUseDoorOrButton(GO_GALDARAH_DOOR);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_EXIT_DOOR_L);
                DoUseDoorOrButton(GO_EXIT_DOOR_R);
            }
            if (uiData == FAIL)
                m_uisShareLoveAchievPlayers.clear();
            break;
        case TYPE_ECK:
            m_auiEncounter[TYPE_ECK] = uiData;
            if (uiData == DONE)
                DoUseDoorOrButton(GO_ECK_UNDERWATER_DOOR);
            break;
        case TYPE_ACHIEV_WHY_SNAKES:
            // insert the players who failed the achiev and haven't been already inserted in the set
            if (m_uisWhySnakesAchievPlayers.find(uiData) == m_uisWhySnakesAchievPlayers.end())
                m_uisWhySnakesAchievPlayers.insert(uiData);
            break;
        case TYPE_ACHIEV_SHARE_LOVE:
            // insert players who got stampeled and haven't been already inserted in the set
            if (m_uisShareLoveAchievPlayers.find(uiData) == m_uisShareLoveAchievPlayers.end())
                m_uisShareLoveAchievPlayers.insert(uiData);
            break;
        default:
            error_log("SD2: Instance Gundrak: ERROR SetData = %u for type %u does not exist/not implemented.", uiType, uiData);
            return;
    }

    if (m_uiBridgeCounter == 3 && !m_bGuardSpawnt)
    {
        if (GameObject* pGo = GetSingleGameObjectFromStorage(GO_ALTAR_OF_COLOSSUS))
        {
            if (pGo->SummonCreature(NPC_BRIDGE_GUARD, BRIDGE_GUARD_X, BRIDGE_GUARD_Y, BRIDGE_GUARD_Z, BRIDGE_GUARD_O, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 2000))
                m_bGuardSpawnt = true;
        }
    }

    if (uiData == DONE || uiData == SPECIAL)                // Save activated altars, too
    {
        OUT_SAVE_INST_DATA;

        std::ostringstream saveStream;
        saveStream << m_auiEncounter[TYPE_SLADRAN] << " " << m_auiEncounter[TYPE_MOORABI] << " " << m_auiEncounter[TYPE_COLOSSUS] << " " << m_auiEncounter[TYPE_GALDARAH] << " "
            << m_auiEncounter[TYPE_ECK];

        m_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
コード例 #20
0
ファイル: cg_dstry.c プロジェクト: Comanche93/eech
static void kill_local (entity *en)
{

	entity
		*task,
		*destroy_task;

	cargo
		*raw;

	////////////////////////////////////////
	//
	// PRE-AMBLE
	//
	////////////////////////////////////////

	#if DEBUG_MODULE >= 2

	debug_log_entity_args (ENTITY_DEBUG_LOCAL, ENTITY_DEBUG_KILL, en);

	#endif

	raw = (cargo *) get_local_entity_data (en);

	////////////////////////////////////////
	//
	// VALIDATE
	//
	////////////////////////////////////////

	////////////////////////////////////////
	//
	// KILL
	//
	////////////////////////////////////////

	set_local_entity_int_value (en, INT_TYPE_ALIVE, FALSE);

	////////////////////////////////////////
	//
	// SEND NOTIFY MESSAGES
	//
	////////////////////////////////////////

	if (get_comms_model () == COMMS_MODEL_SERVER)
	{

		task = get_local_entity_first_child (en, LIST_TYPE_TASK_DEPENDENT);

		while (task)
		{

			destroy_task = task;

			task = get_local_entity_child_succ (task, LIST_TYPE_TASK_DEPENDENT);

			if (destroy_task->type == ENTITY_TYPE_TASK)
			{

				#if DEBUG_MODULE

				debug_log ("FW_DSTRY: killing cargo, notifying task %s complete", entity_sub_type_task_names [get_local_entity_int_value (destroy_task, INT_TYPE_ENTITY_SUB_TYPE)]);

				#endif

				notify_local_entity (ENTITY_MESSAGE_TASK_COMPLETED, destroy_task, en, TASK_TERMINATED_OBJECTIVE_MESSAGE);
			}
		}

		////////////////////////////////////////
		//
		// SEND NOTIFY MESSAGES
		//
		////////////////////////////////////////
	}

	////////////////////////////////////////
	//
	// UNLINK FROM SYSTEM
	//
	////////////////////////////////////////

	//
	// cargo
	//

	unlink_local_entity_children (en, LIST_TYPE_TASK_DEPENDENT);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_CARGO);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_MOVEMENT_DEPENDENT);

	// view_link

	//
	// mobile
	//

	unlink_local_entity_children (en, LIST_TYPE_SPECIAL_EFFECT);

	unlink_local_entity_children (en, LIST_TYPE_TARGET);

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_PADLOCK);

	// sector_link

	delete_local_entity_from_parents_child_list (en, LIST_TYPE_TARGET);

	// update_link

	////////////////////////////////////////
	//
	// SPECIAL EFFECTS
	//
	////////////////////////////////////////
}
コード例 #21
0
void hna_local_add(uint8_t *addr)
{
	struct hna_local_entry *hna_local_entry;
	struct hna_global_entry *hna_global_entry;
	struct hashtable_t *swaphash;
	char hna_str[ETH_STR_LEN];
	unsigned long flags;

	spin_lock_irqsave(&hna_local_hash_lock, flags);
	hna_local_entry =
		((struct hna_local_entry *)hash_find(hna_local_hash, addr));
	spin_unlock_irqrestore(&hna_local_hash_lock, flags);

	if (hna_local_entry != NULL) {
		hna_local_entry->last_seen = jiffies;
		return;
	}

	addr_to_string(hna_str, addr);

	/* only announce as many hosts as possible in the batman-packet and
	   space in batman_packet->num_hna That also should give a limit to
	   MAC-flooding. */
	if ((num_hna + 1 > (ETH_DATA_LEN - BAT_PACKET_LEN) / ETH_ALEN) ||
	    (num_hna + 1 > 255)) {
		debug_log(LOG_TYPE_ROUTES, "Can't add new local hna entry (%s): number of local hna entries exceeds packet size \n", hna_str);
		return;
	}

	debug_log(LOG_TYPE_ROUTES, "Creating new local hna entry: %s \n",
		  hna_str);

	hna_local_entry = kmalloc(sizeof(struct hna_local_entry), GFP_ATOMIC);
	if (!hna_local_entry)
		return;

	memcpy(hna_local_entry->addr, addr, ETH_ALEN);
	hna_local_entry->last_seen = jiffies;

	/* the batman interface mac address should never be purged */
	if (compare_orig(addr, soft_device->dev_addr))
		hna_local_entry->never_purge = 1;
	else
		hna_local_entry->never_purge = 0;

	spin_lock_irqsave(&hna_local_hash_lock, flags);

	hash_add(hna_local_hash, hna_local_entry);
	num_hna++;
	atomic_set(&hna_local_changed, 1);

	if (hna_local_hash->elements * 4 > hna_local_hash->size) {
		swaphash = hash_resize(hna_local_hash,
				       hna_local_hash->size * 2);

		if (swaphash == NULL)
			debug_log(LOG_TYPE_CRIT, "Couldn't resize local hna hash table \n");
		else
			hna_local_hash = swaphash;
	}

	spin_unlock_irqrestore(&hna_local_hash_lock, flags);

	/* remove address from global hash if present */
	spin_lock_irqsave(&hna_global_hash_lock, flags);

	hna_global_entry =
		((struct hna_global_entry *)hash_find(hna_global_hash, addr));

	if (hna_global_entry != NULL)
		_hna_global_del_orig(hna_global_entry, "local hna received");

	spin_unlock_irqrestore(&hna_global_hash_lock, flags);
}
コード例 #22
0
void instance_old_hillsbrad::SetData(uint32 uiType, uint32 uiData)
{
    switch (uiType)
    {
    case TYPE_BARREL_DIVERSION:
        m_auiEncounter[uiType] = uiData;
        if (uiData == IN_PROGRESS)
        {
            if (m_uiBarrelCount >= MAX_BARRELS)
                return;

            // Update barrels used and world state
            ++m_uiBarrelCount;
            DoUpdateWorldState(WORLD_STATE_OH, m_uiBarrelCount);

            debug_log("SD2: Instance Old Hillsbrad: go_barrel_old_hillsbrad count %u", m_uiBarrelCount);

            // Set encounter to done, and spawn Liutenant Drake
            if (m_uiBarrelCount == MAX_BARRELS)
            {
                UpdateLodgeQuestCredit();

                if (Player* pPlayer = GetPlayerInMap())
                {
                    pPlayer->SummonCreature(NPC_DRAKE, aDrakeSummonLoc[0], aDrakeSummonLoc[1], aDrakeSummonLoc[2], aDrakeSummonLoc[3], TEMPSUMMON_DEAD_DESPAWN, 0);

                    // set the houses on fire
                    for (GuidList::const_iterator itr = m_lRoaringFlamesList.begin(); itr != m_lRoaringFlamesList.end(); ++itr)
                        DoRespawnGameObject(*itr, 30 * MINUTE);

                    // move the orcs outside the houses
                    float fX, fY, fZ;
                    for (GuidList::const_iterator itr = m_lRightPrisonersList.begin(); itr != m_lRightPrisonersList.end(); ++itr)
                    {
                        if (Creature* pOrc = instance->GetCreature(*itr))
                        {
                            pOrc->GetRandomPoint(afInstanceLoc[0][0], afInstanceLoc[0][1], afInstanceLoc[0][2], 10.0f, fX, fY, fZ);
                            pOrc->SetWalk(false);
                            pOrc->GetMotionMaster()->MovePoint(0, fX, fY, fZ);
                        }
                    }
                    for (GuidList::const_iterator itr = m_lLeftPrisonersList.begin(); itr != m_lLeftPrisonersList.end(); ++itr)
                    {
                        if (Creature* pOrc = instance->GetCreature(*itr))
                        {
                            pOrc->GetRandomPoint(afInstanceLoc[1][0], afInstanceLoc[1][1], afInstanceLoc[1][2], 10.0f, fX, fY, fZ);
                            pOrc->SetWalk(false);
                            pOrc->GetMotionMaster()->MovePoint(0, fX, fY, fZ);
                        }
                    }
                }
                else
                    debug_log("SD2: Instance Old Hillsbrad: SetData (Type: %u Data %u) cannot find any pPlayer.", uiType, uiData);

                SetData(TYPE_BARREL_DIVERSION, DONE);
            }
        }
        break;
    case TYPE_THRALL_EVENT:
        // nothing to do if already done and thrall respawn
        if (GetData(TYPE_THRALL_EVENT) == DONE)
            return;
        m_auiEncounter[uiType] = uiData;
        if (uiData == FAIL)
        {
            // despawn the bosses if necessary
            if (Creature* pSkarloc = GetSingleCreatureFromStorage(NPC_SKARLOC, true))
                pSkarloc->ForcedDespawn();
            if (Creature* pEpoch = GetSingleCreatureFromStorage(NPC_EPOCH, true))
                pEpoch->ForcedDespawn();

            if (m_uiThrallEventCount <= MAX_WIPE_COUNTER)
            {
                ++m_uiThrallEventCount;
                debug_log("SD2: Instance Old Hillsbrad: Thrall event failed %u times.", m_uiThrallEventCount);

                // reset Thrall on timer
                m_uiThrallResetTimer = 30000;
            }
            // If we already respawned Thrall too many times, the event is failed for good
            else if (m_uiThrallEventCount > MAX_WIPE_COUNTER)
                debug_log("SD2: Instance Old Hillsbrad: Thrall event failed %u times. Reset instance required.", m_uiThrallEventCount);
        }
        break;
    case TYPE_DRAKE:
    case TYPE_SKARLOC:
    case TYPE_ESCORT_BARN:
    case TYPE_ESCORT_INN:
    case TYPE_EPOCH:
        m_auiEncounter[uiType] = uiData;
        debug_log("SD2: Instance Old Hillsbrad: Thrall event type %u adjusted to data %u.", uiType, uiData);
        break;
    }

    if (uiData == DONE)
    {
        OUT_SAVE_INST_DATA;

        std::ostringstream saveStream;
        saveStream << m_auiEncounter[0] << " " << m_auiEncounter[1] << " " << m_auiEncounter[2] << " "
                   << m_auiEncounter[3] << " " << m_auiEncounter[4] << " " << m_auiEncounter[5] << " "
                   << m_auiEncounter[6];

        m_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
コード例 #23
0
ファイル: follower_ai.cpp プロジェクト: krullgor/mangos-wotlk
void FollowerAI::UpdateAI(const uint32 diff)
{
    if (HasFollowState(STATE_FOLLOW_INPROGRESS) && !m_creature->getVictim())
    {
        if (m_updateFollowTimer < diff)
        {
            if (HasFollowState(STATE_FOLLOW_COMPLETE) && !HasFollowState(STATE_FOLLOW_POSTEVENT))
            {
                debug_log("SD2: FollowerAI is set completed, despawns.");
                m_creature->ForcedDespawn();
                return;
            }

            bool isMaxRangeExceeded = true;

            if (Player* player = GetLeaderForFollower())
            {
                if (HasFollowState(STATE_FOLLOW_RETURNING))
                {
                    debug_log("SD2: FollowerAI is returning to leader.");

                    RemoveFollowState(STATE_FOLLOW_RETURNING);
                    m_creature->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
                    return;
                }

                if (Group* pGroup = player->GetGroup())
                {
                    for (GroupReference* ref = pGroup->GetFirstMember(); ref != nullptr; ref = ref->next())
                    {
                        Player* member = ref->getSource();

                        if (member && m_creature->IsWithinDistInMap(member, MAX_PLAYER_DISTANCE))
                        {
                            isMaxRangeExceeded = false;
                            break;
                        }
                    }
                }
                else
                {
                    if (m_creature->IsWithinDistInMap(player, MAX_PLAYER_DISTANCE))
                        isMaxRangeExceeded = false;
                }
            }

            if (isMaxRangeExceeded)
            {
                debug_log("SD2: FollowerAI failed because player/group was to far away or not found");
                m_creature->ForcedDespawn();
                return;
            }

            m_updateFollowTimer = 1000;
        }
        else
            m_updateFollowTimer -= diff;
    }

    UpdateFollowerAI(diff);
}
コード例 #24
0
void instance_ahnkahet::SetData(uint32 uiType, uint32 uiData)
{
    debug_log("SD2: Instance Ahn'Kahet: SetData received for type %u with data %u", uiType, uiData);

    switch (uiType)
    {
        case TYPE_NADOX:
            m_auiEncounter[uiType] = uiData;
            if (uiData == IN_PROGRESS)
                m_bRespectElders = true;
            else if (uiData == SPECIAL)
                m_bRespectElders = false;
            else if (uiData == DONE)
            {
                DoToggleGameObjectFlags(GO_ANCIENT_DEVICE_L, GO_FLAG_NO_INTERACT, false);
                DoToggleGameObjectFlags(GO_ANCIENT_DEVICE_R, GO_FLAG_NO_INTERACT, false);
            }
            break;
        case TYPE_TALDARAM:
            if (uiData == SPECIAL)
            {
                ++m_uiDevicesActivated;

                if (m_uiDevicesActivated == 2)
                {
                    m_auiEncounter[uiType] = uiData;
                    DoUseDoorOrButton(GO_VORTEX);

                    // Lower Taldaram
                    if (Creature* pTaldaram = GetSingleCreatureFromStorage(NPC_TALDARAM))
                        pTaldaram->GetMotionMaster()->MovePoint(1, aTaldaramLandingLoc[0], aTaldaramLandingLoc[1], aTaldaramLandingLoc[2]);

                    // Interrupt the channeling
                    for (GuidList::const_iterator itr = m_lJedogaControllersGuidList.begin(); itr != m_lJedogaControllersGuidList.end(); ++itr)
                    {
                        if (Creature* pTemp = instance->GetCreature(*itr))
                            pTemp->InterruptNonMeleeSpells(false);
                    }
                }
            }
            else if (uiData == DONE)
            {
                m_auiEncounter[uiType] = uiData;
                DoUseDoorOrButton(GO_DOOR_TALDARAM);
            }
            break;
        case TYPE_JEDOGA:
            m_auiEncounter[uiType] = uiData;
            if (uiData == IN_PROGRESS)
                m_bVolunteerWork = true;
            else if (uiData == SPECIAL)
                m_bVolunteerWork = false;
            else if (uiData == FAIL)
                m_uiInitiatesKilled = 0;
            break;
        case TYPE_AMANITAR:
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_VOLAZJ:
            m_auiEncounter[uiType] = uiData;
            if (uiData == IN_PROGRESS)
            {
                m_uiTwistedVisageCount = 0;
                m_lInsanityPlayersGuidList.clear();
            }
            break;

        default:
            script_error_log("Instance Ahn'Kahet: ERROR SetData = %u for type %u does not exist/not implemented.", uiType, uiData);
            break;
    }

    // For some encounters Special data needs to be saved
    if (uiData == DONE || (uiData == SPECIAL && uiType == TYPE_TALDARAM))
    {
        OUT_SAVE_INST_DATA;

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

        m_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
コード例 #25
0
ファイル: window_win32.cpp プロジェクト: franko/libcanvas
void window_win32::update_region(graphics::image& src_img, const agg::rect_i& r) {
    debug_log("update_region: %d %d %d %d", r.x1, r.y1, r.x2, r.y2);
    HDC dc = ::GetDC(m_hwnd);
    display_pmap(dc, &src_img, &r);
    ::ReleaseDC(m_hwnd, dc);
}
コード例 #26
0
ファイル: boss_kiljaeden.cpp プロジェクト: LORDofDOOM/MMOTBC
    void UpdateAI(const uint32 diff)
    {
        if (!UpdateVictim())
            return;

        if ((victimClass == 0) && me->getVictim())
        {
            victimClass = me->getVictim()->getClass();
            switch (victimClass)
            {
                case CLASS_DRUID:
                    break;
                case CLASS_HUNTER:
                    break;
                case CLASS_MAGE:
                    break;
                case CLASS_WARLOCK:
                    break;
                case CLASS_WARRIOR:
                    me->SetCanDualWield(true);
                    break;
                case CLASS_PALADIN:
                    break;
                case CLASS_PRIEST:
                    break;
                case CLASS_SHAMAN:
                    me->SetCanDualWield(true);
                    break;
                case CLASS_ROGUE:
                    me->SetCanDualWield(true);
                    break;
            }
        }

        switch(victimClass) {
            case CLASS_DRUID:
                if (uiTimer[1] <= diff)
                {
                    DoCast(me->getVictim(), SPELL_SR_MOONFIRE, false);
                    uiTimer[1] = urand(2000,4000);
                }
                DoMeleeAttackIfReady();
                break;
            case CLASS_HUNTER:
                if (uiTimer[1] <= diff)
                {
                    DoCast(me->getVictim(), SPELL_SR_MULTI_SHOT, false);
                    uiTimer[1] = urand(8000,10000);
                }
                if (uiTimer[2] <= diff)
                {
                    DoCast(me->getVictim(), SPELL_SR_SHOOT, false);
                    uiTimer[2] = urand(4000,6000);
                }
                if (me->IsWithinMeleeRange(me->getVictim(), 6))
                {
                    if (uiTimer[0] <= diff)
                    {
                        DoCast(me->getVictim(), SPELL_SR_MULTI_SHOT, false);
                        uiTimer[0] = urand(6000,8000);
                    }
                    DoMeleeAttackIfReady();
                }
                break;
            case CLASS_MAGE:
                if (uiTimer[1] <= diff)
                {
                    DoCast(me->getVictim(), SPELL_SR_FIREBALL, false);
                    uiTimer[1] = urand(2000,4000);
                }
                DoMeleeAttackIfReady();
                break;
            case CLASS_WARLOCK:
                if (uiTimer[1] <= diff)
                {
                    DoCast(me->getVictim(), SPELL_SR_SHADOW_BOLT, false);
                    uiTimer[1] = urand(3000,5000);
                }
                if (uiTimer[2] <= diff)
                {
                    DoCast(SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true), SPELL_SR_CURSE_OF_AGONY, true);
                    uiTimer[2] = urand(2000,4000);
                }
                DoMeleeAttackIfReady();
                break;
            case CLASS_WARRIOR:
                if (uiTimer[1] <= diff)
                {
                    DoCast(me->getVictim(), SPELL_SR_WHIRLWIND, false);
                    uiTimer[1] = urand(9000,11000);
                }
                DoMeleeAttackIfReady();
                break;
            case CLASS_PALADIN:
                if (uiTimer[1] <= diff)
                {
                    DoCast(me->getVictim(), SPELL_SR_HAMMER_OF_JUSTICE, false);
                    uiTimer[1] = urand(6000,8000);
                }
                if (uiTimer[2] <= diff)
                {
                    DoCast(me->getVictim(), SPELL_SR_HOLY_SHOCK, false);
                    uiTimer[2] = urand(2000,4000);
                }
                DoMeleeAttackIfReady();
                break;
            case CLASS_PRIEST:
                if (uiTimer[1] <= diff)
                {
                    DoCast(me->getVictim(), SPELL_SR_HOLY_SMITE, false);
                    uiTimer[1] = urand(4000,6000);
                }
                if (uiTimer[2] <= diff)
                {
                    DoCast(me, SPELL_SR_RENEW, false);
                    uiTimer[2] = urand(6000,8000);
                }
                DoMeleeAttackIfReady();
                break;
            case CLASS_SHAMAN:
                if (uiTimer[1] <= diff)
                {
                    DoCast(me->getVictim(), SPELL_SR_EARTH_SHOCK, false);
                    uiTimer[1] = urand(4000,6000);
                }
                DoMeleeAttackIfReady();
                break;
            case CLASS_ROGUE:
                if (uiTimer[1] <= diff)
                {
                    DoCast(me->getVictim(), SPELL_SR_HEMORRHAGE, true);
                    uiTimer[1] = urand(4000,6000);
                }
                DoMeleeAttackIfReady();
                break;
            }
            debug_log("Sinister-Timer");
            for (uint8 i = 0; i < 3; ++i)
                uiTimer[i] -= diff;
        }
コード例 #27
0
BossSpellWorker::~BossSpellWorker()
{
     debug_log("BSW: Removing BossSpellWorker object for boss %u",bossID);
};
コード例 #28
0
ファイル: instance_nexus.cpp プロジェクト: Subv/diamondcore
    void SetData(uint32 uiType, uint32 uiData)
    {
        debug_log("SD2: Instance Nexus: SetData received for type %u with data %u", uiType, uiData);

        switch (uiType)
        {
            case TYPE_TELESTRA:
                m_auiEncounter[0] = uiData;
                if (uiData == DONE)
                {
                    if (GameObject* pGo = instance->GetGameObject(m_uiTelestrasContainmentSphereGUID))
                        pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1);
                }
                break;
            case TYPE_ANOMALUS:
                m_auiEncounter[1] = uiData;
                if (uiData == DONE)
                {
                    if (GameObject* pGo = instance->GetGameObject(m_uiAnomalusContainmentSphereGUID))
                        pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1);
                }
                break;
            case TYPE_ORMOROK:
                m_auiEncounter[2] = uiData;
                if (uiData == DONE)
                {
                    if (GameObject* pGo = instance->GetGameObject(m_uiOrmoroksContainmentSphereGUID))
                        pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1);
                }
                break;
            case TYPE_KERISTRASZA:
                m_auiEncounter[3] = uiData;
                break;
            default:
                error_log("SD2: Instance Nexus: ERROR SetData = %u for type %u does not exist/not implemented.", uiType, uiData);
                break;
        }

        if (m_auiEncounter[0] == SPECIAL && m_auiEncounter[1] == SPECIAL && m_auiEncounter[2] == SPECIAL)
        {
            // release Keristrasza from her prison here
            m_auiEncounter[3] = SPECIAL;

            if (Creature* pCreature = instance->GetCreature(m_uiKeristrazaGUID))
            {
                if (pCreature->isAlive())
                    pCreature->RemoveAurasDueToSpell(SPELL_FROZEN_PRISON);
            }
        }

        if (uiData == DONE)
        {
            OUT_SAVE_INST_DATA;

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

            strInstData = saveStream.str();

            SaveToDB();
            OUT_SAVE_INST_DATA_COMPLETE;
        }
    }
コード例 #29
0
    void UpdateAI(const uint32 diff)
    {

        if(!pInstance) return;

        if (pInstance->GetData(TYPE_EVENT_NPC) == NPC_LICH_KING)
        {
            UpdateTimer = pInstance->GetData(TYPE_EVENT_TIMER);
            if (UpdateTimer <= diff)
            {
            debug_log("EventMGR: creature %u received signal %u ",m_creature->GetEntry(),pInstance->GetData(TYPE_EVENT));
            switch (pInstance->GetData(TYPE_EVENT))
                {
                case 12000:
                          m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_STAND);
                          m_creature->SetStandState(UNIT_STAND_STATE_STAND);
                          StartMovement(0,12020);
                          break;
                case 12020:
                          m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_TALK);
                          DoScriptText(-1631501, m_creature);
                          UpdateTimer = 12000;
                          pInstance->SetData(TYPE_EVENT,12030);
                          break;
                case 12040:
                          m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_READY2H);
                          DoScriptText(-1631503, m_creature);
                          UpdateTimer = 8000;
                          pInstance->SetData(TYPE_EVENT,12041);
                          break;
                case 12041:
                          m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_LAUGH);
                          UpdateTimer = 3000;
                          pInstance->SetData(TYPE_EVENT,12042);
                          break;
                case 12042:
                          m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,EMOTE_ONESHOT_POINT_NOSHEATHE);
                          UpdateTimer = 2000;
                          pInstance->SetData(TYPE_EVENT,12043);
                          break;
                case 12043:
                          m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,EMOTE_ONESHOT_NONE);
                          UpdateTimer = 10000;
                          pInstance->SetData(TYPE_EVENT,12050);
                          break;
                case 12060:
                          m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_TALK);
                          DoScriptText(-1631505, m_creature);
                          UpdateTimer = 10000;
                          pInstance->SetData(TYPE_EVENT,12080);
                          break;
                case 12080:
                          m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,EMOTE_STATE_READY2H);
                          UpdateTimer = 2000;
                          pInstance->SetData(TYPE_EVENT,12100);
                          break;
                case 12100:
                          m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,EMOTE_ONESHOT_NONE);
                          UpdateTimer = 6000;
                          pInstance->SetData(TYPE_EVENT,12120);
                          break;
                case 12120:
                          m_creature->GetMotionMaster()->Clear();
                          m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                          SetCombatMovement(true);
                          m_creature->SetInCombatWithZone();
                          battlestarted = true;
                          pInstance->SetData(TYPE_EVENT,12200);
                          UpdateTimer = 10000;
                          break;
                case 12200:
                          DoScriptText(-1631506, m_creature);
                          UpdateTimer = 5000;
                          pInstance->SetData(TYPE_EVENT,12220);
                          break;
                case 13000:
                          m_creature->SetOrientation(3.1146f);
                          DoScriptText(-1631507, m_creature);
                          UpdateTimer = 12000;
                          finalphase = true;
                          doCast(SPELL_FURY_OF_FROSTMOURNE);
                          pInstance->SetData(TYPE_EVENT,13020);
                          if (pTirion = pInstance->GetSingleCreatureFromStorage(NPC_TIRION)) 
                          {
                              m_creature->SetInCombatWith(pTirion);
                              pTirion->AddThreat(m_creature, 1000.0f);
                          }
                          m_creature->SetInCombatWithZone();
                          break;
                case 13020:
                          DoScriptText(-1631508, m_creature);
                          UpdateTimer = 12000;
                          pInstance->SetData(TYPE_EVENT,13060);
                          break;
                case 13060:
                          DoScriptText(-1631509, m_creature);
                          UpdateTimer = 15000;
                          pInstance->SetData(TYPE_EVENT,13100);
                          break;
                case 13100:
                          DoScriptText(-1631510, m_creature);
                          UpdateTimer = 15000;
                          pInstance->SetData(TYPE_EVENT,13110);
                          doCast(SPELL_CHANNEL_KING);
                          break;
                case 13120:
                          DoScriptText(-1631511, m_creature);
                          UpdateTimer = 12000;
                          pInstance->SetData(TYPE_EVENT,13130);
                          break;
                case 13140:
                          UpdateTimer = 6000;
                          doRemove(SPELL_CHANNEL_KING);
                          pInstance->SetData(TYPE_EVENT,13150);
                          m_creature->CastSpell(m_creature, SPELL_SUMMON_BROKEN_FROSTMOURNE, false);
                          break;
                case 13160:
                          UpdateTimer = 6000;
                          pInstance->SetData(TYPE_EVENT,13170);
                          m_creature->CastSpell(m_creature, SPELL_SUMMON_BROKEN_FROSTMOURNE_2, false);
                          break;
                case 13180:
                          UpdateTimer = 12000;
                          pInstance->SetData(TYPE_EVENT,13190);
                          if (pFrostmourne = m_creature->SummonCreature(NPC_FROSTMOURNE_HOLDER, SpawnLoc[7].x, SpawnLoc[7].y, SpawnLoc[7].z, 0, TEMPSUMMON_MANUAL_DESPAWN, 5000))
                             {
                                 pFrostmourne->CastSpell(pFrostmourne, SPELL_BROKEN_FROSTMOURNE, false);
                                 pFrostmourne->CastSpell(pFrostmourne, SPELL_FROSTMOURNE_TRIGGER, false);
                                 pFrostmourne->GetMotionMaster()->MoveChase(m_creature);
                                 m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED);
                             }
                          break;
                case 13200:
                          DoScriptText(-1631512, m_creature);
                          m_creature->RemoveAurasDueToSpell(SPELL_SUMMON_BROKEN_FROSTMOURNE);
                          m_creature->RemoveAllAuras();
                          pFrostmourne->RemoveAurasDueToSpell(SPELL_FROSTMOURNE_TRIGGER);
                          UpdateTimer = 5000;
                          pInstance->SetData(TYPE_EVENT,13210);
                          break;
                case 13280:
                          UpdateTimer = 2000;
                          pInstance->SetData(TYPE_EVENT,13290);
                          stage = 13;
                          if (pFrostmourne) pFrostmourne->ForcedDespawn();
                          if (Creature* pTemp = pInstance->GetSingleCreatureFromStorage(NPC_FROSTMOURNE_TRIGGER))
                             pTemp->ForcedDespawn();
                          if (Creature* pTemp = pInstance->GetSingleCreatureFromStorage(NPC_FROSTMOURNE_HOLDER))
                             pTemp->ForcedDespawn();
                          SetCombatMovement(true);
                          battlestarted = true;
                          break;
                default:
                          break;
                }
             } else UpdateTimer -= diff;
             pInstance->SetData(TYPE_EVENT_TIMER, UpdateTimer);
        }

        if (battlestarted && !m_creature->SelectHostileTarget() && !finalphase)
        {
            battlestarted = false;
            pInstance->SetData(TYPE_LICH_KING, FAIL);
            pInstance->SetData(TYPE_EVENT,0);
            EnterEvadeMode();
            return;
        }

        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        switch(stage)
        {
            case 0:           // Phase 1
//                    timedCast(SPELL_SHOCKWAVE, diff);
                    timedCast(SPELL_INFEST, diff);
                    timedCast(SPELL_SUMMON_DRUDGE_GHOULS, diff);
                    timedCast(SPELL_PLAGUE_SIPHON, diff);
                    timedCast(SPELL_SUMMON_SHAMBLING_HORROR, diff);
                    timedCast(SPELL_NECROTIC_PLAGUE, diff);

                    DoMeleeAttackIfReady();
                    if (timedQuery(SPELL_BERSERK, diff))
                    {
                        doCast(SPELL_BERSERK);
                        DoScriptText(-1631518,m_creature);
                    };

                    if (m_creature->GetHealthPercent() < 70.0f) 
                       {
                            stage = 1;
                            DoScriptText(-1631515,m_creature);
                       }
                    break;
            case 1:             // Go in transition phase
                    m_creature->AttackStop();
                    m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                    SetCombatMovement(false);
                    StartMovement(1,0);
                    stage = 2;
                    break;
            case 2:
                    if (movementstarted) return;
                    doCast(SPELL_REMORSELESS_WINTER);
                    stage = 3;
                    break;
            case 3:
                    timedCast(SPELL_SUMMON_RAGING_SPIRIT, diff);
                    timedCast(SPELL_SUMMON_ICE_SPHERE, diff);
                    timedCast(SPELL_PAIN_AND_SUFFERING, diff);

                    if (timedQuery(SPELL_BERSERK, diff))
                    {
                        doCast(SPELL_BERSERK);
                        DoScriptText(-1631518,m_creature);
                    };

                    if (timedQuery(SPELL_REMORSELESS_WINTER, diff))
                       {
                            doCast(SPELL_QUAKE);
                            stage = 4;
                            DoScriptText(-1631524, m_creature);
                            pInstance->DoOpenDoor(pInstance->GetData64(GO_SNOW_EDGE));
                       };
                    break;
            case 4:           // Platform destruct
                    if (timedQuery(SPELL_QUAKE, diff))
                       {
                            pInstance->DoOpenDoor(pInstance->GetData64(GO_ICESHARD_1));
                            pInstance->DoOpenDoor(pInstance->GetData64(GO_ICESHARD_2));
                            pInstance->DoOpenDoor(pInstance->GetData64(GO_ICESHARD_3));
                            pInstance->DoOpenDoor(pInstance->GetData64(GO_ICESHARD_4));
                            if (GameObject* pGoFloor = pInstance->GetSingleGameObjectFromStorage(GO_ARTHAS_PLATFORM))
                            {
                                 pGoFloor->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED | GO_FLAG_NODESPAWN);
                                 oldflag = pGoFloor->GetUInt32Value(GAMEOBJECT_BYTES_1);
                                 pGoFloor->SetUInt32Value(GAMEOBJECT_BYTES_1,8449);
                            }
                            pInstance->DoCloseDoor(pInstance->GetData64(GO_FROSTY_WIND));
                            pInstance->DoCloseDoor(pInstance->GetData64(GO_SNOW_EDGE));
                            m_creature->GetMotionMaster()->Clear();
                            m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
                            m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                            SetCombatMovement(true);
                            stage = 5;
                       }
                    break;
            case 5:           // Phase 2

                    if (timedQuery(SPELL_SPAWN_DEFILE, diff)) 
                       {
                            doCast(SPELL_SPAWN_DEFILE);
                            DoScriptText(-1631531,m_creature);
                       }
                    if (timedQuery(SPELL_SUMMON_VALKYR, diff)) 
                       {
                            doCast(SPELL_SUMMON_VALKYR);
                            DoScriptText(-1631527,m_creature);
                       }

                    timedCast(SPELL_SOUL_REAPER, diff);
                    timedCast(SPELL_INFEST, diff);

                    DoMeleeAttackIfReady();

                    if (timedQuery(SPELL_BERSERK, diff))
                    {
                        doCast(SPELL_BERSERK);
                        DoScriptText(-1631518,m_creature);
                    };

                    if (m_creature->GetHealthPercent() < 40.0f) 
                       {
                            stage = 6;
                            DoScriptText(-1631523,m_creature);
                       }
                    break;
            case 6:           // Go in transition phase
                    m_creature->AttackStop();
                    m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                    SetCombatMovement(false);
                    StartMovement(1,0);
                    stage = 7;
                    break;
            case 7:          // Platform restore
                    if (movementstarted) return;
                    if (GameObject* pGoFloor = pInstance->GetSingleGameObjectFromStorage(GO_ARTHAS_PLATFORM))
                    {
                        pGoFloor->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED | GO_FLAG_NODESPAWN);
                        pGoFloor->SetUInt32Value(GAMEOBJECT_BYTES_1,oldflag);
                    }
                    pInstance->DoOpenDoor(pInstance->GetData64(GO_FROSTY_WIND));
                    doCast(SPELL_REMORSELESS_WINTER);
                    stage = 8;
                    break;
            case 8:
                    timedCast(SPELL_SUMMON_RAGING_SPIRIT, diff);
                    timedCast(SPELL_SUMMON_ICE_SPHERE, diff);
                    timedCast(SPELL_PAIN_AND_SUFFERING, diff);

                    if (timedQuery(SPELL_BERSERK, diff))
                    {
                        doCast(SPELL_BERSERK);
                        DoScriptText(-1631518,m_creature);
                    };

                    if (timedQuery(SPELL_REMORSELESS_WINTER, diff))
                       {
                            DoScriptText(-1631524, m_creature);
                            doCast(SPELL_SUMMON_VILE_SPIRITS);
                            for (uint8 i = 0; i < getSpellData(SPELL_SUMMON_VILE_SPIRITS); ++i)
                                 doCast(NPC_VILE_SPIRIT);
                            doCast(SPELL_QUAKE);
                            stage = 9;
                            pInstance->DoOpenDoor(pInstance->GetData64(GO_SNOW_EDGE));
                       };

                    break;
            case 9:           // Platform destruct
                    if (timedQuery(SPELL_QUAKE, diff))
                       {
                            if (GameObject* pGoFloor = pInstance->GetSingleGameObjectFromStorage(GO_ARTHAS_PLATFORM))
                            {
                                 pGoFloor->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED | GO_FLAG_NODESPAWN);
                                 oldflag = pGoFloor->GetUInt32Value(GAMEOBJECT_BYTES_1);
                                 pGoFloor->SetUInt32Value(GAMEOBJECT_BYTES_1,8449);
                            }
                            pInstance->DoCloseDoor(pInstance->GetData64(GO_SNOW_EDGE));
                            pInstance->DoCloseDoor(pInstance->GetData64(GO_FROSTY_WIND));
                            m_creature->GetMotionMaster()->Clear();
                            m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
                            m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                            SetCombatMovement(true);
                            stage = 10;
                       }
                   break;
            case 10:           // Phase 3
                    if (timedQuery(SPELL_SPAWN_DEFILE, diff)) 
                       {
                            doCast(SPELL_SPAWN_DEFILE);
//                            DoScriptText(-1631527,m_creature);
                       }
                    timedCast(SPELL_SOUL_REAPER, diff);

                    if (timedQuery(SPELL_HARVEST_SOUL, diff)) 
                       {
                            doCast(SPELL_HARVEST_SOUL);
                            DoScriptText(-1631520,m_creature);
                       }

                    timedCast(SPELL_SOUL_REAPER, diff);
                    timedCast(SPELL_INFEST, diff);

                    DoMeleeAttackIfReady();

                    if (m_creature->GetHealthPercent() < 10.0f) 
                       {
                            stage = 11;
                            DoScriptText(-1631513,m_creature);
                       }
                    break;
            case 11:           // Ending Phase start
                    m_creature->AttackStop();
                    SetCombatMovement(false);
                    StartMovement(6,13000);
                    stage = 12;
                    battlestarted = false;
                    break;
            case 12:
                    break;
            case 13:
                    DoMeleeAttackIfReady();
                    break;
        }
    }
コード例 #30
0
ファイル: tcp_connection.cpp プロジェクト: xbon/zpublic
TcpConnection::~TcpConnection()
{
    SAFE_DELETE_ARR(_buffer);
    debug_log("connection destroyed.");
}