public HazeDamageCastedEventArgs(BaseEntity[] targets, Character caster)
 {
     this.targets = targets;
     this.caster = caster;
 }
Example #2
0
        private void AttackEntity(BaseEntity ent)
        {
            UpdateTarget();

            if (Monster.Target != null)
            {
                if (!TargetOnAttackRange())
                    state = MonsterAIState.Chase;
                else
                {
                    Monster.Target = ent;
                    Monster.Attacking = true;

                    MonsterAttackInfo info = GetAttackInfo(false);
                    if (MonsterAttack != null)
                        MonsterAttack(this, new MonsterAttackInfoEventArgs(info));
                }
            }
        }
Example #3
0
        private void ChaseEntity(BaseEntity ent)
        {
            UpdateTarget();

            if (Monster.Target != null)
            {
                if (TargetOnAttackRange())
                    state = MonsterAIState.Attack;
                else
                {
                    Position entPos = new Position(ent.Position.X, ent.Position.Y, 0);
                    MoveTo(entPos);
                }
            }
        }
Example #4
0
        private void CharacterGainExperience(Client c, BaseEntity entity, Character ch, bool gainedExp)
        {
            if (ch.Party != null && gainedExp == false)
            {
                foreach (Character m in ch.Party.Members)
                {
                    Client member = GetClientByCharacterID(m.CharacterId);
                    CharacterGainExperience(member, entity, m, true);
                }
                return;
            }
            else if (ch.Level < 200)
            {
                Monster m = null;
                if (entity is Monster)
                    m = entity as Monster;

                long charexp = Math.Abs(ch.CurrentExp - ch.NegativeExp);
                bool leveled = false;
                bool training = false;
                int experience = m.Experience - ch.Level;
                if (experience < 0)
                    experience = 1;
                experience = experience * ExperienceMultiper;

                if (ch.Party != null)
                {
                    float maxExp = 1.0f;
                    float divider = 0.1f;
                    divider = maxExp - (divider * ch.Party.MemberCount);

                    experience = (int)(experience * divider);

                    if (experience < 0)
                        experience = 1;
                }

                if (charexp + experience > ch.ExpToTraining)
                {
                    ch.TrainingPoint++;
                    ch.GainedTrainings++;
                    ch.TpLevel++;
                    ch.ExpToTraining = characterManager.GetExperienceToTpByTpLevel(ch.TpLevel);
                    training = true;

                    c.MyCharacter.CalculateTotalStats();
                    c.MyCharacter.CurrentHp = c.MyCharacter.MaxHp;
                    c.MyCharacter.CurrentMana = c.MyCharacter.MaxMana;
                }
                if (charexp + experience > ch.ExpToLevel)
                {
                    ch.StatPoint += (short)ch.GetStatPointsPerLevel();
                    ch.Level++;
                    ch.ExpToLevel = characterManager.GetExperienceToLevelByLevel(ch.Level);
                    ch.NegativeExp = characterManager.GetNegativeExpByLevel(ch.Level);
                    leveled = true;

                    c.MyCharacter.CalculateTotalStats();
                    c.MyCharacter.CurrentHp = c.MyCharacter.MaxHp;
                    c.MyCharacter.CurrentMana = c.MyCharacter.MaxMana;

                    if (ch.Party != null)
                    {
                        foreach (Character p in c.MyCharacter.Party.Members)
                        {
                            Client playerClient = GetClientByCharacterID(p.CharacterId);
                            playerClient.Send(PacketManager.SendParty(c.MyCharacter.Party));
                        }
                    }
                }

                ch.CurrentExp += experience;

                characterManager.UpdateCharacter(ch);

                byte[] SendExpEffectPacket = PacketManager.SendExpEffectPacket(m);
                c.Send(SendExpEffectPacket);

                byte[] SendExpMaybe = PacketManager.SendExperience(ch, experience, 0, leveled, training);
                c.Send(SendExpMaybe);

                byte[] bufferSendStats = PacketManager.SendStats(c.MyCharacter);
                c.Send(bufferSendStats);
            }
        }
Example #5
0
        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);
                }
            }
        }
Example #6
0
 public ActiveSkill(DateTime casted, BaseSkill skill, BaseEntity[] targets, Character caster)
 {
     this.CastTime = casted;
     this.Skill = skill;
     this.Caster = caster;
     this.Targets = targets;
 }
Example #7
0
        private void MonsterDropItem(BaseEntity deadEntity, BaseEntity killingEntity)
        {
            bool gotItem = false;
            BaseItem item = null;
            MapItem mapItem = null;
            Monster m = null;
            if (deadEntity is Monster)
                m = deadEntity as Monster;
            Character attacker = killingEntity as Character;
            MapEngine mapEngine = GetMapEngine(attacker.MapId);
            Client[] clients = GetClientsForChars(mapEngine.GetCharactersInRange(attacker.Position, 150).ToArray());

            if (m != null)
            {
                if (m.Level >= 60 && XiahRandom.PercentSuccess(PillDropChance))
                {
                    item = itemDataManager.GetRebirthPillDrop(m);
                    if (item != null)
                        gotItem = true;
                }
                if (XiahRandom.PercentSuccess(StoneDropChance))
                {
                    item = itemDataManager.GetImbueDropItem();
                    if (item != null)
                        gotItem = true;
                }
                if (!gotItem && XiahRandom.PercentSuccess(BookDropChance))
                {
                    item = itemDataManager.GetBookDropItem(m);
                    if (item != null)
                        gotItem = true;
                }
                if (!gotItem && XiahRandom.PercentSuccess(ItemDropChance))
                {
                    item = itemDataManager.GetMonsterDropItem(m);
                    if (item != null)
                        gotItem = true;
                }

                if (XiahRandom.PercentSuccess(MoneyDropChance))
                {
                    BaseItem gold = itemDataManager.GetItemByReferenceID(20042);
                    gold.Amount = (short)(XiahRandom.Next(15, 17) * (m.Level));

                    MapItem map = mapEngine.PlayerDropItem(attacker.CharacterId, gold, (short)m.Position.X, (short)m.Position.Y, 0, m.MapID);

                    byte[] SendItemOnGround = PacketManager.SendItemOnGround(map);
                    SendToClients(SendItemOnGround, clients);
                }

                if (gotItem && item != null)
                {
                    mapItem = mapEngine.PlayerDropItem(attacker.CharacterId, item, (short)m.Position.X, (short)m.Position.Y, 0, m.MapID);

                    byte[] SendItemOnGround = PacketManager.SendItemOnGround(mapItem);
                    SendToClients(SendItemOnGround, clients);
                }
            }
        }
