mirror of
https://github.com/moparisthebest/MoparClassic
synced 2024-12-21 15:08:50 -05:00
Closes issue #30.
This commit is contained in:
parent
9fdce3aeba
commit
46d13c60cf
@ -34,7 +34,6 @@ public final class DelayedEventHandler {
|
|||||||
events.addAll(toAdd);
|
events.addAll(toAdd);
|
||||||
toAdd.clear();
|
toAdd.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator<DelayedEvent> iterator = events.iterator();
|
Iterator<DelayedEvent> iterator = events.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
DelayedEvent event = iterator.next();
|
DelayedEvent event = iterator.next();
|
||||||
|
@ -32,7 +32,7 @@ import org.moparscape.msc.gs.util.Logger;
|
|||||||
* operation of the entire game.
|
* operation of the entire game.
|
||||||
*/
|
*/
|
||||||
public final class GameEngine extends Thread {
|
public final class GameEngine extends Thread {
|
||||||
|
|
||||||
private static Captcha captcha;
|
private static Captcha captcha;
|
||||||
/**
|
/**
|
||||||
* World instance
|
* World instance
|
||||||
@ -148,7 +148,8 @@ public final class GameEngine extends Thread {
|
|||||||
* Loads the packet handling classes from the persistence manager.
|
* Loads the packet handling classes from the persistence manager.
|
||||||
*/
|
*/
|
||||||
protected void loadPacketHandlers() {
|
protected void loadPacketHandlers() {
|
||||||
PacketHandlerDef[] handlerDefs = Instance.getDataStore().loadPacketHandlerDefs();
|
PacketHandlerDef[] handlerDefs = Instance.getDataStore()
|
||||||
|
.loadPacketHandlerDefs();
|
||||||
for (PacketHandlerDef handlerDef : handlerDefs) {
|
for (PacketHandlerDef handlerDef : handlerDefs) {
|
||||||
try {
|
try {
|
||||||
String className = handlerDef.getClassName();
|
String className = handlerDef.getClassName();
|
||||||
@ -169,25 +170,21 @@ public final class GameEngine extends Thread {
|
|||||||
clientUpdater.sendQueuedPackets();
|
clientUpdater.sendQueuedPackets();
|
||||||
long now = GameEngine.getTime();
|
long now = GameEngine.getTime();
|
||||||
if (now - lastSentClientUpdate >= 600) {
|
if (now - lastSentClientUpdate >= 600) {
|
||||||
if (now - lastSentClientUpdate >= 1000) {
|
|
||||||
// Logger.println("MAJOR UPDATE DELAYED: " + (now -
|
|
||||||
// lastSentClientUpdate));
|
|
||||||
}
|
|
||||||
lastSentClientUpdate = now;
|
lastSentClientUpdate = now;
|
||||||
clientUpdater.doMajor();
|
clientUpdater.doMajor();
|
||||||
}
|
}
|
||||||
if (now - lastSentClientUpdateFast >= 104) {
|
if (now - lastSentClientUpdateFast >= 104) {
|
||||||
if (now - lastSentClientUpdateFast >= 6000) {
|
|
||||||
// Logger.println("MINOR UPDATE DELAYED: " + (now -
|
|
||||||
// lastSentClientUpdateFast));
|
|
||||||
}
|
|
||||||
lastSentClientUpdateFast = now;
|
lastSentClientUpdateFast = now;
|
||||||
clientUpdater.doMinor();
|
clientUpdater.doMinor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private long lastEventTick;
|
||||||
private void processEvents() {
|
private void processEvents() {
|
||||||
eventHandler.doEvents();
|
if (getTime() - lastEventTick >= 100) {
|
||||||
|
eventHandler.doEvents();
|
||||||
|
lastEventTick = getTime();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DelayedEventHandler getEventHandler() {
|
public DelayedEventHandler getEventHandler() {
|
||||||
|
@ -47,6 +47,7 @@ public class DuelEvent extends DelayedEvent {
|
|||||||
if (opponent.getHits() <= 0) {
|
if (opponent.getHits() <= 0) {
|
||||||
attacker.resetCombat(CombatState.WON);
|
attacker.resetCombat(CombatState.WON);
|
||||||
opponent.resetCombat(CombatState.LOST);
|
opponent.resetCombat(CombatState.LOST);
|
||||||
|
this.stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
attacker.incHitsMade();
|
attacker.incHitsMade();
|
||||||
@ -102,6 +103,7 @@ public class DuelEvent extends DelayedEvent {
|
|||||||
|
|
||||||
attacker.resetDueling();
|
attacker.resetDueling();
|
||||||
opponent.resetDueling();
|
opponent.resetDueling();
|
||||||
|
this.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,12 +81,16 @@ public class FightEvent extends DelayedEvent {
|
|||||||
Npc n = (Npc) attacker;
|
Npc n = (Npc) attacker;
|
||||||
if (attacker.getHits() <= 0) {
|
if (attacker.getHits() <= 0) {
|
||||||
n.resetCombat(CombatState.ERROR);
|
n.resetCombat(CombatState.ERROR);
|
||||||
|
owner.resetCombat(CombatState.ERROR);
|
||||||
|
this.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (opponent instanceof Npc) {
|
if (opponent instanceof Npc) {
|
||||||
Npc n = (Npc) opponent;
|
Npc n = (Npc) opponent;
|
||||||
if (opponent.getHits() <= 0) {
|
if (opponent.getHits() <= 0) {
|
||||||
n.resetCombat(CombatState.ERROR);
|
n.resetCombat(CombatState.ERROR);
|
||||||
|
owner.resetCombat(CombatState.ERROR);
|
||||||
|
this.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (opponent instanceof Player && attacker instanceof Player) {
|
if (opponent instanceof Player && attacker instanceof Player) {
|
||||||
@ -100,8 +104,7 @@ public class FightEvent extends DelayedEvent {
|
|||||||
* opponent.resetCombat(CombatState.LOST); return; }
|
* opponent.resetCombat(CombatState.LOST); return; }
|
||||||
*/
|
*/
|
||||||
attacker.incHitsMade();
|
attacker.incHitsMade();
|
||||||
if (attacker instanceof Npc && opponent.isPrayerActivated(12)
|
if (attacker instanceof Npc && opponent.isPrayerActivated(12)) {
|
||||||
&& ((Npc) attacker).getTeam() == 2) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int damage = (attacker instanceof Player && opponent instanceof Player ? Formulae
|
int damage = (attacker instanceof Player && opponent instanceof Player ? Formulae
|
||||||
@ -148,6 +151,7 @@ public class FightEvent extends DelayedEvent {
|
|||||||
player.resetAll();
|
player.resetAll();
|
||||||
player.getActionSender().sendMessage(
|
player.getActionSender().sendMessage(
|
||||||
"Your opponent is retreating");
|
"Your opponent is retreating");
|
||||||
|
this.stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -254,6 +258,7 @@ public class FightEvent extends DelayedEvent {
|
|||||||
}
|
}
|
||||||
attacker.resetCombat(CombatState.WON);
|
attacker.resetCombat(CombatState.WON);
|
||||||
opponent.resetCombat(CombatState.LOST);
|
opponent.resetCombat(CombatState.LOST);
|
||||||
|
this.stop();
|
||||||
} else {
|
} else {
|
||||||
ArrayList<Player> playersToInform = new ArrayList<Player>();
|
ArrayList<Player> playersToInform = new ArrayList<Player>();
|
||||||
playersToInform.addAll(opponent.getViewArea().getPlayersInView());
|
playersToInform.addAll(opponent.getViewArea().getPlayersInView());
|
||||||
|
@ -68,6 +68,7 @@ public class RangeEvent extends DelayedEvent {
|
|||||||
.loggedIn()) || affectedMob.getHits() <= 0
|
.loggedIn()) || affectedMob.getHits() <= 0
|
||||||
|| !owner.checkAttack(affectedMob, true) || bowID < 0) {
|
|| !owner.checkAttack(affectedMob, true) || bowID < 0) {
|
||||||
owner.resetRange();
|
owner.resetRange();
|
||||||
|
this.stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (owner.withinRange(affectedMob, 5)) {
|
if (owner.withinRange(affectedMob, 5)) {
|
||||||
@ -86,6 +87,7 @@ public class RangeEvent extends DelayedEvent {
|
|||||||
owner.getActionSender().sendMessage(
|
owner.getActionSender().sendMessage(
|
||||||
"I can't get a clear shot from here");
|
"I can't get a clear shot from here");
|
||||||
owner.resetPath();
|
owner.resetPath();
|
||||||
|
this.stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean xbow = DataConversions.inArray(Formulae.xbowIDs, bowID);
|
boolean xbow = DataConversions.inArray(Formulae.xbowIDs, bowID);
|
||||||
@ -106,6 +108,7 @@ public class RangeEvent extends DelayedEvent {
|
|||||||
.sendMessage(
|
.sendMessage(
|
||||||
"You may not use P2P (Member Item) Arrows in the F2P Wilderness");
|
"You may not use P2P (Member Item) Arrows in the F2P Wilderness");
|
||||||
owner.resetRange();
|
owner.resetRange();
|
||||||
|
this.stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,6 +129,7 @@ public class RangeEvent extends DelayedEvent {
|
|||||||
owner.getActionSender().sendMessage(
|
owner.getActionSender().sendMessage(
|
||||||
"Your arrows are too powerful for your Bow.");
|
"Your arrows are too powerful for your Bow.");
|
||||||
owner.resetRange();
|
owner.resetRange();
|
||||||
|
this.stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,11 +147,13 @@ public class RangeEvent extends DelayedEvent {
|
|||||||
owner.getActionSender().sendMessage(
|
owner.getActionSender().sendMessage(
|
||||||
"You have run out of " + (xbow ? "bolts" : "arrows"));
|
"You have run out of " + (xbow ? "bolts" : "arrows"));
|
||||||
owner.resetRange();
|
owner.resetRange();
|
||||||
|
this.stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (affectedMob.isPrayerActivated(13)) {
|
if (affectedMob.isPrayerActivated(13)) {
|
||||||
if (!owner.shouldRangePass()) {
|
if (!owner.shouldRangePass()) {
|
||||||
owner.getActionSender().sendMessage("Your missile got blocked");
|
owner.getActionSender().sendMessage("Your missile was blocked");
|
||||||
|
this.stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -259,6 +265,7 @@ public class RangeEvent extends DelayedEvent {
|
|||||||
public void arrived() {
|
public void arrived() {
|
||||||
if (affectedMob.isBusy() || player.isBusy()) {
|
if (affectedMob.isBusy() || player.isBusy()) {
|
||||||
npc.setChasing(null);
|
npc.setChasing(null);
|
||||||
|
this.stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,12 +305,14 @@ public class RangeEvent extends DelayedEvent {
|
|||||||
fighting.setLastRun(0);
|
fighting.setLastRun(0);
|
||||||
Instance.getDelayedEventHandler().add(
|
Instance.getDelayedEventHandler().add(
|
||||||
fighting);
|
fighting);
|
||||||
|
this.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void failed() {
|
public void failed() {
|
||||||
npc.setChasing(null);
|
npc.setChasing(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
this.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
package org.moparscape.msc.gs.event;
|
package org.moparscape.msc.gs.event;
|
||||||
|
|
||||||
import org.moparscape.msc.gs.model.Mob;
|
import org.moparscape.msc.gs.model.Mob;
|
||||||
|
@ -621,13 +621,4 @@ public class Npc extends Mob {
|
|||||||
|
|
||||||
public boolean hasArmor = false;
|
public boolean hasArmor = false;
|
||||||
public boolean undead = false;
|
public boolean undead = false;
|
||||||
private int team = 2;
|
|
||||||
|
|
||||||
public int getTeam() {
|
|
||||||
return team;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTeam(int team) {
|
|
||||||
this.team = team;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -582,8 +582,10 @@ public final class Player extends Mob {
|
|||||||
|
|
||||||
for (Player p : getViewArea().getPlayersInView())
|
for (Player p : getViewArea().getPlayersInView())
|
||||||
p.informOfModifiedHits(this);
|
p.informOfModifiedHits(this);
|
||||||
if (getCurStat(3) <= 0)
|
if (getCurStat(3) <= 0) {
|
||||||
killedBy(null, false);
|
killedBy(null, false);
|
||||||
|
poisonEvent.stop();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (poisonEvent != null)
|
if (poisonEvent != null)
|
||||||
poisonEvent.stop();
|
poisonEvent.stop();
|
||||||
@ -697,6 +699,7 @@ public final class Player extends Mob {
|
|||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
removeSkull();
|
removeSkull();
|
||||||
|
this.stop();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Instance.getDelayedEventHandler().add(skullEvent);
|
Instance.getDelayedEventHandler().add(skullEvent);
|
||||||
@ -2121,6 +2124,7 @@ public final class Player extends Mob {
|
|||||||
|
|
||||||
Instance.getServer().getLoginConnector().getActionSender()
|
Instance.getServer().getLoginConnector().getActionSender()
|
||||||
.playerLogin(this);
|
.playerLogin(this);
|
||||||
|
final Player p = this;
|
||||||
Instance.getDelayedEventHandler().add(
|
Instance.getDelayedEventHandler().add(
|
||||||
new DelayedEvent(this, 60000) {
|
new DelayedEvent(this, 60000) {
|
||||||
|
|
||||||
@ -2137,6 +2141,9 @@ public final class Player extends Mob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if(p == null || p.isDestroy()) {
|
||||||
|
this.stop();
|
||||||
|
}
|
||||||
for (int statIndex = 0; statIndex < 18; statIndex++) {
|
for (int statIndex = 0; statIndex < 18; statIndex++) {
|
||||||
if (statIndex == 5) {
|
if (statIndex == 5) {
|
||||||
continue;
|
continue;
|
||||||
@ -2159,6 +2166,9 @@ public final class Player extends Mob {
|
|||||||
drainer = new DelayedEvent(this, Integer.MAX_VALUE) {
|
drainer = new DelayedEvent(this, Integer.MAX_VALUE) {
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if(p == null || p.isDestroy()) {
|
||||||
|
this.stop();
|
||||||
|
}
|
||||||
int curPrayer = getCurStat(5);
|
int curPrayer = getCurStat(5);
|
||||||
if (getDrainRate() > 0 && curPrayer > 0) {
|
if (getDrainRate() > 0 && curPrayer > 0) {
|
||||||
incCurStat(5, -1);
|
incCurStat(5, -1);
|
||||||
@ -2681,6 +2691,7 @@ public final class Player extends Mob {
|
|||||||
if (!owner.withinRange(mob) || mob.isRemoved()
|
if (!owner.withinRange(mob) || mob.isRemoved()
|
||||||
|| (owner.isBusy() && !owner.isDueling())) {
|
|| (owner.isBusy() && !owner.isDueling())) {
|
||||||
resetFollowing();
|
resetFollowing();
|
||||||
|
this.stop();
|
||||||
} else if (!owner.finishedPath()
|
} else if (!owner.finishedPath()
|
||||||
&& owner.withinRange(mob, radius)) {
|
&& owner.withinRange(mob, radius)) {
|
||||||
owner.resetPath();
|
owner.resetPath();
|
||||||
|
@ -95,6 +95,7 @@ public class Tanner implements NpcHandler {
|
|||||||
1));
|
1));
|
||||||
owner.getActionSender()
|
owner.getActionSender()
|
||||||
.sendInventory();
|
.sendInventory();
|
||||||
|
this.stop();
|
||||||
} else {
|
} else {
|
||||||
matchRunning = false;
|
matchRunning = false;
|
||||||
owner.setBusy(false);
|
owner.setBusy(false);
|
||||||
|
@ -52,6 +52,7 @@ public class DropHandler implements PacketHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (owner.hasMoved()) {
|
if (owner.hasMoved()) {
|
||||||
|
this.stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
world.addEntryToSnapshots(new Activity(owner.getUsername(),
|
world.addEntryToSnapshots(new Activity(owner.getUsername(),
|
||||||
|
@ -338,6 +338,7 @@ public class InvActionHandler implements PacketHandler {
|
|||||||
if (object != null) {
|
if (object != null) {
|
||||||
world.unregisterGameObject(object);
|
world.unregisterGameObject(object);
|
||||||
}
|
}
|
||||||
|
this.stop();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user