Purpose: Wilderness levels that work.
Difficulty: Eh, depends on the person.
Assumed Knowledge: Basic fundamentals, and have a motivation to learn.
Server Base: Any server.
Classes Modified: Client class
Procedure
Step 1: Declare these methods.
Code:
public boolean CheckWildRange(int pcombat) {
client player = (client) server.playerHandler.players[playerId];
if (((player.combat + WildyLevel() >= pcombat) && (pcombat >= player.combat))
|| ((player.combat - WildyLevel() <= pcombat) && (pcombat <= player.combat))) {
return true;
} else {
return false;
}
}
public int WildyLevel() {
client player = (client) server.playerHandler.players[playerId];
return (((player.absX - 3330) / 8) + 1);
}
I returned the value of the wildylevel, so the server checks for it. Call it in process also.
Step 2: Put this statement into your attack packet.
Code:
if (!CheckWildRange(AttackingOn2.combat)) {
sendMessage("Level difference is too great, move to further wilderness.");
ResetAttack();
IsAttacking = false;
} else if (CheckWildRange(AttackingOn2.combat)) {
// your attacking code here
}
The above statements checks everytime you click the attack.
You can also put that into your attack method, but make sure the ResetAttack method isn't called inside of the statement. This is how.
Go to your attack method, and add this right below the GoodDistance statement.
Code:
if (!CheckWildRange(AttackingOn2.combat)) {
sendMessage("Level difference is too great, move to further wilderness.");
IsAttacking = false;
} else if (CheckWildRange(AttackingOn2.combat)) {
// your attacking code
}
Step 3: idkmybffjill
Credits: idkmybffjill