public static GetObjectIndexAndType ( int Index_, uint ObjectId ) : int | ||
Index_ | int | |
ObjectId | uint | |
리턴 | int |
public static void OnDeSpawn(int Index_, uint ObjectId) { if (ObjectId != 0) { int ObjectIndex = Players.GetObjectIndexAndType(Index_, ObjectId); Timers.MonsterAttack[ObjectIndex].Stop(); Timers.MonsterMovement[ObjectIndex].Stop(); Monsters.General[ObjectIndex] = new Monsters._General(); Monsters.Position[ObjectIndex] = new _Position(); for (int i = 0; i < Player.PlayersOnline; i++) { if (Player.General[i].UniqueID != 0 && Player.Objects[i].SpawnedMonsterIndex.Contains(ObjectIndex)) { ServerSocket.Send(Players.CreateDeSpawnPacket(ObjectId), i); Player.Objects[i].SpawnedMonsterIndex.Remove(ObjectIndex); } } } }
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(); } } } }
public static void Action(PacketReader reader_, int Index_) { PacketWriter writer = new PacketWriter(); reader_.ModifyIndex(1); byte type = reader_.ReadByte(); if (Player.General[Index_].State != 1) { switch (type) { case 1: reader_.ModifyIndex(1); uint ObjectId = reader_.ReadDword(); Player.Objects[Index_].AttackingObjectId = ObjectId; int ObjectIndex = Players.GetObjectIndexAndType(Index_, Player.Objects[Index_].AttackingObjectId); bool attack = false; if (Player.Objects[Index_].SelectedObjectType == 2) { attack = Movement.MoveToObject(Index_, ref Player.Position[Index_], Monsters.Position[ObjectIndex], Player.General[Index_], false); } else { attack = Movement.MoveToObject(Index_, ref Player.Position[Index_], Player.Position[ObjectIndex], Player.General[Index_], false); } if (attack) { if (!Player.Objects[Index_].NormalAttack) { Attack.NormalAttack(Index_); } } break; case 2: reader_.ModifyIndex(1); ObjectId = reader_.ReadDword(); ObjectIndex = 0; for (int i = 0; i <= Item.ItemAmount; i++) { if (Item.General[i].UniqueID == ObjectId && Index_ != i) { ObjectIndex = i; break; } } bool pickup = false; pickup = Movement.MoveToObject(Index_, ref Player.Position[Index_], Item.Position[ObjectIndex], Player.General[Index_], false); if (pickup) { PickUpItem(Index_, ObjectIndex); } break; case 4: uint skillid = reader_.ReadDword(); bool skillexist = false; int CharacterSkillIndex = DatabaseCore.Skill.GetIndexByName(Player.General[Index_].CharacterName); for (int i = 0; i <= DatabaseCore.Skill.SkillAmount[CharacterSkillIndex]; i++) { if (skillid == DatabaseCore.Skill.Skills[CharacterSkillIndex].SkillId[i]) { skillexist = true; break; } skillexist = false; } if (skillexist) { byte type_ = reader_.ReadByte(); switch (type_) { case 0: bool alreadyactive = false; for (byte i = 0; i < Player.Objects[Index_].ActiveBuffs.Length; i++) { if (Player.Objects[Index_].ActiveBuffs[i].Id == skillid) { alreadyactive = true; } } if (!alreadyactive) { Player.Objects[Index_].UsingSkillID = skillid; if (!Player.Objects[Index_].UsingSkill) { PrepareBuff(Index_); } } return; case 1: uint attackingObjectId = reader_.ReadDword(); Player.Objects[Index_].AttackingSkillID = skillid; Player.Objects[Index_].AttackingObjectId = attackingObjectId; Player.Objects[Index_].NormalAttack = false; if (!Player.Objects[Index_].UsingSkill) { SkillAttackType(Index_); } return; } } break; default: Timers.PlayerAttack[Index_].Stop(); break; } } }
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_); } } }