Jump to content

Featured Replies

Posted
comment_100488
package com.deathwish.world.entity.impl.player.bot.type;


import com.deathwish.model.Animation;
import com.deathwish.model.Flag;
import com.deathwish.model.Item;
import com.deathwish.model.Skill;
import com.deathwish.model.container.impl.Equipment;
import com.deathwish.model.definitions.WeaponAnimations;
import com.deathwish.model.definitions.WeaponInterfaces;
import com.deathwish.util.Misc;
import com.deathwish.world.content.BonusManager;
import com.deathwish.world.content.clan.ClanChatManager;
import com.deathwish.world.content.combat.CombatFactory;
import com.deathwish.world.content.combat.weapon.FightType;
import com.deathwish.world.content.skill.SkillManager;
import com.deathwish.world.content.skill.impl.slayer.SlayerMaster;
import com.deathwish.world.content.transportation.TeleportHandler;
import com.deathwish.world.content.transportation.TeleportType;
import com.deathwish.world.entity.impl.npc.NPC;

public class SlayerBot extends com.deathwish.world.entity.impl.player.bot.Bot {
    
    private NPC target;
    
    public SlayerBot(String username, String password) {
        super(username, password);
    }
    
    
    
    @Override
    public void onLogin() {
        setTotalPlayTime(1000_000);
        setPlayerLocked(false);
        setHidePlayer(false);
        getSlayer().doubleSlayerXP = true;
        int[][] data = {
                {Equipment.FEET_SLOT,  12708},
                {Equipment.HANDS_SLOT, 7462}
                
        };
        for(int i = 0; i < data.length; i++) {
            this.getEquipment().set(data[i][0], new Item(data[i][1]));
        }
        int index = Misc.exclusiveRandom(4);
        switch(index) {
        case 0:
            this.getEquipment().set(Equipment.HEAD_SLOT, new Item(10828));
            this.getEquipment().set(Equipment.CAPE_SLOT, new Item(4373));
            this.getEquipment().set(Equipment.AMULET_SLOT, new Item(1712));
            this.getEquipment().set(Equipment.BODY_SLOT, new Item(10564));
            this.getEquipment().set(Equipment.LEG_SLOT, new Item(4087));
            this.getEquipment().set(Equipment.WEAPON_SLOT, new Item(4151));
            this.getEquipment().set(Equipment.SHIELD_SLOT, new Item(6524));
            this.getEquipment().set(Equipment.RING_SLOT, new Item(2572));
            setFightType(FightType.WHIP_LASH);
            break;
        case 1:
            this.getEquipment().set(Equipment.HEAD_SLOT, new Item(3749));
            this.getEquipment().set(Equipment.CAPE_SLOT, new Item(4373));
            this.getEquipment().set(Equipment.AMULET_SLOT, new Item(1712));
            this.getEquipment().set(Equipment.BODY_SLOT, new Item(2503));
            this.getEquipment().set(Equipment.LEG_SLOT, new Item(2497));
            this.getEquipment().set(Equipment.AMMUNITION_SLOT, new Item(9245, 2000000000));
            this.getEquipment().set(Equipment.WEAPON_SLOT, new Item(9185));
            this.getEquipment().set(Equipment.SHIELD_SLOT, new Item(6524));
            this.getEquipment().set(Equipment.RING_SLOT, new Item(2572));
            this.setFightType(FightType.CROSSBOW_RAPID);
            break;
        case 2:
            this.getEquipment().set(Equipment.HEAD_SLOT, new Item(1163));
            this.getEquipment().set(Equipment.CAPE_SLOT, new Item(4373));
            this.getEquipment().set(Equipment.AMULET_SLOT, new Item(6585));
            this.getEquipment().set(Equipment.BODY_SLOT, new Item(1127));
            this.getEquipment().set(Equipment.LEG_SLOT, new Item(1079));
            this.getEquipment().set(Equipment.WEAPON_SLOT, new Item(4151));
            this.getEquipment().set(Equipment.SHIELD_SLOT, new Item(13262));
            this.getEquipment().set(Equipment.RING_SLOT, new Item(2570));
            setFightType(FightType.WHIP_LASH);
            break;
        case 3:
            this.getEquipment().set(Equipment.HEAD_SLOT, new Item(13263));
            this.getEquipment().set(Equipment.CAPE_SLOT, new Item(4373));
            this.getEquipment().set(Equipment.AMULET_SLOT, new Item(1725));
            this.getEquipment().set(Equipment.BODY_SLOT, new Item(10551));
            this.getEquipment().set(Equipment.LEG_SLOT, new Item(11726));
            this.getEquipment().set(Equipment.WEAPON_SLOT, new Item(11730));
            this.getEquipment().set(Equipment.RING_SLOT, new Item(2570));
            setFightType(FightType.TWOHANDEDSWORD_SLASH);
            break;
        }
        WeaponAnimations.update(this);
        WeaponInterfaces.assign(this, this.getEquipment().get(Equipment.WEAPON_SLOT));
        this.getUpdateFlag().flag(Flag.APPEARANCE);
        this.getEquipment().refreshItems();
        BonusManager.update(this);
        
        int stat = Misc.getRandom(24);
        int[][] stats = new int[][]{
            {Skill.ATTACK.ordinal(), 75 +(Misc.getRandom(stat))},
            {Skill.DEFENCE.ordinal(), 75 +(Misc.getRandom(stat))},
            {Skill.STRENGTH.ordinal(), 75  +(Misc.getRandom(stat))},
            {Skill.CONSTITUTION.ordinal(), 400 +(Misc.getRandom(470))},
            {Skill.RANGED.ordinal(), 75 +(Misc.getRandom(stat))},
            {Skill.PRAYER.ordinal(), 10 +(Misc.getRandom(77))},
            {Skill.MAGIC.ordinal(), 75 +(Misc.getRandom(stat))},
            {Skill.SLAYER.ordinal(), 1  +(Misc.getRandom(98))},
        };
        for(int i = 0; i < stats.length; i++) {
            Skill skill = Skill.forId(stats[i][0]);
            int level = stats[i][1];
            this.getSkillManager().setCurrentLevel(skill, level).setMaxLevel(skill, level).setExperience(skill, SkillManager.getExperienceForLevel(level));
        };

        // Voer hier je gewenste acties uit na de switch-case en if-voorwaarde
        newTask();
    }
    
