Пример #1
0
bool LayingWasteToTheUnwantedAllianz(uint32 i, Spell* pSpell)
{
	Player *caster = pSpell->p_caster;
	if(caster == NULL)
		return true;
	
	GameObject *eastern = caster->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(-155, 2517, 43, 300152);
	GameObject *ceastern = caster->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(-152, 2661, 44, 300152);
	GameObject *cwestern = caster->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(-174, 2772, 32, 300152);
	GameObject *western = caster->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(-166, 2818, 29, 300152);

	if(caster->GetQuestLogForEntry(10078))
	{
		// Eastern Thrower
		if (eastern)
		{
			if(caster->CalcDistance(caster, eastern) < 30)
            {
				QuestLogEntry *qle = caster->GetQuestLogForEntry(10078);
	
	      			qle->SetMobCount(0, qle->GetMobCount(0)+1);
				qle->SendUpdateAddKill(0);
				qle->UpdatePlayerFields();
	
				GameObject* obj = 0;
	
				obj = sEAS.SpawnGameobject(caster, 183816, -157.916, 2517.71, 58.5508, 0, 4);
	     			sEAS.GameobjectDelete(obj, 1*60*1000);
			}

			return true;
		}

		// Central Eastern Thrower
		if (ceastern)
		{
			if(caster->CalcDistance(caster, ceastern) < 30)
			{
				QuestLogEntry *qle = caster->GetQuestLogForEntry(10078);
	
	      			qle->SetMobCount(1, qle->GetMobCount(1)+1);
				qle->SendUpdateAddKill(1);
				qle->UpdatePlayerFields();
	
				GameObject* obj = 0;
	
				obj = sEAS.SpawnGameobject(caster, 183816, -152.527, 2661.99, 60.8123, 0, 4);
	     			sEAS.GameobjectDelete(obj, 1*60*1000);
			}

			return true;
		}

		// Central Western Thrower
		if (cwestern)
		{
			if(caster->CalcDistance(caster, cwestern) < 30)
			{
				QuestLogEntry *qle = caster->GetQuestLogForEntry(10078);
	
	      			qle->SetMobCount(2, qle->GetMobCount(2)+1);
				qle->SendUpdateAddKill(2);
				qle->UpdatePlayerFields();
	
				GameObject* obj = 0;
	
				obj = sEAS.SpawnGameobject(caster, 183816, -177.916, 2773.75, 48.636, 0, 4);
	     			sEAS.GameobjectDelete(obj, 1*60*1000);
			}

			return true;
		}

		// Western Thrower
		if (western)
		{
			if(caster->CalcDistance(caster, western) < 30)
			{
				QuestLogEntry *qle = caster->GetQuestLogForEntry(10078);
	
	      			qle->SetMobCount(3, qle->GetMobCount(3)+1);
				qle->SendUpdateAddKill(3);
				qle->UpdatePlayerFields();
	
				GameObject* obj = 0;
	
				obj = sEAS.SpawnGameobject(caster, 183816, -166, 2818, 29, 0, 4);
	     			sEAS.GameobjectDelete(obj, 1*60*1000);
			}

			return true;
		}
	}
	else
	{
		caster->BroadcastMessage("Missing required quest : Laying Waste to the Unwanted");
	}

	return true;
}
Пример #2
0
void QuestMgr::OnPlayerKill(Player* plr, Creature* victim)
{
	if(!plr)
		return;

	uint32 i, j;
	uint32 entry = victim->GetEntry();
	QuestLogEntry *qle;
	for(i = 0; i < 25; ++i)
	{
		if((qle = plr->GetQuestLogInSlot(i)))
		{
			// dont waste time on quests without mobs
			if(qle->GetQuest()->count_required_mob == 0)
				continue;

			for(j = 0; j < 4; ++j)
			{
				if(qle->GetQuest()->required_mob[j] == entry &&
					qle->GetQuest()->required_mobtype[j] == QUEST_MOB_TYPE_CREATURE &&
					qle->m_mobcount[j] < qle->GetQuest()->required_mobcount[j])
				{
					// add another kill.
					// (auto-dirtys it)
					qle->SetMobCount(j, qle->m_mobcount[j] + 1);
					qle->SendUpdateAddKill(j);
					CALL_QUESTSCRIPT_EVENT(qle, OnCreatureKill)(entry, plr);
					qle->UpdatePlayerFields();
					break;
				}
			}
		}
	}
	
	// Shared kills
	Player *gplr = NULL;

	if(plr->InGroup())
	{
		if(Group* pGroup = plr->GetGroup())
		{
			if(pGroup->GetGroupType() != GROUP_TYPE_PARTY) return;  // Raid's don't get shared kills.

			GroupMembersSet::iterator gitr;
			for(uint32 k = 0; k < pGroup->GetSubGroupCount(); k++)
			{
				for(gitr = pGroup->GetSubGroup(k)->GetGroupMembersBegin(); gitr != pGroup->GetSubGroup(k)->GetGroupMembersEnd(); ++gitr)
				{
					gplr = (*gitr);
					if(gplr && gplr != plr) // dont double kills
					{
						for(i = 0; i < 20; ++i)
						{
							if((qle = gplr->GetQuestLogInSlot(i)))
							{
								// dont waste time on quests without mobs
								if(qle->GetQuest()->count_required_mob == 0)
									continue;

								for(j = 0; j < 4; ++j)
								{
									if(qle->GetQuest()->required_mob[j] == entry &&
										qle->GetQuest()->required_mobtype[j] == QUEST_MOB_TYPE_CREATURE &&
										qle->m_mobcount[j] < qle->GetQuest()->required_mobcount[j])
									{
										// add another kill.
										// (auto-dirtys it)
										qle->SetMobCount(j, qle->m_mobcount[j] + 1);
										qle->SendUpdateAddKill(j);
										CALL_QUESTSCRIPT_EVENT(qle, OnCreatureKill)(entry, plr);
										qle->UpdatePlayerFields();

										// lua stuff
										//QUESTLUA_SendEvent(qst, victim, plr, ON_QUEST_KILLMOB, qle->m_mobcount[j]);
										if(qle->CanBeFinished())
											qle->SendQuestComplete();
										break;
									}
								}
							}
						}
					}
				}
			}
		}
	}
}
Пример #3
0
	void OnActivate(Player * pPlayer)
	{
		float SSX = pPlayer->GetPositionX();
		float SSY = pPlayer->GetPositionY();
		float SSZ = pPlayer->GetPositionZ();

		GameObject *nothern = pPlayer->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(-820, 2029, 55, 300150);
		GameObject *southern = pPlayer->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(-1150, 2110, 84, 300150);
		GameObject *forge = pPlayer->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(-893, 1919, 82, 300150);
		GameObject *foothill = pPlayer->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(-978, 1879, 111, 300150);
		GameObject *Beacon = pPlayer->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords( SSX, SSY, SSZ, 184661);

		if(Beacon)
		{
			Beacon->SetUInt32Value(GAMEOBJECT_FLAGS, (Beacon->GetUInt32Value(GAMEOBJECT_FLAGS)-1));
		}

		if(pPlayer->GetQuestLogForEntry(10895))
		{
			// Northern Zeth'Gor Tower
			if (nothern != NULL)
                        {
                        	if(pPlayer->CalcDistance(pPlayer, nothern) < 40) // if reduced the server will crash when out of range
                        	{
					QuestLogEntry *qle = pPlayer->GetQuestLogForEntry(10895);

	      				qle->SetMobCount(0, qle->GetMobCount(0)+1);
					qle->SendUpdateAddKill(0);
					qle->UpdatePlayerFields();

					GameObject* obj = 0;

					obj = sEAS.SpawnGameobject(pPlayer, 183816, -819.77, 2029.09, 55.6082, 0, 4);
     					sEAS.GameobjectDelete(obj, 1*60*1000);

					return;
				}
			}

			// Southern Zeth'Gor Tower
			if (southern != NULL)
                        {
                        	if(pPlayer->CalcDistance(pPlayer, southern) < 40)
                        	{
					QuestLogEntry *qle = pPlayer->GetQuestLogForEntry(10895);
	
					qle->SetMobCount(1, qle->GetMobCount(1)+1);
					qle->SendUpdateAddKill(1);
					qle->UpdatePlayerFields();
	
					GameObject* obj = 0;
	
					obj = sEAS.SpawnGameobject(pPlayer, 183816, -1150.53, 2109.92, 84.4204, 0, 4);
	     				sEAS.GameobjectDelete(obj, 1*60*1000);
	
					return;
				}
			}

			// Forge Zeth'Gor Tower
			if (forge)
                        {
                        	if(pPlayer->CalcDistance(pPlayer, forge) < 40)
                        	{
					QuestLogEntry *qle = pPlayer->GetQuestLogForEntry(10895);
	
					qle->SetMobCount(2, qle->GetMobCount(2)+1);
					qle->SendUpdateAddKill(2);
					qle->UpdatePlayerFields();
	
					GameObject* obj = 0;
	
					obj = sEAS.SpawnGameobject(pPlayer, 183816, -893.499, 1919.27, 81.6449, 0, 4);
	     				sEAS.GameobjectDelete(obj, 1*60*1000);
	
					return;
				}
			}

			// Foothill Zeth'Gor Tower
			if (foothill)
                        {
                        	if(pPlayer->CalcDistance(pPlayer, foothill) < 40)
                        	{
					QuestLogEntry *qle = pPlayer->GetQuestLogForEntry(10895);
	
					qle->SetMobCount(3, qle->GetMobCount(3)+1);
					qle->SendUpdateAddKill(3);
					qle->UpdatePlayerFields();
	
					GameObject* obj = 0;
	
					obj = sEAS.SpawnGameobject(pPlayer, 183816, -977.713, 1879.500, 110.892, 0, 4);
	     				sEAS.GameobjectDelete(obj, 1*60*1000);
	
					return;
				}
			}
			else
			{
				pPlayer->BroadcastMessage("You are to far away!");
			}

		}
		else
		{
				pPlayer->BroadcastMessage("Missing required quest : Zeth'Gor Must Burn");
		}
	}
