public static void DefenceTickReward(BattleFrontKeep keep, List <Player> playersInRange, string description, ContributionManager contributionManagerInstance) { RewardLogger.Info($"DefenceTickReward. {keep.Info.Name} Players : {playersInRange.Count} {description}"); foreach (var plr in playersInRange) { if (keep.Realm == plr.Realm && plr.ValidInTier(keep.Tier, true)) { var influenceId = plr.Realm == Realms.REALMS_REALM_DESTRUCTION ? plr.CurrentArea.DestroInfluenceId : plr.CurrentArea.OrderInfluenceId; var random = StaticRandom.Instance.Next(80, 120); var totalXp = 2000 * keep.Tier * random / 100; var totalRenown = 300 * keep.Tier * random / 100; var totalInfluence = 100 * keep.Tier * random / 100; if (keep.PlayersKilledInRange < 4 * keep.Tier) { totalXp += (int)(totalXp * (0.25 + keep.PlayersKilledInRange / 40f * 0.75)); totalRenown += (int)(totalRenown * (0.25 + keep.PlayersKilledInRange / 40f * 0.75)); totalInfluence += (int)(totalInfluence * (0.25 + keep.PlayersKilledInRange / 40f * 0.75)); } plr.AddXp((uint)totalXp, false, false); plr.AddRenown((uint)totalRenown, false, RewardType.None, $"Defence of {description} against the enemy"); plr.AddInfluence((ushort)influenceId, (ushort)totalInfluence); plr.SendClientMessage($"You've received a reward for your contribution to the holding of {keep.Info.Name}.", ChatLogFilters.CHATLOGFILTERS_RVR); // Add Contribution for Keep Defence Tick plr.UpdatePlayerBountyEvent((byte)ContributionDefinitions.KEEP_DEFENCE_TICK); RewardLogger.Info("Keep", $"Keep Defence XP : {totalXp} RP: {totalRenown}, Influence: {totalInfluence}. Players killed in range {keep.PlayersKilledInRange}"); } } }
public void SendKeepStatus(Player plr, BattleFrontKeep keep) { if (keep.Region == null) { return; } //var doors = keep.Doors.FindAll(x => // x.Info.Number != (int) KeepDoorType.None && x.Info.GameObjectId == 100 && x.GameObject.PctHealth > 0); var doors = keep.Doors.FindAll(x => x.Info.GameObjectId == 100); var innerDoor = keep.Doors.SingleOrDefault(x => x.Info.Number == (int)KeepDoorType.InnerMain); var Out = new PacketOut((byte)Opcodes.F_KEEP_STATUS, 26); Out.WriteByte(keep.Info.KeepId); { Out.WriteByte(keep.KeepStatus == KeepStatus.KEEPSTATUS_LOCKED ? (byte)1 : (byte)keep.KeepStatus); Out.WriteByte(0); // ? Out.WriteByte((byte)keep.Realm); Out.WriteByte((byte)doors.Count); Out.WriteByte(keep.Rank); // Rank if (doors.Count > 0) { if (innerDoor != null) { Out.WriteByte((byte)((innerDoor.GameObject.PctHealth))); // Door health } else { Out.WriteByte(0); } } else { Out.WriteByte(0); } Out.WriteByte(0); // Next rank % } Out.Fill(0, 18); if (plr != null) { plr.SendPacket(Out); } else { lock (Player._Players) { foreach (var player in Player._Players) { player.SendCopy(Out); } } } _logger.Trace($"F_KEEP_STATUS {keep.Info.Name} Status : {keep.KeepStatus} "); }
public Siege(Creature_spawn spawn, Player owner, SiegeType type, BattleFrontKeep keep = null) : base(spawn) { _type = type; SiegeInterface = AddInterface <SiegeInterface>(); SiegeInterface.Creator = owner; AssignedKeep = keep; // Only need to assign keep for oil SiegeInterface.DeathTime = TCPManager.GetTimeStampMS() + SiegeLifeSpan; }
public KeepCreature(Creature_spawn spawn, KeepNpcCreature flagGuard, BattleFrontKeep keep) : base(spawn) { _keep = keep; FlagGuard = flagGuard; IsKeepLord = flagGuard.Info.KeepLord; IsPatrol = flagGuard.Info.IsPatrol; DefenceRank = 3; EvtInterface.AddEventNotify(EventName.OnReceiveDamage, OnReceiveDamage); }
public void SimpleBFKTransition() { var keepInfo = new Keep_Info(); keepInfo.KeepId = 1; keepInfo.Name = "test keep"; var bfk = new BattleFrontKeep(keepInfo, 4, Region1, FakeKeepComms, false); bfk.fsm.Initialize(SM.ProcessState.Initial); bfk.fsm.Fire(SM.Command.OnOpenBattleFront); bfk.fsm.Start(); Assert.IsTrue(bfk.fsm.IsRunning); }
/// <summary> /// Returns the closest keep and distance to Oil spawn pt /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool CheckOil(Player plr, ref List <string> values) { BattleFrontKeep keep = plr.Region.Campaign.GetClosestFriendlyKeep(plr.WorldPosition, plr.Realm); plr.SendClientMessage($"Closest Keep : {keep.Info.Name}"); foreach (var h in keep.HardPoints) { if (!plr.PointWithinRadiusFeet(h, 10)) { plr.SendClientMessage($"Player too far from hardpoint {h.ToString()}"); } } return(true); }
public KeepGameObject(GameObject_spawn spawn, KeepDoor keepDoor, BattleFrontKeep keep) { _keep = keep; Spawn = spawn; Name = spawn.Proto.Name; _keepDoor = keepDoor; if (keepDoor.Info.Number == (int)KeepDoorType.InnerMain || keepDoor.Info.Number == (int)KeepDoorType.OuterMain) { Realm = keep.Realm; Spawn.Proto.HealthPoints = 4 * 500000; Health = Spawn.Proto.HealthPoints; } _enterExitPoints[0] = new Point3D(_keepDoor.Info.TeleportX1, _keepDoor.Info.TeleportY1, _keepDoor.Info.TeleportZ1); _enterExitPoints[1] = new Point3D(_keepDoor.Info.TeleportX2, _keepDoor.Info.TeleportY2, _keepDoor.Info.TeleportZ2); EvtInterface.AddEventNotify(EventName.OnReceiveDamage, OnReceiveDamage); }
private static void DisplayKeepStatus(BattleFrontKeep keep, Player plr) { plr.SendClientMessage($"Keep Status : {keep.KeepStatus}"); plr.SendClientMessage($"Ram Deployed : {keep.RamDeployed}"); plr.SendClientMessage($"Players killed in range : {keep.PlayersKilledInRange}"); plr.SendClientMessage($"Players in range : {keep.PlayersInRange.Count}"); foreach (var keepDoorRepairTimer in keep.DoorRepairTimers) { plr.SendClientMessage($"Door Repair Timer : {keepDoorRepairTimer.Key}:{keepDoorRepairTimer.Value.Value}/{keepDoorRepairTimer.Value.Length}"); } foreach (var keepHardPoint in keep.HardPoints) { plr.SendClientMessage($"Siege : {keepHardPoint.CurrentWeapon} {keepHardPoint.SiegeType}"); } keep.SendDiagnostic(plr); foreach (var door in keep.Doors) { plr.SendClientMessage($"DoorId : {door.Info.DoorId} Interact:{door.GameObject.InteractState} AutoAttack:{door.GameObject.CanAutoAttack}"); plr.SendClientMessage("Occlusion_Visible:" + Occlusion.GetFixtureVisible(door.GameObject.DoorId)); } }
public KeepDoor(RegionMgr region, Keep_Door info, BattleFrontKeep keep) { Region = region; Info = info; Keep = keep; }
public KeepNpcCreature(RegionMgr region, Keep_Creature info, BattleFrontKeep keep) { Region = region; Info = info; Keep = keep; }
public static void F_USE_ITEM(BaseClient client, PacketIn packet) { GameClient cclient = client as GameClient; if (!cclient.IsPlaying()) { return; } Player Plr = cclient.Plr; if (Plr.AbtInterface.IsOnGlobalCooldown()) { return; } ushort slot = packet.GetUint16(); Item item = Plr.ItmInterface.GetItemInSlot(slot); if (item == null || item._Count == 0) { return; } if (!item.CanBeUsedBy(Plr)) { return; } if (item.Info.Entry == 1337) { Plr.SetLevel((byte)40); Plr.ItmInterface.DeleteItem(slot, 1); } // Honor rewards var honorReward = HonorService.HonorRewards.SingleOrDefault(x => x.ItemId == item.Info.Entry); if (honorReward != null) { if (Plr.Info.HonorRank < honorReward.HonorRank) { Plr.SendClientMessage("You can no longer use this item, as you do not have a high enough Honor Rank."); return; } } if ((item.Info.Entry == 208477) || (item.Info.Entry == 208474)) { Plr.ItmInterface.CreateItem(208470, 6); Plr.ItmInterface.DeleteItem(slot, 1); } // Oil if (item.Info.Entry == 86203 || item.Info.Entry == 86207 || item.Info.Entry == 86211 || item.Info.Entry == 86215 || item.Info.Entry == 86219 || item.Info.Entry == 86223) // siege oil { BattleFrontKeep keep = Plr.Region.Campaign.GetClosestFriendlyKeep(Plr.WorldPosition, Plr.Realm); if (keep.Realm == Plr.Realm) { keep.SpawnOil(Plr, slot); } } if (item.ModelId == 1566 || item.ModelId == 3850) // currency conversion boxes { Plr.ItmInterface.OpenBox(slot, item); } #region Loot bags if (item.Info.Entry == 9980 || item.Info.Entry == 9940 || item.Info.Entry == 9941 || item.Info.Entry == 9942 || item.Info.Entry == 9943) // lootbags { packet.Skip(5); byte mode = packet.GetUint8(); if (mode == 0) { Plr.ItmInterface.SendMysteryBag(slot); } else { Plr.ItmInterface.GetItemfromMysterybag(slot, mode); } } #endregion // Banner hack for standards. if (item.ModelId >= 6188 && item.ModelId < 6194) { Plr.Standard(item.Info.SpellId, true); } if (item.Info.Crafts.Length > 0 && CraftingApoInterface.GetCraft(5, item.Info.Crafts) == 4 && (CraftingApoInterface.GetCraft(8, item.Info.Crafts) < 5 || CraftingApoInterface.GetCraft(8, item.Info.Crafts) == 18)) { CultivationInterface.ReapResin(Plr, slot); } #region Dye if (item.Info.Type == 27) { Item dye = Plr.ItmInterface.GetItemInSlot(slot); if (dye == null) { return; } byte prisek = packet.GetUint8(); packet.Skip(4); byte Slot = packet.GetUint8(); Item itemtodye = Plr.ItmInterface.GetItemInSlot(Slot); if (dye.Info.BaseColor1 == 0) { Plr.ItmInterface.RemoveDye(itemtodye, prisek == 1, prisek == 2); } else { if (prisek == 1) { Plr.ItmInterface.DyeItem(itemtodye, dye.Info.BaseColor1, 0); } else { Plr.ItmInterface.DyeItem(itemtodye, 0, dye.Info.BaseColor1); } } Plr.ItmInterface.DeleteItem(slot, 1); } #endregion if (item.Info.SpellId == 0) { return; } var numberSiegeTypeBeforeCast = 0; var numberSiegeTypeAfterCast = 0; var siegeType = Siege.GetSiegeType(item.Info.Entry); if (item.Info.IsSiege) { if (siegeType == null) { _logger.Warn($"Could not locate SiegeType for {item.Info.Entry}"); return; } if (item.Info.IsSiege) { numberSiegeTypeBeforeCast = Plr.Region.Campaign.SiegeManager.GetNumberByType(siegeType.Value, Plr.Realm); } } #region Ability Cast if (!Plr.AbtInterface.CanCastCooldown(item.Info.SpellId)) { Plr.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, Localized_text.TEXT_ITEM_CANT_BE_USED_YET); return; } if (!Plr.AbtInterface.StartCast(Plr, item.Info.SpellId, 1, item.Info.Unk27?[19] ?? 0, item.Info.ObjectLevel)) { return; } if (item.Info.MaxStack > 1) { Plr.ItmInterface.DeleteItem(slot, 1); } // Determine whether to remove the siege item from inventory. if (item.Info.IsSiege) { // If the siege exists, and the cast was not blocked or interrupted. numberSiegeTypeAfterCast = Plr.Region.Campaign.SiegeManager.GetNumberByType(siegeType.Value, Plr.Realm); if ((item.Owner as Player).CharacterId == Plr.CharacterId) { if (item.Info.IsValid) { // If there is a Ram now, but there wasnt one before, remove it from inventory if (numberSiegeTypeBeforeCast + 1 == numberSiegeTypeAfterCast) { Plr.ItmInterface.DeleteItem(slot, 1); } } } } WorldMgr.GeneralScripts.OnWorldPlayerEvent("USE_ITEM", Plr, item); #endregion }
public SM(BattleFrontKeep keep) { Keep = keep; fsm = new PassiveStateMachine <ProcessState, Command>(); fsm.TransitionCompleted += RecordTransition; /* Initial State */ fsm.In(ProcessState.Initial) .On(Command.OnOpenBattleFront) .Goto(ProcessState.Safe) .Execute(() => Keep.SetKeepSafe()); /* Any call to Lock Zone will execute Lock */ fsm.In(ProcessState.Initial) .On(Command.OnLockZone).Goto(ProcessState.Locked).Execute(() => Keep.SetKeepLocked()); fsm.In(ProcessState.Safe) .On(Command.OnLockZone).Goto(ProcessState.Locked).Execute(() => Keep.SetKeepLocked()); fsm.In(ProcessState.OuterDown) .On(Command.OnLockZone).Goto(ProcessState.Locked).Execute(() => Keep.SetKeepLocked()); fsm.In(ProcessState.InnerDown) .On(Command.OnLockZone).Goto(ProcessState.Locked).Execute(() => Keep.SetKeepLocked()); fsm.In(ProcessState.LordKilled) .On(Command.OnLockZone).Goto(ProcessState.Locked).Execute(() => Keep.SetKeepLocked()); fsm.In(ProcessState.GuildClaim) .On(Command.OnLockZone).Goto(ProcessState.Locked).Execute(() => Keep.SetKeepLocked()); fsm.In(ProcessState.Locked) .On(Command.OnLockZone).Goto(ProcessState.Locked).Execute(() => Keep.SetKeepLocked()); fsm.In(ProcessState.DefenceTick) .On(Command.OnLockZone).Goto(ProcessState.Locked).Execute(() => Keep.SetKeepLocked()); fsm.In(ProcessState.LordWounded) .On(Command.OnLockZone).Goto(ProcessState.Locked).Execute(() => Keep.SetKeepLocked()); fsm.In(ProcessState.Safe) .On(Command.OnOuterDoorDown) .Goto(ProcessState.OuterDown) .Execute <uint>((uint doorId) => Keep.SetOuterDoorDown(doorId)); fsm.In(ProcessState.Safe) .On(Command.OnInnerDoorDown) .Goto(ProcessState.InnerDown) .Execute <uint>((uint doorId) => Keep.SetInnerDoorDown(doorId)); fsm.In(ProcessState.OuterDown) .On(Command.OnInnerDoorDown) .Goto(ProcessState.InnerDown) .Execute <uint>((uint doorId) => Keep.SetInnerDoorDown(doorId)); /* Lord Wounded events */ fsm.In(ProcessState.Safe) .On(Command.OnLordWounded).Goto(ProcessState.LordWounded).Execute(() => Keep.SetLordWounded()); fsm.In(ProcessState.InnerDown) .On(Command.OnInnerDoorDown).Goto(ProcessState.LordWounded).Execute(() => Keep.SetLordWounded()); /* GM only events - lord kill */ fsm.In(ProcessState.InnerDown) .On(Command.OnLordKilled).Goto(ProcessState.LordKilled).Execute(() => Keep.SetLordKilled()); fsm.In(ProcessState.OuterDown) .On(Command.OnLordKilled).Goto(ProcessState.LordKilled).Execute(() => Keep.SetLordKilled()); fsm.In(ProcessState.LordWounded) .On(Command.OnLordKilled).Goto(ProcessState.LordKilled).Execute(() => Keep.SetLordKilled()); // Allow for keep to be safe (doors repaired) and lord still to be killed. fsm.In(ProcessState.Safe) .On(Command.OnLordKilled).Goto(ProcessState.LordKilled).Execute(() => Keep.SetLordKilled()); fsm.In(ProcessState.LordKilled) .On(Command.OnLordKilledTimerEnd).Goto(ProcessState.GuildClaim).Execute(() => Keep.SetKeepSeized()); fsm.In(ProcessState.GuildClaim) // Guild claim interacted, go to safe. .On(Command.OnGuildClaimInteracted) .Goto(ProcessState.Safe) .Execute <uint>((uint guildId) => Keep.SetGuildClaimed(guildId)); //.Execute(() => Keep.SetKeepSafe()); fsm.In(ProcessState.GuildClaim) .On(Command.OnGuildClaimTimerEnd) .If(Keep.IsFortress) .Goto(ProcessState.Safe) .Execute(() => Keep.ForceLockZone()) .Execute(() => Keep.SetKeepSafe()); fsm.In(ProcessState.GuildClaim) .On(Command.OnGuildClaimTimerEnd) .If(Keep.IsNotFortress) .Goto(ProcessState.Safe) .Execute(() => Keep.GenerateKeepTakeRewards()) .Execute(() => Keep.SetKeepSafe()); //fsm.In(ProcessState.OuterDown) // .On(Command.OnDoorRepaired) // .If(Keep.AllDoorsRepaired) // .Goto(ProcessState.Safe) // //.Execute<uint>((uint doorId) => Keep.SetDoorRepaired(doorId)) // .Execute(() => Keep.SetKeepSafe()); //fsm.In(ProcessState.InnerDown) // Inner down, but all repaired (implies outer repaired) -> safe // .On(Command.OnDoorRepaired) // .If(Keep.AllDoorsRepaired) // .Goto(ProcessState.Safe) // .Execute(() => Keep.SetKeepSafe()); //fsm.In(ProcessState.InnerDown) // Inner down, but not all repaired -> outer still // .On(Command.OnDoorRepaired) // .Goto(ProcessState.Safe) // .Execute<uint>((uint doorId) => Keep.SetDoorRepaired(doorId)); //fsm.In(ProcessState.LordWounded) // .On(Command.OnDoorRepaired) // .If(Keep.AllDoorsRepaired) // .Goto(ProcessState.Safe) // //.Execute<uint>((uint doorId) => Keep.SetDoorRepaired(doorId)) // .Execute(() => Keep.SetKeepSafe()); fsm.In(ProcessState.Locked) .On(Command.OnOpenBattleFront).Goto(ProcessState.Safe).Execute(() => Keep.SetKeepSafe()); }
public static void KeepLordKill(BattleFrontKeep keep, List <Player> playersInRange, IEnumerable <KeyValuePair <uint, int> > eligiblePlayers) { RewardLogger.Info("**********************KEEP FLIP******************************"); RewardLogger.Info($"Distributing rewards for Keep {keep.Info.Name} number players : {playersInRange.Count} players killed in range {keep.PlayersKilledInRange}"); RewardLogger.Info("*************************************************************"); uint influenceId = 0; byte objCount = 0; var battlePenalty = false; var totalXp = 800 * keep.Tier + 200 * keep.Tier * objCount + keep.PlayersKilledInRange * keep.Tier * 30; // Field of Glory, reduced var totalRenown = 250 * keep.Tier + 80 * keep.Tier * objCount + keep.PlayersKilledInRange * 80; // Ik : Increased values here. var totalInfluence = 40 * keep.Tier + 20 * keep.Tier * objCount + keep.PlayersKilledInRange * keep.Tier * 6; RewardLogger.Info($"Players killed in range {keep.PlayersKilledInRange} {totalXp} {totalRenown} {totalInfluence}"); if (keep.PlayersKilledInRange < 4 * keep.Tier) { battlePenalty = true; totalXp = (int)(totalXp * (0.25 + keep.PlayersKilledInRange / 40f * 0.75)); totalRenown = (int)(totalRenown * (0.25 + keep.PlayersKilledInRange / 40f * 0.75)); totalInfluence = (int)(totalInfluence * (0.25 + keep.PlayersKilledInRange / 40f * 0.75)); RewardLogger.Info($"{keep.PlayersKilledInRange} players killed in range - battle penalty - reduced rewards"); } try { RewardLogger.Info($"Processing {playersInRange.Count()} players for Keep lock rewards"); foreach (var eligibleCharacterId in eligiblePlayers) { var player = Player.GetPlayer(eligibleCharacterId.Key); if (player == null) { continue; } if (!player.Initialized) { continue; } if (player.IsAFK) { continue; } var scaler = 0.5f; RewardLogger.Debug($"Player {player.Name} is in range"); // Player in range must be eligible if (playersInRange.Any(x => x.CharacterId == eligibleCharacterId.Key)) { scaler += 0.5f; RewardLogger.Debug($"Player {player.Name} is in range and eligible"); } RewardLogger.Debug($"Player {player.Name} totalRenown = {totalRenown} scaler = {scaler}"); totalXp = (int)(totalXp * scaler); totalRenown = (int)(totalRenown * scaler); RewardLogger.Debug($"Player {player.Name} totalRenown = {totalRenown} scaler = {scaler}"); // Racial influence if ((player.Info.Race == (int)Races.RACES_GOBLIN) || (player.Info.Race == (int)Races.RACES_ORC)) { if (keep.Info.Race == 2) { totalInfluence = (int)(totalInfluence * scaler * 1.2f); RewardLogger.Debug($"Player {player.Name} +20% INF in keep"); } } else { if (player.Info.Race == keep.Info.Race) { totalInfluence = (int)(totalInfluence * scaler * 1.2f); RewardLogger.Debug($"Player {player.Name} +20% INF in keep"); } } if (player.ValidInTier(keep.Tier, true)) { player.QtsInterface.HandleEvent(Objective_Type.QUEST_CAPTURE_KEEP, keep.Info.KeepId, 1); RewardLogger.Debug($"Player {player.Name} is valid"); player.AddXp((uint)totalXp, false, false); player.AddRenown((uint)totalRenown, false, RewardType.ZoneKeepCapture, keep.Info.Name); if ((influenceId == 0) && player.CurrentArea != null) { influenceId = player.Realm == Realms.REALMS_REALM_DESTRUCTION ? player.CurrentArea.DestroInfluenceId : player.CurrentArea.OrderInfluenceId; player.AddInfluence((ushort)influenceId, (ushort)totalInfluence); } else { RewardLogger.Warn($"Player {player.Name} is not in CurrentArea"); totalInfluence = 0; } if (battlePenalty) { player.SendClientMessage( "This keep was taken with little to no resistance. The rewards have therefore been reduced."); } RewardLogger.Info( $"Distributing rewards for Keep {keep.Info.Name} to {player.Name} RR:{totalRenown} INF:{totalInfluence}"); } } } catch (Exception e) { RewardLogger.Error($"Exception distributing rewards for Keep take {e.Message} {e.StackTrace}"); throw; } }