kusanagy

Res Group

Dec 30th, 2016
432
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.46 KB | None | 0 0
  1.     /*---------------------------------------------*\
  2.     |               Coded By Obitus                 |
  3.     |               April 02, 2016                  |
  4.     |           Tested on TrinityCore 3.3.5         |
  5.     |       Added distance check (Thanks to Phil)   |
  6.     |    This is the 2nd version - without gossip   |
  7.     \*---------------------------------------------*/
  8.  
  9. //I was insipired by http://www.wowhead.com/spell=83968/mass-resurrection
  10.  
  11. /*
  12. -- Execute this query in WORLD DATABASE
  13. INSERT INTO `item_template` (`entry`, `class`, `SoundOverrideSubclass`, `name`, `displayid`, `Quality`, `Flags`, `FlagsExtra`, `BuyCount`, `BuyPrice`, `SellPrice`, `AllowableClass`, `AllowableRace`, `RequiredLevel`, `maxcount`, `stackable`, `delay`, `spellid_1`, `spellcooldown_1`, `spellcategorycooldown_1`, `spellcooldown_2`, `spellcategorycooldown_2`, `spellcooldown_3`, `spellcategorycooldown_3`, `spellcooldown_4`, `spellcategorycooldown_4`, `spellcooldown_5`, `spellcategorycooldown_5`, `description`, `RequiredDisenchantSkill`, `ScriptName`)
  14. VALUES (192000, 15, -1, 'Mass Resurrection', 67105, 7, 0, 0, 1, 228800000, 34, -1, -1, 28, 1, 1, 1000, 14093, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, '|cffffffff100 yd range\r\n|cffffd400Brings all dead party and raid members back to life with 35% health and 35% mana. Cannot be cast in combat or while in a battleground or arena.\r\nYou can use this item once every 15 minutes.', -1, 'item_res_group');
  15.  
  16. */
  17.  
  18.  
  19. #include "ScriptMgr.h"
  20. #include "Player.h"
  21. #include "Group.h"
  22. #include "ObjectAccessor.h"
  23. #include "ScriptedGossip.h"
  24. #include "WorldSession.h"
  25.  
  26. class item_res_group : public ItemScript
  27. {
  28. public:
  29.     item_res_group() : ItemScript("item_res_group") { }
  30.  
  31.     bool DistanceIsValid(Position* playerWhoUsesTheItem, Position* deadPlayersInGroup)
  32.     {
  33.         if (std::abs(deadPlayersInGroup->GetPositionX() - playerWhoUsesTheItem->GetPositionX()) <= 91.44) //91.44 meters = 100 yards
  34.             return true;
  35.         return false;
  36.     }
  37.  
  38.     bool OnUse(Player* playerWhoUsesTheItem, Item* item, SpellCastTargets const& /*targets*/)
  39.     {
  40.         Group* group = playerWhoUsesTheItem->GetGroup();
  41.         Group::MemberSlotList const &members = group->GetMemberSlots();
  42.  
  43.         if (playerWhoUsesTheItem->HasAura(38910)) //Fel Weakness
  44.         {
  45.             playerWhoUsesTheItem->GetSession()->SendNotification("Usted debe esperar 15 minutos para usar este objeto otra vez");
  46.             return false;
  47.         }
  48.  
  49.         if (!playerWhoUsesTheItem->GetGroup())
  50.         {
  51.             playerWhoUsesTheItem->GetSession()->SendNotification("Usted no está en un grupo!");
  52.             return false;
  53.         }
  54.         /* //What if the leader is dead?
  55.         if (playerWhoUsesTheItem->GetGroup()->GetLeaderGUID() != playerWhoUsesTheItem->GetGUID())
  56.         {
  57.             playerWhoUsesTheItem->GetSession()->SendNotification("You are not the group leader!");
  58.             return false;
  59.         }
  60.         */
  61.         if (playerWhoUsesTheItem->InBattleground())
  62.         {
  63.             playerWhoUsesTheItem->GetSession()->SendNotification("Usted no puede usar este objeto en un campo de batalla!");
  64.             return false;
  65.         }
  66.  
  67.         if (playerWhoUsesTheItem->InArena())
  68.         {
  69.             playerWhoUsesTheItem->GetSession()->SendNotification("Usted no puede usar este objeto en una Arena!");
  70.             return false;
  71.         }
  72.  
  73.         if (playerWhoUsesTheItem->IsInCombat())
  74.         {
  75.             playerWhoUsesTheItem->GetSession()->SendNotification("Usted no puede usar este objeto en combate!");
  76.             return false;
  77.         }
  78.        
  79.         else
  80.         {
  81.             for (Group::MemberSlotList::const_iterator itr = members.begin(); itr != members.end(); ++itr)
  82.             {
  83.                 Group::MemberSlot const &slot = *itr;
  84.                 Player* deadPlayersInGroup = ObjectAccessor::FindPlayer((*itr).guid);
  85.  
  86.                 //skip if player/s is/are offline //--This check is mandatory. the server will crash without it
  87.                 if (!deadPlayersInGroup || deadPlayersInGroup->GetSession()->PlayerDisconnected())
  88.                 {
  89.                     playerWhoUsesTheItem->CLOSE_GOSSIP_MENU();
  90.                 }
  91.  
  92.                 if (deadPlayersInGroup && deadPlayersInGroup->GetSession() && deadPlayersInGroup->isDead() && playerWhoUsesTheItem->GetSession() && DistanceIsValid(playerWhoUsesTheItem, deadPlayersInGroup))
  93.                 {
  94.                     deadPlayersInGroup->ResurrectPlayer(0.35f, false); //35% hp and mana, don't apply Resurrection Sickness
  95.                     deadPlayersInGroup->CastSpell(deadPlayersInGroup, 48171, true); //Visual Spell Resurrect (priest)
  96.                     deadPlayersInGroup->DurabilityRepairAll(0, 0, false); //Repair All - upon resurrection
  97.                     playerWhoUsesTheItem->CastSpell(playerWhoUsesTheItem, 38910, true); //Fel Weakness //Cast a debuff on player To prevent the item being used over and over again
  98.                 }
  99.             }
  100.         }
  101.         return true;
  102.     }
  103. };
  104.  
  105. void AddSC_item_res_group()
  106. {
  107.     new item_res_group;
  108. }
Advertisement
Add Comment
Please, Sign In to add comment