Пример #4
0
bool ZethGorMustBurnHorde(uint32 i, Spell* pSpell)
{
	Player *caster = pSpell->p_caster;
	if(caster == NULL)
		return true;
	
	GameObject *barracks = caster->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(-1137, 1970, 74, 300151);
	GameObject *eastern = caster->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(-940, 1920, 69, 300151);
	GameObject *western = caster->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(-1155, 2061, 68, 300151);
	GameObject *stable = caster->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(-1052, 2007, 66, 300151);

	if(caster->GetQuestLogForEntry(10792))
	{
		// Barracks
		if (barracks)
        {
            if(caster->CalcDistance(caster, barracks) < 30)
            {
				QuestLogEntry *qle = caster->GetQuestLogForEntry(10792);
	
	      			qle->SetMobCount(0, qle->GetMobCount(0)+1);
				qle->SendUpdateAddKill(0);
				qle->UpdatePlayerFields();
	
				GameObject* obj = 0;
	
				obj = sEAS.SpawnGameobject(caster, 183816, -1129.08, 1921.77, 94.0074, 0, 4);
	     			sEAS.GameobjectDelete(obj, 1*60*1000);
	     			obj = sEAS.SpawnGameobject(caster, 183816, -1135.00, 1944.05, 84.7084, 0, 4);
	     			sEAS.GameobjectDelete(obj, 1*60*1000);
	     			obj = sEAS.SpawnGameobject(caster, 183816, -1152.01, 1945.00, 102.901, 0, 4);
	     			sEAS.GameobjectDelete(obj, 1*60*1000);
	     			obj = sEAS.SpawnGameobject(caster, 183816, -1159.60, 1958.76, 83.0412, 0, 4);
	     			sEAS.GameobjectDelete(obj, 1*60*1000);
	     			obj = sEAS.SpawnGameobject(caster, 183816, -1126.17, 1880.96, 95.065, 0, 4);
	     			sEAS.GameobjectDelete(obj, 1*60*1000);
	     			obj = sEAS.SpawnGameobject(caster, 183816, -1185.79, 1968.29, 90.931, 0, 4);
	     			sEAS.GameobjectDelete(obj, 1*60*1000);
			}

			return true;
		}

		// Eastern Hovel
		if (eastern)
        {
            if(caster->CalcDistance(caster, eastern) < 30)
            {
				QuestLogEntry *qle = caster->GetQuestLogForEntry(10792);
	
	      			qle->SetMobCount(1, qle->GetMobCount(1)+1);
				qle->SendUpdateAddKill(1);
				qle->UpdatePlayerFields();
	
				GameObject* obj = 0;
	
				obj = sEAS.SpawnGameobject(caster, 183816, -938.034, 1924.153, 73.590, 0, 4);
	     			sEAS.GameobjectDelete(obj, 1*60*1000);
			}

			return true;
		}

		// Western Hovel
		if (western)
        {
            if(caster->CalcDistance(caster, western) < 30)
            {
				QuestLogEntry *qle = caster->GetQuestLogForEntry(10792);
	
	      			qle->SetMobCount(2, qle->GetMobCount(2)+1);
				qle->SendUpdateAddKill(2);
				qle->UpdatePlayerFields();
	
				GameObject* obj = 0;
	
				obj = sEAS.SpawnGameobject(caster, 183816, -1152.10, 2066.20, 72.959, 0, 4);
	     			sEAS.GameobjectDelete(obj, 1*60*1000);
			}

			return true;
		}

		// Stable
		if (stable)
        {
            if(caster->CalcDistance(caster, stable) < 30)
            {
				QuestLogEntry *qle = caster->GetQuestLogForEntry(10792);
	
	      			qle->SetMobCount(3, qle->GetMobCount(3)+1);
				qle->SendUpdateAddKill(3);
				qle->UpdatePlayerFields();
	
				GameObject* obj = 0;
	
				obj = sEAS.SpawnGameobject(caster, 183816, -1058.85, 2010.95, 68.776, 0, 4);
	     			sEAS.GameobjectDelete(obj, 1*60*1000);
			}

			return true;
		}
	}
	else
	{
		caster->BroadcastMessage("Missing required quest : Zeth'Gor Must Burn");
	}

	return true;
}
Пример #5
0
void ArathiBasin::AssaultControlPoint(Player* pPlayer, uint32 Id)
{
#ifdef ANTI_CHEAT
    if(!m_started)
    {
        Anticheat_Log->writefromsession(pPlayer->GetSession(), "%s tried to assault control point in arathi basin before battleground (ID %u) started.", pPlayer->GetName(), this->m_id);
        SendChatMessage(CHAT_MSG_BG_EVENT_NEUTRAL, pPlayer->GetGUID(), "%s will be removed from the game for cheating.", pPlayer->GetName());
        // Remove player from battleground.
        RemovePlayer(pPlayer, false);
        // Kick player from server.
        pPlayer->Kick(6000);
        return;
    }
#endif

    uint32 Team = pPlayer->m_bgTeam;
    uint32 Owner;

    pPlayer->m_bgScore.MiscData[BG_SCORE_AB_BASES_ASSAULTED]++;

    if(m_basesOwnedBy[Id] == -1 && m_basesAssaultedBy[Id] == -1)
    {
        // omgwtfbbq our flag is a virgin?
        SetWorldState(NeutralFields[Id], 0);
    }

    if(m_basesOwnedBy[Id] != -1)
    {
        Owner = m_basesOwnedBy[Id];

        // set it to uncontrolled for now
        m_basesOwnedBy[Id] = -1;
        m_basesLastOwnedBy[Id] = Owner;

        // this control point just got taken over by someone! oh noes!
        if(m_spiritGuides[Id] != NULL)
        {
            map<Creature*, set<uint32> >::iterator itr = m_resurrectMap.find(m_spiritGuides[Id]);
            if(itr != m_resurrectMap.end())
            {
                for(set<uint32>::iterator it2 = itr->second.begin(); it2 != itr->second.end(); ++it2)
                {
                    Player* r_plr = m_mapMgr->GetPlayer(*it2);
                    if(r_plr != NULL && r_plr->IsDead())
                        HookHandleRepop(r_plr);
                }
            }
            m_resurrectMap.erase(itr);
            m_spiritGuides[Id]->Despawn(0, 0);
            m_spiritGuides[Id] = NULL;
        }

        // detract one from the teams controlled points
        m_capturedBases[Owner] -= 1;
        SetWorldState(Owner ? WORLDSTATE_AB_HORDE_CAPTUREBASE : WORLDSTATE_AB_ALLIANCE_CAPTUREBASE, m_capturedBases[Owner]);

        // reset the world states
        SetWorldState(OwnedFields[Id][Owner], 0);

        // modify the resource update time period
        if(m_capturedBases[Owner] == 0)
            this->event_RemoveEvents(EVENT_AB_RESOURCES_UPDATE_TEAM_0 + Owner);
        else
            this->event_ModifyTime(EVENT_AB_RESOURCES_UPDATE_TEAM_0 + Owner, ResourceUpdateIntervals[m_capturedBases[Owner]]);
    }

    // n***a stole my flag!
    if(m_basesAssaultedBy[Id] != -1)
    {
        Owner = m_basesAssaultedBy[Id];

        // woah! vehicle hijack!
        m_basesAssaultedBy[Id] = -1;
        SetWorldState(AssaultFields[Id][Owner], 0);

        // make sure the event does not trigger
        sEventMgr.RemoveEvents(this, EVENT_AB_CAPTURE_CP_1 + Id);
        if(m_basesLastOwnedBy[Id] == (int32)Team)
        {
            m_basesAssaultedBy[Id] = (int32)Team;
            CaptureControlPoint(Id, Team);
            return;
        }

        // no need to remove the spawn, SpawnControlPoint will do this.
    }

    m_basesAssaultedBy[Id] = Team;

    // spawn the new control point gameobject
    SpawnControlPoint(Id, Team ? AB_SPAWN_TYPE_HORDE_ASSAULT : AB_SPAWN_TYPE_ALLIANCE_ASSAULT);

    // update the client's map with the new assaulting field
    SetWorldState(AssaultFields[Id][Team], 1);

    // Check Assault/Defense, the time of capture is not the same.
    if(DefFlag[Id][0] && !DefFlag[Id][1])
    {
        DefFlag[Id][0] = false;
        SendChatMessage(Team ? CHAT_MSG_BG_EVENT_HORDE : CHAT_MSG_BG_EVENT_ALLIANCE, pPlayer->GetGUID(), "$N defend %s", ControlPointNames[Id]);
        sEventMgr.AddEvent(this, &ArathiBasin::CaptureControlPoint, Id, Team, EVENT_AB_CAPTURE_CP_1 + Id, 1000, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
        pPlayer->m_bgScore.MiscData[BG_SCORE_AB_BASES_CAPTURED]++;
        UpdatePvPData();
    }
    else if(!DefFlag[Id][0] && !DefFlag[Id][1])
    {
        DefFlag[Id][0] = true;
        SendChatMessage(Team ? CHAT_MSG_BG_EVENT_HORDE : CHAT_MSG_BG_EVENT_ALLIANCE, pPlayer->GetGUID(), "$N assault %s !", ControlPointNames[Id]);
        PlaySoundToAll(Team ? 8212 : 8174);
        if(Team)
        {
            QuestLogEntry* en = pPlayer->GetQuestLogForEntry(8120);
            switch(Id)
            {
            case AB_CONTROL_POINT_MINE:
            {
                if(en && en->GetMobCount(0) < en->GetQuest()->required_mobcount[0])
                {
                    en->SetMobCount(0, en->GetMobCount(0) + 1);
                    en->SendUpdateAddKill(0);
                    en->UpdatePlayerFields();
                }
            }
            break;
            case AB_CONTROL_POINT_LUMBERMILL:
            {
                if(en && en->GetMobCount(1) < en->GetQuest()->required_mobcount[1])
                {
                    en->SetMobCount(1, en->GetMobCount(1) + 1);
                    en->SendUpdateAddKill(1);
                    en->UpdatePlayerFields();
                }
            }
            break;
            case AB_CONTROL_POINT_BLACKSMITH:
            {
                if(en && en->GetMobCount(2) < en->GetQuest()->required_mobcount[2])
                {
                    en->SetMobCount(2, en->GetMobCount(2) + 1);
                    en->SendUpdateAddKill(2);
                    en->UpdatePlayerFields();
                }
            }
            break;
            case AB_CONTROL_POINT_STABLE:
            {
                if(en && en->GetMobCount(3) < en->GetQuest()->required_mobcount[3])
                {
                    en->SetMobCount(3, en->GetMobCount(3) + 1);
                    en->SendUpdateAddKill(3);
                    en->UpdatePlayerFields();
                }
            }
            break;
            }
        }
        else
        {
            QuestLogEntry* en = pPlayer->GetQuestLogForEntry(8105);
            switch(Id)
            {
            case AB_CONTROL_POINT_MINE:
            {
                if(en && en->GetMobCount(0) < en->GetQuest()->required_mobcount[0])
                {
                    en->SetMobCount(0, en->GetMobCount(0) + 1);
                    en->SendUpdateAddKill(0);
                    en->UpdatePlayerFields();
                }
            }
            break;
            case AB_CONTROL_POINT_LUMBERMILL:
            {
                if(en && en->GetMobCount(1) < en->GetQuest()->required_mobcount[1])
                {
                    en->SetMobCount(1, en->GetMobCount(1) + 1);
                    en->SendUpdateAddKill(1);
                    en->UpdatePlayerFields();
                }
            }
            break;
            case AB_CONTROL_POINT_BLACKSMITH:
            {
                if(en && en->GetMobCount(2) < en->GetQuest()->required_mobcount[2])
                {
                    en->SetMobCount(2, en->GetMobCount(2) + 1);
                    en->SendUpdateAddKill(2);
                    en->UpdatePlayerFields();
                }
            }
            break;
            case AB_CONTROL_POINT_FARM:
            {
                if(en && en->GetMobCount(3) < en->GetQuest()->required_mobcount[3])
                {
                    en->SetMobCount(3, en->GetMobCount(3) + 1);
                    en->SendUpdateAddKill(3);
                    en->UpdatePlayerFields();
                }
            }
            break;
            }
        }
        sEventMgr.AddEvent(this, &ArathiBasin::CaptureControlPoint, Id, Team, EVENT_AB_CAPTURE_CP_1 + Id, MSTIME_MINUTE, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
        pPlayer->m_bgScore.MiscData[BG_SCORE_AB_BASES_ASSAULTED]++;
        UpdatePvPData();
    }
    else
    {
        DefFlag[Id][0] = true;
        SendChatMessage(Team ? CHAT_MSG_BG_EVENT_HORDE : CHAT_MSG_BG_EVENT_ALLIANCE, pPlayer->GetGUID(), "$N claims the %s! If left unchallenged, the %s will control it in 1 minute!", ControlPointNames[Id],
                        Team ? "Horde" : "Alliance");
        PlaySoundToAll(8192);
        sEventMgr.AddEvent(this, &ArathiBasin::CaptureControlPoint, Id, Team, EVENT_AB_CAPTURE_CP_1 + Id, MSTIME_MINUTE, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
    }
}
Пример #6
0
bool ChatHandler::HandleQuestStartCommand(const char * args, WorldSession * m_session)
{
	if(!*args) return false;

	Player* plr = getSelectedChar(m_session, true);
	if(!plr)
	{
		plr = m_session->GetPlayer();
		SystemMessage(m_session, "Auto-targeting self.");
	}

	uint32 quest_id = atol(args);
	std::string recout = "|cff00ff00";

	Quest * qst = QuestStorage.LookupEntry(quest_id);
	if(qst)
	{
		if (plr->HasFinishedQuest(quest_id) || plr->HasFinishedDailyQuest(quest_id))
			recout += "Player has already completed that quest.";
		else
		{
			QuestLogEntry * IsPlrOnQuest = plr->GetQuestLogForEntry(quest_id);
			if (IsPlrOnQuest)
				recout += "Player is currently on that quest.";
			else
			{
				int32 open_slot = plr->GetOpenQuestSlot();

				if (open_slot == -1)
				{
					sQuestMgr.SendQuestLogFull(plr);
					recout += "Player's quest log is full.";
				}
				else
				{
					QuestLogEntry *qle = new QuestLogEntry();
					qle->Init(qst, plr, (uint32)open_slot);
					qle->UpdatePlayerFields();

					CALL_QUESTSCRIPT_EVENT(qle, OnQuestStart)(plr, qle);
		
					// If the quest should give any items on begin, give them the items.
					for(uint32 i = 0; i < 4; ++i)
					{
						if(qst->receive_items[i])
						{
							Item* item = objmgr.CreateItem( qst->receive_items[i], plr);
							if(!plr->GetItemInterface()->AddItemToFreeSlot(item))
							{
								if(item)
									item->Destructor();
							}
						}
					}

					if(qst->srcitem && qst->srcitem != qst->receive_items[0])
					{
						Item* item = objmgr.CreateItem( qst->srcitem, plr);
						if(item)
						{
							item->SetUInt32Value(ITEM_FIELD_STACK_COUNT, qst->srcitemcount ? qst->srcitemcount : 1);
							if(!plr->GetItemInterface()->AddItemToFreeSlot(item))
							{
								if(item)
									item->Destructor();
							}
						}
					}
				

					plr->UpdateNearbyGameObjects();
				
					sHookInterface.OnQuestAccept( plr, qst, NULL );

					recout += "Quest has been added to the player's quest log.";
				}
			}
		}
	}
	else
	{
		recout += "Quest Id [";
		recout += args;
		recout += "] was not found and unable to add it to the player's quest log.";
	}

	recout += "\n\n";

	SendMultilineMessage(m_session, recout.c_str());

	return true;
}
Пример #7
0
		void GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char* Code)
		{
			GossipMenu* Menu;
			switch(IntId)
			{
				case 0:
					GossipHello(pObject, Plr);
					break;
				case 3:
					{
						objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 7755, Plr);
						Menu->AddItem(0, "That sounds dangerous.", 4);
						Menu->SendTo(Plr);
					}
					break;
				case 4:
					{
						objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 7756, Plr);
						Menu->AddItem(0, "What happened to her after that?", 5);
						Menu->SendTo(Plr);
					}
					break;
				case 5:
					{
						objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 7757, Plr);
						Menu->AddItem(0, "Natalia?", 6);
						Menu->SendTo(Plr);
					}
					break;
				case 6:
					{
						objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 7758, Plr);
						Menu->AddItem(0, "What demands?", 7);
						Menu->SendTo(Plr);
					}
					break;
				case 7:
					{
						objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 7759, Plr);
						Menu->AddItem(0, "Lost it? What do you mean?", 8);
						Menu->SendTo(Plr);
					}
					break;
				case 8:
					{
						objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 7760, Plr);
						Menu->AddItem(0, "Possessed by what?", 9);
						Menu->SendTo(Plr);
					}
					break;
				case 9:
					{
						objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 7761, Plr);
						Menu->AddItem(0, "I'll be back once I straighten this mess out.", 10);
						Menu->SendTo(Plr);
					}
					break;
				case 10:
					{
						QuestLogEntry* en = Plr->GetQuestLogForEntry(8304);
						if(en && en->GetMobCount(1) < en->GetQuest()->required_mobcount[1])
						{
							en->SetMobCount(1, 1);
							en->SendUpdateAddKill(1);
							en->UpdatePlayerFields();
						}
					}
					break;
			}
		}
