public void Complete(Creature creature, Skill skill, Packet packet) { var str = packet.GetString(); var dict = new MabiDictionary(str); var hwEntityId = dict.GetLong("ITEMID"); if (hwEntityId == 0) goto L_End; var hw = creature.Inventory.GetItemSafe(hwEntityId); if (!hw.HasTag("/large_blessing_potion/")) goto L_End; // TODO: Check loading time var items = creature.Inventory.GetEquipment(); foreach (var item in items) { var blessable = (item.HasTag("/equip/") && !item.HasTag("/not_bless/")); if (blessable) item.OptionInfo.Flags |= ItemFlags.Blessed; } creature.Inventory.Decrement(hw, 1); Send.ItemBlessed(creature, items); L_End: Send.UseMotion(creature, 14, 0); Send.SkillComplete(creature, skill.Info.Id, str); }
/// <summary> /// Starts Mana Deflector. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="dict"></param> /// <returns></returns> public override StartStopResult Start(Creature creature, Skill skill, MabiDictionary dict) { // Give an indication of activation, official behavior unknown. Send.Notice(creature, Localization.Get("Mana Deflector activated.")); return StartStopResult.Okay; }
/// <summary> /// Starts the skill. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="dict"></param> /// <returns></returns> public override StartStopResult Start(Creature creature, Skill skill, MabiDictionary dict) { creature.Conditions.Activate(ConditionsA.ManaShield); Send.Effect(creature, Effect.ManaShield); return StartStopResult.Okay; }
/// <summary> /// Stops meditation. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="dict"></param> /// <returns></returns> public override StartStopResult Stop(Creature creature, Skill skill, MabiDictionary dict) { creature.Regens.Remove("Meditation"); creature.Conditions.Deactivate(ConditionsE.Meditation); return StartStopResult.Okay; }
public void Start(Creature creature, Skill skill, Packet packet) { // Get parameters var stringParam = packet.NextIs(PacketElementType.String); var dict = new MabiDictionary(); byte unkByte = 0; if (stringParam) dict.Parse(packet.GetString()); else unkByte = packet.GetByte(); // Run skill var result = this.Start(creature, skill, dict); if (result == StartStopResult.Fail) { Send.SkillStartSilentCancel(creature, skill.Info.Id); return; } skill.Activate(SkillFlags.InUse); Send.StatUpdate(creature, StatUpdateType.Private, Stat.Mana, Stat.Stamina); if (stringParam) Send.SkillStart(creature, skill, dict.ToString()); else Send.SkillStart(creature, skill, unkByte); }
public override StartStopResult Stop(Creature creature, Skill skill, MabiDictionary dict) { creature.Conditions.Deactivate(ConditionsA.ManaShield); creature.Regens.Remove("ManaShield"); return(StartStopResult.Okay); }
public PropExtension(SignalType signalType, EventType eventType, string name, byte mode) { this.SignalType = signalType; this.EventType = eventType; this.Name = name; this.Mode = mode; this.Value = new MabiDictionary(); }
public void Activate(ConditionsF condition, MabiDictionary extra = null) { this.F |= condition; if (extra != null) { this.SetExtra((double)condition, 5, extra); } Send.ConditionUpdate(_creature); }
private void SetExtra(double condition, int offset, MabiDictionary extra) { var id = (int)Math.Log(condition, 2) + (64 * offset); lock (_extra) _extra[id] = extra; _extraCache = null; }
public void Activate(ConditionsA condition, MabiDictionary extra = null) { this.A |= condition; if (extra != null) { this.SetExtra((double)condition, 0, extra); } Send.ConditionUpdate(_creature); this.Changed.Raise(_creature); }
public override StartStopResult Stop(Creature creature, Skill skill, MabiDictionary dict) { creature.Conditions.Deactivate(ConditionsA.ManaShield); creature.Regens.Remove("ManaShield"); return StartStopResult.Okay; }
public QuestScript() { this.Prerequisites = new List <QuestPrerequisite>(); this.Objectives = new OrderedDictionary <string, QuestObjective>(); this.Rewards = new List <QuestReward>(); this.MetaData = new MabiDictionary(); }
/// <summary> /// Starts the skill. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="dict"></param> /// <returns></returns> public override StartStopResult Start(Creature creature, Skill skill, MabiDictionary dict) { creature.Conditions.Activate(ConditionsA.ManaShield); Send.Effect(creature, Effect.ManaShield); creature.Regens.Add("ManaShield", Stat.Mana, -skill.RankData.Var2, creature.ManaMax); return(StartStopResult.Okay); }
/// <summary> /// Stops creature's transformation. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="dict"></param> /// <returns></returns> public override StartStopResult Stop(Creature creature, Skill skill, MabiDictionary dict) { creature.StopMove(); this.RemoveBonuses(creature, skill); this.ResetTransformation(creature, skill); return(StartStopResult.Okay); }
public override StartStopResult Start(Creature creature, Skill skill, MabiDictionary dict) { creature.Conditions.Activate(ConditionsA.ManaShield); Send.Effect(creature, Effect.ManaShield); creature.Regens.Add("ManaShield", Stat.Mana, -skill.RankData.Var2, creature.ManaMax); return StartStopResult.Okay; }
public void Start(Creature creature, Skill skill, Packet packet) { // Check mana and stamina if (!this.CheckMana(creature, skill)) { Send.SystemMessage(creature, Localization.Get("Insufficient Mana")); Send.SkillStartSilentCancel(creature, skill.Info.Id); return; } if (!this.CheckStamina(creature, skill)) { Send.SystemMessage(creature, Localization.Get("Insufficient Stamina")); Send.SkillStartSilentCancel(creature, skill.Info.Id); return; } // Get parameters var stringParam = packet.NextIs(PacketElementType.String); var dict = new MabiDictionary(); byte unkByte = 0; if (stringParam) { dict.Parse(packet.GetString()); } else { unkByte = packet.GetByte(); } // Run skill var result = this.Start(creature, skill, dict); if (result == StartStopResult.Fail) { Send.SkillStartSilentCancel(creature, skill.Info.Id); return; } skill.Activate(SkillFlags.InUse); // Use mana/stamina this.UseMana(creature, skill); this.UseStamina(creature, skill); Send.StatUpdate(creature, StatUpdateType.Private, Stat.Mana, Stat.Stamina); if (stringParam) { Send.SkillStart(creature, skill, dict.ToString()); } else { Send.SkillStart(creature, skill, unkByte); } }
public QuestScript() { this.Prerequisites = new List <QuestPrerequisite>(); this.Objectives = new OrderedDictionary <string, QuestObjective>(); this.RewardGroups = new Dictionary <int, QuestRewardGroup>(); this.MetaData = new MabiDictionary(); this.Type = QuestType.Normal; }
public QuestScript() { this.Prerequisites = new List<QuestPrerequisite>(); this.Objectives = new OrderedDictionary<string, QuestObjective>(); this.RewardGroups = new Dictionary<int, QuestRewardGroup>(); this.MetaData = new MabiDictionary(); this.Type = QuestType.Normal; }
public void Deserialize() { var test = new MabiDictionary(); test.Parse("a bool:b:1;a byte:1:1;a short:2:2;an int:4:3;a float:f:4;a string:s:five, special chars %C%S;"); Assert.Equal(true, test.GetBool("a bool")); Assert.Equal(1, test.GetByte("a byte")); Assert.Equal(2, test.GetShort("a short")); Assert.Equal(3, test.GetInt("an int")); Assert.Equal(4, test.GetFloat("a float")); Assert.Equal("five, special chars :;", test.GetString("a string")); }
public override StartStopResult Stop(Creature creature, Skill skill, MabiDictionary dict) { creature.Deactivate(CreatureStates.SitDown); Send.StandUp(creature); creature.Regens.Remove("Rest"); if (creature.Temp.SittingProp != null) this.RemoveChair(creature); return StartStopResult.Okay; }
public void Activate(ConditionsG condition, MabiDictionary extra = null, int duration = -1) { this.G |= condition; if (extra != null) { this.SetExtra((double)condition, 6, extra); } if (duration > 0) { this.SetDuration((double)condition, 6, duration); } Send.ConditionUpdate(_creature); this.Changed.Raise(_creature); }
/// <summary> /// Prepares skill. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="packet"></param> /// <returns></returns> public bool Prepare(Creature creature, Skill skill, Packet packet) { var dict = packet.GetString(); var enchantItemEntityId = MabiDictionary.Fetch <long>("ITEMID", dict); // Check everythig in Complete. // Response Send.Echo(creature, Op.SkillUse, packet); skill.State = SkillState.Used; return(true); }
public void Serialize() { var test = new MabiDictionary(); test.SetBool("a bool", true); test.SetByte("a byte", 1); test.SetShort("a short", 2); test.SetInt("an int", 3); test.SetFloat("a float", 4); test.SetString("a string", "five, special chars :;"); var test2 = test.ToString(); Assert.Equal("a bool:b:1;a byte:1:1;a short:2:2;an int:4:3;a float:f:4;a string:s:five, special chars %C%S;", test2); }
/// <summary> /// Activates weaken conditions for creature. /// </summary> /// <param name="creature"></param> /// <param name="levels">Amount of levels to lower the power level.</param> /// <param name="duration">Duration of the state.</param> protected void Weaken(Creature creature, int levels, int duration) { levels = Math2.Clamp(1, 255, levels); var extra = new MabiDictionary(); extra.SetByte("WKN_LV", (byte)levels); // min -> ms duration = duration * 60 * 1000; Send.Notice(creature, Localization.Get("The enemies seem to be much more powerful now.")); creature.Conditions.Activate(ConditionsA.Weaken, extra, duration); }
/// <summary> /// Starts the skill. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="dict"></param> /// <returns></returns> public override StartStopResult Start(Creature creature, Skill skill, MabiDictionary dict) { //Failure if preparing a skill, stunned, or knocked down. if (creature.Skills.ActiveSkill != null && creature.Skills.ActiveSkill.State == SkillState.None || creature.IsStunned || creature.IsKnockedDown) { return StartStopResult.Fail; } creature.Conditions.Activate(ConditionsA.ManaShield); Send.Effect(creature, Effect.ManaShield); creature.Regens.Add("ManaShield", Stat.Mana, -skill.RankData.Var2, creature.ManaMax); return StartStopResult.Okay; }
/// <summary> /// Stops meditation. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="dict"></param> /// <returns></returns> public override StartStopResult Stop(Creature creature, Skill skill, MabiDictionary dict) { creature.Regens.Remove("Meditation"); creature.Conditions.Deactivate(ConditionsE.Meditation); //Apply normal rest bonus instead of the campfire bonus if applicable. creature.Regens.Remove("Rest"); var restSkill = creature.Skills.Get(SkillId.Rest); if (restSkill != null && creature.Has(CreatureStates.SitDown)) { Life.Rest.ApplyRestBonus(creature, restSkill, creature.Temp.SittingProp != null ? creature.Temp.SittingProp.EntityId : 0); } return StartStopResult.Okay; }
public void Start(Creature creature, Skill skill, Packet packet) { // Check mana and stamina if (!this.CheckMana(creature, skill)) { Send.SystemMessage(creature, Localization.Get("Insufficient Mana")); Send.SkillStartSilentCancel(creature, skill.Info.Id); return; } if (!this.CheckStamina(creature, skill)) { Send.SystemMessage(creature, Localization.Get("Insufficient Stamina")); Send.SkillStartSilentCancel(creature, skill.Info.Id); return; } // Get parameters var stringParam = packet.NextIs(PacketElementType.String); var dict = new MabiDictionary(); byte unkByte = 0; if (stringParam) dict.Parse(packet.GetString()); else unkByte = packet.GetByte(); // Run skill var result = this.Start(creature, skill, dict); if (result == StartStopResult.Fail) { Send.SkillStartSilentCancel(creature, skill.Info.Id); return; } skill.Activate(SkillFlags.InUse); // Use mana/stamina this.UseMana(creature, skill); this.UseStamina(creature, skill); Send.StatUpdate(creature, StatUpdateType.Private, Stat.Mana, Stat.Stamina); if (stringParam) Send.SkillStart(creature, skill, dict.ToString()); else Send.SkillStart(creature, skill, unkByte); }
public void Activate(ConditionsC condition, short val) { this.C |= condition; var id = (int)Math.Log((double)condition, 2) + 64 * 2; lock (_extra) { if (!_extra.ContainsKey(id)) _extra[id] = new MabiDictionary(); _extra[id].SetShort("VAL", val); } _extraCache = null; Send.ConditionUpdate(_creature); }
/// <summary> /// Transforms creature. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="dict"></param> /// <returns></returns> public override StartStopResult Start(Creature creature, Skill skill, MabiDictionary dict) { if (skill.IsCoolingDown) { creature.Notice(Localization.Get("You can't use this for the rest of the day.")); return(StartStopResult.Fail); } creature.StopMove(); this.Transform(creature, skill); this.GiveBonuses(creature, skill); this.SetTimers(creature, skill); return(StartStopResult.Okay); }
/// <summary> /// Starts Meditation. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="dict"></param> /// <returns></returns> public override StartStopResult Start(Creature creature, Skill skill, MabiDictionary dict) { var rate = (skill.RankData.Var1 / 100f) * 0.05f; // TODO: Night? // "Disable" stm regen, triple hunger creature.Regens.Add("Meditation", Stat.Stamina, -0.4f, creature.StaminaMax); if (ChannelServer.Instance.Conf.World.EnableHunger) creature.Regens.Add("Meditation", Stat.Hunger, 0.02f, creature.StaminaMax); // Add mana regen creature.Regens.Add("Meditation", Stat.Mana, rate, creature.ManaMax); creature.Conditions.Activate(ConditionsE.Meditation); return StartStopResult.Okay; }
public bool Prepare(Creature creature, Skill skill, Packet packet) { var dict = packet.GetString(); // Get item entity id creature.Temp.NameColorItemEntityId = MabiDictionary.Fetch <long>("ITEMID", dict); if (creature.Temp.NameColorItemEntityId == 0) { Log.Warning("NameColorChange: Invalid item id '{0}' from creature '{1:X16}'.", creature.Temp.NameColorItemEntityId, creature.EntityId); return(false); } // Go into ready mode Send.SkillReady(creature, skill.Info.Id, dict); skill.State = SkillState.Ready; return(true); }
/// <summary> /// Stops rest skill, called when moving or stopping it. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="dict"></param> /// <returns></returns> public override StartStopResult Stop(Creature creature, Skill skill, MabiDictionary dict) { creature.Deactivate(CreatureStates.SitDown); if (skill.Info.Rank >= SkillRank.R9) { creature.Deactivate(CreatureStatesEx.RestR9); } Send.StandUp(creature); creature.Regens.Remove("Rest"); if (creature.Temp.SittingProp != null) { this.RemoveChair(creature); } return(StartStopResult.Okay); }
/// <summary> /// Completes skill, applying the enchant. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="packet"></param> public void Complete(Creature creature, Skill skill, Packet packet) { var dict = packet.GetString(); var enchantItemEntityId = MabiDictionary.Fetch <long>("ITEMID", dict); // Check enchant var elemental = creature.Inventory.GetItem(enchantItemEntityId); if (elemental == null) { Log.Warning("EnchantElementalAllSlot.Complete: User '{0}' tried to enchant with a non-existent elemental.", creature.Client.Account.Id); goto L_Fail; } // Check option set var optionSetId = elemental.MetaData1.GetInt("ENELEM"); var optionSetData = AuraData.OptionSetDb.Find(optionSetId); if (optionSetData == null) { Log.Warning("EnchantElementalAllSlot.Complete: User '{0:X16}' tried to enchant with unknown option set '{1}'.", creature.Client.Account.Id, optionSetId); goto L_Fail; } // Apply elementals var equip = creature.Inventory.GetMainEquipment(); foreach (var item in equip) { item.ApplyOptionSet(optionSetData, true); Send.ItemUpdate(creature, item); Send.AcquireEnchantedItemInfo(creature, item.EntityId, item.Info.Id, optionSetId); } // Decrement elemental creature.Inventory.Decrement(elemental); Send.Effect(creature, Effect.Enchant, (byte)EnchantResult.Success); L_Fail: Send.Echo(creature, packet); }
/// <summary> /// Starts Meditation. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="dict"></param> /// <returns></returns> public override StartStopResult Start(Creature creature, Skill skill, MabiDictionary dict) { var rate = (skill.RankData.Var1 / 100f) * 0.05f; // TODO: Night? // "Disable" stm regen, triple hunger creature.Regens.Add("Meditation", Stat.Stamina, -0.4f, creature.StaminaMax); if (ChannelServer.Instance.Conf.World.EnableHunger) { creature.Regens.Add("Meditation", Stat.Hunger, 0.02f, creature.StaminaMax); } // Add mana regen creature.Regens.Add("Meditation", Stat.Mana, rate, creature.ManaMax); creature.Conditions.Activate(ConditionsE.Meditation); return(StartStopResult.Okay); }
/// <summary> /// Prepares skill, reading the item to use from the packet. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="packet"></param> /// <returns></returns> public bool Prepare(Creature creature, Skill skill, Packet packet) { var dictStr = packet.GetString(); byte unkByte = 0; if (packet.Peek() == PacketElementType.Byte) { unkByte = packet.GetByte(); } // Get item entity id var itemEntityId = MabiDictionary.Fetch <long>("ITEMID", dictStr); if (itemEntityId == 0) { Log.Warning("HiddenTownBack: Item entity id missing."); return(false); } // Get item var item = creature.Inventory.GetItem(itemEntityId); if (item == null) { Log.Warning("HiddenTownBack: Creature '{0:X16}' tried to use non-existing item.", creature.EntityId); return(false); } // Set callback for Complete creature.Skills.Callback(skill.Info.Id, () => { // Try to warp and remove item if successful if (Warp(creature, item)) { creature.Inventory.Remove(item); } }); Send.SkillUse(creature, skill.Info.Id, itemEntityId, unkByte, ""); skill.State = SkillState.Used; return(true); }
public void Activate(ConditionsC condition, short val) { this.C |= condition; var id = (int)Math.Log((double)condition, 2) + 64 * 2; lock (_extra) { if (!_extra.ContainsKey(id)) { _extra[id] = new MabiDictionary(); } _extra[id].SetShort("VAL", val); } _extraCache = null; Send.ConditionUpdate(_creature); }
/// <summary> /// Readies skill, saving the item id to use for later. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="packet"></param> /// <returns></returns> public bool Ready(Creature creature, Skill skill, Packet packet) { if (skill.Info.Id == SkillId.Campfire) { creature.Temp.FirewoodItemId = packet.GetInt(); Send.SkillReady(creature, skill.Info.Id, creature.Temp.FirewoodItemId); } else { var dict = packet.GetString(); creature.Temp.CampfireKitItemEntityId = MabiDictionary.Fetch <long>("ITEMID", dict); Send.SkillReady(creature, skill.Info.Id, dict); } return(true); }
/// <summary> /// Prepares skill, getting the used item. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="packet"></param> /// <returns></returns> public bool Prepare(Creature creature, Skill skill, Packet packet) { var parameters = packet.GetString(); // Check item var itemEntityId = MabiDictionary.Fetch <long>("ITEMID", parameters); if (itemEntityId == 0) { Log.Warning("HiddenResurrection: Creature '{0:X16}' tried to use skill without item."); return(false); } var item = creature.Inventory.GetItem(itemEntityId); if (item == null) { Log.Warning("HiddenResurrection: Creature '{0:X16}' tried to use skill with non-existing item."); return(false); } if (!item.HasTag("/usable/resurrection/")) { Log.Warning("HiddenResurrection: Creature '{0:X16}' tried to use skill with invalid item."); return(false); } // Check if any party members are actually dead if party feather if (item.HasTag("/party/") && !creature.Party.GetMembers().Any(a => a != creature && a.IsDead && a.DeadMenu.Has(ReviveOptions.PhoenixFeather))) { Send.MsgBox(creature, Localization.Get("There is no one available to resurrect.")); return(false); } creature.Temp.SkillItem1 = item; // Response Send.Echo(creature, Op.SkillReady, packet); skill.State = SkillState.Ready; return(true); }
public override StartStopResult Start(Creature creature, Skill skill, MabiDictionary dict) { creature.StopMove(); var chairItemEntityId = dict.GetLong("ITEMID"); if (chairItemEntityId != 0) this.SetUpChair(creature, chairItemEntityId); creature.Activate(CreatureStates.SitDown); Send.SitDown(creature); creature.Regens.Add("Rest", Stat.Life, (0.12f * ((skill.RankData.Var1 - 100) / 100)), creature.LifeMax); creature.Regens.Add("Rest", Stat.Stamina, (0.4f * ((skill.RankData.Var2 - 100) / 100)), creature.StaminaMax); creature.Regens.Add("Rest", Stat.LifeInjured, skill.RankData.Var3, creature.LifeMax); if (skill.Info.Rank == SkillRank.Novice) skill.Train(1); // Use Rest. return StartStopResult.Okay; }
/// <summary> /// Starts rest skill. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="dict"></param> /// <returns></returns> public override StartStopResult Start(Creature creature, Skill skill, MabiDictionary dict) { creature.StopMove(); creature.IsInBattleStance = false; creature.AttemptingAttack = false; var chairItemEntityId = dict.GetLong("ITEMID"); if (chairItemEntityId != 0) this.SetUpChair(creature, chairItemEntityId); creature.Activate(CreatureStates.SitDown); if (skill.Info.Rank >= SkillRank.R9) creature.Activate(CreatureStatesEx.RestR9); Send.SitDown(creature); // Get bonuses if meditation isn't active. if (!creature.Conditions.Has(ConditionsE.Meditation)) { ApplyRestBonus(creature, skill, chairItemEntityId); } else { RestCampfireBonus(creature, skill, chairItemEntityId); } // Add bonus from campfire // TODO: Check for disappearing of campfire? (OnDisappears+Recheck) var campfires = creature.Region.GetProps(a => a.Info.Id == 203 && a.GetPosition().InRange(creature.GetPosition(), 500)); if (campfires.Count > 0) { Send.Notice(creature, Localization.Get("The fire feels very warm.")); } if (skill.Info.Rank == SkillRank.Novice) skill.Train(1); // Use Rest. return StartStopResult.Okay; }
public void Complete(Creature creature, Skill skill, Packet packet) { var str = packet.GetString(); var dict = new MabiDictionary(str); var hwEntityId = dict.GetLong("ITEMID"); if (hwEntityId == 0) { goto L_End; } var hw = creature.Inventory.GetItemSafe(hwEntityId); if (!hw.HasTag("/large_blessing_potion/")) { goto L_End; } // TODO: Check loading time var items = creature.Inventory.GetEquipment(); foreach (var item in items) { var blessable = (item.HasTag("/equip/") && !item.HasTag("/not_bless/")); if (blessable) { item.OptionInfo.Flags |= ItemFlags.Blessed; } } creature.Inventory.Decrement(hw, 1); Send.ItemBlessed(creature, items); L_End: Send.UseMotion(creature, 14, 0); Send.SkillComplete(creature, skill.Info.Id, str); }
public void Stop(Creature creature, Skill skill, Packet packet) { var stringParam = packet.NextIs(PacketElementType.String); var dict = new MabiDictionary(); byte unkByte = 0; if (stringParam) dict.Parse(packet.GetString()); else if (packet.NextIs(PacketElementType.Byte)) unkByte = packet.GetByte(); var result = this.Stop(creature, skill, dict); skill.Deactivate(SkillFlags.InUse); if (result == StartStopResult.Fail) Send.SkillStopSilentCancel(creature, skill.Info.Id); else if (stringParam) Send.SkillStop(creature, skill, dict.ToString()); else Send.SkillStop(creature, skill, unkByte); }
public void Start(Creature creature, Skill skill, Packet packet) { // Get parameters var stringParam = packet.NextIs(PacketElementType.String); var dict = new MabiDictionary(); byte unkByte = 0; if (stringParam) { dict.Parse(packet.GetString()); } else { unkByte = packet.GetByte(); } // Run skill var result = this.Start(creature, skill, dict); if (result == StartStopResult.Fail) { Send.SkillStartSilentCancel(creature, skill.Info.Id); return; } skill.Activate(SkillFlags.InUse); Send.StatUpdate(creature, StatUpdateType.Private, Stat.Mana, Stat.Stamina); if (stringParam) { Send.SkillStart(creature, skill, dict.ToString()); } else { Send.SkillStart(creature, skill, unkByte); } }
public void GmcpBoost(ChannelClient client, Packet packet) { var multiplier = packet.GetFloat(); var creature = client.GetCreatureSafe(packet.Id); var speedBonus = (short)(multiplier * 100 - 100); speedBonus = (short)Math2.Clamp(0, 1000, speedBonus); if (speedBonus == 0) { creature.Conditions.Deactivate(ConditionsC.Hurry); } else { var extra = new MabiDictionary(); extra.SetShort("VAL", speedBonus); creature.Conditions.Activate(ConditionsC.Hurry, extra); } Send.ServerMessage(creature, Localization.Get("Speed boost: {0}x"), multiplier.ToString("0.0", CultureInfo.InvariantCulture)); }
public void Complete(Creature creature, Skill skill, Packet packet) { var str = packet.GetString(); var dict = new MabiDictionary(str); var hwEntityId = dict.GetLong("ITEMID"); if (hwEntityId == 0) goto L_End; var hw = creature.Inventory.GetItemSafe(hwEntityId); if (!hw.HasTag("/large_blessing_potion/")) goto L_End; // TODO: Check loading time var items = creature.Inventory.GetEquipment(a => a.IsBlessable); creature.Bless(items); creature.Inventory.Decrement(hw, 1); L_End: Send.UseMotion(creature, 14, 0); Send.SkillComplete(creature, skill.Info.Id, str); }
/// <summary> /// Starts Meditation. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="dict"></param> /// <returns></returns> public override StartStopResult Start(Creature creature, Skill skill, MabiDictionary dict) { var rate = (skill.RankData.Var1 / 100f) * 0.05f; // TODO: Night? // "Disable" stm regen, triple hunger creature.Regens.Add("Meditation", Stat.Stamina, -0.4f, creature.StaminaMax); //Apply campfire rest bonus instead of the normal bonus if applicable. creature.Regens.Remove("Rest"); var restSkill = creature.Skills.Get(SkillId.Rest); if (restSkill != null && creature.Has(CreatureStates.SitDown)) { Life.Rest.RestCampfireBonus(creature, restSkill, creature.Temp.SittingProp != null ? creature.Temp.SittingProp.EntityId : 0); } if (ChannelServer.Instance.Conf.World.EnableHunger) creature.Regens.Add("Meditation", Stat.Hunger, 0.02f, creature.StaminaMax); // Add mana regen creature.Regens.Add("Meditation", Stat.Mana, rate, creature.ManaMax); creature.Conditions.Activate(ConditionsE.Meditation); return StartStopResult.Okay; }
/// <summary> /// Stops Heavy Stander. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="dict"></param> /// <returns></returns> public override StartStopResult Stop(Creature creature, Skill skill, MabiDictionary dict) { Send.Notice(creature, Localization.Get("Heavy Stander deactivated.")); return(StartStopResult.Okay); }
/// <summary> /// Stop skills. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="dict"></param> /// <returns></returns> public override StartStopResult Stop(Creature creature, Skill skill, MabiDictionary dict) { return StartStopResult.Okay; }
public void Activate(ConditionsE condition, MabiDictionary extra = null) { this.E |= condition; if (extra != null) this.SetExtra((double)condition, 4, extra); Send.ConditionUpdate(_creature); }
public virtual StartStopResult Stop(Creature creature, Skill skill, MabiDictionary dict) { throw new NotImplementedException(); }
/// <summary> /// Removes previous stat mods and adds new ones. /// </summary> /// <param name="data"></param> /// <param name="option"></param> private void SwitchStatMods(TitleData data, bool option) { // Remove prev stat mods if (option && _optionTitleData != null) { _creature.StatMods.Remove(StatModSource.Title, this.SelectedOptionTitle); if (_titleData.Effects.Any(a => a.Key == "Speed")) { _creature.Conditions.Deactivate(ConditionsC.Hurry); } } else if (!option && _titleData != null) { _creature.StatMods.Remove(StatModSource.Title, this.SelectedTitle); if (_titleData.Effects.Any(a => a.Key == "Speed")) { _creature.Conditions.Deactivate(ConditionsC.Hurry); } } // Add new stat mods if (data != null) { foreach (var effect in data.Effects) { // Simply adding the bonuses allows to "recover" stats by // using different titles, eg first +40, then +120, to // add 160 Life, even though it should only be 120? // Not much of a problem with title apply delay. switch (effect.Key) { case "Life": _creature.StatMods.Add(Stat.LifeMaxMod, effect.Value, StatModSource.Title, data.Id); if (effect.Value > 0) { _creature.Life += effect.Value; // Add value } else { _creature.Life = _creature.Life; // "Reset" stat (in case of reducation, stat = max) } break; case "Mana": _creature.StatMods.Add(Stat.ManaMaxMod, effect.Value, StatModSource.Title, data.Id); if (effect.Value > 0) { _creature.Mana += effect.Value; } else { _creature.Mana = _creature.Mana; } break; case "Stamina": // Adjust hunger to new max value, so Food stays // at the same percentage. var hungerRate = (100 / _creature.StaminaMax * _creature.Hunger) / 100f; _creature.StatMods.Add(Stat.StaminaMaxMod, effect.Value, StatModSource.Title, data.Id); if (effect.Value > 0) { _creature.Stamina += effect.Value; } else { _creature.Stamina = _creature.Stamina; } _creature.Hunger = _creature.StaminaMax * hungerRate; break; case "Str": _creature.StatMods.Add(Stat.StrMod, effect.Value, StatModSource.Title, data.Id); break; case "Int": _creature.StatMods.Add(Stat.IntMod, effect.Value, StatModSource.Title, data.Id); break; case "Dex": _creature.StatMods.Add(Stat.DexMod, effect.Value, StatModSource.Title, data.Id); break; case "Will": _creature.StatMods.Add(Stat.WillMod, effect.Value, StatModSource.Title, data.Id); break; case "Luck": _creature.StatMods.Add(Stat.LuckMod, effect.Value, StatModSource.Title, data.Id); break; case "Defense": _creature.StatMods.Add(Stat.DefenseBaseMod, effect.Value, StatModSource.Title, data.Id); break; case "Protection": _creature.StatMods.Add(Stat.ProtectionBaseMod, effect.Value, StatModSource.Title, data.Id); break; case "MinAttack": _creature.StatMods.Add(Stat.AttackMinMod, effect.Value, StatModSource.Title, data.Id); break; case "MaxAttack": _creature.StatMods.Add(Stat.AttackMaxMod, effect.Value, StatModSource.Title, data.Id); break; case "MinInjury": _creature.StatMods.Add(Stat.InjuryMinMod, effect.Value, StatModSource.Title, data.Id); break; case "MaxInjury": _creature.StatMods.Add(Stat.InjuryMaxMod, effect.Value, StatModSource.Title, data.Id); break; case "Crit": _creature.StatMods.Add(Stat.CriticalMod, effect.Value, StatModSource.Title, data.Id); break; case "CP": _creature.StatMods.Add(Stat.CombatPowerMod, effect.Value, StatModSource.Title, data.Id); break; case "MagicAttack": _creature.StatMods.Add(Stat.MagicAttackMod, effect.Value, StatModSource.Title, data.Id); break; case "MagicDefense": _creature.StatMods.Add(Stat.MagicDefenseMod, effect.Value, StatModSource.Title, data.Id); break; case "MagicProtection": _creature.StatMods.Add(Stat.MagicProtectionMod, effect.Value, StatModSource.Title, data.Id); break; case "Speed": // XXX: Conditions with idents to deactive them // more easily, like stat mods and regens? var extra = new MabiDictionary(); extra.SetShort("VAL", (short)effect.Value); _creature.Conditions.Activate(ConditionsC.Hurry, extra); break; default: Log.Warning("SwitchStatMods: Unknown title effect '{0}' in title {1}.", effect.Key, data.Id); break; } } } // Broadcast new stats if creature is in a region yet if (_creature.Region != Region.Limbo) { Send.StatUpdate(_creature, StatUpdateType.Private, Stat.LifeMaxMod, Stat.Life, Stat.LifeInjured, Stat.ManaMaxMod, Stat.Mana, Stat.StaminaMaxMod, Stat.Stamina, Stat.StrMod, Stat.IntMod, Stat.DexMod, Stat.WillMod, Stat.LuckMod, Stat.DefenseBaseMod, Stat.ProtectionBaseMod, Stat.AttackMinMod, Stat.AttackMaxMod, Stat.InjuryMinMod, Stat.InjuryMaxMod, Stat.CriticalMod, Stat.CombatPower, Stat.MagicAttackMod, Stat.MagicDefenseMod, Stat.MagicProtectionMod ); Send.StatUpdate(_creature, StatUpdateType.Public, Stat.Life, Stat.LifeMaxMod, Stat.LifeMax); } // Save data if (!option) { _titleData = data; } else { _optionTitleData = data; } }
public void Activate(ConditionsG condition, MabiDictionary extra = null, int duration = -1) { this.G |= condition; if (extra != null) this.SetExtra((double)condition, 6, extra); if (duration > 0) this.SetDuration((double)condition, 6, duration); Send.ConditionUpdate(_creature); this.Changed.Raise(_creature); }
/// <summary> /// Starts rest skill. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="dict"></param> /// <returns></returns> public override StartStopResult Start(Creature creature, Skill skill, MabiDictionary dict) { creature.StopMove(); var chairItemEntityId = dict.GetLong("ITEMID"); if (chairItemEntityId != 0) { this.SetUpChair(creature, chairItemEntityId); } creature.Activate(CreatureStates.SitDown); if (skill.Info.Rank >= SkillRank.R9) { creature.Activate(CreatureStatesEx.RestR9); } Send.SitDown(creature); // Get base bonuses var bonusLife = ((skill.RankData.Var1 - 100) / 100); var bonusStamina = ((skill.RankData.Var2 - 100) / 100); var bonusInjury = skill.RankData.Var3; // Add bonus from campfire // TODO: Check for disappearing of campfire? (OnDisappears+Recheck) var campfires = creature.Region.GetProps(a => a.Info.Id == 203 && a.GetPosition().InRange(creature.GetPosition(), 500)); if (campfires.Count > 0) { // Add bonus if no chair? if (chairItemEntityId == 0) { // TODO: Select nearest? Random? var campfire = campfires[0]; var multi = (campfire.Temp.CampfireSkillRank != null ? campfire.Temp.CampfireSkillRank.Var1 / 100f : 1); // Add bonus for better wood. // Amounts unofficial. if (campfire.Temp.CampfireFirewood != null) { if (campfire.Temp.CampfireFirewood.HasTag("/firewood01/")) { multi += 0.1f; } else if (campfire.Temp.CampfireFirewood.HasTag("/firewood02/")) { multi += 0.2f; } else if (campfire.Temp.CampfireFirewood.HasTag("/firewood03/")) { multi += 0.3f; } } // Apply multiplicator bonusLife *= multi; bonusStamina *= multi; bonusInjury *= multi; } Send.Notice(creature, Localization.Get("The fire feels very warm")); } creature.Regens.Add("Rest", Stat.Life, (0.12f * bonusLife), creature.LifeMax); creature.Regens.Add("Rest", Stat.Stamina, (0.4f * bonusStamina), creature.StaminaMax); creature.Regens.Add("Rest", Stat.LifeInjured, bonusInjury, creature.LifeMax); // TODO: Test if LifeInjured = Injuries if (skill.Info.Rank == SkillRank.Novice) { skill.Train(1); // Use Rest. } return(StartStopResult.Okay); }
public void Activate(ConditionsF condition, MabiDictionary extra = null) { this.F |= condition; if (extra != null) this.SetExtra((double)condition, 5, extra); Send.ConditionUpdate(_creature); this.Changed.Raise(_creature); }
/// <summary> /// Stops Heavy Stander. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="dict"></param> /// <returns></returns> public override StartStopResult Stop(Creature creature, Skill skill, MabiDictionary dict) { Send.Notice(creature, Localization.Get("Heavy Stander deactivated.")); return StartStopResult.Okay; }