當前位置: 首頁>>代碼示例>>C#>>正文


C# Player.heal方法代碼示例

本文整理匯總了C#中RS2.Server.player.Player.heal方法的典型用法代碼示例。如果您正苦於以下問題:C# Player.heal方法的具體用法?C# Player.heal怎麽用?C# Player.heal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在RS2.Server.player.Player的用法示例。


在下文中一共展示了Player.heal方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: hitInMulti


//.........這裏部分代碼省略.........
                 }
                 if (n.isAutoRetaliating() && n.getTarget() == null)
                 {
                     //n.getFollow().setFollowing(killer);
                     n.setEntityFocus(p.getClientIndex());
                     n.setCombatTurns(n.getAttackSpeed() / 2);
                     n.setTarget(p);
                 }
                 int damage = Misc.random(Misc.random(getSpellMaxHit(p, index))); //double randomize? uhh wtf?
                 int graphic = END_GFX[index];
                 if (damage == 0)
                 {
                     graphic = 85;
                 }
                 if (damage > n.getHp())
                 {
                     damage = n.getHp();
                 }
                 if (damage > 0)
                 {
                     bool frozen = freezeTarget(index, n);
                     if (!frozen && index == 31)
                     {
                         graphic = 1677;
                     }
                 }
                 totalDamage += damage;
                 n.setAttacker(p);
                 n.setLastAttacked(Environment.TickCount);
                 n.setLastGraphics(new Graphics(graphic, 0, getGroundHeight(index, graphic)));
                 n.hit(damage);
                 if ((n.getCombatTurns() > 2 || n.getCombatTurns() < 0))
                 {
                     n.setLastAnimation(new Animation(n.getDefenceAnimation()));
                 }
                 addDamage(p, n, damage);
             }
         }
     }
     else
     {
         foreach (Player target in Server.getPlayerList())
         {
             if (mainTarget == null || target.Equals(mainTarget) || target.isDead() || target.isHidden() || target.isDestroyed())
             {
                 continue;
             }
             if (target.getLocation().inArea(l.getX() - 1, l.getY() - 1, l.getX() + 1, l.getY() + 1))
             {
                 if (!canCastSpell2(p, mainTarget, index, false))
                 {
                     continue;
                 }
                 if (target.isAutoRetaliating() && target.getTarget() == null)
                 {
                     //n.getFollow().setFollowing(killer);
                     target.setEntityFocus(p.getClientIndex());
                     target.setCombatTurns(target.getAttackSpeed() / 2);
                     target.setTarget(p);
                 }
                 int damage = Misc.random(Misc.random(getSpellMaxHit(p, index))); //double randomize? uhh wtf?
                 int graphic = END_GFX[index];
                 if (damage == 0)
                 {
                     graphic = 85;
                 }
                 if (damage > target.getHp())
                 {
                     damage = target.getHp();
                 }
                 if (damage > 0)
                 {
                     bool frozen = freezeTarget(index, target);
                     if (!frozen && index == 31)
                     {
                         graphic = 1677;
                     }
                 }
                 totalDamage += damage;
                 target.setAttacker(p);
                 target.setLastAttacked(Environment.TickCount);
                 target.setLastGraphics(new Graphics(graphic, 0, getGroundHeight(index, graphic)));
                 target.hit(damage);
                 if ((target.getCombatTurns() > 2 || target.getCombatTurns() < 0))
                 {
                     target.setLastAnimation(new Animation(target.getDefenceAnimation()));
                 }
                 addDamage(p, target, damage);
             }
         }
     }
     if (totalDamage > 0)
     {
         addMagicXp(p, null, totalDamage, index, false);
         if (index == 18 || index == 22 || index == 26 || index == 30)
         {
             p.heal((int)(totalDamage * 0.25));
         }
     }
 }
開發者ID:ramatronics,項目名稱:rsps,代碼行數:101,代碼來源:MagicCombat.cs

示例2: newMagicAttack