Пример #8
0
void WorldSession::HandleQuestgiverAcceptQuestOpcode( WorldPacket & recv_data )
{
	sLog.outDebug( "WORLD: Received CMSG_QUESTGIVER_ACCEPT_QUEST" );
    if(!_player) return;
	if(!_player->IsInWorld()) return;

	//WorldPacket data;

	uint64 guid;
	uint32 quest_id;

	recv_data >> guid;
	recv_data >> quest_id;

	bool bValid = false;
	bool hasquest = true;
	bool bSkipLevelCheck = false;
	Quest *qst = NULL;
	Object *qst_giver = NULL;
	uint32 guidtype = GET_TYPE_FROM_GUID(guid);

	if(guidtype==HIGHGUID_TYPE_UNIT)
	{
		Creature *quest_giver = _player->GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid));
		if(quest_giver)
			qst_giver = (Object*)quest_giver;
		else
			return;
		bValid = quest_giver->isQuestGiver();
		hasquest = quest_giver->HasQuest(quest_id, 1);
		if(bValid)
			qst = QuestStorage.LookupEntry(quest_id);
	} 
	else if(guidtype==HIGHGUID_TYPE_GAMEOBJECT)
	{
		GameObject *quest_giver = _player->GetMapMgr()->GetGameObject(GET_LOWGUID_PART(guid));
		if(quest_giver)
			qst_giver = (Object*)quest_giver;
		else
			return;
		//bValid = quest_giver->isQuestGiver();
		//if(bValid)
		bValid = true;
			qst = QuestStorage.LookupEntry(quest_id);
	} 
	else if(guidtype==HIGHGUID_TYPE_ITEM)
	{
		Item *quest_giver = GetPlayer()->GetItemInterface()->GetItemByGUID(guid);
		if(quest_giver)
			qst_giver = (Object*)quest_giver;
		else
			return;
		bValid = true;
		bSkipLevelCheck=true;
		qst = QuestStorage.LookupEntry(quest_id);
	}
	else if(guidtype==HIGHGUID_TYPE_PLAYER)
	{
		Player *quest_giver = _player->GetMapMgr()->GetPlayer((uint32)guid);
		if(quest_giver)
			qst_giver = (Object*)quest_giver;
		else
			return;
		bValid = true;
		qst = QuestStorage.LookupEntry(quest_id);
	}

	if (!qst_giver)
	{
		sLog.outDebug("WORLD: Invalid questgiver GUID.");
		return;
	}

	if( !bValid || qst == NULL )
	{
		sLog.outDebug("WORLD: Creature is not a questgiver.");
		return;
	}

	if( _player->GetQuestLogForEntry( qst->id ) )
		return;

	if( qst_giver->GetTypeId() == TYPEID_UNIT && static_cast< Creature* >( qst_giver )->m_escorter != NULL )
	{
		SystemMessage("You cannot accept this quest at this time.");
		return;
	}

	// Check the player hasn't already taken this quest, or
	// it isn't available.
	uint32 status = sQuestMgr.CalcQuestStatus(qst_giver, _player,qst,3, bSkipLevelCheck);

	if((!sQuestMgr.IsQuestRepeatable(qst) && _player->HasFinishedQuest(qst->id)) || ( status != QMGR_QUEST_AVAILABLE && status != QMGR_QUEST_REPEATABLE && status != QMGR_QUEST_CHAT )
		|| !hasquest)
	{
		// We've got a hacker. Disconnect them.
		//sCheatLog.writefromsession(this, "tried to accept incompatible quest %u from %u.", qst->id, qst_giver->GetEntry());
		//Disconnect();
		return;
	}

	int32 log_slot = GetPlayer()->GetOpenQuestSlot();

	if (log_slot == -1)
	{
		sQuestMgr.SendQuestLogFull(GetPlayer());
		return;
	}

	//FIXME
	/*if(Player Has Timed quest && qst->HasFlag(QUEST_FLAG_TIMED))
		sQuestMgr.SendQuestInvalid(INVALID_REASON_HAVE_TIMED_QUEST);*/

	if(qst->count_receiveitems || qst->srcitem)
	{
		uint32 slots_required = qst->count_receiveitems;

		if(GetPlayer()->GetItemInterface()->CalculateFreeSlots(NULL) < slots_required)
		{
			GetPlayer()->GetItemInterface()->BuildInventoryChangeError(NULL, NULL, INV_ERR_BAG_FULL);
			sQuestMgr.SendQuestFailed(FAILED_REASON_INV_FULL, qst, GetPlayer());
			return;
		}
	}	
	
