From a795df9ccae69b17117a1446efb51f4fe06266fb Mon Sep 17 00:00:00 2001 From: megamage Date: Thu, 27 Aug 2009 19:26:18 -0500 Subject: *Remove function passengerleft --HG-- branch : trunk --- .../eastern_kingdoms/scarlet_enclave/chapter1.cpp | 7 +++-- .../ulduar/ulduar/boss_flame_leviathan.cpp | 14 +++++---- .../northrend/ulduar/ulduar/boss_kologarn.cpp | 34 ++++++++++++++++++++-- src/game/CreatureAI.h | 3 +- src/game/Vehicle.cpp | 4 +-- 5 files changed, 46 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter1.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter1.cpp index 545e62a530e..7965d053006 100644 --- a/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter1.cpp +++ b/src/bindings/scripts/scripts/eastern_kingdoms/scarlet_enclave/chapter1.cpp @@ -739,10 +739,11 @@ struct TRINITY_DLL_DECL npc_scarlet_miner_cartAI : public PassiveAI } } - void PassengerLeft(Unit *who, int8 seatId) + void PassengerBoarded(Unit *who, int8 seatId, bool apply) { - if(Creature *miner = Unit::GetCreature(*me, minerGUID)) - miner->DisappearAndDie(); + if(!apply) + if(Creature *miner = Unit::GetCreature(*me, minerGUID)) + miner->DisappearAndDie(); } }; diff --git a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_flame_leviathan.cpp b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_flame_leviathan.cpp index 39c667522e2..71746299d9b 100644 --- a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_flame_leviathan.cpp +++ b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_flame_leviathan.cpp @@ -218,13 +218,16 @@ struct TRINITY_DLL_DECL boss_flame_leviathan_seatAI : public PassiveAI } #endif - void PassengerBoarded(Unit *who, int8 seatId) + void PassengerBoarded(Unit *who, int8 seatId, bool apply) { if(!me->GetVehicle()) return; if(seatId == SEAT_PLAYER) { + if(!apply) + return; + if(Creature *turret = CAST_CRE(vehicle->GetPassenger(SEAT_TURRET))) { turret->setFaction(me->GetVehicleBase()->getFaction()); @@ -237,12 +240,11 @@ struct TRINITY_DLL_DECL boss_flame_leviathan_seatAI : public PassiveAI device->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); } } - } - - void PassengerLeft(Unit *who, int8 seatId) - { - if(seatId == SEAT_TURRET) + else if(seatId == SEAT_TURRET) { + if(apply) + return; + if(Unit *device = vehicle->GetPassenger(SEAT_DEVICE)) { device->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); diff --git a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_kologarn.cpp b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_kologarn.cpp index b9a2f628d4f..775456e875e 100644 --- a/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_kologarn.cpp +++ b/src/bindings/scripts/scripts/northrend/ulduar/ulduar/boss_kologarn.cpp @@ -31,16 +31,33 @@ struct TRINITY_DLL_DECL boss_kologarnAI : public BossAI { - boss_kologarnAI(Creature *c) : BossAI(c, BOSS_KOLOGARN), vehicle(me->GetVehicleKit()) + boss_kologarnAI(Creature *c) : BossAI(c, BOSS_KOLOGARN), vehicle(me->GetVehicleKit()), + leftArm(NULL), rightArm(NULL) { assert(vehicle); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); + } + + void Reset() + { + _Reset(); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); } Vehicle *vehicle; + Creature *leftArm, *rightArm; void AttackStart(Unit *who) { - me->Attack(who, true); + me->Attack(who, false); + } + + void PassengerBoarded(Unit *who, int8 seatId, bool apply) + { + if(who->GetEntry() == 32933) + leftArm = apply ? CAST_CRE(who) : NULL; + else if(who->GetEntry() == 32934) + rightArm = apply ? CAST_CRE(who) : NULL; } void UpdateAI(const uint32 diff) @@ -48,7 +65,18 @@ struct TRINITY_DLL_DECL boss_kologarnAI : public BossAI if(!UpdateVictim()) return; - DoMeleeAttackIfReady(); + if (me->isAttackReady()) + { + //If we are within range melee the target + if (me->IsWithinMeleeRange(me->getVictim())) + { + Unit *attacker = me; + if(leftArm) attacker = leftArm; + if(rightArm && rand()%2) attacker = rightArm; + attacker->AttackerStateUpdate(me->getVictim()); + me->resetAttackTimer(); + } + } } }; diff --git a/src/game/CreatureAI.h b/src/game/CreatureAI.h index 1ec04a2e3c9..5a5a7528bf0 100644 --- a/src/game/CreatureAI.h +++ b/src/game/CreatureAI.h @@ -160,8 +160,7 @@ class TRINITY_DLL_SPEC CreatureAI : public UnitAI void SetGazeOn(Unit *target); - virtual void PassengerBoarded(Unit *who, int8 seatId) {} - virtual void PassengerLeft(Unit *who, int8 seatId) {} + virtual void PassengerBoarded(Unit *who, int8 seatId, bool apply) {} protected: bool _EnterEvadeMode(); diff --git a/src/game/Vehicle.cpp b/src/game/Vehicle.cpp index 4df462f57f4..d666f0f76f9 100644 --- a/src/game/Vehicle.cpp +++ b/src/game/Vehicle.cpp @@ -275,7 +275,7 @@ bool Vehicle::AddPassenger(Unit *unit, int8 seatId) } if(((Creature*)me)->IsAIEnabled) - ((Creature*)me)->AI()->PassengerBoarded(unit, seat->first); + ((Creature*)me)->AI()->PassengerBoarded(unit, seat->first, true); } //if(unit->GetTypeId() == TYPEID_PLAYER) @@ -316,7 +316,7 @@ void Vehicle::RemovePassenger(Unit *unit) me->RemoveCharmedBy(unit); if(me->GetTypeId() == TYPEID_UNIT && ((Creature*)me)->IsAIEnabled) - ((Creature*)me)->AI()->PassengerLeft(unit, seat->first); + ((Creature*)me)->AI()->PassengerBoarded(unit, seat->first, false); // only for flyable vehicles? //CastSpell(this, 45472, true); // Parachute -- cgit v1.2.3