0
package com.rs.game.npc.combat.impl;

import java.util.ArrayList;

import com.rs.game.Animation;
import com.rs.game.Entity;
import com.rs.game.ForceTalk;
import com.rs.game.Graphics;
import com.rs.game.Hit;
import com.rs.game.Hit.HitLook;
import com.rs.game.World;
import com.rs.game.npc.NPC;
import com.rs.game.npc.combat.CombatScript;
import com.rs.game.npc.combat.NPCCombatDefinitions;
import com.rs.game.player.Player;
import com.rs.utils.Utils;

public class RangerCombat extends CombatScript {

    private Entity target;

    public RangerCombat(Entity target) {
    this.target = target;
    }

    @Override
    public Object[] getKeys() {
        return new Object[] { 15176 };
    }

    @Override
    public int attack(final NPC npc, final Entity target) {
        final NPCCombatDefinitions defs = npc.getCombatDefinitions();
        if (Utils.getRandom(4) == 0) {
            switch (Utils.getRandom(6)) {
            case 0:
                npc.setNextForceTalk(new ForceTalk("You shall fall this day!"));
                break;
            case 1:
                npc.setNextForceTalk(new ForceTalk("May my arrows pierce your heart!"));
                break;
            case 2:
                npc.setNextForceTalk(new ForceTalk("Fight on!"));
                break;
            }
        }
        if (Utils.getRandom(3) == 0) {
            npc.setNextAnimation(new Animation(829)); //eating 2 rocktails at a time xd
            npc.heal(350);
        }
        if (Utils.getRandom(2) == 0) { // Range - Special Attack
            npc.setNextAnimation(new Animation(426)); //i know this is a dds special attack and he isn't wearing it...
            npc.setNextGraphics(new Graphics(1099, 0, 150)); //don't make it hit higher then 300, could end very very badly
            World.sendProjectile(player, target, 1099, 41, 16, 31, 35, 16, 0);
            World.sendProjectile(player, target, 1099, 41, 16, 25, 35, 21, 0);
            npc.playSound(2537, 1);
            for (Entity t : npc.getPossibleTargets()) {
                delayHit(
                        npc,
                        1,
                        target,
                        getMeleeHit(
                                npc,
                                getRandomMaxHit(npc, 345,
                                        NPCCombatDefinitions.RANGE, target)),
                        getMeleeHit(
                                npc,
                                getRandomMaxHit(npc, 345,
                                        NPCCombatDefinitions.RANGE, target)));
            }
        } else { // Melee - Whip Attack
            npc.setNextAnimation(new Animation(defs.getAttackEmote()));
            delayHit(
                    npc,
                    0,
                    target,
                    getRangeHit(
                            npc,
                            getRandomMaxHit(npc, defs.getMaxHit(),
                                    NPCCombatDefinitions.RANGE, target)));
        }
        return defs.getAttackDelay();
    }
}

每当我尝试在 Java 中使用此代码进行编译时,都会收到错误消息:

src\com\rs\game\npc\combat\impl\RangerCombat.java:54: error: cannot find symbol
World.sendProjectile(***player***, target, 1099, 41, 16, 35, 16, 0);

symbol: variable player
location: Class RangerCombat

对此的任何帮助将不胜感激。提前致谢

4

1 回答 1

0

您没有player在发布的代码中的任何地方设置变量,这也是编译器告诉您的。

在您调用的此类/方法中适当地设置播放器World.sendProjectile(),构造一个新的player或发布您已经执行此操作的代码。

于 2013-07-28T20:49:46.327 回答