Show
Ignore:
Timestamp:
11/19/08 13:49:07 (17 years ago)
Author:
yumileroy
Message:

[svn] * Reimplemented packet/update forwarding in more generic way
* Implemented far sight spells (Far Sight, Eagle Eye, etc) at unlimited range and properly forward packets
* Implemented bind vision spells (Mind Vision, etc) to forward packets at unlimited distance
* Implemented Sentry Totem (both vision switching/forwarding and alerting)
* Other misc possession fixes
* Added .bindsight and .unbindsight commands

Please test out the above spells (including Mind Control) and report any issues on the forums.

Original author: gvcoman
Date: 2008-11-14 20:40:35-06:00

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/Player.cpp

    r230 r233  
    428428 
    429429    m_isActive = true; 
     430 
     431    m_farsightVision = false; 
    430432} 
    431433 
     
    12921294        RemoveGuardians(); 
    12931295 
     1296        // remove possession 
     1297        if(isPossessing()) 
     1298            RemovePossess(false); 
     1299        else 
     1300            RemoveFarsightTarget(); 
     1301 
    12941302        // save value before aura remove in Unit::setDeathState 
    12951303        ressSpellId = GetUInt32Value(PLAYER_SELF_RES_SPELL); 
     
    15451553        ((Player*)GetCharmer())->RemovePossess(); 
    15461554 
    1547     // The player was ported to another map and looses the duel immediately. 
     1555    // Remove player's possession before teleporting 
     1556    if (isPossessing()) 
     1557        RemovePossess(false); 
     1558 
     1559    // Empty vision list and clear farsight (if it hasn't already been cleared by RemovePossess) before teleporting 
     1560    RemoveAllFromVision(); 
     1561    RemoveFarsightTarget(); 
     1562 
     1563    // The player was ported to another map and looses the duel immediatly. 
    15481564    // We have to perform this check before the teleport, otherwise the 
    15491565    // ObjectAccessor won't find the flag. 
     
    17631779        RemoveMiniPet(); 
    17641780        RemoveGuardians(); 
     1781        RemoveFarsightTarget(); 
    17651782    } 
    17661783 
     
    1729417311        return false; 
    1729517312 
    17296     // If the player is currently possessing, update visibility from the possessed unit's location 
    17297     const Unit* target = isPossessing() ? GetCharm() : this; 
     17313    // If the player is currently channeling vision, update visibility from the target unit's location 
     17314    const WorldObject* target = GetFarsightTarget(); 
     17315    if (!target || !HasFarsightVision()) // Vision needs to be on the farsight target 
     17316        target = this; 
    1729817317 
    1729917318    // different visible distance checks 
     
    1874418763    SetPossessedTarget(target); 
    1874518764 
     18765    // Start channeling packets to possessor 
     18766    target->AddPlayerToVision(this); 
     18767 
    1874618768    target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, getFaction()); 
    1874718769    target->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); 
     
    1874918771    target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); 
    1875018772    SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE); 
    18751     SetUInt64Value(PLAYER_FARSIGHT, target->GetGUID()); 
    1875218773 
    1875318774    if(target->GetTypeId() == TYPEID_UNIT) 
    1875418775    { 
    18755         // Set target to active in the grid and place it in the world container to be picked up by all regular player cell visits 
    18756         Map* map = target->GetMap(); 
    18757         map->SwitchGridContainers((Creature*)target, true); 
    18758         target->setActive(true); 
    18759  
    1876018776        ((Creature*)target)->InitPossessedAI(); // Initialize the possessed AI 
    1876118777        target->StopMoving(); 
     
    1881018826    RemovePossessedTarget(); 
    1881118827 
     18828    // Stop channeling packets back to possessor 
     18829    target->RemovePlayerFromVision(this); 
     18830 
    1881218831    if(target->GetTypeId() == TYPEID_PLAYER) 
    1881318832        ((Player*)target)->setFactionForRace(target->getRace()); 
    1881418833    else if(target->GetTypeId() == TYPEID_UNIT) 
    1881518834    { 
    18816         // Set creature to inactive in grid and place it back into the grid container 
    18817         Map* map = target->GetMap(); 
    18818         target->setActive(false); 
    18819         map->SwitchGridContainers((Creature*)target, false); 
    18820  
    1882118835        if(((Creature*)target)->isPet()) 
    1882218836        { 
     
    1883218846    target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNKNOWN5); 
    1883318847    RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE); 
    18834     SetUInt64Value(PLAYER_FARSIGHT, 0); 
    1883518848 
    1883618849    // Remove pet spell action bar 
     
    1889818911} 
    1889918912 
     18913WorldObject* Player::GetFarsightTarget() const 
     18914{ 
     18915    // Players can have in farsight field another player's guid, a creature's guid, or a dynamic object's guid 
     18916    if (uint64 guid = GetUInt64Value(PLAYER_FARSIGHT)) 
     18917        return (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*this, guid, TYPEMASK_PLAYER | TYPEMASK_UNIT | TYPEMASK_DYNAMICOBJECT); 
     18918    return NULL; 
     18919} 
     18920 
     18921void Player::RemoveFarsightTarget() 
     18922{ 
     18923    if (WorldObject* fTarget = GetFarsightTarget()) 
     18924    { 
     18925        if (fTarget->isType(TYPEMASK_PLAYER | TYPEMASK_UNIT)) 
     18926            ((Unit*)fTarget)->RemovePlayerFromVision(this); 
     18927    } 
     18928    ClearFarsight(); 
     18929} 
     18930 
     18931void Player::ClearFarsight() 
     18932{ 
     18933    if (GetUInt64Value(PLAYER_FARSIGHT)) 
     18934    { 
     18935        SetUInt64Value(PLAYER_FARSIGHT, 0); 
     18936        WorldPacket data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE, 0); 
     18937        GetSession()->SendPacket(&data); 
     18938    } 
     18939} 
     18940 
     18941void Player::SetFarsightTarget(WorldObject* obj) 
     18942{ 
     18943    if (!obj || !obj->isType(TYPEMASK_PLAYER | TYPEMASK_UNIT | TYPEMASK_DYNAMICOBJECT)) 
     18944        return; 
     18945 
     18946    // Remove the current target if there is one 
     18947    RemoveFarsightTarget(); 
     18948 
     18949    SetUInt64Value(PLAYER_FARSIGHT, obj->GetGUID()); 
     18950} 
     18951 
    1890018952bool Player::isAllowUseBattleGroundObject() 
    1890118953{