Example #8
0
 private void AttackMonster(int monsterID, BaseEntity entity)
 {
 }
Example #9
0
 public HazeSkill(DateTime hit, BaseSkill skill, BaseEntity[] targets, Character caster, BaseEntity hitTarget)
     : base(hit, skill, targets, caster)
 {
     this.hitTarget = hitTarget;
 }
Example #10
0
 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();
 }
Example #11
0
 private void SkillMonster(int monsterID, BaseEntity entity)
 {
 }
Example #12
0
 public static byte[] SendMonsterStopMoving(BaseEntity ent , MovementInfo mi)
 {
     Pet pet = null;
     Monster m = null;
     Packet p = new Packet(200);
     if (ent is Monster)
     {
         m = ent as Monster;
         p.WriteHexString("00");
         p.WriteInt(m.MonsterID);
         p.WriteByte((byte)m.Type);
         p.WriteShort(mi.FromX);
         p.WriteShort(mi.FromY);
         p.WriteHexString("00 14");
         p.WriteByte(m.MovementSpeed);
     }
     if (ent is Pet)
     {
         pet = ent as Pet;
         p.WriteHexString("00");
         p.WriteInt(pet.PetID);
         p.WriteByte((byte)pet.Type);
         p.WriteShort(mi.FromX);
         p.WriteShort(mi.FromY);
         p.WriteHexString("00 00 03");
     }
     return p.GetWrittenBuffer(PacketIds.SendMonsterStopMoving);
 }
Example #13
0
        public static byte[] SendMonsterStopMoving(BaseEntity ent, MonsterMoveInfo mi)
        {
            Monster m = null;
            Packet p = new Packet(200);
            if (ent is Monster)
            {
                m = ent as Monster;
                p.WriteHexString("00");
                p.WriteInt(m.MonsterID);
                p.WriteByte((byte)m.Type);
                p.WriteShort(mi.CurrentPosition.X);
                p.WriteShort(mi.CurrentPosition.Y);
                p.WriteHexString("00 14");
                p.WriteByte(m.MovementSpeed);
            }

            return p.GetWrittenBuffer(PacketIds.SendMonsterStopMoving);
        }
Example #14
0
 public static byte[] SendMonsterKeepMoving(BaseEntity ent, MovementInfo mi)
 {
     Pet pet = null;
     Packet p = new Packet(200);
     if (ent is Pet)
     {
         pet = ent as Pet;
         p.WriteHexString("00");
         p.WriteInt(pet.PetID);
         p.WriteByte((byte)pet.Type);
         p.WriteShort(mi.FromX);
         p.WriteShort(mi.FromY);
         p.WriteByte(mi.FromZ);
         p.WriteShort(mi.ToX);
         p.WriteShort(mi.ToY);
         p.WriteByte(mi.ToZ);
         p.WriteInt(mi.Rotation);
         p.WriteHexString("00 00");
     }
     return p.GetWrittenBuffer(PacketIds.SendMonsterKeepMoving);
 }
Example #15
0
 public static byte[] SendMonsterDie(BaseEntity entity)
 {
     Packet p = new Packet(20);
     Pet pet = null;
     Monster m = null;
     if (entity is Monster)
     {
         m = entity as Monster;
         p.WriteByte((byte)m.Type);
         p.WriteInt(m.MonsterID);
     }
     if (entity is Pet)
     {
         pet = entity as Pet;
         p.WriteByte((byte)pet.Type);
         p.WriteInt(pet.PetID);
     }
     p.WriteHexString("03 00 00 FF");
     return p.GetWrittenBuffer(PacketIds.SendMonsterDie);
 }
Example #16
0
 public static byte[] SendAttack2(AttackInfo i, BaseEntity target)
 {
     Packet p = new Packet(200);
     p.WriteByte((byte)i.Type);
     p.WriteByte(i.AttackerType);
     p.WriteInt(i.AttackerID);
     p.WriteShort(i.TargetX);
     p.WriteShort(i.TargetY);
     p.WriteByte(i.TargetZ);
     p.WriteByte(i.TargetType);
     p.WriteInt(i.TargetID);
     if (target is Monster)
     {
         Monster m = target as Monster;
         p.WriteInt(m.MaxHealth);
         p.WriteInt(m.CurHealth);
     }
     if (target is Character)
     {
         Character ch = target as Character;
         p.WriteInt(ch.MaxHp);
         p.WriteInt(ch.CurrentHp);
     }
     if (target is Pet)
     {
         Pet pet = target as Pet;
         p.WriteInt(pet.MaxHealth);
         p.WriteInt(pet.CurHealth);
     }
     p.WriteInt(i.Damage);
     p.WriteInt(i.Experience);
     p.WriteHexString("00");
     p.WriteByte(Convert.ToByte(i.Critical));
     return p.GetWrittenBuffer(PacketIds.SendAttack2);
 }