Esempio n. 1
0
////////////////////////////////////////////////////////////////////////////////
// 액션을 실행한다.
////////////////////////////////////////////////////////////////////////////////
void ActionDenyReinforce::execute (Creature * pCreature1 , Creature * pCreature2) 
	throw(Error)
{
	__BEGIN_TRY

#ifndef __OLD_GUILD_WAR__

	Assert(pCreature1 != NULL);
	Assert(pCreature2 != NULL);
	Assert(pCreature1->isNPC());
	Assert(pCreature2->isPC());

	SYSTEM_RETURN_IF_NOT(SYSTEM_GUILD_WAR);

	GCNPCResponse gcNPCResponse;

	PlayerCreature* pPC = dynamic_cast<PlayerCreature*>(pCreature2);
	GuildID_t guildID = pPC->getGuildID();

	if (!g_pVariableManager->isWarActive() || !g_pVariableManager->isActiveGuildWar() )
	{
		gcNPCResponse.setCode(NPC_RESPONSE_WAR_UNAVAILABLE);
		pPC->getPlayer()->sendPacket(&gcNPCResponse);
		return;
	}

	if (!g_pGuildManager->isGuildMaster(guildID, pPC ) )
	{
		gcNPCResponse.setCode(NPC_RESPONSE_NOT_GUILD_MASTER);
		pPC->getPlayer()->sendPacket(&gcNPCResponse);
		return;
	}

	Zone* pZone = getZoneByZoneID(m_ZoneID);
	Assert(pZone != NULL);
	Assert(pZone->isCastle());

	WarScheduler* pWarScheduler = pZone->getWarScheduler();
	Assert(pWarScheduler != NULL);

	CastleInfo* pCastleInfo = g_pCastleInfoManager->getCastleInfo(m_ZoneID);
	GuildID_t ownerGuildID = pCastleInfo->getGuildID();

	if (guildID != ownerGuildID )
	{
		gcNPCResponse.setCode(NPC_RESPONSE_NOT_YOUR_CASTLE);
		pPC->getPlayer()->sendPacket(&gcNPCResponse);
		return;
	}

	Schedule* pNextSchedule = pWarScheduler->getRecentSchedule();

	Work* pNextWork = NULL;
	if (pNextSchedule != NULL ) pNextWork = pNextSchedule->getWork();

	SiegeWar* pNextWar = dynamic_cast<SiegeWar*>(pNextWork);

	if (pNextWar == NULL || pNextWar->recentReinforceCandidate() == 0 )
	{
		gcNPCResponse.setCode(NPC_RESPONSE_NO_WAR_REGISTERED);
		pPC->getPlayer()->sendPacket(&gcNPCResponse);

		//SAFE_DELETE(pNextWar);
		return;
	}
	else if (pNextWar->getReinforceGuildID() == 0 )
	{
		WarSchedule* pNextWarSchedule = dynamic_cast<WarSchedule*>(pNextSchedule);
		Assert(pNextWarSchedule != NULL);

		if (!pNextWar->denyReinforce() )
		{
			gcNPCResponse.setCode(NPC_RESPONSE_CANNOT_ACCEPT);
			pPC->getPlayer()->sendPacket(&gcNPCResponse);

			//SAFE_DELETE(pNextWar);
			return;
		}
	}
	else
	{
		gcNPCResponse.setCode(NPC_RESPONSE_ALREADY_REINFORCE_ACCEPTED);
		pPC->getPlayer()->sendPacket(&gcNPCResponse);

		//SAFE_DELETE(pNextWar);
		return;
	}

	gcNPCResponse.setCode(NPC_RESPONSE_ACCEPT_OK);
	pPC->getPlayer()->sendPacket(&gcNPCResponse);

	gcNPCResponse.setCode(NPC_RESPONSE_QUIT_DIALOGUE);
	pPC->getPlayer()->sendPacket(&gcNPCResponse);

	return;

#endif

	__END_CATCH
}
Esempio n. 2
0
////////////////////////////////////////////////////////////////////////////////
// 액션을 실행한다.
////////////////////////////////////////////////////////////////////////////////
void ActionRegisterSiege::execute (Creature * pCreature1 , Creature * pCreature2) 
	throw(Error)
{
	__BEGIN_TRY

#ifndef __OLD_GUILD_WAR__

	Assert(pCreature1 != NULL);
	Assert(pCreature2 != NULL);
	Assert(pCreature1->isNPC());
	Assert(pCreature2->isPC());

	SYSTEM_RETURN_IF_NOT(SYSTEM_GUILD_WAR);

	GCNPCResponse gcNPCResponse;

	PlayerCreature* pPC = dynamic_cast<PlayerCreature*>(pCreature2);
	GuildID_t guildID = pPC->getGuildID();

	if (!g_pVariableManager->isWarActive() || !g_pVariableManager->isActiveGuildWar() )
	{
		gcNPCResponse.setCode(NPC_RESPONSE_WAR_UNAVAILABLE);
		pPC->getPlayer()->sendPacket(&gcNPCResponse);
		return;
	}

	if (!g_pGuildManager->isGuildMaster(guildID, pPC ) )
	{
		gcNPCResponse.setCode(NPC_RESPONSE_NOT_GUILD_MASTER);
		pPC->getPlayer()->sendPacket(&gcNPCResponse);
		return;
	}

	Gold_t warRegistrationFee = g_pVariableManager->getVariable(WAR_REGISTRATION_FEE);
	if (pPC->getGold() < warRegistrationFee )
	{
		gcNPCResponse.setCode(NPC_RESPONSE_NOT_ENOUGH_MONEY);
		pPC->getPlayer()->sendPacket(&gcNPCResponse);
		return;
	}

	Zone* pZone = getZoneByZoneID(m_ZoneID);
	Assert(pZone != NULL);
	Assert(pZone->isCastle());

	WarScheduler* pWarScheduler = pZone->getWarScheduler();
	Assert(pWarScheduler != NULL);

	/* 성을 소유했어도 전쟁 신청이 되도록 수정함 (자기 성에는 신청 못하겠지 -_-;;)
	// 이미 성을 소유한 길드인가?
	if (g_pGuildManager->hasCastle(guildID ) )
	{
		gcNPCResponse.setCode(NPC_RESPONSE_ALREADY_HAS_CASTLE);
		pPC->getPlayer()->sendPacket(&gcNPCResponse);
		return;
	}
	*/

//	ServerID_t serverID;
//	ZoneID_t zoneID;
//	bool bHasCastle = g_pGuildManager->hasCastle(guildID , serverID , zoneID);

//	if (bHasCastle && serverID == g_pConfig->getPropertyInt("ServerID" ) && zoneID == m_ZoneID )

	CastleInfo* pCastleInfo = g_pCastleInfoManager->getCastleInfo(m_ZoneID);
	GuildID_t ownerGuildID = pCastleInfo->getGuildID();

	if (guildID == ownerGuildID )
	{
		gcNPCResponse.setCode(NPC_RESPONSE_ALREADY_HAS_CASTLE);
		pPC->getPlayer()->sendPacket(&gcNPCResponse);
		return;
	}

	// 이미 전쟁 신청을 했는가?
	if (g_pGuildManager->hasWarSchedule(guildID ) )
	{
		gcNPCResponse.setCode(NPC_RESPONSE_WAR_ALREADY_REGISTERED);
		pPC->getPlayer()->sendPacket(&gcNPCResponse);
		return;
	}

	// 전쟁 스케쥴이 다 찼는가?
/*	if (!pWarScheduler->canAddWar(WAR_GUILD ) )
	{
		gcNPCResponse.setCode(NPC_RESPONSE_WAR_SCHEDULE_FULL);
		pPC->getPlayer()->sendPacket(&gcNPCResponse);
		return;
	}

	GuildWar* pWar = new GuildWar(m_ZoneID, guildID, War::WAR_STATE_WAIT);

	pWar->setRegistrationFee(warRegistrationFee);

	if (!pWarScheduler->addWar(pWar ) )
	{
		gcNPCResponse.setCode(NPC_RESPONSE_WAR_SCHEDULE_FULL);
		pPC->getPlayer()->sendPacket(&gcNPCResponse);

		SAFE_DELETE(pWar);
		return;
	}*/

	Schedule* pNextSchedule = pWarScheduler->getRecentSchedule();

	Work* pNextWork = NULL;
	if (pNextSchedule != NULL ) pNextWork = pNextSchedule->getWork();

	SiegeWar* pNextWar = dynamic_cast<SiegeWar*>(pNextWork);

	if (pNextWar == NULL )
	{
		pNextWar = new SiegeWar(m_ZoneID, War::WAR_STATE_WAIT);
		pNextWar->addRegistrationFee(warRegistrationFee);
		pNextWar->addChallengerGuild(guildID);

		if (!pWarScheduler->addWar(pNextWar ) )
		{
			gcNPCResponse.setCode(NPC_RESPONSE_WAR_SCHEDULE_FULL);
			pPC->getPlayer()->sendPacket(&gcNPCResponse);

			SAFE_DELETE(pNextWar);
			return;
		}
	}
	else if (pNextWar->getChallengerGuildCount() < 5 )
	{
		WarSchedule* pNextWarSchedule = dynamic_cast<WarSchedule*>(pNextSchedule);
		Assert(pNextWarSchedule != NULL);

		pNextWar->addRegistrationFee(warRegistrationFee);
		pNextWar->addChallengerGuild(guildID);
		pNextWarSchedule->save();
	}
	else
	{
		gcNPCResponse.setCode(NPC_RESPONSE_WAR_SCHEDULE_FULL);
		pPC->getPlayer()->sendPacket(&gcNPCResponse);

//		SAFE_DELETE(pNextWar);
		return;
	}

	pPC->decreaseGoldEx(warRegistrationFee);

	GCModifyInformation gcMI;
	gcMI.addLongData(MODIFY_GOLD, pPC->getGold());
	pPC->getPlayer()->sendPacket(&gcMI);

	gcNPCResponse.setCode(NPC_RESPONSE_WAR_REGISTRATION_OK);
	pPC->getPlayer()->sendPacket(&gcNPCResponse);
	return;

#endif

	__END_CATCH
}
Esempio n. 3
0
////////////////////////////////////////////////////////////////////////////////
// 액션을 실행한다.
////////////////////////////////////////////////////////////////////////////////
void ActionEnterSiege::execute (Creature * pNPC , Creature * pCreature) 
	throw(Error)
{
	__BEGIN_TRY
	__BEGIN_DEBUG

	Assert(pCreature != NULL);
	Assert(pCreature->isPC());

	GamePlayer* pGamePlayer = dynamic_cast<GamePlayer*>(pCreature->getPlayer());
	if (!g_pWarSystem->hasCastleActiveWar(m_ZoneID ) )
	{
		GCSystemMessage gcSM;
		gcSM.setMessage("공선전 중에만 입장하실 수 있습니다.");
		pGamePlayer->sendPacket(&gcSM);
		return;
	}

	PlayerCreature* pPC = dynamic_cast<PlayerCreature*>(pCreature);

	Assert(pPC != NULL);

	Zone* pZone = getZoneByZoneID(m_ZoneID);
	Assert(pZone != NULL);

	WarScheduler* pWS = pZone->getWarScheduler();
	Assert(pWS != NULL);

	ZoneID_t siegeZoneID = SiegeManager::Instance().getSiegeZoneID(m_ZoneID);
	Assert(siegeZoneID != 0);

/*	WarSchedule* pSchedule = dynamic_cast<WarSchedule*>(pWS->getRecentSchedule());
	if (pSchedule == NULL )
	{
		return;
	}*/

	SiegeWar* pSiegeWar = dynamic_cast<SiegeWar*>(g_pWarSystem->getActiveWar(m_ZoneID ));
	if (pSiegeWar == NULL )
	{
		GCSystemMessage gcSM;
		gcSM.setMessage("타입 1 서버 오류입니다. 운영팀에 문의하세요.");
		pGamePlayer->sendPacket(&gcSM);
		return;
	}

	int side = pSiegeWar->getGuildSide(pPC->getGuildID());
	if (side == 0 )
	{
		GCSystemMessage gcSM;
		gcSM.setMessage("전쟁에 참가한 길드가 아닙니다.");
		pGamePlayer->sendPacket(&gcSM);
		return;
	}
	
	if (!g_pGuildManager->isGuildMaster(pPC->getGuildID(), pPC ) )
	{
		GCSystemMessage gcSM;
		gcSM.setMessage("길드 마스터만 가능합니다.");
		pGamePlayer->sendPacket(&gcSM);
		return;
	}

	static TPOINT targetPos[7] =
	{
		{172, 38},
		{172, 38},
		{20, 232},
		{20, 232},
		{20, 232},
		{20, 232},
		{20, 232}
	};

	// 소환자의 존과 좌표.
	ZoneID_t ZoneNum = siegeZoneID;
	Coord_t ZoneX = targetPos[side-1].x;
	Coord_t ZoneY = targetPos[side-1].y;

	for (int i=0; i<7; ++i )
	{
		deleteCreatureEffect(pPC, (Effect::EffectClass)(Effect::EFFECT_CLASS_SIEGE_DEFENDER + i));
	}

	if (side < 8 && side > 0 )
	{
		//cout << "side : " << side << endl;
		addSimpleCreatureEffect(pPC, (Effect::EffectClass)(Effect::EFFECT_CLASS_SIEGE_DEFENDER + side - 1));
	}

	EventTransport* pEvent = dynamic_cast<EventTransport*>(pGamePlayer->getEvent(Event::EVENT_CLASS_TRANSPORT));
	bool newEvent = false;
	if (pEvent==NULL)
	{
		pEvent = new EventTransport(pGamePlayer);
		newEvent = true;
	}

//		pEvent = new EventTransport(pGamePlayer);
	pEvent->setTargetZone(ZoneNum, ZoneX, ZoneY);
	pEvent->setDeadline(0);

	if (newEvent )
		pGamePlayer->addEvent(pEvent);

	__END_DEBUG
	__END_CATCH
}