public void execute(Player player, string[] arguments)
        {
            if (arguments.Length == 0)
            {
                player.getPackets().sendMessage("[Test Damage command]: ::testdmg dmg  ::testdmg 2000");
                return;
            }

            int dmg = 0;
            Hits.Hit hit;
            if (!int.TryParse(arguments[0], out dmg))
            {
                dmg = 0;
                hit = new Hits.Hit(dmg, Hits.HitType.NO_DAMAGE);
            }
            else
            {
                hit = new Hits.Hit(dmg, Hits.HitType.NORMAL_DAMAGE);
            }

            player.getHits().setHit1(hit);
            player.getUpdateFlags().setHitUpdateRequired(true);
        }
예제 #2
0
        public void processQueuedHits()
        {
            // kinda messy, but what can you do.
            Hits.Hit hit  = null;
            Hits.Hit hit2 = null;

            if (this is Player)
            {
                if (!((Player)this).getUpdateFlags().isHitUpdateRequired())
                {
                    if (queuedHits.Count() > 0)
                    {
                        hit = queuedHits.Dequeue();

                        //Send damage of hit1 to screen.
                        getHits().setHit1(hit);
                        ((Player)this).getUpdateFlags().setHitUpdateRequired(true);
                    }
                }
                if (!((Player)this).getUpdateFlags().isHit2UpdateRequired())
                {
                    if (queuedHits.Count() > 0)
                    {
                        hit2 = queuedHits.Dequeue();

                        //Send damage of hit2 to screen.
                        getHits().setHit2(hit2);
                        ((Player)this).getUpdateFlags().setHit2UpdateRequired(true);
                    }
                }
            }
            else
            {
                if (!((Npc)this).getUpdateFlags().isHitUpdateRequired())
                {
                    if (queuedHits.Count() > 0)
                    {
                        hit = queuedHits.Dequeue();

                        //Send damage of hit1 to screen.
                        getHits().setHit1(hit);
                        ((Npc)this).getUpdateFlags().setHitUpdateRequired(true);
                    }
                }
                if (!((Npc)this).getUpdateFlags().isHit2UpdateRequired())
                {
                    if (queuedHits.Count() > 0)
                    {
                        hit2 = queuedHits.Dequeue();

                        //Send damage of hit2 to screen.
                        getHits().setHit2(hit2);
                        ((Npc)this).getUpdateFlags().setHit2UpdateRequired(true);
                    }
                }
            }

            if (hit != null)
            {
                damageTaken += ((double)hit.getDamage() / 10);
            }
            if (hit2 != null)
            {
                damageTaken += ((double)hit2.getDamage() / 10);
            }

            //If the fraction damage adds up to 1 damage or mroe then we process it off healthpoints.
            if (this is Player && damageTaken >= 1)
            {
                Skills skills       = ((Player)this).getSkills();
                int    damageToTake = (int)damageTaken;

                skills.setCurLevel(Skills.SKILL.HITPOINTS, skills.getCurLevel(Skills.SKILL.HITPOINTS) - damageToTake);
                damageTaken -= damageToTake;
                if (skills.getCurLevel(Skills.SKILL.HITPOINTS) <= 0)
                {
                    skills.setCurLevel(Skills.SKILL.HITPOINTS, 0);
                    if (!isDead())
                    {
                        Server.registerEvent(new DeathEvent(this));
                        setDead(true);
                    }
                }
                ((Player)this).getPackets().sendSkillLevel(Skills.SKILL.HITPOINTS);
            }
            else if (this is Npc && damageTaken >= 1)
            {
                NpcSkills skills       = ((Npc)this).getSkills();
                int       damageToTake = (int)damageTaken;

                skills.setCurLevel(NpcSkills.SKILL.HITPOINTS, skills.getCurLevel(NpcSkills.SKILL.HITPOINTS) - damageToTake);
                damageTaken -= damageToTake;
                if (skills.getCurLevel(NpcSkills.SKILL.HITPOINTS) == 0)
                {
                    if (!isDead())
                    {
                        Server.registerEvent(new DeathEvent(this));
                        setDead(true);
                    }
                }
            }
        }