mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-14 23:07:51 -04:00
* Code compiles - execution NOT tested * updating gitignore * Removed intellij settings files * Removed more intellij files * Added exclusion for JDK classes. * Fixed purchasing script for vendors that have listed coin types. * Updated script to not kick off until the entire preload is complete. * adds static name entry for Solo movie poster and tcg9 vendor entry * clean up empty and orphaned object templates * adds placeholder black market (static) spawns * corrects entries for the video game table to correctly set it in tcg series 2 and remove series 1 console errors * Updated gitignore and removed intellij project files * Fixed appearance reference for thranta payroll and kashyyyk door, added skipLosCheck objvar due to cannit see issue. Requires updated src * Fixed appearance and template for terminal (#2) * Fixed appearance and template for terminal (#3) * Fixed appearance and template for terminal (#4) * Deleted another faulty/orphaned object template * Fixed gcw ranks option on frog. Only issue is that it doesn't award the officer commands or badges. * Fixed some unneeded java 11 changes
671 lines
34 KiB
Java
Executable File
671 lines
34 KiB
Java
Executable File
package script.systems.crafting;
|
|
|
|
import script.*;
|
|
import script.library.*;
|
|
|
|
public class crafting_base extends script.base_script
|
|
{
|
|
public crafting_base()
|
|
{
|
|
}
|
|
public static final String VERSION = "v0.00.00";
|
|
public String[] getRequiredSkills() throws InterruptedException
|
|
{
|
|
LOG("crafting", "Called into crafting_base script getRequiredSkills()! This function should have been overridden!");
|
|
return null;
|
|
}
|
|
public String[] getAssemblySkillMods() throws InterruptedException
|
|
{
|
|
LOG("crafting", "Called into crafting_base script getAssemblySkillMods()! This function should have been overridden!");
|
|
return null;
|
|
}
|
|
public String[] getExperimentSkillMods() throws InterruptedException
|
|
{
|
|
LOG("crafting", "Called into crafting_base script getExperimentSkillMods()! This function should have been overridden!");
|
|
return null;
|
|
}
|
|
public resource_weight[] getResourceMaxResourceWeights() throws InterruptedException
|
|
{
|
|
LOG("crafting", "Called into craftin_base script getResourceMaxResourceWeights()! This function should have been overridden!");
|
|
return null;
|
|
}
|
|
public resource_weight[] getAssemblyResourceWeights() throws InterruptedException
|
|
{
|
|
LOG("crafting", "Called into crafting_base script getAssemblyResourceWeights()! This function should have been overridden!");
|
|
return null;
|
|
}
|
|
public void calcAndSetPrototypeProperties(obj_id prototype, draft_schematic.attribute[] itemAttributes) throws InterruptedException
|
|
{
|
|
LOG("crafting", "Called into crafting_base script calcAndSetPrototypeProperties()! This function should have been overridden!");
|
|
}
|
|
public String[] getAppearances(obj_id player, draft_schematic.slot[] slots) throws InterruptedException
|
|
{
|
|
LOG("crafting", "Called into crafting_base script getAppearances()! This function should have been overridden!");
|
|
return null;
|
|
}
|
|
public draft_schematic.custom[] getCustomizations(obj_id player, draft_schematic.custom[] customizations) throws InterruptedException
|
|
{
|
|
LOG("crafting", "Called into crafting_base script getCustomizations()! This function should have been overridden!");
|
|
return null;
|
|
}
|
|
public void modifyForCustomAppearance(obj_id self, obj_id newObject) throws InterruptedException
|
|
{
|
|
}
|
|
public boolean calcAndSetPrototypeProperty(obj_id prototype, draft_schematic.attribute itemAttribute) throws InterruptedException
|
|
{
|
|
if (itemAttribute == null)
|
|
{
|
|
return false;
|
|
}
|
|
boolean result = false;
|
|
if (itemAttribute.name.equals("complexity"))
|
|
{
|
|
setComplexity(prototype, itemAttribute.currentValue);
|
|
setComplexity(getSelf(), itemAttribute.currentValue);
|
|
result = true;
|
|
}
|
|
else if (itemAttribute.name.equals("hitPoints"))
|
|
{
|
|
setMaxHitpoints(prototype, (int)itemAttribute.currentValue);
|
|
result = true;
|
|
}
|
|
else if (itemAttribute.name.equals("xp"))
|
|
{
|
|
utils.setScriptVar(prototype, "crafting.creator.xp", (int)(itemAttribute.currentValue + 0.5f));
|
|
result = true;
|
|
}
|
|
else if (itemAttribute.name.equals("sockets"))
|
|
{
|
|
if ((int)itemAttribute.currentValue > 0 && getGameObjectType(prototype) != GOT_misc_container_wearable)
|
|
{
|
|
if (getGameObjectType(prototype) == GOT_cybernetic_legs || getGameObjectType(prototype) == GOT_cybernetic_arm)
|
|
{
|
|
setSkillModSockets(prototype, 2);
|
|
}
|
|
else if (getGameObjectType(prototype) == GOT_cybernetic_forearm)
|
|
{
|
|
setSkillModSockets(prototype, 1);
|
|
}
|
|
else if (getGameObjectType(prototype) == GOT_cybernetic_hand)
|
|
{
|
|
setSkillModSockets(prototype, 0);
|
|
}
|
|
else
|
|
{
|
|
setSkillModSockets(prototype, 1);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
setSkillModSockets(prototype, 0);
|
|
}
|
|
result = true;
|
|
}
|
|
else if ((itemAttribute.name.getTable()).equals(craftinglib.OBJVAR_SKILLMOD_BONUS))
|
|
{
|
|
setSkillModBonus(prototype, itemAttribute.name.getAsciiId(), (int)itemAttribute.currentValue);
|
|
result = true;
|
|
}
|
|
return result;
|
|
}
|
|
public void calcAndSetPrototypeProperties(obj_id prototype, draft_schematic.attribute[] itemAttributes, dictionary craftingValuesDictionary) throws InterruptedException
|
|
{
|
|
debugServerConsoleMsg(null, "*** crafting base calcAndSetPrototypeProperties enter ***");
|
|
obj_var_list componentData = getObjVarList(getSelf(), craftinglib.COMPONENT_ATTRIBUTE_INTERNAL_OBJVAR_NAME);
|
|
if (componentData != null)
|
|
{
|
|
for (draft_schematic.attribute itemAttribute : itemAttributes) {
|
|
if (itemAttribute == null) {
|
|
continue;
|
|
}
|
|
obj_var component = componentData.getObjVar((itemAttribute.name).getAsciiId());
|
|
if (component != null) {
|
|
if (component.getData() instanceof Integer) {
|
|
itemAttribute.currentValue = component.getIntData();
|
|
} else if (itemAttribute.minValue != itemAttribute.maxValue) {
|
|
debugServerConsoleMsg(null, "updating attrib " + (itemAttribute.name).getAsciiId() + ", current value = " + itemAttribute.currentValue + " by component value " + component.getFloatData());
|
|
// Cekis: This may be a bug - why incremenet if a float (in this condition), but just re-assign if an int?
|
|
itemAttribute.currentValue += component.getFloatData();
|
|
} else {
|
|
debugServerConsoleMsg(null, "updating attrib " + (itemAttribute.name).getAsciiId() + ", current value = " + itemAttribute.currentValue + " by component value " + component.getFloatData());
|
|
itemAttribute.currentValue = itemAttribute.minValue + component.getFloatData();
|
|
}
|
|
}
|
|
}
|
|
if (componentData.hasObjVar(craftinglib.OBJVAR_COMPONENT_ATTRIB_BONUSES))
|
|
{
|
|
float[] componentBonuses = componentData.getFloatArrayObjVar(craftinglib.OBJVAR_COMPONENT_ATTRIB_BONUSES);
|
|
if (componentBonuses != null && componentBonuses.length == NUM_ATTRIBUTES)
|
|
{
|
|
int[] bonuses = new int[componentBonuses.length];
|
|
for (int i = 0; i < componentBonuses.length; ++i)
|
|
{
|
|
bonuses[i] = (int)(componentBonuses[i]);
|
|
}
|
|
setAttributeBonuses(getSelf(), bonuses);
|
|
}
|
|
}
|
|
}
|
|
debugServerConsoleMsg(null, "*** crafting base calcAndSetPrototypeProperties exit ***");
|
|
}
|
|
public void grantExperience(obj_id player, draft_schematic.slot[] slots) throws InterruptedException
|
|
{
|
|
if (slots == null)
|
|
{
|
|
return;
|
|
}
|
|
for (draft_schematic.slot slot : slots) {
|
|
if (slot.ingredients == null) {
|
|
continue;
|
|
}
|
|
if (slot.ingredientType == draft_schematic.IT_item || slot.ingredientType == draft_schematic.IT_template || slot.ingredientType == draft_schematic.IT_templateGeneric) {
|
|
for (int j = 0; j < slot.ingredients.length; ++j) {
|
|
if (isIdValid(slot.ingredients[j].source) && slot.ingredients[j].source != player) {
|
|
grantExperiencePoints(slot.ingredients[j].source, slot.ingredients[j].xpType, slot.ingredients[j].xpAmount);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
public int OnManufacturingSchematicCreation(obj_id self, obj_id player, obj_id prototype, draft_schematic schematic, modifiable_int assemblyResult, modifiable_int experimentPoints) throws InterruptedException
|
|
{
|
|
if (!craftinglib.validateReComponent(player, schematic))
|
|
{
|
|
assemblyResult.set(9);
|
|
endCraftingSession(player, obj_id.NULL_ID, prototype);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (schematic.getCategory() == CT_genetics || schematic.getCategory() == CT_animalBreeding)
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
debugServerConsoleMsg(self, "OnManufacturingSchematicCreation enter");
|
|
dictionary craftingValuesDictionary = new dictionary();
|
|
draft_schematic.slot[] slots = schematic.getSlots();
|
|
draft_schematic.attribute[] objectAttribs = schematic.getAttribs();
|
|
draft_schematic.attribute[] experimentalAttribs = schematic.getExperimentalAttribs();
|
|
/* Cekis: pointless loop.
|
|
for (int i = 0; i < objectAttribs.length; ++i)
|
|
{
|
|
float modifiedValue = objectAttribs[i].currentValue;
|
|
String attribName = (objectAttribs[i].name).getAsciiId();
|
|
}
|
|
*/
|
|
String[] obj_attributes = new String[objectAttribs.length];
|
|
for (int i = 0; i < obj_attributes.length; ++i)
|
|
{
|
|
obj_attributes[i] = (objectAttribs[i].name).getAsciiId();
|
|
}
|
|
float refactorPercent = 0;
|
|
float refactorComplexity = 0;
|
|
if (hasObjVar(self, craftinglib.OBJVAR_REFACTOR))
|
|
{
|
|
refactorPercent = getFloatObjVar(self, craftinglib.OBJVAR_REFACTOR);
|
|
if (refactorPercent > 0 && refactorPercent < 1.0f)
|
|
{
|
|
debugServerConsoleMsg(null, "Using refactor value " + refactorPercent);
|
|
craftingValuesDictionary.put(craftinglib.OBJVAR_REFACTOR, refactorPercent);
|
|
int myDraftSchematic = getDraftSchematicCrc(self);
|
|
if (myDraftSchematic != 0)
|
|
{
|
|
for (draft_schematic.slot slot : slots) {
|
|
if (slot.ingredientType == draft_schematic.IT_schematic && myDraftSchematic == getSourceDraftSchematic(slot.ingredients[0].ingredient)) {
|
|
refactorComplexity = getComplexity(slot.ingredients[0].ingredient);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for (int i = 0; i < objectAttribs.length; ++i)
|
|
{
|
|
if (objectAttribs[i].maxValue > objectAttribs[i].minValue && !obj_attributes[i].equals("complexity") && !obj_attributes[i].equals("armorSpecialType"))
|
|
{
|
|
debugServerConsoleMsg(null, "Refactoring attribute max " + obj_attributes[i] + " from " + objectAttribs[i].maxValue + " to " + objectAttribs[i].maxValue * refactorPercent);
|
|
objectAttribs[i].maxValue *= refactorPercent;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
CustomerServiceLog("crafting", "WARNING: schematic " + self + " has invalid refactor objvar value " + refactorPercent);
|
|
}
|
|
}
|
|
debugServerConsoleMsg(self, "Ingredient slot info (" + slots.length + " slots):");
|
|
for (draft_schematic.slot slot : slots) {
|
|
debugServerConsoleMsg(self, "\tslot " + slot.name + ", ingredient " + slot.ingredients[0].ingredient + ", amount = " + slot.ingredients[0].count);
|
|
}
|
|
debugServerConsoleMsg(self, "Item attribute info (" + objectAttribs.length + " attribs):");
|
|
craftingValuesDictionary.put("craftingType", schematic.getCategory());
|
|
for (draft_schematic.attribute objectAttrib : objectAttribs) {
|
|
if ((objectAttrib.name).equals("complexity")) {
|
|
float defaultComplexity = objectAttrib.minValue;
|
|
float currentComplexity = objectAttrib.currentValue + refactorComplexity;
|
|
craftingValuesDictionary.put("itemDefaultComplexity", defaultComplexity);
|
|
craftingValuesDictionary.put("itemCurrentComplexity", currentComplexity);
|
|
debugServerConsoleMsg(self, "\tdefault complexity " + defaultComplexity + ", current complexity " + currentComplexity);
|
|
} else if ((objectAttrib.name).equals("armorSpecialType")) {
|
|
craftingValuesDictionary.put("itemDefaultArmorSpecialType", objectAttrib.minValue);
|
|
craftingValuesDictionary.put("itemCurrentArmorSpecialType", objectAttrib.currentValue);
|
|
} else if ((objectAttrib.name).equals("sockets")) {
|
|
int[] mods = getEnhancedSkillStatisticModifiersUncapped(player, getAssemblySkillMods());
|
|
if (mods != null) {
|
|
int experimentModTotal = 0;
|
|
for (int mod : mods) {
|
|
experimentModTotal += mod;
|
|
}
|
|
if (experimentModTotal > craftinglib.socketThreshold) {
|
|
int sockets = 0;
|
|
int chance = experimentModTotal - 50;
|
|
if (chance > rand(1, 100)) {
|
|
sockets = 1;
|
|
}
|
|
objectAttrib.minValue = sockets;
|
|
objectAttrib.maxValue = sockets;
|
|
objectAttrib.currentValue = sockets;
|
|
if (sockets > 0) {
|
|
setCondition(prototype, CONDITION_MAGIC_ITEM);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
debugServerConsoleMsg(self, "\tattrib " + objectAttrib.name + ", values = " + objectAttrib.minValue + ".." + objectAttrib.maxValue);
|
|
}
|
|
grantExperience(player, slots);
|
|
collection.updateCraftingSlot(player, getTemplateName(prototype));
|
|
int forceCritSuccessCount = getIntObjVar(self, craftinglib.OBJVAR_FORCE_CRITICAL_SUCCESS);
|
|
if (forceCritSuccessCount > 0)
|
|
{
|
|
craftingValuesDictionary.put(craftinglib.OBJVAR_FORCE_CRITICAL_SUCCESS, true);
|
|
}
|
|
int assemblySuccess = craftinglib.calcAssemblyPhaseAttributes(player, slots, objectAttribs, craftingValuesDictionary, getAssemblySkillMods(), getResourceMaxResourceWeights(), getAssemblyResourceWeights());
|
|
assemblyResult.set(assemblySuccess);
|
|
if (assemblySuccess == craftinglib.STATE_CRITICAL_FAILURE || assemblySuccess == craftinglib.STATE_CRITICAL_FAILURE_NODESTROY)
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
debugServerConsoleMsg(self, "OnManufacturingSchematicCreation calling craftinglib.calcExperimentalAttribs");
|
|
craftinglib.calcExperimentalAttribs(schematic);
|
|
debugServerConsoleMsg(self, "OnManufacturingSchematicCreation return from craftinglib.calcExperimentalAttribs");
|
|
float resourceMalleabilitySkillMod = craftingValuesDictionary.getFloat(craftinglib.RESOURCE_MALLEABILITY_SKILL_MOD);
|
|
utils.setScriptVar(self, craftinglib.RESOURCE_MALLEABILITY_SKILL_MOD, resourceMalleabilitySkillMod);
|
|
experimentPoints.set(craftinglib.calcExperimentPoints(player, getExperimentSkillMods()));
|
|
debugServerConsoleMsg(self, "OnManufacturingSchematicCreation setting current attributes");
|
|
if (setSchematicAttributes(self, objectAttribs))
|
|
{
|
|
debugServerConsoleMsg(self, "OnManufacturingSchematicCreation set initial attributes of schematic");
|
|
}
|
|
else
|
|
{
|
|
debugServerConsoleMsg(self, "OnManufacturingSchematicCreation failed to set initial attributes of schematic!");
|
|
}
|
|
debugServerConsoleMsg(self, "OnManufacturingSchematicCreation setting experimental attributes");
|
|
if (setSchematicExperimentalAttributes(self, experimentalAttribs))
|
|
{
|
|
debugServerConsoleMsg(self, "OnManufacturingSchematicCreation set experimental attributes of schematic");
|
|
}
|
|
else
|
|
{
|
|
debugServerConsoleMsg(self, "OnManufacturingSchematicCreation failed to set experimental attributes of schematic!");
|
|
}
|
|
craftinglib.calcPerExperimentationCheckMod(player, craftingValuesDictionary, 0, objectAttribs, getExperimentSkillMods());
|
|
setSchematicExperimentMod(self, craftingValuesDictionary.getFloat("totalExperimentPointModifier"));
|
|
if (slots != null && slots.length > 0)
|
|
{
|
|
String[] appearances = getAppearances(player, slots);
|
|
if (appearances != null && appearances.length > 0)
|
|
{
|
|
setSchematicAppearances(self, appearances);
|
|
}
|
|
}
|
|
debugServerConsoleMsg(self, "OnManufacturingSchematicCreation getting customization data");
|
|
draft_schematic.custom[] customizations = schematic.getCustomizations();
|
|
if (customizations != null && customizations.length > 0)
|
|
{
|
|
debugServerConsoleMsg(self, "OnManufacturingSchematicCreation calling getCustomizations");
|
|
customizations = getCustomizations(player, customizations);
|
|
if (customizations != null && customizations.length > 0)
|
|
{
|
|
setSchematicCustomizations(self, customizations);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (customizations == null)
|
|
{
|
|
debugServerConsoleMsg(self, "OnManufacturingSchematicCreation customizations == null");
|
|
}
|
|
else
|
|
{
|
|
debugServerConsoleMsg(self, "OnManufacturingSchematicCreation customizations.length == 0");
|
|
}
|
|
}
|
|
if (refactorPercent != 0)
|
|
{
|
|
for (int i = 0; i < objectAttribs.length; ++i)
|
|
{
|
|
if (objectAttribs[i].maxValue > objectAttribs[i].minValue && !obj_attributes[i].equals("complexity") && !obj_attributes[i].equals("armorSpecialType"))
|
|
{
|
|
objectAttribs[i].resourceMaxValue /= refactorPercent;
|
|
objectAttribs[i].maxValue /= refactorPercent;
|
|
debugServerConsoleMsg(self, "OnManufacturingSchematicCreation final attrib " + (objectAttribs[i].name).getAsciiId() + " values: current = " + objectAttribs[i].currentValue + ", rmax = " + objectAttribs[i].resourceMaxValue + ", max = " + objectAttribs[i].maxValue);
|
|
}
|
|
}
|
|
}
|
|
if (craftingValuesDictionary.containsKey(craftinglib.OBJVAR_FORCE_CRITICAL_SUCCESS_RESULT))
|
|
{
|
|
setObjVar(self, craftinglib.OBJVAR_FORCE_CRITICAL_SUCCESS, forceCritSuccessCount - 1);
|
|
}
|
|
weapons.storeWeaponCraftingValues(prototype, self, schematic);
|
|
craftinglib.storeSecondarySkillBonuses(prototype, schematic);
|
|
calcAndSetPrototypeProperties(prototype, objectAttribs, craftingValuesDictionary);
|
|
craftinglib.storeTissueDataAsObjvars(craftingValuesDictionary, objectAttribs, prototype, true);
|
|
calcAndSetPrototypeProperties(prototype, objectAttribs);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public int OnCraftingExperiment(obj_id self, obj_id player, obj_id prototype, string_id[] attributeNames, int[] experimentPoints, int totalPoints, modifiable_int experimentResult, int coreLevel) throws InterruptedException
|
|
{
|
|
if (utils.hasScriptVar(self, "skipCraftingExperiment"))
|
|
{
|
|
utils.removeScriptVar(self, "skipCraftingExperiment");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (doCraftingExperiment(self, player, prototype, attributeNames, experimentPoints, totalPoints, experimentResult, coreLevel) == SCRIPT_CONTINUE)
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
public int doCraftingExperiment(obj_id self, obj_id player, obj_id prototype, string_id[] attributeNames, int[] experimentPoints, int totalPoints, modifiable_int experimentResult, int coreLevel) throws InterruptedException
|
|
{
|
|
debugServerConsoleMsg(self, "OnCraftingExperiment enter");
|
|
draft_schematic schematic = getSchematicForExperimentalAttributes(self, attributeNames);
|
|
if (schematic == null)
|
|
{
|
|
debugServerConsoleMsg(self, "OnCraftingExperiment NO SCHEMATIC");
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
draft_schematic.attribute[] objectAttribs = schematic.getAttribs();
|
|
draft_schematic.attribute[] experimentalAttribs = schematic.getExperimentalAttribs();
|
|
if (objectAttribs == null || experimentalAttribs == null)
|
|
{
|
|
debugServerConsoleMsg(self, "OnCraftingExperiment NO ATTRIBS");
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
String[] obj_attributes = new String[objectAttribs.length];
|
|
for (int i = 0; i < obj_attributes.length; ++i)
|
|
{
|
|
obj_attributes[i] = (objectAttribs[i].name).getAsciiId();
|
|
if (obj_attributes[i].equals("coreLevel"))
|
|
{
|
|
objectAttribs[i].currentValue = coreLevel;
|
|
}
|
|
}
|
|
dictionary craftingValuesDictionary = new dictionary();
|
|
float refactorPercent = 0;
|
|
float refactorComplexity = 0;
|
|
if (hasObjVar(self, craftinglib.OBJVAR_REFACTOR))
|
|
{
|
|
refactorPercent = getFloatObjVar(self, craftinglib.OBJVAR_REFACTOR);
|
|
if (refactorPercent > 0 && refactorPercent < 1.0f)
|
|
{
|
|
debugServerConsoleMsg(null, "Using refactor value " + refactorPercent);
|
|
craftingValuesDictionary.put(craftinglib.OBJVAR_REFACTOR, refactorPercent);
|
|
for (int i = 0; i < objectAttribs.length; ++i)
|
|
{
|
|
if (objectAttribs[i].maxValue > objectAttribs[i].minValue && !obj_attributes[i].equals("complexity") && !obj_attributes[i].equals("armorSpecialType"))
|
|
{
|
|
debugServerConsoleMsg(null, "Refactoring attribute max " + obj_attributes[i] + " from " + objectAttribs[i].maxValue + " to " + objectAttribs[i].maxValue * refactorPercent);
|
|
objectAttribs[i].maxValue *= refactorPercent;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
CustomerServiceLog("crafting", "WARNING: schematic " + self + " has invalid refactor objvar value " + refactorPercent);
|
|
}
|
|
}
|
|
float[] objExperimentPoints = craftinglib.convertExperimentalPointsToObjectPoints(schematic, attributeNames, experimentPoints);
|
|
if (objExperimentPoints == null)
|
|
{
|
|
debugServerConsoleMsg(self, "OnCraftingExperiment NO POINTS");
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
if (getIntObjVar(self, craftinglib.OBJVAR_FORCE_CRITICAL_SUCCESS) > 0)
|
|
{
|
|
craftingValuesDictionary.put(craftinglib.OBJVAR_FORCE_CRITICAL_SUCCESS, true);
|
|
}
|
|
float resourceMalleabilitySkillMod = utils.getFloatScriptVar(self, craftinglib.RESOURCE_MALLEABILITY_SKILL_MOD);
|
|
craftingValuesDictionary.put(craftinglib.RESOURCE_MALLEABILITY_SKILL_MOD, resourceMalleabilitySkillMod);
|
|
craftinglib.calcExpFullSinglePointValue(craftingValuesDictionary, objectAttribs);
|
|
craftinglib.calcPerExperimentationCheckMod(player, craftingValuesDictionary, experimentPoints.length, objectAttribs, getExperimentSkillMods());
|
|
craftinglib.calcSuccessPerAttributeExperimentation(craftingValuesDictionary, objExperimentPoints, objectAttribs, player, getRequiredSkills());
|
|
craftinglib.calcExperimentalAttribs(schematic);
|
|
experimentResult.set(craftingValuesDictionary.getInt("experimentSuccessState"));
|
|
for (draft_schematic.attribute objectAttrib : objectAttribs) {
|
|
if (objectAttrib != null && (objectAttrib.name).equals("complexity")) {
|
|
++objectAttrib.currentValue;
|
|
break;
|
|
}
|
|
}
|
|
debugServerConsoleMsg(self, "OnCraftingExperiment setting current attributes");
|
|
if (setSchematicAttributes(self, objectAttribs))
|
|
{
|
|
debugServerConsoleMsg(self, "OnCraftingExperiment set initial attributes of schematic");
|
|
}
|
|
else
|
|
{
|
|
debugServerConsoleMsg(self, "OnCraftingExperiment failed to set initial attributes of schematic!");
|
|
}
|
|
debugServerConsoleMsg(self, "OnCraftingExperiment setting experimental attributes");
|
|
if (setSchematicExperimentalAttributes(self, experimentalAttribs))
|
|
{
|
|
debugServerConsoleMsg(self, "OnCraftingExperiment set experimental attributes of schematic");
|
|
}
|
|
else
|
|
{
|
|
debugServerConsoleMsg(self, "OnCraftingExperiment failed to set experimental attributes of schematic!");
|
|
}
|
|
if (refactorPercent != 0)
|
|
{
|
|
for (int i = 0; i < objectAttribs.length; ++i)
|
|
{
|
|
if (objectAttribs[i].maxValue > objectAttribs[i].minValue && !obj_attributes[i].equals("complexity") && !obj_attributes[i].equals("armorSpecialType"))
|
|
{
|
|
objectAttribs[i].resourceMaxValue /= refactorPercent;
|
|
objectAttribs[i].maxValue /= refactorPercent;
|
|
}
|
|
}
|
|
}
|
|
if (craftingValuesDictionary.containsKey(craftinglib.OBJVAR_FORCE_CRITICAL_SUCCESS_RESULT))
|
|
{
|
|
setObjVar(self, craftinglib.OBJVAR_FORCE_CRITICAL_SUCCESS, getIntObjVar(self, craftinglib.OBJVAR_FORCE_CRITICAL_SUCCESS) - 1);
|
|
}
|
|
calcAndSetPrototypeProperties(prototype, objectAttribs, craftingValuesDictionary);
|
|
craftinglib.storeTissueDataAsObjvars(craftingValuesDictionary, objectAttribs, prototype, true);
|
|
calcAndSetPrototypeProperties(prototype, objectAttribs);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public int OnFinalizeSchematic(obj_id self, obj_id player, obj_id prototype, draft_schematic schematic) throws InterruptedException
|
|
{
|
|
int myDraftSchematic = getDraftSchematicCrc(self);
|
|
obj_id bioLink = temp_schematic.getBioLinkSchematicId(player, myDraftSchematic);
|
|
if (isIdValid(bioLink))
|
|
{
|
|
setBioLink(prototype, bioLink);
|
|
}
|
|
draft_schematic.attribute[] objectAttribs = schematic.getAttribs();
|
|
dictionary craftingValuesDictionary = new dictionary();
|
|
/* Cekis: this is a totally pointless loop! Commenting out for now.
|
|
for (int i = 0; i < objectAttribs.length; ++i)
|
|
{
|
|
float modifiedValue = objectAttribs[i].currentValue;
|
|
String attribName = (objectAttribs[i].name).getAsciiId();
|
|
}
|
|
*/
|
|
calcAndSetPrototypeProperties(prototype, objectAttribs, craftingValuesDictionary);
|
|
setSchematicAttributes(self, objectAttribs);
|
|
craftinglib.storeTissueDataAsObjvars(craftingValuesDictionary, objectAttribs, prototype, true);
|
|
weapons.storeWeaponCraftingValues(prototype, self, schematic);
|
|
weapons.setSchematicVariablesFromSchematic(self, prototype);
|
|
removeObjVar(self, craftinglib.COMPONENT_ATTRIBUTE_INTERNAL_OBJVAR_NAME);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public int getInspirationBuffXpBonus(obj_id self, int category, int amt) throws InterruptedException
|
|
{
|
|
if (utils.hasScriptVar(self, "buff.general_inspiration.value"))
|
|
{
|
|
float mod = utils.getFloatScriptVar(self, "buff.general_inspiration.value");
|
|
mod /= 100.0f;
|
|
float modAmt = amt * mod;
|
|
return Math.round(modAmt);
|
|
}
|
|
if (!utils.hasScriptVar(self, "buff.xpBonus.types") && !utils.hasScriptVar(self, "buff.xpBonusGeneral.types"))
|
|
{
|
|
return 0;
|
|
}
|
|
if (!utils.hasScriptVar(self, "buff.craftBonus.types"))
|
|
{
|
|
return 0;
|
|
}
|
|
int flags = utils.getIntScriptVar(self, "buff.craftBonus.types");
|
|
if ((flags & category) > 0)
|
|
{
|
|
float mod = 0;
|
|
if (utils.hasScriptVar(self, "buff.xpBonus.value"))
|
|
{
|
|
mod += utils.getFloatScriptVar(self, "buff.xpBonus.value");
|
|
}
|
|
if (utils.hasScriptVar(self, "buff.xpBonusGeneral.value"))
|
|
{
|
|
mod += utils.getFloatScriptVar(self, "buff.xpBonusGeneral.value");
|
|
}
|
|
float modAmt = amt * mod;
|
|
return Math.round(modAmt);
|
|
}
|
|
return 0;
|
|
}
|
|
public int OnManufactureObject(obj_id self, obj_id player, obj_id newObject, draft_schematic schematic, boolean isPrototype, boolean isRealObject) throws InterruptedException
|
|
{
|
|
/* Cekis: unused vars and a pointless loop. Commenting out for now.
|
|
draft_schematic.attribute[] objectAttribs = schematic.getAttribs();
|
|
draft_schematic.attribute[] experimentalAttribs = schematic.getExperimentalAttribs();
|
|
for (int i = 0; i < objectAttribs.length; ++i)
|
|
{
|
|
float modifiedValue = objectAttribs[i].currentValue;
|
|
String attribName = (objectAttribs[i].name).getAsciiId();
|
|
}
|
|
*/
|
|
if (isPrototype)
|
|
{
|
|
OnFinalizeSchematic(self, player, newObject, schematic);
|
|
}
|
|
calcAndSetPrototypeProperties(newObject, schematic.getAttribs());
|
|
if (getSkillModSockets(newObject) > 0)
|
|
{
|
|
setCondition(newObject, CONDITION_MAGIC_ITEM);
|
|
}
|
|
int[] bonuses = getAttributeBonuses(self);
|
|
if (bonuses != null)
|
|
{
|
|
setAttributeBonuses(newObject, bonuses);
|
|
}
|
|
if (isIdValid(player))
|
|
{
|
|
obj_id id = getObjIdObjVar(newObject, "crafting.creator.id");
|
|
String name = getStringObjVar(newObject, "crafting.creator.name");
|
|
String xpType = getStringExperienceType(getIntObjVar(newObject, "crafting.creator.xpType"));
|
|
int xpAmount = utils.getIntScriptVar(newObject, "crafting.creator.xp");
|
|
int buffXP = getInspirationBuffXpBonus(player, schematic.getCategory(), xpAmount);
|
|
xpAmount += buffXP;
|
|
if (!isPrototype)
|
|
{
|
|
xpAmount = (int)(xpAmount * 0.1);
|
|
}
|
|
else if (!isRealObject)
|
|
{
|
|
xpAmount = (int)(xpAmount * 1.05);
|
|
}
|
|
if (xpType != null)
|
|
{
|
|
xp.grantCraftingStyleXp(player, xpType, xpAmount);
|
|
}
|
|
setObjVar(newObject, "crafting.creator.id", id);
|
|
setObjVar(newObject, "crafting.creator.name", name);
|
|
String expertiseSkill = craftinglib.getCraftingSubskill(getRequiredSkills());
|
|
int complexityDecrease = (int)getSkillStatisticModifier(player, "expertise_complexity_decrease_" + expertiseSkill);
|
|
if (complexityDecrease > 0)
|
|
{
|
|
int newComplexity = (int)getComplexity(newObject) - complexityDecrease;
|
|
if (newComplexity > 0)
|
|
{
|
|
setComplexity(newObject, newComplexity);
|
|
setComplexity(getSelf(), newComplexity);
|
|
}
|
|
else
|
|
{
|
|
setComplexity(newObject, 1);
|
|
setComplexity(getSelf(), 1);
|
|
}
|
|
}
|
|
}
|
|
if (hasObjVar(self, "customAppearance"))
|
|
{
|
|
modifyForCustomAppearance(self, newObject);
|
|
}
|
|
weapons.validateDamage(player, newObject);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public int OnMakeCraftedItem(obj_id self, obj_id prototype, draft_schematic schematic, float qualityPercent) throws InterruptedException
|
|
{
|
|
draft_schematic.attribute[] objectAttribs = schematic.getAttribs();
|
|
/* Cekis: look kids! Pointless vars and Another pointless loop! Commenting out for now.
|
|
draft_schematic.attribute[] experimentalAttribs = schematic.getExperimentalAttribs();
|
|
for (int i = 0; i < objectAttribs.length; ++i)
|
|
{
|
|
float modifiedValue = objectAttribs[i].currentValue;
|
|
String attribName = (objectAttribs[i].name).getAsciiId();
|
|
}
|
|
*/
|
|
debugServerConsoleMsg(null, "OnMakeCraftedItem enter, quality = " + qualityPercent);
|
|
dictionary craftingValuesDictionary = new dictionary();
|
|
for (draft_schematic.attribute objectAttrib : objectAttribs) {
|
|
objectAttrib.currentValue = objectAttrib.maxValue * (qualityPercent / 100.0f);
|
|
}
|
|
setSchematicAttributes(self, objectAttribs);
|
|
calcAndSetPrototypeProperties(prototype, objectAttribs);
|
|
OnManufactureObject(self, null, prototype, schematic, true, true);
|
|
debugServerConsoleMsg(null, "OnMakeCraftedItem exit");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public int OnRequestResourceWeights(obj_id self, obj_id player, String[] desiredAttribs, String[] attribs, int[] slots, int[] counts, int[] data) throws InterruptedException
|
|
{
|
|
int attribIndex = 0;
|
|
int dataIndex = 0;
|
|
java.util.HashSet attribSet = new java.util.HashSet(java.util.Arrays.asList(desiredAttribs));
|
|
resource_weight[] weights = getAssemblyResourceWeights();
|
|
for (int i = 0; i < 2; ++i)
|
|
{
|
|
if (weights == null)
|
|
{
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
for (resource_weight weight : weights) {
|
|
if (attribSet.contains(weight.attribName)) {
|
|
attribs[attribIndex] = weight.attribName;
|
|
slots[attribIndex] = weight.slot;
|
|
counts[attribIndex++] = weight.weights.length;
|
|
resource_weight.weight[] resources = weight.weights;
|
|
for (resource_weight.weight resource : resources) {
|
|
data[dataIndex++] = resource.resource;
|
|
data[dataIndex++] = resource.weight;
|
|
}
|
|
}
|
|
}
|
|
if (i == 0)
|
|
{
|
|
weights = getResourceMaxResourceWeights();
|
|
}
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|