mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-21 09:02:07 -07:00
Enabled randoms with toggle to turn them off
This commit is contained in:
parent
126e055132
commit
a5be2de747
5 changed files with 81 additions and 8 deletions
|
|
@ -24,6 +24,11 @@ public final class AntiMacroHandler implements SavingModule {
|
|||
*/
|
||||
private static final int UPDATE_FREQUENCY = 50;
|
||||
|
||||
/**
|
||||
* Whether randoms are disabled for this player
|
||||
*/
|
||||
public boolean isDisabled;
|
||||
|
||||
/**
|
||||
* The ratio of firing events, the higher the less frequent.
|
||||
*/
|
||||
|
|
@ -52,7 +57,7 @@ public final class AntiMacroHandler implements SavingModule {
|
|||
/**
|
||||
* The experience monitors.
|
||||
*/
|
||||
private ExperienceMonitor[] monitors = new ExperienceMonitor[Skills.SKILL_NAME.length];
|
||||
public ExperienceMonitor[] monitors = new ExperienceMonitor[Skills.SKILL_NAME.length];
|
||||
|
||||
/**
|
||||
* The chance ratio of firing random events.
|
||||
|
|
@ -120,8 +125,8 @@ public final class AntiMacroHandler implements SavingModule {
|
|||
}
|
||||
if (!player.getLocks().isInteractionLocked() && !player.getLocks().isTeleportLocked() && !player.getLocks().isMovementLocked()) {
|
||||
for (int i = 0; i < monitors.length; i++) {
|
||||
FIRE_RATIO = 250;
|
||||
if (chanceRatio[i] > FIRE_RATIO) {
|
||||
FIRE_RATIO = 1;
|
||||
if (chanceRatio[i] > FIRE_RATIO && !isDisabled) {
|
||||
fireEvent(i);
|
||||
}
|
||||
ExperienceMonitor monitor = monitors[i];
|
||||
|
|
@ -162,10 +167,17 @@ public final class AntiMacroHandler implements SavingModule {
|
|||
for (int i = 0; i < monitors.length; i++) {
|
||||
monitors[i] = new ExperienceMonitor(i);
|
||||
}
|
||||
nextPulse = GameWorld.getTicks() + UPDATE_FREQUENCY;
|
||||
if(isDisabled){
|
||||
nextPulse = -1;
|
||||
} else {
|
||||
nextPulse = GameWorld.getTicks() + UPDATE_FREQUENCY;
|
||||
}
|
||||
if (event != null) {
|
||||
event.start(player, true);
|
||||
}
|
||||
if(!player.isArtificial() && !isDisabled) {
|
||||
System.out.println("Anti-Macro: Initialized anti-macro handler for " + player.getUsername());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -249,6 +261,7 @@ public final class AntiMacroHandler implements SavingModule {
|
|||
event = getRandomEvent(skillId);
|
||||
if (event != null) {
|
||||
if ((event = event.create(player)).start(player, false, args)) {
|
||||
System.out.println("Anti-Macro: Firing event " + event.getName() + " for player: " + player.getUsername());
|
||||
resetTrigger();
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -214,6 +214,7 @@ public final class Skills {
|
|||
boolean hadMax = this.experience[slot] != 200000000;
|
||||
final double experienceAdd = (int) (experience * mod);
|
||||
this.experience[slot] += experienceAdd;
|
||||
player.getAntiMacroHandler().monitors[slot].setExperienceAmount((int)experienceAdd);
|
||||
if (this.experience[slot] > 200000000) {
|
||||
if(hadMax && !player.isArtificial()){
|
||||
Repository.sendNews(entity.asPlayer().getUsername()+" has just reached 200m experience in " + SKILL_NAME[slot] + "!");
|
||||
|
|
@ -236,6 +237,9 @@ public final class Skills {
|
|||
lifepoints += amount;
|
||||
}
|
||||
staticLevels[slot] = newLevel;
|
||||
if(newLevel == 99 && !player.isArtificial()){
|
||||
Repository.sendNews(entity.asPlayer().getUsername() + " has just achieved level 99 " + SKILL_NAME[slot]);
|
||||
}
|
||||
if (entity instanceof Player) {
|
||||
if (updateCombatLevel()) {
|
||||
player.getUpdateMasks().register(new AppearanceFlag(player));
|
||||
|
|
|
|||
|
|
@ -354,10 +354,12 @@ public class Player extends Entity {
|
|||
|
||||
@Override
|
||||
public void init() {
|
||||
if (!isArtificial()) {
|
||||
antiMacroHandler.isDisabled = savedData.getGlobalData().getMacroDisabled();
|
||||
if (!artificial) {
|
||||
getProperties().setSpawnLocation(ServerConstants.HOME_LOCATION);
|
||||
getDetails().getSession().setObject(this);
|
||||
getDetails().getSession().setLastPing(System.currentTimeMillis() + 10_000L);
|
||||
antiMacroHandler.init();
|
||||
}
|
||||
super.init();
|
||||
LoginConfiguration.configureLobby(this);
|
||||
|
|
|
|||
|
|
@ -301,7 +301,11 @@ public final class GlobalData implements SavingModule {
|
|||
private int hunterCapeCharges;
|
||||
|
||||
private long minigameTeleportDelay;
|
||||
|
||||
|
||||
/**
|
||||
* Whether or not randoms are enabled
|
||||
*/
|
||||
private boolean macroDisabled = false;
|
||||
|
||||
@Override
|
||||
public void save(ByteBuffer buffer) {
|
||||
|
|
@ -392,6 +396,7 @@ public final class GlobalData implements SavingModule {
|
|||
SavedData.save(buffer, getSavedH(), 63);
|
||||
SavedData.save(buffer, getTaskAmount(), 64);
|
||||
SavedData.save(buffer, getTaskPoints(), 65);
|
||||
SavedData.save(buffer, macroDisabled,66);
|
||||
buffer.put((byte) 0);
|
||||
}
|
||||
|
||||
|
|
@ -624,6 +629,9 @@ public final class GlobalData implements SavingModule {
|
|||
case 65:
|
||||
setTaskPoints(buffer.getInt());
|
||||
break;
|
||||
case 66:
|
||||
macroDisabled = SavedData.getBoolean(buffer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1628,4 +1636,8 @@ public final class GlobalData implements SavingModule {
|
|||
public void setTaskPoints(int taskPoints) {
|
||||
this.taskPoints = taskPoints;
|
||||
}
|
||||
|
||||
public void setMacroDisabled(boolean disabled){this.macroDisabled = disabled;}
|
||||
|
||||
public boolean getMacroDisabled() {return this.macroDisabled;}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ public final class HansDialoguePlugin extends DialoguePlugin {
|
|||
stage = 50;
|
||||
break;
|
||||
case 4:
|
||||
interpreter.sendOptions("Select an Option", "Have you been here as long as me?", "I'd like to learn faster!", "About Iron Man mode...", "Go Back...");
|
||||
interpreter.sendOptions("Select an Option", "Have you been here as long as me?", "I'd like to learn faster!", "About Iron Man mode...","About random events...", "Go Back...");
|
||||
stage = 10;
|
||||
break;
|
||||
}
|
||||
|
|
@ -106,7 +106,17 @@ public final class HansDialoguePlugin extends DialoguePlugin {
|
|||
stage = 110;
|
||||
}
|
||||
break;
|
||||
case 4: // Go back
|
||||
case 4:
|
||||
if(player.getAntiMacroHandler().isDisabled == true){
|
||||
interpreter.sendOptions("Select an Option","I want to enable random events.","Nevermind.");
|
||||
stage = 130;
|
||||
break;
|
||||
} else {
|
||||
interpreter.sendOptions("Select an Option","I want to disable random events.","Nevermind.");
|
||||
stage = 135;
|
||||
break;
|
||||
}
|
||||
case 5: // Go back
|
||||
interpreter.sendOptions("Select an Option", "I'm looking for whoever is in charge of this place.", "I have come to kill everyone in this castle!", "I don't know. I'm lost. Where am I?", "More Options...");
|
||||
stage = 1;
|
||||
break;
|
||||
|
|
@ -242,6 +252,38 @@ public final class HansDialoguePlugin extends DialoguePlugin {
|
|||
}
|
||||
break;
|
||||
|
||||
case 130:
|
||||
switch(buttonId){
|
||||
case 1:
|
||||
npc("Voila, you should now get random events!");
|
||||
player.getGlobalData().setMacroDisabled(false);
|
||||
player.getAntiMacroHandler().isDisabled = false;
|
||||
player.getAntiMacroHandler().init();
|
||||
stage = 131;
|
||||
break;
|
||||
case 2:
|
||||
player("Never mind.");
|
||||
stage = 131;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 131:
|
||||
end();
|
||||
break;
|
||||
case 135:
|
||||
switch(buttonId){
|
||||
case 1:
|
||||
npc("Voila, you shouldn't get random events now!");
|
||||
player.getGlobalData().setMacroDisabled(true);
|
||||
player.getAntiMacroHandler().isDisabled = true;
|
||||
stage = 131;
|
||||
break;
|
||||
case 2:
|
||||
player("Never mind.");
|
||||
stage = 131;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
//Change Iron man mode dialogue/code
|
||||
case 150:
|
||||
switch(buttonId){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue