Permalink
Browse files

Merge branch 'develop' into python_exception_logging

  • Loading branch information...
2 parents 4b37a71 + c1028c6 commit eb077dae2dcdf0143b4a09e93b3da08ee09a9a47 @rcythr rcythr committed Mar 6, 2013
Showing 311 changed files with 2,478 additions and 471 deletions.
@@ -1,7 +1,7 @@
import swgpy
from swgpy.object import *
from swgpy.attributes import *
-from attributes.AttributeHelpers import SetOptionalAttribute
+from attributes.AttributeHelpers import SetOptionalAttribute, RAW, PERCENT, PERCENT_DASH
class ArmorAttributeTemplate(BaseAttributeTemplate):
def buildAttributeTemplate(self, object):
attribute_list_message = AttributeListMessage()
@@ -10,41 +10,41 @@ def buildAttributeTemplate(self, object):
if len(object.custom_name) > 0:
attributes.append("@obj_attr_n:original_name", "@" + object.stf_file + ":" + object.stf_name)
attributes.extend([
- Attribute("@obj_attr_n:condition", str(object.condition_damage) + "/" + str(object.max_condition)),
+ Attribute("@obj_attr_n:condition", str(object.max_condition-object.condition_damage) + "/" + str(object.max_condition)),
Attribute("@obj_attr_n:volume", str(object.volume)),
Attribute("@obj_attr_n:armor_rating", object.getStringAttribute("armor_rating"))
])
SetOptionalAttribute(attributes, '@obj_attr_n:sockets', 'sockets', object, True)
- SetOptionalAttribute(attributes, "cat_armor_special_protection.@obj_attr_n:armor_eff_kinetic", "cat_armor_special_protection.armor_eff_kinetic", object, True);
- SetOptionalAttribute(attributes, "cat_armor_special_protection.@obj_attr_n:armor_eff_energy", "cat_armor_special_protection.armor_eff_energy", object, True);
- SetOptionalAttribute(attributes, "cat_armor_special_protection.@obj_attr_n:armor_eff_blast", "cat_armor_special_protection.armor_eff_blast", object, True);
- SetOptionalAttribute(attributes, "cat_armor_special_protection.@obj_attr_n:armor_eff_stun", "cat_armor_special_protection.armor_eff_stun", object, True);
- SetOptionalAttribute(attributes, "cat_armor_special_protection.@obj_attr_n:armor_eff_elemental_heat", "cat_armor_special_protection.armor_eff_elemental_heat", object, True);
- SetOptionalAttribute(attributes, "cat_armor_special_protection.@obj_attr_n:armor_eff_elemental_cold", "cat_armor_special_protection.armor_eff_elemental_cold", object, True);
- SetOptionalAttribute(attributes, "cat_armor_special_protection.@obj_attr_n:armor_eff_elemental_acid", "cat_armor_special_protection.armor_eff_elemental_acid", object, True);
- SetOptionalAttribute(attributes, "cat_armor_special_protection.@obj_attr_n:armor_eff_elemental_electrical", "cat_armor_special_protection.armor_eff_elemental_electrical", object, True);
- SetOptionalAttribute(attributes, "cat_armor_special_protection.@obj_attr_n:armor_eff_restraint", "cat_armor_special_protection.armor_eff_restraint", object, True);
- SetOptionalAttribute(attributes, "cat_armor_effectiveness.@obj_attr_n:armor_eff_kinetic", "cat_armor_effectiveness.armor_eff_restraint", object, True);
- SetOptionalAttribute(attributes, "cat_armor_effectiveness.@obj_attr_n:armor_eff_energy", "cat_armor_effectiveness.armor_eff_energy", object, True);
- SetOptionalAttribute(attributes, "cat_armor_effectiveness.@obj_attr_n:armor_eff_blast", "cat_armor_effectiveness.armor_eff_blast", object, True);
- SetOptionalAttribute(attributes, "cat_armor_effectiveness.@obj_attr_n:armor_eff_stun", "cat_armor_effectiveness.armor_eff_stun", object, True);
- SetOptionalAttribute(attributes, "cat_armor_effectiveness.@obj_attr_n:armor_eff_elemental_heat", "cat_armor_effectiveness.armor_eff_elemental_heat", object, True);
- SetOptionalAttribute(attributes, "cat_armor_effectiveness.@obj_attr_n:armor_eff_elemental_cold", "cat_armor_effectiveness.armor_eff_elemental_cold", object, True);
- SetOptionalAttribute(attributes, "cat_armor_effectiveness.@obj_attr_n:armor_eff_elemental_acid", "cat_armor_effectiveness.armor_eff_elemental_acid", object, True);
- SetOptionalAttribute(attributes, "cat_armor_effectiveness.@obj_attr_n:armor_eff_elemental_electrical", "cat_armor_effectiveness.armor_eff_elemental_electrical", object, True);
- SetOptionalAttribute(attributes, "cat_armor_effectiveness.@obj_attr_n:armor_eff_restraint", "cat_armor_effectiveness.armor_eff_restraint", object, True);
- SetOptionalAttribute(attributes, "cat_armor_vulnerability.@obj_attr_n:armor_eff_kinetic", "cat_armor_vulnerability.armor_eff_kinetic", object, True);
- SetOptionalAttribute(attributes, "cat_armor_vulnerability.@obj_attr_n:armor_eff_energy", "cat_armor_vulnerability.armor_eff_energy", object, True);
- SetOptionalAttribute(attributes, "cat_armor_vulnerability.@obj_attr_n:armor_eff_blast", "cat_armor_vulnerability.armor_eff_blast", object, True);
- SetOptionalAttribute(attributes, "cat_armor_vulnerability.@obj_attr_n:armor_eff_stun", "cat_armor_vulnerability.armor_eff_stun", object, True);
- SetOptionalAttribute(attributes, "cat_armor_vulnerability.@obj_attr_n:armor_eff_elemental_heat", "cat_armor_vulnerability.armor_eff_elemental_heat", object, True);
- SetOptionalAttribute(attributes, "cat_armor_vulnerability.@obj_attr_n:armor_eff_elemental_cold", "cat_armor_vulnerability.armor_eff_elemental_cold", object, True);
- SetOptionalAttribute(attributes, "cat_armor_vulnerability.@obj_attr_n:armor_eff_elemental_acid", "cat_armor_vulnerability.armor_eff_elemental_acid", object, True);
- SetOptionalAttribute(attributes, "cat_armor_vulnerability.@obj_attr_n:armor_eff_elemental_electrical", "cat_armor_vulnerability.armor_eff_elemental_electrical", object, True);
- SetOptionalAttribute(attributes, "cat_armor_vulnerability.@obj_attr_n:armor_eff_restraint", "cat_armor_vulnerability.armor_eff_restraint", object, True);
- SetOptionalAttribute(attributes, "cat_armor_encumbrance.@obj_attr_n:armor_health_encumbrance", "cat_armor_encumbrance.armor_health_encumbrance", object, True);
- SetOptionalAttribute(attributes, "cat_armor_encumbrance.@obj_attr_n:armor_action_encumbrance", "cat_armor_encumbrance.armor_action_encumbrance", object, True);
- SetOptionalAttribute(attributes, "cat_armor_encumbrance.@obj_attr_n:armor_mind_encumbrance", "cat_armor_encumbrance.armor_mind_encumbrance", object, True);
+ SetOptionalAttribute(attributes, "cat_armor_special_protection.@obj_attr_n:armor_eff_kinetic", "cat_armor_special_protection.armor_eff_kinetic", object, True, PERCENT);
+ SetOptionalAttribute(attributes, "cat_armor_special_protection.@obj_attr_n:armor_eff_energy", "cat_armor_special_protection.armor_eff_energy", object, True, PERCENT);
+ SetOptionalAttribute(attributes, "cat_armor_special_protection.@obj_attr_n:armor_eff_blast", "cat_armor_special_protection.armor_eff_blast", object, True, PERCENT);
+ SetOptionalAttribute(attributes, "cat_armor_special_protection.@obj_attr_n:armor_eff_stun", "cat_armor_special_protection.armor_eff_stun", object, True, PERCENT);
+ SetOptionalAttribute(attributes, "cat_armor_special_protection.@obj_attr_n:armor_eff_elemental_heat", "cat_armor_special_protection.armor_eff_elemental_heat", object, True, PERCENT);
+ SetOptionalAttribute(attributes, "cat_armor_special_protection.@obj_attr_n:armor_eff_elemental_cold", "cat_armor_special_protection.armor_eff_elemental_cold", object, True, PERCENT);
+ SetOptionalAttribute(attributes, "cat_armor_special_protection.@obj_attr_n:armor_eff_elemental_acid", "cat_armor_special_protection.armor_eff_elemental_acid", object, True, PERCENT);
+ SetOptionalAttribute(attributes, "cat_armor_special_protection.@obj_attr_n:armor_eff_elemental_electrical", "cat_armor_special_protection.armor_eff_elemental_electrical", object, True, PERCENT);
+ SetOptionalAttribute(attributes, "cat_armor_special_protection.@obj_attr_n:armor_eff_restraint", "cat_armor_special_protection.armor_eff_restraint", object, True, PERCENT);
+ SetOptionalAttribute(attributes, "cat_armor_effectiveness.@obj_attr_n:armor_eff_kinetic", "cat_armor_effectiveness.armor_eff_restraint", object, True, PERCENT);
+ SetOptionalAttribute(attributes, "cat_armor_effectiveness.@obj_attr_n:armor_eff_energy", "cat_armor_effectiveness.armor_eff_energy", object, True, PERCENT);
+ SetOptionalAttribute(attributes, "cat_armor_effectiveness.@obj_attr_n:armor_eff_blast", "cat_armor_effectiveness.armor_eff_blast", object, True, PERCENT);
+ SetOptionalAttribute(attributes, "cat_armor_effectiveness.@obj_attr_n:armor_eff_stun", "cat_armor_effectiveness.armor_eff_stun", object, True, PERCENT);
+ SetOptionalAttribute(attributes, "cat_armor_effectiveness.@obj_attr_n:armor_eff_elemental_heat", "cat_armor_effectiveness.armor_eff_elemental_heat", object, True, PERCENT);
+ SetOptionalAttribute(attributes, "cat_armor_effectiveness.@obj_attr_n:armor_eff_elemental_cold", "cat_armor_effectiveness.armor_eff_elemental_cold", object, True, PERCENT);
+ SetOptionalAttribute(attributes, "cat_armor_effectiveness.@obj_attr_n:armor_eff_elemental_acid", "cat_armor_effectiveness.armor_eff_elemental_acid", object, True, PERCENT);
+ SetOptionalAttribute(attributes, "cat_armor_effectiveness.@obj_attr_n:armor_eff_elemental_electrical", "cat_armor_effectiveness.armor_eff_elemental_electrical", object, True, PERCENT);
+ SetOptionalAttribute(attributes, "cat_armor_effectiveness.@obj_attr_n:armor_eff_restraint", "cat_armor_effectiveness.armor_eff_restraint", object, True, PERCENT);
+ SetOptionalAttribute(attributes, "cat_armor_vulnerability.@obj_attr_n:armor_eff_kinetic", "cat_armor_vulnerability.armor_eff_kinetic", object, True, PERCENT_DASH);
+ SetOptionalAttribute(attributes, "cat_armor_vulnerability.@obj_attr_n:armor_eff_energy", "cat_armor_vulnerability.armor_eff_energy", object, True, PERCENT_DASH);
+ SetOptionalAttribute(attributes, "cat_armor_vulnerability.@obj_attr_n:armor_eff_blast", "cat_armor_vulnerability.armor_eff_blast", object, True, PERCENT_DASH);
+ SetOptionalAttribute(attributes, "cat_armor_vulnerability.@obj_attr_n:armor_eff_stun", "cat_armor_vulnerability.armor_eff_stun", object, True, PERCENT_DASH);
+ SetOptionalAttribute(attributes, "cat_armor_vulnerability.@obj_attr_n:armor_eff_elemental_heat", "cat_armor_vulnerability.armor_eff_elemental_heat", object, True, PERCENT_DASH);
+ SetOptionalAttribute(attributes, "cat_armor_vulnerability.@obj_attr_n:armor_eff_elemental_cold", "cat_armor_vulnerability.armor_eff_elemental_cold", object, True, PERCENT_DASH);
+ SetOptionalAttribute(attributes, "cat_armor_vulnerability.@obj_attr_n:armor_eff_elemental_acid", "cat_armor_vulnerability.armor_eff_elemental_acid", object, True, PERCENT_DASH);
+ SetOptionalAttribute(attributes, "cat_armor_vulnerability.@obj_attr_n:armor_eff_elemental_electrical", "cat_armor_vulnerability.armor_eff_elemental_electrical", object, True, PERCENT);
+ SetOptionalAttribute(attributes, "cat_armor_vulnerability.@obj_attr_n:armor_eff_restraint", "cat_armor_vulnerability.armor_eff_restraint", object, True, PERCENT);
+ SetOptionalAttribute(attributes, "cat_armor_encumbrance.@obj_attr_n:health", "cat_armor_encumbrance.armor_health_encumbrance", object, True);
+ SetOptionalAttribute(attributes, "cat_armor_encumbrance.@obj_attr_n:action", "cat_armor_encumbrance.armor_action_encumbrance", object, True);
+ SetOptionalAttribute(attributes, "cat_armor_encumbrance.@obj_attr_n:mind", "cat_armor_encumbrance.armor_mind_encumbrance", object, True);
SetOptionalAttribute(attributes, '@obj_attr_n:crafter', 'crafter', object, False)
SetOptionalAttribute(attributes, '@obj_attr_n:serial_number', 'serial_number', object, False)
attribute_list_message.attributes = attributes
@@ -1,12 +1,29 @@
import swgpy
from swgpy.object import *
from swgpy.attributes import *
-def SetOptionalAttribute(attribute_list, attribute_name, attribute_label, object, is_recursive):
+
+def RAW(input):
+ return input
+
+def PERCENT(input):
+ return ('%.1f' % float(input)) + "%"
+
+def PERCENT_DASH(input):
+ output = PERCENT(input)
+ if output == '0.0%':
+ return '-';
+ else:
+ return output
+
+def SetOptionalAttribute(attribute_list, attribute_name, attribute_label, object, is_recursive, func=RAW):
attr_val = ""
if is_recursive:
attr_val = object.getAttributeRecursive(attribute_label)
else:
if object.hasAttribute(attribute_label):
attr_val = object.getStringAttribute(attribute_label)
- if len(attr_val) > 0:
+
+ attr_val = func(attr_val)
+
+ if attr_val != '' and attr_val != '0.0%':
attribute_list.append(Attribute(attribute_name, attr_val))
@@ -10,7 +10,7 @@ def buildAttributeTemplate(self, object):
if len(object.custom_name) > 0:
attributes.append("@obj_attr_n:original_name", "@" + object.stf_file + ":" + object.stf_name)
attributes.extend([
- Attribute("@obj_attr_n:condition", str(object.condition_damage) + "/" + str(object.max_condition)),
+ Attribute("@obj_attr_n:condition", str(object.max_condition-object.condition_damage) + "/" + str(object.max_condition)),
Attribute("@obj_attr_n:volume", str(object.volume)),
Attribute("@obj_attr_n:craft_tool_effectiveness", object.getStringAttribute("craft_tool_effectiveness")),
Attribute("@obj_attr_n:craft_tool_status", object.getStringAttribute("craft_tool_status"))
@@ -10,7 +10,7 @@ def buildAttributeTemplate(self, object):
if len(object.custom_name) > 0:
attributes.append("@obj_attr_n:original_name", "@" + object.stf_file + ":" + object.stf_name)
attributes.extend([
- Attribute("@obj_attr_n:condition", str(object.condition_damage) + "/" + str(object.max_condition)),
+ Attribute("@obj_attr_n:condition", str(object.max_condition-object.condition_damage) + "/" + str(object.max_condition)),
Attribute("@obj_attr_n:volume", str(object.volume)),
Attribute("@obj_attr_n:armor_rating", object.getStringAttribute("armor_rating"))
])
@@ -23,9 +23,9 @@ def buildAttributeTemplate(self, object):
SetOptionalAttribute(attributes, "cat_wpn_rangemods.@obj_attr_n:wpn_range_zero", "cat_wpn_rangemods.wpn_range_zero", object, True)
SetOptionalAttribute(attributes, "cat_wpn_rangemods.@obj_attr_n:wpn_range_mid", "cat_wpn_rangemods.wpn_range_mid", object, True)
SetOptionalAttribute(attributes, "cat_wpn_rangemods.@obj_attr_n:wpn_range_max", "cat_wpn_rangemods.wpn_range_max", object, True)
- SetOptionalAttribute(attributes, "cat_wpn_attack_cost.@obj_attr_n:wpn_attack_cost_health", "cat_wpn_attack_cost.wpn_attack_cost_health", object, True)
- SetOptionalAttribute(attributes, "cat_wpn_attack_cost.@obj_attr_n:wpn_attack_cost_action", "cat_wpn_attack_cost.wpn_attack_cost_action", object, True)
- SetOptionalAttribute(attributes, "cat_wpn_attack_cost.@obj_attr_n:wpn_attack_cost_mind", "cat_wpn_attack_cost.wpn_attack_cost_mind", object, True)
+ SetOptionalAttribute(attributes, "cat_wpn_attack_cost.@obj_attr_n:health", "cat_wpn_attack_cost.wpn_attack_cost_health", object, True)
+ SetOptionalAttribute(attributes, "cat_wpn_attack_cost.@obj_attr_n:action", "cat_wpn_attack_cost.wpn_attack_cost_action", object, True)
+ SetOptionalAttribute(attributes, "cat_wpn_attack_cost.@obj_attr_n:mind", "cat_wpn_attack_cost.wpn_attack_cost_mind", object, True)
attribute_list_message.attributes = attributes
return attribute_list_message
@@ -10,7 +10,7 @@ def buildAttributeTemplate(self, object):
if len(object.custom_name) > 0:
attributes.append("@obj_attr_n:original_name", "@" + object.stf_file + ":" + object.stf_name)
attributes.extend([
- Attribute("@obj_attr_n:condition", str(object.condition_damage) + "/" + str(object.max_condition)),
+ Attribute("@obj_attr_n:condition", str(object.max_condition-object.condition_damage) + "/" + str(object.max_condition)),
Attribute("@obj_attr_n:volume", str(object.volume))
])
SetOptionalAttribute(attributes, '@obj_attr_n:crafter', 'crafter', object, False)
@@ -25,7 +25,7 @@ def CreateStartingCharacter(kernel, scale, base_model, customization, full_name,
creature.custom_name = full_name
creature.position = vector3(startLoc.x, startLoc.y, startLoc.z)
if customization:
- creature.customization = customization
+ creature.setCustomizationFromInts(customization)
creature.bank_credits = 2000
creature.speed_base = 5.75
# Set Starting Stats
@@ -53,7 +53,7 @@ def CreateStartingCharacter(kernel, scale, base_model, customization, full_name,
creature.add(creature, bank)
creature.add(creature, mission)
if (hair):
- hair.customization = hair_customization
+ hair.setCustomizationFromInts(hair_customization)
creature.add(creature, hair)
creature.add(creature, player)
# Now add the objects to the inventory
@@ -7,4 +7,4 @@ def run(self):
split = re.split('\W+', self.getCommandString())
container_id = split[1]
container = self.getKernel().serviceManager().simulationService().findObjectById(int(container_id))
- self.getActor().transfer(self.getActor(), self.getTarget(), container)
+ self.getActor().transfer(self.getActor(), self.getTarget(), container, vector3(0, 0, 0))
@@ -7,4 +7,4 @@ def run(self):
split = re.split('\W+', self.getCommandString())
container_id = split[1]
container = self.getKernel().serviceManager().simulationService().findObjectById(int(container_id))
- self.getTarget().container().transfer(self.getActor(), self.getTarget(), container)
+ self.getTarget().container().transfer(self.getActor(), self.getTarget(), container, vector3(0, 0, 0))
@@ -7,4 +7,4 @@ def run(self):
split = re.split('\W+', self.getCommandString())
container_id = split[1]
c = self.getKernel().serviceManager().simulationService().findObjectById(int(container_id))
- self.getTarget().container().transfer(self.getActor(), self.getTarget(), c)
+ self.getTarget().container().transfer(self.getActor(), self.getTarget(), c, vector3(0, 0, 0))
@@ -7,4 +7,4 @@ def run(self):
split = re.split('\W+', self.getCommandString())
container_id = split[1]
container = self.getKernel().serviceManager().simulationService().findObjectById(int(container_id))
- self.getActor().container().transfer(self.getActor(), self.getTarget(), container)
+ self.getActor().container().transfer(self.getActor(), self.getTarget(), container, vector3(0, 0, 0))
Oops, something went wrong.

0 comments on commit eb077da

Please sign in to comment.