AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
npc_echo_of_medivh Struct Reference
Inheritance diagram for npc_echo_of_medivh:
ScriptedAI CreatureAI UnitAI

Public Member Functions

 npc_echo_of_medivh (Creature *creature)
 
void Reset () override
 
void JustSummoned (Creature *summon) override
 
void SummonedCreatureDespawn (Creature *summon) override
 
void RemoveCheats ()
 
void SetupBoard ()
 
void HandleCellInitialData (uint8 row, uint8 col, Creature *trigger, BoardCell &cell)
 
bool IsMedivhPiece (uint32 entry) const
 
CreatureGetHostileTargetForChangeFacing (Creature *piece, KarazhanChessOrientationType orientation)
 
void HandlePieceJustDied (Creature *piece)
 
int8 HandlePieceRotate (Creature *piece, ObjectGuid const &triggerGUID)
 
int8 HandlePieceMove (Creature *piece, ObjectGuid const &triggerGUID, bool moveByAI)
 
void CastChangeFacing (Creature *piece, Creature *trigger)
 
bool HandlePieceMoveByAI (Creature *piece, KarazhanChessOrientationType orientation)
 
void HandleCheat ()
 
CreatureGetPiece (Creature *sourcePiece, uint8 searchType, float distance, bool hostile, uint32 minHPDiff, bool checkFront)
 
void UpdateAI (uint32 diff) override
 Use to start attacking a target. Called just before JustEngagedWith() More...
 
void sGossipHello (Player *player) override
 
void sGossipSelect (Player *player, uint32, uint32 gossipListId) override
 
- Public Member Functions inherited from ScriptedAI
 ScriptedAI (Creature *creature)
 
 ~ScriptedAI () override
 
void AttackStartNoMove (Unit *target)
 
void DamageTaken (Unit *, uint32 &, DamageEffectType, SpellSchoolMask) override
 Called at any Damage from any attacker (before damage apply) More...
 
void UpdateAI (uint32 diff) override
 Use to start attacking a target. Called just before JustEngagedWith() More...
 
void JustDied (Unit *) override
 
void KilledUnit (Unit *) override
 
void JustSummoned (Creature *) override
 
void SummonedCreatureDespawn (Creature *) override
 
void SpellHit (Unit *, SpellInfo const *) override
 
void SpellHitTarget (Unit *, SpellInfo const *) override
 
void MovementInform (uint32, uint32) override
 
void OnPossess (bool)
 
bool IsInRoom (const Position *pos, Axis axis, bool above)
 
void Reset () override
 
void JustEngagedWith (Unit *) override
 Called for reaction when initially engaged. More...
 
void AttackStart (Unit *) override
 
void DoStartMovement (Unit *target, float distance=0.0f, float angle=0.0f)
 
void DoStartNoMovement (Unit *target)
 
void DoStopAttack ()
 
void DoCastSpell (Unit *target, SpellInfo const *spellInfo, bool triggered=false)
 
void DoPlaySoundToSet (WorldObject *source, uint32 soundId)
 
void DoPlayMusic (uint32 soundId, bool zone)
 
void DoAddThreat (Unit *unit, float amount)
 
void DoModifyThreatByPercent (Unit *unit, int32 pct)
 
void DoResetThreat (Unit *unit)
 
void DoResetThreatList ()
 
float DoGetThreat (Unit *unit)
 
void DoTeleportPlayer (Unit *unit, float x, float y, float z, float o)
 
void DoTeleportPlayer (Unit *unit, Position pos)
 
void DoTeleportAll (float x, float y, float z, float o)
 
UnitDoSelectLowestHpFriendly (float range, uint32 minHPDiff=1)
 
std::list< Creature * > DoFindFriendlyCC (float range)
 
std::list< Creature * > DoFindFriendlyMissingBuff (float range, uint32 spellId)
 
PlayerGetPlayerAtMinimumRange (float minRange)
 
CreatureDoSpawnCreature (uint32 entry, float offsetX, float offsetY, float offsetZ, float angle, uint32 type, uint32 despawntime)
 
bool IsUniqueTimedEventDone (uint32 id) const
 
void SetUniqueTimedEventDone (uint32 id)
 
void ResetUniqueTimedEvent (uint32 id)
 
void ClearUniqueTimedEventsDone ()
 
void ScheduleTimedEvent (Milliseconds timerMin, Milliseconds timerMax, std::function< void()> exec, Milliseconds repeatMin, Milliseconds repeatMax=0s, uint32 uniqueId=0)
 
void ScheduleTimedEvent (Milliseconds timerMax, std::function< void()> exec, Milliseconds repeatMin, Milliseconds repeatMax=0s, uint32 uniqueId=0)
 
void ScheduleUniqueTimedEvent (Milliseconds timer, std::function< void()> exec, uint32 uniqueId)
 
bool HealthBelowPct (uint32 pct) const
 
bool HealthAbovePct (uint32 pct) const
 
SpellInfo const * SelectSpell (Unit *target, uint32 school, uint32 mechanic, SelectTargetType targets, uint32 powerCostMin, uint32 powerCostMax, float rangeMin, float rangeMax, SelectEffect effect)
 
void SetEquipmentSlots (bool loadDefault, int32 mainHand=EQUIP_NO_CHANGE, int32 offHand=EQUIP_NO_CHANGE, int32 ranged=EQUIP_NO_CHANGE)
 
virtual bool CheckEvadeIfOutOfCombatArea () const
 
bool IsHeroic () const
 
Difficulty GetDifficulty () const
 
bool Is25ManRaid () const
 
template<class T >
const T & DUNGEON_MODE (const T &normal5, const T &heroic10) const
 
template<class T >
const T & RAID_MODE (const T &normal10, const T &normal25) const
 
template<class T >
const T & RAID_MODE (const T &normal10, const T &normal25, const T &heroic10, const T &heroic25) const
 
PlayerSelectTargetFromPlayerList (float maxdist, uint32 excludeAura=0, bool mustBeInLOS=false) const
 
- Public Member Functions inherited from CreatureAI
void Talk (uint8 id, WorldObject const *whisperTarget=nullptr, Milliseconds delay=0s)
 Causes the creature to talk/say the text assigned to their entry in the creature_text database table. More...
 
void Talk (uint8 id, Milliseconds delay)
 
 CreatureAI (Creature *creature)
 
 ~CreatureAI () override
 
void MoveCircleChecks ()
 
void MoveBackwardsChecks ()
 
void MoveInLineOfSight_Safe (Unit *who)
 == Reactions At ================================= More...
 
void TriggerAlert (Unit const *who) const
 
virtual bool CanRespawn ()
 
virtual void EnterEvadeMode (EvadeReason why=EVADE_REASON_OTHER)
 
virtual void JustEngagedWith (Unit *)
 Called for reaction when initially engaged. More...
 
virtual void JustDied (Unit *)
 
virtual void KilledUnit (Unit *)
 
virtual void JustSummoned (Creature *)
 
virtual void IsSummonedBy (WorldObject *)
 
virtual void SummonedCreatureDespawn (Creature *)
 
virtual void SummonedCreatureDies (Creature *, Unit *)
 
virtual void SummonedCreatureDespawnAll ()
 
virtual void SummonedCreatureEvade (Creature *)
 
virtual void SpellHit (Unit *, SpellInfo const *)
 
virtual void SpellHitTarget (Unit *, SpellInfo const *)
 
virtual void AttackedBy (Unit *)
 
virtual bool IsEscorted ()
 
virtual void JustRespawned ()
 
virtual void MovementInform (uint32, uint32)
 
virtual void PathEndReached (uint32)
 
void OnCharmed (bool apply) override
 Called when unit is charmed. More...
 
virtual void JustReachedHome ()
 
void DoZoneInCombat (Creature *creature=nullptr, float maxRangeToNearestTarget=250.0f)
 
virtual void ReceiveEmote (Player *, uint32)
 
virtual void OwnerAttackedBy (Unit *)
 
virtual void OwnerAttacked (Unit *)
 
virtual void CorpseRemoved (uint32 &)
 == Triggered Actions Requested ================== More...
 
virtual void PassengerBoarded (Unit *, int8, bool)
 == Fields ======================================= More...
 
virtual bool BeforeSpellClick (Unit *)
 
virtual void OnSpellClick (Unit *, bool &)
 
virtual bool CanSeeAlways (WorldObject const *)
 
virtual bool CanBeSeen (Player const *)
 
virtual bool CanAlwaysBeDetectable (WorldObject const *)
 
virtual void PetStopAttack ()
 
virtual bool CheckInRoom ()
 
CreatureBoundary const * GetBoundary () const
 
void SetBoundary (CreatureBoundary const *boundary, bool negativeBoundaries=false)
 
bool IsInBoundary (Position const *who=nullptr) const
 