//.........這裏部分代碼省略.........
                {
                    if (target is Npc)
                    {
                    }
                    else
                    {
                        if (((Player)target).getTemporaryAttribute("autoCastSpell") != null)
                        {
                            int autoCastSpell = (int)((Player)target).getTemporaryAttribute("autoCastSpell");
                            ((Player)target).setTemporaryAttribute("autoCasting", true);
                            target.setTarget(p);
                            MagicCombat.newMagicAttack((Player)target, p, autoCastSpell, ((Player)target).getTemporaryAttribute("autoCastAncients") != null);
                        }
                    }
                    target.getFollow().setFollowing(p);
                    target.setEntityFocus(p.getClientIndex());
                    if ((target.getCombatTurns() <= (target.getAttackSpeed() / 2) || target.getCombatTurns() >= (target.getAttackSpeed())))
                    {
                        target.setCombatTurns(target.getAttackSpeed() / 2);
                    }
                    target.setTarget(p);
                    if (target is Player)
                    {
                        ((Player)target).getWalkingQueue().resetWalkingQueue();
                        ((Player)target).getPackets().clearMapFlag();
                    }
                }
                addMagicXp(p, target, damage, index, true);
                target.setLastGraphics(new Graphics(endGfx, 0, getGroundHeight(index, endGfx)));
                if (index == 47 && endGfx != 85)
                { // teleblock
                    if (target is Player)
                    {
                        teleblockPlayer(p, (Player)target);
                    }
                }
                if (damage != 0)
                {
                    Combat.checkRecoil(p, target, damage);
                    Combat.checkSmite(p, target, damage);
                    Combat.checkVengeance(p, target, damage);
                    hitInMulti(p, target, index);
                    applyMiasmicEffects(p, target, index);
                    if ((target.getCombatTurns() > 2 || target.getCombatTurns() < 0) && !target.isDead())
                    {
                        target.setLastAnimation(new Animation(target.getDefenceAnimation()));
                    }
                    if (index != 27)
                    {
                        target.hit((int)damage);
                        if (index == 18 || index == 22 || index == 26 || index == 30)
                        {
                            p.heal(Convert.ToInt32(damage / 4));
                        }
                    }
                    else if (index == 27)
                    {
                        Event doHitEvent = new Event(1000);
                        doHitEvent.setAction(() =>
                        {
                            doHitEvent.stop();
                            target.hit((int)damage);
                        });
                        Server.registerEvent(doHitEvent);
                    }
                }
            });
            Server.registerEvent(doMagicAttackEvent);
            if (p.getTemporaryAttribute("autoCasting") != null)
            {
                if (p.getTemporaryAttribute("autoCastSpell") != null)
                {
                    if (id != (int)p.getTemporaryAttribute("autoCastSpell"))
                    {
                        p.setTarget(null);
                        return;
                    }
                }
                if (!fakeNPC)
                {
                    p.setTemporaryAttribute("autocastLocation", target.getLocation());
                    p.setTemporaryAttribute("autocastEntity", target);
                }
                Event autoCastSpellEvent = new Event(3500);
                autoCastSpellEvent.setAction(() =>
                {
                    autoCastSpellEvent.stop();
                    if (p.getTemporaryAttribute("autoCasting") != null && p.getTemporaryAttribute("autoCastSpell") != null)
                    {
                        int autoCastSpell = (int)p.getTemporaryAttribute("autoCastSpell");
                        MagicCombat.newMagicAttack(p, p.getTarget(), autoCastSpell, p.getTemporaryAttribute("autoCastAncients") != null);
                    }
                });
                Server.registerEvent(autoCastSpellEvent);
            }
            else
            {
                p.setTarget(null);
            }
        }
開發者ID:ramatronics,項目名稱:rsps,代碼行數:101,代碼來源:MagicCombat.cs

