void c_ClientKillPetInfo(object sender, ClientKillPetInfoEventArgs e) { Client c = (Client)sender; KillPet i = e.Info; MapEngine mapEngine = GetMapEngine(c.MyCharacter.MapId); Client[] clients = GetClientsForChars(mapEngine.GetCharactersInRange(c.MyCharacter.Position, 150).ToArray()); if (c.MyCharacter.tempPet != null && i.Action == 3) { BaseSkill skill = new BaseSkill(); if (c.MyCharacter.RemoveActiveSkill((int)HardSkills.Shadow_Strike)) { skill.SkillID = (int)HardSkills.Shadow_Strike; skill.SkillLevel = 1; c.Send(PacketManager.SendEndSkill(c.MyCharacter, skill)); } if (c.MyCharacter.RemoveActiveSkill((int)AbsorbSkills.Shadow_Focus)) { skill.SkillID = (int)AbsorbSkills.Shadow_Focus; skill.SkillLevel = 1; c.Send(PacketManager.SendEndSkill(c.MyCharacter, skill)); } if (c.MyCharacter.RemoveActiveSkill((int)RebirthSkills.Duplicate_Attack)) { skill.SkillID = (int)RebirthSkills.Duplicate_Attack; skill.SkillLevel = 1; c.Send(PacketManager.SendEndSkill(c.MyCharacter, skill)); } if (c.MyCharacter.RemoveActiveSkill((int)HardSkills.Summon_Monster)) { skill.SkillID = (int)HardSkills.Summon_Monster; skill.SkillLevel = 1; c.Send(PacketManager.SendEndSkill(c.MyCharacter, skill)); } byte[] RemovePet = PacketManager.SendMonsterDie(c.MyCharacter.tempPet); SendToClients(RemovePet, clients); c.MyCharacter.tempPet = null; } if (c.MyCharacter.Pet != null && i.PetID == c.MyCharacter.Pet.PetID && i.Action == 3) { byte[] RemovePet = PacketManager.SendMonsterDie(c.MyCharacter.Pet); SendToClients(RemovePet, clients); c.MyCharacter.Pet.Alive = false; petManager.UpdatePet(c.MyCharacter.Pet); c.MyCharacter.Pet = null; } }
private bool LearnSkill(Client c, BaseItem item, bool removeItem, BaseSkill skill, BookItem book) { short test = 0; if (!c.MyCharacter.ContainSkill(skill.SkillID, skill.SkillLevel) && c.MyCharacter.TrainingPoint >= skill.RequiredTraining && c.MyCharacter.Level >= skill.RequiredLevel && c.MyCharacter.Strength >= skill.RequiredStrength && c.MyCharacter.Stamina >= skill.RequiredStamina && c.MyCharacter.Dexterity >= skill.RequiredDexterity && c.MyCharacter.Energy >= skill.RequiredEnergy) { if (item.RequiredClass == 0 || c.MyCharacter.Class == item.RequiredClass) { if (book.SkillLevel == 1) { characterManager.LearnSkill(c.MyCharacter.CharacterId, skill.SkillID, skill.SkillLevel, ref test); c.MyCharacter.TrainingPoint = test; characterManager.UpdateCharacter(c.MyCharacter); c.MyCharacter.SkillList.Add(skill); byte[] LearnSkill = PacketManager.SendLearnSkill(0, skill.SkillID, skill.SkillLevel, skill.RequiredTraining, c.MyCharacter.TrainingPoint); c.Send(LearnSkill); c.Send(PacketManager.SendSkillSomething()); removeItem = true; } else { if (c.MyCharacter.ContainSkill(skill.SkillID, skill.SkillLevel - 1)) { characterManager.LearnSkill(c.MyCharacter.CharacterId, skill.SkillID, skill.SkillLevel, ref test); c.MyCharacter.UpdateSkill(skill); c.MyCharacter.TrainingPoint = test; characterManager.UpdateCharacter(c.MyCharacter); byte[] LearnSkill = PacketManager.SendLearnSkill(0, skill.SkillID, skill.SkillLevel, skill.RequiredTraining, c.MyCharacter.TrainingPoint); c.Send(LearnSkill); c.Send(PacketManager.SendSkillSomething()); removeItem = true; } else { c.Send(PacketManager.SendSkillError(SkillLearnError.NeedMartialArts)); } } } else { c.Send(PacketManager.SendSkillError(SkillLearnError.WrongClass)); } } else { byte error = 0; if (c.MyCharacter.TrainingPoint <= skill.RequiredTraining) error = 9; if (c.MyCharacter.Level <= skill.RequiredLevel) error = 5; if (c.MyCharacter.Strength <= skill.RequiredStrength) error = 2; if (c.MyCharacter.Dexterity <= skill.RequiredDexterity) error = 1; if (c.MyCharacter.Stamina <= skill.RequiredStamina) error = 3; if (c.MyCharacter.Energy <= skill.RequiredEnergy) error = 4; if (c.MyCharacter.Class != item.RequiredClass && item.RequiredClass != 0) error = 8; if (c.MyCharacter.ContainSkill(skill.SkillID, skill.SkillLevel)) error = 6; c.Send(PacketManager.SendSkillError((SkillLearnError)error)); // send not enought stats/tps } return removeItem; }
public ActiveSkill(DateTime casted, BaseSkill skill, BaseEntity[] targets, Character caster) { this.CastTime = casted; this.Skill = skill; this.Caster = caster; this.Targets = targets; }
void c_ClientAttackInfo(object sender, ClientAttackEventArgs e) { Client c = (Client)sender; Client OtherPlayer = null; AttackInfo i = e.Info; BaseEntity Attacker = null; BaseEntity Target = null; MapEngine mapEngine = GetMapEngine(c.MyCharacter.MapId); Client[] clients = GetClientsForChars(mapEngine.GetCharactersInRange(c.MyCharacter.Position, 150).ToArray()); if (i.AttackerID == c.MyCharacter.CharacterId) Attacker = c.MyCharacter; if (i.TargetID == c.MyCharacter.CharacterId) Target = c.MyCharacter; if (c.MyCharacter.tempPet != null && i.AttackerID == c.MyCharacter.tempPet.PetID) Attacker = c.MyCharacter.tempPet; if (c.MyCharacter.tempPet != null && i.TargetID == c.MyCharacter.tempPet.PetID) Target = c.MyCharacter.tempPet; if (c.MyCharacter.Pet != null && i.AttackerID == c.MyCharacter.Pet.PetID) Attacker = c.MyCharacter.Pet; if (c.MyCharacter.Pet != null && i.TargetID == c.MyCharacter.Pet.PetID) Target = c.MyCharacter.Pet; if (i.AttackerType == 3) Target = mapEngine.GetMonsterByID(i.AttackerID, c.MyCharacter.MapId); if (i.TargetType == 3) Target = mapEngine.GetMonsterByID(i.TargetID, c.MyCharacter.MapId); if (i.TargetType == 1) { OtherPlayer = GetClientByCharacterID(i.TargetID); if (OtherPlayer.MyCharacter.MapId == 10 && c.MyCharacter.MapId == 10) { Target = OtherPlayer.MyCharacter; } } if (i.PacketID == 1) { if (Target is Character) { Character ch = Target as Character; if (ch.Alive) { byte[] SendAttack1 = PacketManager.SendAttack1(i); SendToClients(SendAttack1, clients); } } if (Target is Monster) { Character ch = null; if (Attacker is Character) ch = Attacker as Character; Monster m = Target as Monster; if (m.Alive) { if (ch != null) { float distance = ch.Position.GetDistance(m.Position); if(distance > ch.AttackRange * 2) SendChatToAll(string.Format("{0} Rangehacking, THIS IS JUST A TEST", ch.Name)); } byte[] SendAttack1 = PacketManager.SendAttack1(i); SendToClients(SendAttack1, clients); } } } else { AttackInfo info = null; if (Attacker is Pet && Target is Monster) { Pet pet = Attacker as Pet; Monster[] monsters = null; if (pet.PetType >= 250) { if (pet.PetType == 250) // summon monsters = mapEngine.GetMonstersByRange(pet, 28); else if (pet.PetType == 251 || pet.PetType == 252 || pet.PetType == 253 || pet.PetType == 254) monsters = mapEngine.GetMonstersByRange(pet, 15); foreach (Monster m in monsters) { Target = m; info = m.OnAttack(pet); if (info == null) return; byte[] SendAttack2 = PacketManager.SendAttack2(info, Target); SendToClients(SendAttack2, clients); if (info.Dead) { CharacterGainExperience(c, m, c.MyCharacter, false); MonsterDropItem(m, c.MyCharacter); byte[] SendMonsterDie = PacketManager.SendMonsterDie(m); SendToClients(SendMonsterDie, clients); } } } else // normal pet we want to level up { info = Target.OnAttack(pet); if (info == null) return; byte[] SendAttack2 = PacketManager.SendAttack2(info, Target); SendToClients(SendAttack2, clients); if (info.Dead) { PetGainExperience(c, Target, pet); MonsterDropItem(Target, c.MyCharacter); byte[] SendMonsterDie = PacketManager.SendMonsterDie(Target); SendToClients(SendMonsterDie, clients); } } } else { //info = CreateAttackInfo(Attacker, Target); if (Target is Monster && Attacker is Character) { Character ch = Attacker as Character; Monster m = Target as Monster; info = m.OnAttack(ch); if (info == null) return; byte[] SendAttack2 = PacketManager.SendAttack2(info, Target); SendToClients(SendAttack2, clients); if (info.Dead) { CharacterGainExperience(c, Target, c.MyCharacter, false); MonsterDropItem(Target, c.MyCharacter); byte[] SendMonsterDie = PacketManager.SendMonsterDie(Target); SendToClients(SendMonsterDie, clients); } } if (Target is Character && Attacker is Pet) { Character targ = Target as Character; Pet pet = Attacker as Pet; info = targ.OnAttack(pet); if (info == null) return; byte[] SendAttack2 = PacketManager.SendAttack2(info, Target); SendToClients(SendAttack2, clients); byte[] SendHpMana = PacketManager.SendHealMana(targ.MaxHp, targ.CurrentHp, targ.MaxMana, targ.CurrentMana, 0); OtherPlayer.Send(SendHpMana); if (info.PetDamaged) { if (targ.tempPet != null) { byte[] SendPetHealth = PacketManager.SendPetHealth(targ.tempPet); OtherPlayer.Send(SendPetHealth); if (info.PetDied) { BaseSkill skill = new BaseSkill(); if (targ.RemoveActiveSkill((int)HardSkills.Shadow_Strike)) { skill.SkillID = (int)HardSkills.Shadow_Strike; skill.SkillLevel = 1; OtherPlayer.Send(PacketManager.SendEndSkill(targ, skill)); } if (targ.RemoveActiveSkill((int)AbsorbSkills.Shadow_Focus)) { skill.SkillID = (int)AbsorbSkills.Shadow_Focus; skill.SkillLevel = 1; OtherPlayer.Send(PacketManager.SendEndSkill(targ, skill)); } if (targ.RemoveActiveSkill((int)RebirthSkills.Duplicate_Attack)) { skill.SkillID = (int)RebirthSkills.Duplicate_Attack; skill.SkillLevel = 1; OtherPlayer.Send(PacketManager.SendEndSkill(targ, skill)); } byte[] RemovePet = PacketManager.SendMonsterDie(targ.tempPet); SendToClients(RemovePet, clients); targ.tempPet = null; } } } if (info.Dead) { byte[] SendPlayerDie = PacketManager.SendPlayerDie(targ); SendToClients(SendPlayerDie, clients); } } if (Target is Character && Attacker is Character) { Character targ = Target as Character; Character ch = Attacker as Character; info = targ.OnAttack(ch); if (info == null) return; byte[] SendAttack2 = PacketManager.SendAttack2(info, Target); SendToClients(SendAttack2, clients); byte[] SendHpMana = PacketManager.SendHealMana(targ.MaxHp, targ.CurrentHp, targ.MaxMana, targ.CurrentMana, 0); OtherPlayer.Send(SendHpMana); if (info.PetDamaged) { if (targ.tempPet != null) { byte[] SendPetHealth = PacketManager.SendPetHealth(targ.tempPet); OtherPlayer.Send(SendPetHealth); if (info.PetDied) { BaseSkill skill = new BaseSkill(); if (targ.RemoveActiveSkill((int)HardSkills.Shadow_Strike)) { skill.SkillID = (int)HardSkills.Shadow_Strike; skill.SkillLevel = 1; OtherPlayer.Send(PacketManager.SendEndSkill(targ, skill)); } if (targ.RemoveActiveSkill((int)AbsorbSkills.Shadow_Focus)) { skill.SkillID = (int)AbsorbSkills.Shadow_Focus; skill.SkillLevel = 1; OtherPlayer.Send(PacketManager.SendEndSkill(targ, skill)); } if (targ.RemoveActiveSkill((int)RebirthSkills.Duplicate_Attack)) { skill.SkillID = (int)RebirthSkills.Duplicate_Attack; skill.SkillLevel = 1; OtherPlayer.Send(PacketManager.SendEndSkill(targ, skill)); } byte[] RemovePet = PacketManager.SendMonsterDie(targ.tempPet); SendToClients(RemovePet, clients); targ.tempPet = null; } } } if (info.Dead) { byte[] SendPlayerDie = PacketManager.SendPlayerDie(targ); SendToClients(SendPlayerDie, clients); } } } } }
public PUTM(DateTime casted, BaseSkill skill, Pet target, Character caster) : base(casted, skill, target, caster) { }
public StrengthenMonster(DateTime casted, BaseSkill skill, Pet target, Character caster) : base(casted, skill, target, caster) { }
public override CastSkillInfo OnCast(Character ch, BaseSkill skill) { if (Alive && ch.Alive) { CastSkillInfo info = new CastSkillInfo(); info.Dead = false; info.Type = AttackType.Miss; info.Damage = 0; info.CasterType = (byte)ch.Type; info.CasterID = ch.CharacterId; info.CasterX = (short)ch.Position.X; info.CasterY = (short)ch.Position.Y; info.CasterZ = 0; info.TargetID = MonsterID; info.TargetType = (byte)Type; info.TargetX = (short)Position.X; info.TargetY = (short)Position.Y; info.TargetZ = 0; if (ch.TotalAttackRating > AttackRating) { info.Type = AttackType.Hit; } else { int chance = Random().Next(1, AttackRating); if (chance <= ch.TotalAttackRating) info.Type = AttackType.Hit; else info.Type = AttackType.Miss; } if (info.Type == AttackType.Hit) { info.Damage = ch.TotalDamage - Defense / 3; if (info.Damage <= 0) info.Damage = 1; if (skill.IncDamage != 0) { info.Damage += skill.IncDamage; } if (skill.IncDamagePerc != 0) { float DamageInc = skill.IncDamagePerc; float increase = (DamageInc / 100); info.Damage = (int)(info.Damage * increase); } if (info.Damage <= CurHealth) { CurHealth -= info.Damage; } else if (info.Damage >= CurHealth) { Alive = false; CurHealth = 0; DeathTime = DateTime.Now; info.Dead = true; info.Experience = Experience; } } return info; } else return base.OnCast(ch, skill); }
public static byte[] SendCast2(BaseSkill skill, CastSkillInfo i, Monster m) { Packet p = new Packet(500); p.WriteByte((byte)i.Type); p.WriteInt(skill.SkillID); p.WriteByte(skill.SkillLevel); p.WriteByte(i.CasterType); p.WriteInt(i.CasterID); p.WriteShort(i.CasterX); p.WriteShort(i.CasterY); p.WriteByte(i.CasterZ); if (m != null) { p.WriteByte(3); p.WriteInt(m.MonsterID); p.WriteInt(m.MaxHealth); p.WriteInt(m.CurHealth); p.WriteInt(i.Damage); p.WriteInt(i.Experience); p.WriteHexString("00"); } else { p.WriteByte(i.TargetType); p.WriteInt(i.TargetID); p.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"); } return p.GetWrittenBuffer(PacketIds.SendCast2); }
public HazeSkill(DateTime hit, BaseSkill skill, BaseEntity[] targets, Character caster, BaseEntity hitTarget) : base(hit, skill, targets, caster) { this.hitTarget = hitTarget; }
public virtual CastSkillInfo OnCast(Character ch, BaseSkill skill) { return null; }
public void UpdateSkill(BaseSkill skill) { BaseSkill igetsdeleted = null; foreach (BaseSkill s in SkillList) { if (s.SkillID == skill.SkillID) igetsdeleted = s; } if (igetsdeleted != null) { SkillList.Remove(igetsdeleted); SkillList.Add(skill); } }
public bool NotCastedYet(BaseSkill skill) { foreach (ActiveSkill s in ActiveSkills) { if (s.Skill.SkillID == skill.SkillID) return false; } return true; }
public static byte[] SendSkillEffect(BaseEntity ent, BaseSkill skill) { Packet p = new Packet(20); p.WriteHexString("2C 35 0B 00 00"); if (ent is Character) { Character ch = ent as Character; p.WriteInt(ch.CharacterId); p.WriteByte((byte)ch.Type); } if (ent is Monster) { Monster m = ent as Monster; p.WriteInt(m.MonsterID); p.WriteByte((byte)m.Type); } if (ent is Pet) { Pet pet = ent as Pet; p.WriteInt(pet.PetID); p.WriteByte((byte)pet.Type); } p.WriteInt(skill.SkillID); p.WriteByte(skill.SkillLevel); return p.GetWrittenBuffer(); }
void mapEngine_MonsterAttack(object sender, MonsterAttackInfoEventArgs e) { MonsterAI monsterAI = sender as MonsterAI; MapEngine mapEngine = GetMapEngine(monsterAI.Monster.MapID); Client[] clients = GetClientsForChars(mapEngine.GetCharactersInRange(monsterAI.Monster.Position, 150).ToArray()); BaseEntity Target = e.Info.Target; Character ch = null; Pet pet = null; Client c = null; if (Target == null) { monsterAI.Monster.Attacking = false; monsterAI.Monster.Target = null; return; } if (Target is Character) { ch = Target as Character; c = GetClientByCharacterID(ch.CharacterId); } if (Target is Pet) { pet = Target as Pet; c = GetClientByCharacterID(pet.OwnerID); } if (ch != null && ch.Alive && monsterAI.Monster.Alive) { AttackInfo atk = ch.OnAttack(monsterAI.Monster); if (atk != null) { byte[] SendTargetHealMana = PacketManager.SendHealMana(ch.MaxHp, ch.CurrentHp, ch.MaxMana, ch.CurrentMana, 0); c.Send(SendTargetHealMana); byte[] SendAttack1 = PacketManager.SendAttack1(atk); SendToClients(SendAttack1, clients); byte[] SendAttack2 = PacketManager.SendAttack2(atk, c.MyCharacter); SendToClients(SendAttack2, clients); if (atk.DoRefDamage && !atk.Dead) { BaseSkill skill = c.MyCharacter.FindSkill((int)HardSkills.Reflection); CastSkillInfo RefInfo = monsterAI.Monster.OnCast(c.MyCharacter, skill); RefInfo.CasterType = 1; byte[] SendRefdamage = PacketManager.SendCast2(skill, RefInfo, monsterAI.Monster); SendToClients(SendRefdamage, clients); if (RefInfo.Dead) { CharacterGainExperience(c, monsterAI.Monster, c.MyCharacter, false); MonsterDropItem(monsterAI.Monster, c.MyCharacter); byte[] SendMonsterDie = PacketManager.SendMonsterDie(monsterAI.Monster); SendToClients(SendMonsterDie, clients); } } if (atk.PetDamaged) { if (c.MyCharacter.tempPet != null) { byte[] SendPetHealth = PacketManager.SendPetHealth(c.MyCharacter.tempPet); c.Send(SendPetHealth); if (atk.PetDied) { BaseSkill skill = new BaseSkill(); if (c.MyCharacter.RemoveActiveSkill((int)HardSkills.Shadow_Strike)) { skill.SkillID = (int)HardSkills.Shadow_Strike; skill.SkillLevel = 1; c.Send(PacketManager.SendEndSkill(c.MyCharacter, skill)); } if (c.MyCharacter.RemoveActiveSkill((int)AbsorbSkills.Shadow_Focus)) { skill.SkillID = (int)AbsorbSkills.Shadow_Focus; skill.SkillLevel = 1; c.Send(PacketManager.SendEndSkill(c.MyCharacter, skill)); } if (c.MyCharacter.RemoveActiveSkill((int)RebirthSkills.Duplicate_Attack)) { skill.SkillID = (int)RebirthSkills.Duplicate_Attack; skill.SkillLevel = 1; c.Send(PacketManager.SendEndSkill(c.MyCharacter, skill)); } byte[] RemovePet = PacketManager.SendMonsterDie(c.MyCharacter.tempPet); SendToClients(RemovePet, clients); c.MyCharacter.tempPet = null; } } } if (atk.Dead) { mapEngine.ActiveClientEntities.Remove(c.MyCharacter); byte[] SendPlayerDead = PacketManager.SendPlayerDie(c.MyCharacter); SendToClients(SendPlayerDead, clients); } monsterAI.Monster.LastAttack = DateTime.Now; } } else if (pet != null && pet.Alive && monsterAI.Monster.Alive) { AttackInfo atk = pet.OnAttack(monsterAI.Monster); if (atk != null) { byte[] SendPetHealth = PacketManager.SendPetHealth(pet); c.Send(SendPetHealth); byte[] SendAttack1 = PacketManager.SendAttack1(atk); SendToClients(SendAttack1, clients); byte[] SendAttack2 = PacketManager.SendAttack2(atk, Target); SendToClients(SendAttack2, clients); if (atk.Dead) { byte[] SendPetDie = PacketManager.SendMonsterDie(pet); SendToClients(SendPetDie, clients); pet.Alive = false; petManager.UpdatePet(pet); c.MyCharacter.Pet = null; mapEngine.ActiveClientEntities.Remove(pet); } monsterAI.Monster.LastAttack = DateTime.Now; } } }
public PetSkill(DateTime casted, BaseSkill skill, Pet target, Character caster) { this.CastTime = casted; this.Skill = skill; this.Caster = caster; this.Target = target; }
public List<BaseSkill> GetAllSkillsByCharacterID(int characterId) { List<BaseSkill> returnskills = new List<BaseSkill>(); List<BaseSkill> skills = new List<BaseSkill>(); DbParameter characterIdParameter = _db.CreateParameter(DbNames.GETSKILLBYCHARACTERID_CHARACTERID_PARAMETER, characterId); characterIdParameter.DbType = DbType.Int32; _db.Open(); DbDataReader reader = _db.ExcecuteReader(DbNames.GETSKILLBYCHARACTERID_STOREDPROC, CommandType.StoredProcedure, characterIdParameter); int ordinalSkill_skillid = reader.GetOrdinal(DbNames.SKILL_SKILLID); int ordinalSkill_skilllevel = reader.GetOrdinal(DbNames.SKILL_SKILLLEVEL); while (reader.Read()) { BaseSkill skill = new BaseSkill { SkillID = reader.GetInt16(ordinalSkill_skillid), SkillLevel = reader.GetByte(ordinalSkill_skilllevel) }; skills.Add(skill); } reader.Close(); _db.Close(); foreach (BaseSkill s in skills) { returnskills.Add(GetSkillByLevelAndID(s.SkillID, s.SkillLevel)); } return returnskills; }
public static byte[] SendCast1(BaseSkill skill, CastSkillInfo i, byte error) { Packet p = new Packet(500); p.WriteByte(error); p.WriteInt(skill.SkillID); p.WriteByte(skill.SkillLevel); p.WriteHexString("01"); p.WriteInt(i.CasterID); p.WriteShort(i.CasterX); p.WriteShort(i.CasterY); p.WriteByte(i.CasterZ); p.WriteByte(i.TargetType); p.WriteInt(i.TargetID); p.WriteShort(i.TargetX); p.WriteShort(i.TargetY); p.WriteShort(i.TargetZ); p.WriteHexString("00 00 00"); return p.GetWrittenBuffer(PacketIds.SendCast1); }