diff options
author | Rat <none@none> | 2010-04-29 21:22:25 +0200 |
---|---|---|
committer | Rat <none@none> | 2010-04-29 21:22:25 +0200 |
commit | 757fbfba83f466bd3f757998a705407cfe156868 (patch) | |
tree | e8b238532f1d342532b20279bdd71bf70cca69aa | |
parent | 946ded461927ddb352d2f20041b70ecb7f568cf6 (diff) |
*implemented 'empty' VehicleAI
NOTE: VehicleAI::UpdateAI runs even while the vehicle is mounted!
--HG--
branch : trunk
-rw-r--r-- | src/game/CombatAI.cpp | 24 | ||||
-rw-r--r-- | src/game/CombatAI.h | 17 | ||||
-rw-r--r-- | src/game/CreatureAIRegistry.cpp | 1 | ||||
-rw-r--r-- | src/game/CreatureAISelector.cpp | 6 | ||||
-rw-r--r-- | src/game/Unit.cpp | 20 | ||||
-rw-r--r-- | src/game/Vehicle.h | 1 |
6 files changed, 59 insertions, 10 deletions
diff --git a/src/game/CombatAI.cpp b/src/game/CombatAI.cpp index 5f1b21e0da2..e9babeba414 100644 --- a/src/game/CombatAI.cpp +++ b/src/game/CombatAI.cpp @@ -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; +}
\ No newline at end of file diff --git a/src/game/CombatAI.h b/src/game/CombatAI.h index ee13180f9b5..1c043a1aad1 100644 --- a/src/game/CombatAI.h +++ b/src/game/CombatAI.h @@ -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 diff --git a/src/game/CreatureAIRegistry.cpp b/src/game/CreatureAIRegistry.cpp index 8e4f1c17c69..9db30a0a5c4 100644 --- a/src/game/CreatureAIRegistry.cpp +++ b/src/game/CreatureAIRegistry.cpp @@ -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(); diff --git a/src/game/CreatureAISelector.cpp b/src/game/CreatureAISelector.cpp index 1653dad9b18..d3fd5a8aed9 100644 --- a/src/game/CreatureAISelector.cpp +++ b/src/game/CreatureAISelector.cpp @@ -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"); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 9baa91b7fbc..65187a92789 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -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); diff --git a/src/game/Vehicle.h b/src/game/Vehicle.h index 1770a60798d..339ab1ad188 100644 --- a/src/game/Vehicle.h +++ b/src/game/Vehicle.h @@ -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; |