/*	if(qst_giver->GetTypeId() == TYPEID_UNIT && !ScriptSystem->OnQuestRequireEvent(qst, static_cast< Creature* >( qst_giver ), _player, QUEST_EVENT_CAN_ACCEPT))
		return;*/

	QuestLogEntry *qle = new QuestLogEntry();
	qle->Init(qst, _player, log_slot);
	qle->UpdatePlayerFields();

	// If the quest should give any items on begin, give them the items.
	for(uint32 i = 0; i < 4; ++i)
	{
		if(qst->receive_items[i])
		{
			Item *item = objmgr.CreateItem( qst->receive_items[i], GetPlayer());
			if(!GetPlayer()->GetItemInterface()->AddItemToFreeSlot(item))
			{
				delete item;
			}
			else
				SendItemPushResult(item, false, true, false, true, 
				_player->GetItemInterface()->LastSearchItemBagSlot(), _player->GetItemInterface()->LastSearchItemSlot(),
				1);
		}
	}

	if(qst->srcitem && qst->srcitem != qst->receive_items[0])
	{
		Item * item = objmgr.CreateItem( qst->srcitem, _player );
		if(item)
		{
			item->SetUInt32Value(ITEM_FIELD_STACK_COUNT, qst->srcitemcount ? qst->srcitemcount : 1);
			if(!_player->GetItemInterface()->AddItemToFreeSlot(item))
				delete item;
		}
	}

	// Timed quest handler.
	if(qst->time > 0)
	{
		//Start Quest Timer Event Here
		//sEventMgr.AddEvent(GetPlayer(), &Player::EventTimedQuestExpire, qst, qle, static_cast<uint32>(log_slot), EVENT_TIMED_QUEST_EXPIRE, qst->time * 1000, 1);
		//uint32 qtime = static_cast<uint32>(time(NULL) + qst->time);
		//GetPlayer()->SetUInt32Value(log_slot+2, qtime);
		//GetPlayer()->SetUInt32Value(PLAYER_QUEST_LOG_1_01 + (log_slot * 3), qtime);
		//GetPlayer()->timed_quest_slot = log_slot;
	}

	if(qst->count_required_item || qst_giver->GetTypeId() == TYPEID_GAMEOBJECT)	// gameobject quests deactivate
		GetPlayer()->UpdateNearbyGameObjects();

	//ScriptSystem->OnQuestEvent(qst, static_cast< Creature* >( qst_giver ), _player, QUEST_EVENT_ON_ACCEPT);

	sQuestMgr.OnQuestAccepted(_player,qst,qst_giver);

	sLog.outDebug("WORLD: Added new QLE.");
	sHookInterface.OnQuestAccept(_player, qst);
}
Пример #9
0
        void OnActivate(Player* pPlayer)
        {
            QuestLogEntry* pQuest = pPlayer->GetQuestLogForEntry(10895);
            if(pQuest != NULL)
            {
                // M4ksiu - WTF IS THIS FOR? :|
                float SSX = pPlayer->GetPositionX();
                float SSY = pPlayer->GetPositionY();
                float SSZ = pPlayer->GetPositionZ();

                GameObject* pBeacon = pPlayer->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(SSX, SSY, SSZ, 184661);
                if(pBeacon != NULL && pBeacon->GetFlags() > 0)
                {
                    pBeacon->SetFlags((pBeacon->GetFlags() - 1));
                }

                // Northern Zeth'Gor Tower
                if(pQuest->GetMobCount(0) < pQuest->GetQuest()->required_mobcount[0])
                {
                    GameObject* pNorthern = pPlayer->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(-820.0f, 2029.0f, 55.0f, 300150);
                    if(pNorthern != NULL && pPlayer->CalcDistance(pPlayer, pNorthern) < 40)      // if reduced the server will crash when out of range
                    {
                        pQuest->SetMobCount(0, pQuest->GetMobCount(0) + 1);
                        pQuest->SendUpdateAddKill(0);
                        pQuest->UpdatePlayerFields();

                        GameObject* pGameobject = sEAS.SpawnGameobject(pPlayer, 183816, -819.77f, 2029.09f, 55.6082f, 0, 4, 0, 0, 0, 0);
                        if(pGameobject != NULL)
                        {
                            sEAS.GameobjectDelete(pGameobject, 1 * 60 * 1000);
                        }

                        return;
                    }
                }

                // Southern Zeth'Gor Tower
                if(pQuest->GetMobCount(1) < pQuest->GetQuest()->required_mobcount[1])
                {
                    GameObject* pSouthern = pPlayer->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(-1150.0f, 2110.0f, 84.0f, 300150);
                    if(pSouthern != NULL && pPlayer->CalcDistance(pPlayer, pSouthern) < 40)
                    {
                        pQuest->SetMobCount(1, pQuest->GetMobCount(1) + 1);
                        pQuest->SendUpdateAddKill(1);
                        pQuest->UpdatePlayerFields();

                        GameObject* pGameobject = sEAS.SpawnGameobject(pPlayer, 183816, -1150.53f, 2109.92f, 84.4204f, 0, 4, 0, 0, 0, 0);
                        if(pGameobject != NULL)
                        {
                            sEAS.GameobjectDelete(pGameobject, 1 * 60 * 1000);
                        }

                        return;
                    }
                }

                // Forge Zeth'Gor Tower
                if(pQuest->GetMobCount(2) < pQuest->GetQuest()->required_mobcount[2])
                {
                    GameObject* pForge = pPlayer->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(-893.0f, 1919.0f, 82.0f, 300150);
                    if(pForge != NULL && pPlayer->CalcDistance(pPlayer, pForge) < 40)
                    {
                        pQuest->SetMobCount(2, pQuest->GetMobCount(2) + 1);
                        pQuest->SendUpdateAddKill(2);
                        pQuest->UpdatePlayerFields();

                        GameObject* pGameobject = sEAS.SpawnGameobject(pPlayer, 183816, -893.499f, 1919.27f, 81.6449f, 0, 4, 0, 0, 0, 0);
                        if(pGameobject != NULL)
                        {
                            sEAS.GameobjectDelete(pGameobject, 1 * 60 * 1000);
                        }

                        return;
                    }
                }

                // Foothill Zeth'Gor Tower
                if(pQuest->GetMobCount(3) < pQuest->GetQuest()->required_mobcount[3])
                {
                    GameObject* pFoothill = pPlayer->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(-978.0f, 1879.0f, 111.0f, 300150);
                    if(pFoothill != NULL && pPlayer->CalcDistance(pPlayer, pFoothill) < 40)
                    {
                        pQuest->SetMobCount(3, pQuest->GetMobCount(3) + 1);
                        pQuest->SendUpdateAddKill(3);
                        pQuest->UpdatePlayerFields();

                        GameObject* pGameobject = sEAS.SpawnGameobject(pPlayer, 183816, -977.713f, 1879.500f, 110.892f, 0, 4, 0, 0, 0, 0);
                        if(pGameobject != NULL)
                        {
                            sEAS.GameobjectDelete(pGameobject, 1 * 60 * 1000);
                        }

                        return;
                    }
                }
                else
                {
                    pPlayer->BroadcastMessage("You are to far away!");
                }

            }
            else
            {
                pPlayer->BroadcastMessage("Missing required quest : Zeth'Gor Must Burn");
            }
        }
