Class Combat
java.lang.Object
privbot.hooks.Combat
- All Implemented Interfaces:
CombatCollision.Source
Thread-safe combat reads and player/spec interactions for scripts.
Use via PrivContext.combat (ctx.combat). It keeps the behavior of the
older combat helper it replaces (SpawnPK spec bar, Orion spec orb dispatch, Roat attack row, etc.).
Special attack orb dispatch is server-specific:
- Orion:
CC_OP,identifier=1, packed widgetparam1=38862884. - Impact: widget
12311, toggled through the client's own special attack control. - Default / SpawnPK:
WIDGET_TYPE_1,param1=12311. - RoatPkz:
WIDGET_TYPE_1,param1=7537.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanArms the special attack orb unless it already reads armed.booleanactivateSpecialAttackWithImpactFallback(int impactWidgetFallback) Arms the current Impact special orb, using the supplied weapon widget only if the live holder has not populated its active-row field yet.booleanAttacks the loaded player whose name equalsplayerName(ignore case).booleanattackPlayer(String playerName) booleanattackPlayer(net.runelite.api.Player target) booleanCasts Vengeance (Lunar spellbook; by name through the spellbook on Elorin).corridor()One immutable collision read from the local player's tile, reusable for every candidate NPC of one decision.booleanDisarms the special attack orb when it reads armed.intZero-based selected attack style; -1 means unavailable, never a guessed default.net.runelite.api.ActorintintintSpecial attack energy 0–100 (SpawnPK widget path when applicable, else adapter).intDeprecated.booleanhasEnoughSpecialEnergy(int requiredPercentage) booleanbooleanisPlayerValid(net.runelite.api.Player target) booleanSame asisSpecialAttackEnabled()— name aligned with the olderisSpecialAttackActive().booleanWhether the spec orb is armed (varp on the client thread).intnpcSize(net.runelite.api.NPC npc) Current transformed footprint size; unavailable definitions conservatively use one tile.Whether the special attack orb is armed as anObserved:specialAttackArmedOrNull()with its null turned into UNREADABLE.Special attack energy 0–100 as anObserved:specialAttackPercentOrNull()with its null turned into UNREADABLE (never the 0getSpecialAttackPercent()answers for that).static intresolvePlayerMenuIndex(net.runelite.api.Client client, net.runelite.api.Player target) Resolves the menuidentifierindex for a player (list index first).booleansetAttackStyle(int index) Dispatch acceptance only.booleansetAutoRetaliate(boolean enabled) Whether the spec orb is armed, or null when it could not be read.Special attack energy 0–100, or null when it could not be read.booleanClicks the special attack orb once, whatever its state.booleanArms the orb unless armed, then re-reads it in the same client-thread call.
-
Method Details
-
getAttackStyle
public int getAttackStyle()Zero-based selected attack style; -1 means unavailable, never a guessed default. -
setAttackStyle
public boolean setAttackStyle(int index) Dispatch acceptance only. Open the combat tab first and re-read getAttackStyle afterwards. -
getAutoRetaliate
- Returns:
- whether auto retaliate is on; null when it cannot be read
-
setAutoRetaliate
public boolean setAutoRetaliate(boolean enabled) - Parameters:
enabled- the wanted state- Returns:
- dispatch acceptance; re-read
getAutoRetaliate()
-
corridor
One immutable collision read from the local player's tile, reusable for every candidate NPC of one decision. It proves a conservative walls-only corridor, not that the server accepts the attack. Unreadable: the result hasCombatCollision.isAvailable()false and every check answers false or null (never throws). Thread: marshals its own client-thread read; call from the runner worker or a node.- Specified by:
corridorin interfaceCombatCollision.Source- Returns:
- the same object
collision()returns, typed as the public interface; never null
-
npcSize
public int npcSize(net.runelite.api.NPC npc) Current transformed footprint size; unavailable definitions conservatively use one tile. -
isInCombat
public boolean isInCombat()- Returns:
- the adapter's in-combat read; false when unreadable
-
getOpponentCurrentHp
public int getOpponentCurrentHp()- Returns:
- the opponent's current hitpoints from the adapter; 0 when unknown
-
getOpponentMaxHp
public int getOpponentMaxHp()- Returns:
- the opponent's maximum hitpoints from the adapter; 0 when unknown
-
getOpponentName
- Returns:
- the opponent's name, or ""
-
getSpecialAttackPercent
public int getSpecialAttackPercent()Special attack energy 0–100 (SpawnPK widget path when applicable, else adapter). -
getSpecialAttackPercentage
Deprecated.usegetSpecialAttackPercent()(orspecialAttackPercentOrNull()to tell 0 from "cannot read")Same asgetSpecialAttackPercent()— kept for callers migrating from the older namegetSpecialAttackPercentage().- Returns:
- the same answer as
getSpecialAttackPercent()
-
isSpecialAttackEnabled
public boolean isSpecialAttackEnabled()Whether the spec orb is armed (varp on the client thread). Safe from script/task threads. -
isSpecialAttackActive
public boolean isSpecialAttackActive()Same asisSpecialAttackEnabled()— name aligned with the olderisSpecialAttackActive(). -
specialAttackPercentOrNull
Special attack energy 0–100, or null when it could not be read.getSpecialAttackPercent()cannot say "unknown": it answers 0 for a failed read too, and on Impact, Elorin and SpawnPK a raw varp read also answers 0 when it cannot read. A caller that must not act on a read that never happened (an arm click is a toggle) uses this instead. A readable answer always equalsgetSpecialAttackPercent()'s. -
specialAttackArmedOrNull
Whether the spec orb is armed, or null when it could not be read. The same contract asspecialAttackPercentOrNull(). -
hasEnoughSpecialEnergy
public boolean hasEnoughSpecialEnergy(int requiredPercentage) - Parameters:
requiredPercentage- energy needed, 0..100- Returns:
- whether
getSpecialAttackPercent()reaches it (an unreadable 0 reads as not enough)
-
toggleSpecialAttack
public boolean toggleSpecialAttack()Clicks the special attack orb once, whatever its state.- Returns:
- dispatch acceptance
-
activateSpecialAttack
public boolean activateSpecialAttack()Arms the special attack orb unless it already reads armed.- Returns:
- dispatch acceptance (true also when already armed)
-
activateSpecialAttackWithImpactFallback
public boolean activateSpecialAttackWithImpactFallback(int impactWidgetFallback) Arms the current Impact special orb, using the supplied weapon widget only if the live holder has not populated its active-row field yet. Other servers ignore the Impact fallback. -
tryArmSpecialAttackOrb
public boolean tryArmSpecialAttackOrb()Arms the orb unless armed, then re-reads it in the same client-thread call.- Returns:
- whether the orb reads armed afterwards
-
deactivateSpecialAttack
public boolean deactivateSpecialAttack()Disarms the special attack orb when it reads armed.- Returns:
- dispatch acceptance (true also when already disarmed)
-
attack
Attacks the loaded player whose name equalsplayerName(ignore case). Alias ofattackPlayer(String). -
attackPlayer
- Parameters:
playerName- the exact name of a loaded player- Returns:
- dispatch acceptance; false when no loaded player has that name
-
attackPlayer
public boolean attackPlayer(net.runelite.api.Player target) - Parameters:
target- a loaded player- Returns:
- dispatch acceptance
-
isPlayerValid
public boolean isPlayerValid(net.runelite.api.Player target) - Parameters:
target- a player object- Returns:
- whether it is still in the client's loaded player list
-
resolvePlayerMenuIndex
public static int resolvePlayerMenuIndex(net.runelite.api.Client client, net.runelite.api.Player target) Resolves the menuidentifierindex for a player (list index first). -
getCurrentTarget
public net.runelite.api.Actor getCurrentTarget()- Returns:
- who the local player is interacting with, or null (also when unreadable: see
ctx.player.interacting())
-
castVengeance
public boolean castVengeance()Casts Vengeance (Lunar spellbook; by name through the spellbook on Elorin).- Returns:
- dispatch acceptance
-
observedSpecialAttackPercent
Special attack energy 0–100 as anObserved:specialAttackPercentOrNull()with its null turned into UNREADABLE (never the 0getSpecialAttackPercent()answers for that).- Returns:
- the energy, or UNREADABLE
-
observedSpecialAttackArmed
Whether the special attack orb is armed as anObserved:specialAttackArmedOrNull()with its null turned into UNREADABLE. Arming is a toggle: never click it on an unreadable answer.- Returns:
- TRUE / FALSE, or UNREADABLE
-
getSpecialAttackPercent()(orspecialAttackPercentOrNull()to tell 0 from "cannot read")