diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game/Map.cpp | 2 | ||||
-rw-r--r-- | src/game/MovementHandler.cpp | 7 | ||||
-rw-r--r-- | src/game/Object.cpp | 29 | ||||
-rw-r--r-- | src/game/Player.cpp | 69 | ||||
-rw-r--r-- | src/game/Spell.cpp | 2 | ||||
-rw-r--r-- | src/game/SpellEffects.cpp | 1 | ||||
-rw-r--r-- | src/game/Unit.cpp | 10 | ||||
-rw-r--r-- | src/game/Unit.h | 2 |
8 files changed, 76 insertions, 46 deletions
diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 4aa6494ac5d..ac81b9c2a6d 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -723,7 +723,7 @@ void Map::Update(const uint32 &t_diff) } } - if(plr->m_seer != plr) + if(plr->m_seer != plr && !plr->hasUnitState(UNIT_STAT_ONVEHICLE)) { Trinity::PlayerVisibilityNotifier notifier(*plr); VisitAll(plr->m_seer->GetPositionX(), plr->m_seer->GetPositionY(), World::GetMaxVisibleDistance(), notifier); diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp index 69a8572e7a5..560fb4d651e 100644 --- a/src/game/MovementHandler.cpp +++ b/src/game/MovementHandler.cpp @@ -294,7 +294,12 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data ) else // creature charmed { if(Map *map = mover->GetMap()) + { + //if(GetPlayer()->m_seer != mover) + if(((Creature*)mover)->isVehicle()) + map->PlayerRelocation(GetPlayer(), movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o); map->CreatureRelocation((Creature*)mover, movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o); + } mover->SetUnitMovementFlags(movementInfo.flags); } } @@ -435,8 +440,6 @@ void WorldSession::HandleDismissControlledVehicle(WorldPacket &recv_data) if(Vehicle *vehicle = ObjectAccessor::GetVehicle(vehicleGUID)) { _player->ExitVehicle(vehicle); - if(!vehicle->GetDBTableGUIDLow()) - vehicle->Dismiss(); } } diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 32a5d61a918..8aadd510fa9 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -286,7 +286,7 @@ void Object::_BuildMovementUpdate(ByteBuffer * data, uint8 flags, uint32 flags2) { flags2 = ((Player*)this)->GetUnitMovementFlags(); - if(((Player*)this)->GetTransport()) + if(((Player*)this)->GetTransport() || ((Player*)this)->hasUnitState(UNIT_STAT_ONVEHICLE)) flags2 |= MOVEMENTFLAG_ONTRANSPORT; else flags2 &= ~MOVEMENTFLAG_ONTRANSPORT; @@ -336,7 +336,10 @@ void Object::_BuildMovementUpdate(ByteBuffer * data, uint8 flags, uint32 flags2) { if(GetTypeId() == TYPEID_PLAYER) { - *data << (uint64)((Player*)this)->GetTransport()->GetGUID(); + if(((Player*)this)->hasUnitState(UNIT_STAT_ONVEHICLE)) + *data << (uint64)((Player*)this)->GetCharmGUID(); + else + *data << (uint64)((Player*)this)->GetTransport()->GetGUID(); *data << (float)((Player*)this)->GetTransOffsetX(); *data << (float)((Player*)this)->GetTransOffsetY(); *data << (float)((Player*)this)->GetTransOffsetZ(); @@ -1619,7 +1622,17 @@ void WorldObject::BuildHeartBeatMsg(WorldPacket *data) const *data << m_positionY; *data << m_positionZ; *data << m_orientation; - *data << uint32(0); + if(GetTypeId() == TYPEID_PLAYER && ((Unit*)this)->hasUnitState(UNIT_STAT_ONVEHICLE)) + { + *data << uint64(((Unit*)this)->GetCharmGUID()); + *data << float(((Player*)this)->GetTransOffsetX()); + *data << float(((Player*)this)->GetTransOffsetY()); + *data << float(((Player*)this)->GetTransOffsetZ()); + *data << float(((Player*)this)->GetTransOffsetO()); + *data << uint32(((Player*)this)->GetTransTime()); + *data << uint8(((Player*)this)->GetTransSeat()); + } + *data << uint32(0); //fall time } void WorldObject::BuildTeleportAckMsg(WorldPacket *data, float x, float y, float z, float ang) const @@ -1638,6 +1651,16 @@ void WorldObject::BuildTeleportAckMsg(WorldPacket *data, float x, float y, float *data << y; *data << z; *data << ang; + if(GetTypeId() == TYPEID_PLAYER && ((Unit*)this)->hasUnitState(UNIT_STAT_ONVEHICLE)) + { + *data << uint64(((Unit*)this)->GetCharmGUID()); + *data << float(((Player*)this)->GetTransOffsetX()); + *data << float(((Player*)this)->GetTransOffsetY()); + *data << float(((Player*)this)->GetTransOffsetZ()); + *data << float(((Player*)this)->GetTransOffsetO()); + *data << uint32(((Player*)this)->GetTransTime()); + *data << uint8(((Player*)this)->GetTransSeat()); + } *data << uint32(0); } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index ef695df5f7b..2064a6b6f3c 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -19750,37 +19750,31 @@ void Player::EnterVehicle(Vehicle *vehicle) StopCastingCharm(); StopCastingBindSight(); + SetCharm(vehicle, true); SetViewpoint(vehicle, true); SetMover(vehicle); - SetClientControl(vehicle, 1); // redirect controls to vehicle + addUnitState(UNIT_STAT_ONVEHICLE); + Relocate(vehicle->GetPositionX(), vehicle->GetPositionY(), vehicle->GetPositionZ(), vehicle->GetOrientation()); + AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT); + m_movementInfo.t_x = veSeat->m_attachmentOffsetX; + m_movementInfo.t_y = veSeat->m_attachmentOffsetY; + m_movementInfo.t_z = veSeat->m_attachmentOffsetZ; + m_movementInfo.t_o = 0; + m_movementInfo.t_time = getMSTime(); + m_movementInfo.t_seat = 0; + WorldPacket data(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA, 0); GetSession()->SendPacket(&data); - data.Initialize(MSG_MOVE_TELEPORT_ACK, 30); - data.append(GetPackGUID()); - data << uint32(0); // counter? - data << uint32(MOVEMENTFLAG_ONTRANSPORT); // transport - data << uint16(0); // special flags - data << uint32(getMSTime()); // time - data << vehicle->GetPositionX(); // x - data << vehicle->GetPositionY(); // y - data << vehicle->GetPositionZ(); // z - data << vehicle->GetOrientation(); // o - // transport part, TODO: load/calculate seat offsets - data << uint64(vehicle->GetGUID()); // transport guid - data << float(veSeat->m_attachmentOffsetX); // transport offsetX - data << float(veSeat->m_attachmentOffsetY); // transport offsetY - data << float(veSeat->m_attachmentOffsetZ); // transport offsetZ - data << float(0); // transport orientation - data << uint32(getMSTime()); // transport time - data << uint8(0); // seat - // end of transport part - data << uint32(0); // fall time + BuildTeleportAckMsg(&data, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); GetSession()->SendPacket(&data); + BuildHeartBeatMsg(&data); + SendMessageToSet(&data, false); + VehicleSpellInitialize(); } @@ -19793,29 +19787,36 @@ void Player::ExitVehicle(Vehicle *vehicle) SetCharm(vehicle, false); SetViewpoint(vehicle, false); SetMover(this); - SetClientControl(vehicle, 0); - WorldPacket data(MSG_MOVE_TELEPORT_ACK, 30); - data.append(GetPackGUID()); - data << uint32(0); // counter? - data << uint32(MOVEMENTFLAG_FLY_UNK1); // fly unk - data << uint16(0x40); // special flags - data << uint32(getMSTime()); // time - data << vehicle->GetPositionX(); // x - data << vehicle->GetPositionY(); // y - data << vehicle->GetPositionZ(); // z - data << vehicle->GetOrientation(); // o - data << uint32(0); // fall time + clearUnitState(UNIT_STAT_ONVEHICLE); + Relocate(vehicle->GetPositionX(), vehicle->GetPositionY(), vehicle->GetPositionZ(), vehicle->GetOrientation()); + RemoveUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT); + m_movementInfo.t_x = 0; + m_movementInfo.t_y = 0; + m_movementInfo.t_z = 0; + m_movementInfo.t_o = 0; + m_movementInfo.t_time = 0; + m_movementInfo.t_seat = 0; + + WorldPacket data; + BuildTeleportAckMsg(&data, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); GetSession()->SendPacket(&data); + BuildHeartBeatMsg(&data); + SendMessageToSet(&data, false); + data.Initialize(SMSG_PET_SPELLS, 8+4); data << uint64(0); data << uint32(0); GetSession()->SendPacket(&data); // only for flyable vehicles? - CastSpell(this, 45472, true); // Parachute + //CastSpell(this, 45472, true); // Parachute + + //if(!vehicle->GetDBTableGUIDLow()) + if(vehicle->GetOwnerGUID() == GetGUID()) + vehicle->Dismiss(); } bool Player::isTotalImmune() diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index a2c6ae6dfee..c5646311c2d 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -3704,7 +3704,7 @@ SpellCastResult Spell::CheckCast(bool strict) return SPELL_FAILED_TARGET_AURASTATE; // Not allow casting on flying player - if (target->isInFlight()) + if (target->hasUnitState(UNIT_STAT_UNATTACKABLE)) return SPELL_FAILED_BAD_TARGETS; if(!m_IsTriggeredSpell && VMAP::VMapFactory::checkSpellForLoS(m_spellInfo->Id) && !m_caster->IsWithinLOSInMap(target)) diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 810931c5229..ffab7bdc83a 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -6437,6 +6437,7 @@ void Spell::SummonVehicle(uint32 entry, SummonPropertiesEntry const *properties) if(!vehicle) return; + vehicle->SetOwnerGUID(m_caster->GetGUID()); vehicle->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); if(damage) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index eb5bd306511..97dc6351ccf 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -517,7 +517,7 @@ void Unit::RemoveSpellbyDamageTaken(uint32 damage, uint32 spell) uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const *spellProto, bool durabilityLoss) { - if (!pVictim->isAlive() || pVictim->isInFlight() || pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()) + if (!pVictim->isAlive() || pVictim->hasUnitState(UNIT_STAT_UNATTACKABLE) || pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()) return 0; //You don't lose health from damage taken from another player while in a sanctuary @@ -1320,7 +1320,7 @@ void Unit::DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss) if(!this || !pVictim) return; - if (!pVictim->isAlive() || pVictim->isInFlight() || pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()) + if (!pVictim->isAlive() || pVictim->hasUnitState(UNIT_STAT_UNATTACKABLE) || pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()) return; SpellEntry const *spellProto = sSpellStore.LookupEntry(damageInfo->SpellID); @@ -1563,7 +1563,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) if(!this || !pVictim) return; - if (!pVictim->isAlive() || pVictim->isInFlight() || pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()) + if (!pVictim->isAlive() || pVictim->hasUnitState(UNIT_STAT_UNATTACKABLE) || pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()) return; //You don't lose health from damage taken from another player while in a sanctuary @@ -9665,7 +9665,7 @@ bool Unit::isAttackableByAOE() const if(GetTypeId()==TYPEID_PLAYER && ((Player *)this)->isGameMaster()) return false; - return !isInFlight(); + return !hasUnitState(UNIT_STAT_UNATTACKABLE); } int32 Unit::ModifyHealth(int32 dVal) @@ -12784,7 +12784,7 @@ void Unit::SetCharmedOrPossessedBy(Unit* charmer, bool possess) if(this == charmer) return; - if(isInFlight()) + if(hasUnitState(UNIT_STAT_UNATTACKABLE)) return; if(GetTypeId() == TYPEID_PLAYER && ((Player*)this)->GetTransport()) diff --git a/src/game/Unit.h b/src/game/Unit.h index d56a0831cdc..33b03c821db 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -422,6 +422,8 @@ enum UnitState UNIT_STAT_POSSESSED = 0x00010000, UNIT_STAT_CHARGING = 0x00020000, UNIT_STAT_JUMPING = 0x00040000, + UNIT_STAT_ONVEHICLE = 0x00080000, + UNIT_STAT_UNATTACKABLE = (UNIT_STAT_IN_FLIGHT | UNIT_STAT_ONVEHICLE), UNIT_STAT_MOVING = (UNIT_STAT_ROAMING | UNIT_STAT_CHASE), UNIT_STAT_CONTROLLED = (UNIT_STAT_CONFUSED | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING), UNIT_STAT_LOST_CONTROL = (UNIT_STAT_CONTROLLED | UNIT_STAT_JUMPING | UNIT_STAT_CHARGING), |