    private void newTask() {
        int slayLevel = getSkillManager().getMaxLevel(Skill.SLAYER);

        switch (slayLevel) {
            case 1:
                getSlayer().setSlayerMaster(SlayerMaster.VANNAKA);
                break;
            default:
                if (slayLevel < 15) {
                    getSlayer().setSlayerMaster(SlayerMaster.CHAELDAR);
                }
                if (slayLevel < 50) {
                    getSlayer().setSlayerMaster(SlayerMaster.DURADEL);
                }
                if (slayLevel < 80) {
                    getSlayer().setSlayerMaster(SlayerMaster.KURADEL);
                }
                if (slayLevel < 92) {
                    getSlayer().setSlayerMaster(SlayerMaster.SUMONA);
                }
                break;
        }
        this.getSlayer().assignTask();
        this.getPacketSender().sendInterfaceRemoval();
        TeleportHandler.teleportPlayer(this, this.getSlayer().getSlayerTask().getTaskPosition(), TeleportType.RING_TELE);
        ClanChatManager.sendMessage(this, "New Slayer Task: " + this.getSlayer().getSlayerTask() + " Amount: " + this.getSlayer().getAmountToSlay());
        this.heal(200);
    }

    @Override
    public void onProcess() {
        if(this.getPosition() != this.getSlayer().getSlayerTask().getTaskPosition()) {
            BotGearClass.getRandomSet();
        }
        if(this.getSkillManager().getCurrentLevel(Skill.CONSTITUTION) <= 500) {
            heal(750);
            performAnimation(new Animation(401));
            if(target != null ) {
            this.getCombatBuilder().attack(target);
            return;
        }
    }    
        if(this.getSlayer().getAmountToSlay() == 0) {
            newTask();
            if(target != null ) {
            this.getCombatBuilder().attack(target);
            return;
        }
    }
        
        if(!getCombatBuilder().isAttacking() && !getCombatBuilder().isBeingAttacked()) {
                for(NPC n : getLocalNpcs()) {
                    if(n == null) {
                        continue;
                    }
                    if(n.getDefinition().getId() == this.getSlayer().getSlayerTask().getNpcId()) {
                        if(!n.getCombatBuilder().isBeingAttacked() && !n.getCombatBuilder().isAttacking()) {
                            if(CombatFactory.checkHook(this, n)) {
                            getCombatBuilder().attack(n);
                            //System.out.println(this.getSlayer().getAmountToSlay()  + " " + this.getSlayer().getSlayerTask() +" for player "+ this.getUsername());
                            target = n;
                            break;
                            }
                        }
                    }
                }
            }
        }
    }


 

  • 2 weeks later...

Create an account or sign in to comment