mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 10:05:32 +01:00
*implemented 'empty' VehicleAI
NOTE: VehicleAI::UpdateAI runs even while the vehicle is mounted! --HG-- branch : trunk
This commit is contained in:
@@ -59,6 +59,11 @@ int AOEAI::Permissible(const Creature * /*creature*/)
|
||||
return PERMIT_BASE_NO;
|
||||
}
|
||||
|
||||
int VehicleAI::Permissible(const Creature * /*creature*/)
|
||||
{
|
||||
return PERMIT_BASE_NO;
|
||||
}
|
||||
|
||||
void CombatAI::InitializeAI()
|
||||
{
|
||||
for (uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i)
|
||||
@@ -281,3 +286,22 @@ void AOEAI::UpdateAI(const uint32 /*diff*/)
|
||||
if (!me->HasAura(me->m_spells[0]))
|
||||
me->CastSpell(me, me->m_spells[0],false);
|
||||
}
|
||||
|
||||
//////////////
|
||||
//VehicleAI
|
||||
//////////////
|
||||
|
||||
//NOTE: VehicleAI::UpdateAI runs even while the vehicle is mounted
|
||||
void VehicleAI::UpdateAI(const uint32 diff)
|
||||
{
|
||||
}
|
||||
|
||||
void VehicleAI::Reset()
|
||||
{
|
||||
m_vehicle->Reset();
|
||||
}
|
||||
|
||||
void VehicleAI::OnCharmed(bool apply)
|
||||
{
|
||||
m_IsVehicleInUse = apply;
|
||||
}
|
||||
@@ -100,5 +100,22 @@ struct AOEAI : public CreatureAI
|
||||
|
||||
static int Permissible(const Creature *);
|
||||
};
|
||||
#define VEHICLE_RESET_TIME 5000
|
||||
struct VehicleAI : public CreatureAI
|
||||
{
|
||||
public:
|
||||
explicit VehicleAI(Creature *c) : CreatureAI(c), m_vehicle(c->GetVehicleKit()), m_IsVehicleInUse(false) {}
|
||||
|
||||
void UpdateAI(const uint32 diff);
|
||||
static int Permissible(const Creature *);
|
||||
void Reset();
|
||||
void MoveInLineOfSight(Unit *) {}
|
||||
void AttackStart(Unit *) {}
|
||||
void OnCharmed(bool apply);
|
||||
|
||||
private:
|
||||
Vehicle* m_vehicle;
|
||||
bool m_IsVehicleInUse;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace AIRegistry
|
||||
(new CreatureAIFactory<TurretAI>("TurretAI"))->RegisterSelf();
|
||||
(new CreatureAIFactory<CreatureEventAI>("EventAI"))->RegisterSelf();
|
||||
(new CreatureAIFactory<AOEAI>("AOEAI"))->RegisterSelf();
|
||||
(new CreatureAIFactory<VehicleAI>("VehicleAI"))->RegisterSelf();
|
||||
|
||||
(new MovementGeneratorFactory<RandomMovementGenerator<Creature> >(RANDOM_MOTION_TYPE))->RegisterSelf();
|
||||
(new MovementGeneratorFactory<WaypointMovementGenerator<Creature> >(WAYPOINT_MOTION_TYPE))->RegisterSelf();
|
||||
|
||||
@@ -54,9 +54,11 @@ namespace FactorySelector
|
||||
// select by NPC flags
|
||||
if (!ai_factory)
|
||||
{
|
||||
if (creature->HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN) && ((Guardian*)creature)->GetOwner()->GetTypeId() == TYPEID_PLAYER)
|
||||
if (creature->IsVehicle())
|
||||
ai_factory = ai_registry.GetRegistryItem("VehicleAI");
|
||||
else if (creature->HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN) && ((Guardian*)creature)->GetOwner()->GetTypeId() == TYPEID_PLAYER)
|
||||
ai_factory = ai_registry.GetRegistryItem("PetAI");
|
||||
else if (creature->IsVehicle() || creature->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK))
|
||||
else if (creature->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK))
|
||||
ai_factory = ai_registry.GetRegistryItem("NullCreatureAI");
|
||||
else if (creature->isGuard())
|
||||
ai_factory = ai_registry.GetRegistryItem("GuardAI");
|
||||
|
||||
@@ -15167,17 +15167,21 @@ void Unit::RemoveCharmedBy(Unit *charmer)
|
||||
if (GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
this->ToCreature()->AI()->OnCharmed(false);
|
||||
this->ToCreature()->AIM_Initialize();
|
||||
|
||||
if (this->ToCreature()->AI() && charmer && charmer->isAlive())
|
||||
this->ToCreature()->AI()->AttackStart(charmer);
|
||||
/*if (isAlive() && this->ToCreature()->IsAIEnabled)
|
||||
if (type != CHARM_TYPE_VEHICLE)//Vehicles' AI is never modified
|
||||
{
|
||||
if (charmer && !IsFriendlyTo(charmer))
|
||||
this->ToCreature()->AIM_Initialize();
|
||||
|
||||
if (this->ToCreature()->AI() && charmer && charmer->isAlive())
|
||||
this->ToCreature()->AI()->AttackStart(charmer);
|
||||
else
|
||||
this->ToCreature()->AI()->EnterEvadeMode();
|
||||
}*/
|
||||
/*if (isAlive() && this->ToCreature()->IsAIEnabled)
|
||||
{
|
||||
if (charmer && !IsFriendlyTo(charmer))
|
||||
this->ToCreature()->AI()->AttackStart(charmer);
|
||||
else
|
||||
this->ToCreature()->AI()->EnterEvadeMode();
|
||||
}*/
|
||||
}
|
||||
}
|
||||
else
|
||||
this->ToPlayer()->SetClientControl(this, 1);
|
||||
|
||||
@@ -74,6 +74,7 @@ class Vehicle
|
||||
void RelocatePassengers(float x, float y, float z, float ang);
|
||||
void RemoveAllPassengers();
|
||||
void Dismiss();
|
||||
bool IsVehicleInUse() { return m_Seats.begin() != m_Seats.end(); }
|
||||
|
||||
SeatMap m_Seats;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user