Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Find if a player is wearing a specific cape?


    Before

    Recommended Posts

    Posted

    I'm trying to write a Castle Wars script now that CWars is available to F2P, but I'm having a difficult time trying to find if a player is on the enemy team. The only way to do that is to tell if they're wearing a cape that's not the same as yours, but I'm unsure how I would do that.

     

    Any advice?

     

    ---

     

    Also, I'm a shit scripter. If anyone else was thinking about writing this script, I can show you what I have and you would probably do better at writing it. I just wanna see it happen (fuck it I'd pay money for this script I just wanna see it happen)

     

     

    edit: I'll post the code I have after like 2 hours. If anyone wants to adopt this LMK so I stop wasting my time writing useless code.

     

     

    import org.dreambot.api.methods.map.Area;
    import org.dreambot.api.methods.map.Tile;
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.wrappers.interactive.GameObject;
    import org.dreambot.api.wrappers.interactive.Player;
    
    import java.awt.*;
    import java.util.Random;
    import java.util.Timer;
    import javax.imageio.ImageIO;
    
    @ScriptManifest(category = Category.MINIGAME, name = "F2P Castle Wars Script", author = "B4", version = 0.0)
    public class main extends AbstractScript
    {
        public Area banklobby = new Area(2436,3099,2443,3082,0);
        public Area inlobby = new Area(2391,9482,2370,9496,0);
    
        public Area SaradominSpawn = new Area(2431,3072,2423,3080,1);
        public Area firstFloor = new Area(2431,3083,2420,3072,1);
        public Area groundFloor = new Area(2431,3072,2417,3086,0);
    
        public GameObject southBarrier = getGameObjects().getTopObjectOnTile(new Tile(2422,3076,1));
    
        Random Rand = new Random();
        private Timer timeRan;
    
    
        public enum scriptState{
            INGAME, INLOBBY, BANKLOBBY, LOSTINOVERWORLD
        }
        public scriptState SCRIPTSTATE;
        public enum gameState {
            RESPAWNROOM, FIRSTFLOOR, GROUNDFLOOR, ATTACKINGBARRICADE, NOTINGAME
        }
        public gameState GAMESTATE;
    
        @Override
        public int onLoop() {
            SCRIPTSTATE = getScriptState();
            GAMESTATE = getGameState();
    
            if (getGameObjects().closest(o -> getLocalPlayer().distance(o) < 2 && o.getName().equals("Barricade")))
            {
    
            }
    
            if (SCRIPTSTATE == scriptState.INGAME)
            {
                playGame();
            }
            else if (SCRIPTSTATE == scriptState.INLOBBY)
            {
                idleInLobby();
            }
            else if (SCRIPTSTATE == scriptState.BANKLOBBY)
            {
                bankLobby();
            }
            else
            {
                teleportToCastleWars();
            }
    
            return Rand.nextInt(600)+Rand.nextInt(600);
        }
    
        public void interactWithObject(GameObject object, int attempt)
        {
            if (attempt <= 0)
            {
                return;
            }
    
            if(getMap().canReach(object))
            {
                if (object.isOnScreen())
                {
                    object.interact();
                }
            }
            else
            {
                getWalking().walk(object);
                sleepUntil(() -> object.isOnScreen(), 6000+Rand.nextInt(5000));
                interactWithObject(object, attempt-1);
            }
        }
    
        public scriptState getScriptState()
        {
    
        }
    
        public gameState getGameState()
        {
    
        }
    
        public void playGame()
        {
            if (GAMESTATE == gameState.RESPAWNROOM)
            {
                respawnRoom();
            }
            else if (GAMESTATE == gameState.FIRSTFLOOR)
            {
                firstFloor();
            }
            else if (GAMESTATE == gameState.GROUNDFLOOR)
            {
                groundFloor();
            }
        }
    
        public void respawnRoom()
        {
            if (!getInventory().isFull())
            {
                GameObject table = getGameObjects().closest(o -> o.getName().equals("Table") && o.hasAction("Take-5") && o != null);
                table.interact("Take-5");
                respawnRoom();
            }
            interactWithObject(southBarrier, 1);
        }
    
        public void firstFloor()
        {
            if (getMap().canReach(southStairs))
            {
                interactWithObject(southStairs, 1);
            }
            else
            {
                if(getMap().canReach(eastLadder))
                {
                    interactWithObject(eastLadder, 1);
                }
            }
        }
    
        public void groundFloor()
        {
            Player enemy = findEnemy();
            if (enemy != null)
            {
                enemy.interact("Attack");
            }
            else
            {
                getWalking().walk(groundFloor.getRandomTile());
            }
        }
    
        public Player findEnemy()
        {
            getPlayers().closest(o -> getMap().canReach(o) && o.HASZAMORAKIAMCAPE);
        }
    
        @Override
        public void onPaint(Graphics2D g) {
            Font font = new Font("Times new roamn", Font.PLAIN, 19);
            g.setFont(font);
            g.setColor(Color.BLACK);
    
            g.drawString("" + timeRan.toString(), 121, 371);
            g.drawString("" + SCRIPTSTATE, 121, 391);
            g.drawString("" + GAMESTATE, 121, 411);
        }
    
    }
     

     

     

     

    edit2: Noodles has a Castle Wars script here: https://dreambot.org/forums/index.php/topic/10996-noodle-castle-wars-advanced-anti-ban-free-supports-all-factions-flawless-tickets/ It requires VIP tho

    Posted

    It may be easier to check if a player has the Attack option instead of going through the equipment they are wearing and looking for a specific cape. You should ask @Nex how he does it.

    Posted

    Oh it does just AFK lol. I might make a CW script that actually fights then XD

    Yo I'll help you if you do. I can post what I've got so far after 2 hrs of struggling. It's a pretty good core I think, but I know everyone has different style

    Posted

    Yo I'll help you if you do. I can post what I've got so far after 2 hrs of struggling. It's a pretty good core I think, but I know everyone has different style

    It will actually be a while before I start unfortunately. I am going to be moving on Monday and I'll be packing over the weekend. It will be at least a week before I start.

    Posted

    Oh it does just AFK lol. I might make a CW script that actually fights then XD

     

    Noodle Boy already has one that fights, but I guess you can still make one. :P

    Posted
    getTeam()!= getLocalPlayer().getTeam()
    

    Thanks! Does your script support fighting or just afking?

     

    edit: O dam it does. I'm not VIP tho :( can you give me like a trial or does that not work for VIP scripts?

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.