Post: [PI] Better Restore Special Attack Handling
03-09-2015, 10:29 PM #1
Stunz
Former Staff
(adsbygoogle = window.adsbygoogle || []).push({});
This is a better way to handle restore spec - first off go to player.java and add this
    public boolean isRestoringSpec = false;


then go to combatAssistand and search for this: (should be in the attackPlayer method)
    if (c.getCombat().checkSpecAmount(c.playerEquipment[c.playerWeapon])) {
c.lastArrowUsed = c.playerEquipment[c.playerArrows];
c.getCombat().activateSpecial(
c.playerEquipment[c.playerWeapon], i);
c.followId = c.playerIndex;


under that add this:
    						if(!c.isRestoringSpec){
RestoreSpecialAttack.execute(c);
}


then look for: (should be in attackNpc method)
    if(c.getCombat().checkSpecAmount(c.playerEquipment[c.playerWeapon])){
c.lastWeaponUsed = c.playerEquipment[c.playerWeapon];
c.lastArrowUsed = c.playerEquipment[c.playerArrows];
c.getCombat().activateSpecial(c.playerEquipment[c.playerWeapon], i);


under it add
    						if(!c.isRestoringSpec){
RestoreSpecialAttack.execute(c);
}


now go to client and find this:
    public void initialize() {

under it add this
    		if(this.specAmount < 10){
RestoreSpecialAttack.execute(this);
}

Now you can remove all the restore special attack in process()
now in players folder make a new folder called content and make a class called RestoreSpecialAttack and add this
    package org.rs2server.entity.players.content;

import org.rs2server.entity.players.*;
import org.rs2server.event.*;

public class RestoreSpecialAttack {

public static void execute(final Client player){
player.isRestoringSpec = true;
CycleEventHandler.getSingleton().addEvent(player, new CycleEvent() {
@Override
public void execute(CycleEventContainer container) {
if (player.specAmount < 10) {
player.specAmount += 1;
if (player.specAmount > 10) {
player.specAmount = 10;
container.stop();
}
player.getItems().addSpecialBar(player.playerEquipment[player.playerWeapon]);
}
}
@Override
public void stop() {
player.isRestoringSpec = false;
}
}, 29);
}
}


Remember to change all your imports
(adsbygoogle = window.adsbygoogle || []).push({});

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo