Example #1
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);
 }
        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);
        }