private void GenerateExperience(Aisling player) { var percent = 0.3; var poly = 9; var coponent = poly + player.ExpLevel / Template.Level + 99 * 2; var expToAward = Math.Round(coponent / percent * (player.ExpLevel * 0.30)); var expGained = Math.Round(player.ExpLevel * expToAward); var p = player.ExpLevel - Template.Level; if (p / 10 > 0) { expGained = 1; } else { expGained = Math.Abs(expToAward); } if (p < 0) { expGained = expToAward * (Math.Abs(p) + 3); } player.ExpTotal += (int)expGained; player.ExpNext -= (int)expGained; player.Client.SendMessage(0x02, string.Format("You received {0} Experience!.", (int)expGained)); if (player.ExpNext <= 0) { player.ExpNext = player.ExpTotal * (int)(player.ExpLevel * 0.45) / 6; player._MaximumHp += (int)(50 * player.Con * 0.65); player._MaximumMp += (int)(25 * player.Wis * 0.45); player.StatPoints += 2; player.ExpLevel++; if (player.ExpLevel > 99) { player.AbpLevel++; player.ExpLevel = 99; } if (player.AbpLevel > 99) { player.AbpLevel = 99; player.GamePoints++; } player.Client.SendMessage(0x02, string.Format("You have reached level {0}!", player.ExpLevel)); player.Show(Scope.NearbyAislings, new ServerFormat29((uint)player.Serial, (uint)player.Serial, 0x004F, 0x004F, 64)); } }
public GameClient LeaveArea(bool update = false, bool delete = false) { if (Aisling.LastMapId == short.MaxValue) { Aisling.LastMapId = Aisling.CurrentMapId; } Aisling.Remove(update, delete); return(this); }
public void UpdateQuest(Aisling user) { if (StageIndex + 1 < QuestStages.Count) { StageIndex++; } else { OnCompleted(user); } }
private int CheckSpellandSkillPredicates(Aisling player, Dictionary <int, Tuple <bool, object> > result, int n) { if (Skill_Required != null) { var skill = ServerContextBase.GlobalSkillTemplateCache[Skill_Required]; var skill_retainer = player.SkillBook.Get(i => i.Template?.Name.Equals(skill.Name) ?? false) .FirstOrDefault(); if (skill_retainer == null) { result[n++] = new Tuple <bool, object>(false, $"You don't have the skill required. ({Skill_Required})"); } else { if (skill_retainer != null && skill_retainer.Level >= Skill_Level_Required) { result[n++] = new Tuple <bool, object>(true, "Skills Required."); } else { result[n++] = new Tuple <bool, object>(false, $"{skill.Name} Must be level {Skill_Level_Required} - Go get {Math.Abs(skill_retainer.Level - Skill_Level_Required)} more levels."); } } } if (Spell_Required != null) { var spell = ServerContextBase.GlobalSpellTemplateCache[Spell_Required]; var spell_retainer = player.SpellBook.Get(i => i != null && i.Template != null && i.Template.Name.Equals(spell.Name)).FirstOrDefault(); if (spell_retainer == null) { result[n++] = new Tuple <bool, object>(false, $"You don't have the spell required. ({Spell_Required})"); } else if (spell_retainer.Level >= Spell_Level_Required) { result[n++] = new Tuple <bool, object>(true, "Spells Required."); } else { result[n++] = new Tuple <bool, object>(false, $"{spell.Name} Must be level {Skill_Level_Required} - Go get {Math.Abs(spell_retainer.Level - Spell_Level_Required)} more levels."); } } return(n); }
public void SendSound(byte sound, Scope scope = Scope.Self) { var empty = new ServerFormat13 { Serial = Aisling.Serial, Health = byte.MaxValue, Sound = sound }; Aisling.Show(scope, empty); }
public void Say(string message, byte type = 0x00) { var response = new ServerFormat0D { Serial = Aisling.Serial, Type = type, Text = message }; Aisling.Show(Scope.NearbyAislings, response); }
private void UpdateCounters(Aisling player) { if (!player.MonsterKillCounters.ContainsKey(Template.Name)) { player.MonsterKillCounters[Template.Name] = 1; } else { player.MonsterKillCounters[Template.Name]++; } }
public static bool GiveTo(Aisling aisling, string args, byte slot, int level = 1) { var skillTemplate = ServerContextBase.GlobalSkillTemplateCache[args]; var skill = Create(slot, skillTemplate); { skill.Level = level; skill.Scripts = ScriptManager.Load <SkillScript>(skill.Template.ScriptName, skill); aisling.SkillBook.Assign(skill); } return(true); }
public GameClient SendSound(byte sound, Scope scope = Scope.Self) { var empty = new ServerFormat13 { Serial = Aisling.Serial, Health = byte.MaxValue, Sound = sound }; Aisling.Show(scope, empty); return(this); }
public ServerFormat42(Aisling user, byte type = 0x00, byte method = 0x00, string lpMsg = "", Item lpItem = null) { if (method <= 0) { throw new ArgumentOutOfRangeException(nameof(method)); } Stage = type; Player = user; ExchangedItem = lpItem; Message = lpMsg; }
public bool IsMet(Aisling player, Action <string, bool> callbackMsg = null) { var result = new Dictionary <int, Tuple <bool, object> >(); var n = 0; n = CheckSpellandSkillPredicates(player, result, n); n = CHeckAttributePredicates(player, result, n); n = CheckItemPredicates(player, result, n); n = CheckQuestPredicates(player, result, n); return(CheckPredicates(callbackMsg, result)); }
public static bool AddToParty(Party prmParty, Aisling User) { if (prmParty.Members.Find(i => string.Equals(i.Username, User.Username, System.StringComparison.OrdinalIgnoreCase)) == null) { User.InvitePrivleges = true; prmParty.Members.Add(User); return(true); } return(false); }
private int CheckSpellandSkillPredicates(Aisling player, Dictionary <int, Tuple <bool, object> > result, int n) { if (Skill_Required != null) { var skill = ServerContext.GlobalSkillTemplateCache[Skill_Required]; var skill_retainer = player.SkillBook.Get(i => i.Template.Name.Equals(skill.Name)).FirstOrDefault(); if (skill_retainer == null) { result[n++] = new Tuple <bool, object>(false, string.Format("You don't have the skill required. ({0})", Skill_Required)); } if (skill_retainer != null && skill_retainer.Level >= Skill_Level_Required) { result[n++] = new Tuple <bool, object>(true, "Skills Required."); } else { result[n++] = new Tuple <bool, object>(false, string.Format("{0} Must be level {1} - Go get {2} more levels.", skill.Name, Skill_Level_Required, Math.Abs(skill_retainer.Level - Skill_Level_Required))); } } if (Spell_Required != null) { var spell = ServerContext.GlobalSpellTemplateCache[Spell_Required]; var spell_retainer = player.SpellBook.Get(i => i.Template.Name.Equals(spell.Name)).FirstOrDefault(); if (spell_retainer == null) { result[n++] = new Tuple <bool, object>(false, string.Format("You don't have the spell required. ({0})", Spell_Required)); } if (spell_retainer != null & spell_retainer.Level >= Spell_Level_Required) { result[n++] = new Tuple <bool, object>(true, "Spells Required."); } else { result[n++] = new Tuple <bool, object>(false, string.Format("{0} Must be level {1} - Go get {2} more levels.", spell.Name, Skill_Level_Required, Math.Abs(spell_retainer.Level - Spell_Level_Required))); } } return(n); }
public void Rewards(Aisling user, bool equipLoot) { foreach (var items in SkillRewards.Where(items => !Skill.GiveTo(user.Client, items))) { } foreach (var items in SpellRewards.Where(items => !Spell.GiveTo(user, items))) { } foreach (var obj in from items in ItemRewards where ServerContextBase.GlobalItemTemplateCache.ContainsKey(items) select ServerContextBase.GlobalItemTemplateCache[items] into template select Item.Create(user, template) into obj where !obj.GiveTo(user) select obj) { obj.Release(user, user.Position); } foreach (var legends in LegendRewards) { user.LegendBook.AddLegend(new Legend.LegendItem { Category = "Quest Reward", Color = legends.Color, Icon = legends.Icon, Value = legends.Value }); } if (ExpRewards.Count > 0) { ExpRewards.ForEach(i => Monster.DistributeExperience(user, i)); } if (GoldReward > 0) { user.GoldPoints += (int)GoldReward; user.Client.SendMessage(0x02, $"You are awarded {GoldReward} gold."); } if (equipLoot) { EquipRewards(user); user.Client.Refresh(); } user.Client.SendStats(StatusFlags.All); }
public void LearnSkill(Mundane Source, SkillTemplate subject, string message) { if (PayPrerequisites(subject.Prerequisites)) { Skill.GiveTo(this, subject.Name); SendOptionsDialog(Source, message); Aisling.Show(Scope.NearbyAislings, new ServerFormat29((uint)Aisling.Serial, (uint)Source.Serial, subject?.TargetAnimation ?? 124, subject?.TargetAnimation ?? 124, 100)); } }
public void GiveTo(int amount, Aisling aisling) { aisling.GoldPoints += amount; if (aisling.GoldPoints > ServerContext.Config.MaxCarryGold) { aisling.GoldPoints = int.MaxValue; } aisling.Client.Send(new ServerFormat08(aisling, StatusFlags.StructC)); Remove <Money>(); }
/// <summary> /// Login - Check username/password. Proceed to Game Server. /// </summary> protected override void Format03Handler(LoginClient client, ClientFormat03 format) { Aisling _aisling = null; try { _aisling = StorageManager.AislingBucket.Load(format.Username); if (_aisling != null) { if (_aisling.Password != format.Password) { client.SendMessageBox(0x02, "Sorry, Incorrect Password."); return; } } else { client.SendMessageBox(0x02, string.Format( "{0} does not exist in this world. You can make this hero by clicking on 'Create'.", format.Username)); return; } } catch (Exception e) { client.SendMessageBox(0x02, string.Format( "{0} is not supported by the new server. Please remake your character. This will not happen when the server goes to beta.", format.Username)); ServerContext.Report(e); return; } if (!ServerContext.Config.MultiUserLogin) { var aislings = GetObjects <Aisling>(null, i => i.Username.ToLower() == format.Username.ToLower() && format.Password == i.Password); foreach (var aisling in aislings) { aisling.Client.Server.ClientDisconnected(aisling.Client); } } LoginAsAisling(client, _aisling); }
private int CHeckAttributePredicates(Aisling player, Dictionary <int, Tuple <bool, object> > result, int n) { result[n++] = new Tuple <bool, object>(player.ExpLevel >= ExpLevel_Required, string.Format("Go level more. (Level {0} Required.)", Spell_Level_Required)); result[n++] = new Tuple <bool, object>(player.Str >= Str_Required, string.Format("You are not strong enough. ({0} Str Required.).", Str_Required)); result[n++] = new Tuple <bool, object>(player.Int >= Int_Required, string.Format("You are not smart enough. ({0} Int Required.).", Int_Required)); result[n++] = new Tuple <bool, object>(player.Wis >= Wis_Required, string.Format("You are not wise enough. ({0} Wis Required.).", Wis_Required)); result[n++] = new Tuple <bool, object>(player.Con >= Con_Required, string.Format("You lack stamina. ({0} Con Required.).", Con_Required)); result[n++] = new Tuple <bool, object>(player.Dex >= Dex_Required, string.Format("You are not nimble enough. ({0} Dex Required.).", Dex_Required)); result[n++] = new Tuple <bool, object>(player.GoldPoints >= Gold_Required, string.Format("You best come back when you got the cash. ({0} Gold Required.).", Gold_Required)); result[n++] = new Tuple <bool, object>(player.Stage == Stage_Required, "You must transcend further first"); result[n++] = new Tuple <bool, object>(player.Path == Class_Required, "You should not be here, " + player.Path.ToString()); return(n); }
/// <summary> /// Login - Check username/password. Proceed to Game Server. /// </summary> protected override void Format03Handler(LoginClient client, ClientFormat03 format) { Aisling _aisling = null; try { _aisling = StorageManager.AislingBucket.Load(format.Username); if (_aisling != null) { if (_aisling.Password != format.Password) { client.SendMessageBox(0x02, "Sorry, Incorrect Password."); return; } } else { client.SendMessageBox(0x02, string.Format("{0} does not exist in this world. You can make this hero by clicking on 'Create'.", format.Username)); return; } } catch { client.SendMessageBox(0x02, string.Format("{0} is not supported by the new server. Please remake your character. This will not happen when the server goes to beta.", format.Username)); return; } if (_aisling != null) { ServerContext.Info?.Info("Player Entering Game: {0}", _aisling.Username); var redirect = new Redirect { Serial = Convert.ToString(client.Serial), Salt = System.Text.Encoding.UTF8.GetString(client.Encryption.Parameters.Salt), Seed = Convert.ToString(client.Encryption.Parameters.Seed), Name = _aisling.Username }; client.SendMessageBox(0x00, "\0"); client.Send(new ServerFormat03 { EndPoint = new IPEndPoint(Address, ServerContext.DefaultPort), Redirect = redirect }); } }
public bool CanPickup(Aisling player, Item LpItem) { if (player == null || LpItem == null) { return(false); } if (LpItem.Template == null) { return(false); } return((player.CurrentWeight + LpItem.Template.CarryWeight < player.MaximumWeight) && FindEmpty() != byte.MaxValue); }
private static void Levelup(Aisling player) { if (player.ExpLevel < ServerContext.Config.PlayerLevelCap) { player._MaximumHp += (int)(ServerContext.Config.HpGainFactor * player.Con * 0.65); player._MaximumMp += (int)(ServerContext.Config.MpGainFactor * player.Wis * 0.45); player.StatPoints += ServerContext.Config.StatsPerLevel; player.ExpLevel++; player.Client.SendMessage(0x02, string.Format(ServerContext.Config.LevelUpMessage, player.ExpLevel)); player.Show(Scope.NearbyAislings, new ServerFormat29((uint)player.Serial, (uint)player.Serial, 0x004F, 0x004F, 64)); } }
protected override void Format03Handler(LoginClient client, ClientFormat03 format) { Aisling aisling = null; try { aisling = StorageManager.AislingBucket.Load(format.Username); if (aisling != null) { if (aisling.Password != format.Password) { client.SendMessageBox(0x02, "Sorry, Incorrect Password."); return; } } else { client.SendMessageBox(0x02, $"{format.Username} does not exist in this world. You can make this hero by clicking on 'Create'."); return; } } catch (Exception ex) { ServerContext.Logger(ex.Message, Microsoft.Extensions.Logging.LogLevel.Error); ServerContext.Logger(ex.StackTrace, Microsoft.Extensions.Logging.LogLevel.Error); client.SendMessageBox(0x02, $"{format.Username} is not supported by the new server. Please remake your character. This will not happen when the server goes to beta."); return; } if (!ServerContext.Config.MultiUserLogin) { var aislings = ServerContext.Game.Clients.Where(i => i?.Aisling != null && i.Aisling.LoggedIn && i.Aisling.Username.ToLower() == format.Username.ToLower()); foreach (var obj in aislings) { obj.Aisling?.Remove(true); obj.Server.ClientDisconnected(obj); } } LoginAsAisling(client, aisling); }
//up public override void OnBack(Aisling aisling) { if (aisling.ActiveReactor == null) { aisling.ReactorActive = false; aisling.Client.CloseDialog(); return; } if (aisling.ActiveReactor.Index - 1 >= 0) { aisling.ActiveReactor.Index--; aisling.ActiveReactor.Next(aisling.Client, true); } }
public void Update(TimeSpan elapsedTime) { #region Sanity Checks if (Aisling == null) { return; } if (!Aisling.LoggedIn) { return; } if ((DateTime.UtcNow - Aisling.LastLogged).TotalMilliseconds < ServerContextBase.Config.LingerState) { return; } #endregion var distance = Aisling.Position.DistanceFrom(Aisling.LastPosition.X, Aisling.LastPosition.Y); if (distance > 2 && !IsWarping && (DateTime.UtcNow - LastMapUpdated).TotalMilliseconds > 2000) { LastWarp = DateTime.UtcNow; Aisling.LastPosition.X = (ushort)Aisling.XPos; Aisling.LastPosition.Y = (ushort)Aisling.YPos; LastLocationSent = DateTime.UtcNow; Refresh(); return; } if (Aisling.TrapsAreNearby()) { var nextTrap = Trap.Traps.Select(i => i.Value) .FirstOrDefault(i => i.Owner.Serial != Aisling.Serial && Aisling.Map.Flags.HasFlag(MapFlags.PlayerKill) && i.Location.X == Aisling.X && i.Location.Y == Aisling.Y); if (nextTrap != null) { Trap.Activate(nextTrap, Aisling); } } DoUpdate(elapsedTime); }
public static void DistributeExperience(Aisling player, double exp) { var chunks = exp / 1000; if (chunks <= 1) { HandleExp(player, exp); } else { for (var i = 0; i < chunks; i++) { HandleExp(player, 1000); } } }
public GameClient DoUpdate(TimeSpan elapsedTime) { if (!Session.ConnectedSocket.Connected) { Aisling.Remove(true); Server.ClientDisconnected(this); return(this); } return(HandleTimeOuts() .StatusCheck() .Regen(elapsedTime) .UpdateStatusBar(elapsedTime) .UpdateReactors(elapsedTime)); }
public GameClient HandleTimeOuts() { if (Aisling.Exchange != null) { if (Aisling.Exchange.Trader != null) { if (!Aisling.Exchange.Trader.LoggedIn || !Aisling.WithinRangeOf(Aisling.Exchange.Trader)) { Aisling.CancelExchange(); } } } return(this); }
public override void OnTriggered(Aisling aisling) { if (aisling.ReactedWith(Reactor.Name)) { foreach (var sequences in Reactor.Sequences.Where(i => i.OnSequenceStep != null)) { sequences.OnSequenceStep.Invoke(aisling, sequences); } } else { aisling.ReactorActive = true; aisling.ActiveReactor = Reactor; aisling.ActiveReactor.Next(aisling.Client); } }
private void QuestCompleted(Aisling aisling, DialogSequence b) { aisling.Client.SendOptionsDialog(Mundane, "Ah there we go, splendid! this should be useful to you for a while. Come back again another time, i might be able to make you something even better."); var subject = aisling.Quests.Find(i => i.Name == Mundane.Template.QuestKey); if (subject != null) { Actor.Quest.OnCompleted(aisling); aisling.DestroyReactor(Actor); aisling.Client.CloseDialog(); subject.Completed = true; } }
public static bool GiveTo(Aisling Aisling, string spellname, byte slot) { var spellTemplate = ServerContext.GlobalSpellTemplateCache[spellname]; if (slot <= 0) { return(false); } var spell = Create(slot, spellTemplate); spell.Script = ScriptManager.Load <SpellScript>(spell.Template.ScriptKey, spell); Aisling.SpellBook.Assign(spell); return(true); }