public bool UserDetected(int[] boxIds, byte jobId) { Job job = (Job) jobId; List<IFieldActor<Player>> players = Field.State.Players.Values.ToList(); if (job != Job.None) { players = players.Where(x => x.Value.Job == job).ToList(); } foreach (int boxId in boxIds) { MapTriggerBox box = MapEntityStorage.GetTriggerBox(Field.MapId, boxId); if (box == null) { return false; } foreach (IFieldObject<Player> player in players) { if (FieldManager.IsPlayerInBox(box, player)) { return true; } } } return false; }
public int GetUserCount(int boxId, int userTagId) { if (boxId == 0) { return(Field.State.Players.Values.Count); } MapTriggerBox box = MapEntityMetadataStorage.GetTriggerBox(Field.MapId, boxId); if (box is null) { return(0); } int userCount = 0; foreach (IFieldActor <Player> player in Field.State.Players.Values) { if (FieldManager.IsPlayerInBox(box, player)) { userCount++; } } return(userCount); }
public void SetAchievement(int boxId, string type, string trophySet) { List <IFieldActor <Player> > players = Field.State.Players.Values.ToList(); if (boxId != 0) { MapTriggerBox box = MapEntityStorage.GetTriggerBox(Field.MapId, boxId); List <IFieldActor <Player> > boxedPlayers = new(); foreach (IFieldActor <Player> player in players) { if (FieldManager.IsPlayerInBox(box, player)) { boxedPlayers.Add(player); } } players = boxedPlayers; } foreach (IFieldObject <Player> player in players) { if (type == "trigger") { TrophyManager.OnTrigger(player.Value, trophySet); } } }
public void MiniGameCameraDirection(int boxId, int cameraId) { MapTriggerBox box = MapEntityMetadataStorage.GetTriggerBox(Field.MapId, boxId); if (box is null) { return; } List <IFieldObject <Player> > boxPlayers = new(); foreach (IFieldObject <Player> player in Field.State.Players.Values) { if (FieldManager.IsPlayerInBox(box, player)) { boxPlayers.Add(player); } } Random random = Random.Shared; int index = random.Next(boxPlayers.Count); IFieldObject <Player> randomPlayer = boxPlayers[index]; Field.BroadcastPacket(LocalCameraPacket.Camera(cameraId, 1, randomPlayer.ObjectId)); }
public void MiniGameGiveReward(int winnerBoxId, string contentType, MiniGame type) { MapTriggerBox box = MapEntityStorage.GetTriggerBox(Field.MapId, winnerBoxId); List <IFieldObject <Player> > players = new List <IFieldObject <Player> >(); foreach (IFieldObject <Player> player in Field.State.Players.Values) { if (FieldManager.IsPlayerInBox(box, player)) { players.Add(player); } } foreach (IFieldObject <Player> player in players) { if (contentType == "miniGame") { List <Item> items = RewardContentMetadataStorage.GetRewardItems(3, player.Value.Levels.Level); foreach (Item item in items) { InventoryController.Add(player.Value.Session, item, true); } } else if (contentType == "UserOpenMiniGameExtraReward") { } } }
public bool UserDetected(int[] boxIds, byte jobId) { Job job = (Job)jobId; List <Character> players = Field.State.Players.Values.ToList(); if (job != Job.None) { players = players.Where(x => x.Value.Job == job).ToList(); } foreach (int boxId in boxIds) { MapTriggerBox box = MapEntityMetadataStorage.GetTriggerBox(Field.MapId, boxId); if (box == null) { return(false); } if (players.Any(player => FieldManager.IsPlayerInBox(box, player))) { return(true); } } return(false); }
public void EndMiniGame(int winnerBoxId, MiniGame type, bool isOnlyWinner) { MapTriggerBox box = MapEntityMetadataStorage.GetTriggerBox(Field.MapId, winnerBoxId); if (box is null) { return; } foreach (IFieldObject <Player> player in Field.State.Players.Values) { if (!FieldManager.IsPlayerInBox(box, player)) { continue; } switch (type) { case MiniGame.LudibriumEscape: PlayerTrigger trigger = player.Value.Triggers.FirstOrDefault(x => x.Key == "gameStart"); player.Value.Triggers.Remove(trigger); player.Value.Session.Send(ResultsPacket.Rounds(1, 1)); break; case MiniGame.OXQuiz: player.Value.Session.Send(ResultsPacket.Rounds(10, 10)); break; } } }
public void PlaySystemSoundInBox(int[] boxIds, string sound) { if (boxIds != null) { foreach (int boxId in boxIds) { MapTriggerBox box = MapEntityMetadataStorage.GetTriggerBox(Field.MapId, boxId); if (box is null) { return; } foreach (IFieldObject <Player> player in Field.State.Players.Values) { if (FieldManager.IsPlayerInBox(box, player)) { player.Value.Session.Send(SystemSoundPacket.Play(sound)); } } } return; } Field.BroadcastPacket(SystemSoundPacket.Play(sound)); }
public void SetAchievement(int boxId, string type, string trophySet) { List <IFieldObject <Player> > players = Field.State.Players.Values.ToList(); if (boxId != 0) { MapTriggerBox box = MapEntityStorage.GetTriggerBox(Field.MapId, boxId); List <IFieldObject <Player> > boxedPlayers = new List <IFieldObject <Player> >(); foreach (IFieldObject <Player> player in players) { if (FieldManager.IsPlayerInBox(box, player)) { boxedPlayers.Add(player); } } players = boxedPlayers; } foreach (IFieldObject <Player> player in players) { if (type == "trigger") { switch (trophySet) { case "oxquiz_start": player.Value.TrophyUpdate(23400009, 1); break; case "oxquiz_correct": player.Value.TrophyUpdate(23400010, 1); break; case "oxquiz_win": player.Value.TrophyUpdate(23400011, 1); break; case "trapmaster_start": player.Value.TrophyUpdate(23400001, 1); break; case "trapmaster_win": player.Value.TrophyUpdate(23400002, 1); break; case "finalsurvivor_start": player.Value.TrophyUpdate(23400003, 1); break; case "finalsurvivor_win": player.Value.TrophyUpdate(23400004, 1); break; default: Logger.Warn($"Unhandled trophy set: {trophySet}"); break; } } } }
public void MoveUser(int mapId, int triggerId, int boxId) { List <Character> players = Field.State.Players.Values.ToList(); if (boxId != 0) { MapTriggerBox box = MapEntityMetadataStorage.GetTriggerBox(Field.MapId, boxId); if (box is null) { return; } players = players.Where(player => FieldManager.IsPlayerInBox(box, player)).ToList(); } // move player back to return map if (mapId == 0 && triggerId == 0) { foreach (IFieldObject <Player> player in players) { player.Value.Warp(player.Value.ReturnMapId, player.Value.ReturnCoord); } return; } if (mapId == Field.MapId) { IFieldObject <Portal> portal = Field.State.Portals.Values.First(p => p.Value.Id == triggerId); foreach (IFieldObject <Player> player in players) { player.Value.Move(portal.Coord, portal.Rotation, isTrigger: true); } return; } CoordF moveCoord; CoordF moveRotation; MapPortal dstPortal = MapEntityMetadataStorage.GetPortals(mapId).FirstOrDefault(portal => portal.Id == triggerId); if (dstPortal == null) { MapPlayerSpawn spawn = MapEntityMetadataStorage.GetRandomPlayerSpawn(mapId); moveCoord = spawn.Coord.ToFloat(); moveRotation = spawn.Rotation.ToFloat(); } else { moveCoord = dstPortal.Coord.ToFloat(); moveRotation = dstPortal.Rotation.ToFloat(); } foreach (IFieldObject <Player> player in players) { player.Value.Warp(mapId, moveCoord, moveRotation, instanceId: 1); } }
public void EndMiniGameRound(int winnerBoxId, float expRate, bool isOnlyWinner, bool isGainLoserBonus, bool meso, MiniGame type) { MapTriggerBox box = MapEntityStorage.GetTriggerBox(Field.MapId, winnerBoxId); foreach (IFieldObject <Player> player in Field.State.Players.Values) { if (FieldManager.IsPlayerInBox(box, player)) { // TODO: calculate correct amount of exp; player.Value.Levels.GainExp(10000); } } }
public static bool IsPlayerInBox(MapTriggerBox box, IFieldObject <Player> player) { CoordF minCoord = CoordF.From( box.Position.X - box.Dimension.X / 2, box.Position.Y - box.Dimension.Y / 2, box.Position.Z - box.Dimension.Z / 2); CoordF maxCoord = CoordF.From( box.Position.X + box.Dimension.X / 2, box.Position.Y + box.Dimension.Y / 2, box.Position.Z + box.Dimension.Z / 2); bool min = player.Coord.X >= minCoord.X && player.Coord.Y >= minCoord.Y && player.Coord.Z >= minCoord.Z; bool max = player.Coord.X <= maxCoord.X && player.Coord.Y <= maxCoord.Y && player.Coord.Z <= maxCoord.Z; return(min && max); }
public bool QuestUserDetected(int[] boxes, int[] questIds, byte[] modes, byte arg4) { byte mode = modes[0]; foreach (int boxId in boxes) { MapTriggerBox box = MapEntityMetadataStorage.GetTriggerBox(Field.MapId, boxId); if (box is null) { return(false); } List <Character> players = Field.State.Players.Values.ToList(); foreach (Character player in players) { if (!FieldManager.IsPlayerInBox(box, player)) { continue; } foreach (int questId in questIds) { if (!player.Value.QuestData.TryGetValue(questId, out QuestStatus quest)) { return(false); } switch (mode) { case 1: // started return(quest.State is QuestState.Started); case 2: // on going return(quest.State is QuestState.Started && quest.Condition.All(x => x.Completed)); case 3: // completed return(quest.State is QuestState.Completed); } } } } return(false); }
public void AddBuff(int[] boxIds, int skillId, byte skillLevel, bool arg4, bool arg5, string feature) { foreach (int boxId in boxIds) { MapTriggerBox box = MapEntityMetadataStorage.GetTriggerBox(Field.MapId, boxId); if (box is null) { return; } foreach (Character player in Field.State.Players.Values.Where(player => FieldManager.IsPlayerInBox(box, player))) { // TODO: Rework when buff system is implemented Status status = new(new(skillId, skillLevel), player.ObjectId, player.ObjectId, 1); StatusHandler.Handle(player.Value.Session, status); } } }
public int GetUserCount(int boxId, int userTagId) { if (boxId != 0) { List <IFieldObject <Player> > players = Field.State.Players.Values.ToList(); MapTriggerBox box = MapEntityStorage.GetTriggerBox(Field.MapId, boxId); int userCount = 0; foreach (IFieldObject <Player> player in players) { if (FieldManager.IsPlayerInBox(box, player)) { userCount++; } } return(userCount); } return(Field.State.Players.Values.Count); }
public void EndMiniGame(int winnerBoxId, MiniGame type, bool isOnlyWinner) { MapTriggerBox box = MapEntityStorage.GetTriggerBox(Field.MapId, winnerBoxId); List <IFieldObject <Player> > players = new List <IFieldObject <Player> >(); foreach (IFieldObject <Player> player in Field.State.Players.Values) { if (FieldManager.IsPlayerInBox(box, player)) { if (type == MiniGame.LudibriumEscape) { PlayerTrigger trigger = player.Value.Triggers.FirstOrDefault(x => x.Key == "gameStart"); player.Value.Triggers.Remove(trigger); player.Value.Session.Send(ResultsPacket.Rounds(1, 1)); } else if (type == MiniGame.OXQuiz) { player.Value.Session.Send(ResultsPacket.Rounds(10, 10)); } } } }
public void SetAchievement(int boxId, string type, string trophySet) { List <Character> players = Field.State.Players.Values.ToList(); if (boxId != 0) { MapTriggerBox box = MapEntityMetadataStorage.GetTriggerBox(Field.MapId, boxId); if (box is null) { return; } players = players.Where(player => FieldManager.IsPlayerInBox(box, player)).ToList(); } foreach (IFieldObject <Player> player in players) { if (type == "trigger") { TrophyManager.OnTrigger(player.Value, trophySet); } } }
public bool QuestUserDetected(int[] boxes, int[] questIds, byte[] modes, byte arg4) { QuestState mode = (QuestState) modes[0]; foreach (int boxId in boxes) { MapTriggerBox box = MapEntityStorage.GetTriggerBox(Field.MapId, boxId); List<IFieldActor<Player>> players = Field.State.Players.Values.ToList(); foreach (IFieldObject<Player> player in players) { if (!FieldManager.IsPlayerInBox(box, player)) { continue; } foreach (int questId in questIds) { if (!player.Value.QuestData.TryGetValue(questId, out QuestStatus quest)) { return false; } switch (mode) { case QuestState.Started: return quest.State is QuestState.Started; case QuestState.ConditionCompleted: return quest.Condition.All(condition => condition.Completed); case QuestState.Finished: return quest.State is QuestState.Finished; } } } } return false; }
public void MoveUser(int mapId, int triggerId, int boxId) { List <IFieldObject <Player> > players = Field.State.Players.Values.ToList(); if (boxId != 0) { MapTriggerBox box = MapEntityStorage.GetTriggerBox(Field.MapId, boxId); List <IFieldObject <Player> > boxedPlayers = new List <IFieldObject <Player> >(); foreach (IFieldObject <Player> player in players) { if (FieldManager.IsPlayerInBox(box, player)) { boxedPlayers.Add(player); } } players = boxedPlayers; } // move player back to return map if (mapId == 0 && triggerId == 0) { foreach (IFieldObject <Player> player in players) { player.Value.Warp(player.Value.ReturnMapId, player.Value.ReturnCoord); } return; } if (mapId == Field.MapId) { IFieldObject <Portal> portal = Field.State.Portals.Values.First(p => p.Value.Id == triggerId); foreach (IFieldObject <Player> player in players) { player.Coord = portal.Coord; player.Rotation = portal.Rotation; player.Value.Session.Send(UserMoveByPortalPacket.Move(player, portal.Coord, portal.Rotation)); } return; } CoordF moveCoord; CoordF moveRotation; MapPortal dstPortal = MapEntityStorage.GetPortals(mapId).FirstOrDefault(portal => portal.Id == triggerId); if (dstPortal == null) { MapPlayerSpawn spawn = MapEntityStorage.GetRandomPlayerSpawn(mapId); moveCoord = spawn.Coord.ToFloat(); moveRotation = spawn.Rotation.ToFloat(); } else { moveCoord = dstPortal.Coord.ToFloat(); moveRotation = dstPortal.Rotation.ToFloat(); } foreach (IFieldObject <Player> player in players) { player.Value.Warp(mapId, moveCoord, moveRotation); } }