World Boot Task 0.6. Static objects are built from client data each boot, so dev commands answer "Must use external tooling to modify gameworld" and log the command, target and caller instead of changing them. - /addbuilding, /mob and /npc always refuse (addsWorldContent hook in doCmd). - rotate, pull, setbuildingaltitude, remove, rename, npcname, setowner, setguild, setrank and forcerename refuse a static target. - purge skips static objects and reports how many it skipped. Value changes: none for non-static objects; the purge message now also reports the skipped count. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
110 lines
4.1 KiB
Java
110 lines
4.1 KiB
Java
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
|
// Magicbane Emulator Project © 2013 - 2026
|
|
// https://www.magicbane.com
|
|
|
|
|
|
package engine.devcmd.cmds;
|
|
|
|
import engine.InterestManagement.WorldGrid;
|
|
import engine.devcmd.AbstractDevCmd;
|
|
import engine.gameManager.BuildingManager;
|
|
import engine.gameManager.DbManager;
|
|
import engine.math.Vector3fImmutable;
|
|
import engine.mbEnums.GameObjectType;
|
|
import engine.objects.AbstractGameObject;
|
|
import engine.objects.Building;
|
|
import engine.objects.PlayerCharacter;
|
|
|
|
public class SetBuildingAltitudeCmd extends AbstractDevCmd {
|
|
|
|
public SetBuildingAltitudeCmd() {
|
|
super("setbuildingaltitude");
|
|
this.addCmdString("buildingaltitude");
|
|
}
|
|
|
|
private static boolean UpdateBuildingAltitude(Building building, float altitude) {
|
|
|
|
if (!DbManager.BuildingQueries.UPDATE_BUILDING_ALTITUDE(building.getObjectUUID(), altitude))
|
|
return false;
|
|
|
|
building.statAlt = altitude;
|
|
|
|
if (building.parentZone != null) {
|
|
if (building.parentBuildingID != 0) {
|
|
Building parentBuilding = BuildingManager.getBuilding(building.parentBuildingID);
|
|
if (parentBuilding != null) {
|
|
building.setLoc(new Vector3fImmutable(building.statLat + building.parentZone.absX + parentBuilding.statLat, building.statAlt + building.parentZone.absY + parentBuilding.statAlt, building.statLon + building.parentZone.absZ + parentBuilding.statLon));
|
|
} else {
|
|
building.setLoc(new Vector3fImmutable(building.statLat + building.parentZone.absX, building.statAlt + building.parentZone.absY, building.statLon + building.parentZone.absZ));
|
|
|
|
}
|
|
} else
|
|
building.setLoc(new Vector3fImmutable(building.statLat + building.parentZone.absX, building.statAlt + building.parentZone.absY, building.statLon + building.parentZone.absZ));
|
|
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
protected void _doCmd(PlayerCharacter pc, String[] words,
|
|
AbstractGameObject target) {
|
|
// Arg Count Check
|
|
if (words.length != 1) {
|
|
this.sendUsage(pc);
|
|
return;
|
|
}
|
|
|
|
if (target.getObjectType() != GameObjectType.Building) {
|
|
this.sendUsage(pc);
|
|
return;
|
|
}
|
|
|
|
Building targetBuilding = (Building) target;
|
|
|
|
if (this.refuseStaticTarget(pc, targetBuilding))
|
|
return;
|
|
|
|
|
|
float altitude = 0;
|
|
try {
|
|
altitude = Float.parseFloat(words[0]);
|
|
|
|
if (!UpdateBuildingAltitude(targetBuilding, targetBuilding.getStatAlt() + altitude)) {
|
|
this.throwbackError(pc, "Failed to update building altitude");
|
|
return;
|
|
}
|
|
|
|
|
|
WorldGrid.updateObject(targetBuilding);
|
|
|
|
this.setTarget(pc); //for logging
|
|
|
|
// Update all surrounding clients.
|
|
|
|
} catch (NumberFormatException e) {
|
|
this.throwbackError(pc, "Supplied data: " + words[0]
|
|
+ " failed to parse to an Integer.");
|
|
} catch (Exception e) {
|
|
this.throwbackError(pc,
|
|
"An unknown exception occurred while attempting to setSlot to "
|
|
+ words[0]);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected String _getHelpString() {
|
|
return "Sets slot position for an NPC to 'slot'";
|
|
}
|
|
|
|
@Override
|
|
protected String _getUsageString() {
|
|
return "' /changeslot slot'";
|
|
}
|
|
|
|
}
|