PC barricades wip

This commit is contained in:
Player Name 2026-06-19 16:59:08 +02:00
parent 1485ee9275
commit 0b454ab84a
3 changed files with 19 additions and 14 deletions

View file

@ -140,7 +140,7 @@ public final class PCObjectHandler extends OptionHandler {
handleTurretTower(player, session, object);
return true;
}
if (!object.isActive() || (getObjectType(object.getId()) == 9 && !session.getBarricades().contains(object))) {
if (!object.isActive() || !session.getBarricades().contains(object)) {
return true;
}
if (option.equals("repair")) { // Handle barricades
@ -229,15 +229,16 @@ public final class PCObjectHandler extends OptionHandler {
int dir = open ? object.getRotation() : rotation;
Direction direction = Direction.get(!open ? dir : ((3 + dir) % 4));
if (session.getBarricades().contains(object) && session.getBarricades().contains(second)) {
session.getBarricades().remove(object);
session.getBarricades().remove(second);
Location l = object.getLocation().transform(direction.getStepX(), direction.getStepY(), 0);
Scenery replacement = new Scenery(object.getId() + (open ? 1 : -1), l, 0, open ? rotation : ((direction.toInteger() + 3) % 4));
session.getBarricades().remove(object);
SceneryBuilder.replace(object, replacement);
session.getBarricades().add(replacement);
l = second.getLocation().transform(direction.getStepX(), direction.getStepY(), 0);
replacement = new Scenery(second.getId() + (open ? 1 : -1), l, 0, open ? getRotation(second) : ((direction.toInteger() + 3) % 4));
session.getBarricades().remove(second);
SceneryBuilder.replace(second, replacement);
session.getBarricades().add(replacement);
}
@ -294,7 +295,7 @@ public final class PCObjectHandler extends OptionHandler {
* @param objectId The object id.
* @return The object type.
*/
static int getObjectType(int objectId) {
private static int getObjectType(int objectId) {
if (objectId == 14225 || objectId == 14226 || objectId == 14228 || objectId == 14229) {
return 9;
}

View file

@ -184,7 +184,8 @@ public final class PCPortalNPC extends AbstractNPC {
int index = getDifficultyIndex();
Random r = RandomFunction.RANDOM;
int amount = index + 1;
amount += RegionManager.getLocalPlayers(location).size() / 10;
Region region = RegionManager.forId(location.getRegionId());
amount += region.assemblePlayerList(0).size() / 10;
if (getDifficultyIndex() == 0) {
amount += ((getDifficultyIndex() + 1) * 3) / 2;
}

View file

@ -8,6 +8,7 @@ import core.game.node.entity.npc.NPC;
import core.game.node.entity.player.Player;
import core.game.node.scenery.Scenery;
import core.game.world.map.Location;
import core.game.world.map.Point;
import core.game.world.map.build.DynamicRegion;
import core.tools.RandomFunction;
@ -19,6 +20,12 @@ import static core.api.ContentAPIKt.*;
* @author Emperor
*/
public final class PestControlSession {
/**
* The barricade object offsets.
*/
private static final Point[] OBJECT_OFFSETS = { new Point(46, 33), new Point(46, 32), new Point(32, 25), new Point(33, 25), new Point(19, 32), new Point(19, 33), new Point(49, 33), new Point(49, 32), new Point(49, 31), new Point(49, 30), new Point(52, 27), new Point(52, 26), new Point(52, 25), new Point(52, 24), new Point(52, 14), new Point(52, 13), new Point(52, 12), new Point(52, 11), new Point(42, 18), new Point(43, 18), new Point(44, 18), new Point(45, 18), new Point(32, 15), new Point(33, 15), new Point(34, 15), new Point(35, 15), new Point(23, 18), new Point(24, 18), new Point(25, 18), new Point(26, 18), new Point(13, 11), new Point(13, 12), new Point(13, 13), new Point(13, 14), new Point(12, 28), new Point(12, 29), new Point(12, 30), new Point(12, 31), };
/**
* The object ids of non-attackable barricades/gates.
*/
@ -263,15 +270,11 @@ public final class PestControlSession {
* Initializes the barricades list.
*/
private void initBarricadesList() {
for (int chunkX = 0; chunkX < 8; chunkX++) {
for (int chunkY = 0; chunkY < 8; chunkY++) {
List<Scenery> objects = region.getChunks()[chunkX][chunkY][0].assembleObjectList();
for (Scenery object : objects) {
boolean isActualBarricade = PCObjectHandler.getObjectType(object.getId()) == 9;
boolean isGate = object.getId() > 14232;
if (isActualBarricade || isGate) {
barricades.add(object);
}
List<Scenery> objectList = region.assembleObjectList(0);
for (Scenery object : objectList) {
for (Point point : OBJECT_OFFSETS) {
if (object.getLocation().getLocalX() == point.getX() && object.getLocation().getLocalY() == point.getY()) {
barricades.add(object);
}
}
}