Files
Server/src/engine/devcmd/cmds/SetNpcEquipSetCmd.java
T

137 lines
4.3 KiB
Java
Raw Normal View History

2022-04-30 09:41:17 -04:00
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;
import engine.InterestManagement.WorldGrid;
import engine.devcmd.AbstractDevCmd;
import engine.objects.AbstractGameObject;
import engine.objects.MobBase;
import engine.objects.NPC;
import engine.objects.PlayerCharacter;
public class SetNpcEquipSetCmd extends AbstractDevCmd {
2023-07-15 09:23:48 -04:00
public static int lastEquipSetID = 0;
public SetNpcEquipSetCmd() {
2022-04-30 09:41:17 -04:00
super("setEquipSet");
this.addCmdString("equipset");
}
2023-07-15 09:23:48 -04:00
@Override
protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) {
// Arg Count Check
if (words.length != 1) {
this.sendUsage(pc);
return;
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
if (target.getObjectType() != GameObjectType.NPC) {
this.sendUsage(pc);
return;
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
NPC npc = (NPC) target;
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
if (words[0].equalsIgnoreCase("next")) {
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
if (SetNpcEquipSetCmd.lastEquipSetID >= 1222)
SetNpcEquipSetCmd.lastEquipSetID = 1;
else
SetNpcEquipSetCmd.lastEquipSetID++;
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
boolean complete = false;
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
while (complete == false) {
complete = NPC.UpdateEquipSetID(npc, SetNpcEquipSetCmd.lastEquipSetID);
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
if (!complete) {
SetNpcEquipSetCmd.lastEquipSetID++;
if (SetNpcEquipSetCmd.lastEquipSetID >= 1222)
SetNpcEquipSetCmd.lastEquipSetID = 1;
}
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
if (complete) {
npc.equip = MobBase.loadEquipmentSet(npc.getEquipmentSetID());
WorldGrid.updateObject(npc);
this.throwbackInfo(pc, "Equipment Set Changed to " + SetNpcEquipSetCmd.lastEquipSetID);
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
return;
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
if (words[0].equalsIgnoreCase("last")) {
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
if (SetNpcEquipSetCmd.lastEquipSetID <= 1)
SetNpcEquipSetCmd.lastEquipSetID = 1222;
else
SetNpcEquipSetCmd.lastEquipSetID--;
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
boolean complete = false;
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
while (complete == false) {
complete = NPC.UpdateEquipSetID(npc, SetNpcEquipSetCmd.lastEquipSetID);
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
if (!complete) {
SetNpcEquipSetCmd.lastEquipSetID--;
if (SetNpcEquipSetCmd.lastEquipSetID <= 1)
SetNpcEquipSetCmd.lastEquipSetID = 1222;
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
if (complete) {
this.throwbackInfo(pc, "Equipment Set Changed to " + SetNpcEquipSetCmd.lastEquipSetID);
npc.equip = MobBase.loadEquipmentSet(npc.getEquipmentSetID());
WorldGrid.updateObject(npc);
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
return;
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
int equipSetID = 0;
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
try {
equipSetID = Integer.parseInt(words[0]);
} catch (Exception e) {
this.throwbackError(pc, e.getMessage());
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
if (!NPC.UpdateEquipSetID(npc, equipSetID)) {
this.throwbackError(pc, "Unable to find Equipset for ID " + equipSetID);
return;
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
SetNpcEquipSetCmd.lastEquipSetID = equipSetID;
npc.equip = MobBase.loadEquipmentSet(npc.getEquipmentSetID());
WorldGrid.updateObject(npc);
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
this.throwbackInfo(pc, "Equipment Set Changed to " + equipSetID);
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
@Override
protected String _getHelpString() {
return "Sets slot position for an NPC to 'slot'";
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
@Override
protected String _getUsageString() {
return "' /changeslot slot'";
}
2022-04-30 09:41:17 -04:00
}