Merge pull request #864 from CharonInferar/ReverseEngineering

Reverse engineering implemented
This commit is contained in:
CharonInferar
2014-06-10 15:27:40 +02:00
22 changed files with 4155 additions and 53 deletions
+8
View File
@@ -0,0 +1,8 @@
import sys
def setup():
return
def run(core, actor, target, commandString):
target.splitFactoryCrate(actor,target,commandString)
return
@@ -0,0 +1,36 @@
def itemTemplate():
return ['object/tangible/loot/npc_loot/shared_wiring_generic.iff']
def customItemName():
return 'Wiring'
def lootDescriptor():
return 'customattributes'
def customizationAttributes():
return ['/private/index_color_1']
def customizationValues():
return [1]
def reverse_engineering_name():
return 'White'
def stackable():
return 1
def junkDealerPrice():
return 12
def junkType():
return 0
@@ -1,4 +1,5 @@
import sys
def setup(core, object):
object.setAttachment('radial_filename', 'item/factory_crate')
return
@@ -1,4 +1,5 @@
import sys
def setup(core, object):
object.setAttachment('radial_filename', 'item/factory_crate')
return
@@ -1,4 +1,5 @@
import sys
def setup(core, object):
object.setAttachment('radial_filename', 'item/factory_crate')
return
@@ -1,4 +1,5 @@
import sys
def setup(core, object):
object.setAttachment('radial_filename', 'item/factory_crate')
return
@@ -1,4 +1,5 @@
import sys
def setup(core, object):
object.setAttachment('radial_filename', 'item/factory_crate')
return
@@ -1,4 +1,5 @@
import sys
def setup(core, object):
object.setAttachment('radial_filename', 'item/factory_crate')
return
@@ -1,4 +1,5 @@
import sys
def setup(core, object):
object.setAttachment('radial_filename', 'item/factory_crate')
return
@@ -1,4 +1,5 @@
import sys
def setup(core, object):
object.setAttachment('radial_filename', 'item/factory_crate')
return
@@ -1,4 +1,5 @@
import sys
def setup(core, object):
object.setAttachment('radial_filename', 'item/factory_crate')
return
@@ -1,4 +1,5 @@
import sys
def setup(core, object):
object.setAttachment('radial_filename', 'item/reverse_engineering_tool')
return
+19
View File
@@ -0,0 +1,19 @@
from resources.common import RadialOptions
import sys
def createRadial(core, owner, target, radials):
radials.clear()
radials.add(RadialOptions(0, 44, 0, 'Get Item From Crate'))
radials.add(RadialOptions(0, 49, 0, 'Split'))
radials.add(RadialOptions(0, 7, 0, 'Examine'))
radials.add(RadialOptions(0, 15, 0, 'Destroy'))
return
def handleSelection(core, owner, target, option):
if option == 44 and target:
target.getObjectOutOfCrate(owner)
if option == 15 and target:
core.objectService.destroyObject(target)
#if option == 49 and target:
#target.splitFactoryCrate(owner, target, option)
return
@@ -0,0 +1,44 @@
from resources.common import RadialOptions
from protocol.swg import ResourceListForSurveyMessage
from services.sui.SUIService import MessageBoxType
from services.SurveyService import createSurveyRangeSUIWindow
from services.sui.SUIWindow import Trigger
from java.util import Vector
import sys
def createRadial(core, owner, target, radials):
radials.clear()
radials.add(RadialOptions(0, 17, 1, 'Open'))
radials.add(RadialOptions(0, 7, 2, 'Examine'))
radials.add(RadialOptions(0, 15, 3, 'Destroy'))
radials.add(RadialOptions(0, 14, 4, 'Drop'))
radials.add(RadialOptions(0, 132, 5, 'Reverse Engineer'))
radials.add(RadialOptions(0, 133, 6, 'Create Skill Enhancing Attachment'))
radials.add(RadialOptions(0, 134, 7, 'Create Powerup'))
return
def handleSelection(core, owner, target, option):
if owner.getPlayerObject().getProfession()!='trader_0a' and owner.getPlayerObject().getProfession()!='trader_0b' and owner.getPlayerObject().getProfession()!='trader_0c' and owner.getPlayerObject().getProfession()!='trader_0d':
owner.sendSystemMessage('@base_player:not_correct_skill', 0)
return
if option == 21 and target:
if owner is not None:
return
if option == 132:
if owner is not None:
core.reverseEngineeringService.reverseEngineer(owner, target)
return
if option == 133:
if owner is not None:
core.reverseEngineeringService.createSEA(owner, target)
return
if option == 134:
if owner is not None:
core.reverseEngineeringService.createPowerup(owner, target)
return
return
+4 -1
View File
@@ -103,6 +103,7 @@ import services.playercities.PlayerCityService;
import services.resources.HarvesterService;
import services.resources.ResourceService;
import services.retro.RetroService;
import services.reverseengineering.ReverseEngineeringService;
import services.spawn.SpawnService;
import services.sui.SUIService;
import services.trade.TradeService;
@@ -199,7 +200,7 @@ public class NGECore {
public HarvesterService harvesterService;
public MountService mountService;
public PlayerCityService playerCityService;
public ReverseEngineeringService reverseEngineeringService;
// Login Server
public NetworkDispatch loginDispatch;
@@ -340,6 +341,7 @@ public class NGECore {
mountService = new MountService(this);
playerCityService = new PlayerCityService(this);
staticService = new StaticService(this);
reverseEngineeringService = new ReverseEngineeringService(this);
if (config.keyExists("JYTHONCONSOLE.PORT")) {
int jythonPort = config.getInt("JYTHONCONSOLE.PORT");
@@ -398,6 +400,7 @@ public class NGECore {
zoneDispatch.addService(housingService);
zoneDispatch.addService(playerCityService);
zoneDispatch.addService(staticService);
zoneDispatch.addService(reverseEngineeringService);
if (optionsConfigLoaded && options.getInt("LOAD.RESOURCE.SYSTEM") == 1) {
zoneDispatch.addService(surveyService);
@@ -48,7 +48,7 @@ public class FactoryCrateMessageBuilder extends TangibleMessageBuilder{
buffer.putFloat(1.0f); //op0
buffer.put(getAsciiString("factory_n"));
buffer.putInt(0);
buffer.put(getAsciiString("food_crate"));
buffer.put(getAsciiString(factoryCrateObject.getFactoryCrateType()));
if (factoryCrateObject.getCustomName().length()>0)
buffer.put(getUnicodeString(factoryCrateObject.getCustomName()));
@@ -42,6 +42,7 @@ import engine.resources.scene.Point3D;
import engine.resources.scene.Quaternion;
import resources.objects.ObjectMessageBuilder;
import resources.objects.creature.CreatureObject;
import resources.objects.resource.ResourceContainerObject;
import resources.objects.tangible.TangibleObject;
@Persistent(version=0)
@@ -53,7 +54,13 @@ public class FactoryCrateObject extends TangibleObject implements Serializable {
private byte capacity;
private byte contentObjectQuantity;
private int contentCRC;
private TangibleObject contentObjectType;
//private TangibleObject contentObjectType;
private String contentObjectTypeTemplate;
private String contentObjectType;
private String factoryCrateType;
private Map<String,String> contentAttributes;
private String contentFilename;
private String crateSerialNumber;
@NotPersistent
private transient FactoryCrateMessageBuilder messageBuilder;
@@ -72,29 +79,22 @@ public class FactoryCrateObject extends TangibleObject implements Serializable {
public FactoryCrateObject(long objectID, Planet planet, Point3D position, Quaternion orientation, String template) {
super(objectID, planet, position, orientation, template);
this.messageBuilder = new FactoryCrateMessageBuilder(this);
this.contents = new Vector<TangibleObject>();
this.contentObjectQuantity = 0;
this.capacity = 25;
this.getAttributes().put("@obj_attr_n:condition", "100/100");
this.getAttributes().put("@obj_attr_n:volume", "1");
this.getAttributes().put("@obj_attr_n:quantity", "1");
this.getAttributes().put("@obj_attr_n:factory_count", "1");
this.getAttributes().put("@obj_attr_n:factory_attribs", "------------");
this.getAttributes().put("@obj_attr_n:type", "@got_n:component");
this.getAttributes().put("@obj_attr_n:serial_number", "123");
this.factoryCrateType = "factory_crate";
this.contentObjectType = "";
//this.setStackable(true);
}
public boolean setContentType(TangibleObject contentObject) {
synchronized(objectMutex) {
this.contentObjectType = contentObject;
this.contentObjectTypeTemplate = contentObject.getTemplate();
if (contentObject.getTemplate().length()>0)
this.contentCRC = CRC.StringtoCRC(contentObject.getTemplate());
else
this.contentCRC = 0;
Map<String,String> contentAttributes = contentObject.getAttributes();
contentAttributes = contentObject.getAttributes();
for (Map.Entry<String, String> entry : contentAttributes.entrySet())
{
//if (!entry.getKey().equals(@obj_attr_n:condition))
@@ -105,13 +105,13 @@ public class FactoryCrateObject extends TangibleObject implements Serializable {
}
}
public TangibleObject getContentType() {
public String getContentType() {
return this.contentObjectType;
}
public boolean setContentTypeAndQuantity(TangibleObject contentObject, int quantity) {
synchronized(objectMutex) {
this.contentObjectType = contentObject;
this.contentObjectTypeTemplate = contentObject.getTemplate();
if (contentObject.getTemplate().length()>0)
this.contentCRC = CRC.StringtoCRC(contentObject.getTemplate());
else{
@@ -119,33 +119,101 @@ public class FactoryCrateObject extends TangibleObject implements Serializable {
return false; // Does it make sense to continue anyway?
}
Map<String,String> contentAttributes = contentObject.getAttributes();
this.setCustomName(contentObject.getCustomName());
contentAttributes = contentObject.getAttributes();
for (Map.Entry<String, String> entry : contentAttributes.entrySet())
{
//if (!entry.getKey().equals(@obj_attr_n:condition))
this.getAttributes().put(entry.getKey(), entry.getValue());
System.out.println(entry.getKey() + " " + entry.getValue());
}
if (quantity<capacity) {
contentObject.setSerialNumber(contentObject.getSerialNumber());
if (quantity<=capacity) {
this.setSerialNumber(contentObject.getSerialNumber());
for (int i=0;i<quantity;i++){
contents.add(contentObject);
//contents.add(contentObject);
this.setUses(this.getUses()+1);
this.sendAddItem(this.getClient());
System.out.println("i " + i);
}
contentObjectQuantity = (byte) quantity;
contentObjectQuantity = (byte) quantity;
this.sendSetQuantity(this.getClient(),quantity);
return true;
}
return false;
}
}
public boolean setContentTypeAndQuantity(TangibleObject contentObject, int quantity, String crateType, String contentType, Client client, boolean destroyContentObject) {
synchronized(objectMutex) {
this.setClient(client);
if (crateType!=null)
if (crateType.length()>0)
this.factoryCrateType = crateType;
if (contentType!=null)
if (contentType.length()>0)
this.contentObjectType = contentType;
this.contentObjectTypeTemplate = contentObject.getTemplate();
contentFilename = contentObject.getStfFilename();
if (contentObject.getTemplate().length()>0)
this.contentCRC = CRC.StringtoCRC(contentObject.getTemplate());
else{
this.contentCRC = 0;
return false; // Does it make sense to continue anyway?
}
if (contentObject.getSerialNumber()==null){
crateSerialNumber = main.NGECore.getInstance().reverseEngineeringService.createSerialNumber();
} else {
crateSerialNumber = contentObject.getSerialNumber();
}
this.setCustomName(contentObject.getCustomName());
this.getAttributes().put("@obj_attr_n:condition", "100/100");
this.getAttributes().put("@obj_attr_n:volume", "1");
this.getAttributes().put("@obj_attr_n:quantity", "1");
this.getAttributes().put("@obj_attr_n:factory_count", "1");
this.getAttributes().put("@obj_attr_n:factory_attribs", "------------");
this.getAttributes().put("@obj_attr_n:type", "@got_n:"+contentType);
if (contentObject.getStringAttribute("@obj_attr_n:original_name")!=null)
this.getAttributes().put("@obj_attr_n:original_name", contentObject.getStringAttribute("@obj_attr_n:original_name"));
if (contentObject.getStringAttribute("@obj_attr_n:crafter")!=null)
this.getAttributes().put("@obj_attr_n:crafter", contentObject.getStringAttribute("@obj_attr_n:crafter"));
this.getAttributes().put("@obj_attr_n:serial_number", crateSerialNumber);
contentAttributes = contentObject.getAttributes();
for (Map.Entry<String, String> entry : contentAttributes.entrySet())
{
//if (!entry.getKey().equals(@obj_attr_n:condition))
if (entry.getKey()!=null && entry.getValue()!=null)
this.getAttributes().put(entry.getKey(), entry.getValue());
}
if (quantity<=capacity) {
//this.setSerialNumber(contentObject.getSerialNumber());
// for (int i=0;i<quantity;i++){
// //contents.add(contentObject);
// //this.setUses(this.getUses()+1);
// //this.sendAddItem(this.getClient());
// }
contentObjectQuantity = (byte) quantity;
//this.sendSetQuantity(this.getClient(),quantity);
if (destroyContentObject)
main.NGECore.getInstance().objectService.destroyObject(contentObject.getObjectID());
return true;
}
return false;
}
}
public boolean addToCrate(TangibleObject contentObject) {
synchronized(objectMutex) {
if (contentObjectQuantity<capacity) {
if (! contents.isEmpty()) {
TangibleObject serialProvider = contents.firstElement();
contentObject.setSerialNumber(serialProvider.getSerialNumber());
}
contents.add(contentObject);
// if (! contents.isEmpty()) {
// TangibleObject serialProvider = contents.firstElement();
// contentObject.setSerialNumber(serialProvider.getSerialNumber());
// }
//contents.add(contentObject);
contentObjectQuantity ++;
return true;
@@ -156,34 +224,46 @@ public class FactoryCrateObject extends TangibleObject implements Serializable {
public String getContentFilename() {
if (!contents.isEmpty()) {
return contents.firstElement().getStfFilename();
// return contents.firstElement().getStfFilename();
return contentFilename;
} else {
System.err.println("Crate is empty");
}
return null;
}
public void getObjectOutOfCrate(CreatureObject player,NGECore core) {
public void getObjectOutOfCrate(CreatureObject player) {
synchronized(objectMutex) {
if (this.getQuantity()>0){
TangibleObject contentType = this.getContentType();
if (contentType==null)
return; // Bad, crate had no content type set
TangibleObject contentItem = (TangibleObject) core.objectService.createObject(contentType.getTemplate(), player.getPlanet());
NGECore core = main.NGECore.getInstance();
if (this.getQuantity()>0){
TangibleObject contentItem = (TangibleObject) core.objectService.createObject(contentObjectTypeTemplate, player.getPlanet());
contentItem.setOptions(resources.datatables.Options.SERIAL, true);
int crc = this.getContentCRC();//CRC.StringtoCRC("object/tangible/food/crafted/shared_drink_alcohol.iff");
SceneCreateObjectByCrc createObjectMsg = new SceneCreateObjectByCrc(contentItem.getObjectID(), player.getOrientation().x, player.getOrientation().y, player.getOrientation().z, player.getOrientation().w, player.getPosition().x, player.getPosition().y, player.getPosition().z, crc, (byte) 0);
player.getClient().getSession().write(createObjectMsg.serialize());
contentItem.sendBaselines(player.getClient()); // TANO 3,6,8,9 Baselines
SceneEndBaselines sceneEndBaselinesMsg = new SceneEndBaselines(contentItem.getObjectID());
player.getClient().getSession().write(sceneEndBaselinesMsg.serialize());
contentItem.setSerialNumber(this.getSerialNumber());
// int crc = this.getContentCRC();//CRC.StringtoCRC("object/tangible/food/crafted/shared_drink_alcohol.iff");
// SceneCreateObjectByCrc createObjectMsg = new SceneCreateObjectByCrc(contentItem.getObjectID(), player.getOrientation().x, player.getOrientation().y, player.getOrientation().z, player.getOrientation().w, player.getPosition().x, player.getPosition().y, player.getPosition().z, crc, (byte) 0);
// player.getClient().getSession().write(createObjectMsg.serialize());
// contentItem.sendBaselines(player.getClient()); // TANO 3,6,8,9 Baselines
// SceneEndBaselines sceneEndBaselinesMsg = new SceneEndBaselines(contentItem.getObjectID());
// player.getClient().getSession().write(sceneEndBaselinesMsg.serialize());
for (Map.Entry<String, String> entry : contentAttributes.entrySet()){
//contentItem.getAttributes().put(entry.getKey(),entry.getValue());
System.out.println("entry.getKey()"+entry.getKey());
System.out.println("entry.getValue()"+entry.getValue());
if (entry.getKey()!=null && entry.getValue()!=null)
contentItem.setStringAttribute(entry.getKey(),entry.getValue());
}
contentItem.setCustomName(this.getCustomName());
long parentId = this.getParentId();
SWGObject parentContainer = core.objectService.getObject(parentId);
if (parentContainer==null)
return; // crate has no parent, error
UpdateContainmentMessage updateContainmentMessage= new UpdateContainmentMessage(contentItem.getObjectID(), parentContainer.getObjectID(), -1);
player.getClient().getSession().write(updateContainmentMessage.serialize());
// UpdateContainmentMessage updateContainmentMessage= new UpdateContainmentMessage(contentItem.getObjectID(), parentContainer.getObjectID(), -1);
// player.getClient().getSession().write(updateContainmentMessage.serialize());
parentContainer.add(contentItem);
this.sendSetQuantity(player.getClient(),this.getQuantity()-1);
if (this.getQuantity()==0){ // Crate is empty now, delete it
@@ -210,10 +290,11 @@ public class FactoryCrateObject extends TangibleObject implements Serializable {
}
public String getSerialNumber() {
if (!contents.isEmpty()) {
return contents.firstElement().getSerialNumber();
}
return "";
// if (!contents.isEmpty()) {
// return contents.firstElement().getSerialNumber();
// }
return crateSerialNumber;
//return "";
}
public int getContentCRC() {
@@ -226,11 +307,49 @@ public class FactoryCrateObject extends TangibleObject implements Serializable {
}
}
public void handleSplit(){
}
public void splitFactoryCrate(CreatureObject owner, FactoryCrateObject originalObject, String commandString){
String[] splitArray = commandString.split(" ");
if (splitArray.length<3)
return;
int cloneStackQuantity= Integer.parseInt(splitArray[0]);
int parentcontainerID= Integer.parseInt(splitArray[1]);
SWGObject objectParentContainer = (SWGObject) NGECore.getInstance().objectService.getObject(parentcontainerID);
if (objectParentContainer==null || originalObject==null)
return;
FactoryCrateObject newCrateObject = (FactoryCrateObject) NGECore.getInstance().objectService.createObject(originalObject.getTemplate(), owner.getPlanet());
//newCrateObject.cloneStats(originalObject);
TangibleObject contentItem = (TangibleObject) NGECore.getInstance().objectService.createObject(contentObjectTypeTemplate, owner.getPlanet());
contentItem.setOptions(resources.datatables.Options.SERIAL, true);
//contentItem.setSerialNumber(this.getSerialNumber());
for (Map.Entry<String, String> entry : contentAttributes.entrySet()){
//contentItem.getAttributes().put(entry.getKey(),entry.getValue());
System.out.println("entry.getKey()"+entry.getKey());
System.out.println("entry.getValue()"+entry.getValue());
if (entry.getKey()!=null && entry.getValue()!=null)
contentItem.setStringAttribute(entry.getKey(),entry.getValue());
}
contentItem.setCustomName(this.getCustomName());
newCrateObject.setContentTypeAndQuantity(contentItem,cloneStackQuantity, originalObject.getFactoryCrateType(), originalObject.getContentType(), owner.getClient(),true);
newCrateObject.getAttributes().put("@obj_attr_n:factory_count", ""+cloneStackQuantity);
newCrateObject.getAttributes().put("@obj_attr_n:quantity", ""+cloneStackQuantity);
//newCrateObject.sendSetQuantity(owner.getClient(), cloneStackQuantity);
originalObject.sendSetQuantity(owner.getClient(), originalObject.getQuantity()-cloneStackQuantity);
objectParentContainer.add(newCrateObject);
}
public void sendAddItem(Client destination) {
if (destination==null)
return;
destination.getSession().write(messageBuilder.buildDelta3());
this.getAttributes().put("@obj_attr_n:factory_count", ""+this.getQuantity());
this.getAttributes().put("@obj_attr_n:quantity", ""+this.getQuantity());
@@ -238,6 +357,8 @@ public class FactoryCrateObject extends TangibleObject implements Serializable {
}
public void sendSetQuantity(Client destination,int quantity) {
if (destination==null)
return;
contentObjectQuantity = (byte) quantity;
destination.getSession().write(messageBuilder.buildDelta3());
this.getAttributes().put("@obj_attr_n:factory_count", ""+quantity);
@@ -276,4 +397,8 @@ public class FactoryCrateObject extends TangibleObject implements Serializable {
return messageBuilder;
}
public String getFactoryCrateType(){
return factoryCrateType;
}
}
+10
View File
@@ -95,6 +95,8 @@ public class DevService implements INetworkDispatch {
suiOptions.put((long) 130, "Vehicle Deeds");
if (creature.getClient().isGM()) {
suiOptions.put((long) 121, "Sandbox City");
if(creature.getPlayerObject().getProfession().equals("trader_0a") || creature.getPlayerObject().getProfession().equals("trader_0b") || creature.getPlayerObject().getProfession().equals("trader_0c") || creature.getPlayerObject().getProfession().equals("trader_0d"))
suiOptions.put((long) 177, "REing");
}
break;
@@ -1309,6 +1311,14 @@ public class DevService implements INetworkDispatch {
case 153:
Point3D position = new Point3D(-6222,1,7380);
core.simulationService.transferToPlanet(player, core.terrainService.getPlanetByName("dantooine"), position, player.getOrientation(), null);
case 177:
// "object/draft_schematic/item/shared_item_reverse_engineering_tool.iff"
TangibleObject REingTool = (TangibleObject) core.objectService.createObject("object/tangible/container/loot/shared_reverse_engineer_tool.iff", planet);
REingTool.setCustomName("Reverse Engineering Tool");
inventory.add(REingTool);
core.lootService.prepInv2(player);
return;
}
}
});
+165 -1
View File
@@ -47,6 +47,7 @@ import resources.datatables.DisplayType;
import resources.loot.LootGroup;
import resources.loot.LootRollSession;
import resources.objects.creature.CreatureObject;
import resources.objects.factorycrate.FactoryCrateObject;
import resources.objects.group.GroupObject;
import resources.objects.intangible.IntangibleObject;
import resources.objects.tangible.TangibleObject;
@@ -616,6 +617,7 @@ public class LootService implements INetworkDispatch {
String requiredFaction = "";
Vector<String> customizationAttributes = null;
Vector<Integer> customizationValues = null;
Vector<String> reverse_engineering_name = null;
int customColor1 = 0;
String lootDescriptor = "";
Vector<String> itemStats = null;
@@ -649,6 +651,9 @@ public class LootService implements INetworkDispatch {
if(core.scriptService.getMethod(itemPath,"","customizationValues")!=null)
customizationValues = (Vector<Integer>)core.scriptService.fetchIntegerVector(itemPath,"customizationValues");
if(core.scriptService.getMethod(itemPath,"","reverse_engineering_name")!=null)
reverse_engineering_name = (Vector<String>)core.scriptService.fetchStringVector(itemPath,"reverse_engineering_name");
if(core.scriptService.getMethod(itemPath,"","customColor1")!=null)
customColor1 = (Integer)core.scriptService.fetchInteger(itemPath,"customColor1");
@@ -698,6 +703,7 @@ public class LootService implements INetworkDispatch {
droppedItem.setAttachment("LootItemName", itemName);
droppedItem.setAttachment("customColor1", customColor1);
droppedItem.setAttachment("lootDescriptor", lootDescriptor);
droppedItem.setAttachment("reverse_engineering_name", reverse_engineering_name);
droppedItem.setAttachment("customName", customName);
@@ -1320,7 +1326,7 @@ public class LootService implements INetworkDispatch {
droppedItem.setCustomizationVariable(customizationAttributes.get(i), value);
}
}
}
public void handleSpecialItems(TangibleObject droppedItem,String itemName) {
@@ -2692,6 +2698,164 @@ public class LootService implements INetworkDispatch {
}
public void prepInv2(CreatureObject player){
SWGObject playerInventory = player.getSlottedObject("inventory");
TangibleObject item11 = (TangibleObject)core.objectService.createObject("object/tangible/wearables/armor/composite/shared_armor_composite_bicep_r.iff", player.getPlanet());
item11.setCustomName("Composite Armor Right Bicep");
item11.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 6000);
item11.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 4000);
item11.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 5000);
item11.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 5000);
item11.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 5000);
item11.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 5000);
item11.setIntAttribute("cat_stat_mod_bonus.@stat_n:agility_modified", 25);
item11.setIntAttribute("cat_stat_mod_bonus.@stat_n:constitution_modified", 25);
item11.setIntAttribute("cat_stat_mod_bonus.@stat_n:precision_modified", 25);
playerInventory.add(item11);
TangibleObject item11a = (TangibleObject)core.objectService.createObject("object/tangible/wearables/armor/composite/shared_armor_composite_bicep_r.iff", player.getPlanet());
item11.setCustomName("Composite Armor Right Bicep");
item11a.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 6000);
item11a.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 4000);
item11a.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 5000);
item11a.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 5000);
item11a.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 5000);
item11a.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 5000);
item11a.setIntAttribute("cat_stat_mod_bonus.@stat_n:agility_modified", 25);
item11a.setIntAttribute("cat_stat_mod_bonus.@stat_n:constitution_modified", 25);
playerInventory.add(item11a);
TangibleObject item12aa = (TangibleObject)core.objectService.createObject("object/tangible/wearables/shirt/shared_shirt_s07.iff", player.getPlanet());
item12aa.setCustomName("Socketed Shirt");
item12aa.setIntAttribute("@obj_attr_n:sockets", 1);
playerInventory.add(item12aa);
TangibleObject item12 = (TangibleObject)core.objectService.createObject("object/tangible/wearables/shirt/shared_shirt_s07.iff", player.getPlanet());
item12.setStfFilename("wearables_name");
item12.setStfName("shirt_s01");
item12.setDetailFilename("wearables_detail");
item12.setDetailName("shirt_s01");
item12.setCustomName("Socketed Shirt");
item12.getAttributes().put("@obj_attr_n:crafter", "Charon");
item12.setIntAttribute("@obj_attr_n:sockets", 1);
String crateTemplate = "object/factory/shared_factory_crate_clothing.iff";
FactoryCrateObject crate1 = (FactoryCrateObject) core.objectService.createObject(crateTemplate, player.getPlanet());
crate1.setContentTypeAndQuantity(item12,25, "clothing_factory_crate", "clothing", player.getClient(),true);
playerInventory.add(crate1);
TangibleObject item12a = (TangibleObject)core.objectService.createObject("object/tangible/wearables/shirt/shared_shirt_s07.iff", player.getPlanet());
item12a.setCustomName("Socketed Shirt");
item12a.setIntAttribute("cat_stat_mod_bonus.@stat_n:agility_modified", 18);
playerInventory.add(item12a);
String powerBitTemplate = "object/tangible/component/reverse_engineering/shared_power_bit.iff";
TangibleObject powerBit = (TangibleObject) core.objectService.createObject(powerBitTemplate, player.getPlanet());
powerBit.setCustomName("+25 2nd Order Power Bit");
powerBit.setAttachment("PowerBitValue", 25);
powerBit.setAttachment("PowerBitOrder", 2);
playerInventory.add(powerBit);
TangibleObject powerBit2 = (TangibleObject) core.objectService.createObject(powerBitTemplate, player.getPlanet());
powerBit2.setCustomName("+25 3nd Order Power Bit");
powerBit2.setAttachment("PowerBitValue", 25);
powerBit2.setAttachment("PowerBitOrder", 3);
playerInventory.add(powerBit2);
TangibleObject powerBit3 = (TangibleObject) core.objectService.createObject(powerBitTemplate, player.getPlanet());
powerBit3.setCustomName("+25 1st Order Power Bit");
powerBit3.setAttachment("PowerBitValue", 25);
powerBit3.setAttachment("PowerBitOrder", 1);
playerInventory.add(powerBit3);
TangibleObject item24a = (TangibleObject)core.objectService.createObject("object/tangible/loot/npc_loot/shared_medical_console_generic.iff", player.getPlanet());
item24a.setCustomName("Medical Console");
item24a.setStackable(true);
item24a.setUses(299);
core.objectService.addStackableItem(item24a,playerInventory);
TangibleObject item24b = (TangibleObject)core.objectService.createObject("object/tangible/loot/npc_loot/shared_medical_device_generic.iff", player.getPlanet());
item24b.setCustomName("Medical Device");
item24b.setStackable(true);
item24b.setUses(399);
core.objectService.addStackableItem(item24b,playerInventory);
String modifierBitTemplate = "object/tangible/component/reverse_engineering/shared_modifier_bit.iff";
TangibleObject modifierBit = (TangibleObject) core.objectService.createObject(modifierBitTemplate, player.getPlanet());
modifierBit.setCustomName("Droid Experimentation");
modifierBit.setStringAttribute("serial_number", core.reverseEngineeringService.createSerialNumber());
modifierBit.setStringAttribute("@crafting:mod_bit_type", "@stat_n:droid_experimentation");
modifierBit.setIntAttribute("@crafting:mod_bit_ratio", 4);
playerInventory.add(modifierBit);
modifierBit = (TangibleObject) core.objectService.createObject(modifierBitTemplate, player.getPlanet());
modifierBit.setCustomName("Droid Experimentation");
modifierBit.setStringAttribute("serial_number", core.reverseEngineeringService.createSerialNumber());
modifierBit.setStringAttribute("@crafting:mod_bit_type", "@stat_n:droid_experimentation");
modifierBit.setIntAttribute("@crafting:mod_bit_ratio", 4);
playerInventory.add(modifierBit);
modifierBit = (TangibleObject) core.objectService.createObject(modifierBitTemplate, player.getPlanet());
modifierBit.setCustomName("Droid Experimentation");
modifierBit.setStringAttribute("serial_number", core.reverseEngineeringService.createSerialNumber());
modifierBit.setStringAttribute("@crafting:mod_bit_type", "@stat_n:droid_experimentation");
modifierBit.setIntAttribute("@crafting:mod_bit_ratio", 4);
playerInventory.add(modifierBit);
String SEALabel = "socket_gem_armor";
String SEADescription = "socket_gem";
String SEATemplate = "object/tangible/gem/shared_clothing.iff";
TangibleObject skillEnhancingAttachment = (TangibleObject)core.objectService.createObject(SEATemplate, player.getPlanet());
skillEnhancingAttachment.setStfFilename("item_n");
skillEnhancingAttachment.setStfName(SEALabel);
skillEnhancingAttachment.setDetailFilename("item_n");
skillEnhancingAttachment.setDetailName(SEADescription);
String effectName = "@stat_n:expertise_glancing_blow_ranged";
int modifierValue = 5;
skillEnhancingAttachment.setIntAttribute(effectName, modifierValue);
Vector<String> effectNameList = new Vector<String>();
effectNameList.add(effectName);
Vector<Integer> effectValueList = new Vector<Integer>();
effectValueList.add(modifierValue);
skillEnhancingAttachment.setAttachment("SEAeffectNameList", effectNameList);
skillEnhancingAttachment.setAttachment("SEAmodifierValueList", effectValueList);
playerInventory.add(skillEnhancingAttachment);
TangibleObject skillEnhancingAttachment2 = (TangibleObject)core.objectService.createObject(SEATemplate, player.getPlanet());
skillEnhancingAttachment2.setStfFilename("item_n");
skillEnhancingAttachment2.setStfName(SEALabel);
skillEnhancingAttachment2.setDetailFilename("item_n");
skillEnhancingAttachment2.setDetailName(SEADescription);
effectName = "@stat_n:expertise_action_weapon_5";
String effectName2 = "@stat_n:expertise_critical_line_sp_dm";
modifierValue = 5;
skillEnhancingAttachment2.setIntAttribute(effectName, modifierValue);
skillEnhancingAttachment2.setIntAttribute(effectName2, 6);
effectNameList = new Vector<String>();
effectNameList.add(effectName);
effectNameList.add(effectName2);
effectValueList = new Vector<Integer>();
effectValueList.add(modifierValue);
effectValueList.add(6);
skillEnhancingAttachment2.setAttachment("SEAeffectNameList", effectNameList);
skillEnhancingAttachment2.setAttachment("SEAmodifierValueList", effectValueList);
playerInventory.add(skillEnhancingAttachment2);
}
/*
1377 wpn_category_0 Rifle
+57 -2
View File
@@ -48,6 +48,7 @@ import engine.resources.service.INetworkRemoteEvent;
import resources.objects.player.PlayerObject;
import resources.objects.tangible.TangibleObject;
import resources.objects.weapon.WeaponObject;
import resources.skills.SkillMod;
public class EquipmentService implements INetworkDispatch {
@@ -196,7 +197,49 @@ public class EquipmentService implements INetworkDispatch {
if(equipping)
{
if(item.getStringAttribute("cat_wpn_damage.wpn_category") != null) core.skillModService.addSkillMod(creature, "display_only_critical", getWeaponCriticalChance(creature, item));
if(item.getStringAttribute("cat_wpn_damage.wpn_category") != null) {
core.skillModService.addSkillMod(creature, "display_only_critical", getWeaponCriticalChance(creature, item));
creature.setAttachment("EquippedWeapon", item.getObjectID());
// Check if weapon has power up active
if (item.getAttachment("PUPEndTime")!=null){
long pupEndTime = (long)item.getAttachment("PUPEndTime");
if (pupEndTime>System.currentTimeMillis()){
// do nothing let the rest add the mods
} else {
// Make sure pup buff icons are cleared
}
}
}
if(item.getTemplate().contains("shirt")) {
creature.setAttachment("EquippedShirt", item.getObjectID());
// Check if shirt has power up active
if (item.getAttachment("PUPEndTime")!=null){
long pupEndTime = (long)item.getAttachment("PUPEndTime");
if (pupEndTime>System.currentTimeMillis()){
// do nothing let the rest add the mods
} else {
// Make sure pup buff icons are cleared
}
}
}
if(item.getTemplate().contains("chest")) {
creature.setAttachment("EquippedChest", item.getObjectID());
// Check if chest has power up active
if (item.getAttachment("PUPEndTime")!=null){
long pupEndTime = (long)item.getAttachment("PUPEndTime");
if (pupEndTime>System.currentTimeMillis()){
// do nothing let the rest add the mods
} else {
// Make sure pup buff icons are cleared
}
}
}
if(item.getStringAttribute("proc_name") != null) core.buffService.addBuffToCreature(creature, item.getStringAttribute("proc_name").replace("@ui_buff:", ""), creature);
for(Entry<String, Object> e : attributes.entrySet())
@@ -224,7 +267,19 @@ public class EquipmentService implements INetworkDispatch {
}
else
{
if(item.getStringAttribute("cat_wpn_damage.wpn_category") != null) core.skillModService.deductSkillMod(creature, "display_only_critical", getWeaponCriticalChance(creature, item));
if(item.getStringAttribute("cat_wpn_damage.wpn_category") != null){
core.skillModService.deductSkillMod(creature, "display_only_critical", getWeaponCriticalChance(creature, item));
creature.setAttachment("EquippedWeapon", null);
}
if(item.getTemplate().contains("shirt")) {
creature.setAttachment("EquippedShirt", null);
}
if(item.getTemplate().contains("chest")) {
creature.setAttachment("EquippedChest", null);
}
if(item.getStringAttribute("proc_name") != null) core.buffService.removeBuffFromCreatureByName(creature, item.getStringAttribute("proc_name").replace("@ui_buff:", ""));
for(Entry<String, Object> e : attributes.entrySet())
+107
View File
@@ -726,6 +726,83 @@ public class ObjectService implements INetworkDispatch {
}
}
// Check if used item was a PUP
String powerUpTemplate1 = "object/tangible/powerup/base/shared_armor_base.iff";
String powerUpTemplate2 = "object/tangible/powerup/base/shared_base.iff";
String powerUpTemplate3 = "object/tangible/powerup/base/shared_weapon_base.iff";
if (object.getTemplate().equals(powerUpTemplate1)){
// chestplate
String effectName = (String) object.getAttachment("effectName");
int powerValue = (int) object.getAttachment("powerValue");
Long chestID = (Long) creature.getAttachment("EquippedChest");
if (chestID==null)
return;
TangibleObject chest = (TangibleObject) core.objectService.getObject(chestID);
//chest.setIntAttribute(effectName, powerValue);
chest.setAttachment("PUPEffectName", effectName);
chest.setAttachment("PUPEffectValue", powerValue);
}
if (object.getTemplate().equals(powerUpTemplate2)){
// Shirt
String effectName = (String) object.getAttachment("effectName");
int powerValue = (int) object.getAttachment("powerValue");
Long shirtID = (Long) creature.getAttachment("EquippedShirt");
if (shirtID==null)
return;
TangibleObject shirt = (TangibleObject) core.objectService.getObject(shirtID);
//shirt.setIntAttribute(effectName, powerValue);
shirt.setAttachment("PUPEffectName", effectName);
shirt.setAttachment("PUPEffectValue", powerValue);
}
if (object.getTemplate().equals(powerUpTemplate3)){
// weapon
String effectName = (String) object.getAttachment("effectName");
int powerValue = (int) object.getAttachment("powerValue");
Long weaponID = (Long) creature.getAttachment("EquippedWeapon");
if (weaponID==null)
return;
WeaponObject weapon = (WeaponObject) core.objectService.getObject(weaponID);
//weapon.setIntAttribute(effectName, powerValue);
weapon.setAttachment("PUPEffectName", effectName);
weapon.setAttachment("PUPEffectValue", powerValue);
List<String> statList = new ArrayList<String>();
statList.add("constitution_modified");
statList.add("agility_modified");
statList.add("precision_modified");
statList.add("strength_modified");
statList.add("stamina_modified");
statList.add("luck_modified");
if (statList.contains(effectName)){
// Probably this has to be done preferably via the buff service or a new power up service
// Problem : Some of the effect names do NOT occur in buff.iff
// So Light or Treeku better look into this
weapon.setIntAttribute("cat_stat_mod_bonus."+effectName, powerValue);
core.skillModService.addSkillMod(creature, "cat_stat_mod_bonus."+effectName, powerValue);
} else {
// assume skillmod then
weapon.setIntAttribute("cat_skill_mod_bonus."+effectName, powerValue);
core.skillModService.addSkillMod(creature, "cat_skill_mod_bonus."+effectName, powerValue);
}
int amount = object.getIntAttribute("num_in_stack");
if (amount==1)
destroyObject(object.getObjectID());
else
object.setIntAttribute("num_in_stack",amount-1);
}
creature.setUseTarget(object);
int reuse_time;
@@ -1307,4 +1384,34 @@ public class ObjectService implements INetworkDispatch {
odb.remove(key);
}
public void addStackableItem(TangibleObject item, SWGObject container) {
// Maybe even better placed inside SWGObject.add(), so whenever an item is added to a container
// it will bechecked if it is stackable and if there is already a stack to add it to
if (! item.isStackable())
container.add(item);
final Vector<SWGObject> alikeItemsInContainer = new Vector<SWGObject>();
container.viewChildren(container, false, false, new Traverser() {
@Override
public void process(SWGObject obj) {
if (obj.getTemplate().equals(item.getTemplate())){
alikeItemsInContainer.add(obj);
System.out.println(obj.getTemplate());
}
}
});
if (alikeItemsInContainer.size()==0){
container.add(item);
return;
}
TangibleObject alikeItem = (TangibleObject)alikeItemsInContainer.get(0);
int alikeUses = alikeItem.getUses();
int itemUses = item.getUses();
if (itemUses==0)
itemUses=1;
int newUses = alikeUses+itemUses;
alikeItem.setUses(newUses);
core.objectService.destroyObject(item.getObjectID());
}
}
File diff suppressed because it is too large Load Diff