virtual void CalculateThreat (Unit *, float &, SpellInfo const *)
 
virtual bool OnTeleportUnreacheablePlayer (Player *)
 
virtual void OnAuraRemove (AuraApplication *, AuraRemoveMode)
 
- Public Member Functions inherited from UnitAI
 UnitAI (Unit *unit)
 
virtual ~UnitAI ()
 
virtual bool CanAIAttack (Unit const *) const
 
virtual void AttackStart (Unit *)
 
virtual void UpdateAI (uint32)=0
 Use to start attacking a target. Called just before JustEngagedWith() More...
 
virtual void InitializeAI ()
 
virtual void Reset ()
 
virtual void OnCharmed (bool apply)=0
 Called when unit is charmed. More...
 
virtual void DoAction (int32)
 
virtual uint32 GetData (uint32) const
 
virtual void SetData (uint32, uint32)
 
virtual void SetGUID (ObjectGuid, int32=0)
 
virtual ObjectGuid GetGUID (int32=0) const
 
UnitSelectTarget (SelectTargetMethod targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
 
template<class PREDICATE >
UnitSelectTarget (SelectTargetMethod targetType, uint32 position, PREDICATE const &predicate)
 
void SelectTargetList (std::list< Unit * > &targetList, uint32 num, SelectTargetMethod targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
 Select the best (up to) <num> targets (in <targetType> order) from the threat list that fulfill the following: More...
 
template<class PREDICATE >
void SelectTargetList (std::list< Unit * > &targetList, uint32 num, SelectTargetMethod targetType, uint32 position, PREDICATE const &predicate)
 
virtual void JustEnteredCombat (Unit *)
 Called when the unit enters combat. More...
 
virtual void JustExitedCombat ()
 Called when the unit leaves combat. More...
 
virtual void DamageDealt (Unit *, uint32 &, DamageEffectType)
 Called at any Damage to any victim (before damage apply) More...
 
virtual void DamageTaken (Unit *, uint32 &, DamageEffectType, SpellSchoolMask)
 Called at any Damage from any attacker (before damage apply) More...
 
virtual void HealReceived (Unit *, uint32 &)
 Called when the creature receives heal. More...
 
virtual void OnPowerUpdate (Powers, int32, int32, uint32)
 Called when the creature power updates. More...
 
virtual void HealDone (Unit *, uint32 &)
 Called when the unit heals. More...
 
virtual void OnCalculateMeleeDamageReceived (uint32 &, Unit *)
 Called during damage calculations. More...
 
virtual void OnCalculateSpellDamageReceived (int32 &, Unit *)
 
virtual void OnCalculatePeriodicTickReceived (uint32 &, Unit *)
 Called during calculation when receiving periodic healing or damage (DoT or HoT) More...
 
void AttackStartCaster (Unit *victim, float dist)
 
SpellCastResult DoAddAuraToAllHostilePlayers (uint32 spellid)
 
SpellCastResult DoCast (uint32 spellId)
 
SpellCastResult DoCast (Unit *victim, uint32 spellId, bool triggered=false)
 
SpellCastResult DoCastSelf (uint32 spellId, bool triggered=false)
 
SpellCastResult DoCastToAllHostilePlayers (uint32 spellid, bool triggered=false)
 To specify the caster as target if the spell is self-cast. More...
 
SpellCastResult DoCastVictim (uint32 spellId, bool triggered=false)
 
SpellCastResult DoCastAOE (uint32 spellId, bool triggered=false)
 
SpellCastResult DoCastRandomTarget (uint32 spellId, uint32 threatTablePosition=0, float dist=0.0f, bool playerOnly=true, bool triggered=false, bool withTank=true)
 Cast the spell on a random unit from the threat list. More...
 
SpellCastResult DoCastMaxThreat (uint32 spellId, uint32 threatTablePosition=0, float dist=0.0f, bool playerOnly=true, bool triggered=false)
 Cast spell on the top threat target, which may not be the current victim. More...
 
float DoGetSpellMaxRange (uint32 spellId, bool positive=false)
 
void DoMeleeAttackIfReady ()
 
bool DoSpellAttackIfReady (uint32 spell)
 
void DoSpellAttackToRandomTargetIfReady (uint32 spell, uint32 threatTablePosition=0, float dist=0.f, bool playerOnly=true)
 
virtual void SummonMovementInform (Creature *, uint32, uint32)
 Called when a summon reaches a waypoint or point movement finished. More...
 
virtual void sGossipHello (Player *)
 
virtual void sGossipSelect (Player *, uint32, uint32)
 
virtual void sGossipSelectCode (Player *, uint32, uint32, char const *)
 
virtual void sQuestAccept (Player *, Quest const *)
 
virtual void sQuestSelect (Player *, Quest const *)
 
virtual void sQuestComplete (Player *, Quest const *)
 
virtual void sQuestReward (Player *, Quest const *, uint32)
 
virtual void sOnGameEvent (bool, uint16)
 
virtual std::string GetDebugInfo () const
 

Private Attributes

InstanceScript_instance
 
SummonList _summons
 
std::array< std::array< BoardCell, MAX_COL >, MAX_ROW_boards
 
std::array< uint32, 2 > _deadCount
 
uint32 _cheatTimer
 

Additional Inherited Members

- Public Types inherited from ScriptedAI
enum class  Axis {
  AXIS_X ,
  AXIS_Y
}
 
- Public Types inherited from CreatureAI
enum  EvadeReason {
  EVADE_REASON_NO_HOSTILES ,
  EVADE_REASON_BOUNDARY ,
  EVADE_REASON_SEQUENCE_BREAK ,
  EVADE_REASON_NO_PATH ,
  EVADE_REASON_OTHER
}
 
- Static Public Member Functions inherited from CreatureAI
static bool IsInBounds (CreatureBoundary const &boundary, Position const *who)
 
- Static Public Member Functions inherited from UnitAI
static void FillAISpellInfo ()
 
- Public Attributes inherited from ScriptedAI
Creatureme
 
- Static Public Attributes inherited from UnitAI
static AISpellInfoTypeAISpellInfo
 
- Protected Member Functions inherited from CreatureAI
bool UpdateVictim ()
 
bool UpdateVictimWithGaze ()
 
void SetGazeOn (Unit *target)
 
CreatureDoSummon (uint32 entry, Position const &pos, uint32 despawnTime=30000, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
 
CreatureDoSummon (uint32 entry, WorldObject *obj, float radius=5.0f, uint32 despawnTime=30000, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
 
CreatureDoSummonFlyer (uint32 entry, WorldObject *obj, float flightZ, float radius=5.0f, uint32 despawnTime=30000, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
 
virtual void MoveInLineOfSight (Unit *)
 
bool _EnterEvadeMode (EvadeReason why=EVADE_REASON_OTHER)
 
- Protected Attributes inherited from CreatureAI
Creature *const me
 
EventMap events
 
TaskScheduler scheduler
 
CreatureBoundary const * _boundary
 
bool _negateBoundary
 
- Protected Attributes inherited from UnitAI
Unit *const me
 

Detailed Description

Constructor & Destructor Documentation

◆ npc_echo_of_medivh()

npc_echo_of_medivh::npc_echo_of_medivh ( Creature creature)
inline
191 : ScriptedAI(creature), _summons(me)
192 {
193 _instance = creature->GetInstanceScript();
194 }
Definition: ScriptedCreature.h:190
Creature * me
Definition: ScriptedCreature.h:280
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1192
InstanceScript * _instance
Definition: boss_chess_event.cpp:1411
SummonList _summons
Definition: boss_chess_event.cpp:1412

References _instance, and WorldObject::GetInstanceScript().

Member Function Documentation

◆ CastChangeFacing()

void npc_echo_of_medivh::CastChangeFacing ( Creature piece,
Creature trigger 
)
inline
967 {
968 piece->CastSpell(trigger, SPELL_CHANGE_FACING, true);
969 }
@ SPELL_CHANGE_FACING
Definition: boss_chess_event.cpp:49
SpellCastResult CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:1168

References Unit::CastSpell(), and SPELL_CHANGE_FACING.

Referenced by HandlePieceMoveByAI().

◆ GetHostileTargetForChangeFacing()

Creature * npc_echo_of_medivh::GetHostileTargetForChangeFacing ( Creature piece,
KarazhanChessOrientationType  orientation 
)
inline
392 {
393 for (uint8 row = 0; row < MAX_ROW; ++row)
394 {
395 for (uint8 col = 0; col < MAX_COL; ++col)
396 {
397 BoardCell const& cell = _boards[row][col];
398 if (cell.pieceGUID != piece->GetGUID())
399 continue;
400
401 std::vector<KarazhanChessOrientationType> orientations;
402 switch (orientation)
403 {
404 case ORI_SE:
406 break;
407 case ORI_S:
409 break;
410 case ORI_SW:
412 break;
413 case ORI_W:
415 break;
416 case ORI_NW:
418 break;
419 case ORI_N:
421 break;
422 case ORI_NE:
424 break;
425 case ORI_E:
427 break;
428 default:
429 break;
430 }
431
433 {
434 uint8 newRow = row;
435 uint8 newCol = col;
436 switch (orient)
437 {
438 case ORI_SE:
439 newRow -= 1;
440 break;
441 case ORI_S:
442 newRow -= 1;
443 newCol -= 1;
444 break;
445 case ORI_SW:
446 newCol -= 1;
447 break;
448 case ORI_W:
449 newRow += 1;
450 newCol -= 1;
451 break;
452 case ORI_NW:
453 newRow += 1;
454 break;
455 case ORI_N:
456 newRow += 1;
457 newCol += 1;
458 break;
459 case ORI_NE:
460 newCol += 1;
461 break;
462 case ORI_E:
463 newRow -= 1;
464 newCol += 1;
465 break;
466 default:
467 break;
468 }
469
470 if (newRow < MAX_ROW && newCol < MAX_COL)
471 if (Creature* targetPiece = ObjectAccessor::GetCreature(*me, _boards[newRow][newCol].pieceGUID))
472 if (!IsFriendly(piece, targetPiece))
473 return targetPiece;
474 }
475
476 return nullptr;
477 }
478 }
479
480 return nullptr;
481 }
std::uint8_t uint8
Definition: Define.h:109
static std::array< float, MAX_ORI > orientations
Definition: boss_chess_event.cpp:176
static constexpr uint8 MAX_ROW
Definition: boss_chess_event.cpp:142
KarazhanChessOrientationType
Definition: boss_chess_event.cpp:73
@ ORI_NE
Definition: boss_chess_event.cpp:80
@ ORI_W
Definition: boss_chess_event.cpp:77
@ ORI_E
Definition: boss_chess_event.cpp:81
@ ORI_S
Definition: boss_chess_event.cpp:75
@ ORI_NW
Definition: boss_chess_event.cpp:78
@ ORI_N
Definition: boss_chess_event.cpp:79
@ ORI_SE
Definition: boss_chess_event.cpp:74
@ ORI_SW
Definition: boss_chess_event.cpp:76
static constexpr uint8 MAX_COL
Definition: boss_chess_event.cpp:143
static bool IsFriendly(Creature *piece, Creature *target)
Definition: boss_chess_event.cpp:178
Creature * GetCreature(WorldObject const &u, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:213
Definition: Creature.h:46
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109
Definition: boss_chess_event.cpp:146
ObjectGuid pieceGUID
Definition: boss_chess_event.cpp:150
std::array< std::array< BoardCell, MAX_COL >, MAX_ROW > _boards
Definition: boss_chess_event.cpp:1413

References _boards, ObjectAccessor::GetCreature(), Object::GetGUID(), IsFriendly(), MAX_COL, MAX_ROW, ScriptedAI::me, ORI_E, ORI_N, ORI_NE, ORI_NW, ORI_S, ORI_SE, ORI_SW, ORI_W, orientations, and BoardCell::pieceGUID.

Referenced by HandlePieceMoveByAI().

◆ GetPiece()

Creature * npc_echo_of_medivh::GetPiece ( Creature sourcePiece,
uint8  searchType,
float  distance,
bool  hostile,
uint32  minHPDiff,
bool  checkFront 
)
inline
1267 {
1268 if (!sourcePiece)
1269 {
1270 return nullptr;
1271 }
1272
1273 Creature* target = nullptr;
1274 std::vector<Creature*> targets;
1275
1276 for (uint8 row = 0; row < MAX_ROW; ++row)
1277 {
1278 for (uint8 col = 0; col < MAX_COL; ++col)
1279 {
1280 if (Creature* piece = ObjectAccessor::GetCreature(*me, _boards[row][col].pieceGUID))
1281 {
1282 if (IsFriendly(piece, sourcePiece) == hostile)
1283 {
1284 continue;
1285 }
1286
1287 if (checkFront && !sourcePiece->HasInArc(float(M_PI) / 3.0f, piece))
1288 {
1289 continue;
1290 }
1291
1292 if (minHPDiff)
1293 {
1294 if (piece->GetMaxHealth() - piece->GetHealth() <= minHPDiff)
1295 {
1296 continue;
1297 }
1298
1299 minHPDiff = piece->GetMaxHealth() - piece->GetHealth();
1300 }
1301
1302 float dist = sourcePiece->GetExactDist2d(piece);
1303 if (dist < distance)
1304 {
1305 if (searchType == CHESS_PIECE_SEARCH_TYPE_CLOSEST)
1306 {
1307 distance = dist;
1308 target = piece;
1309 }
1310 else
1311 {
1312 targets.push_back(piece);
1313 }
1314 }
1315 }
1316 }
1317 }
1318
1319 if (!targets.empty())
1320 {
1322 }
1323
1324 return target;
1325 }
@ CHESS_PIECE_SEARCH_TYPE_CLOSEST
Definition: boss_chess_event.cpp:185
auto SelectRandomContainerElement(C const &container) -> typename std::add_const< decltype(*std::begin(container))>::type &
Definition: Containers.h:133
float GetExactDist2d(const float x, const float y) const
Definition: Position.h:166
bool HasInArc(float arcangle, const Position *pos, float targetRadius=0.0f) const
Definition: Position.cpp:140
uint32 GetMaxHealth() const
Definition: Unit.h:870

References _boards, CHESS_PIECE_SEARCH_TYPE_CLOSEST, ObjectAccessor::GetCreature(), Position::GetExactDist2d(), Unit::GetMaxHealth(), Position::HasInArc(), IsFriendly(), MAX_COL, MAX_ROW, ScriptedAI::me, and Acore::Containers::SelectRandomContainerElement().

◆ HandleCellInitialData()

void npc_echo_of_medivh::HandleCellInitialData ( uint8  row,
uint8  col,
Creature trigger,
BoardCell cell 
)
inline
263 {
264 switch (row)
265 {
266 case 0: // Alliance first row
267 {
268 switch (col)
269 {
270 case 0:
271 case 7: // Rook
272 if (Creature* rook = trigger->FindNearestCreature(NPC_ROOK_A, 4.0f, true))
273 {
274 cell.SetPiece(rook);
275 }
276 break;
277 case 1:
278 case 6: // Knight
279 if (Creature* knight = trigger->FindNearestCreature(NPC_KNIGHT_A, 4.0f, true))
280 {
281 cell.SetPiece(knight);
282 }
283 break;
284 case 2:
285 case 5: // Bishop
286 if (Creature* bishop = trigger->FindNearestCreature(NPC_BISHOP_A, 4.0f, true))
287 {
288 cell.SetPiece(bishop);
289 }
290 break;
291 case 3: // Queen
292 if (Creature* queen = trigger->FindNearestCreature(NPC_QUEEN_A, 4.0f, true))
293 {
294 cell.SetPiece(queen);
295 }
296 break;
297 case 4: // King
298 if (Creature* king = trigger->FindNearestCreature(NPC_KING_A, 4.0f, true))
299 {
300 cell.SetPiece(king);
301 }
302 break;
303 }
304 break;
305 }
306 case 1: // Alliance second row
307 // All pawns
308 if (Creature* pawn = trigger->FindNearestCreature(NPC_PAWN_A, 4.0f, true))
309 {
310 cell.SetPiece(pawn);
311 }
312 break;
313 case 6: // Horde second row
314 // All pawns
315 if (Creature* pawn = trigger->FindNearestCreature(NPC_PAWN_H, 4.0f, true))
316 {
317 cell.SetPiece(pawn);
318 }
319 break;
320 case 7: // Horde first row
321 {
322 switch (col)
323 {
324 case 0:
325 case 7: // Rook
326 if (Creature* rook = trigger->FindNearestCreature(NPC_ROOK_H, 4.0f, true))
327 {
328 cell.SetPiece(rook);
329 }
330 break;
331 case 1:
332 case 6: // Knight
333 if (Creature* knight = trigger->FindNearestCreature(NPC_KNIGHT_H, 4.0f, true))
334 {
335 cell.SetPiece(knight);
336 }
337 break;
338 case 2:
339 case 5: // Bishop
340 if (Creature* bishop = trigger->FindNearestCreature(NPC_BISHOP_H, 4.0f, true))
341 {
342 cell.SetPiece(bishop);
343 }
344 break;
345 case 3: // Queen
346 if (Creature* queen = trigger->FindNearestCreature(NPC_QUEEN_H, 4.0f, true))
347 {
348 cell.SetPiece(queen);
349 }
350 break;
351 case 4: // King
352 if (Creature* king = trigger->FindNearestCreature(NPC_KING_H, 4.0f, true))
353 {
354 cell.SetPiece(king);
355 }
356 break;
357 default:
358 break;
359 }
360 break;
361 }
362 default:
363 cell.Reset();
364 break;
365 }
366 }
@ NPC_QUEEN_H
Definition: karazhan.h:126
@ NPC_ROOK_A
Definition: karazhan.h:131
@ NPC_KNIGHT_H
Definition: karazhan.h:124
@ NPC_KING_A
Definition: karazhan.h:133
@ NPC_PAWN_H
Definition: karazhan.h:122
@ NPC_PAWN_A
Definition: karazhan.h:123
@ NPC_ROOK_H
Definition: karazhan.h:130
@ NPC_KING_H
Definition: karazhan.h:132
@ NPC_QUEEN_A
Definition: karazhan.h:127
@ NPC_BISHOP_H
Definition: karazhan.h:128
@ NPC_BISHOP_A
Definition: karazhan.h:129
@ NPC_KNIGHT_A
Definition: karazhan.h:125
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition: Object.cpp:2446
void Reset()
Definition: boss_chess_event.cpp:162
void SetPiece(Creature *piece)
Definition: boss_chess_event.cpp:168

References WorldObject::FindNearestCreature(), NPC_BISHOP_A, NPC_BISHOP_H, NPC_KING_A, NPC_KING_H, NPC_KNIGHT_A, NPC_KNIGHT_H, NPC_PAWN_A, NPC_PAWN_H, NPC_QUEEN_A, NPC_QUEEN_H, NPC_ROOK_A, NPC_ROOK_H, BoardCell::Reset(), and BoardCell::SetPiece().

Referenced by SetupBoard().

◆ HandleCheat()

void npc_echo_of_medivh::HandleCheat ( )
inline
1172 {
1174
1175 switch (urand(0, 2))
1176 {
1177 case 0: // Heal king
1178 {
1180 {
1181 if (Creature* king = me->FindNearestCreature(NPC_KING_H, 80.0f, true))
1182 {
1183 king->SetHealth(king->GetMaxHealth());
1184 }
1185 }
1187 {
1188 if (Creature* king = me->FindNearestCreature(NPC_KING_A, 80.0f, true))
1189 {
1190 king->SetHealth(king->GetMaxHealth());
1191 }
1192 }
1193
1194 break;
1195 }
1196 case 1: // Fire
1197 {
1198 std::list<Creature*> targetList;
1199 for (uint8 row = 0; row < MAX_ROW; ++row)
1200 {
1201 for (uint8 col = 0; col < MAX_COL; ++col)
1202 {
1203 BoardCell const& cell = _boards[row][col];
1204 if (!cell.pieceGUID || IsMedivhPiece(cell.pieceEntry))
1205 {
1206 continue;
1207 }
1208
1209 if (Creature* trigger = ObjectAccessor::GetCreature(*me, cell.triggerGUID))
1210 {
1211 targetList.push_back(trigger);
1212 }
1213 }
1214 }
1215
1216 if (targetList.size() > 3)
1217 {
1218 Acore::Containers::RandomResize(targetList, 3);
1219 }
1220
1221 for (Creature* target : targetList)
1222 {
1223 DoCast(target, SPELL_FURY_OF_MEDIVH_FIRE, true);
1224 }
1225
1226 break;
1227 }
1228 case 2: // Buff
1229 {
1230 std::list<Creature*> targetList;
1231 for (uint8 row = 0; row < MAX_ROW; ++row)
1232 {
1233 for (uint8 col = 0; col < MAX_COL; ++col)
1234 {
1235 BoardCell const& cell = _boards[row][col];
1236 if (!cell.pieceGUID || !IsMedivhPiece(cell.pieceEntry))
1237 {
1238 continue;
1239 }
1240
1241 if (Creature* piece = ObjectAccessor::GetCreature(*me, cell.pieceGUID))
1242 {
1243 targetList.push_back(piece);
1244 }
1245 }
1246 }
1247
1248 uint8 resizeMax = urand(1, 4);
1249 if (targetList.size() > resizeMax)
1250 {
1251 Acore::Containers::RandomResize(targetList, resizeMax);
1252 }
1253
1254 for (Creature* target : targetList)
1255 {
1256 DoCast(target, SPELL_HAND_OF_MEDIVH, true);
1257 }
1258
1259 break;
1260 }
1261 }
1262
1264 }
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:44
@ TALK_MEDIHV_CHEAT_EMOTE
Definition: boss_chess_event.cpp:122
@ TALK_MEDIHV_CHEAT
Definition: boss_chess_event.cpp:121
@ SPELL_FURY_OF_MEDIVH_FIRE
Definition: boss_chess_event.cpp:55
@ SPELL_HAND_OF_MEDIVH
Definition: karazhan.h:183
@ CHESS_EVENT_TEAM
Definition: karazhan.h:62
Talk
Definition: hyjal.cpp:82
@ TEAM_ALLIANCE
Definition: SharedDefines.h:760
@ TEAM_HORDE
Definition: SharedDefines.h:761
void RandomResize(C &container, std::size_t requestedSize)
Definition: Containers.h:79
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:177
virtual uint32 GetData(uint32) const
Definition: ZoneScript.h:52
uint32 pieceEntry
Definition: boss_chess_event.cpp:151
ObjectGuid triggerGUID
Definition: boss_chess_event.cpp:149
bool IsMedivhPiece(uint32 entry) const
Definition: boss_chess_event.cpp:368

References _boards, _instance, CHESS_EVENT_TEAM, UnitAI::DoCast(), WorldObject::FindNearestCreature(), ObjectAccessor::GetCreature(), ZoneScript::GetData(), IsMedivhPiece(), MAX_COL, MAX_ROW, ScriptedAI::me, NPC_KING_A, NPC_KING_H, BoardCell::pieceEntry, BoardCell::pieceGUID, Acore::Containers::RandomResize(), SPELL_FURY_OF_MEDIVH_FIRE, SPELL_HAND_OF_MEDIVH, TALK_MEDIHV_CHEAT, TALK_MEDIHV_CHEAT_EMOTE, TEAM_ALLIANCE, TEAM_HORDE, BoardCell::triggerGUID, and urand().

Referenced by UpdateAI().

◆ HandlePieceJustDied()

void npc_echo_of_medivh::HandlePieceJustDied ( Creature piece)
inline
484 {
485 switch (piece->GetFaction())
486 {
488 {
489 float baseX = -11078.116211f;
490 float baseY = -1908.443115f;
491 float deltaX = 2.148438f;
492 float deltaY = 1.723755f;
493 float extraX = 2.416992f;
494 float extraY = -2.889649f;
495 float offset = 1.3f * (_deadCount[DEAD_ALLIANCE] % MAX_ROW);
496 float finalX = baseX + offset * deltaX + (_deadCount[DEAD_ALLIANCE] >= MAX_ROW ? 1 : 0) * extraX;
497 float finalY = baseY + offset * deltaY + (_deadCount[DEAD_ALLIANCE] >= MAX_ROW ? 1 : 0) * extraY;
498 piece->NearTeleportTo(finalX, finalY, 221.0f, orientations[ORI_SW]);
500
501 piece->CombatStop();
503 piece->setDeathState(DeathState::JustRespawned);
504 piece->SetHealth(piece->GetMaxHealth());
505 break;
506 }
508 {
509 float baseX = -11081.393555f;
510 float baseY = -1844.194092f;
511 float deltaX = -2.148438f;
512 float deltaY = -1.723755f;
513 float extraX = -2.416992f;
514 float extraY = 2.889649f;
515
516 float offset = 1.3f * (_deadCount[DEAD_HORDE] % MAX_ROW);
517
518 float finalX = baseX + offset * deltaX + (_deadCount[DEAD_HORDE] >= MAX_ROW ? 1 : 0) * extraX;
519 float finalY = baseY + offset * deltaY + (_deadCount[DEAD_HORDE] >= MAX_ROW ? 1 : 0) * extraY;
520 piece->NearTeleportTo(finalX, finalY, 221.0f, orientations[ORI_NE]);
522
523 piece->CombatStop();
525 piece->setDeathState(DeathState::JustRespawned);
526 piece->SetHealth(piece->GetMaxHealth());
527 break;
528 }
529 }
530
531 for (uint8 row = 0; row < MAX_ROW; ++row)
532 {
533 for (uint8 col = 0; col < MAX_COL; ++col)
534 {
535 if (_boards[row][col].pieceGUID == piece->GetGUID())
536 {
537 _boards[row][col].Reset();
538 }
539 }
540 }
541
543 {
544 bool ended = false;
545 switch (piece->GetEntry())
546 {
547 case NPC_KING_H:
551 break;
552 case NPC_KING_A:
554 {
560 ended = true;
562 }
564 {
568 ended = true;
570 }
571 break;
572 default:
573 break;
574 }
575
576 if (!ended)
577 {
578 uint8 talkIndex = TALK_PLAYER_LOOSE_PAWN;
579 if (piece->GetFaction() == CHESS_FACTION_ALLIANCE)
580 {
581 talkIndex = TALK_MEDIVH_LOOSE_PAWN;
582 }
583
584 switch (piece->GetEntry())
585 {
586 case NPC_ROOK_A:
587 case NPC_ROOK_H:
588 talkIndex += 1;
589 break;
590 case NPC_KNIGHT_A:
591 case NPC_KNIGHT_H:
592 talkIndex += 2;
593 break;
594 case NPC_BISHOP_A:
595 case NPC_BISHOP_H:
596 talkIndex += 3;
597 break;
598 case NPC_QUEEN_A:
599 case NPC_QUEEN_H:
600 talkIndex += 4;
601 break;
602 case NPC_KING_H:
603 case NPC_KING_A:
604 talkIndex += 5;
605 break;
606 }
607
608 Talk(talkIndex);
609 }
610 }
612 {
613 bool ended = false;
614 switch (piece->GetEntry())
615 {
616 case NPC_KING_A:
620 break;
621 case NPC_KING_H:
623 {
629 ended = true;
631 }
633 {
638 ended = true;
639 }
640 break;
641 default:
642 break;
643 }
644
645 if (!ended)
646 {
647 uint8 talkIndex = TALK_PLAYER_LOOSE_PAWN;
648 if (piece->GetFaction() == CHESS_FACTION_HORDE)
649 {
650 talkIndex = TALK_MEDIVH_LOOSE_PAWN;
651 }
652
653 switch (piece->GetEntry())
654 {
655 case NPC_ROOK_A:
656 case NPC_ROOK_H:
657 talkIndex += 1;
658 break;
659 case NPC_KNIGHT_A:
660 case NPC_KNIGHT_H:
661 talkIndex += 2;
662 break;
663 case NPC_BISHOP_A:
664 case NPC_BISHOP_H:
665 talkIndex += 3;
666 break;
667 case NPC_QUEEN_A:
668 case NPC_QUEEN_H:
669 talkIndex += 4;
670 break;
671 case NPC_KING_H:
672 case NPC_KING_A:
673 talkIndex += 5;
674 break;
675 }
676
677 Talk(talkIndex);
678 }
679 }
680 else
681 {
682 switch (piece->GetEntry())
683 {
684 case NPC_KING_H:
685 case NPC_KING_A:
690 break;
691 }
692
693 uint8 talkIndex = TALK_PLAYER_LOOSE_PAWN;
694 if (piece->GetFaction() == CHESS_FACTION_HORDE)
695 {
696 talkIndex = TALK_MEDIVH_LOOSE_PAWN;
697 }
698
699 switch (piece->GetEntry())
700 {
701 case NPC_ROOK_A:
702 case NPC_ROOK_H:
703 talkIndex += 1;
704 break;
705 case NPC_KNIGHT_A:
706 case NPC_KNIGHT_H:
707 talkIndex += 2;
708 break;
709 case NPC_BISHOP_A:
710 case NPC_BISHOP_H:
711 talkIndex += 3;
712 break;
713 case NPC_QUEEN_A:
714 case NPC_QUEEN_H:
715 talkIndex += 4;
716 break;
717 case NPC_KING_H:
718 case NPC_KING_A:
719 talkIndex += 5;
720 break;
721 }
722
723 Talk(talkIndex);
724 }
725 }
constexpr auto DAY
Definition: Common.h:49
@ IN_PROGRESS
Definition: InstanceScript.h:58
@ DONE
Definition: InstanceScript.h:60
@ SPECIAL
Definition: InstanceScript.h:61
@ NOT_STARTED
Definition: InstanceScript.h:57
@ UNIT_FLAG_NOT_SELECTABLE
Definition: UnitDefines.h:254
@ TALK_EVENT_ENDED
Definition: boss_chess_event.cpp:139
@ TALK_MEDIVH_LOOSE_PAWN
Definition: boss_chess_event.cpp:131
@ TALK_PLAYER_LOOSE_PAWN
Definition: boss_chess_event.cpp:124
@ DEAD_ALLIANCE
Definition: boss_chess_event.cpp:68
@ DEAD_HORDE
Definition: boss_chess_event.cpp:69
@ CHESS_FACTION_HORDE
Definition: karazhan.h:200
@ CHESS_FACTION_ALLIANCE
Definition: karazhan.h:201
@ CHESS_PHASE_NOT_STARTED
Definition: karazhan.h:189
@ CHESS_PHASE_PVE_FINISHED
Definition: karazhan.h:193
@ SPELL_GAME_IN_SESSION
Definition: karazhan.h:182
@ DATA_CHESS_GAME_PHASE
Definition: karazhan.h:64
@ DATA_DUST_COVERED_CHEST
Definition: karazhan.h:66
@ DATA_CHESS_EVENT
Definition: karazhan.h:39
@ DATA_CHESS_REINIT_PIECES
Definition: karazhan.h:63
void setDeathState(DeathState s, bool despawn=false) override
A creature can be in 4 different states: Alive, JustDied, Corpse, and JustRespawned....
Definition: Creature.cpp:1960
uint32 GetEntry() const
Definition: Object.h:112
void CombatStop(bool includingCast=false)
Definition: Unit.cpp:10398
void SetHealth(uint32 val)
Definition: Unit.cpp:15433
uint32 GetFaction() const
Definition: Unit.h:755
void NearTeleportTo(Position &pos, bool casting=false, bool vehicleTeleport=false, bool withPet=false, bool removeTransport=false)
Definition: Unit.cpp:19937
void SetUnitFlag(UnitFlags flags)
UnitFlags available in UnitDefines.h.
Definition: Unit.h:683
ObjectGuid GetGuidData(uint32 type) const override
Definition: InstanceScript.cpp:95
void DoRemoveAurasDueToSpellOnPlayers(uint32 spell)
Definition: InstanceScript.cpp:639
void DoRespawnGameObject(ObjectGuid guid, uint32 timeToDespawn=MINUTE)
Definition: InstanceScript.cpp:535
virtual void SetData(uint32, uint32)
Definition: ZoneScript.h:53
std::array< uint32, 2 > _deadCount
Definition: boss_chess_event.cpp:1414

References _boards, _deadCount, _instance, CHESS_EVENT_TEAM, CHESS_FACTION_ALLIANCE, CHESS_FACTION_HORDE, CHESS_PHASE_NOT_STARTED, CHESS_PHASE_PVE_FINISHED, Unit::CombatStop(), DATA_CHESS_EVENT, DATA_CHESS_GAME_PHASE, DATA_CHESS_REINIT_PIECES, DATA_DUST_COVERED_CHEST, DAY, DEAD_ALLIANCE, DEAD_HORDE, DONE, InstanceScript::DoRemoveAurasDueToSpellOnPlayers(), InstanceScript::DoRespawnGameObject(), ZoneScript::GetData(), Object::GetEntry(), Unit::GetFaction(), Object::GetGUID(), InstanceScript::GetGuidData(), Unit::GetMaxHealth(), IN_PROGRESS, MAX_COL, MAX_ROW, Unit::NearTeleportTo(), NOT_STARTED, NPC_BISHOP_A, NPC_BISHOP_H, NPC_KING_A, NPC_KING_H, NPC_KNIGHT_A, NPC_KNIGHT_H, NPC_QUEEN_A, NPC_QUEEN_H, NPC_ROOK_A, NPC_ROOK_H, ORI_NE, ORI_SW, orientations, ZoneScript::SetData(), Creature::setDeathState(), Unit::SetHealth(), Unit::SetUnitFlag(), SPECIAL, SPELL_GAME_IN_SESSION, TALK_EVENT_ENDED, TALK_MEDIVH_LOOSE_PAWN, TALK_PLAYER_LOOSE_PAWN, TEAM_ALLIANCE, TEAM_HORDE, and UNIT_FLAG_NOT_SELECTABLE.

◆ HandlePieceMove()

int8 npc_echo_of_medivh::HandlePieceMove ( Creature piece,
ObjectGuid const &  triggerGUID,
bool  moveByAI 
)
inline
849 {
850 bool foundProperCell = false;
851 bool foundOld = false;
852 bool foundNew = false;
853 int8 oldRow = MAX_ROW;
854 int8 oldCol = MAX_COL;
855 int8 newRow = -1;
856 int8 newCol = -1;
857
858 for (uint8 row = 0; row < MAX_ROW; ++row)
859 {
860 for (uint8 col = 0; col < MAX_COL; ++col)
861 {
862 BoardCell const& cell = _boards[row][col];
863 if (!foundNew)
864 {
865 if (cell.triggerGUID == triggerGUID)
866 {
867 //is there already a piece on this cell ?
868 if (cell.pieceGUID)
869 {
870 return -1;
871 }
872
873 newCol = col;
874 newRow = row;
875 foundProperCell = true;
876 foundNew = true;
877 }
878 }
879
880 if (!foundOld)
881 {
882 if (cell.pieceGUID == piece->GetGUID())
883 {
884 oldCol = col;
885 oldRow = row;
886 foundOld = true;
887 }
888 }
889
890 if (foundNew && foundOld)
891 {
892 break;
893 }
894 }
895
896 if (foundNew && foundOld)
897 {
898 break;
899 }
900 }
901
902 if (newCol == -1 || newRow == -1)
903 {
904 return -1;
905 }
906
907 if (!moveByAI && foundProperCell)
908 {
909 uint8 deltaRow = abs(oldRow - newRow);
910 uint8 deltaCol = abs(oldCol - newCol);
911
912 switch (piece->GetEntry())
913 {
914 case NPC_PAWN_H:
915 case NPC_PAWN_A:
916 case NPC_BISHOP_H:
917 case NPC_BISHOP_A:
918 case NPC_ROOK_H:
919 case NPC_ROOK_A:
920 case NPC_KING_H:
921 case NPC_KING_A:
922 if (deltaRow > 1 || deltaCol > 1)
923 {
924 foundProperCell = false;
925 }
926 break;
927 case NPC_QUEEN_H:
928 case NPC_QUEEN_A:
929 if (deltaRow > 3 || deltaCol > 3)
930 {
931 foundProperCell = false;
932 }
933 break;
934 case NPC_KNIGHT_H:
935 case NPC_KNIGHT_A:
936 if (deltaRow > 2 || deltaCol > 2)
937 {
938 foundProperCell = false;
939 }
940 break;
941 default:
942 break;
943 }
944 }
945
946 if (foundProperCell || moveByAI)
947 {
948 int8 orientation = HandlePieceRotate(piece, triggerGUID);
949 if (orientation != -1)
950 {
951 _boards[newRow][newCol].triggerGUID = triggerGUID;
952 _boards[newRow][newCol].SetPiece(piece);
953
954 if (oldRow != MAX_ROW && oldCol != MAX_COL)
955 {
956 _boards[oldRow][oldCol].Reset();
957 }
958 }
959
960 return orientation;
961 }
962
963 return -1;
964 }
std::int8_t int8
Definition: Define.h:105
int8 HandlePieceRotate(Creature *piece, ObjectGuid const &triggerGUID)
Definition: boss_chess_event.cpp:727

References _boards, Object::GetEntry(), Object::GetGUID(), HandlePieceRotate(), MAX_COL, MAX_ROW, NPC_BISHOP_A, NPC_BISHOP_H, NPC_KING_A, NPC_KING_H, NPC_KNIGHT_A, NPC_KNIGHT_H, NPC_PAWN_A, NPC_PAWN_H, NPC_QUEEN_A, NPC_QUEEN_H, NPC_ROOK_A, NPC_ROOK_H, BoardCell::pieceGUID, and BoardCell::triggerGUID.

◆ HandlePieceMoveByAI()

bool npc_echo_of_medivh::HandlePieceMoveByAI ( Creature piece,
KarazhanChessOrientationType  orientation 
)
inline

Change orientation at edges

Here we shouldn't be facing the edges of the board, check in the 4 first if statements

972 {
973 uint8 pieceRow = 0;
974 uint8 pieceCol = 0;
975 bool found = false;
976
977 for (uint8 row = 0; row < MAX_ROW; ++row)
978 {
979 for (uint8 col = 0; col < MAX_COL; ++col)
980 {
981 if (_boards[row][col].pieceGUID == piece->GetGUID())
982 {
983 pieceRow = row;
984 pieceCol = col;
985 found = true;
986 break;
987 }
988 }
989
990 if (found)
991 {
992 break;
993 }
994 }
995
997 if (orientation == ORI_SE && pieceRow == 0)
998 {
999 if (Creature* trigger = ObjectAccessor::GetCreature(*me, _boards[pieceRow + 1][pieceCol].triggerGUID))
1000 {
1001 CastChangeFacing(piece, trigger);
1002 }
1003
1004 return true;
1005 }
1006 else if (orientation == ORI_NW && pieceRow == 7)
1007 {
1008 if (Creature* trigger = ObjectAccessor::GetCreature(*me, _boards[pieceRow - 1][pieceCol].triggerGUID))
1009 {
1010 CastChangeFacing(piece, trigger);
1011 }
1012
1013 return true;
1014 }
1015 else if (orientation == ORI_SW && pieceCol == 0)
1016 {
1017 if (Creature* trigger = ObjectAccessor::GetCreature(*me, _boards[pieceRow][pieceCol + 1].triggerGUID))
1018 {
1019 CastChangeFacing(piece, trigger);
1020 }
1021
1022 return true;
1023 }
1024 else if (orientation == ORI_NE && pieceCol == 7)
1025 {
1026 if (Creature* trigger = ObjectAccessor::GetCreature(*me, _boards[pieceRow][pieceCol - 1].triggerGUID))
1027 {
1028 CastChangeFacing(piece, trigger);
1029 }
1030
1031 return true;
1032 }
1033 else if (urand(0, 1)) // 50% chance to check for nearby enemies
1034 {
1035 if (Creature* target = GetHostileTargetForChangeFacing(piece, orientation))
1036 {
1037 CastChangeFacing(me, target);
1038 return true;
1039 }
1040 }
1041
1042 switch (orientation)
1043 {
1044 case ORI_W:
1045 case ORI_N:
1046 orientation = ORI_NW;
1047 break;
1048 case ORI_S:
1049 case ORI_E:
1050 orientation = ORI_SE;
1051 break;
1052 default:
1053 break;
1054 }
1055
1056 switch (orientation)
1057 {
1058 case ORI_SE:
1059 case ORI_NW:
1060 {
1061 int32 randomRow = (orientation == ORI_SE) ? pieceRow - 1 : pieceRow + 1;
1062 int32 randomCol = pieceCol;
1063 switch (urand(0, 2))
1064 {
1065 case 0:
1066 if ((me->GetEntry() == NPC_QUEEN_A || me->GetEntry() == NPC_QUEEN_H))
1067 {
1068 randomCol -= irand(1, 2);
1069 }
1070 else
1071 {
1072 randomCol -= 1;
1073 }
1074 break;
1075 case 1:
1076 if ((me->GetEntry() == NPC_QUEEN_A || me->GetEntry() == NPC_QUEEN_H))
1077 {
1078 randomCol += irand(1, 2);
1079 }
1080 else
1081 {
1082 randomCol += 1;
1083 }
1084 break;
1085 case 2:
1086 if ((me->GetEntry() == NPC_QUEEN_A || me->GetEntry() == NPC_QUEEN_H))
1087 {
1088 randomRow += (orientation == ORI_SE) ? irand(-2, 0) : irand(0, 2);
1089 }
1090 else if ((me->GetEntry() == NPC_KNIGHT_A || me->GetEntry() == NPC_KNIGHT_H) && urand(0, 1))
1091 {
1092 randomRow += (orientation == ORI_SE) ? -1 : 1;
1093 }
1094 break;
1095 }
1096
1097 randomRow = RoundToInterval(randomRow, 0, 7);
1098 randomCol = RoundToInterval(randomCol, 0, 7);
1099
1100 BoardCell const& cell = _boards[randomRow][randomCol];
1101 if (Creature* trigger = ObjectAccessor::GetCreature(*me, cell.triggerGUID))
1102 {
1103 if (!cell.pieceGUID)
1104 {
1105 piece->CastSpell(trigger, SPELL_MOVE_GENERIC, false);
1106 return true;
1107 }
1108 }
1109 break;
1110 }
1111 case ORI_SW:
1112 case ORI_NE:
1113 {
1114 int32 randomRow = pieceRow;
1115 int32 randomCol = orientation == ORI_SW ? pieceCol - 1 : pieceCol + 1;
1116 switch (urand(0, 2))
1117 {
1118 case 0:
1119 if ((me->GetEntry() == NPC_QUEEN_A || me->GetEntry() == NPC_QUEEN_H))
1120 {
1121 randomRow -= irand(1, 2);
1122 }
1123 else
1124 {
1125 randomRow -= 1;
1126 }
1127 break;
1128 case 1:
1129 if ((me->GetEntry() == NPC_QUEEN_A || me->GetEntry() == NPC_QUEEN_H))
1130 {
1131 randomRow += irand(1, 2);
1132 }
1133 else
1134 {
1135 randomRow += 1;
1136 }
1137 break;
1138 case 2:
1139 if ((me->GetEntry() == NPC_QUEEN_A || me->GetEntry() == NPC_QUEEN_H))
1140 {
1141 randomCol += (orientation == ORI_SW) ? irand(-2, 0) : irand(0, 2);
1142 }
1143 else if ((me->GetEntry() == NPC_KNIGHT_A || me->GetEntry() == NPC_KNIGHT_H) && urand(0, 1))
1144 {
1145 randomCol += (orientation == ORI_SW) ? -1 : 1;
1146 }
1147 break;
1148 }
1149
1150 randomRow = RoundToInterval(randomRow, 0, 7);
1151 randomCol = RoundToInterval(randomCol, 0, 7);
1152
1153 BoardCell const& cell = _boards[randomRow][randomCol];
1154 if (Creature* trigger = ObjectAccessor::GetCreature(*me, cell.triggerGUID))
1155 {
1156 if (!cell.pieceGUID)
1157 {
1158 piece->CastSpell(trigger, SPELL_MOVE_GENERIC, false);
1159 return true;
1160 }
1161 }
1162 break;
1163 }
1164 default:
1165 break;
1166 }
1167
1168 return false;
1169 }
int32 irand(int32 min, int32 max)
Definition: Random.cpp:37
T RoundToInterval(T &num, T floor, T ceil)
Definition: Util.h:79
std::int32_t int32
Definition: Define.h:103
@ SPELL_MOVE_GENERIC
Definition: boss_chess_event.cpp:47
void CastChangeFacing(Creature *piece, Creature *trigger)
Definition: boss_chess_event.cpp:966
Creature * GetHostileTargetForChangeFacing(Creature *piece, KarazhanChessOrientationType orientation)
Definition: boss_chess_event.cpp:391

References _boards, CastChangeFacing(), Unit::CastSpell(), ObjectAccessor::GetCreature(), Object::GetEntry(), Object::GetGUID(), GetHostileTargetForChangeFacing(), irand(), MAX_COL, MAX_ROW, ScriptedAI::me, NPC_KNIGHT_A, NPC_KNIGHT_H, NPC_QUEEN_A, NPC_QUEEN_H, ORI_E, ORI_N, ORI_NE, ORI_NW, ORI_S, ORI_SE, ORI_SW, ORI_W, BoardCell::pieceGUID, RoundToInterval(), SPELL_MOVE_GENERIC, BoardCell::triggerGUID, and urand().

◆ HandlePieceRotate()

int8 npc_echo_of_medivh::HandlePieceRotate ( Creature piece,
ObjectGuid const &  triggerGUID 
)
inline
728 {
729 bool foundOld = false;
730 bool foundNew = false;
731 int8 pieceRow = MAX_ROW;
732 int8 pieceCol = MAX_COL;
733 int8 targetRow = -1;
734 int8 targetCol = -1;
735
736 for (uint8 row = 0; row < MAX_ROW; ++row)
737 {
738 for (uint8 col = 0; col < MAX_COL; ++col)
739 {
740 BoardCell const& cell = _boards[row][col];
741 if (!foundNew && cell.triggerGUID == triggerGUID)
742 {
743 targetRow = row;
744 targetCol = col;
745 foundNew = true;
746 }
747
748 if (!foundOld && cell.pieceGUID == piece->GetGUID())
749 {
750 pieceRow = row;
751 pieceCol = col;
752 foundOld = true;
753 }
754
755 if (foundNew && foundOld)
756 {
757 break;
758 }
759 }
760
761 if (foundNew && foundOld)
762 {
763 break;
764 }
765 }
766
767 if (targetRow == -1 || targetCol == -1)
768 {
769 return -1;
770 }
771
772 int8 deltaRow = targetRow - pieceRow;
773 int8 deltaCol = targetCol - pieceCol;
774
775 if (!deltaRow && !deltaCol)
776 {
777 return -1;
778 }
779
780 switch (deltaRow)
781 {
782 case -3:
783 case -2:
784 case -1:
785 {
786 switch (deltaCol)
787 {
788 case -3:
789 case -2:
790 case -1:
791 return ORI_S;
792 case 0:
793 return ORI_SE;
794 case 1:
795 case 2:
796 case 3:
797 return ORI_E;
798 default:
799 break;
800 }
801 break;
802 }
803 case 0:
804 {
805 switch (deltaCol)
806 {
807 case -3:
808 case -2:
809 case -1:
810 return ORI_SW;
811 case 1:
812 case 2:
813 case 3:
814 return ORI_NE;
815 default:
816 break;
817 }
818 break;
819 }
820 case 1:
821 case 2:
822 case 3:
823 {
824 switch (deltaCol)
825 {
826 case -3:
827 case -2:
828 case -1:
829 return ORI_W;
830 case 0:
831 return ORI_NW;
832 case 1:
833 case 2:
834 case 3:
835 return ORI_N;
836 default:
837 break;
838 }
839 break;
840 }
841 default:
842 break;
843 }
844
845 return -1;
846 }

References _boards, Object::GetGUID(), MAX_COL, MAX_ROW, ORI_E, ORI_N, ORI_NE, ORI_NW, ORI_S, ORI_SE, ORI_SW, ORI_W, BoardCell::pieceGUID, and BoardCell::triggerGUID.

Referenced by HandlePieceMove().

◆ IsMedivhPiece()

bool npc_echo_of_medivh::IsMedivhPiece ( uint32  entry) const
inline
369 {
370 switch (entry)
371 {
372 case NPC_PAWN_H:
373 case NPC_KNIGHT_H:
374 case NPC_QUEEN_H:
375 case NPC_BISHOP_H:
376 case NPC_ROOK_H:
377 case NPC_KING_H:
379 case NPC_PAWN_A:
380 case NPC_KNIGHT_A:
381 case NPC_QUEEN_A:
382 case NPC_BISHOP_A:
383 case NPC_ROOK_A:
384 case NPC_KING_A:
386 }
387
388 return false;
389 }

References _instance, CHESS_EVENT_TEAM, ZoneScript::GetData(), NPC_BISHOP_A, NPC_BISHOP_H, NPC_KING_A, NPC_KING_H, NPC_KNIGHT_A, NPC_KNIGHT_H, NPC_PAWN_A, NPC_PAWN_H, NPC_QUEEN_A, NPC_QUEEN_H, NPC_ROOK_A, NPC_ROOK_H, TEAM_ALLIANCE, and TEAM_HORDE.

Referenced by HandleCheat().

◆ JustSummoned()

void npc_echo_of_medivh::JustSummoned ( Creature summon)
inlineoverridevirtual

Reimplemented from ScriptedAI.

212 {
213 _summons.Summon(summon);
214 }
void Summon(Creature const *summon)
Definition: ScriptedCreature.h:88

References _summons, and SummonList::Summon().

◆ RemoveCheats()

void npc_echo_of_medivh::RemoveCheats ( )
inline
222 {
223 // Buffs
224 for (uint8 row = 0; row < MAX_ROW; ++row)
225 {
226 for (uint8 col = 0; col < MAX_COL; ++col)
227 {
228 if (ObjectGuid guid = _boards[row][col].pieceGUID)
229 {
230 if (Creature* piece = ObjectAccessor::GetCreature(*me, guid))
231 {
232 piece->RemoveAurasDueToSpell(SPELL_HAND_OF_MEDIVH);
233 }
234 }
235 }
236 }
237 }
Definition: ObjectGuid.h:118

References _boards, ObjectAccessor::GetCreature(), MAX_COL, MAX_ROW, ScriptedAI::me, and SPELL_HAND_OF_MEDIVH.

◆ Reset()

void npc_echo_of_medivh::Reset ( )
inlineoverridevirtual

Reimplemented from ScriptedAI.

197 {
198 for (uint8 row = 0; row < MAX_ROW; ++row)
199 {
200 for (uint8 col = 0; col < MAX_COL; ++col)
201 {
202 _boards[row][col].Reset();
203 }
204 }
205
207
209 }
constexpr auto IN_MILLISECONDS
Definition: Common.h:53
void DespawnAll(uint32 delay=0)
Definition: ScriptedCreature.cpp:71
uint32 _cheatTimer
Definition: boss_chess_event.cpp:1415

References _boards, _cheatTimer, _summons, SummonList::DespawnAll(), IN_MILLISECONDS, MAX_COL, MAX_ROW, and urand().

◆ SetupBoard()

void npc_echo_of_medivh::SetupBoard ( )
inline
240 {
242
244
245 for (uint8 row = 0; row < MAX_ROW; ++row)
246 {
247 for (uint8 col = 0; col < MAX_COL; ++col)
248 {
249 BoardCell& cell = _boards[row][col];
250
251 if (Creature* trigger = me->SummonCreature(NPC_CHESS_MOVE_TRIGGER, (-11108.099609f + (3.49f * col) + (4.4f * row)), (-1872.910034f - (4.4f * col) + (3.45f * row)), 220.667f, 0, TEMPSUMMON_MANUAL_DESPAWN, 0))
252 {
253 cell.SetData(trigger->GetGUID(), row, col);
254 HandleCellInitialData(row, col, trigger, cell);
255 }
256 }
257 }
258
259 _deadCount.fill(0);
260 }
@ TEMPSUMMON_MANUAL_DESPAWN
Definition: Object.h:52
@ NPC_CHESS_MOVE_TRIGGER
Definition: boss_chess_event.cpp:63
TempSummon * SummonCreature(uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0, SummonPropertiesEntry const *properties=nullptr, bool visibleBySummonerOnly=false) const
Definition: Object.cpp:2355
void SetData(ObjectGuid _triggerGUID, uint8 _row, uint8 _col)
Definition: boss_chess_event.cpp:155
void HandleCellInitialData(uint8 row, uint8 col, Creature *trigger, BoardCell &cell)
Definition: boss_chess_event.cpp:262

References _boards, _deadCount, _instance, _summons, DATA_CHESS_REINIT_PIECES, SummonList::DespawnAll(), HandleCellInitialData(), MAX_COL, MAX_ROW, ScriptedAI::me, NPC_CHESS_MOVE_TRIGGER, BoardCell::SetData(), ZoneScript::SetData(), WorldObject::SummonCreature(), and TEMPSUMMON_MANUAL_DESPAWN.

Referenced by sGossipSelect().

◆ sGossipHello()

void npc_echo_of_medivh::sGossipHello ( Player player)
inlineoverridevirtual

Reimplemented from UnitAI.

1348 {
1350 switch (chessPhase)
1351 {
1353 AddGossipItemFor(player, GOSSIP_ICON_CHAT, "We want to play a game against you!", GOSSIP_SENDER_MAIN, MEDIVH_GOSSIP_START_PVE);
1354 break;
1357 AddGossipItemFor(player, GOSSIP_ICON_CHAT, "Restart", GOSSIP_SENDER_MAIN, MEDIVH_GOSSIP_RESTART); // We want to player another game against you
1358 break;
1360 AddGossipItemFor(player, GOSSIP_ICON_CHAT, "PvP", GOSSIP_SENDER_MAIN, MEDIVH_GOSSIP_START_PVP); // We'd like to fight each other
1361 break;
1362 }
1363
1364 SendGossipMenuFor(player, player->GetGossipTextId(me), me->GetGUID());
1365 }
std::uint32_t uint32
Definition: Define.h:107
void SendGossipMenuFor(Player *player, uint32 npcTextID, ObjectGuid const guid)
Definition: ScriptedGossip.cpp:45
void AddGossipItemFor(Player *player, uint32 icon, std::string const &text, uint32 sender, uint32 action)
Definition: ScriptedGossip.cpp:28
@ GOSSIP_SENDER_MAIN
Definition: ScriptedGossip.h:70
@ GOSSIP_ICON_CHAT
Definition: GossipDef.h:60
@ MEDIVH_GOSSIP_RESTART
Definition: boss_chess_event.cpp:34
@ MEDIVH_GOSSIP_START_PVP
Definition: boss_chess_event.cpp:35
@ MEDIVH_GOSSIP_START_PVE
Definition: boss_chess_event.cpp:33
@ CHESS_PHASE_INPROGRESS_PVP
Definition: karazhan.h:195
@ CHESS_PHASE_INPROGRESS_PVE
Definition: karazhan.h:191
uint32 GetGossipTextId(uint32 menuId, WorldObject *source)
Definition: PlayerGossip.cpp:404

References _instance, AddGossipItemFor(), CHESS_PHASE_INPROGRESS_PVE, CHESS_PHASE_INPROGRESS_PVP, CHESS_PHASE_NOT_STARTED, CHESS_PHASE_PVE_FINISHED, DATA_CHESS_GAME_PHASE, ZoneScript::GetData(), Player::GetGossipTextId(), Object::GetGUID(), GOSSIP_ICON_CHAT, GOSSIP_SENDER_MAIN, ScriptedAI::me, MEDIVH_GOSSIP_RESTART, MEDIVH_GOSSIP_START_PVE, MEDIVH_GOSSIP_START_PVP, and SendGossipMenuFor().

◆ sGossipSelect()

void npc_echo_of_medivh::sGossipSelect ( Player player,
uint32  ,
uint32  gossipListId 
)
inlineoverridevirtual

Reimplemented from UnitAI.

1368 {
1370 _instance->SetData(CHESS_EVENT_TEAM, chessPhase < CHESS_PHASE_PVE_FINISHED ? player->GetTeamId() : TEAM_NEUTRAL);
1371
1372 CloseGossipMenuFor(player);
1373
1374 uint32 const action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId);
1375 switch (action)
1376 {
1379 SetupBoard();
1382 break;
1386 _deadCount.fill(0);
1388 {
1391 }
1393 {
1396 }
1398 break;
1401 SetupBoard();
1404 break;
1405 default:
1406 break;
1407 }
1408 }
void CloseGossipMenuFor(Player *player)
Definition: ScriptedGossip.cpp:56
@ TALK_EVENT_BEGIN
Definition: boss_chess_event.cpp:119
@ CHESS_PHASE_FAILED
Definition: karazhan.h:192
@ CHESS_PHASE_PVE_WARMUP
Definition: karazhan.h:190
@ CHESS_PHASE_PVP_WARMUP
Definition: karazhan.h:194
TeamId GetTeamId(PvPTeamId teamId)
Definition: SharedDefines.h:3462
@ TEAM_NEUTRAL
Definition: SharedDefines.h:762
uint32 GetGossipOptionAction(uint32 selection) const
Definition: GossipDef.h:270
PlayerMenu * PlayerTalkClass
Definition: Player.h:2219
void SetupBoard()
Definition: boss_chess_event.cpp:239

References _deadCount, _instance, CHESS_EVENT_TEAM, CHESS_PHASE_FAILED, CHESS_PHASE_NOT_STARTED, CHESS_PHASE_PVE_FINISHED, CHESS_PHASE_PVE_WARMUP, CHESS_PHASE_PVP_WARMUP, CloseGossipMenuFor(), DATA_CHESS_EVENT, DATA_CHESS_GAME_PHASE, DATA_CHESS_REINIT_PIECES, DONE, InstanceScript::DoRemoveAurasDueToSpellOnPlayers(), ZoneScript::GetData(), PlayerMenu::GetGossipOptionAction(), GetTeamId(), IN_PROGRESS, MEDIVH_GOSSIP_RESTART, MEDIVH_GOSSIP_START_PVE, MEDIVH_GOSSIP_START_PVP, NOT_STARTED, Player::PlayerTalkClass, ZoneScript::SetData(), SetupBoard(), SPECIAL, SPELL_GAME_IN_SESSION, TALK_EVENT_BEGIN, and TEAM_NEUTRAL.

◆ SummonedCreatureDespawn()

void npc_echo_of_medivh::SummonedCreatureDespawn ( Creature summon)
inlineoverridevirtual

Reimplemented from ScriptedAI.

217 {
218 _summons.Despawn(summon);
219 }
void Despawn(Creature const *summon)
Definition: ScriptedCreature.h:89

References _summons, and SummonList::Despawn().

◆ UpdateAI()

void npc_echo_of_medivh::UpdateAI ( uint32  )
inlineoverridevirtual

Use to start attacking a target. Called just before JustEngagedWith()

Reimplemented from ScriptedAI.

1328 {
1330 if (chessPhase != CHESS_PHASE_INPROGRESS_PVE && chessPhase != CHESS_PHASE_INPROGRESS_PVP)
1331 return;
1332
1333 if (chessPhase == CHESS_PHASE_INPROGRESS_PVE)
1334 {
1335 if (_cheatTimer <= diff)
1336 {
1337 HandleCheat();
1338 _cheatTimer = urand(45000, 100000);
1339 }
1340 else
1341 {
1342 _cheatTimer -= diff;
1343 }
1344 }
1345 }
void HandleCheat()
Definition: boss_chess_event.cpp:1171

References _cheatTimer, _instance, CHESS_PHASE_INPROGRESS_PVE, CHESS_PHASE_INPROGRESS_PVP, DATA_CHESS_GAME_PHASE, ZoneScript::GetData(), HandleCheat(), and urand().

Member Data Documentation

◆ _boards

◆ _cheatTimer

uint32 npc_echo_of_medivh::_cheatTimer
private

Referenced by Reset(), and UpdateAI().

◆ _deadCount

std::array<uint32, 2> npc_echo_of_medivh::_deadCount
private

◆ _instance

◆ _summons

SummonList npc_echo_of_medivh::_summons
private