Class Combat


  • public class Combat
    extends java.lang.Object
    The Combat class handles various combat-related actions and checks for the player. It allows querying the player's combat status, special attack energy, health, attack style, and provides functionality to interact with NPCs and use specific combat features like special attacks.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Combat.AttackStyle
      Enum for handling different player attack styles and their corresponding widgets.
    • Constructor Summary

      Constructors 
      Constructor Description
      Combat()  
    • Constructor Detail

      • Combat

        public Combat()
    • Method Detail

      • isRetaliating

        public boolean isRetaliating()
        Checks if the player has auto-retaliate enabled. Auto-retaliate makes the player automatically attack enemies that attack them.
        Returns:
        true if auto-retaliate is enabled, false otherwise.
      • isPoisoned

        public boolean isPoisoned()
        Checks if the player is poisoned. Poisoning gradually reduces the player's health.
        Returns:
        true if poisoned, false otherwise.
      • isVenomed

        public boolean isVenomed()
        Checks if the player is venomed. Venom is a stronger form of poisoning and can rapidly drain the player's health.
        Returns:
        true if venomed, false otherwise.
      • isSpecEnabled

        public boolean isSpecEnabled()
        Checks if special attack mode is enabled. Special attacks are powerful abilities that consume a portion of the special energy.
        Returns:
        true if special attack is enabled, false otherwise.
      • getSpecEnergy

        public int getSpecEnergy()
        Retrieves the current special attack energy as a percentage. Special attack energy is used to perform special attacks and regenerates over time.
        Returns:
        special attack energy as an integer percentage.
      • isAntifired

        public boolean isAntifired()
        Checks if the player has antifire protection. Antifire protection reduces damage taken from fire-based attacks.
        Returns:
        true if antifire protection is active, false otherwise.
      • isSuperAntifired

        public boolean isSuperAntifired()
        Checks if the player has super antifire protection. Super antifire protection provides stronger resistance to fire-based attacks.
        Returns:
        true if super antifire protection is active, false otherwise.
      • setAttackStyle

        public void setAttackStyle​(Combat.AttackStyle attackStyle)
        Sets the player's attack style to the desired one.
        Parameters:
        attackStyle - The desired attack style to set.
      • getAttackStyle

        public Combat.AttackStyle getAttackStyle()
        Gets the player's current attack style based on the game setting.
        Returns:
        the current AttackStyle.
      • specialEnabled

        public boolean specialEnabled()
        Checks if special attack is currently enabled.
        Returns:
        true if enabled, false otherwise.
      • enableSpecial

        public void enableSpecial()
        Enables special attack mode if it is not currently enabled.
      • getCurrentHealth

        public int getCurrentHealth()
        Gets the player's current health (hitpoints).
        Returns:
        the current health level.
      • getMissingHealth

        public int getMissingHealth()
        Calculates the difference between real and boosted health.
        Returns:
        the amount of missing health.
      • getHealthPercent

        public double getHealthPercent()
        Gets the player's current health as a percentage of maximum health.
        Returns:
        health percentage.
      • inCombat

        public boolean inCombat()
        Checks if the player is currently in combat.
        Returns:
        true if in combat, false otherwise.
      • isAttacking

        public boolean isAttacking​(KSNPC npc)
        Check if player is attacking specific NPC
        Returns:
        true if attacking specific NPC, false otherwise
      • getAttackableNPC

        public NPCQuery getAttackableNPC​(java.lang.String... names)
        Searches for an attackable NPC by name. If no NPC is found interacting with the player, it searches for any alive NPC with the specified name.
        Parameters:
        names - The names of the NPCs to search for.
        Returns:
        the found NPC or null if no match is found.
      • getAttackableNPC

        public NPCQuery getAttackableNPC​(int... ids)
        Searches for an attackable NPC by ID. If no NPC is found interacting with the player, it searches for any alive NPC with the specified ID.
        Parameters:
        ids - The IDs of the NPCs to search for.
        Returns:
        the found NPC or null if no match is found.