*Update vehicle code.

*Show correct visual effects to other players.
*Do not allow attack players on vehicle.
*Only dismiss vehicle when it is summoned.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-04-09 13:39:23 -05:00
parent ba4e54f2f7
commit 5a71d93bd2
8 changed files with 76 additions and 46 deletions
+1 -1
View File
@@ -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);
+5 -2
View File
@@ -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();
}
}
+26 -3
View File
@@ -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);
}
+35 -34
View File
@@ -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()
+1 -1
View File
@@ -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))
+1
View File
@@ -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)
+5 -5
View File
@@ -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())
+2
View File
@@ -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),