diff --git a/scripts/commands/generic/openContainer.js b/scripts/commands/generic/openContainer.js index 3aee4d1a6..7376bb3cc 100644 --- a/scripts/commands/generic/openContainer.js +++ b/scripts/commands/generic/openContainer.js @@ -1,4 +1,4 @@ function executeCommand(galacticManager, player, target, args) { var ClientOpenContainerMessage = Java.type("network.packets.swg.zone.ClientOpenContainerMessage"); - player.sendPacket(new ClientOpenContainerMessage(target.getObjectId(), args)); + player.sendPacket(new ClientOpenContainerMessage(target.getObjectId(), "")); } \ No newline at end of file diff --git a/src/resources/commands/callbacks/TransferItemCallback.java b/src/resources/commands/callbacks/TransferItemCallback.java index 0f426550e..7e13df88e 100644 --- a/src/resources/commands/callbacks/TransferItemCallback.java +++ b/src/resources/commands/callbacks/TransferItemCallback.java @@ -114,6 +114,13 @@ public class TransferItemCallback implements ICmdCallback { return; } } + + // Check the players level, if they're too low of a level, don't allow them to wear it + short reqlevel = Short.parseShort(target.getAttribute("required_combat_level")); + if (actor.getLevel() < Short.parseShort(target.getAttribute("required_combat_level"))) { + new ChatBroadcastIntent(player, "@base_player:level_too_low").broadcast(); + return; + } switch (target.moveToContainer(actor, newContainer)) { case SUCCESS: diff --git a/src/resources/containers/AdminPermissions.java b/src/resources/containers/AdminPermissions.java new file mode 100644 index 000000000..3cd8a7dad --- /dev/null +++ b/src/resources/containers/AdminPermissions.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package resources.containers; + +import resources.objects.SWGObject; +import resources.objects.creature.CreatureObject; + +class AdminPermissions extends DefaultPermissions { + + @Override + public boolean canView(SWGObject requester, SWGObject container) { + return isAdmin(requester); + } + + @Override + public boolean canEnter(SWGObject requester, SWGObject container) { + return isAdmin(requester); + } + + private boolean isAdmin(SWGObject requester) { + if (requester == null) + return false; + if (!(requester instanceof CreatureObject)) { + return false; + } + + return ((CreatureObject) requester).hasAbility("admin"); + } +} diff --git a/src/resources/containers/ContainerPermissionsType.java b/src/resources/containers/ContainerPermissionsType.java index 1feb242f1..3b1906112 100644 --- a/src/resources/containers/ContainerPermissionsType.java +++ b/src/resources/containers/ContainerPermissionsType.java @@ -31,7 +31,8 @@ import resources.objects.SWGObject; public enum ContainerPermissionsType { DEFAULT (new DefaultPermissions()), - INVENTORY (new InventoryPermissions()); + INVENTORY (new InventoryPermissions()), + ADMIN (new AdminPermissions()); private final ContainerPermissions permissions; diff --git a/src/resources/objects/SWGObject.java b/src/resources/objects/SWGObject.java index 195056cd4..aa6ef2d14 100644 --- a/src/resources/objects/SWGObject.java +++ b/src/resources/objects/SWGObject.java @@ -655,8 +655,7 @@ public abstract class SWGObject extends BaselineObject implements Comparable observers = target.getAwareness().getChildObservers(); diff --git a/src/services/combat/CombatManager.java b/src/services/combat/CombatManager.java index 6e47dc15e..dad0ffc12 100644 --- a/src/services/combat/CombatManager.java +++ b/src/services/combat/CombatManager.java @@ -218,6 +218,9 @@ public class CombatManager extends Manager { CreatureObject source = intent.getSource(); SWGObject target = intent.getTarget(); + // Regardless of HitType, the command might have action cost + addActionCost(source, c); + // TODO implement support for remaining HitTypes switch (c.getHitType()) { case ATTACK: handleAttack(source, target, c); break; @@ -520,6 +523,20 @@ public class CombatManager extends Manager { return CombatStatus.UNKNOWN; } + private void addActionCost(CreatureObject source, CombatCommand command) { + double actionCost = command.getActionCost(); + int currentAction = source.getAction(); + + if (actionCost <= 0 || actionCost > currentAction) { + return; + } + + synchronized (regeneratingActionCreatures) { + source.setAction((int) (currentAction - actionCost)); + regeneratingActionCreatures.add(source); + } + } + private int calculateWeaponDamage(CreatureObject source, CombatCommand command) { WeaponObject weapon = source.getEquippedWeapon(); int minDamage = weapon.getMinDamage(); diff --git a/src/services/objects/StaticItemService.java b/src/services/objects/StaticItemService.java index 8c1b879fc..03cf50f68 100644 --- a/src/services/objects/StaticItemService.java +++ b/src/services/objects/StaticItemService.java @@ -311,7 +311,6 @@ public final class StaticItemService extends Service { public final String getIffTemplate() { return iffTemplate; } - } private static class WearableAttributes extends ObjectAttributes { @@ -347,15 +346,15 @@ public final class StaticItemService extends Service { } else { requiredFaction = "@pvp_factions:" + requiredFaction; } - + // Load mods String modsString = resultSet.getString("skill_mods"); - + // If this wearable is supposed to have mods, then load 'em! mods = parseSkillMods(modsString); String buffNameCell = resultSet.getString("buff_name"); - + if(!buffNameCell.equals("-")) { buffName = "@ui_buff:" + buffNameCell; } @@ -368,7 +367,7 @@ public final class StaticItemService extends Service { object.addAttribute("class_required", requiredProfession); object.addAttribute("required_combat_level", requiredLevel); object.addAttribute("faction_restriction", requiredFaction); - + // Apply the mods! for(Map.Entry modEntry : mods.entrySet()) object.addAttribute(modEntry.getKey(), modEntry.getValue()); diff --git a/src/services/spawn/SpawnerService.java b/src/services/spawn/SpawnerService.java index 5471a321b..f154c2298 100644 --- a/src/services/spawn/SpawnerService.java +++ b/src/services/spawn/SpawnerService.java @@ -42,6 +42,7 @@ import resources.Location; import resources.PvpFlag; import resources.Terrain; import resources.config.ConfigFile; +import resources.containers.ContainerPermissionsType; import resources.control.Intent; import resources.control.Service; import resources.objects.building.BuildingObject; @@ -203,6 +204,7 @@ public final class SpawnerService extends Service { SpawnerType spawnerType = SpawnerType.valueOf(set.getString("spawner_type")); SWGObject egg = ObjectCreator.createObjectFromTemplate(spawnerType.getObjectTemplate()); + egg.setContainerPermissions(ContainerPermissionsType.ADMIN); egg.setLocation(loc); egg.moveToContainer(parent); new ObjectCreatedIntent(egg).broadcast();