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