Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.osbot.rs07.api.*;
- import org.osbot.rs07.api.filter.Filter;
- import org.osbot.rs07.api.map.Area;
- import org.osbot.rs07.api.model.GroundItem;
- import org.osbot.rs07.api.model.NPC;
- import org.osbot.rs07.api.model.Player;
- import org.osbot.rs07.api.ui.Skill;
- import org.osbot.rs07.api.ui.Tab;
- //Class used to, well, manage combat
- public class CombatManager {
- private String[] equipmentNames;
- private Player player;
- private Area a;
- private String[] lootables;
- private boolean lootingMode = false;
- public CombatManager(Player player, String[] equipment, Area area, String[] loot)
- {
- //For
- this.player = player;
- this.equipmentNames = equipment;
- this.a = area;
- this.lootables = loot;
- }
- public boolean IsInArea()
- {
- if (!a.contains(player))
- {
- return false;
- }
- else {
- return true;
- }
- }
- public void checkEquipped(Inventory inv, Equipment equip)
- {
- for (String x : equipmentNames)
- {
- if (inv.getItem(x) != null)
- {
- inv.getItem(x).interact();
- }
- }
- }
- public boolean LootableMode(GroundItem item)
- {
- boolean isLootable = false;
- for (String x : lootables)
- {
- if (x == item.getName())
- {
- isLootable = true;
- break;
- }
- }
- if(isLootable)
- {
- item.interact("Take");
- }
- return isLootable;
- }
- public void findNewTarget(NPCS npcs)
- {
- Filter<NPC> cowFilter = npc -> npc.getName().equalsIgnoreCase("Cow") &&
- npc.isAttackable() &&
- !npc.isUnderAttack() &
- npc.isVisible();
- NPC cow = npcs.closest(cowFilter);
- cow.interact("Attack");
- }
- public void changeAttackStyle(Tabs tabs, int style, Configs config, Widgets widget)
- {
- tabs.open(Tab.ATTACK);
- if(style != config.get(43) && tabs.isOpen(Tab.ATTACK))
- {
- switch (style) {
- case 0:
- widget.get(593, 4).interact();
- case 1:
- widget.get(593, 9).interact();
- case 2:
- widget.get(593,12).interact();
- case 3:
- widget.get(593, 17).interact();
- }
- }
- else if (!tabs.isOpen(Tab.ATTACK))
- {
- //if attack tab is not open, re-run function
- changeAttackStyle(tabs,style,config,widget);
- }
- }
- public boolean checkHealth(int threshold, Skills skills)
- {
- if (skills.getDynamic(Skill.HITPOINTS) <= threshold)
- {
- return true;
- }
- else {
- return false;
- }
- }
- }
- //Main Class Code (That is relevant to the error at hand)
- //Script uses skills as states to swap behaviors
- private Area lummyCows = new Area(3253,3255,3265,3296);
- private String[] gearNames = {"Bronze sword"};
- private String[] lootables = {"Cowhide"};
- private CombatManager cm = new CombatManager(myPlayer(),gearNames,lummyCows,lootables);
- /*
- * Blah Blah Blah
- * Other Code that I know works goes here
- *
- */
- else if (currState == Skill.ATTACK || currState == Skill.DEFENCE || currState == Skill.STRENGTH)
- {
- Tabs tabs = getTabs();
- Configs configs = getConfigs();
- Widgets widgets = getWidgets();
- boolean isLooting = cm.checkHealth(3, getSkills());
- if (cm.IsInArea())
- {
- cm.checkEquipped(getInventory(),getEquipment());
- if (currState == Skill.ATTACK)
- {
- cm.changeAttackStyle(tabs, 0, configs, widgets);
- }
- else if (currState == Skill.STRENGTH)
- {
- cm.changeAttackStyle(tabs, 1, configs, widgets);
- }
- else if (currState == Skill.DEFENCE)
- {
- cm.changeAttackStyle(tabs, 3, configs, widgets);
- }
- if (isLooting)
- {
- boolean foundItem = cm.LootableMode(getGroundItems().closest("Cowhide"));
- log("Found Cowhide Status: " + foundItem);
- }
- else
- {
- cm.findNewTarget(getNpcs());
- }
- }
- else
- {
- getWalking().webWalk(lummyCows);
- return random(1000,2500);
- }
- return random(500,1736);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement