Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using DOL.Database;
- using DOL.GS;
- using DOL.Language;
- using DOL.GS.PacketHandler;
- using log4net;
- using System;
- using System.Linq;
- using System.Text;
- using System.Reflection;
- using DOL.GS.Scripts;
- using DOL.GS.Quests;
- using DOL.GS;
- using DOL.GS;
- using DOL.GS.Effects;
- using DOL.Events;
- namespace DOL.GS
- {
- public enum eFaithClassType : int
- {
- Healer = 0,
- HybridHealer = 1,
- LightTank = 2,
- HeavyTank = 3,
- Caster = 4
- }
- public class FaithUtils
- {
- public static int PvPCap = 20;
- public static bool Enable_Guild_PvP_Leaderboard = false;
- public static Dictionary<string, int> SoloPlayerDeathblowList = new Dictionary<string, int>();
- public static Dictionary<string, int> GuildDeathblowList = new Dictionary<string, int>();
- public static GameLocation SetupSpawnLocation = new GameLocation("SETUP-SPAWN", 10, 34805, 22902, 8464, 12);
- private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
- [GameServerStartedEvent]
- public static void OnServerStartup(DOLEvent e, object sender, EventArgs args)
- {
- }
- public static void GiveCredit(GamePlayer player)
- {
- foreach (GamePlayer p1 in player.GetPlayersInRadius(3000))
- {
- DragonslayerQuest quest = p1.IsDoingQuest(typeof(DragonslayerQuest)) as DragonslayerQuest;
- if (quest != null)
- {
- if (!quest.killLeviathan.IsAchieved)
- {
- quest.killLeviathan.Advance();
- p1.Out.SendMessage("You have killed Leviathan! Now return to Los Ortiz to gain your reward!", PacketHandler.eChatType.CT_ScreenCenter, PacketHandler.eChatLoc.CL_ChatWindow);
- }
- }
- }
- }
- public static void ForceBroadCast(string playerNameWhoBroadcasts, string msg)
- {
- foreach (GameClient thisClient in WorldMgr.GetAllPlayingClients())
- {
- thisClient.Player.Out.SendMessage(LanguageMgr.GetTranslation("EN", "Scripts.Players.Broadcast.Message", playerNameWhoBroadcasts, msg), eChatType.CT_Broadcast, eChatLoc.CL_ChatWindow);
- }
- }
- public static bool IPIFDM(GamePlayer player)
- {
- return IsPlayerInFaithDebugMode(player);
- }
- public static bool IsPlayerInFaithDebugMode(GamePlayer player)
- {
- return player.TempProperties.getProperty<bool>("FAITH_DEBUG_FLAG");
- }
- public static bool IsPlayerVIP(GamePlayer player)
- {
- if (player.Client.Account.Status == 1)
- {
- return true;
- }
- return false;
- }
- public static bool IsPlayerRR14OnOldServer(GamePlayer player)
- {
- if (player.Client.Account.IsRR14OnOldFaith == true)
- {
- return true;
- }
- return false;
- }
- public static bool HasPlayerGotTransfer(GamePlayer player)
- {
- if (player.Client.Account.HasPlayerGotFreeTransfer == true)
- {
- return true;
- }
- return false;
- }
- public static void PortPlayerToCTF(MyPlayer player, eRealm team)
- {
- int relX = 0, relY = 0, relZ = 0;
- ushort relRegion = 0, relHeading = 0;
- if (player.Realm == eRealm.Albion)
- {
- GameLocation randomLoc = CTFHandler.redSpawnLocations[Util.Random(0, CTFHandler.redSpawnLocations.Count - 1)];
- if (randomLoc == null)
- {
- Console.WriteLine("RANDOM LOC IS NULL");
- return;
- }
- relX = randomLoc.X;
- relY = randomLoc.Y;
- relZ = randomLoc.Z;
- relHeading = randomLoc.Heading;
- relRegion = randomLoc.RegionID;
- }
- if (player.Realm == eRealm.Midgard)
- {
- GameLocation randomLoc = CTFHandler.blueSpawnLocations[Util.Random(0, CTFHandler.blueSpawnLocations.Count - 1)];
- if (randomLoc == null)
- {
- Console.WriteLine("RANDOM LOC IS NULL");
- return;
- }
- relX = randomLoc.X;
- relY = randomLoc.Y;
- relZ = randomLoc.Z;
- relHeading = randomLoc.Heading;
- relRegion = randomLoc.RegionID;
- }
- player.Realm = team;
- string teamName = team == eRealm.Albion ? "Red" : "Blue";
- player.CTFGuild = GuildMgr.GetGuildByName(teamName + " CTF");
- player.SaveIntoDatabase();
- player.MoveTo(relRegion, relX, relY, relZ, relHeading);
- FaithCTFBlueScoreEffect blueEffect = (FaithCTFBlueScoreEffect)player.EffectList.GetOfType(typeof(FaithCTFBlueScoreEffect));
- if (blueEffect == null)
- {
- blueEffect = new FaithCTFBlueScoreEffect();
- blueEffect.Start(player);
- }
- blueEffect.EffectName = "Blue: " + CTFHandler.BlueScore + "/" + CTFHandler.PointsNeeded + " points";
- blueEffect.UpdateScore(player);
- FaithCTFRedScoreEffect redEffect = (FaithCTFRedScoreEffect)player.EffectList.GetOfType(typeof(FaithCTFRedScoreEffect));
- if (redEffect == null)
- {
- redEffect = new FaithCTFRedScoreEffect();
- redEffect.Start(player);
- }
- redEffect.EffectName = "Red: " + CTFHandler.RedScore + "/" + CTFHandler.PointsNeeded + " points";
- redEffect.UpdateScore(player);
- Buffbot.BuffPlayer(player);
- if (player.Group == null)
- {
- int totalGrps = 0;
- foreach (GameClient client in WorldMgr.GetClientsOfRegion(GlobalFaithStuff.CTFRegionUsed))
- {
- if (client.Player != null && client.Player.Group != null && client.Player.Realm == team && client.Player.Group.MemberCount < 8)
- {
- totalGrps += 1;
- }
- }
- if (totalGrps == 0)
- {
- Group group = new Group(player);
- GroupMgr.AddGroup(group, group);
- group.AddMember(player);
- foreach (GameClient client in WorldMgr.GetClientsOfRegion(GlobalFaithStuff.CTFRegionUsed))
- {
- if (client.Player != null && client.Player.Group == null && client.Player.Realm == team && group.MemberCount < 8)
- {
- group.AddMember(client.Player);
- }
- }
- }
- else
- {
- foreach (GameClient client in WorldMgr.GetClientsOfRegion(GlobalFaithStuff.CTFRegionUsed))
- {
- if (client.Player != null && client.Player.Group != null && client.Player.Realm == team && player.Group.MemberCount < 8)
- {
- client.Player.Group.AddMember(player);
- return;
- }
- }
- }
- }
- }
- public static void QueuePortRedCTFResponse(GamePlayer player, byte response)
- {
- if (response != 0x01)
- {
- return; //declined
- }
- player.SaveIntoDatabase();
- PortPlayerToCTF(player as MyPlayer, eRealm.Albion);
- }
- public static void QueuePortBlueCTFResponse(GamePlayer player, byte response)
- {
- if (response != 0x01)
- {
- return; //declined
- }
- player.SaveIntoDatabase();
- PortPlayerToCTF(player as MyPlayer, eRealm.Midgard);
- }
- public static void QueuePortPvPDialogREsponse(GamePlayer player, byte response)
- {
- Queue<string> queuedObjects = QueueManager.getQueuedObjects(QueueManager.eQueueType.PvPQueue);
- if (response != 0x01)
- {
- QueueManager.DequeueQueue(QueueManager.eQueueType.PvPQueue);
- FaithUtils.Info("response is D E C L I N E, removing");
- return; //declined
- }
- if (FaithUtils.PlayersInPvP() > FaithUtils.PvPCap)
- {
- 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);
- return;
- }
- QueueManager.DequeueQueue(QueueManager.eQueueType.PvPQueue);
- PvPHandler.PortToPvPZone(player);
- // player.MoveTo(51, 239699, 439530, 4839, 1008);
- player.Bind(true);
- if (player.Group != null)
- {
- player.Group.RemoveMember(player);
- }
- }
- public static int GetClientsWithRealmAndRegion(eRealm realm, ushort region)
- {
- int count = 0;
- foreach (GameClient client in WorldMgr.GetClientsOfRegion(region))
- {
- if (client.Player == null)
- {
- continue;
- }
- if (client.Player.Realm == realm)
- {
- count += 1;
- }
- }
- return count;
- }
- public static ItemTemplate GetItemByKey(string Name)
- {
- ItemTemplate item = GameServer.Database.FindObjectByKey<ItemTemplate>(Name);
- return item;
- }
- public static eFaithClassType getPlayerClassType(GamePlayer player)
- {
- switch (player.CharacterClass.ID)
- {
- case (int)eCharacterClass.Healer:
- case (int)eCharacterClass.Cleric:
- case (int)eCharacterClass.Druid:
- return eFaithClassType.Healer;
- case (int)eCharacterClass.Friar:
- case (int)eCharacterClass.Heretic:
- case (int)eCharacterClass.Shaman:
- case (int)eCharacterClass.Bard:
- case (int)eCharacterClass.Warden:
- return eFaithClassType.HybridHealer;
- }
- if (player.CharacterClass.ClassType == eClassType.ListCaster)
- {
- return eFaithClassType.Caster;
- }
- return eFaithClassType.HeavyTank;
- }
- public static void GivePlayerFaithToken(GamePlayer player)
- {
- InventoryItem existing = player.Inventory.GetFirstItemByName("Faith Token", eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack);
- ItemTemplate itemTemplate = GetItemByKey("FaithToken");
- if (itemTemplate == null)
- {
- Console.WriteLine("FaithToken item does not exist, aborting GivePlayerFaithToken");
- return;
- }
- InventoryItem item = GameInventoryItem.Create<ItemTemplate>(itemTemplate);
- if (existing == null)
- {
- if (player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, item))
- {
- player.Out.SendMessage("You receive the " + itemTemplate.Name + ".", eChatType.CT_System, eChatLoc.CL_SystemWindow);
- }
- else
- {
- player.CreateItemOnTheGround(item);
- 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);
- }
- }
- else
- {
- player.Inventory.AddCountToStack(existing, 1);
- }
- player.Out.SendMessage("You have received " + 1 + " Faith Token!", eChatType.CT_ScreenCenter, eChatLoc.CL_ChatWindow);
- }
- public static void GivePlayerFaithToken(GamePlayer player,int count)
- {
- InventoryItem existing = player.Inventory.GetFirstItemByName("Faith Token", eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack);
- ItemTemplate itemTemplate = GetItemByKey("FaithToken");
- InventoryItem item = GameInventoryItem.Create<ItemTemplate>(itemTemplate);
- item.Count = count;
- if (existing == null)
- {
- if (player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, item))
- {
- // player.Out.SendMessage("You receive the " + itemTemplate.Name + ".", eChatType.CT_System, eChatLoc.CL_SystemWindow);
- }
- else
- {
- player.CreateItemOnTheGround(item);
- 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);
- }
- }
- else
- {
- player.Inventory.AddCountToStack(existing, count);
- }
- player.Out.SendMessage("You have received " + count + " Faith Tokens!", eChatType.CT_Advise, eChatLoc.CL_ChatWindow);
- player.Out.SendMessage("You have received " + count + " Faith Tokens!", eChatType.CT_ScreenCenter, eChatLoc.CL_ChatWindow);
- }
- public static ChatGroup getPCG(GamePlayer player)
- {
- ChatGroup mychatgroup = (ChatGroup)player.TempProperties.getProperty<object>(ChatGroup.CHATGROUP_PROPERTY, null);
- return mychatgroup;
- }
- public static void storeStringValue(string key, string value)
- {
- //faithcode #[
- }
- public static void Info(string value)
- {
- log.Info(value);
- }
- public static void Error(string value)
- {
- log.Error(value);
- }
- public static bool GroupInCombat(GamePlayer player, int milliseconds)
- {
- if (player.Group == null)
- {
- return false;
- }
- foreach (GamePlayer t in player.Group.GetPlayersInTheGroup())
- {
- if (t.InCombatInLast(milliseconds))
- {
- return true;
- }
- }
- return false;
- }
- public static bool IsPlayerCustomClass(GamePlayer player)
- {
- switch (player.CharacterClass.ID)
- {
- case (int)eCharacterClass.BloodStalker:
- case (int)eCharacterClass.Immortal:
- case (int)eCharacterClass.Saboteur:
- return true;
- }
- return false;
- }
- public static GamePlayer getRandomPlayer()
- {
- IList<GameClient> List = WorldMgr.GetAllPlayingClients();
- return List[Util.Random(0, List.Count - 1)].Player;
- }
- public static GamePlayer getRandomPlayerFromRealm(eRealm realm)
- {
- IList<GameClient> realmList = WorldMgr.GetClientsOfRealm(realm);
- return realmList[Util.Random(0, realmList.Count - 1)].Player;
- }
- public static void UnlockClassForPlayer(GamePlayer player, eCharacterClass classID)
- {
- AccountXSettings settings = player.TempProperties.getProperty<AccountXSettings>(AccountXSettings.AccountXSettings_KEY);
- switch (classID)
- {
- case eCharacterClass.Saboteur:
- settings.UnlockedSaboteur = true;
- break;
- case eCharacterClass.Immortal:
- break;
- case eCharacterClass.BloodStalker:
- settings.UnlockedSaboteur = true;
- break;
- }
- }
- //player.Out.SendInventoryItemsUpdate(new InventoryItem[] { item });
- public static void DyePlayerItems(GamePlayer player, int color)
- {
- foreach (InventoryItem item in player.Inventory.GetItemRange(eInventorySlot.MinEquipable, eInventorySlot.MaxEquipable))
- {
- Console.WriteLine("DYING " + item.Name);
- item.Color = color;
- player.Out.SendInventoryItemsUpdate(new InventoryItem[] { item });
- }
- }
- public static void PlaceBountyOn(GameClient client, GamePlayer chosenHead, long rps)
- {
- CustomEvents.bountyHeads.Add(chosenHead.Name, rps);
- foreach (GameClient clients in WorldMgr.GetAllPlayingClients())
- {
- 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);
- 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);
- }
- foreach (GamePlayer pl in chosenHead.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
- pl.Out.SendMinotaurRelicWindow(chosenHead, 159, true);
- }
- public static GameNPC getMobFromName(string Name, string Guild)
- {
- GameNPC[] npcs = WorldMgr.GetNPCsByName(Name, eRealm.None);
- if (npcs.Length > 0 && npcs != null)
- {
- foreach (GameNPC npc in npcs)
- {
- if (npc != null)
- {
- if (npc.GuildName == Guild)
- {
- return npc;
- }
- }
- }
- }
- return null;
- }
- public static void PortRvR(GamePlayer player)
- {
- GameNPC albPort = getMobFromName("Thidranki", "Alb Thid RvR");
- GameNPC midPort = getMobFromName("Thidranki", "Mid Thid RvR");
- GameNPC hibPort = getMobFromName("Thidranki", "Hib Thid RvR");
- switch (player.Realm)
- {
- case eRealm.Midgard:
- portToMob(player, midPort);
- break;
- case eRealm.Albion:
- portToMob(player, albPort);
- break;
- case eRealm.Hibernia:
- portToMob(player, hibPort);
- break;
- }
- player.Bind(true);
- }
- public static int PlayersInPvP()
- {
- Console.WriteLine("PlayersInPvP #1");
- int count = 0;
- if (PvPHandler.currentPvPPort() == null)
- {
- return count;
- }
- Console.WriteLine("PlayersInPvP #2");
- foreach (GameClient client in WorldMgr.GetClientsOfRegion(PvPHandler.currentPvPPort().CurrentRegionID))
- {
- if (client != null && client.Player != null)
- {
- if (client.Account.Status == 0) // only non vips count.
- {
- count += 1;
- }
- }
- }
- Console.WriteLine("PlayersInPvP #3");
- return count;
- }
- public static int CustomClassesInRegion(GamePlayer player, ushort regionid)
- {
- int count = 0;
- foreach (GameClient client in WorldMgr.GetClientsOfRegion(regionid))
- {
- if (FaithUtils.IsPlayerCustomClass(client.Player))
- {
- count += 1;
- }
- }
- return count;
- }
- public static int PlayersInDuel(GamePlayer player)
- {
- int count = 0;
- foreach (GameClient client in WorldMgr.GetClientsOfRegion(91))
- {
- if (client.Account.Status == 0) // only non vips count.
- {
- count += 1;
- }
- }
- return count;
- }
- public static void portpvpDialogResponse(GamePlayer player, byte response)
- {
- if (response != 0x01)
- {
- return; //declined
- }
- {
- PvPHandler.PortToPvPZone(player);
- // player.MoveTo(51, 239699, 439530, 4839, 1008);
- player.Bind(true);
- if (player.Group != null)
- {
- player.Group.RemoveMember(player);
- }
- }
- }
- //player.Out.SendInventoryItemsUpdate(new InventoryItem[] { item });
- public static void portRvRDialogResponse(GamePlayer player, byte response)
- {
- if (response != 0x01)
- {
- return; //declined
- }
- {
- player.Model = (ushort)player.Client.Account.Characters[player.Client.ActiveCharIndex].CreationModel;
- player.Out.SendUpdatePlayer();
- player.SaveIntoDatabase();
- if (player.Group != null)
- {
- player.Group.RemoveMember(player);
- }
- PortRvR(player); ;
- player.Bind(true);
- //player.Out.SendLoginGranted(2);
- }
- }
- //portRvRDialogResponse
- public static void PortPlayerToSetup(GamePlayer player)
- {
- if (!IsPlayerCustomClass(player))
- {
- //player.Realm = (eRealm)GlobalConstants.GetClassBaseRealm((eCharacterClass)player.CharacterClass.ID);
- //player.Out.SendUpdatePlayer();
- //player.SaveIntoDatabase();
- }//SetupSpawnLocation
- player.MoveTo(SetupSpawnLocation);
- player.Realm = GlobalConstants.GetPlayerBaseRealm(player);
- player.SaveIntoDatabase();
- }
- public static void portToMob(GamePlayer player, GameNPC npc)
- {
- try
- {
- if (npc == null)
- {
- player.Out.SendMessage("Error #1, please contact a GM", eChatType.CT_Important, eChatLoc.CL_ChatWindow);
- return;
- }
- }
- catch (Exception exc)
- {
- Console.WriteLine("BOOOOM EXCEPTION = " + exc.Message);
- }
- player.MoveTo(npc.CurrentRegionID, npc.X, npc.Y, npc.Z, npc.Heading);
- }
- public static GameNPC getMobFromNameAndGuild(string Name, string Guild)
- {
- GameNPC[] npcs = WorldMgr.GetNPCsByName(Name, eRealm.None);
- if (npcs.Length > 0 && npcs != null)
- {
- foreach (GameNPC npc in npcs)
- {
- if (npc != null)
- {
- if (npc.GuildName == Guild)
- {
- return npc;
- }
- }
- }
- }
- return null;
- }
- public static List<GameNPC> getMobsFromNameAndGuildAndRealm(string Name, string Guild, eRealm realm)
- {
- List<GameNPC> list = new List<GameNPC>();
- GameNPC[] npcs = WorldMgr.GetNPCsByName(Name, realm);
- if (npcs.Length > 0 && npcs != null)
- {
- foreach (GameNPC npc in npcs)
- {
- if (npc != null)
- {
- if (npc.GuildName == Guild)
- {
- list.Add(npc);
- }
- }
- }
- }
- return list;
- }
- public static void SendCasterSpellEffectAndCastMessage(GameLiving caster, ushort spellEffect, bool success)
- {
- foreach (GamePlayer player in caster.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
- {
- player.Out.SendSpellEffectAnimation(caster, caster, spellEffect, 0, false, success ? (byte)1 : (byte)0);
- if (caster.IsWithinRadius(player, WorldMgr.INFO_DISTANCE))
- {
- if (player == caster)
- {
- player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "RealmAbility.SendCasterSpellEffectAndCastMessage.You", caster.Name), eChatType.CT_Spell, eChatLoc.CL_SystemWindow);
- }
- else
- {
- player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "RealmAbility.SendCasterSpellEffectAndCastMessage.Caster", caster.Name), eChatType.CT_Spell, eChatLoc.CL_SystemWindow);
- }
- }
- }
- }
- public static int RealmCountInRegion(ushort region, eRealm realm)
- {
- int count = 0;
- foreach (GameClient client in WorldMgr.GetClientsOfRegion(region))
- {
- if (client != null && client.Player != null)
- {
- if (client.Player.Realm == realm)
- {
- count += 1;
- }
- }
- }
- return count;
- }
- public static int GetNumOfFaithTokensInPlayerInventory(GamePlayer player)
- {
- int count = 0;
- foreach (InventoryItem item in player.Inventory.GetItemRange(eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack))
- {
- if (item.Name.ToLower().Contains("faith token"))
- {
- count += 1;
- }
- }
- return count;
- }
- public static InventoryItem GetHighestStackOfFaithTokensFromPlayerInventory(GamePlayer player)
- {
- int highestCount = 0;
- InventoryItem highestCountItem = null;
- foreach (InventoryItem item in player.Inventory.GetItemRange(eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack))
- {
- if (item.Name.ToLower().Contains("faith token"))
- {
- if (item.Count > highestCount)
- {
- highestCount = item.Count;
- highestCountItem = item;
- }
- }
- }
- return highestCountItem;
- }
- public static void portsetupDialogResponse(GamePlayer player, byte response)
- {
- if (response != 0x01)
- {
- return; //declined
- }
- {
- FaithUtils.PortPlayerToSetup(player);
- player.Bind(true);
- }
- }
- public static bool RemoveFaithTokensFromPlayerInventory(GamePlayer player, int count)
- {
- InventoryItem toRemoveFrom = GetHighestStackOfFaithTokensFromPlayerInventory(player);
- if (toRemoveFrom == null)
- {
- return false;
- }
- if (toRemoveFrom.Count < count)
- {
- return false;
- }
- player.Inventory.RemoveCountFromStack(toRemoveFrom, count);
- return true;
- }
- }
- }
Add Comment
Please, Sign In to add comment