public static void OnSkillUpdate(PacketReader reader_, int Index_) { int CharacterSkillIndex = DatabaseCore.Skill.GetIndexByName(Player.General[Index_].CharacterName); uint SkillId = reader_.ReadDword(); Silkroad.Skill_ NewSkill = Silkroad.GetSkillById(SkillId); if (Player.Stats[Index_].Skillpoints >= NewSkill.RequiredSp) { writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_SKILLUPDATE); writer.AppendByte(1); writer.AppendDword(SkillId); ServerSocket.Send(writer.getWorkspace(), Index_); DatabaseCore.Skill.SkillAmount[CharacterSkillIndex]++; for (int i = 1; i <= DatabaseCore.Skill.SkillAmount[CharacterSkillIndex]; i++) { if (DatabaseCore.Skill.Skills[CharacterSkillIndex].SkillId[i] == SkillId - 1) { DatabaseCore.WriteQuery("UPDATE skills SET Skill{0}='{1}' WHERE Skill{0}='{2}' AND owner='{3}'", i, SkillId, DatabaseCore.Skill.Skills[CharacterSkillIndex].SkillId[i], Player.General[Index_].CharacterName); DatabaseCore.Skill.Skills[CharacterSkillIndex].SkillId[i + 1] = SkillId; } } DatabaseCore.WriteQuery("UPDATE skills SET Skill{0}='{1}' WHERE owner='{2}'", DatabaseCore.Skill.SkillAmount[CharacterSkillIndex], SkillId, Player.General[Index_].CharacterName); DatabaseCore.WriteQuery("UPDATE skills SET AmountSkill='{0}' WHERE owner='{1}'", DatabaseCore.Skill.SkillAmount[CharacterSkillIndex], Player.General[Index_].CharacterName); DatabaseCore.Skill.Skills[CharacterSkillIndex].SkillId[DatabaseCore.Skill.SkillAmount[CharacterSkillIndex] - 1] = SkillId; Player.Stats[Index_].Skillpoints -= (uint)NewSkill.RequiredSp; SPUpdate(Index_); } }
public static void BeginSkill(int Index_) { Player.Objects[Index_].UsingSkill = true; Silkroad.Skill_ tmpSkill = Silkroad.GetSkillById(Player.Objects[Index_].AttackingSkillID); Player.Stats[Index_].CMP -= tmpSkill.RequiredMp; Stats.MPUpdate(Index_, true); Player.Objects[Index_].AttackingCastingID = (uint)random.Next(500, 50000); PacketWriter writer = new PacketWriter(); writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_SKILL_ATTACK); writer.AppendByte(1); writer.AppendByte(1); ServerSocket.Send(writer.getWorkspace(), Index_); writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_ATTACK); writer.AppendWord(0x201); writer.AppendDword(Player.Objects[Index_].AttackingSkillID); writer.AppendDword(Player.General[Index_].UniqueID); writer.AppendDword(Player.Objects[Index_].AttackingCastingID); writer.AppendDword(Player.Objects[Index_].AttackingObjectId); writer.AppendByte(0); ServerSocket.SendPacketIfPlayerIsSpawned(writer.getWorkspace(), Index_); if (tmpSkill.CastTime <= 0) { EndSkill(Index_); } else { Timers.CastAttackTimer[Index_].Interval = tmpSkill.CastTime * 1000; Timers.CastAttackTimer[Index_].Start(); } }
private static void PrepareBuff(int Index_) { PacketWriter writer = new PacketWriter(); Player.Objects[Index_].UsingSkill = true; uint CastingId = (uint)random.Next(65536, 1048575); writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_ATTACK); writer.AppendByte(1); writer.AppendByte(0); writer.AppendDword(Player.Objects[Index_].UsingSkillID); writer.AppendDword(Player.General[Index_].UniqueID); writer.AppendDword(CastingId); writer.AppendByte(0); writer.AppendDword(0); ServerSocket.SendPacketIfPlayerIsSpawned(writer.getWorkspace(), Index_); Silkroad.Skill_ tmpSkill = Silkroad.GetSkillById(Player.Objects[Index_].UsingSkillID); Player.Objects[Index_].BuffCastingID = CastingId; Timers.CastBuffTimer[Index_].Interval = tmpSkill.CastTime * 1000; Timers.CastBuffTimer[Index_].Start(); }
public static void NormalAttack(int Index_) { uint SkillId = 0; byte AttackAmount = GetAmountAndSkillIdByWeaponType(Index_, ref SkillId); bool AttackingPlayer = false; for (int i = 0; i <= Player.PlayersOnline; i++) { if (Player.Objects[Index_].AttackingObjectId == Player.General[i].UniqueID) { AttackingPlayer = true; } } int ObjectIndex = Players.GetObjectIndexAndType(Index_, Player.Objects[Index_].AttackingObjectId); Silkroad.Skill_ tmpAttackSkill = Silkroad.GetSkillById(SkillId); uint BasicAttackPower = 0; if (tmpAttackSkill.Type == Silkroad.TypeTable.Phy) { BasicAttackPower = (uint)random.Next(Player.Stats[Index_].MinPhy, Player.Stats[Index_].MaxPhy); } else if (tmpAttackSkill.Type == Silkroad.TypeTable.Mag) { BasicAttackPower = (uint)random.Next(Player.Stats[Index_].MinMag, Player.Stats[Index_].MaxMag); } double SkillAttackPower = 1; //cause its normal attack double SkillIncreaseRate = 0; // needs to be calculated from passive skills/active buffs double EnemyAbsorbation = 0; if (AttackingPlayer) { EnemyAbsorbation = Player.Stats[ObjectIndex].TotalAccessoriesAbsorption / (double)100; } double EnemyDefence = 0; if (AttackingPlayer) { if (tmpAttackSkill.Type == Silkroad.TypeTable.Phy) { EnemyDefence = Player.Stats[ObjectIndex].PhyDef; } else if (tmpAttackSkill.Type == Silkroad.TypeTable.Mag) { EnemyDefence = Player.Stats[ObjectIndex].MagDef; } } else { if (tmpAttackSkill.Type == Silkroad.TypeTable.Phy) { EnemyDefence = Silkroad.GetObjectById(Monsters.General[ObjectIndex].ID).PhyDef; } else if (tmpAttackSkill.Type == Silkroad.TypeTable.Mag) { EnemyDefence = Silkroad.GetObjectById(Monsters.General[ObjectIndex].ID).MagDef; } } double TotalDamageIncreaseRate = 0;//needs to be calculated from the players equipment double Damage = Formula.CalculateDmg( BasicAttackPower, SkillAttackPower, SkillIncreaseRate, EnemyAbsorbation, EnemyDefence, Player.Stats[Index_].Level, Player.Stats[Index_].Strength, Player.Stats[Index_].Intelligence, TotalDamageIncreaseRate, tmpAttackSkill.PwrPercent / (double)100); byte Critical = 0; Player.Objects[Index_].NormalAttack = true; if (Player.Objects[Index_].SelectedObjectType == 2) { Timers.MonsterMovement[ObjectIndex].Stop(); } PacketWriter writer = new PacketWriter(); writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_ATTACK); writer.AppendByte(1); writer.AppendByte(2); writer.AppendDword(SkillId); writer.AppendDword(Player.General[Index_].UniqueID); writer.AppendDword((uint)(random.Next(1000, 10000) + Player.General[Index_].UniqueID)); writer.AppendDword(Player.Objects[Index_].AttackingObjectId); writer.AppendByte(1); writer.AppendByte(AttackAmount); writer.AppendByte(1); writer.AppendDword(Player.Objects[Index_].AttackingObjectId); byte afterstate = 0; for (int i = 1; i <= AttackAmount; i++) { if (tmpAttackSkill.Type == Silkroad.TypeTable.Phy) { if (random.Next(1, 10) >= 7) { Damage *= 2; Critical = 2; } } if (Player.Objects[Index_].SelectedObjectType == 2) { Monsters.General[ObjectIndex].HP -= (int)Damage; if (Monsters.General[ObjectIndex].HP < 0) { afterstate = 0x80; Monsters.General[ObjectIndex].HP = 0; } } else if (Player.Objects[Index_].SelectedObjectType == 1) { int tmpHp = (int)(Player.Stats[ObjectIndex].CHP - Damage); if (tmpHp < 0) { afterstate = 0x80; Player.Stats[ObjectIndex].CHP = 0; } else { Player.Stats[ObjectIndex].CHP -= (int)Damage; } } writer.AppendByte(afterstate); writer.AppendByte(Critical); writer.AppendDword((uint)Damage); writer.AppendByte(0); writer.AppendWord(0); } ServerSocket.SendPacketIfPlayerIsSpawned(writer.getWorkspace(), Index_); Player.General[Index_].Busy = true; Player.Objects[Index_].NormalAttack = true; Timers.PlayerAttack[Index_].Interval = 1350.0; Timers.PlayerAttack[Index_].Start(); if (afterstate == 0x80) { Player.Objects[Index_].AttackingObjectDeadID = Player.Objects[Index_].AttackingObjectId; Player.General[Index_].Busy = false; Timers.PlayerAttack[Index_].Stop(); Player.Objects[Index_].NormalAttack = false; if (Player.Objects[Index_].SelectedObjectType == 1) { Player.General[ObjectIndex].State = 10; Player.Objects[ObjectIndex].NormalAttack = false; Player.General[ObjectIndex].Busy = false; Timers.PlayerAttack[ObjectIndex].Stop(); Character.Die(ObjectIndex); Character.Die2(ObjectIndex); Player.Flags[ObjectIndex].Dead = true; } if (Player.Objects[Index_].SelectedObjectType == 2) { Stats.GetBerserk(Index_, ObjectIndex); Stats.GetXP(Index_, ObjectIndex); if (Monsters.General[ObjectIndex].Type == 3) { Unique.OnUnique((uint)Monsters.General[ObjectIndex].ID, true, Player.General[Index_].CharacterName); } Monsters.General[ObjectIndex].Dead = true; Timers.MonsterAttack[ObjectIndex].Stop(); Timers.MonsterDeath[Index_].Interval = 3000.0; Timers.MonsterDeath[Index_].Start(); } } else { if (Player.Objects[Index_].SelectedObjectType == 2) { if (!Timers.MonsterAttack[ObjectIndex].Enabled) { Monsters.General[ObjectIndex].AttackingObjectIndex = Index_; Timers.MonsterAttack[ObjectIndex].Interval = 2350; Timers.MonsterAttack[ObjectIndex].Start(); } } } }
private static void SkillAttackType(int Index_) { PacketWriter writer = new PacketWriter(); Silkroad.Skill_ tmpSkill = Silkroad.GetSkillById(Player.Objects[Index_].AttackingSkillID); byte weapontype = 0; if (Player.General[Index_].WeaponType == 6) { weapontype = Silkroad.TypeTable.Bow; } if ((Player.General[Index_].WeaponType == 2) || (Player.General[Index_].WeaponType == 3)) { weapontype = Silkroad.TypeTable.Bicheon; } if ((Player.General[Index_].WeaponType == 4) || (Player.General[Index_].WeaponType == 5)) { weapontype = Silkroad.TypeTable.Heuksal; } byte skilltype = tmpSkill.Type2; if (!(weapontype == skilltype) && !(skilltype == Silkroad.TypeTable.All)) { Player.Objects[Index_].UsingSkill = false; writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_ATTACK); writer.AppendWord(0xD02); ServerSocket.Send(writer.getWorkspace(), Index_); writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_SKILL_ATTACK); writer.AppendWord(3); writer.AppendByte(4); ServerSocket.Send(writer.getWorkspace(), Index_); } else { int ObjectIndex = Players.GetObjectIndexAndType(Index_, Player.Objects[Index_].AttackingObjectId); if (Player.Objects[Index_].SelectedObjectType == 2) { Timers.MonsterMovement[ObjectIndex].Stop(); } bool attack = false; if (Player.Objects[Index_].SelectedObjectType == 2) { attack = Movement.MoveToObject(Index_, ref Player.Position[Index_], Monsters.Position[ObjectIndex], Player.General[Index_].UniqueID, Player.General[Index_].CharacterID, tmpSkill.Distance * 10, weapontype, false); } else { attack = Movement.MoveToObject(Index_, ref Player.Position[Index_], Player.Position[ObjectIndex], Player.General[Index_].UniqueID, Player.General[Index_].CharacterID, tmpSkill.Distance * 10, weapontype, false); } if (attack) { Attack.BeginSkill(Index_); } } }