public static void GiveWeaponExperience(Character target, uint wexp) { byte index = target.weapons.ActiveWeaponIndex == 1 ? target.weapons.SeconairyWeaponIndex : target.weapons.PrimaryWeaponIndex; if (index < target.weapons.UnlockedWeaponSlots) { Weapon weapon = target.weapons[index]; if (weapon == null || weapon._weaponlevel >= Singleton.experience.MaxWLVL) { return; } //Checks if the weapon is at already at max experience uint ReqWexp = Singleton.experience.FindRequiredWexp(weapon._weaponlevel + 1); if (weapon._experience == ReqWexp) { return; } //Adds the experience and check if we gain a level weapon._experience += wexp; if (weapon._experience > ReqWexp) { weapon._experience = ReqWexp; } //Adds the weapon experience SMSG_WEAPONADJUST spkt = new SMSG_WEAPONADJUST(); spkt.Function = 2; spkt.Value = weapon._experience; spkt.Slot = (byte)index; spkt.SessionId = target.id; target.client.Send((byte[])spkt); } }
public static void CheckWeaponary(Character character) { //Disable weapon for (int i = 0; i < 5; i++) { //Verify if the weapon exists Weapon weapon = character.weapons[i]; if (weapon == null) { continue; } bool Active = weapon._active == 1; bool NewActive = Common.Skills.HasRootSkillPresent( character, weapon.Info.weapon_skill); if (Active == NewActive) { continue; } weapon._active = (byte)((NewActive == true) ? 1 : 0); SMSG_WEAPONADJUST spkt = new SMSG_WEAPONADJUST(); spkt.Function = 6; spkt.Slot = (byte)i; spkt.SessionId = character.id; spkt.Value = weapon._active; character.client.Send((byte[])spkt); } }
/// <summary> /// Performs a loose of durabillity on the active weapon. /// </summary> /// <param name="target"></param> public static void DoWeapon(Character target) { if (target == null) { return; } byte index = target.weapons.ActiveWeaponIndex == 1 ? target.weapons.SeconairyWeaponIndex : target.weapons.PrimaryWeaponIndex; if (index < target.weapons.UnlockedWeaponSlots) { Weapon ActiveWeapon = target.weapons[index]; //Do durabillity lost if (ActiveWeapon._durabillity > 1) { //Lose durability ActiveWeapon._durabillity -= 1; SMSG_WEAPONADJUST spkt = new SMSG_WEAPONADJUST(); spkt.SessionId = target.id; spkt.Slot = index; spkt.Function = 3; spkt.Value = ActiveWeapon._durabillity; target.client.Send((byte[])spkt); //Do deactivation if (ActiveWeapon._durabillity == 0) { CommonFunctions.SendBattleStatus(target); } } } }
public void wdura(uint dura) { SMSG_WEAPONADJUST spkt = new SMSG_WEAPONADJUST(); spkt.SessionId = this.session; spkt.Slot = 0; spkt.Function = 3; spkt.Value = dura; this.Send((byte[])spkt); }
public void wup() { SMSG_WEAPONADJUST spkt = new SMSG_WEAPONADJUST(); spkt.SessionId = this.session; spkt.Slot = 0; spkt.Function = 1; spkt.Value = ++lvl2; this.Send((byte[])spkt); }
public void wlvl(uint lvl) { lvl2 = lvl; SMSG_WEAPONADJUST spkt = new SMSG_WEAPONADJUST(); spkt.SessionId = this.session; spkt.Slot = 0; spkt.Function = 1; spkt.Value = lvl; this.Send((byte[])spkt); }
public static void CheckWeaponary(Character character) { //Disable weapon for (int i = 0; i < 5; i++) { //Verify if the weapon exists Weapon weapon = character.weapons[i]; if (weapon == null) continue; bool Active = weapon._active == 1; bool NewActive = Common.Skills.HasRootSkillPresent( character, weapon.Info.weapon_skill); if (Active == NewActive) continue; weapon._active = (byte)((NewActive == true) ? 1 : 0); SMSG_WEAPONADJUST spkt = new SMSG_WEAPONADJUST(); spkt.Function = 6; spkt.Slot = (byte)i; spkt.SessionId = character.id; spkt.Value = weapon._active; character.client.Send((byte[])spkt); } }
/// <summary> /// Performs a loose of durabillity on the active weapon. /// </summary> /// <param name="target"></param> public static void DoWeapon(Character target) { if (target == null) return; byte index = target.weapons.ActiveWeaponIndex == 1 ? target.weapons.SeconairyWeaponIndex : target.weapons.PrimaryWeaponIndex; if (index < target.weapons.UnlockedWeaponSlots) { Weapon ActiveWeapon = target.weapons[index]; //Do durabillity lost if (ActiveWeapon._durabillity > 1) { //Lose durability ActiveWeapon._durabillity -= 1; SMSG_WEAPONADJUST spkt = new SMSG_WEAPONADJUST(); spkt.SessionId = target.id; spkt.Slot = index; spkt.Function = 3; spkt.Value = ActiveWeapon._durabillity; target.client.Send((byte[])spkt); //Do deactivation if (ActiveWeapon._durabillity == 0) { CommonFunctions.SendBattleStatus(target); } } } }
public static void GiveWeaponExperience(Character target, uint wexp) { byte index = target.weapons.ActiveWeaponIndex == 1 ? target.weapons.SeconairyWeaponIndex : target.weapons.PrimaryWeaponIndex; if (index < target.weapons.UnlockedWeaponSlots) { Weapon weapon = target.weapons[index]; if (weapon == null || weapon._weaponlevel >= Singleton.experience.MaxWLVL) return; //Checks if the weapon is at already at max experience uint ReqWexp = Singleton.experience.FindRequiredWexp(weapon._weaponlevel + 1); if (weapon._experience == ReqWexp) { return; } //Adds the experience and check if we gain a level weapon._experience += wexp; if (weapon._experience > ReqWexp) { weapon._experience = ReqWexp; } //Adds the weapon experience SMSG_WEAPONADJUST spkt = new SMSG_WEAPONADJUST(); spkt.Function = 2; spkt.Value = weapon._experience; spkt.Slot = (byte)index; spkt.SessionId = target.id; target.client.Send((byte[])spkt); } }
/// <summary> /// Occurs when repairing equipment /// </summary> /// <param name="cpkt"></param> private void CM_REPAIREQUIPMENT(CMSG_REPAIRITEM cpkt) { bool HasBadIndex = false; double price = 0; int amount = cpkt.Amount; List<KeyValuePair<byte, byte>> list = new List<KeyValuePair<byte, byte>>(); for (int i = 0; i < amount; i++) { //Read the equipment information byte index; byte container; cpkt.ReadEquipmentInfo(out index, out container); list.Add(new KeyValuePair<byte, byte>(container, index)); // Item from weaponary if (container == 8) { //CHECK IF WEAPON EXISTS Weapon current = this.character.weapons[index]; if (current == null) { HasBadIndex = true; continue; } //Compute the repair costs float scalar = (float)(current.Info.max_durabillity - current._durabillity) / (float)current.Info.max_durabillity; double costs = (double)(Singleton.experience.FindRepairCosts(current._weaponlevel) * scalar); //Increment the repair costs price += costs; } //Increment the repair costs else if (container == 1) { //Check if equipment exists Rag2Item current = this.character.Equipment[index]; if (current == null) { HasBadIndex = true; continue; } //Compute the repair costs double scalar = (double)(current.info.max_durability - current.durabillty) / (double)current.info.max_durability; double costs = (double) Rag2Item.CalculateRepairCosts( (double)current.info.price, (double)current.clvl, (double)current.info.max_durability ) * scalar; //Increment the repair costs price += costs; } //Item from inventory else if (container == 2) { //Check if equipment exists Rag2Item current = this.character.container[index]; if (current == null) { HasBadIndex = true; continue; } //Compute the repair costs double scalar = (double)(current.info.max_durability - current.durabillty) / (double)current.info.max_durability; double costs = (double) Rag2Item.CalculateRepairCosts( (double)current.info.price, (double)current.clvl, (double)current.info.max_durability ) * scalar; //Increment the repair costs price += costs; } } price = Math.Ceiling(price); //Check if a bad index occured if (HasBadIndex) { Common.Errors.GeneralErrorMessage( this.character, (uint)Generalerror.WrongServerIndex ); } //Check if our price is right uint aprice = (uint)price; if (this.character.ZENY >= aprice) { this.character.ZENY -= aprice; foreach (KeyValuePair<byte, byte> pair in list) { // Item from weaponary if (pair.Key == 8) { Weapon current = this.character.weapons[pair.Value]; if (current._durabillity == 0 && Common.Skills.HasRootSkillPresent(this.character, current.Info.weapon_skill)) { current._active = 1; SMSG_WEAPONADJUST spkt2 = new SMSG_WEAPONADJUST(); spkt2.SessionId = this.character.id; spkt2.Function = 6; spkt2.Value = 1; spkt2.Slot = pair.Value; this.Send((byte[])spkt2); } current._durabillity = (ushort)current.Info.max_durabillity; SMSG_WEAPONADJUST spkt = new SMSG_WEAPONADJUST(); spkt.SessionId = this.character.id; spkt.Function = 3; spkt.Value = current.Info.max_durabillity; spkt.Slot = pair.Value; this.Send((byte[])spkt); } //Equipment else if (pair.Key == 1) { Rag2Item current = this.character.Equipment[pair.Value]; if (current.durabillty == 0 && this.character.jlvl >= current.info.JobRequirement[this.character.job - 1]) { current.active = 1; SMSG_ITEMADJUST spkt2 = new SMSG_ITEMADJUST(); spkt2.Function = 5; spkt2.Container = pair.Key; spkt2.Slot = pair.Value; spkt2.Value = 1; spkt2.SessionId = this.character.id; this.Send((byte[])spkt2); #warning "Equipment applied" current.Activate(AdditionContext.Applied, this.character); } current.durabillty = (int)current.info.max_durability; SMSG_ITEMADJUST spkt = new SMSG_ITEMADJUST(); spkt.Function = 3; spkt.Container = pair.Key; spkt.Slot = pair.Value; spkt.Value = (uint)current.durabillty; spkt.SessionId = this.character.id; this.Send((byte[])spkt); } //Inventory else if (pair.Key == 2) { Rag2Item current = this.character.container[pair.Value]; current.durabillty = (int)current.info.max_durability; SMSG_ITEMADJUST spkt = new SMSG_ITEMADJUST(); spkt.Function = 3; spkt.Container = pair.Key; spkt.Slot = pair.Value; spkt.Value = (uint)current.durabillty; spkt.SessionId = this.character.id; this.Send((byte[])spkt); } } //Flush all pending updates LifeCycle.Update(this.character); //Update zeny CommonFunctions.UpdateZeny( this.character ); } else { Common.Errors.GeneralErrorMessage( this.character, (uint)Generalerror.NotEnoughMoneyToRepair ); } }
/// <summary> /// Occurs when a player tries to upgrade her weapon /// </summary> /// <param name="cpkt"></param> private void CM_WEAPONARY_UPGRADE(CMSG_WEAPONUPGRADE cpkt) { //Helper variables Character target = this.character; Saga.Factory.Weaponary.Info info; int slot = cpkt.SlotId - 1; byte result = 0; try { //CHECK FOR VALID SLOT if (slot < 5 && target.weapons[slot] != null) { Weapon weapon = target.weapons[slot]; byte newLevel = (byte)(weapon._weaponlevel + 1); uint ReqZeny = Singleton.experience.FindUpgradeCosts(weapon._weaponlevel); //CHECK IF WE HAVEN'T REACHED OUR LEVEL LIMIT if (weapon._weaponlevel == Singleton.experience.MaxWLVL) { result = (byte)Generalerror.LevelLimitReached; } //NOT ENOUGH MONEY TO UPGRADE else if (ReqZeny > target.ZENY) { result = (byte)Generalerror.NotEnoughMoneyWithDialog; } //ONLY PROCESS IF WEAPON WAS FOUND else if (Singleton.Weapons.TryGetWeaponInfo(weapon._weapontype, newLevel, out info)) { BattleStatus status = this.character._status; status.MaxWMAttack -= (ushort)weapon.Info.max_magic_attack; status.MinWMAttack -= (ushort)weapon.Info.min_magic_attack; status.MaxWPAttack -= (ushort)weapon.Info.max_short_attack; status.MinWPAttack -= (ushort)weapon.Info.min_short_attack; status.MaxWRAttack -= (ushort)weapon.Info.max_range_attack; status.MinWRAttack -= (ushort)weapon.Info.min_range_attack; status.MaxWMAttack += (ushort)info.max_magic_attack; status.MinWMAttack += (ushort)info.min_magic_attack; status.MaxWPAttack += (ushort)info.max_short_attack; status.MinWPAttack += (ushort)info.min_short_attack; status.MaxWRAttack += (ushort)info.max_range_attack; status.MinWRAttack += (ushort)info.min_range_attack; status.Updates |= 2; weapon._weaponlevel += 1; weapon.Info = info; SMSG_WEAPONADJUST spkt2 = new SMSG_WEAPONADJUST(); spkt2.Function = 1; spkt2.Value = newLevel; spkt2.Slot = (byte)slot; spkt2.SessionId = target.id; this.Send((byte[])spkt2); Tasks.LifeCycle.Update(this.character); target.ZENY -= ReqZeny; CommonFunctions.UpdateZeny(target); } } //NOT VALID SLOT else { result = (byte)Generalerror.WeaponNotExists; } //ADJUST WEAPONARY SMSG_WEAPONUPGRADE spkt = new SMSG_WEAPONUPGRADE(); spkt.Result = result; spkt.SessionId = this.character.id; this.Send((byte[])spkt); } //ON ERROR SENT FAILURE MESSAGE catch (Exception) { SMSG_WEAPONUPGRADE spkt = new SMSG_WEAPONUPGRADE(); spkt.Result = result; spkt.SessionId = this.character.id; this.Send((byte[])spkt); } }