예제 #1
0
        private void handleExamineNPC(Player player, Packet packet)
        {
            int npcId = packet.readUShort();

            if (npcId < 0 || npcId > NpcData.getTotalNpcDefinitions() || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null)
            {
                return;
            }

            player.getPackets().sendMessage(NpcData.forId(npcId).getExamine());
        }
예제 #2
0
 public Npc(int id)
 {
     this.id = id;
     npcDef  = NpcData.forId(id);
     skills  = new NpcSkills(this);
     skills.setMaxLevel(NpcSkills.SKILL.HITPOINTS, npcDef.getHitpoints()); //this must be first.
     skills.setCurLevel(NpcSkills.SKILL.HITPOINTS, npcDef.getHitpoints());
     this.setWalkType(WalkType.RANGE);
     this.faceDirection = FaceDirection.NORTH;
     this.updateFlags   = new AppearanceUpdateFlags(this);
 }
예제 #3
0
파일: Combat.cs 프로젝트: Rut0/RSPS-CSharp
        public static double getDamage(Entity killer, Entity target)
        {
            if (killer is Npc)
            {
                int maxDamage = killer.getMaxHit();
                if (maxDamage > target.getHp())
                {
                    maxDamage = target.getHp();
                }
                if (target is Player)
                {
                    NpcData npcDef         = NpcData.forId(((Npc)killer).getId());
                    int     npcAttackStyle = ((Npc)killer).getAttackType();

                    if (((Player)target).getPrayers().getHeadIcon() == PrayerData.MELEE && npcAttackStyle == NpcData.MELEE)
                    {
                        return(0);
                    }
                    else
                    if (Misc.random((int)CombatFormula.getNPCMeleeAttack((Npc)killer)) < Misc.random((int)CombatFormula.getMeleeDefence((Player)target, (Player)target)))
                    {
                        return(0);
                    }
                }
                return(Misc.random(maxDamage));
            }
            else
            {
                if (target is Npc)
                {
                    if (Misc.random((int)CombatFormula.getMeleeAttack((Player)killer)) < Misc.random((int)CombatFormula.getNPCMeleeDefence((Npc)target)))
                    {
                        return(0);
                    }
                }
                double damage = CombatFormula.getMeleeHit((Player)killer, target);
                if (target is Player)
                {
                    if (((Player)target).getPrayers().getHeadIcon() == PrayerData.MELEE)
                    {
                        damage = (int)(damage * 0.60);
                    }
                }
                if (damage > target.getHp())
                {
                    damage = target.getHp();
                }
                return(damage);
            }
        }
예제 #4
0
        private static void appendHitUpdate(Npc Npc, PacketBuilder updateBlock)
        {
            NpcData npcDef = NpcData.forId(Npc.getId());
            int     ratio  = 1;

            if (npcDef != null)
            {
                ratio = Npc.getHp() * 255 / npcDef.getHitpoints();
            }
            else
            {
                misc.WriteError("Missing npcDef npcId: " + Npc.getId());
            }
            updateBlock.addByte((byte)Npc.getHits().getHitDamage1());
            updateBlock.addByteC((int)Npc.getHits().getHitType1()); //TODO: <- check
            updateBlock.addByteS((byte)ratio);
        }
        public static double getNPCMeleeAttack(Npc npc)
        {
            double  power       = 0.640;
            double  amount      = 1.670;
            NpcData npcDef      = NpcData.forId(npc.getId());
            int     combatLevel = 3;

            if (npcDef == null)  //Level 3 if npcDef doesn't exist
            {
                power *= (amount * combatLevel) * power;
                misc.WriteError("Missing npcDef for npcId: " + npc.getId());
            }
            else
            {
                combatLevel = NpcData.forId(npc.getId()).getCombat();
                power      *= (amount * combatLevel) * power;
                if (npcDef.isBoss())
                {
                    power *= 1.2;
                }
            }
            return(power);
        }
        public static double getNPCMeleeDefence(Npc npc)
        {
            double power  = 0.600;
            double amount = 0.900;

            NpcData npcDef      = NpcData.forId(npc.getId());
            int     combatLevel = 3;

            if (npcDef == null)
            { //Level 3 if npcDef doesn't exist
                power *= (amount * combatLevel) * power;
                misc.WriteError("Missing npcDef for npcId: " + npc.getId());
            }
            else
            {
                combatLevel = NpcData.forId(npc.getId()).getCombat();
                power      *= (amount * combatLevel) * power;
                if (npcDef.isBoss())
                {
                    power *= 1.4; //40% increase.
                }
            }
            return(power);
        }