示例3: applyBoltGraphic

        private static int applyBoltGraphic(Player killer, Entity target, int damage, int bolt)
        {
            int hit = Misc.random(10);
            if (hit != 0 || getBowType(killer) != BOW_TYPE.CROSSBOW)
            {
                return damage;
            }
            double maxDamage = getDamage((Player)killer, target, ((Player)killer).getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON), bolt);
            switch (bolt)
            {
                case 9236: // Opal.
                    target.setLastGraphics(new Graphics(749));
                    maxDamage *= 1.25;
                    break;

                case 9237: // Jade.
                    target.setLastGraphics(new Graphics(756));
                    //TODO Falling emote
                    break;

                case 9238: // Pearl.
                    target.setLastGraphics(new Graphics(750));
                    break;

                case 9239: // Topaz.
                    target.setLastGraphics(new Graphics(757, 0, 0));
                    if (target is Player)
                    {
                        int magicLevel = ((Player)target).getSkills().getCurLevel(Skills.SKILL.MAGIC);
                        if (magicLevel == 1)
                            return (int)maxDamage;
                        int magicLevelDeduction = Misc.random(1, 10);
                        magicLevelDeduction = Math.Min(magicLevelDeduction, (magicLevel - 1));
                        string s = magicLevelDeduction == 1 ? "" : "s";
                        ((Player)target).getSkills().setCurLevel(Skills.SKILL.MAGIC, magicLevel - magicLevelDeduction);
                        ((Player)target).getPackets().sendSkillLevel(Skills.SKILL.MAGIC);
                        ((Player)target).getPackets().sendMessage("Your Magic level has been reduced by " + magicLevelDeduction + " level" + s + " !");
                    }
                    break;

                case 9240: // Sapphire.
                    target.setLastGraphics(new Graphics(751));
                    if (target is Player)
                    {
                        int prayerLevel = ((Player)target).getSkills().getCurLevel(Skills.SKILL.PRAYER);
                        if (prayerLevel == 1)
                            return (int)maxDamage;
                        int prayerLevelDeduction = Misc.random(1, 10);
                        prayerLevelDeduction = Math.Min(prayerLevelDeduction, (prayerLevel - 1));
                        string s = prayerLevelDeduction == 1 ? "" : "s";
                        ((Player)target).getSkills().setCurLevel(Skills.SKILL.PRAYER, prayerLevel - prayerLevelDeduction);
                        ((Player)target).getPackets().sendSkillLevel(Skills.SKILL.PRAYER);
                        ((Player)target).getPackets().sendMessage("Your Prayer level has been lowered by " + prayerLevelDeduction + " level" + s + " !");
                        killer.getPackets().sendMessage("You steal " + prayerLevelDeduction + " Prayer point" + s + " from your opponent!");

                        int prayerLevelObtained = Math.Min(killer.getSkills().getCurLevel(Skills.SKILL.PRAYER) + prayerLevelDeduction, killer.getSkills().getMaxLevel(Skills.SKILL.PRAYER));
                        killer.getSkills().setCurLevel(Skills.SKILL.PRAYER, prayerLevelObtained);
                        killer.getPackets().sendSkillLevel(Skills.SKILL.PRAYER);
                    }
                    break;

                case 9241: // Emerald.
                    if (!target.isPoisoned())
                    {
                        Server.registerEvent(new PoisonEvent(target, 6));
                        target.setLastGraphics(new Graphics(752));
                    }
                    break;

                case 9242: // Ruby
                    target.setLastGraphics(new Graphics(754));
                    int currentHP = killer.getHp();
                    bool has11Percent = (currentHP * 0.11) < currentHP;
                    int removeFromOpponent = (int)(target.getHp() * 0.20); //20% off opponents HP.
                    if (has11Percent)
                    {
                        killer.hit((int)(currentHP * 0.10));
                        target.hit(removeFromOpponent);
                        killer.getPackets().sendMessage("You sacrifice some of your own health to deal more damage to your opponent!");
                    }
                    break;

                case 9243: // Diamond.
                    target.setLastGraphics(new Graphics(758));
                    maxDamage *= 1.15;
                    //TODO this affects opponents range defence for X minutes.
                    break;

                case 9244: // Dragon.
                    bool hitsFire = true;
                    if (target is Player)
                    {
                        int shield = ((Player)target).getEquipment().getItemInSlot(ItemData.EQUIP.SHIELD);
                        /*
                         * Opponent has anti-fire shield.
                         */
                        if (shield == 11283 || shield == 1540)
                        {
                            hitsFire = false;
                        }
//.........這裏部分代碼省略.........
開發者ID:ramatronics,項目名稱:rsps,代碼行數:101,代碼來源:RangeCombat.cs


注:本文中的RS2.Server.player.Player.heal方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。