Exemple #1
0
inline bool MtgCard::operator==(const MtgCard& rhs) {
    return GetLayout() == rhs.GetLayout() &&
            GetManacost() == rhs.GetManacost() &&
            GetCmc() == rhs.GetCmc() &&
            CompareStringList(GetColors(), rhs.GetColors()) &&
            type == rhs.type &&
            CompareStringList(GetSupertypes(), rhs.GetSupertypes()) &&
            CompareStringList(GetTypes(), rhs.GetTypes()) &&
            CompareStringList(GetSubtypes(), rhs.GetSubtypes()) &&
            GetRarity() == rhs.GetRarity() &&
            text == rhs.GetText() &&
            GetFlavor() == rhs.GetFlavor() &&
            GetArtist() == rhs.GetArtist() &&
            GetNumber() == rhs.GetNumber() &&
            GetPower() == rhs.GetPower() &&
            GetToughness() == rhs.GetToughness() &&
            GetLoyalty() == rhs.GetLoyalty() &&
            GetMultiverseid() == rhs.GetMultiverseid() &&
            CompareIntList(GetVariations(), rhs.GetVariations()) &&
            GetImageName() == rhs.GetImageName() &&
            GetWatermark() == rhs.GetWatermark() &&
            GetBorder() == rhs.GetBorder() &&
            IsTimeshifted() == rhs.IsTimeshifted() &&
            GetHand() == rhs.GetHand() &&
            GetLife() == rhs.GetLife() &&
            IsReserved() == rhs.IsReserved() &&
            GetReleasedate() == rhs.GetReleasedate() &&
            IsStarter() == rhs.IsStarter() &&
            CompareStringPairList(GetRulings(), rhs.GetRulings()) &&
            CompareStringPairList(GetForeignNames(), rhs.GetForeignNames()) &&
            GetOriginalText() == rhs.GetOriginalText() &&
            GetOriginalType() == rhs.GetOriginalType() &&
            CompareStringPairList(GetLegalities(), rhs.GetLegalities()) &&
            GetEdition() == rhs.GetEdition();
}
void CUser::Regene(uint8 regene_type, uint32 magicid /*= 0*/)
{
	ASSERT(GetMap() != nullptr);

	_OBJECT_EVENT* pEvent = nullptr;
	_HOME_INFO* pHomeInfo = nullptr;
	float x = 0.0f, z = 0.0f;

	if (!isDead())
		return;

	if (regene_type != 1 && regene_type != 2)
		regene_type = 1;

	if (regene_type == 2) 
	{
		magicid = 490041;	// The Stone of Ressurection magic ID

		// Is our level high enough to be able to resurrect using this skill?
		if (GetLevel() <= 5
			// Do we have enough resurrection stones?
				|| !RobItem(379006000, 3 * GetLevel()))
				return;
	}

	// If we're in a home zone, we'll want the coordinates from there. Otherwise, assume our own home zone.
	pHomeInfo = g_pMain->m_HomeArray.GetData(GetZoneID() <= ZONE_ELMORAD ? GetZoneID() : GetNation());
	if (pHomeInfo == nullptr)
		return;

	UserInOut(INOUT_OUT);

	pEvent = GetMap()->GetObjectEvent(m_sBind);	

	// If we're not using a spell to resurrect.
	if (magicid == 0) 
	{
		// Resurrect at a bind/respawn point
		if (pEvent != nullptr && pEvent->byLife == 1)
		{
			SetPosition(pEvent->fPosX + x, 0.0f, pEvent->fPosZ + z);
		}
		// Are we trying to respawn in a home zone?
		else if (GetZoneID() <= ZONE_ELMORAD) 
		{
			// Use the proper respawn area for our nation, as the opposite nation can
			// enter this zone at a war's invasion stage.
			if (GetNation() == KARUS) 
			{
				x = (float)(pHomeInfo->KarusZoneX + myrand(0, pHomeInfo->KarusZoneLX));
				z = (float)(pHomeInfo->KarusZoneZ + myrand(0, pHomeInfo->KarusZoneLZ));			
			}
			else 
			{
				x = (float)(pHomeInfo->ElmoZoneX + myrand(0, pHomeInfo->ElmoZoneLX));
				z = (float)(pHomeInfo->ElmoZoneZ + myrand(0, pHomeInfo->ElmoZoneLZ));
			}		
		}
		else
		{
			// If we're in a war zone (aside from snow wars, which apparently use different coords), use BattleZone coordinates.
			if (GetZoneID() != ZONE_SNOW_BATTLE 
				&& GetZoneID() == (ZONE_BATTLE_BASE + g_pMain->m_byBattleZone))
			{
				x = (float)(pHomeInfo->BattleZoneX + myrand(0, pHomeInfo->BattleZoneLX));
				z = (float)(pHomeInfo->BattleZoneZ + myrand(0, pHomeInfo->BattleZoneLZ));
			}
			// If we died in the Moradon arena, we need to spawn near the Arena.
			else if (GetZoneID() == ZONE_MORADON && isInArena())
			{
				x = (float)(MINI_ARENA_RESPAWN_X + myrand(-MINI_ARENA_RESPAWN_RADIUS, MINI_ARENA_RESPAWN_RADIUS));
				z = (float)(MINI_ARENA_RESPAWN_Z + myrand(-MINI_ARENA_RESPAWN_RADIUS, MINI_ARENA_RESPAWN_RADIUS));
			}
			// For all else, just grab the start position (/town coordinates) from the START_POSITION table.
			else
			{
				short sx, sz;
				GetStartPosition(sx, sz);

				x = sx;
				z = sz;
			}
		}

		SetPosition(x, 0.0f, z);

		m_bResHpType = USER_STANDING;	
		m_bRegeneType = REGENE_NORMAL;
	}
	else // we're respawning using a resurrect skill.
	{
		_MAGIC_TYPE5 * pType = g_pMain->m_Magictype5Array.GetData(magicid);     
		if (pType == nullptr)
			return;

		MSpChange(-m_iMaxMp); // reset us to 0 MP. 

		if (m_sWhoKilledMe == -1) 
			ExpChange((m_iLostExp * pType->bExpRecover) / 100); // Restore 

		m_bResHpType = USER_STANDING;
		m_bRegeneType = REGENE_MAGIC;
	}

	Packet result(WIZ_REGENE);
	result << GetSPosX() << GetSPosZ() << GetSPosY();
	Send(&result);

	HpChange(GetMaxHealth());

	m_tLastRegeneTime = UNIXTIME;
	m_sWhoKilledMe = -1;
	m_iLostExp = 0;

	if (magicid == 0)
		BlinkStart();

	if (!isBlinking())
	{
		result.Initialize(AG_USER_REGENE);
		result << GetSocketID() << m_sHp;
		Send_AIServer(&result);
	}

	SetRegion(GetNewRegionX(), GetNewRegionZ());

	UserInOut(INOUT_RESPAWN);		

	g_pMain->RegionUserInOutForMe(this);
	g_pMain->RegionNpcInfoForMe(this);

	InitializeStealth();
	SendUserStatusUpdate(USER_STATUS_DOT, USER_STATUS_CURE);
	SendUserStatusUpdate(USER_STATUS_POISON, USER_STATUS_CURE);

	if (isInArena())
		SendUserStatusUpdate(USER_STATUS_SPEED, USER_STATUS_CURE);

	RecastSavedMagic();

	// If we actually respawned (i.e. we weren't resurrected by a skill)...
	if (magicid == 0)
	{
		// In PVP zones (not war zones), we must kick out players if they no longer
		// have any national points.
		if (GetMap()->isNationPVPZone() 
			&& GetMap()->isWarZone()
			&& GetLoyalty() == 0)
			KickOutZoneUser(false);
	}
}
bool CUser::CanChangeZone(C3DMap * pTargetMap, ZoneChangeError & errorReason)
{
	// While unofficial, game masters should be allowed to teleport anywhere.
	if (isGM())
		return true;

	// Generic error reason; this should only be checked when the method returns false.
	errorReason = ZoneChangeErrorGeneric;

	// Ensure the user meets the zone's level requirements
	if (GetLevel() < pTargetMap->GetMinLevelReq()
		|| GetLevel() > pTargetMap->GetMaxLevelReq())
	{
		errorReason = ZoneChangeErrorWrongLevel;
		return false;
	}

	switch (pTargetMap->GetID())
	{
	case ZONE_ELMORAD:
	case ZONE_KARUS:
		// Users may enter Luferson (1)/El Morad (2) if they are that nation, 
		if (GetNation() == pTargetMap->GetID())
			return true;

		// Users may also enter if there's a war invasion happening in that zone.
		if (GetNation() == KARUS)
			return g_pMain->m_byElmoradOpenFlag;
		else
			return g_pMain->m_byKarusOpenFlag;

	case ZONE_KARUS_ESLANT:
		return GetNation() == KARUS;

	case ZONE_ELMORAD_ESLANT:
		return GetNation() == ELMORAD;

	// Delos (30) may be entered by anybody, unless CSW is started -- in which case, it should only allow members of the clans competing for the castle (right?).
	case ZONE_DELOS: // TO-DO: implement CSW logic
		return true;

	// Bifrost (31) may only be entered if the zone is open by the event. 
	// If it's open, it should only be open for the zone in control of the monument in the first stage. 
	// After that, it's open to both zones (note: this extended logic won't be implemented until we actually implement the event -- #84).
	case ZONE_BIFROST: // TO-DO: implement Bifrost logic
		return true;

	case ZONE_RONARK_LAND:
	case ZONE_ARDREAM:
		// PVP zones such as Ronark Land/Ardream (do we include both?) may only be entered if a war is not started. 
		if (g_pMain->m_byBattleOpen != NO_BATTLE)
		{
			errorReason = ZoneChangeErrorWarActive;
			return false;
		}

		// They may also not be entered if the user has no NP.
		if (GetLoyalty() <= 0)
		{
			errorReason = ZoneChangeErrorNeedLoyalty;
			return false;
		}
		break;

	default:
		// War zones may only be entered if that war zone is active.
		if (pTargetMap->isWarZone())
		{
			if ((ZONE_BATTLE_BASE - pTargetMap->GetID()) != g_pMain->m_byBattleZone)
				return false;
		}
	}

	return true;
}