Pest control refactor

This commit is contained in:
dginovker 2019-06-15 18:32:00 -04:00
parent 223f1e33bf
commit 0ecae80828
16 changed files with 76 additions and 36 deletions

View file

@ -5,6 +5,7 @@ import org.crandor.game.node.Node;
import org.crandor.game.node.entity.Entity;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.object.GameObject;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.map.zone.MapZone;
import org.crandor.game.world.map.zone.ZoneBorders;
import org.crandor.game.world.map.zone.ZoneRestriction;
@ -89,11 +90,20 @@ public final class PCLanderZone extends MapZone {
return super.leave(e, logout);
}
private static ZoneBorders boatA = new ZoneBorders(2659, 2637, 2664, 2664); //I should probably find the real names
private static ZoneBorders boatB = new ZoneBorders(2637, 2641, 2642, 2648);
private static ZoneBorders boatC = new ZoneBorders(2631, 2648, 2636, 2655);
@Override
public void configure() {
register(new ZoneBorders(2659, 2637, 2664, 2664));
register(new ZoneBorders(2637, 2641, 2642, 2648));
register(new ZoneBorders(2631, 2648, 2636, 2655));
register(boatA);
register(boatB);
register(boatC);
}
public static boolean landerContainsLoc(Location l)
{
return boatA.insideBorder(l) || boatB.insideBorder(l) || boatC.insideBorder(l);
}
}

View file

