Advertisement
Guest User

Chess event

a guest
Feb 15th, 2012
1,077
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 29.95 KB | None | 0 0
  1. /*
  2.  * Copyright (C) 2006-2012 SkCore <http://www.skwow.net/>
  3.  *
  4.  * This program is free software; you can redistribute it and/or modify it
  5.  * under the terms of the GNU General Public License as published by the
  6.  * Free Software Foundation; either version 2 of the License, or (at your
  7.  * option) any later version.
  8.  *
  9.  * This program is distributed in the hope that it will be useful, but WITHOUT
  10.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11.  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12.  * more details.
  13.  *
  14.  * You should have received a copy of the GNU General Public License along
  15.  * with this program. If not, see <http://www.gnu.org/licenses/>.
  16.  */
  17.  
  18. #include "ScriptPCH.h"
  19. #include "karazhan.h"
  20.  
  21. #define ALLI_CREATURE_FACTION 1690
  22. #define HORDE_CREATURE_FACTION 1689
  23. #define DUST_COVERED_CHEST  185119
  24.  
  25. #define GOSSIP_POSSES "Ich übernehme!" //need correction
  26.  
  27. #define EVENT_START "Lasst uns Schach spielen!"
  28. #define NPC_ATTACK_RADIUS 7
  29.  
  30. #define SAY_AT_EVENT_START "Sehr gutw. Lasst das Spiel beginnen."
  31. #define SOUND_START 10338
  32.  
  33. #define SAY_LOSE_KNIGHT_P "Yes...all according to plan."
  34. #define SOUND_KNIGHT_LOSE_P 10349
  35. #define SAY_LOSE_KNIGHT_M "Ja... natürlich."
  36. #define SOUND_KNIGHT_LOSE_M 10350
  37.  
  38. #define SAY_LOSE_PAWN_P_1 "A transparent stratagem."
  39. #define SOUND_LOSE_PAWN_P_1 10339
  40. #define SAY_LOSE_PAWN_P_2 "Sehen wir mal."
  41. #define SOUND_LOSE_PAWN_P_2 10340
  42. #define SAY_LOSE_PAWN_P_3 "Ah, the wheels have begun to turn."
  43. #define SOUND_LOSE_PAWN_P_3 10341
  44. #define SAY_LOSE_PAWN_M_1 "Hmm."
  45. #define SOUND_LOSE_PAWN_M_1 10342
  46. #define SAY_LOSE_PAWN_M_2 "Egal!"
  47. #define SOUND_LOSE_PAWN_M_2 10344
  48. #define SAY_LOSE_PAWN_M_3 "Interesting."
  49. #define SOUND_LOSE_PAWN_M_3 10343
  50.  
  51. #define SAY_LOSE_QUEEN_P "Now it gets interesting."
  52. #define SOUND_LOSE_QUEEN_P 10351
  53. #define SAY_LOSE_QUEEN_M "Ahh, I should have known."
  54. #define SOUND_LOSE_QUEEN_M 10352
  55.  
  56. #define SAY_LOSE_BISHOP_P "The slightest loss of concentration is all it takes."
  57. #define SOUND_LOSE_BISHOP_P 10347
  58. #define SAY_LOSE_BISHOP_M "A necessary sacrifice."
  59. #define SOUND_LOSE_BISHOP_M 10348
  60.  
  61. #define SAY_LOSE_ROOK_P "Foolish! Very foolish!"
  62. #define SOUND_LOSE_ROOK_P 10345
  63. #define SAY_LOSE_ROOK_M "A minor concern."
  64. #define SOUND_LOSE_ROOK_M 10346
  65.  
  66. #define SAY_PLAYER_CHECK "And so, the end draws near."
  67. #define SOUND_PLAYER_CHECK 10353
  68. #define SAY_MEDIVH_CHECK "As it should be."
  69. #define SOUND_MEDIVH_CHECK 10354
  70.  
  71. #define SAY_PLAYER_WIN "And so it ends."
  72. #define SOUND_PLAYER_WIN 10355
  73. #define SAY_MEDIVH_WIN "Nothing less than perfection will do."
  74. #define SOUND_MEDIVH_WIN 10356
  75.  
  76. #define SAY_MEDIVH_CHEAT_1 "Perhaps a change is in order."
  77. #define SOUND_MEDIVH_CHEAT_1 //10357
  78. #define SAY_MEDIVH_CHEAT_2 "Time for an alternative scenario."
  79. #define SOUND_MEDIVH_CHEAT_2 10358
  80. #define SAY_MEDIVH_CHEAT_3 "One must not become too complacent."
  81. #define SOUND_MEDIVH_CHEAT_3 10359
  82.  
  83. #define SPELL_HAND_OF_MEDIVH 39339 //berserk spell
  84. #define SPELL_FURY_OF_MEDIVH 39383 //aoe spell
  85. //and we have another cheat medivh heals the target to max.(creature->sethealth(creature->getmaxhealth()))
  86.  
  87. #define TRIGGER_ID 22519
  88.  
  89. #define NPC_MEDIVH 16816
  90.  
  91. #define NPC_PAWN_H 17469
  92. #define NPC_PAWN_A 17211
  93.  
  94. #define NPC_KNIGHT_H 21748
  95. #define NPC_KNIGHT_A 21664
  96.  
  97. #define NPC_QUEEN_H 21750
  98. #define NPC_QUEEN_A 21683
  99.  
  100. #define NPC_BISHOP_H 21747
  101. #define NPC_BISHOP_A 21682
  102.  
  103. #define BISHOP_HEAL_H 37456
  104. #define BISHOP_HEAL_A 37455
  105.  
  106. #define NPC_ROOK_H 21726
  107. #define NPC_ROOK_A 21160
  108.  
  109. #define NPC_KING_H 21752
  110. #define NPC_KING_A 21684
  111.  
  112. #define SPELL_MOVE_1 37146
  113. #define SPELL_MOVE_2 30012
  114. #define SPELL_MOVE_3 37144
  115. #define SPELL_MOVE_4 37148
  116. #define SPELL_MOVE_5 37151
  117. #define SPELL_MOVE_6 37152
  118. #define SPELL_MOVE_7 37153
  119.  
  120. #define SPELL_CHANGE_FACING 30284
  121. #define SPELL_MOVE_MARKER 32261
  122.  
  123. #define SEARCH_RANGE 5
  124.  
  125. class chess_move_trigger : public CreatureScript
  126. {
  127. public:
  128.     chess_move_trigger() : CreatureScript("chess_move_trigger") { }
  129.  
  130.     CreatureAI* GetAI(Creature* creature) const
  131.     {
  132.         return new chess_move_triggerAI(creature);
  133.     }
  134.  
  135.     struct chess_move_triggerAI : public ScriptedAI
  136.     {
  137.         chess_move_triggerAI(Creature* c) : ScriptedAI(creature), _instance(creature->GetInstanceScript())
  138.         {
  139.         }
  140.  
  141.         InstanceScript* instance;
  142.         uint32 search_time;
  143.         Unit *unit_on_me;
  144.        
  145.         void Reset()
  146.         {
  147.             search_time = 4500;//imho better with movementinformation but possedai override scriptedai.dont work with movementinformation
  148.             unit_on_me = NULL;
  149.         }
  150.        
  151.         void Aggro(Unit *){}
  152.         void UpdateAI(const uint32 diff)
  153.            
  154.         //haxx?
  155.         {
  156.             if(instance->GetData(TYPE_CHESS) != IN_PROGRESS)
  157.                 return;
  158.             if(unit_on_me != NULL)
  159.             {
  160.                 if(search_time < diff )
  161.             {
  162.             if(Creature->GetDistance2d(unit_on_me) != 0 || unit_on_me->isAlive())
  163.             {
  164.                 unit_on_me = NULL;
  165.             }
  166.  
  167.             search_time = 500;
  168.         }
  169.         else search_time -= diff;
  170.     }
  171. }
  172.  
  173. void SpellHit(Unit *caster,const SpellEntry *spell)
  174. {
  175.     if(spell->Id == SPELL_CHANGE_FACING)
  176.         caster->SetInFront(creature);
  177.     if(spell->Id == SPELL_MOVE_1 || spell->Id == SPELL_MOVE_2 || spell->Id == SPELL_MOVE_3
  178.         || spell->Id == SPELL_MOVE_4 || spell->Id == SPELL_MOVE_5 || spell->Id == SPELL_MOVE_6
  179.         || spell->Id == SPELL_MOVE_7)
  180.     {
  181.         if(unit_on_me != NULL)
  182.             return;
  183.         caster->GetMotionMaster()->Clear();
  184.         caster->GetMotionMaster()->MovePoint(0,creature->GetPositionX(),creature->GetPositionY(),creature->GetPositionZ());
  185.         unit_on_me = caster;
  186.         DoCast(creature,SPELL_MOVE_MARKER);
  187.     }
  188. }
  189. };
  190.  
  191. class chess_npc : public CreatureScript
  192. {
  193. public:
  194.     chess_npc() : CreatureScript("chess_npc") { }
  195.  
  196.     CreatureAI* GetAI(Creature* creature) const
  197.     {
  198.         return new chess_npcAI(creature);
  199.     }
  200.  
  201.     struct chess_npcAI : public ScriptedAI
  202.     {
  203.         chess_npcAI(Creature* c) : ScriptedAI(c) {}
  204.  
  205.         Creature *npc_medivh;
  206.         bool sendedtohome;
  207.         bool isInGame;
  208.         bool canmove;
  209.         uint32 original_faction_of_player;
  210.         Unit *creaturecharmer;
  211.         uint64 medivhGUID;
  212.         InstanceScript* instance;
  213.         uint32 healtimer;
  214.         uint32 move_timer;
  215.         std::list<Unit *> PossibleMoveUnits;
  216.         uint64 playerGUID;
  217.        
  218.         void MoveInLineOfSight(Unit *who)
  219.         {
  220.             if (creature->getVictim() && who->isTargetableForAttack() && ( creature->IsHostileTo( who )) && who->isInAccessiblePlaceFor(creature) )
  221.             {
  222.                 if (!creature->canFly() && creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
  223.                     return;
  224.  
  225.                 if( creature->IsWithinDistInMap(who, NPC_ATTACK_RADIUS) && creature->IsWithinLOSInMap(who) && isInGame)
  226.                 {
  227.                     who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
  228.                     AttackStart(who);
  229.                     playerGUID = who->GetGUID();
  230.                 }
  231.             }
  232.         }
  233.         void Aggro(Unit *Unit)
  234.         {
  235.             ImageGUID = instance->GetData64(DATA_IMAGE_OF_MEDIVH);
  236.             npc_medivh = (Creature*)Unit::GetUnit(*creature,ImageGUID);
  237.             Player* player = Unit::GetPlayer(playerGUID);
  238.             if(npc_medivh && player)
  239.             {
  240.                
  241.  
  242.             if (player->GetTeam() == ALLIANCE)
  243.             {
  244.                 if(creature->GetEntry() == NPC_KING_H)
  245.                 {
  246.                     npc_medivh->Say(SAY_MEDIVH_CHECK,LANG_UNIVERSAL,NULL);
  247.                 }
  248.                 else if(creature->GetEntry() == NPC_KING_A)
  249.                 {
  250.                     npc_medivh->Say(SAY_PLAYER_CHECK,LANG_UNIVERSAL,NULL);
  251.                 }
  252.             }
  253.             else
  254.             {
  255.                 if(creature->GetEntry() == NPC_KING_A)
  256.                 {
  257.                     npc_medivh->Say(SAY_MEDIVH_CHECK,LANG_UNIVERSAL,NULL);
  258.                 }
  259.                 else if(creature->GetEntry() == NPC_KING_H)
  260.                 {
  261.                     npc_medivh->Say(SAY_PLAYER_CHECK,LANG_UNIVERSAL,NULL);
  262.                 }
  263.             }
  264.         }
  265.     }
  266.  
  267.     void Reset()
  268.     {
  269.         healtimer = 7000;
  270.         sendedtohome = false;
  271.         isInGame = true;
  272.         canmove = true;
  273.         move_timer = 3000; //we wait 3s with move
  274.         creature->setActive(true);
  275.         playerGUID = 0;
  276.     }
  277.     void JustRespawned(){
  278.         //not finally - just a presentation - need 32place two side of chesstable
  279.         float angle = creature->GetOrientation();
  280.         float pos_x = -11066;
  281.         float pos_y = -1898;
  282.         int move_lenght = 2*rand()%10;
  283.         float new_x = pos_x + move_lenght * cos(angle);
  284.         float new_y = pos_y + move_lenght * sin(angle);
  285.         creature->Relocate(new_x,new_y,221,2.24);
  286.         creature->CombatStop();
  287.         creature->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_NOT_SELECTABLE);
  288.     }
  289.     void JustDied(Unit *Killer)
  290.     {
  291.         isInGame = false;
  292.         creature->setActive(false);
  293.         creature->Respawn();
  294.     }
  295.     void OnPossess(bool Apply)
  296.     {
  297.         if(Apply)
  298.         {
  299.             original_faction_of_player = creature->GetCharmer()->getFaction();
  300.             creaturecharmer = creature->GetCharmer();
  301.             //very big haxx imho, need fix in posses patch(make creature attackable by *_Creature_faction)
  302.             if (Player* player = me->GetPlayer(*me, playerGUID));
  303.                 return;
  304.             if(player->GetTeam() == ALLIANCE)
  305.             {
  306.                 creature->setFaction(ALLI_CREATURE_FACTION);
  307.                 creaturecharmer->setFaction(ALLI_CREATURE_FACTION);
  308.             }
  309.             else
  310.             {
  311.                 creature->setFaction(HORDE_CREATURE_FACTION);
  312.                 creaturecharmer->setFaction(HORDE_CREATURE_FACTION);
  313.             }
  314.         }
  315.         else
  316.         {
  317.             creaturecharmer->setFaction(original_faction_of_player);
  318.         }
  319.  
  320.     }
  321.     void KilledUnit(Unit* victim)
  322.     {
  323.         ImageGUID = instance->GetData64(DATA_IMAGE_OF_MEDIVH);
  324.         npc_medivh = (Creature*)Unit::GetUnit(*creature,ImageGUID);
  325.         Player* player = Unit::GetPlayer(playerGUID);
  326.         if(!npc_medivh || !player)
  327.             return;
  328.  
  329.         if(player->GetTeam() == HORDE)
  330.         {
  331.             switch(victim->GetEntry())
  332.             {
  333.                 case NPC_ROOK_H: npc_medivh->Say(SAY_LOSE_ROOK_P,LANG_UNIVERSAL,NULL);break;
  334.                 case NPC_ROOK_A: npc_medivh->Say(SAY_LOSE_ROOK_M,LANG_UNIVERSAL,NULL);break;
  335.                 case NPC_QUEEN_H: npc_medivh->Say(SAY_LOSE_QUEEN_P,LANG_UNIVERSAL,NULL);break;
  336.                 case NPC_QUEEN_A: npc_medivh->Say(SAY_LOSE_QUEEN_M,LANG_UNIVERSAL,NULL);break;
  337.                 case NPC_BISHOP_H: npc_medivh->Say(SAY_LOSE_BISHOP_P,LANG_UNIVERSAL,NULL);break;
  338.                 case NPC_BISHOP_A: npc_medivh->Say(SAY_LOSE_BISHOP_M,LANG_UNIVERSAL,NULL);break;
  339.                 case NPC_KNIGHT_H: npc_medivh->Say(SAY_LOSE_KNIGHT_P,LANG_UNIVERSAL,NULL);break;
  340.                 case NPC_KNIGHT_A: npc_medivh->Say(SAY_LOSE_KNIGHT_M,LANG_UNIVERSAL,NULL);break;
  341.                 case NPC_PAWN_H:
  342.                 switch(rand()%3)
  343.                 {
  344.                 case 0:npc_medivh->Say(SAY_LOSE_PAWN_P_1,LANG_UNIVERSAL,NULL);break;
  345.                 case 1:npc_medivh->Say(SAY_LOSE_PAWN_P_2,LANG_UNIVERSAL,NULL);break;
  346.                 case 2:npc_medivh->Say(SAY_LOSE_PAWN_P_3,LANG_UNIVERSAL,NULL);break;
  347.                 }
  348.                 break;
  349.                 case NPC_PAWN_A:
  350.                 switch(rand()%2)
  351.                 {
  352.                 case 0:npc_medivh->Say(SAY_LOSE_PAWN_M_1,LANG_UNIVERSAL,NULL);break;
  353.                 case 1:npc_medivh->Say(SAY_LOSE_PAWN_M_2,LANG_UNIVERSAL,NULL);break;
  354.                 }
  355.                 break;
  356.                 case NPC_KING_H:
  357.                 npc_medivh->Say(SAY_MEDIVH_WIN,LANG_UNIVERSAL,NULL);
  358.                 instance->SetData(TYPE_CHESS,FAIL);
  359.                 break;
  360.                 case NPC_KING_A:
  361.                 npc_medivh->Say(SAY_PLAYER_WIN,LANG_UNIVERSAL,NULL);
  362.                 instance->SetData(TYPE_CHESS,DONE);
  363.                 npc_medivh->SummonGameObject(DUST_COVERED_CHEST,-11058,-1903,221,2.24,0,0,0,0,7200000);
  364.                 break;
  365.                 default:
  366.                 break;
  367.             }
  368.         }
  369.         else
  370.         {
  371.             switch(victim->GetEntry())
  372.             {
  373.                 case NPC_ROOK_A: npc_medivh->Say(SAY_LOSE_ROOK_P,LANG_UNIVERSAL,NULL);break;
  374.                 case NPC_ROOK_H: npc_medivh->Say(SAY_LOSE_ROOK_M,LANG_UNIVERSAL,NULL);break;
  375.                 case NPC_QUEEN_A: npc_medivh->Say(SAY_LOSE_QUEEN_P,LANG_UNIVERSAL,NULL);break;
  376.                 case NPC_QUEEN_H: npc_medivh->Say(SAY_LOSE_QUEEN_M,LANG_UNIVERSAL,NULL);break;
  377.                 case NPC_BISHOP_A: npc_medivh->Say(SAY_LOSE_BISHOP_P,LANG_UNIVERSAL,NULL);break;
  378.                 case NPC_BISHOP_H: npc_medivh->Say(SAY_LOSE_BISHOP_M,LANG_UNIVERSAL,NULL);break;
  379.                 case NPC_KNIGHT_A: npc_medivh->Say(SAY_LOSE_KNIGHT_P,LANG_UNIVERSAL,NULL);break;
  380.                 case NPC_KNIGHT_H: npc_medivh->Say(SAY_LOSE_KNIGHT_M,LANG_UNIVERSAL,NULL);break;
  381.                 case NPC_PAWN_A:
  382.                 switch(rand()%3)
  383.                 {
  384.                 case 0:npc_medivh->Say(SAY_LOSE_PAWN_P_1,LANG_UNIVERSAL,NULL);break;
  385.                 case 1:npc_medivh->Say(SAY_LOSE_PAWN_P_2,LANG_UNIVERSAL,NULL);break;
  386.                 case 2:npc_medivh->Say(SAY_LOSE_PAWN_P_3,LANG_UNIVERSAL,NULL);break;
  387.                 }
  388.                 case NPC_PAWN_H:
  389.                 switch(rand()%2)
  390.                 {
  391.                 case 0:npc_medivh->Say(SAY_LOSE_PAWN_M_1,LANG_UNIVERSAL,NULL);break;
  392.                 case 1:npc_medivh->Say(SAY_LOSE_PAWN_M_2,LANG_UNIVERSAL,NULL);break;
  393.                 }
  394.                 break;
  395.                 case NPC_KING_A:
  396.                 npc_medivh->Say(SAY_MEDIVH_WIN,LANG_UNIVERSAL,NULL);
  397.                 instance->SetData(TYPE_CHESS,FAIL);
  398.                 break;
  399.                 case NPC_KING_H:
  400.                 npc_medivh->Say(SAY_PLAYER_WIN,LANG_UNIVERSAL,NULL);
  401.                 instance->SetData(TYPE_CHESS,DONE);
  402.                 npc_medivh->SummonGameObject(DUST_COVERED_CHEST,-11058,-1903,221,2.24,0,0,0,0,7200000);
  403.                 break;
  404.                 default:
  405.                 break;
  406.             }
  407.         }
  408.         if(victim->isPossessed())
  409.         {
  410.             victim->RemoveCharmAuras();
  411.         }      
  412.  
  413.     }
  414.     std::list<Unit*> FindPossibleMoveUnits()
  415.     {
  416.         //need argument for strafe/forwardmove
  417.         CellPair p(Trinity::ComputeCellPair(creature->GetPositionX(), creature->GetPositionY()));
  418.         Cell cell(p);
  419.         cell.data.Part.reserved = ALL_DISTRICT;
  420.         cell.SetNoCreate();
  421.  
  422.         std::list<Unit*> pList;
  423.         std::list<Unit*> returnList;
  424.         float range = GetStrafeLenght(creature->GetEntry())*SEARCH_RANGE;
  425.  
  426.         Trinity::AnyUnitInObjectRangeCheck u_check(creature,range);
  427.         Trinity::UnitListSearcher<Trinity::AnyUnitInObjectRangeCheck> searcher(pList, u_check);
  428.         TypeContainerVisitor<Trinity::UnitListSearcher<Trinity::AnyUnitInObjectRangeCheck>, GridTypeMapContainer >  grid_unit_searcher(searcher);
  429.  
  430.         CellLock<GridReadGuard> cell_lock(cell, p);
  431.         cell_lock->Visit(cell_lock, grid_unit_searcher, *(creature->GetMap()));
  432.         for(std::list<Unit *>::iterator itr = pList.begin(); itr != pList.end();itr++)
  433.     {
  434.         if((*itr)->GetEntry() != TRIGGER_ID)
  435.         {
  436.             continue;
  437.         }
  438.         returnList.push_back((*itr));
  439.         pList.clear();
  440.         return returnList;
  441.     }
  442.  
  443.     int GetStrafeLenght(uint32 Entry)
  444.     {
  445.         if(Entry == NPC_QUEEN_H ||Entry == NPC_QUEEN_A)
  446.             return 2;
  447.         return 1;
  448.     }
  449.     void UpdateAI(const uint32 diff)
  450.     {
  451.  
  452.         if(instance->GetData(DATA_CHESS_EVENT) == DONE || instance->GetData(DATA_CHESS_EVENT) == FAIL)
  453.         {
  454.             if(creature->isInCombat())
  455.                 creature->CombatStop();        
  456.  
  457.             if(creature->isPossessed())
  458.                 creature->RemoveCharmAuras();
  459.  
  460.             if(creature->HasFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_NOT_SELECTABLE))
  461.                 creature->RemoveFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_NOT_SELECTABLE);
  462.  
  463.             if(!sendedtohome)
  464.             {
  465.                 creature->GetMotionMaster()->Clear();
  466.                 creature->GetMotionMaster()->MoveTargetedHome();
  467.                 sendedtohome = true;
  468.             }
  469.         }
  470.         if(instance->GetData(DATA_CHESS_EVENT) != IN_PROGRESS)
  471.             return;
  472.  
  473.         if(sendedtohome) //for fail
  474.         {
  475.             sendedtohome = false;
  476.         }
  477.         if(!isInGame)
  478.             return;
  479.  
  480.         if(!creature->isPossessed())
  481.         {
  482.             if(!canmove)
  483.             {
  484.                 if(move_timer < diff)
  485.                 {
  486.                     canmove = true;
  487.                     move_timer = 6000;
  488.                     move_timer -= diff;
  489.                 }
  490.             }
  491.  
  492.             if(!creature->getVictim())
  493.             {
  494.                 if(!canmove)
  495.                     return;
  496.  
  497.                 PossibleMoveUnits = FindPossibleMoveUnits();
  498.                 if(PossibleMoveUnits.empty())
  499.                     return;
  500.                 std::list<Unit*>::iterator i = PossibleMoveUnits.begin();
  501.                 advance ( i ,rand()%PossibleMoveUnits.size());
  502.                 DoCast((*i),SPELL_MOVE_1);
  503.                 canmove = false;
  504.             }
  505.  
  506.             switch(creature->GetEntry())
  507.             {
  508.                 case NPC_ROOK_A:break;
  509.                 case NPC_ROOK_H:break;
  510.                 case NPC_QUEEN_A:break;
  511.                 case NPC_QUEEN_H:break;
  512.                 case NPC_BISHOP_A:
  513.                 if(healtimer <= diff)
  514.                 {
  515.                     Unit *target = DoSelectLowestHpFriendly(25,5000); //dont select player controlled unit
  516.                     if(target)
  517.                     DoCast(target,BISHOP_HEAL_A);
  518.                     healtimer = 21000;
  519.                 }
  520.                 else healtimer -= diff;
  521.                 break;
  522.                 case NPC_BISHOP_H:
  523.                 if(healtimer <= diff)
  524.                 {
  525.                     Unit *target = DoSelectLowestHpFriendly(25,5000); //dont select player controlled unit
  526.                     if(target)
  527.                     DoCast(target,BISHOP_HEAL_H);
  528.                     healtimer = 21000;
  529.                 }
  530.                 else healtimer -= diff;
  531.                 break;
  532.                 case NPC_KNIGHT_A:break;
  533.                 case NPC_KNIGHT_H:break;
  534.                 case NPC_PAWN_A:break;
  535.                 case NPC_PAWN_H:break;
  536.                 case NPC_KING_A:break;
  537.                 case NPC_KING_H:break;
  538.                 default:
  539.                 break;
  540.             }
  541.             if(creature->getVictim() || !creature->IsWithinDistInMap(creature->getVictim(), NPC_ATTACK_RADIUS))
  542.             {
  543.                 creature->CombatStop();
  544.                 return;
  545.             }
  546.         }
  547.  
  548.         DoMeleeAttackIfReady();
  549.     }
  550. };
  551.  
  552. bool GossipHello_chess_npc(Player* player, Creature* _Creature)
  553. {
  554.     InstanceScript* instance = ((InstanceScript*)_Creature->GetInstanceScript());
  555.  
  556.     if(instance->GetData(TYPE_CHESS) != IN_PROGRESS)
  557.         return true;
  558.     if(player->GetTeam() == ALLIANCE && _Creature->getFaction() != ALLI_CREATURE_FACTION)
  559.         return true;
  560.     if(player->GetTeam() == HORDE && _Creature->getFaction() != HORDE_CREATURE_FACTION)
  561.         return true;
  562.     if(!_Creature->isPossessedByPlayer())
  563.          player->ADD_GOSSIP_ITEM(0, GOSSIP_POSSES, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
  564.          player->SEND_GOSSIP_MENU(8990, _Creature->GetGUID());
  565.     return true;
  566. }
  567.  
  568. bool GossipSelect_chess_npc(Player* player, Creature* _Creature, uint32 sender, uint32 action)
  569. {
  570.     if(action == GOSSIP_ACTION_INFO_DEF + 1)
  571.     {
  572.         _Creature->SetCharmedOrPossessedBy(player, true);
  573.         //player->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISABLE_MOVE);
  574.         //_Creature->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISABLE_MOVE);
  575.     }
  576.  
  577.     player->CLOSE_GOSSIP_MENU();
  578.     return true;
  579. }
  580.  
  581. class npc_echo_of_medivh : public CreatureScript
  582. {
  583. public:
  584.     npc_echo_of_medivh() : CreatureScript("npc_echo_of_medivh") { }
  585.    
  586.     bool GossipHello_npc_echo_of_medivh(Player* player, Creature* _Creature)
  587.     {
  588.         InstanceScript* instance = ((InstanceScript*)_Creature->GetInstanceScript());
  589.         if(instance->GetData(TYPE_CHESS) == FAIL)
  590.         {
  591.             instance->SetData(TYPE_CHESS,NOT_STARTED);
  592.         }
  593.         if(instance->GetData(TYPE_CHESS) == DONE) //for testing
  594.         {
  595.             instance->SetData(TYPE_CHESS,NOT_STARTED);
  596.         }
  597.        
  598.         if(instance->GetData(TYPE_CHESS) != NOT_STARTED)
  599.             return true;
  600.        
  601.         player->ADD_GOSSIP_ITEM(0, EVENT_START, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
  602.         player->SEND_GOSSIP_MENU(8990, _Creature->GetGUID());
  603.         //_Creature->GetNpcTextId()
  604.         return true;
  605.     }
  606.    
  607.     bool GossipSelect_npc_echo_of_medivh(Player* player, Creature* _Creature, uint32 sender, uint32 action)
  608.     {
  609.         InstanceScript* instance = ((InstanceScript*)_Creature->GetInstanceScript());
  610.  
  611.         if(action == GOSSIP_ACTION_INFO_DEF + 1)
  612.         {
  613.             _Creature->Say(SAY_AT_EVENT_START,LANG_UNIVERSAL,NULL);
  614.             instance->SetData(TYPE_CHESS,IN_PROGRESS);
  615.             //instance->SetData(CHESS_EVENT_TEAM,player->GetTeam());
  616.             _Creature->GetMotionMaster()->MoveConfused();
  617.             //player->TeleportTo(-11054.032,-1909.979,229.626,2.190);
  618.         }
  619.  
  620.         player->CLOSE_GOSSIP_MENU();
  621.         return true;
  622.     }
  623. };
  624.     void AddSC_chess_event()
  625.     {
  626.         new chess_npc();
  627.         new npc_echo_of_medivh();
  628.         new chess_move_trigger();
  629.     }
  630.  
  631. /*
  632. UPDATE creature_template SET spell3=37462, spell4=37465 WHERE entry=21683;
  633. UPDATE creature_template SET spell2=37148, spell3=37471, spell4=37474 WHERE entry=21684;
  634. UPDATE creature_template SET spell2=37152, spell3=37455, spell4=37459 WHERE entry=21682;
  635. UPDATE creature_template SET spell1=30284, spell2=37144, spell3=37453, spell4=37498 WHERE entry=21664;
  636. UPDATE creature_template SET spell2=37151, spell3=37427, spell4=37432 WHERE entry=21160;
  637. UPDATE creature_template SET spell2=37146, spell3=37406, spell4=37414 WHERE entry=17211;
  638. UPDATE creature_template SET spell3=37472, spell4=37476 WHERE entry=21752;
  639. UPDATE creature_template SET spell3=37463, spell4=37461 WHERE entry=21750;
  640. UPDATE creature_template SET spell2=37152, spell3=37456, spell4=37461 WHERE entry=21747;
  641. UPDATE creature_template SET spell1=30284, spell2=37144, spell3=37454, spell4=37502 WHERE entry=21748;
  642. UPDATE creature_template SET spell2=37151, spell3=37434, spell4=37428 WHERE entry=21726;
  643. UPDATE creature_template SET spell2=37146, spell3=37413, spell4=37416 WHERE entry=17469;
  644.  
  645. update creature_template set scriptname = "chess_npc" where entry in (17469,17211,21748,21664,21750,21683,21747,21682,21726,21160,21752,21684);
  646. update creature_template set scriptname = "npc_echo_of_medivh" where entry = 16816;
  647. update creature_template set scriptname = "chess_move_trigger" where entry = 22519;
  648.  
  649. INSERT INTO `creature` (`guid`, `id`, `map`, `spawnMask`, `modelid`, `equipment_id`, `position_x`, `position_y`, `position_z`, `orientation`, `spawntimesecs`, `spawndist`, `currentwaypoint`, `curhealth`, `curmana`, `DeathState`, `MovementType`) VALUES (NULL, 16816, 532, 1, 0, 0, -11074, -1853.28, 220.667, 3.84199, 7200, 0, 0, 50000, 0, 0, 0);
  650.  
  651. Triggers
  652.  
  653. UPDATE creature SET position_x = '-11089.131836', position_y = '-1841.463867', position_z = '221.070999', orientation = '5.734146' WHERE guid = '1523302';
  654. DELETE FROM creature WHERE guid = '1523981';
  655. INSERT INTO creature VALUES (1523981,22519,532,1,0,0,-11078.3,-1848.74,220.668,5.41802,25,0,0,8,0,0,0);
  656. DELETE FROM creature WHERE guid = '1523983';
  657. INSERT INTO creature VALUES (1523983,22519,532,1,0,0,-11074.1,-1853.58,220.668,5.41802,25,0,0,8,0,0,0);
  658. DELETE FROM creature WHERE guid = '1523985';
  659. INSERT INTO creature VALUES (1523985,22519,532,1,0,0,-11070.8,-1857.51,220.668,5.41802,25,0,0,8,0,0,0);
  660. DELETE FROM creature WHERE guid = '1523987';
  661. INSERT INTO creature VALUES (1523987,22519,532,1,0,0,-11067.3,-1861.65,220.668,5.41802,25,0,0,8,0,0,0);
  662. DELETE FROM creature WHERE guid = '1523989';
  663. INSERT INTO creature VALUES (1523989,22519,532,1,0,0,-11063.7,-1865.84,220.668,3.81895,25,0,0,8,0,0,0);
  664. DELETE FROM creature WHERE guid = '1523991';
  665. INSERT INTO creature VALUES (1523991,22519,532,1,0,0,-11059.8,-1870.83,220.668,2.84192,25,0,0,8,0,0,0);
  666. DELETE FROM creature WHERE guid = '1523993';
  667. INSERT INTO creature VALUES (1523993,22519,532,1,0,0,-11057.6,-1874.61,220.668,5.64108,25,0,0,8,0,0,0);
  668. DELETE FROM creature WHERE guid = '1523995';
  669. INSERT INTO creature VALUES (1523995,22519,532,1,0,0,-11054.6,-1878.95,220.668,5.78481,25,0,0,8,0,0,0);
  670. DELETE FROM creature WHERE guid = '1523997';
  671. INSERT INTO creature VALUES (1523997,22519,532,1,0,0,-11057.8,-1882.23,220.668,4.60357,25,0,0,8,0,0,0);
  672. DELETE FROM creature WHERE guid = '1523999';
  673. INSERT INTO creature VALUES (1523999,22519,532,1,0,0,-11060.7,-1878.66,220.668,3.86529,25,0,0,8,0,0,0);
  674. DELETE FROM creature WHERE guid = '1524001';
  675. INSERT INTO creature VALUES (1524001,22519,532,1,0,0,-11064,-1874.8,220.668,2.27464,25,0,0,8,0,0,0);
  676. DELETE FROM creature WHERE guid = '1524003';
  677. INSERT INTO creature VALUES (1524003,22519,532,1,0,0,-11067.7,-1870.41,220.668,2.27464,25,0,0,8,0,0,0);
  678. DELETE FROM creature WHERE guid = '1524005';
  679. INSERT INTO creature VALUES (1524005,22519,532,1,0,0,-11070.8,-1866.71,220.668,2.27464,25,0,0,8,0,0,0);
  680. DELETE FROM creature WHERE guid = '1524007';
  681. INSERT INTO creature VALUES (1524007,22519,532,1,0,0,-11070.8,-1866.71,220.668,2.27464,25,0,0,8,0,0,0);
  682. DELETE FROM creature WHERE guid = '1524009';
  683. INSERT INTO creature VALUES (1524009,22519,532,1,0,0,-11074.7,-1862.17,220.668,2.27464,25,0,0,8,0,0,0);
  684. DELETE FROM creature WHERE guid = '1524011';
  685. INSERT INTO creature VALUES (1524011,22519,532,1,0,0,-11078.4,-1857.76,220.668,2.27464,25,0,0,8,0,0,0);
  686. DELETE FROM creature WHERE guid = '1524013';
  687. INSERT INTO creature VALUES (1524013,22519,532,1,0,0,-11082,-1853.61,220.668,2.27464,25,0,0,8,0,0,0);
  688. DELETE FROM creature WHERE guid = '1524015';
  689. INSERT INTO creature VALUES (1524015,22519,532,1,0,0,-11085.3,-1855.97,220.668,2.65478,25,0,0,8,0,0,0);
  690. DELETE FROM creature WHERE guid = '1524017';
  691. INSERT INTO creature VALUES (1524017,22519,532,1,0,0,-11082.7,-1859.65,220.668,5.33141,25,0,0,8,0,0,0);
  692. DELETE FROM creature WHERE guid = '1524019';
  693. INSERT INTO creature VALUES (1524019,22519,532,1,0,0,-11079.6,-1864.03,220.668,5.33141,25,0,0,8,0,0,0);
  694. DELETE FROM creature WHERE guid = '1524021';
  695. INSERT INTO creature VALUES (1524021,22519,532,1,0,0,-11075.6,-1869.63,220.668,5.33141,25,0,0,8,0,0,0);
  696. DELETE FROM creature WHERE guid = '1524023';
  697. INSERT INTO creature VALUES (1524023,22519,532,1,0,0,-11072.5,-1873.48,220.668,5.45394,25,0,0,8,0,0,0);
  698. DELETE FROM creature WHERE guid = '1524025';
  699. INSERT INTO creature VALUES (1524025,22519,532,1,0,0,-11069.4,-1877.84,220.668,5.83485,25,0,0,8,0,0,0);
  700. DELETE FROM creature WHERE guid = '1524027';
  701. INSERT INTO creature VALUES (1524027,22519,532,1,0,0,-11066.3,-1881.92,220.668,6.2464,25,0,0,8,0,0,0);
  702. DELETE FROM creature WHERE guid = '1524029';
  703. INSERT INTO creature VALUES (1524029,22519,532,1,0,0,-11062.2,-1886.33,220.668,5.39896,25,0,0,8,0,0,0);
  704. DELETE FROM creature WHERE guid = '1524031';
  705. INSERT INTO creature VALUES (1524031,22519,532,1,0,0,-11066,-1889.75,220.668,3.75669,25,0,0,8,0,0,0);
  706. DELETE FROM creature WHERE guid = '1524033';
  707. INSERT INTO creature VALUES (1524033,22519,532,1,0,0,-11069.5,-1885.3,220.668,2.2393,25,0,0,8,0,0,0);
  708. DELETE FROM creature WHERE guid = '1524035';
  709. INSERT INTO creature VALUES (1524035,22519,532,1,0,0,-11072.8,-1881.1,220.668,2.2393,25,0,0,8,0,0,0);
  710. DELETE FROM creature WHERE guid = '1524037';
  711. INSERT INTO creature VALUES (1524037,22519,532,1,0,0,-11076.5,-1876.47,220.668,2.2393,25,0,0,8,0,0,0);
  712. DELETE FROM creature WHERE guid = '1524039';
  713. INSERT INTO creature VALUES (1524039,22519,532,1,0,0,-11079.3,-1872.86,220.668,2.2393,25,0,0,8,0,0,0);
  714. DELETE FROM creature WHERE guid = '1524041';
  715. INSERT INTO creature VALUES (1524041,22519,532,1,0,0,-11082.8,-1868.5,220.668,2.2393,25,0,0,8,0,0,0);
  716. DELETE FROM creature WHERE guid = '1524043';
  717. INSERT INTO creature VALUES (1524043,22519,532,1,0,0,-11086.6,-1864.39,220.668,2.17882,25,0,0,8,0,0,0);
  718. DELETE FROM creature WHERE guid = '1524045';
  719. INSERT INTO creature VALUES (1524045,22519,532,1,0,0,-11090.3,-1860.19,220.668,2.33983,25,0,0,8,0,0,0);
  720. DELETE FROM creature WHERE guid = '1524047';
  721. INSERT INTO creature VALUES (1524047,22519,532,1,0,0,-11094.8,-1863.03,220.668,3.57369,25,0,0,8,0,0,0);
  722. DELETE FROM creature WHERE guid = '1524049';
  723. INSERT INTO creature VALUES (1524049,22519,532,1,0,0,-11091.4,-1866.6,220.668,5.12564,25,0,0,8,0,0,0);
  724. DELETE FROM creature WHERE guid = '1524051';
  725. INSERT INTO creature VALUES (1524051,22519,532,1,0,0,-11087.7,-1870.88,220.668,4.99919,25,0,0,8,0,0,0);
  726. DELETE FROM creature WHERE guid = '1524053';
  727. INSERT INTO creature VALUES (1524053,22519,532,1,0,0,-11084.8,-1875.5,220.668,5.41388,25,0,0,8,0,0,0);
  728. DELETE FROM creature WHERE guid = '1524055';
  729. INSERT INTO creature VALUES (1524055,22519,532,1,0,0,-11080.7,-1880.27,220.668,5.41388,25,0,0,8,0,0,0);
  730. DELETE FROM creature WHERE guid = '1524057';
  731. INSERT INTO creature VALUES (1524057,22519,532,1,0,0,-11077.4,-1884.23,220.668,5.41388,25,0,0,8,0,0,0);
  732. DELETE FROM creature WHERE guid = '1524059';
  733. INSERT INTO creature VALUES (1524059,22519,532,1,0,0,-11074.2,-1888.1,220.668,5.32199,25,0,0,8,0,0,0);
  734. DELETE FROM creature WHERE guid = '1524061';
  735. INSERT INTO creature VALUES (1524061,22519,532,1,0,0,-11071,-1892.7,220.668,5.32199,25,0,0,8,0,0,0);
  736. DELETE FROM creature WHERE guid = '1524063';
  737. INSERT INTO creature VALUES (1524063,22519,532,1,0,0,-11075.2,-1896.22,220.668,4.93793,25,0,0,8,0,0,0);
  738. DELETE FROM creature WHERE guid = '1524065';
  739. INSERT INTO creature VALUES (1524065,22519,532,1,0,0,-11078.9,-1892.13,220.668,2.29899,25,0,0,8,0,0,0);
  740. DELETE FROM creature WHERE guid = '1524067';
  741. INSERT INTO creature VALUES (1524067,22519,532,1,0,0,-11081.5,-1888.96,220.668,2.15055,25,0,0,8,0,0,0);
  742. DELETE FROM creature WHERE guid = '1524069';
  743. INSERT INTO creature VALUES (1524069,22519,532,1,0,0,-11084.8,-1883.69,220.668,2.35554,25,0,0,8,0,0,0);
  744. DELETE FROM creature WHERE guid = '1524071';
  745. INSERT INTO creature VALUES (1524071,22519,532,1,0,0,-11088.2,-1879.71,220.668,2.24951,25,0,0,8,0,0,0);
  746. DELETE FROM creature WHERE guid = '1524073';
  747. INSERT INTO creature VALUES (1524073,22519,532,1,0,0,-11092.5,-1874.34,220.668,2.24951,25,0,0,8,0,0,0);
  748. DELETE FROM creature WHERE guid = '1524075';
  749. INSERT INTO creature VALUES (1524075,22519,532,1,0,0,-11095.2,-1870.99,220.668,2.24951,25,0,0,8,0,0,0);
  750. DELETE FROM creature WHERE guid = '1524077';
  751. INSERT INTO creature VALUES (1524077,22519,532,1,0,0,-11098.7,-1866.69,220.668,2.24951,25,0,0,8,0,0,0);
  752. DELETE FROM creature WHERE guid = '1524079';
  753. INSERT INTO creature VALUES (1524079,22519,532,1,0,0,-11103.7,-1869.11,220.668,3.68443,25,0,0,8,0,0,0);
  754. DELETE FROM creature WHERE guid = '1524081';
  755. INSERT INTO creature VALUES (1524081,22519,532,1,0,0,-11099.7,-1873.42,220.668,5.28979,25,0,0,8,0,0,0);
  756. DELETE FROM creature WHERE guid = '1524083';
  757. INSERT INTO creature VALUES (1524083,22519,532,1,0,0,-11096.5,-1878.36,220.668,5.28979,25,0,0,8,0,0,0);
  758. DELETE FROM creature WHERE guid = '1524085';
  759. INSERT INTO creature VALUES (1524085,22519,532,1,0,0,-11093.2,-1881.88,220.668,4.65519,25,0,0,8,0,0,0);
  760. DELETE FROM creature WHERE guid = '1524087';
  761. INSERT INTO creature VALUES (1524087,22519,532,1,0,0,-11089.8,-1886.71,220.668,5.3212,25,0,0,8,0,0,0);
  762. DELETE FROM creature WHERE guid = '1524089';
  763. INSERT INTO creature VALUES (1524089,22519,532,1,0,0,-11086.8,-1891.13,220.668,5.3212,25,0,0,8,0,0,0);
  764. DELETE FROM creature WHERE guid = '1524091';
  765. INSERT INTO creature VALUES (1524091,22519,532,1,0,0,-11083.2,-1895.54,220.668,4.9984,25,0,0,8,0,0,0);
  766. DELETE FROM creature WHERE guid = '1524093';
  767. INSERT INTO creature VALUES (1524093,22519,532,1,0,0,-11080.1,-1900.17,220.668,5.50185,25,0,0,8,0,0,0);
  768. DELETE FROM creature WHERE guid = '1524095';
  769. INSERT INTO creature VALUES (1524095,22519,532,1,0,0,-11082.9,-1902.83,220.668,3.9122,25,0,0,8,0,0,0);
  770. DELETE FROM creature WHERE guid = '1524097';
  771. INSERT INTO creature VALUES (1524097,22519,532,1,0,0,-11085.8,-1899.68,220.668,2.41287,25,0,0,8,0,0,0);
  772. DELETE FROM creature WHERE guid = '1524099';
  773. INSERT INTO creature VALUES (1524099,22519,532,1,0,0,-11089.9,-1895.41,220.668,2.29978,25,0,0,8,0,0,0);
  774. DELETE FROM creature WHERE guid = '1524101';
  775. INSERT INTO creature VALUES (1524101,22519,532,1,0,0,-11094.3,-1890.5,220.668,2.29978,25,0,0,8,0,0,0);
  776. DELETE FROM creature WHERE guid = '1524103';
  777. INSERT INTO creature VALUES (1524103,22519,532,1,0,0,-11097.1,-1886.43,220.668,2.31705,25,0,0,8,0,0,0);
  778. DELETE FROM creature WHERE guid = '1524105';
  779. INSERT INTO creature VALUES (1524105,22519,532,1,0,0,-11100.5,-1881.81,220.668,2.46314,25,0,0,8,0,0,0);
  780. DELETE FROM creature WHERE guid = '1524107';
  781. INSERT INTO creature VALUES (1524107,22519,532,1,0,0,-11103.5,-1877.88,220.668,2.22124,25,0,0,8,0,0,0);
  782. DELETE FROM creature WHERE guid = '1524109';
  783. INSERT INTO creature VALUES (1524109,22519,532,1,0,0,-11107.4,-1873.91,220.668,2.43565,25,0,0,8,0,0,0);
  784. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement