public static byte[] SendPetExperienceGained(Pet pet, int exp) { Packet p = new Packet(50); p.WriteInt(pet.PetID); p.WriteInt(exp); return p.GetWrittenBuffer(PacketIds.SendPetExperienceGained); }
public StrengthenMonster(DateTime casted, BaseSkill skill, Pet target, Character caster) : base(casted, skill, target, caster) { }
private void PetGainExperience(Client c, BaseEntity entity, Pet pet) { if (pet.Level < 200) { Monster m = null; if (entity is Monster) m = entity as Monster; long petexp = Math.Abs(pet.CurrentExperience - pet.NegativeExperience); bool leveled = false; bool evolved = false; int experience = m.Experience - pet.Level; if (experience < 0) experience = 1; if (pet.IsUsingEmpathy) { float bonus = (float)(experience * pet.BonusExperience); experience += (int)bonus; } experience *= ExperienceMultiper; if (petexp + experience > pet.ExperienceToLevel) { int stat = XiahRandom.Next(0, 4); pet.Level++; int additional = 1; if (pet.Evolution < 3) { if (pet.Level >= pet.EvolutionTable[pet.Evolution].Level) { evolved = true; pet.PetType = pet.EvolutionTable[pet.Evolution].Type; pet.Evolution++; additional += 2 * pet.Evolution; } } switch (stat) { case 0: pet.MaxHealth += (pet.Level * 4) + additional; break; case 1: pet.Damage += (pet.Level * 3) + additional; break; case 2: pet.Defense += (pet.Level * 3) + additional; break; case 3: pet.AttackRating += (pet.Level * 3) + additional; break; } pet.ExperienceToLevel = petManager.GetExperienceToLevelByLevel(pet.Level); pet.NegativeExperience = petManager.GetNegativeExpByLevel(pet.Level); leveled = true; pet.CurHealth = pet.MaxHealth; } pet.CurrentExperience += experience; petManager.UpdatePet(pet); byte[] SendPetGainedExperience = PacketManager.SendPetExperienceGained(pet, experience); c.Send(SendPetGainedExperience); if (leveled) { byte[] SendPetLeveled = PacketManager.SendPetLeveled(pet); c.Send(SendPetLeveled); } if (evolved) { byte[] SendPetEvolution = PacketManager.SendPetEvolution(pet); c.Send(SendPetEvolution); } } }
public virtual CastSkillInfo OnCast(Pet pet) { return null; }
public PetSkill(DateTime casted, BaseSkill skill, Pet target, Character caster) { this.CastTime = casted; this.Skill = skill; this.Caster = caster; this.Target = target; }
public Pet TamePet(Monster m, Character ch) { Pet pet = new Pet { OwnerID = ch.CharacterId, MapID = ch.MapId, Position = m.Position.NormalizedCopy(), PetType = m.MonsterType, Name = m.Name, Level = m.Level, CurHealth = m.MaxHealth, MaxHealth = m.MaxHealth, Damage = m.Damage, Defense = m.Defense, AttackRating = m.AttackRating, }; pet.PetID = InsertPet(pet, true); pet.ExperienceToLevel = GetExperienceToLevelByLevel(pet.Level); pet.NegativeExperience = GetNegativeExpByLevel(pet.Level); pet.CurrentExperience = pet.NegativeExperience; pet.EvolutionTable = GetPetEvolutionByType(pet.PetType); pet.Alive = true; UpdatePet(pet); return pet; }
public override AttackInfo OnAttack(Pet pet) { if (Alive) { AttackInfo info = new AttackInfo(); info.Damage = 0; info.Critical = false; info.Type = AttackType.Miss; info.TargetID = CharacterId; info.TargetType = (byte)Type; info.TargetX = (short)Position.X; info.TargetY = (short)Position.Y; info.TargetZ = 0; info.AttackerID = pet.PetID; info.AttackerType = (byte)pet.Type; if (pet.TotalAttackRating > TotalAttackRating) { info.Type = AttackType.Hit; if (PercentSuccess(10)) info.Critical = true; } else { int chance = Random().Next(1, TotalAttackRating); if (chance <= pet.TotalAttackRating) info.Type = AttackType.Hit; else info.Type = AttackType.Miss; } if (info.Type == AttackType.Hit) { info.Damage = pet.TotalDamage - TotalDefence / 3; if (info.Damage <= 0) info.Damage = 1; if (info.Critical) info.Damage *= 6; if (UsingReflection()) { float damageInc = ReflectPerc; float increase = (damageInc / 100); int amount = (int)(info.Damage * increase); info.Damage -= amount; if (info.Damage <= 0) info.Damage = 1; info.DoRefDamage = true; } if (UsingShadow()) { if (info.Damage <= tempPet.CurHealth) { tempPet.CurHealth -= info.Damage; info.PetDamaged = true; } else if (info.Damage >= tempPet.CurHealth) { info.PetDamaged = true; info.PetDied = true; } } else { if (info.Damage <= CurrentHp) { CurrentHp -= info.Damage; } else if (info.Damage >= CurrentHp) { Alive = false; CurrentHp = 0; DeathTime = DateTime.Now; info.Dead = true; } } } return info; } else return base.OnAttack(pet); }
public static byte[] SendPetRenamed(Pet pet) { Packet p = new Packet(200); p.WriteHexString("00"); p.WriteInt(pet.PetID); p.WriteString(pet.Name); return p.GetWrittenBuffer(PacketIds.SendPetRenamed); }
public static byte[] SendPetStats(Pet pet) { Packet p = new Packet(200); p.WriteHexString("00"); p.WriteInt(pet.PetID); p.WriteInt(pet.OwnerID); p.WriteInt(pet.MapID); p.WriteByte(pet.PetType); p.WriteString(pet.Name); p.WriteShort(pet.Level); p.WriteShort(pet.Position.X); p.WriteShort(pet.Position.Y); p.WriteHexString("00"); p.WriteShort(pet.Position.X); p.WriteShort(pet.Position.Y); p.WriteHexString("00 8B 00"); p.WriteInt(pet.TotalHealth); p.WriteInt(pet.CurHealth); p.WriteShort(pet.TotalDamage); p.WriteShort(pet.TotalDefense); p.WriteShort(pet.TotalAttackRating); p.WriteHexString("00 00 04 04 00 00 00 00 83 4E 00 00 01"); p.WriteLong(pet.CurrentExperience); p.WriteLong(pet.NegativeExperience); p.WriteLong(pet.ExperienceToLevel + pet.NegativeExperience); p.WriteByte(pet.Evolution); p.WriteByte(pet.Wildness); p.WriteByte(Convert.ToByte(pet.IsLegendary)); p.WriteHexString("00 00 00 00 00 00 00 00 00 00"); return p.GetWrittenBuffer(PacketIds.SendPetStats); }
public static byte[] SendPetOtherPlayerSpawn(Pet pet) { Packet p = new Packet(200); p.WriteHexString("00"); p.WriteInt(pet.MapID); p.WriteByte(pet.Evolution); p.WriteByte(pet.PetType); p.WriteInt(pet.PetID); p.WriteHexString("00"); p.WriteInt(pet.MapID); p.WriteShort(pet.Position.X); p.WriteShort(pet.Position.Y); p.WriteHexString("4E 58 01"); p.WriteString(pet.Name); p.WriteHexString("14 51 01 B4 00 4E 24 00 00 00 24 00 00 00 09"); p.WriteInt(pet.OwnerID); p.WriteHexString("02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"); return p.GetWrittenBuffer(PacketIds.SendPetOtherPlayerSpawn); }
public static byte[] SendPetOtherPlayerSpawn2(Pet pet) { Packet p = new Packet(200); p.WriteHexString("00"); p.WriteInt(pet.PetID); p.WriteByte(pet.PetType); p.WriteInt(pet.MapID); p.WriteShort(pet.Position.X); p.WriteShort(pet.Position.Y); p.WriteHexString("00 00 00"); p.WriteString(pet.Name); p.WriteHexString("00"); p.WriteShort(pet.Position.X); p.WriteShort(pet.Position.Y); p.WriteHexString("00"); p.WriteInt(pet.MaxHealth); p.WriteInt(pet.CurHealth); p.WriteHexString("00"); p.WriteInt(pet.OwnerID); p.WriteHexString("00"); p.WriteByte(Convert.ToByte(pet.IsLegendary)); p.WriteHexString("00"); // mytholy pill :S p.WriteHexString("00 00"); // pet skill1 p.WriteHexString("00 00"); // pet skill1 amount p.WriteHexString("00 00"); // pet skill2 p.WriteHexString("00 00"); // pet skill2 amount p.WriteHexString("00"); // pet closeness p.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 00"); return p.GetWrittenBuffer(PacketIds.SendPetOtherPlayerSpawn2); }
public static byte[] SendPetOtherPlayerHasPet(Pet pet) { Packet p = new Packet(200); p.WriteHexString("00"); p.WriteInt(pet.MapID); p.WriteInt(pet.PetID); p.WriteByte((byte)pet.Type); p.WriteShort(pet.Position.X); p.WriteShort(pet.Position.Y); p.WriteHexString("4E 1D 01 00 02"); return p.GetWrittenBuffer(PacketIds.SendPetOtherPlayerHasPet); }
public static byte[] SendPetLeveled(Pet pet) { Packet p = new Packet(200); p.WriteInt(pet.OwnerID); p.WriteInt(pet.PetID); p.WriteByte(pet.Level); p.WriteShort(pet.TotalDamage); p.WriteShort(pet.TotalDefense); p.WriteShort(pet.TotalAttackRating); p.WriteHexString("00 00"); p.WriteInt(pet.MaxHealth); p.WriteInt(pet.CurHealth); p.WriteLong(pet.CurrentExperience); p.WriteLong(pet.NegativeExperience); p.WriteLong(pet.ExperienceToLevel + pet.NegativeExperience); return p.GetWrittenBuffer(PacketIds.SendPetLeveled); }
public static byte[] SendPetHealth(Pet pet) { Packet p = new Packet(20); p.WriteInt(pet.PetID); p.WriteInt(pet.CurHealth); p.WriteInt(pet.MaxHealth); p.WriteByte(0); return p.GetWrittenBuffer(PacketIds.SendPetHealth); }
public Pet GetAlivePetByCharacterID(int characterID) { DbParameter characterIdParameter = _db.CreateParameter(DbNames.GETALIVEPETBYCHARACTERID_CHARACTERID_PARAMETER, characterID); characterIdParameter.DbType = DbType.Int32; _db.Open(); DbDataReader reader = _db.ExcecuteReader(DbNames.GETALIVEPETBYCHARACTERID_STOREDPROC, CommandType.StoredProcedure, characterIdParameter); int ordinalPET_ID = reader.GetOrdinal(DbNames.PET_ID); int ordinalPET_OWNERID = reader.GetOrdinal(DbNames.PET_OWNERID); int ordinalPET_MAPID = reader.GetOrdinal(DbNames.PET_MAPID); int ordinalPET_TYPE = reader.GetOrdinal(DbNames.PET_TYPE); int ordinalPET_BASETYPE = reader.GetOrdinal(DbNames.PET_BASETYPE); int ordinalPET_LEVEL = reader.GetOrdinal(DbNames.PET_LEVEL); int ordinalPET_NAME = reader.GetOrdinal(DbNames.PET_NAME); int ordinalPET_CURHEALTH = reader.GetOrdinal(DbNames.PET_CURHEALTH); int ordinalPET_MAXHEALTH = reader.GetOrdinal(DbNames.PET_MAXHEALTH); int ordinalPET_DAMAGE = reader.GetOrdinal(DbNames.PET_DAMAGE); int ordinalPET_DEFENSE = reader.GetOrdinal(DbNames.PET_DEFENSE); int ordinalPET_ATTACKRATING = reader.GetOrdinal(DbNames.PET_ATTACKRATING); int ordinalPET_EXPERIENCE = reader.GetOrdinal(DbNames.PET_CURRENTEXPERIENCE); int ordinalPET_WILDNESS = reader.GetOrdinal(DbNames.PET_WILDNESS); int ordinalPET_EVOLUTION = reader.GetOrdinal(DbNames.PET_EVOLUTION); int ordinalPET_ISLEGENDARY = reader.GetOrdinal(DbNames.PET_ISLEGENDARY); int ordinalPET_ISALIVE = reader.GetOrdinal(DbNames.PET_ISALIVE); int ordinalPET_ISSEALED = reader.GetOrdinal(DbNames.PET_ISSEALED); Pet p = null; while (reader.Read()) { p = new Pet(); p.PetID = reader.GetInt32(ordinalPET_ID); p.OwnerID = reader.GetInt32(ordinalPET_OWNERID); p.MapID = reader.GetInt32(ordinalPET_MAPID); p.PetType = reader.GetByte(ordinalPET_TYPE); p.PetBaseType = reader.GetByte(ordinalPET_BASETYPE); p.Level = reader.GetInt16(ordinalPET_LEVEL); p.Name = reader.GetString(ordinalPET_NAME); p.CurHealth = reader.GetInt32(ordinalPET_CURHEALTH); p.MaxHealth = reader.GetInt32(ordinalPET_MAXHEALTH); p.Damage = reader.GetInt32(ordinalPET_DAMAGE); p.Defense = reader.GetInt32(ordinalPET_DEFENSE); p.AttackRating = reader.GetInt32(ordinalPET_ATTACKRATING); p.CurrentExperience = reader.GetInt64(ordinalPET_EXPERIENCE); p.Wildness = reader.GetByte(ordinalPET_WILDNESS); p.Evolution = reader.GetByte(ordinalPET_EVOLUTION); p.IsLegendary = reader.GetBoolean(ordinalPET_ISLEGENDARY); p.Alive = reader.GetBoolean(ordinalPET_ISALIVE); p.IsSealed = reader.GetBoolean(ordinalPET_ISSEALED); } reader.Close(); _db.Close(); if (p != null) { p.ExperienceToLevel = GetExperienceToLevelByLevel(p.Level); p.NegativeExperience = GetNegativeExpByLevel(p.Level); p.EvolutionTable = GetPetEvolutionByType(p.PetBaseType); } return p; }
public static byte[] SendPetTamedMessage(Pet pet, PetTamedError error) { Packet p = new Packet(200); p.WriteByte((byte)error); if (error == PetTamedError.None) { p.WriteInt(pet.PetID); p.WriteByte((byte)pet.Type); } else { p.WriteInt(0); p.WriteByte(0); } return p.GetWrittenBuffer(PacketIds.SendPetTamed); }
public int InsertPet(Pet pet, bool IsAlive) { DbParameter ownerIdParameter = _db.CreateParameter(DbNames.INSERTPET_OWNERID_PARAMETER, pet.OwnerID); DbParameter mapIdParameter = _db.CreateParameter(DbNames.INSERTPET_MAPID_PARAMETER, pet.MapID); DbParameter typeParameter = _db.CreateParameter(DbNames.INSERTPET_TYPE_PARAMETER, pet.PetType); DbParameter levelParameter = _db.CreateParameter(DbNames.INSERTPET_LEVEL_PARAMETER, pet.Level); DbParameter curHealthParameter = _db.CreateParameter(DbNames.INSERTPET_CURHEALTH_PARAMETER, pet.CurHealth); DbParameter maxHealthParameter = _db.CreateParameter(DbNames.INSERTPET_MAXHEALTH_PARAMETER, pet.MaxHealth); DbParameter damageParameter = _db.CreateParameter(DbNames.INSERTPET_DAMAGE_PARAMETER, pet.Damage); DbParameter defenseParameter = _db.CreateParameter(DbNames.INSERTPET_DEFENSE_PARAMETER, pet.Defense); DbParameter attackratingParameter = _db.CreateParameter(DbNames.INSERTPET_ATTACKRATING_PARAMETER, pet.AttackRating); DbParameter petIdParameter = _db.CreateParameter(DbNames.INSERTPET_PETID_OUTPUT, System.Data.DbType.Int32); DbParameter isaliveParameter = _db.CreateParameter(DbNames.INSERTPET_ISALIVE_PARAMETER, IsAlive); DbParameter nameParameter = _db.CreateParameter(DbNames.INSERTPET_NAME_PARAMETER, pet.Name); mapIdParameter.DbType = System.Data.DbType.Int32; ownerIdParameter.DbType = System.Data.DbType.Int32; typeParameter.DbType = System.Data.DbType.Byte; levelParameter.DbType = System.Data.DbType.Int16; curHealthParameter.DbType = System.Data.DbType.Int32; maxHealthParameter.DbType = System.Data.DbType.Int32; damageParameter.DbType = System.Data.DbType.Int32; defenseParameter.DbType = System.Data.DbType.Int32; attackratingParameter.DbType = System.Data.DbType.Int32; isaliveParameter.DbType = System.Data.DbType.Boolean; nameParameter.DbType = DbType.String; petIdParameter.Direction = System.Data.ParameterDirection.Output; pet.Alive = IsAlive; _db.Open(); _db.ExecuteNonQuery(DbNames.INSERTPET_STOREDPROC, System.Data.CommandType.StoredProcedure, ownerIdParameter, mapIdParameter, typeParameter, levelParameter,nameParameter, curHealthParameter, maxHealthParameter, damageParameter, defenseParameter, attackratingParameter, isaliveParameter, petIdParameter); _db.Close(); int mapItemId = (int)petIdParameter.Value; return mapItemId; }
public static byte[] SendRemovePet(Pet pet) { Packet p = new Packet(200); p.WriteByte(0); p.WriteInt(pet.PetID); p.WriteByte((byte)pet.Type); p.WriteInt(pet.MapID); return p.GetWrittenBuffer(PacketIds.SendRemovePet); }
public void UpdatePet(Pet pet) { DbParameter petIDParameter = _db.CreateParameter(DbNames.UPDATEPET_PETID_PARAMETER, pet.PetID); petIDParameter.DbType = DbType.Int32; DbParameter petOwnerIDParameter = _db.CreateParameter(DbNames.UPDATEPET_OWNERID_PARAMETER, pet.OwnerID); petOwnerIDParameter.DbType = DbType.Int32; DbParameter petMapIDParameter = _db.CreateParameter(DbNames.UPDATEPET_MAPID_PARAMETER, pet.MapID); petMapIDParameter.DbType = DbType.Int32; DbParameter petTypeParameter = _db.CreateParameter(DbNames.UPDATEPET_TYPE_PARAMETER, pet.PetType); petTypeParameter.DbType = DbType.Byte; DbParameter petLevelParamater = _db.CreateParameter(DbNames.UPDATEPET_LEVEL_PARAMETER, pet.Level); petLevelParamater.DbType = DbType.Int16; DbParameter petNameParameter = _db.CreateParameter(DbNames.UPDATEPET_NAME_PARAMETER, pet.Name); petNameParameter.DbType = DbType.String; DbParameter petCurHealthParameter = _db.CreateParameter(DbNames.UPDATEPET_CURHEALTH_PARAMETER, pet.CurHealth); petCurHealthParameter.DbType = DbType.Int32; DbParameter petMaxHealthParameter = _db.CreateParameter(DbNames.UPDATEPET_MAXHEALTH_PARAMATER, pet.MaxHealth); petMaxHealthParameter.DbType = DbType.Int32; DbParameter petDamageParameter = _db.CreateParameter(DbNames.UPDATEPET_DAMAGE_PARAMETER, pet.Damage); petDamageParameter.DbType = DbType.Int32; DbParameter petDefenseParameter = _db.CreateParameter(DbNames.UPDATEPET_DEFENSE_PARAMETER, pet.Defense); petDefenseParameter.DbType = DbType.Int32; DbParameter petAttackRatingParameter = _db.CreateParameter(DbNames.UPDATEPET_ATTACKRATING_PARAMETER, pet.AttackRating); petAttackRatingParameter.DbType = DbType.Int32; DbParameter petCurExpParameter = _db.CreateParameter(DbNames.UPDATEPET_CURRENTEXP_PARAMETER, pet.CurrentExperience); petCurExpParameter.DbType = DbType.Int64; DbParameter petWildnessParameter = _db.CreateParameter(DbNames.UPDATEPET_WILDNESS_PARAMATER, pet.Wildness); petWildnessParameter.DbType = DbType.Byte; DbParameter petEvolutionParameter = _db.CreateParameter(DbNames.UPDATEPET_EVOLUTION_PARAMETER, pet.Evolution); petEvolutionParameter.DbType = DbType.Byte; DbParameter petIsLegendaryParameter = _db.CreateParameter(DbNames.UPDATEPET_ISLEGENDARY_PARAMETER, pet.IsLegendary); petIsLegendaryParameter.DbType = DbType.Boolean; DbParameter petIsAliveParameter = _db.CreateParameter(DbNames.UPDATEPET_ISALIVE_PARAMETER, pet.Alive); // once monsters attack pets this can be done petIsAliveParameter.DbType = DbType.Boolean; // or release could work aswell DbParameter petIsSealedParameter = _db.CreateParameter(DbNames.UPDATEPET_ISSEALED_PARAMETER, pet.IsSealed); // once mirrors is done this will be used petIsSealedParameter.DbType = DbType.Boolean; DbParameter deathTimeParameter = _db.CreateParameter(DbNames.UPDATEPET_DEATHTIME_PARAMETER, DateTime.Now); deathTimeParameter.DbType = DbType.DateTime; _db.Open(); _db.ExecuteNonQuery(DbNames.UPDATEPET_STOREDPROC, System.Data.CommandType.StoredProcedure, petIDParameter, petOwnerIDParameter, petMapIDParameter, petTypeParameter, petLevelParamater, petNameParameter, petCurHealthParameter, petMaxHealthParameter, petDamageParameter, petDefenseParameter, petAttackRatingParameter, petCurExpParameter, petWildnessParameter, petEvolutionParameter, petIsLegendaryParameter, petIsAliveParameter, petIsSealedParameter, deathTimeParameter); _db.Close(); }
public static byte[] SendSealPet(Pet pet) { Packet p = new Packet(20); p.WriteHexString("00"); p.WriteInt(pet.PetID); return p.GetWrittenBuffer(PacketIds.SendSealPet); }
public virtual AttackInfo OnAttack(Pet pet) { return null; }
public static byte[] SendSummonSpawn(Pet pet) { Packet p = new Packet(200); p.WriteHexString("00"); p.WriteInt(pet.PetID); p.WriteInt(pet.OwnerID); p.WriteInt(pet.MapID); // pet.PetType = 2; p.WriteByte(pet.PetType); // type, 250 = summon, 251 = sm shadow, 252 = mage shadow, 253 = warrior shadow, 254 = gf shadow p.WriteHexString("06 00 2C D2 B0 C6 00 00"); p.WriteShort(pet.Level); p.WriteShort(pet.Position.X); p.WriteShort(pet.Position.Y); p.WriteHexString("00"); p.WriteShort(pet.Position.X); p.WriteShort(pet.Position.Y); p.WriteHexString("00"); p.WriteHexString("BB 00"); p.WriteInt(pet.CurHealth); p.WriteInt(pet.MaxHealth); p.WriteShort(pet.Damage); p.WriteShort(pet.Defense); p.WriteShort(pet.AttackRating); p.WriteShort(pet.AttackRating); p.WriteHexString("00 14 00 14 00 14 00 00 00 00 02 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"); return p.GetWrittenBuffer(PacketIds.SendSummonPet); }
public override AttackInfo OnAttack(Pet pet) { if (Alive) { AttackInfo info = new AttackInfo(); info.Damage = 0; info.Critical = false; info.Type = AttackType.Miss; info.TargetID = MonsterID; info.TargetType = (byte)Type; info.TargetX = (short)Position.X; info.TargetY = (short)Position.Y; info.TargetZ = 0; info.AttackerID = pet.PetID; info.AttackerType = (byte)pet.Type; if (pet.TotalAttackRating > AttackRating) { info.Type = AttackType.Hit; if (PercentSuccess(10)) info.Critical = true; } else { int chance = Random().Next(1, AttackRating); if (chance <= pet.TotalAttackRating) info.Type = AttackType.Hit; else info.Type = AttackType.Miss; } if (info.Type == AttackType.Hit) { info.Damage = pet.TotalDamage - Defense / 3; if (info.Damage <= 0) info.Damage = 1; if (info.Critical) info.Damage *= 6; 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.OnAttack(pet); }
public static byte[] SendTradePetOffer(Pet pet, int MoneyWanted, int targetid) { Packet p = new Packet(200); p.WriteHexString("00"); p.WriteInt(pet.OwnerID); p.WriteInt(targetid); p.WriteInt(pet.PetID); p.WriteInt(MoneyWanted); p.WriteString("Pet"); // type of the pet, could be like beast, undead etc p.WriteString(pet.Name); p.WriteShort(pet.Level); p.WriteInt(pet.MaxHealth); p.WriteShort(pet.Damage); p.WriteShort(pet.Defense); p.WriteShort(pet.AttackRating); p.WriteHexString("01 00 00 00"); return p.GetWrittenBuffer(PacketIds.SendTradePetOffer); }
public PUTM(DateTime casted, BaseSkill skill, Pet target, Character caster) : base(casted, skill, target, caster) { }
public static byte[] SendUnSealPet(Pet pet) { Packet p = new Packet(200); p.WriteHexString("00"); p.WriteInt(pet.PetID); p.WriteInt(pet.OwnerID); p.WriteInt(pet.MapID); p.WriteByte(pet.PetType); p.WriteString(pet.Name); p.WriteShort(pet.Level); p.WriteShort((short)pet.Position.X); p.WriteShort((short)pet.Position.Y); p.WriteHexString("4E 4E"); p.WriteHexString("01 78 02 4E C6 00"); p.WriteInt(pet.MaxHealth); p.WriteInt(pet.CurHealth); p.WriteShort(pet.Damage); p.WriteShort(pet.Defense); p.WriteShort(pet.AttackRating); p.WriteHexString("01 00 09 00 00 00 00 00 25 32 00 00 01"); p.WriteLong(pet.CurrentExperience); p.WriteLong(pet.NegativeExperience); p.WriteLong(pet.ExperienceToLevel + pet.NegativeExperience); p.WriteByte(pet.Evolution); p.WriteByte(pet.Wildness); p.WriteByte(Convert.ToByte(pet.IsLegendary)); p.WriteHexString("00 00 00 00"); p.WriteHexString("00 00 00 00 00 00 00 00"); return p.GetWrittenBuffer(PacketIds.SendUnSealPet); }
void c_ClientCastSkillInfo(object sender, ClientCastSkillEventArgs e) { Client c = (Client)sender; CastSkillInfo i = e.Info; BaseSkill skill = null; MapEngine mapEngine = GetMapEngine(c.MyCharacter.MapId); Client[] clients = GetClientsForChars(mapEngine.GetCharactersInRange(c.MyCharacter.Position, 150).ToArray()); skill = c.MyCharacter.FindSkill(i.SkillID); if (c.MyCharacter.NotCastedYet(skill)) { if (i.PacketID == 1) { bool cast = false; if (c.MyCharacter.CurrentMana >= skill.ManaCost) { if (skill.KeepUpTime > 0 && skill.SkillID != (int)HardSkills.Haze && skill.SkillID != (int)HardSkills.Power_Up_Pet && skill.SkillID != (int)HardSkills.Empathy && skill.SkillID != (int)RebirthSkills.Strengthen_Monster) cast = true; else if (skill.SkillID == (int)HardSkills.Haze) { if (i.TargetID != 0) { Monster m = mapEngine.GetMonsterByID(i.TargetID, c.MyCharacter.MapId); Monster[] monsters = mapEngine.GetMonstersByRange(m, skill.Distance); int distance = MapEngine.GetDistance(c.MyCharacter.Position.X, c.MyCharacter.Position.Y, m.Position.X, m.Position.Y); if (distance <= skill.Distance) { cast = true; byte[] SendHazeEffect = PacketManager.SendSkillEffect(m, skill); SendToClients(SendHazeEffect, clients); HazeSkill hazeSkill = new HazeSkill(DateTime.Now, skill, monsters, c.MyCharacter, m); hazeSkill.HazeDamageCasted += new EventHandler<HazeDamageCastedEventArgs>(hazeSkill_HazeDamageCasted); hazeSkill.HazeEnded += new EventHandler(hazeSkill_HazeEnded); hazeSkill.DoEffect(); } } } else if (skill.SkillID == (int)HardSkills.Power_Up_Pet) { if (i.TargetID != 0) { if (c.MyCharacter.Pet != null && c.MyCharacter.Pet.PetID == i.TargetID && !c.MyCharacter.Pet.IsUsingBuff) { Pet pet = c.MyCharacter.Pet; cast = true; //byte[] SendPutmEffect = PacketManager.SendSkillEffect(pet, skill); //SendSpecific(nearbyClients, SendPutmEffect); PUTM putmSkill = new PUTM(DateTime.Now, skill, pet, c.MyCharacter); putmSkill.PUTMCasted += new EventHandler(putmSkill_PUTMCasted); putmSkill.PUTMEnded += new EventHandler(putmSkill_PUTMEnded); putmSkill.DoEffect(); } } } else if (skill.SkillID == (int)HardSkills.Empathy) { if (i.TargetID != 0) { if (c.MyCharacter.Pet != null && c.MyCharacter.Pet.PetID == i.TargetID && !c.MyCharacter.Pet.IsUsingEmpathy) { Pet pet = c.MyCharacter.Pet; cast = true; EmpathySkill empathySkill = new EmpathySkill(DateTime.Now, skill, pet, c.MyCharacter); empathySkill.EmpathyCasted += new EventHandler(empathySkill_EmpathyCasted); empathySkill.EmpathyEnded += new EventHandler(empathySkill_EmpathyEnded); empathySkill.DoEffect(); } } } else if (skill.SkillID == (int)RebirthSkills.Strengthen_Monster) { if (i.TargetID != 0) { if (c.MyCharacter.Pet != null && c.MyCharacter.Pet.PetID == i.TargetID && !c.MyCharacter.Pet.IsUsingBuff) { Pet pet = c.MyCharacter.Pet; cast = true; StrengthenMonster strMon = new StrengthenMonster(DateTime.Now, skill, pet, c.MyCharacter); strMon.StrMonsterCasted += new EventHandler(strMons_strMonCasted); strMon.StrMonsterEnded += new EventHandler(strMon_strMonEnded); strMon.DoEffect(); } } } if (skill.SkillID == (int)HardSkills.Energy_Bomb || skill.SkillID == (int)HardSkills.Crushing_Hands || skill.SkillID == (int)HardSkills.Death_Energy || skill.SkillID == (int)RebirthSkills.Rising_Fire_Dragon) cast = true; if (skill.SkillID == (int)HardSkills.Attack_Song || skill.SkillID == (int)HardSkills.Sword_Missle || skill.SkillID == (int)HardSkills.Poison_Shot || skill.SkillID == (int)HardSkills.Fist_Wind) { Monster m = mapEngine.GetMonsterByID(i.TargetID, c.MyCharacter.MapId); if (m != null) { int distance = MapEngine.GetDistance(c.MyCharacter.Position.X, c.MyCharacter.Position.Y, m.Position.X, m.Position.Y); if (distance <= skill.Distance) cast = true; } } if (cast) { c.MyCharacter.CurrentMana -= skill.ManaCost; byte[] SendCastSkill1 = PacketManager.SendCast1(skill, i, 0); SendToClients(SendCastSkill1, clients); // c.Send(SendCastSkill1); byte[] SendStats = PacketManager.SendStats(c.MyCharacter); c.Send(SendStats); } if (skill.KeepUpTime > 0 && skill.SkillID != (int)HardSkills.Haze && skill.SkillID != (int)HardSkills.Power_Up_Pet) { if (skill.SkillID == (int)HardSkills.Summon_Monster || skill.SkillID == (int)HardSkills.Shadow_Strike || skill.SkillID == (int)AbsorbSkills.Shadow_Focus || skill.SkillID == (int)RebirthSkills.Duplicate_Attack) { if (c.MyCharacter.tempPet == null) { byte type = 250; if (skill.SkillID == (int)HardSkills.Summon_Monster) type = 250; if (skill.SkillID == (int)HardSkills.Shadow_Strike || skill.SkillID == (int)RebirthSkills.Duplicate_Attack) type = 251; if (skill.SkillID == (int)AbsorbSkills.Shadow_Focus) { switch (c.MyCharacter.Class) { case 1: type = 251; break; case 2: type = 252; break; case 3: type = 253; break; case 4: type = 254; break; default: type = 250; break; } } Pet tempPet = new Pet { PetType = type, CurrentExperience = 0, Name = "Summon", MapID = c.MyCharacter.MapId, OwnerID = c.MyCharacter.CharacterId, Position = new Position(c.MyCharacter.Position.X, c.MyCharacter.Position.Y, c.MyCharacter.Position.Z), CurHealth = c.MyCharacter.CurrentHp, MaxHealth = c.MyCharacter.MaxHp, Level = 100, Damage = c.MyCharacter.TotalDamage, Defense = c.MyCharacter.TotalDefence, AttackRating = c.MyCharacter.TotalAttackRating, }; if (skill.IncDamagePerc != 0) { float DamageInc = skill.IncDamagePerc; float increase = (DamageInc / 100); tempPet.Damage = (int)(tempPet.Damage * increase); } if (skill.IncHpCurPerc != 0) { float HpInc = skill.IncHpCurPerc; float increase = (HpInc / 100); tempPet.MaxHealth = (int)(tempPet.MaxHealth * increase); tempPet.CurHealth = tempPet.MaxHealth; } if (skill.SkillID == (int)RebirthSkills.Duplicate_Attack) { tempPet.Damage *= 2; tempPet.Defense *= 2; tempPet.AttackRating *= 2; tempPet.MaxHealth *= 2; tempPet.CurHealth = tempPet.MaxHealth; } tempPet.PetID = petManager.InsertPet(tempPet, false); c.MyCharacter.tempPet = tempPet; byte[] SendSummon = PacketManager.SendSummonSpawn(tempPet); SendToClients(SendSummon, clients); } else return; } c.MyCharacter.ActiveSkills.Add(new ActiveSkill(DateTime.Now, skill, null, c.MyCharacter)); byte[] SendSkillEffect = PacketManager.SendSkillEffect(c.MyCharacter, skill); SendToClients(SendSkillEffect, clients); byte[] SendStats = PacketManager.SendStats(c.MyCharacter); c.Send(SendStats); } } else { byte[] SendNoMana = PacketManager.SendCast1(skill, i, 1); c.Send(SendNoMana); } } else { if (skill.SkillID == (int)HardSkills.Energy_Bomb || skill.SkillID == (int)HardSkills.Crushing_Hands || skill.SkillID == (int)HardSkills.Death_Energy || skill.SkillID == (int)RebirthSkills.Rising_Fire_Dragon) { Monster[] monsters = mapEngine.GetMonstersByRange(c.MyCharacter, skill.Distance); foreach (Monster m in monsters) { CastSkillInfo info = m.OnCast(c.MyCharacter, skill); byte[] SendDamage = PacketManager.SendCast2(skill, info, m); SendToClients(SendDamage, clients); if (info.Dead) { CharacterGainExperience(c, m, c.MyCharacter, false); MonsterDropItem(m, c.MyCharacter); byte[] SendMonsterDie = PacketManager.SendMonsterDie(m); SendToClients(SendMonsterDie, clients); } } } if (skill.SkillID == (int)HardSkills.Attack_Song || skill.SkillID == (int)HardSkills.Sword_Missle || skill.SkillID == (int)HardSkills.Poison_Shot || skill.SkillID == (int)HardSkills.Fist_Wind) { Monster m = mapEngine.GetMonsterByID(i.TargetID, c.MyCharacter.MapId); int distance = MapEngine.GetDistance(c.MyCharacter.Position.X, c.MyCharacter.Position.Y, m.Position.X, m.Position.Y); if (m != null && m.Alive && distance < skill.Distance && c.MyCharacter.Alive) { CastSkillInfo info = m.OnCast(c.MyCharacter, skill); byte[] SendDamage = PacketManager.SendCast2(skill, info, m); SendToClients(SendDamage, clients); if (info.Dead) { CharacterGainExperience(c, m, c.MyCharacter, false); MonsterDropItem(m, c.MyCharacter); byte[] SendMonsterDie = PacketManager.SendMonsterDie(m); SendToClients(SendMonsterDie, clients); } } } else { byte[] SendCastSkill2 = PacketManager.SendCast2(skill, i, null); c.Send(SendCastSkill2); } } } }
public List<Pet> GetLastDiedPets(int OwnerID) { DbParameter ownerIDParameter = _db.CreateParameter(DbNames.GETLASTDIEDPETS_OWNERID_PARAMETER, OwnerID); ownerIDParameter.DbType = DbType.Int32; _db.Open(); DbDataReader reader = _db.ExcecuteReader(DbNames.GETLASTDIEDPETS_STOREDPROC, CommandType.StoredProcedure, ownerIDParameter); int ordinalPET_ID = reader.GetOrdinal(DbNames.PET_ID); int ordinalPET_OWNERID = reader.GetOrdinal(DbNames.PET_OWNERID); int ordinalPET_MAPID = reader.GetOrdinal(DbNames.PET_MAPID); int ordinalPET_TYPE = reader.GetOrdinal(DbNames.PET_TYPE); int ordinalPET_BASETYPE = reader.GetOrdinal(DbNames.PET_BASETYPE); int ordinalPET_LEVEL = reader.GetOrdinal(DbNames.PET_LEVEL); int ordinalPET_NAME = reader.GetOrdinal(DbNames.PET_NAME); int ordinalPET_CURHEALTH = reader.GetOrdinal(DbNames.PET_CURHEALTH); int ordinalPET_MAXHEALTH = reader.GetOrdinal(DbNames.PET_MAXHEALTH); int ordinalPET_DAMAGE = reader.GetOrdinal(DbNames.PET_DAMAGE); int ordinalPET_DEFENSE = reader.GetOrdinal(DbNames.PET_DEFENSE); int ordinalPET_ATTACKRATING = reader.GetOrdinal(DbNames.PET_ATTACKRATING); int ordinalPET_EXPERIENCE = reader.GetOrdinal(DbNames.PET_CURRENTEXPERIENCE); int ordinalPET_WILDNESS = reader.GetOrdinal(DbNames.PET_WILDNESS); int ordinalPET_EVOLUTION = reader.GetOrdinal(DbNames.PET_EVOLUTION); int ordinalPET_ISLEGENDARY = reader.GetOrdinal(DbNames.PET_ISLEGENDARY); int ordinalPET_ISALIVE = reader.GetOrdinal(DbNames.PET_ISALIVE); int ordinalPET_ISSEALED = reader.GetOrdinal(DbNames.PET_ISSEALED); List<Pet> lastDiedPets = new List<Pet>(); while (reader.Read()) { Pet p = new Pet(); p.PetID = reader.GetInt32(ordinalPET_ID); p.OwnerID = reader.GetInt32(ordinalPET_OWNERID); p.MapID = reader.GetInt32(ordinalPET_MAPID); p.PetType = reader.GetByte(ordinalPET_TYPE); p.PetBaseType = reader.GetByte(ordinalPET_BASETYPE); p.Level = reader.GetInt16(ordinalPET_LEVEL); p.Name = reader.GetString(ordinalPET_NAME); p.CurHealth = reader.GetInt32(ordinalPET_CURHEALTH); p.MaxHealth = reader.GetInt32(ordinalPET_MAXHEALTH); p.Damage = reader.GetInt32(ordinalPET_DAMAGE); p.Defense = reader.GetInt32(ordinalPET_DEFENSE); p.AttackRating = reader.GetInt32(ordinalPET_ATTACKRATING); p.CurrentExperience = reader.GetInt64(ordinalPET_EXPERIENCE); p.Wildness = reader.GetByte(ordinalPET_WILDNESS); p.Evolution = reader.GetByte(ordinalPET_EVOLUTION); p.IsLegendary = reader.GetBoolean(ordinalPET_ISLEGENDARY); p.Alive = reader.GetBoolean(ordinalPET_ISALIVE); lastDiedPets.Add(p); } reader.Close(); _db.Close(); return lastDiedPets; }
public Monster[] GetMonstersByRange(Pet pet, int distance) { try { //var map = maps.Where(x => x.MapID == pet.MapID).First(); var monsters = Map.Monsters.Where(x => x.Alive && GetDistance(x.Position.X, x.Position.Y, pet.Position.X, pet.Position.Y) < distance); return monsters.ToArray(); } catch { return null; } }
public static byte[] SendPetEvolution(Pet pet) { Packet p = new Packet(200); p.WriteInt(pet.OwnerID); p.WriteInt(pet.PetID); p.WriteByte(pet.PetType); p.WriteByte(pet.Evolution); p.WriteHexString("00 00 00 00 00 00 00"); // some transforming stuff like when using a pill i guess return p.GetWrittenBuffer(PacketIds.SendPetEvolved); }