mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-10-10 00:13:05 -04:00
Updated lightsaber system messages, changed EquipmentService.canEquip to report why the actor cannot equip the item
This commit is contained in:
@@ -69,69 +69,92 @@ public class EquipmentService implements INetworkDispatch {
|
||||
|
||||
}
|
||||
|
||||
public boolean canEquip(CreatureObject actor, SWGObject item) {
|
||||
|
||||
/*
|
||||
Returns an array;
|
||||
[0] = boolean, whether or not the item may be equipped;
|
||||
[1] = string, in case of failure, why
|
||||
*/
|
||||
public Object[] canEquip(CreatureObject actor, SWGObject item) {
|
||||
// TODO: Species restrictions
|
||||
// TODO: Gender restrictions
|
||||
|
||||
boolean result = true;
|
||||
String message = "";
|
||||
|
||||
if (item == null)
|
||||
return false;
|
||||
if (item == null)
|
||||
{
|
||||
result = false;
|
||||
message = "null_item";
|
||||
return new Object[] { result, message };
|
||||
}
|
||||
|
||||
if (item.getAttributes().toString().contains("cat_armor"))
|
||||
{
|
||||
if (actor.hasAbility("wear_all_armor")) result = true; // Change to "wear_all_armor" ability instead of lvl 22
|
||||
else return false;
|
||||
if (actor.hasAbility("wear_all_armor")) result = true;
|
||||
else
|
||||
{
|
||||
result = false;
|
||||
message = "@error_message:insufficient_skill"; // I am unsure if this is the right message
|
||||
return new Object[] { result, message };
|
||||
}
|
||||
}
|
||||
|
||||
if (item.getStringAttribute("class_required") != null) {
|
||||
if (item.getStringAttribute("class_required") != null)
|
||||
{
|
||||
String classRequired = item.getStringAttribute("class_required");
|
||||
String profession = ((PlayerObject) actor.getSlottedObject("ghost")).getProfession();
|
||||
|
||||
if (classRequired.contains(",")) {
|
||||
String[] classes = classRequired.split(",");
|
||||
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
if (classes[i].contains(core.playerService.getFormalProfessionName(profession))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (classRequired.contains(core.playerService.getFormalProfessionName(profession)) || classRequired.equals("None")) result = true;
|
||||
else
|
||||
{
|
||||
result = false;
|
||||
message = "@error_message:insufficient_skill"; // I am unsure if this is the right message
|
||||
return new Object[] { result, message };
|
||||
}
|
||||
if (classRequired.contentEquals(core.playerService.getFormalProfessionName(profession)) || classRequired.contentEquals("None"))
|
||||
result = true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item.getStringAttribute("faction_restriction") != null)
|
||||
if (item.getStringAttribute("faction_restriction").toLowerCase().contentEquals(actor.getFaction()) && actor.getFactionStatus() >= FactionStatus.Combatant)
|
||||
result = true;
|
||||
else
|
||||
return false;
|
||||
{
|
||||
if (item.getStringAttribute("faction_restriction").toLowerCase().contentEquals(actor.getFaction()) && actor.getFactionStatus() >= FactionStatus.Combatant) result = true;
|
||||
else
|
||||
{
|
||||
result = false;
|
||||
message = "@faction_recruiter:must_be_faction_member_use"; // will have to somehow manage prose %TO for faction name
|
||||
return new Object[] { result, message };
|
||||
}
|
||||
}
|
||||
|
||||
if (item.getAttributes().containsKey("required_combat_level"))
|
||||
{
|
||||
if (actor.getLevel() >= item.getIntAttribute("required_combat_level"))
|
||||
result = true;
|
||||
else
|
||||
return false;
|
||||
if (actor.getLevel() >= item.getIntAttribute("required_combat_level")) result = true;
|
||||
else
|
||||
{
|
||||
result = false;
|
||||
message = "@error_message:insufficient_skill"; // I am unsure if this is the right message
|
||||
return new Object[] { result, message };
|
||||
}
|
||||
}
|
||||
|
||||
if(item.getAttachment("unity") != null)
|
||||
{
|
||||
actor.sendSystemMessage("@unity:cannot_remove_ring", (byte) 0);
|
||||
return false;
|
||||
result = false;
|
||||
message = "@unity:cannot_remove_ring";
|
||||
return new Object[] { result, message };
|
||||
}
|
||||
|
||||
if(item.getTemplate().startsWith("object/weapon/") && item.getTemplate().contains("lightsaber") && item.getAttachment("hasColorCrystal") == null) item.setAttachment("hasColorCrystal", false);
|
||||
|
||||
if(item.getAttachment("hasColorCrystal") != null && (Boolean) item.getAttachment("hasColorCrystal") == false)
|
||||
{
|
||||
actor.sendSystemMessage("You may not equip a light saber that has no color crystal!", (byte) 0);
|
||||
return false;
|
||||
result = false;
|
||||
message = "@jedi_spam:lightsaber_no_color";
|
||||
return new Object[] { result, message };
|
||||
}
|
||||
|
||||
return result;
|
||||
result = true;
|
||||
message = "success";
|
||||
return new Object[] { result, message };
|
||||
}
|
||||
|
||||
synchronized public void equip(CreatureObject actor, SWGObject item)
|
||||
@@ -318,17 +341,34 @@ public class EquipmentService implements INetworkDispatch {
|
||||
// Check if item is a lightsaber component
|
||||
if(lightsaber == null) return;
|
||||
if(lightsaberInventory == null) return;
|
||||
if(lightsaber.getContainer() instanceof CreatureObject) return;
|
||||
if(lightsaber.getContainer() instanceof CreatureObject)
|
||||
{
|
||||
actor.sendSystemMessage("@jedi_spam:saber_not_while_equpped", (byte) 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!item.getTemplate().startsWith("object/tangible/component/weapon/lightsaber/")) return;
|
||||
if(!item.getTemplate().startsWith("object/tangible/component/weapon/lightsaber/"))
|
||||
{
|
||||
actor.sendSystemMessage("@jedi_spam:saber_not_crystal", (byte) 0);
|
||||
return;
|
||||
}
|
||||
if(lightsaber.getAttachment("hasColorCrystal") == null) lightsaber.setAttachment("hasColorCrystal", false);
|
||||
if(item.getAttributes().containsKey("@obj_attr_n:color") && (Boolean) lightsaber.getAttachment("hasColorCrystal") && !(targetContainer.getContainer() instanceof CreatureObject)) return;
|
||||
if(item.getAttributes().containsKey("@obj_attr_n:color") && (Boolean) lightsaber.getAttachment("hasColorCrystal") && !(targetContainer.getContainer() instanceof CreatureObject))
|
||||
{
|
||||
actor.sendSystemMessage("@jedi_spam:saber_already_has_color", (byte) 0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Find our tuner
|
||||
if(item.getAttachment("tunerId") == null) item.setAttachment("tunerId", 0);
|
||||
tunerId = (int) item.getAttachment("tunerId");
|
||||
|
||||
// Check if player tuned the crystal
|
||||
if(tunerId == 0)
|
||||
{
|
||||
actor.sendSystemMessage("@jedi_spam:saber_crystal_not_tuned", (byte) 0);
|
||||
return;
|
||||
}
|
||||
if(tunerId != actor.getObjectId())
|
||||
{
|
||||
actor.sendSystemMessage("@jedi_spam:saber_crystal_not_owner", (byte) 0);
|
||||
|
||||
Reference in New Issue
Block a user