diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game/CreatureAI.cpp | 13 | ||||
-rw-r--r-- | src/game/Unit.cpp | 13 | ||||
-rw-r--r-- | src/game/Vehicle.cpp | 58 |
3 files changed, 46 insertions, 38 deletions
diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp index cfe72f654eb..165bb2411ec 100644 --- a/src/game/CreatureAI.cpp +++ b/src/game/CreatureAI.cpp @@ -200,13 +200,16 @@ void CreatureAI::EnterEvadeMode() if(!_EnterEvadeMode()) return; - if(Unit *owner = me->GetCharmerOrOwner()) + if(!me->m_Vehicle) // otherwise me will be in evade mode forever { - me->GetMotionMaster()->Clear(false); - me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, m_creature->GetFollowAngle(), MOTION_SLOT_ACTIVE); + if(Unit *owner = me->GetCharmerOrOwner()) + { + me->GetMotionMaster()->Clear(false); + me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, m_creature->GetFollowAngle(), MOTION_SLOT_ACTIVE); + } + else + me->GetMotionMaster()->MoveTargetedHome(); } - else - me->GetMotionMaster()->MoveTargetedHome(); Reset(); } diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 33db2c2ffdd..573dd702dd0 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -10843,6 +10843,9 @@ bool Unit::canAttack(Unit const* target, bool force) const else if(!IsHostileTo(target)) return false; + //if(m_Vehicle && m_Vehicle == target->m_Vehicle) + // return true; + if(!target->isAttackableByAOE() || target->hasUnitState(UNIT_STAT_DIED)) return false; @@ -14296,11 +14299,13 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type) assert(type != CHARM_TYPE_POSSESS || charmer->GetTypeId() == TYPEID_PLAYER); assert(type != CHARM_TYPE_VEHICLE || GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isVehicle()); + sLog.outDebug("SetCharmedBy: charmer %u, charmed %u, type %u.", charmer->GetEntry(), GetEntry(), (uint32)type); + if(this == charmer) return false; - if(hasUnitState(UNIT_STAT_UNATTACKABLE)) - return false; + //if(hasUnitState(UNIT_STAT_UNATTACKABLE)) + // return false; if(GetTypeId() == TYPEID_PLAYER && ((Player*)this)->GetTransport()) return false; @@ -14940,7 +14945,6 @@ void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId) return; } - addUnitState(UNIT_STAT_ONVEHICLE); SetControlled(true, UNIT_STAT_ROOT); //movementInfo is set in AddPassenger //packets are sent in AddPassenger @@ -14985,7 +14989,6 @@ void Unit::ExitVehicle() Vehicle *vehicle = m_Vehicle; m_Vehicle = NULL; - clearUnitState(UNIT_STAT_ONVEHICLE); SetControlled(false, UNIT_STAT_ROOT); RemoveUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT); @@ -14996,6 +14999,8 @@ void Unit::ExitVehicle() m_movementInfo.t_time = 0; m_movementInfo.t_seat = 0; + Relocate(vehicle->GetPositionX(), vehicle->GetPositionY(), vehicle->GetPositionZ(), GetOrientation()); + //Send leave vehicle, not correct if(GetTypeId() == TYPEID_PLAYER) { diff --git a/src/game/Vehicle.cpp b/src/game/Vehicle.cpp index 257dfb5c912..3cad7963d0b 100644 --- a/src/game/Vehicle.cpp +++ b/src/game/Vehicle.cpp @@ -65,9 +65,9 @@ void Vehicle::AddToWorld() } } + Unit::AddToWorld(); InstallAllAccessories(); - Unit::AddToWorld(); AIM_Initialize(); } } @@ -90,9 +90,11 @@ void Vehicle::InstallAllAccessories() InstallAccessory(33139,7); break; case 33114: - InstallAccessory(33143,1); - //InstallAccessory(33142,0); - InstallAccessory(33142,2); + InstallAccessory(33142,0); + //InstallAccessory(33143,1); + //InstallAccessory(33142,2); + InstallAccessory(33143,2); + InstallAccessory(33142,1); break; } } @@ -266,17 +268,9 @@ void Vehicle::InstallAccessory(uint32 entry, int8 seatId) if(!accessory) return; - if (!accessory->m_Vehicle) - { - accessory->m_Vehicle = this; - if (!AddPassenger(accessory, seatId)) - { - accessory->m_Vehicle = NULL; - return; - } - // This is not good, we have to send update twice - accessory->SendMovementFlagUpdate(); - } + accessory->EnterVehicle(this, seatId); + // This is not good, we have to send update twice + accessory->SendMovementFlagUpdate(); } bool Vehicle::AddPassenger(Unit *unit, int8 seatId) @@ -317,6 +311,9 @@ bool Vehicle::AddPassenger(Unit *unit, int8 seatId) RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); } + if(!(seat->second.seatInfo->m_flags & 0x4000)) + unit->addUnitState(UNIT_STAT_ONVEHICLE); + //SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_24); unit->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT); @@ -328,12 +325,15 @@ bool Vehicle::AddPassenger(Unit *unit, int8 seatId) unit->m_movementInfo.t_time = 0; // 1 for player unit->m_movementInfo.t_seat = seat->first; - if(unit->GetTypeId() == TYPEID_PLAYER && seat->first == 0 && seat->second.seatInfo->IsUsable()) // not right + if(unit->GetTypeId() == TYPEID_PLAYER && seat->first == 0 && seat->second.seatInfo->m_flags & 0x800) // not right if (!SetCharmedBy(unit, CHARM_TYPE_VEHICLE)) assert(false); if(IsInWorld()) + { unit->SendMonsterMoveTransport(this); + GetMap()->CreatureRelocation(this, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); + } //if(unit->GetTypeId() == TYPEID_PLAYER) // ((Player*)unit)->SendTeleportAckMsg(); @@ -349,27 +349,27 @@ void Vehicle::RemovePassenger(Unit *unit) SeatMap::iterator seat; for(seat = m_Seats.begin(); seat != m_Seats.end(); ++seat) - { if(seat->second.passenger == unit) - { - seat->second.passenger = NULL; - if(seat->second.seatInfo->IsUsable()) - { - if(!m_usableSeatNum) - SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); - ++m_usableSeatNum; - } break; - } - } assert(seat != m_Seats.end()); - sLog.outDebug("Unit %s exit vehicle entry %u id %u dbguid %u", unit->GetName(), GetEntry(), m_vehicleInfo->m_ID, GetDBTableGUIDLow()); + sLog.outDebug("Unit %s exit vehicle entry %u id %u dbguid %u seat %d", unit->GetName(), GetEntry(), m_vehicleInfo->m_ID, GetDBTableGUIDLow(), (int32)seat->first); + + seat->second.passenger = NULL; + if(seat->second.seatInfo->IsUsable()) + { + if(!m_usableSeatNum) + SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); + ++m_usableSeatNum; + } + + if(!(seat->second.seatInfo->m_flags & 0x4000)) + unit->clearUnitState(UNIT_STAT_ONVEHICLE); //SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); - if(unit->GetTypeId() == TYPEID_PLAYER && seat->first == 0 && seat->second.seatInfo->IsUsable()) + if(unit->GetTypeId() == TYPEID_PLAYER && seat->first == 0 && seat->second.seatInfo->m_flags & 0x800) RemoveCharmedBy(unit); // only for flyable vehicles? |