All pastes #338365 Raw Edit

Untitled

public text v1 · immutable
·published 2007-02-03 11:11 UTC
rendered paste body
void Player::UpdatePvPArea()
{
    PvPArea * oldArea = currentPVPArea;

    currentPVPArea = ObjectMgr::getSingleton().GetPvPArea(m_AreaID);
    if(currentPVPArea == oldArea ||
        currentPVPArea == 0 || !currentPVPArea->AreaId)
    {
        // Someone is too lazy to extract adt, or they haven't filled in the info in the table.
        return;
    }

    // This is where all the magic happens :P
    if(currentPVPArea->HomeFor(this))
    {
        if(IsPvPFlagged())
        {
            // I'm flagged and I just walked into a zone of my type. Start the 5min counter.
            ResetPvPTimer();
        }
    }
    else
    {
        // I just walked into either an enemies town, or a contested zone.
        // Force flag me if i'm not already.
        if(!IsPvPFlagged()) SetPvPFlag();
    }
}

void Player::LoginPvPSetup()
{
    // Make sure we know our area ID.
    _EventExploration();

    // Lazy bastards..
    if(currentPVPArea == 0)
        return;

    // If we're not in the home area for our faction, add a honorless target
    // buff to avoid ganking.
    if(!currentPVPArea->HomeFor(this))
        CastSpell(this, PLAYER_HONORLESS_TARGET_SPELL, true);
}

void Player::PvPToggle()
{
    if(m_pvpTimer > 0)
    {
        // Means that we typed /pvp while we were "cooling down". Stop the timer.
        StopPvPTimer();
    }
    else
    {
        uint32 AreaType = AREA_CONTESTED;
        if(currentPVPArea)
            AreaType = currentPVPArea->PvPType;

        // Can't modify flags in a contested area.
        if(AreaType == AREA_CONTESTED)
            return;

        if(IsPvPFlagged())
        {
            // Start the "cooldown" timer.
            ResetPvPTimer();
        }
        else
        {
            // Move into PvP state.
            StopPvPTimer();
            SetPvPFlag();
        }        
    }