Пример #10
0
// A Lesson in Fear
bool PlantForsakenBanner(uint32 i, Spell* pSpell)
{
	if(pSpell->u_caster->IsPlayer() == false)
		return true;

	Player *pPlayer = static_cast<Player*>(pSpell->u_caster);
	if( pPlayer == NULL )
		return true;

	QuestLogEntry *pQuest = pPlayer->GetQuestLogForEntry(11282);
	if( pQuest == NULL )
		return true;
	
	Creature*target = static_cast<Creature*>(pSpell->GetUnitTarget());
	if (target == NULL)
		return true;

	float X = target->GetPositionX();
	float Y = target->GetPositionY();
	float Z = target->GetPositionZ();

	uint32 cit = target->GetEntry();
	
	switch(cit)
	{
	case 24161:
		{
			if( pQuest->GetMobCount( 0 ) < pQuest->GetQuest()->required_mobcount[ 0 ] )
			{
				uint32 newcount = pQuest->GetMobCount( 0 ) + 1;
				pQuest->SetMobCount( 0, newcount );
				pQuest->SendUpdateAddKill( 0 );
				pQuest->UpdatePlayerFields();
				target->Despawn(0, 3*60*1000);
			}	
		}
		break;
	case 24016:
		{
			if( pQuest->GetMobCount( 0 ) < pQuest->GetQuest()->required_mobcount[ 1 ] )
			{
				uint32 newcount = pQuest->GetMobCount( 0 ) + 1;
				pQuest->SetMobCount( 0, newcount );
				pQuest->SendUpdateAddKill( 0 );
				pQuest->UpdatePlayerFields();
				target->Despawn(0, 3*60*1000);
			}	
		}
		break;
	case 24162:
		{
			if( pQuest->GetMobCount( 0 ) < pQuest->GetQuest()->required_mobcount[ 2 ] )
			{
				uint32 newcount = pQuest->GetMobCount( 0 ) + 1;
				pQuest->SetMobCount( 0, newcount );
				pQuest->SendUpdateAddKill( 0 );
				pQuest->UpdatePlayerFields();
				target->Despawn(0, 3*60*1000);
			}	
		}
		break;
  }
  return true;
}
Пример #11
0
bool ShipBombing(uint32 i, Spell* pSpell)
{
	Player* pPlayer = TO_PLAYER(pSpell->u_caster);
	if(!pPlayer)
		return true;

	if(!pSpell->u_caster->IsPlayer())
		return true;

	QuestLogEntry *qle = NULL;
	qle = pPlayer->GetQuestLogForEntry(11542);
	if(qle == NULL)
	{
		qle = pPlayer->GetQuestLogForEntry(11543);
		if(qle == NULL)
		{
			return true;
		}
	}
	
	GameObject* pSinloren = pPlayer->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(13200.232422, -7049.176270, 3.838517, 550000);
	GameObject* pBloodoath = pPlayer->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(13319.419922, -6988.779785, 4.002993, 550000);
	GameObject* pDawnchaser = pPlayer->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(13274.51625, -7145.434570, 4.770292, 550000);
	
	GameObject* obj = NULL;

	if(pSinloren != NULL)
	{
		if(qle->GetMobCount(0) < qle->GetQuest()->required_mobcount[0])
		{
			if(pPlayer->CalcDistance(pPlayer, pSinloren) < 15)
			{
				qle->SetMobCount(0, qle->GetMobCount(0)+1);
				qle->SendUpdateAddKill(0);
				qle->UpdatePlayerFields();
				for(uint8 i = 0; i < 2; i++)
				{
					obj = sEAS.SpawnGameobject(pPlayer, GO_FIRE, SinlorenFire[i].x, SinlorenFire[i].y, SinlorenFire[i].z, SinlorenFire[i].o, 1, 0, 0, 0, 0);
					sEAS.GameobjectDelete(obj, 2*60*1000);
				}
			}
		}
	}
	if(pBloodoath != NULL)
	{
		if(qle->GetMobCount(1) < qle->GetQuest()->required_mobcount[1])
		{
			if(pPlayer->CalcDistance(pPlayer, pBloodoath) < 15)
			{
				qle->SetMobCount(1, qle->GetMobCount(1)+1);
				qle->SendUpdateAddKill(1);
				qle->UpdatePlayerFields();
				for(uint8 i = 0; i < 2; i++)
				{
					obj = sEAS.SpawnGameobject(pPlayer, GO_FIRE, BloodoathFire[i].x, BloodoathFire[i].y, BloodoathFire[i].z, BloodoathFire[i].o, 1, 0, 0, 0, 0);
					sEAS.GameobjectDelete(obj, 2*60*1000);
				}
			}
		}
	}
	if(pDawnchaser != NULL)
	{
		if(pPlayer->CalcDistance(pPlayer, pDawnchaser) < 15)
		{
			if(qle->GetMobCount(2) < qle->GetQuest()->required_mobcount[2])
			{
				qle->SetMobCount(2, qle->GetMobCount(2)+1);
				qle->SendUpdateAddKill(2);
				qle->UpdatePlayerFields();
				for(uint8 i = 0; i < 2; i++)
				{
					obj = sEAS.SpawnGameobject(pPlayer, GO_FIRE, DawnchaserFire[i].x, DawnchaserFire[i].y, DawnchaserFire[i].z, DawnchaserFire[i].o, 1, 0, 0, 0, 0);
					sEAS.GameobjectDelete(obj, 2*60*1000);
				}
			}
		}
	}
	return true;
}