Guest User

Untitled

a guest
Jul 18th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.73 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using DOL.Database;
  6. using DOL.GS;
  7. using DOL.Language;
  8. using DOL.GS.PacketHandler;
  9. using log4net;
  10. using System;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Reflection;
  14. using DOL.GS.Scripts;
  15.  
  16. using DOL.GS.Quests;
  17. using DOL.GS;
  18.  
  19. using DOL.GS;
  20. using DOL.GS.Effects;
  21. using DOL.Events;
  22.  
  23. namespace DOL.GS
  24. {
  25. public enum eFaithClassType : int
  26. {
  27. Healer = 0,
  28. HybridHealer = 1,
  29. LightTank = 2,
  30. HeavyTank = 3,
  31. Caster = 4
  32. }
  33. public class FaithUtils
  34. {
  35. public static int PvPCap = 20;
  36.  
  37. public static bool Enable_Guild_PvP_Leaderboard = false;
  38. public static Dictionary<string, int> SoloPlayerDeathblowList = new Dictionary<string, int>();
  39. public static Dictionary<string, int> GuildDeathblowList = new Dictionary<string, int>();
  40.  
  41.  
  42. public static GameLocation SetupSpawnLocation = new GameLocation("SETUP-SPAWN", 10, 34805, 22902, 8464, 12);
  43. private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  44. [GameServerStartedEvent]
  45. public static void OnServerStartup(DOLEvent e, object sender, EventArgs args)
  46. {
  47.  
  48.  
  49. }
  50. public static void GiveCredit(GamePlayer player)
  51. {
  52. foreach (GamePlayer p1 in player.GetPlayersInRadius(3000))
  53. {
  54. DragonslayerQuest quest = p1.IsDoingQuest(typeof(DragonslayerQuest)) as DragonslayerQuest;
  55. if (quest != null)
  56. {
  57. if (!quest.killLeviathan.IsAchieved)
  58. {
  59. quest.killLeviathan.Advance();
  60. p1.Out.SendMessage("You have killed Leviathan! Now return to Los Ortiz to gain your reward!", PacketHandler.eChatType.CT_ScreenCenter, PacketHandler.eChatLoc.CL_ChatWindow);
  61. }
  62. }
  63.  
  64. }
  65. }
  66. public static void ForceBroadCast(string playerNameWhoBroadcasts, string msg)
  67. {
  68. foreach (GameClient thisClient in WorldMgr.GetAllPlayingClients())
  69. {
  70.  
  71. thisClient.Player.Out.SendMessage(LanguageMgr.GetTranslation("EN", "Scripts.Players.Broadcast.Message", playerNameWhoBroadcasts, msg), eChatType.CT_Broadcast, eChatLoc.CL_ChatWindow);
  72. }
  73. }
  74. public static bool IPIFDM(GamePlayer player)
  75. {
  76. return IsPlayerInFaithDebugMode(player);
  77. }
  78. public static bool IsPlayerInFaithDebugMode(GamePlayer player)
  79. {
  80. return player.TempProperties.getProperty<bool>("FAITH_DEBUG_FLAG");
  81. }
  82. public static bool IsPlayerVIP(GamePlayer player)
  83. {
  84. if (player.Client.Account.Status == 1)
  85. {
  86. return true;
  87. }
  88.  
  89. return false;
  90. }
  91. public static bool IsPlayerRR14OnOldServer(GamePlayer player)
  92. {
  93. if (player.Client.Account.IsRR14OnOldFaith == true)
  94. {
  95. return true;
  96. }
  97. return false;
  98. }
  99. public static bool HasPlayerGotTransfer(GamePlayer player)
  100. {
  101. if (player.Client.Account.HasPlayerGotFreeTransfer == true)
  102. {
  103. return true;
  104. }
  105. return false;
  106. }
  107. public static void PortPlayerToCTF(MyPlayer player, eRealm team)
  108. {
  109.  
  110.  
  111. int relX = 0, relY = 0, relZ = 0;
  112. ushort relRegion = 0, relHeading = 0;
  113. if (player.Realm == eRealm.Albion)
  114. {
  115. GameLocation randomLoc = CTFHandler.redSpawnLocations[Util.Random(0, CTFHandler.redSpawnLocations.Count - 1)];
  116. if (randomLoc == null)
  117. {
  118. Console.WriteLine("RANDOM LOC IS NULL");
  119. return;
  120. }
  121.  
  122. relX = randomLoc.X;
  123. relY = randomLoc.Y;
  124. relZ = randomLoc.Z;
  125. relHeading = randomLoc.Heading;
  126. relRegion = randomLoc.RegionID;
  127. }
  128. if (player.Realm == eRealm.Midgard)
  129. {
  130. GameLocation randomLoc = CTFHandler.blueSpawnLocations[Util.Random(0, CTFHandler.blueSpawnLocations.Count - 1)];
  131. if (randomLoc == null)
  132. {
  133. Console.WriteLine("RANDOM LOC IS NULL");
  134. return;
  135. }
  136.  
  137. relX = randomLoc.X;
  138. relY = randomLoc.Y;
  139. relZ = randomLoc.Z;
  140. relHeading = randomLoc.Heading;
  141. relRegion = randomLoc.RegionID;
  142. }
  143.  
  144. player.Realm = team;
  145.  
  146. string teamName = team == eRealm.Albion ? "Red" : "Blue";
  147. player.CTFGuild = GuildMgr.GetGuildByName(teamName + " CTF");
  148. player.SaveIntoDatabase();
  149.  
  150. player.MoveTo(relRegion, relX, relY, relZ, relHeading);
  151.  
  152. FaithCTFBlueScoreEffect blueEffect = (FaithCTFBlueScoreEffect)player.EffectList.GetOfType(typeof(FaithCTFBlueScoreEffect));
  153. if (blueEffect == null)
  154. {
  155. blueEffect = new FaithCTFBlueScoreEffect();
  156. blueEffect.Start(player);
  157. }
  158. blueEffect.EffectName = "Blue: " + CTFHandler.BlueScore + "/" + CTFHandler.PointsNeeded + " points";
  159. blueEffect.UpdateScore(player);
  160.  
  161. FaithCTFRedScoreEffect redEffect = (FaithCTFRedScoreEffect)player.EffectList.GetOfType(typeof(FaithCTFRedScoreEffect));
  162. if (redEffect == null)
  163. {
  164. redEffect = new FaithCTFRedScoreEffect();
  165. redEffect.Start(player);
  166. }
  167. redEffect.EffectName = "Red: " + CTFHandler.RedScore + "/" + CTFHandler.PointsNeeded + " points";
  168. redEffect.UpdateScore(player);
  169.  
  170.  
  171. Buffbot.BuffPlayer(player);
  172.  
  173.  
  174. if (player.Group == null)
  175. {
  176. int totalGrps = 0;
  177. foreach (GameClient client in WorldMgr.GetClientsOfRegion(GlobalFaithStuff.CTFRegionUsed))
  178. {
  179. if (client.Player != null && client.Player.Group != null && client.Player.Realm == team && client.Player.Group.MemberCount < 8)
  180. {
  181. totalGrps += 1;
  182. }
  183. }
  184.  
  185. if (totalGrps == 0)
  186. {
  187. Group group = new Group(player);
  188. GroupMgr.AddGroup(group, group);
  189. group.AddMember(player);
  190. foreach (GameClient client in WorldMgr.GetClientsOfRegion(GlobalFaithStuff.CTFRegionUsed))
  191. {
  192. if (client.Player != null && client.Player.Group == null && client.Player.Realm == team && group.MemberCount < 8)
  193. {
  194. group.AddMember(client.Player);
  195. }
  196. }
  197.  
  198. }
  199. else
  200. {
  201. foreach (GameClient client in WorldMgr.GetClientsOfRegion(GlobalFaithStuff.CTFRegionUsed))
  202. {
  203. if (client.Player != null && client.Player.Group != null && client.Player.Realm == team && player.Group.MemberCount < 8)
  204. {
  205. client.Player.Group.AddMember(player);
  206. return;
  207. }
  208. }
  209. }
  210. }
  211. }
  212. public static void QueuePortRedCTFResponse(GamePlayer player, byte response)
  213. {
  214. if (response != 0x01)
  215. {
  216. return; //declined
  217. }
  218. player.SaveIntoDatabase();
  219. PortPlayerToCTF(player as MyPlayer, eRealm.Albion);
  220. }
  221. public static void QueuePortBlueCTFResponse(GamePlayer player, byte response)
  222. {
  223. if (response != 0x01)
  224. {
  225. return; //declined
  226. }
  227. player.SaveIntoDatabase();
  228. PortPlayerToCTF(player as MyPlayer, eRealm.Midgard);
  229. }
  230. public static void QueuePortPvPDialogREsponse(GamePlayer player, byte response)
  231. {
  232. Queue<string> queuedObjects = QueueManager.getQueuedObjects(QueueManager.eQueueType.PvPQueue);
  233. if (response != 0x01)
  234. {
  235. QueueManager.DequeueQueue(QueueManager.eQueueType.PvPQueue);
  236. FaithUtils.Info("response is D E C L I N E, removing");
  237. return; //declined
  238. }
  239. if (FaithUtils.PlayersInPvP() > FaithUtils.PvPCap)
  240. {
  241. player.Out.SendMessage("Sorry, too slow :/ PvP is capped again! you are still in the queue though, so keep trying!", eChatType.CT_Advise, eChatLoc.CL_ChatWindow);
  242. return;
  243. }
  244. QueueManager.DequeueQueue(QueueManager.eQueueType.PvPQueue);
  245. PvPHandler.PortToPvPZone(player);
  246. // player.MoveTo(51, 239699, 439530, 4839, 1008);
  247. player.Bind(true);
  248. if (player.Group != null)
  249. {
  250. player.Group.RemoveMember(player);
  251.  
  252. }
  253. }
  254.  
  255. public static int GetClientsWithRealmAndRegion(eRealm realm, ushort region)
  256. {
  257. int count = 0;
  258. foreach (GameClient client in WorldMgr.GetClientsOfRegion(region))
  259. {
  260. if (client.Player == null)
  261. {
  262. continue;
  263. }
  264. if (client.Player.Realm == realm)
  265. {
  266. count += 1;
  267. }
  268. }
  269. return count;
  270. }
  271. public static ItemTemplate GetItemByKey(string Name)
  272. {
  273. ItemTemplate item = GameServer.Database.FindObjectByKey<ItemTemplate>(Name);
  274. return item;
  275. }
  276. public static eFaithClassType getPlayerClassType(GamePlayer player)
  277. {
  278. switch (player.CharacterClass.ID)
  279. {
  280. case (int)eCharacterClass.Healer:
  281. case (int)eCharacterClass.Cleric:
  282. case (int)eCharacterClass.Druid:
  283. return eFaithClassType.Healer;
  284.  
  285. case (int)eCharacterClass.Friar:
  286. case (int)eCharacterClass.Heretic:
  287. case (int)eCharacterClass.Shaman:
  288. case (int)eCharacterClass.Bard:
  289. case (int)eCharacterClass.Warden:
  290. return eFaithClassType.HybridHealer;
  291. }
  292. if (player.CharacterClass.ClassType == eClassType.ListCaster)
  293. {
  294. return eFaithClassType.Caster;
  295. }
  296. return eFaithClassType.HeavyTank;
  297. }
  298. public static void GivePlayerFaithToken(GamePlayer player)
  299. {
  300. InventoryItem existing = player.Inventory.GetFirstItemByName("Faith Token", eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack);
  301. ItemTemplate itemTemplate = GetItemByKey("FaithToken");
  302. if (itemTemplate == null)
  303. {
  304. Console.WriteLine("FaithToken item does not exist, aborting GivePlayerFaithToken");
  305. return;
  306.  
  307. }
  308. InventoryItem item = GameInventoryItem.Create<ItemTemplate>(itemTemplate);
  309.  
  310.  
  311. if (existing == null)
  312. {
  313. if (player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, item))
  314. {
  315. player.Out.SendMessage("You receive the " + itemTemplate.Name + ".", eChatType.CT_System, eChatLoc.CL_SystemWindow);
  316. }
  317. else
  318. {
  319. player.CreateItemOnTheGround(item);
  320. player.Out.SendMessage("Your Inventory is full. You couldn't recieve the " + itemTemplate.Name + ", so it's been placed on the ground. Pick it up as soon as possible or it will vanish in a few minutes.", eChatType.CT_Important, eChatLoc.CL_PopupWindow);
  321. }
  322. }
  323. else
  324. {
  325. player.Inventory.AddCountToStack(existing, 1);
  326. }
  327. player.Out.SendMessage("You have received " + 1 + " Faith Token!", eChatType.CT_ScreenCenter, eChatLoc.CL_ChatWindow);
  328. }
  329. public static void GivePlayerFaithToken(GamePlayer player,int count)
  330. {
  331.  
  332. InventoryItem existing = player.Inventory.GetFirstItemByName("Faith Token", eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack);
  333. ItemTemplate itemTemplate = GetItemByKey("FaithToken");
  334. InventoryItem item = GameInventoryItem.Create<ItemTemplate>(itemTemplate);
  335. item.Count = count;
  336.  
  337. if (existing == null)
  338. {
  339. if (player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, item))
  340. {
  341. // player.Out.SendMessage("You receive the " + itemTemplate.Name + ".", eChatType.CT_System, eChatLoc.CL_SystemWindow);
  342. }
  343. else
  344. {
  345. player.CreateItemOnTheGround(item);
  346. player.Out.SendMessage("Your Inventory is full. You couldn't recieve the " + itemTemplate.Name + ", so it's been placed on the ground. Pick it up as soon as possible or it will vanish in a few minutes.", eChatType.CT_Important, eChatLoc.CL_PopupWindow);
  347. }
  348. }
  349. else
  350. {
  351. player.Inventory.AddCountToStack(existing, count);
  352. }
  353.  
  354. player.Out.SendMessage("You have received " + count + " Faith Tokens!", eChatType.CT_Advise, eChatLoc.CL_ChatWindow);
  355. player.Out.SendMessage("You have received " + count + " Faith Tokens!", eChatType.CT_ScreenCenter, eChatLoc.CL_ChatWindow);
  356. }
  357. public static ChatGroup getPCG(GamePlayer player)
  358. {
  359. ChatGroup mychatgroup = (ChatGroup)player.TempProperties.getProperty<object>(ChatGroup.CHATGROUP_PROPERTY, null);
  360. return mychatgroup;
  361. }
  362. public static void storeStringValue(string key, string value)
  363. {
  364. //faithcode #[
  365. }
  366. public static void Info(string value)
  367. {
  368. log.Info(value);
  369. }
  370. public static void Error(string value)
  371. {
  372. log.Error(value);
  373. }
  374. public static bool GroupInCombat(GamePlayer player, int milliseconds)
  375. {
  376. if (player.Group == null)
  377. {
  378. return false;
  379. }
  380. foreach (GamePlayer t in player.Group.GetPlayersInTheGroup())
  381. {
  382. if (t.InCombatInLast(milliseconds))
  383. {
  384. return true;
  385. }
  386. }
  387. return false;
  388. }
  389. public static bool IsPlayerCustomClass(GamePlayer player)
  390. {
  391. switch (player.CharacterClass.ID)
  392. {
  393. case (int)eCharacterClass.BloodStalker:
  394. case (int)eCharacterClass.Immortal:
  395. case (int)eCharacterClass.Saboteur:
  396. return true;
  397. }
  398. return false;
  399. }
  400. public static GamePlayer getRandomPlayer()
  401. {
  402. IList<GameClient> List = WorldMgr.GetAllPlayingClients();
  403. return List[Util.Random(0, List.Count - 1)].Player;
  404. }
  405. public static GamePlayer getRandomPlayerFromRealm(eRealm realm)
  406. {
  407. IList<GameClient> realmList = WorldMgr.GetClientsOfRealm(realm);
  408. return realmList[Util.Random(0, realmList.Count - 1)].Player;
  409. }
  410. public static void UnlockClassForPlayer(GamePlayer player, eCharacterClass classID)
  411. {
  412. AccountXSettings settings = player.TempProperties.getProperty<AccountXSettings>(AccountXSettings.AccountXSettings_KEY);
  413. switch (classID)
  414. {
  415. case eCharacterClass.Saboteur:
  416. settings.UnlockedSaboteur = true;
  417. break;
  418. case eCharacterClass.Immortal:
  419. break;
  420. case eCharacterClass.BloodStalker:
  421. settings.UnlockedSaboteur = true;
  422. break;
  423. }
  424. }
  425. //player.Out.SendInventoryItemsUpdate(new InventoryItem[] { item });
  426. public static void DyePlayerItems(GamePlayer player, int color)
  427. {
  428. foreach (InventoryItem item in player.Inventory.GetItemRange(eInventorySlot.MinEquipable, eInventorySlot.MaxEquipable))
  429. {
  430. Console.WriteLine("DYING " + item.Name);
  431. item.Color = color;
  432. player.Out.SendInventoryItemsUpdate(new InventoryItem[] { item });
  433. }
  434.  
  435. }
  436. public static void PlaceBountyOn(GameClient client, GamePlayer chosenHead, long rps)
  437. {
  438. CustomEvents.bountyHeads.Add(chosenHead.Name, rps);
  439. foreach (GameClient clients in WorldMgr.GetAllPlayingClients())
  440. {
  441. clients.Out.SendMessage(string.Format("{0} has placed a bounty on {1}'s head worth {2} realmpoints", client.Player.Name, chosenHead.Name, rps), eChatType.CT_Important, eChatLoc.CL_ChatWindow);
  442. clients.Out.SendMessage(string.Format("{0} has placed a bounty on {1}'s head worth {2} realmpoints", client.Player.Name, chosenHead.Name, rps), eChatType.CT_ScreenCenter, eChatLoc.CL_ChatWindow);
  443. }
  444.  
  445. foreach (GamePlayer pl in chosenHead.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
  446. pl.Out.SendMinotaurRelicWindow(chosenHead, 159, true);
  447. }
  448. public static GameNPC getMobFromName(string Name, string Guild)
  449. {
  450. GameNPC[] npcs = WorldMgr.GetNPCsByName(Name, eRealm.None);
  451. if (npcs.Length > 0 && npcs != null)
  452. {
  453. foreach (GameNPC npc in npcs)
  454. {
  455. if (npc != null)
  456. {
  457. if (npc.GuildName == Guild)
  458. {
  459. return npc;
  460. }
  461. }
  462. }
  463. }
  464. return null;
  465. }
  466. public static void PortRvR(GamePlayer player)
  467. {
  468. GameNPC albPort = getMobFromName("Thidranki", "Alb Thid RvR");
  469. GameNPC midPort = getMobFromName("Thidranki", "Mid Thid RvR");
  470. GameNPC hibPort = getMobFromName("Thidranki", "Hib Thid RvR");
  471.  
  472. switch (player.Realm)
  473. {
  474. case eRealm.Midgard:
  475. portToMob(player, midPort);
  476. break;
  477. case eRealm.Albion:
  478. portToMob(player, albPort);
  479. break;
  480. case eRealm.Hibernia:
  481. portToMob(player, hibPort);
  482. break;
  483. }
  484. player.Bind(true);
  485. }
  486. public static int PlayersInPvP()
  487. {
  488. Console.WriteLine("PlayersInPvP #1");
  489. int count = 0;
  490.  
  491. if (PvPHandler.currentPvPPort() == null)
  492. {
  493. return count;
  494. }
  495. Console.WriteLine("PlayersInPvP #2");
  496. foreach (GameClient client in WorldMgr.GetClientsOfRegion(PvPHandler.currentPvPPort().CurrentRegionID))
  497. {
  498. if (client != null && client.Player != null)
  499. {
  500. if (client.Account.Status == 0) // only non vips count.
  501. {
  502. count += 1;
  503. }
  504. }
  505. }
  506. Console.WriteLine("PlayersInPvP #3");
  507. return count;
  508. }
  509. public static int CustomClassesInRegion(GamePlayer player, ushort regionid)
  510. {
  511. int count = 0;
  512. foreach (GameClient client in WorldMgr.GetClientsOfRegion(regionid))
  513. {
  514. if (FaithUtils.IsPlayerCustomClass(client.Player))
  515. {
  516. count += 1;
  517. }
  518. }
  519. return count;
  520. }
  521. public static int PlayersInDuel(GamePlayer player)
  522. {
  523. int count = 0;
  524. foreach (GameClient client in WorldMgr.GetClientsOfRegion(91))
  525. {
  526. if (client.Account.Status == 0) // only non vips count.
  527. {
  528. count += 1;
  529. }
  530. }
  531. return count;
  532. }
  533. public static void portpvpDialogResponse(GamePlayer player, byte response)
  534. {
  535. if (response != 0x01)
  536. {
  537. return; //declined
  538. }
  539.  
  540. {
  541. PvPHandler.PortToPvPZone(player);
  542. // player.MoveTo(51, 239699, 439530, 4839, 1008);
  543. player.Bind(true);
  544. if (player.Group != null)
  545. {
  546. player.Group.RemoveMember(player);
  547. }
  548. }
  549.  
  550. }
  551. //player.Out.SendInventoryItemsUpdate(new InventoryItem[] { item });
  552.  
  553. public static void portRvRDialogResponse(GamePlayer player, byte response)
  554. {
  555. if (response != 0x01)
  556. {
  557. return; //declined
  558. }
  559.  
  560. {
  561. player.Model = (ushort)player.Client.Account.Characters[player.Client.ActiveCharIndex].CreationModel;
  562. player.Out.SendUpdatePlayer();
  563. player.SaveIntoDatabase();
  564. if (player.Group != null)
  565. {
  566. player.Group.RemoveMember(player);
  567. }
  568. PortRvR(player); ;
  569. player.Bind(true);
  570. //player.Out.SendLoginGranted(2);
  571.  
  572. }
  573.  
  574.  
  575. }
  576. //portRvRDialogResponse
  577.  
  578. public static void PortPlayerToSetup(GamePlayer player)
  579. {
  580. if (!IsPlayerCustomClass(player))
  581. {
  582. //player.Realm = (eRealm)GlobalConstants.GetClassBaseRealm((eCharacterClass)player.CharacterClass.ID);
  583.  
  584. //player.Out.SendUpdatePlayer();
  585. //player.SaveIntoDatabase();
  586. }//SetupSpawnLocation
  587. player.MoveTo(SetupSpawnLocation);
  588.  
  589. player.Realm = GlobalConstants.GetPlayerBaseRealm(player);
  590. player.SaveIntoDatabase();
  591. }
  592. public static void portToMob(GamePlayer player, GameNPC npc)
  593. {
  594. try
  595. {
  596. if (npc == null)
  597. {
  598. player.Out.SendMessage("Error #1, please contact a GM", eChatType.CT_Important, eChatLoc.CL_ChatWindow);
  599. return;
  600. }
  601. }
  602. catch (Exception exc)
  603. {
  604. Console.WriteLine("BOOOOM EXCEPTION = " + exc.Message);
  605. }
  606. player.MoveTo(npc.CurrentRegionID, npc.X, npc.Y, npc.Z, npc.Heading);
  607. }
  608. public static GameNPC getMobFromNameAndGuild(string Name, string Guild)
  609. {
  610. GameNPC[] npcs = WorldMgr.GetNPCsByName(Name, eRealm.None);
  611. if (npcs.Length > 0 && npcs != null)
  612. {
  613. foreach (GameNPC npc in npcs)
  614. {
  615. if (npc != null)
  616. {
  617. if (npc.GuildName == Guild)
  618. {
  619. return npc;
  620. }
  621. }
  622. }
  623. }
  624. return null;
  625. }
  626. public static List<GameNPC> getMobsFromNameAndGuildAndRealm(string Name, string Guild, eRealm realm)
  627. {
  628. List<GameNPC> list = new List<GameNPC>();
  629.  
  630. GameNPC[] npcs = WorldMgr.GetNPCsByName(Name, realm);
  631. if (npcs.Length > 0 && npcs != null)
  632. {
  633. foreach (GameNPC npc in npcs)
  634. {
  635. if (npc != null)
  636. {
  637. if (npc.GuildName == Guild)
  638. {
  639. list.Add(npc);
  640. }
  641. }
  642. }
  643. }
  644. return list;
  645. }
  646. public static void SendCasterSpellEffectAndCastMessage(GameLiving caster, ushort spellEffect, bool success)
  647. {
  648. foreach (GamePlayer player in caster.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
  649. {
  650. player.Out.SendSpellEffectAnimation(caster, caster, spellEffect, 0, false, success ? (byte)1 : (byte)0);
  651.  
  652. if (caster.IsWithinRadius(player, WorldMgr.INFO_DISTANCE))
  653. {
  654. if (player == caster)
  655. {
  656. player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "RealmAbility.SendCasterSpellEffectAndCastMessage.You", caster.Name), eChatType.CT_Spell, eChatLoc.CL_SystemWindow);
  657. }
  658. else
  659. {
  660. player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "RealmAbility.SendCasterSpellEffectAndCastMessage.Caster", caster.Name), eChatType.CT_Spell, eChatLoc.CL_SystemWindow);
  661. }
  662. }
  663. }
  664. }
  665. public static int RealmCountInRegion(ushort region, eRealm realm)
  666. {
  667. int count = 0;
  668. foreach (GameClient client in WorldMgr.GetClientsOfRegion(region))
  669. {
  670. if (client != null && client.Player != null)
  671. {
  672. if (client.Player.Realm == realm)
  673. {
  674. count += 1;
  675. }
  676. }
  677. }
  678. return count;
  679. }
  680. public static int GetNumOfFaithTokensInPlayerInventory(GamePlayer player)
  681. {
  682. int count = 0;
  683.  
  684. foreach (InventoryItem item in player.Inventory.GetItemRange(eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack))
  685. {
  686. if (item.Name.ToLower().Contains("faith token"))
  687. {
  688. count += 1;
  689. }
  690. }
  691. return count;
  692. }
  693. public static InventoryItem GetHighestStackOfFaithTokensFromPlayerInventory(GamePlayer player)
  694. {
  695. int highestCount = 0;
  696. InventoryItem highestCountItem = null;
  697.  
  698. foreach (InventoryItem item in player.Inventory.GetItemRange(eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack))
  699. {
  700. if (item.Name.ToLower().Contains("faith token"))
  701. {
  702. if (item.Count > highestCount)
  703. {
  704. highestCount = item.Count;
  705. highestCountItem = item;
  706. }
  707. }
  708. }
  709. return highestCountItem;
  710. }
  711. public static void portsetupDialogResponse(GamePlayer player, byte response)
  712. {
  713. if (response != 0x01)
  714. {
  715. return; //declined
  716. }
  717.  
  718. {
  719. FaithUtils.PortPlayerToSetup(player);
  720. player.Bind(true);
  721. }
  722.  
  723. }
  724. public static bool RemoveFaithTokensFromPlayerInventory(GamePlayer player, int count)
  725. {
  726.  
  727. InventoryItem toRemoveFrom = GetHighestStackOfFaithTokensFromPlayerInventory(player);
  728. if (toRemoveFrom == null)
  729. {
  730. return false;
  731. }
  732. if (toRemoveFrom.Count < count)
  733. {
  734. return false;
  735. }
  736. player.Inventory.RemoveCountFromStack(toRemoveFrom, count);
  737.  
  738.  
  739. return true;
  740.  
  741. }
  742. }
  743. }
Add Comment
Please, Sign In to add comment