예제 #7
0
 public override int getDefenceAnimation()
 {
     return(!this.appearance.isNpc() ? Animations.getDefenceAnimation(this) : NpcData.forId(this.appearance.getNpcId()).getDefenceAnimation());
 }
예제 #8
0
 public override int getDeathAnimation()
 {
     return(!this.appearance.isNpc() ? 7185 : NpcData.forId(this.appearance.getNpcId()).getDeathAnimation());
 }
예제 #9
0
        public static double getDamage(Entity killer, Entity target)
        {
            //If attacker is a Npc
            if (killer is Npc)
            {
                //Gets the NPC's max hit
                double maxDamage = killer.getMaxHit();
                //If the NPC's max hit is more then target's healthpoints
                if (maxDamage > target.getHp())
                {
                    //Set's NPC's new max hit to the target's healthpoints.
                    maxDamage = target.getHp();
                }
                //If target is a Player
                if (target is Player)
                {
                    //Get the NPC Defintions for the Attacker's NPC Id.
                    NpcData npcDef = NpcData.forId(((Npc)killer).getId());
                    //Gets the NPC's attack style (MELEE, RANGE OR MAGIC)
                    int npcAttackStyle = ((Npc)killer).getAttackType();

                    //If the target Player has prayer headicon on for MELEE (doesn't mean prayer is on!) and npc attacker style is also MELEE
                    if (((Player)target).getPrayers().getHeadIcon() == PrayerData.PrayerHeadIcon.MELEE && npcAttackStyle == NpcData.MELEE)
                    {
                        //The damage will be 0.
                        return(0);
                        //Otherwise if checks if the NPC Melee Attack damage precisely randomized is less then Player's Melee Defence also precisely randomized.
                    }
                    else if (misc.randomDouble(CombatFormula.getNPCMeleeAttack((Npc)killer)) < misc.randomDouble(CombatFormula.getMeleeDefence((Player)target, (Player)target)))
                    {
                        //The damage will be 0.
                        return(0);
                    }
                }
                //Returns a damage based on the NPC's max hit.
                return(misc.randomDouble(maxDamage));
            }
            else
            {
                //If the target is NPC
                if (target is Npc)
                {
                    //Checks if the Player attacker's Melee Attack precisely randomized is less then target's NPC Melee defense also precisely randomized.
                    if (misc.randomDouble(CombatFormula.getMeleeAttack((Player)killer)) < misc.randomDouble(CombatFormula.getNPCMeleeDefence((Npc)target)))
                    {
                        //The damage will be 0.
                        return(0);
                    }
                }
                //This finds the damage of attacker's MeleeHit vs target [Npc or Player]'s MeleeHit.
                double damage = CombatFormula.getMeleeHit((Player)killer, target);
                //If target is a Player
                if (target is Player)
                {
                    //If target Player has headicon MELEE on (doesn't mean prayer is on)
                    if (((Player)target).getPrayers().getHeadIcon() == PrayerData.PrayerHeadIcon.MELEE)
                    {
                        //the damage calculated from melee hit is reduced by 40% [0.60=40%]
                        damage = (damage * 0.60);
                    }
                }
                //If damage going to be done is more then target's healthpoints
                if (damage > target.getHp())
                {
                    //damage will be reduced to the target's healthpoints
                    damage = target.getHp();
                }
                //returns the damage.
                return(damage);
            }
        }