@ -12,6 +12,8 @@ import org.crandor.game.world.map.Location;
import org.crandor.game.world.map.RegionPlane;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.tools.RandomFunction;
import plugin.activity.pestcontrol.monsters.PCRavagerNPC;
import plugin.activity.pestcontrol.monsters.PCSpinnerNPC;
/**
* Handles the portal NPC.

View file

@ -1,7 +1,6 @@
package plugin.activity.pestcontrol;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.crandor.ServerConstants;
@ -29,6 +28,7 @@ import org.crandor.plugin.PluginManager;
import org.crandor.tools.RandomFunction;
import org.crandor.plugin.InitializablePlugin;
import org.crandor.tools.StringUtils;
import plugin.activity.pestcontrol.monsters.*;
/**
* Handles the Pest Control activity.
@ -74,24 +74,24 @@ public final class PestControlActivityPlugin extends ActivityPlugin {
@Override
public boolean pulse() {
for (Iterator<PestControlSession> it = sessions.iterator(); it.hasNext();) {
PestControlSession session = it.next();
if (session != null && session.update()) {
it.remove();
sessions.removeIf(session -> session != null && session.update());
ticks++;
if (waitingPlayers.size() >= MAX_TEAM_SIZE && ticks < 575)
{
ticks = 585;
}
if ((ticks < 450 && ticks % 100 == 0) || (ticks % 50 == 0) || ticks == 596) {
for (Player p : waitingPlayers) {
updateTime(p);
}
}
if (++ticks >= 500) { // 500
if (ticks >= 500) { // 500
if (waitingPlayers.size() >= MIN_TEAM_SIZE) {
PestControlActivityPlugin.this.start();
} else {
ticks = 400;
}
}
if ((ticks < 450 && ticks % 100 == 0) || (ticks % 50 == 0)) {
for (Player p : waitingPlayers) {
updateTime(p);
}
}
return false;
}
};
@ -105,6 +105,7 @@ public final class PestControlActivityPlugin extends ActivityPlugin {
session.getRegion().getRegionZones().add(new RegionZone(this, session.getRegion().getBorders()));
sessions.add(session);
ticks = 0;
updatePlayerCount();
}
/**

View file

@ -0,0 +1,5 @@
package plugin.activity.pestcontrol;
public class PestControlHelper {
public static final int NOVICE_GANGPLANK = 14315;
}

View file

@ -18,6 +18,8 @@ import org.crandor.game.world.map.RegionPlane;
import org.crandor.game.world.map.build.DynamicRegion;
import org.crandor.tools.RandomFunction;
import static plugin.activity.pestcontrol.PestControlActivityPlugin.MAX_TEAM_SIZE;
/**
* Represents a pest control session.
* @author Emperor
@ -219,7 +221,7 @@ public final class PestControlSession {
for (Iterator<Player> it = waitingPlayers.iterator(); it.hasNext();) {
Player p = it.next();
if (p.getSession().isActive()) {
if (++count > 25) {
if (++count > MAX_TEAM_SIZE) {
int priority = p.getAttribute("pc_prior", 0) + 1;
p.getPacketDispatch().sendMessage("You have been given priority level " + priority + " over other players in joining the next");
p.getPacketDispatch().sendMessage("game.");

View file

@ -11,6 +11,7 @@ import org.crandor.game.world.map.RegionManager;
import org.crandor.game.world.update.flag.context.Graphics;
import org.crandor.plugin.Plugin;
import org.crandor.tools.RandomFunction;
import plugin.activity.pestcontrol.monsters.*;
/**
* Handles the void knight seal.

View file

@ -1,4 +1,4 @@
package plugin.activity.pestcontrol;
package plugin.activity.pestcontrol.monsters;
import org.crandor.game.node.entity.Entity;
import org.crandor.game.node.entity.combat.BattleState;
@ -10,6 +10,7 @@ import org.crandor.game.node.entity.npc.AbstractNPC;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.world.map.Location;
import org.crandor.game.world.map.MapDistance;
import plugin.activity.pestcontrol.PestControlSession;
/**
* Handles the Defiler NPCs.

View file

@ -1,4 +1,4 @@
package plugin.activity.pestcontrol;
package plugin.activity.pestcontrol.monsters;
import org.crandor.game.interaction.MovementPulse;
import org.crandor.game.node.Node;
@ -15,6 +15,7 @@ import org.crandor.game.world.map.MapDistance;
import org.crandor.game.world.map.path.Pathfinder;
import org.crandor.game.world.map.zone.ZoneBorders;
import org.crandor.tools.RandomFunction;
import plugin.activity.pestcontrol.PestControlSession;
/**
* Handles the Ravager pest control NPC.

View file

@ -1,4 +1,4 @@
package plugin.activity.pestcontrol;
package plugin.activity.pestcontrol.monsters;
import java.util.ArrayList;
import java.util.Collections;
@ -20,6 +20,7 @@ import org.crandor.game.world.map.RegionManager;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.game.world.update.flag.context.Graphics;
import org.crandor.tools.RandomFunction;
import plugin.activity.pestcontrol.PestControlSession;
/**
* Handles the pest control shifter NPCs.

View file

@ -1,4 +1,4 @@
package plugin.activity.pestcontrol;
package plugin.activity.pestcontrol.monsters;
import org.crandor.game.interaction.MovementPulse;
import org.crandor.game.node.entity.Entity;
@ -16,6 +16,7 @@ import org.crandor.game.world.map.RegionManager;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.game.world.update.flag.context.Graphics;
import org.crandor.tools.RandomFunction;
import plugin.activity.pestcontrol.PestControlSession;
/**
* Handles a pest control spinner NPC.

View file

@ -1,4 +1,4 @@
package plugin.activity.pestcontrol;
package plugin.activity.pestcontrol.monsters;
import java.util.ArrayList;
@ -17,6 +17,7 @@ import org.crandor.game.world.map.RegionManager;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.game.world.update.flag.context.Graphics;
import org.crandor.tools.RandomFunction;
import plugin.activity.pestcontrol.PestControlSession;
/**
* Handles the pest control splatter NPC.

View file

@ -1,4 +1,4 @@
package plugin.activity.pestcontrol;
package plugin.activity.pestcontrol.monsters;
import org.crandor.game.node.entity.Entity;
import org.crandor.game.node.entity.combat.BattleState;
@ -18,6 +18,7 @@ import org.crandor.game.world.map.MapDistance;
import org.crandor.game.world.update.flag.context.Animation;
import org.crandor.game.world.update.flag.context.Graphics;
import org.crandor.plugin.Plugin;
import plugin.activity.pestcontrol.PestControlSession;
/**
* Handles the torcher pest control NPC.