mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-08-27 16:56:48 -04:00
More Java optimizations and code review for library and spawning systems.
This commit is contained in:
Regular → Executable
+98
-142
@@ -1,19 +1,10 @@
|
||||
package script.library;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
import script.combat_engine.combat_data;
|
||||
import script.combat_engine.weapon_data;
|
||||
|
||||
import script.library.utils;
|
||||
import script.library.combat;
|
||||
import script.library.static_item;
|
||||
import script.library.colors;
|
||||
import script.library.buff;
|
||||
import script.library.vehicle;
|
||||
import java.util.Vector;
|
||||
|
||||
public class proc extends script.base_script
|
||||
{
|
||||
@@ -29,7 +20,6 @@ public class proc extends script.base_script
|
||||
}
|
||||
public static void executeProcEffects(obj_id attacker, obj_id defender, combat_data actionData) throws InterruptedException
|
||||
{
|
||||
weapon_data weaponData = getWeaponData(getCurrentWeapon(attacker));
|
||||
String params = "";
|
||||
prose_package pp = new prose_package();
|
||||
if (actionData != null)
|
||||
@@ -47,59 +37,61 @@ public class proc extends script.base_script
|
||||
{
|
||||
return;
|
||||
}
|
||||
weapon_data weaponData = getWeaponData(getCurrentWeapon(attacker));
|
||||
if (utils.hasScriptVar(attacker, "currentProcList"))
|
||||
{
|
||||
if (actionData.attackType == combat.CONE || actionData.attackType == combat.AREA || actionData.attackType == combat.TARGET_AREA)
|
||||
if (actionData != null && (actionData.attackType == combat.CONE || actionData.attackType == combat.AREA || actionData.attackType == combat.TARGET_AREA))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Vector procEffects = utils.getResizeableStringArrayScriptVar(attacker, "currentProcList");
|
||||
if (procEffects != null && procEffects.size() > 0)
|
||||
{
|
||||
for (int i = 0; i < procEffects.size(); ++i)
|
||||
{
|
||||
dictionary parms = dataTableGetRow(PROC_TABLE, ((String)procEffects.get(i)));
|
||||
if (parms != null)
|
||||
{
|
||||
dictionary parms;
|
||||
String noSelfProcBuffs;
|
||||
String noTargetProcBuffs;
|
||||
String requiredBuffs;
|
||||
String procCommand;
|
||||
|
||||
for (Object procEffect : procEffects) {
|
||||
parms = dataTableGetRow(PROC_TABLE, ((String) procEffect));
|
||||
if (parms != null) {
|
||||
int procChance = parms.getInt("procChance");
|
||||
int expertiseProcChance = (int)getSkillStatisticModifier(attacker, ((String)procEffects.get(i)));
|
||||
if (expertiseProcChance > 0)
|
||||
{
|
||||
int expertiseProcChance = getSkillStatisticModifier(attacker, ((String) procEffect));
|
||||
if (expertiseProcChance > 0) {
|
||||
procChance = expertiseProcChance;
|
||||
if (((String)procEffects.get(i)).startsWith("kill_meter_"))
|
||||
{
|
||||
if (((String) procEffect).startsWith("kill_meter_")) {
|
||||
procChance *= getKillMeter(attacker);
|
||||
}
|
||||
}
|
||||
String noSelfProcBuffs = parms.getString("noSelfProcBuffs");
|
||||
String noTargetProcBuffs = parms.getString("noTargetProcBuffs");
|
||||
if (isGod(attacker) || isGod(defender))
|
||||
{
|
||||
noSelfProcBuffs = parms.getString("noSelfProcBuffs");
|
||||
noTargetProcBuffs = parms.getString("noTargetProcBuffs");
|
||||
if (isGod(attacker) || isGod(defender)) {
|
||||
LOG("expertise", "Proc: " + parms.getString("procString") + " noSelfProcBuffs: " + noSelfProcBuffs + " noTargetProcBuffs: " + noTargetProcBuffs);
|
||||
}
|
||||
if (buff.hasAnyBuffInList(attacker, noSelfProcBuffs) || buff.hasAnyBuffInList(defender, noTargetProcBuffs))
|
||||
{
|
||||
if (buff.hasAnyBuffInList(attacker, noSelfProcBuffs) || buff.hasAnyBuffInList(defender, noTargetProcBuffs)) {
|
||||
continue;
|
||||
}
|
||||
String requiredBuffs = parms.getString("requiredSelfBuffs");
|
||||
if (requiredBuffs.length() > 0 && !buff.hasAnyBuffInList(attacker, requiredBuffs))
|
||||
{
|
||||
requiredBuffs = parms.getString("requiredSelfBuffs");
|
||||
if (requiredBuffs.length() > 0 && !buff.hasAnyBuffInList(attacker, requiredBuffs)) {
|
||||
continue;
|
||||
}
|
||||
if (procChance != 100)
|
||||
{
|
||||
procChance = Math.round(weaponData.attackSpeed * (float)procChance);
|
||||
if (procChance != 100) {
|
||||
procChance = Math.round(weaponData.attackSpeed * (float) procChance);
|
||||
}
|
||||
if (rand(0, 99) < procChance)
|
||||
{
|
||||
String procCommand = parms.getString("procString");
|
||||
if (procCommand != null)
|
||||
{
|
||||
if (combat.canUseWeaponWithAbility(attacker, weaponData, procCommand, false))
|
||||
{
|
||||
if (rand(0, 99) < procChance) {
|
||||
procCommand = parms.getString("procString");
|
||||
if (procCommand != null) {
|
||||
if (combat.canUseWeaponWithAbility(attacker, weaponData, procCommand, false)) {
|
||||
queueCommand(attacker, getStringCrc(procCommand.toLowerCase()), defender, params, COMMAND_PRIORITY_DEFAULT);
|
||||
pp = prose.setStringId(pp, new string_id("proc/proc", procCommand));
|
||||
showFlyTextPrivateProseWithFlags(attacker, attacker, pp, 1.5f, colors.LEMONCHIFFON, FLY_TEXT_FLAG_IS_CRITICAL_HIT);
|
||||
showFlyTextPrivateProseWithFlags(
|
||||
attacker,
|
||||
attacker,
|
||||
prose.setStringId(pp, new string_id("proc/proc", procCommand)),
|
||||
1.5f,
|
||||
colors.LEMONCHIFFON,
|
||||
FLY_TEXT_FLAG_IS_CRITICAL_HIT
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,58 +112,45 @@ public class proc extends script.base_script
|
||||
Vector reacEffects = utils.getResizeableStringArrayScriptVar(defender, "currentReacList");
|
||||
if (reacEffects != null && reacEffects.size() > 0)
|
||||
{
|
||||
for (int i = 0; i < reacEffects.size(); ++i)
|
||||
{
|
||||
dictionary reacParms = dataTableGetRow(PROC_TABLE, ((String)reacEffects.get(i)));
|
||||
if (reacParms != null)
|
||||
{
|
||||
dictionary reacParms;
|
||||
String reacCommand;
|
||||
String cooldownGroup;
|
||||
|
||||
for (Object reacEffect : reacEffects) {
|
||||
reacParms = dataTableGetRow(PROC_TABLE, ((String) reacEffect));
|
||||
if (reacParms != null) {
|
||||
int reacChance = reacParms.getInt("procChance");
|
||||
int expertiseReacChance = (int)getSkillStatisticModifier(defender, ((String)reacEffects.get(i)));
|
||||
if (expertiseReacChance > 0)
|
||||
{
|
||||
int expertiseReacChance = getSkillStatisticModifier(defender, ((String) reacEffect));
|
||||
if (expertiseReacChance > 0) {
|
||||
reacChance = expertiseReacChance;
|
||||
if (((String)reacEffects.get(i)).startsWith("kill_meter_"))
|
||||
{
|
||||
if (((String) reacEffect).startsWith("kill_meter_")) {
|
||||
reacChance *= getKillMeter(defender);
|
||||
}
|
||||
}
|
||||
String noSelfProcBuffs = reacParms.getString("noSelfProcBuffs");
|
||||
String noTargetProcBuffs = reacParms.getString("noTargetProcBuffs");
|
||||
if (buff.hasAnyBuffInList(defender, noSelfProcBuffs) || buff.hasAnyBuffInList(attacker, noTargetProcBuffs))
|
||||
{
|
||||
if (buff.hasAnyBuffInList(defender, reacParms.getString("noSelfProcBuffs")) || buff.hasAnyBuffInList(attacker, reacParms.getString("noTargetProcBuffs"))) {
|
||||
return;
|
||||
}
|
||||
if (reacChance != 100)
|
||||
{
|
||||
reacChance = Math.round(weaponData.attackSpeed * (float)reacChance);
|
||||
if (reacChance != 100) {
|
||||
reacChance = Math.round(weaponData.attackSpeed * (float) reacChance);
|
||||
}
|
||||
if (rand(0, 99) < reacChance)
|
||||
{
|
||||
String reacCommand = reacParms.getString("procString");
|
||||
if (reacCommand != null)
|
||||
{
|
||||
if (rand(0, 99) < reacChance) {
|
||||
reacCommand = reacParms.getString("procString");
|
||||
if (reacCommand != null) {
|
||||
combat_data abilityData = combat_engine.getCombatData(reacCommand);
|
||||
String cooldownGroup = abilityData.cooldownGroup;
|
||||
float cooldownTime = abilityData.cooldownTime;
|
||||
cooldownGroup = abilityData.cooldownGroup;
|
||||
boolean canProc = false;
|
||||
int timeLapse = -1;
|
||||
if (utils.hasScriptVar(defender, REAC_BASE + cooldownGroup))
|
||||
{
|
||||
if (utils.hasScriptVar(defender, REAC_BASE + cooldownGroup)) {
|
||||
int lastProc = utils.getIntScriptVar(defender, REAC_BASE + cooldownGroup);
|
||||
timeLapse = getGameTime() - lastProc;
|
||||
if (timeLapse >= cooldownTime)
|
||||
{
|
||||
if (timeLapse >= abilityData.cooldownTime) {
|
||||
canProc = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
canProc = true;
|
||||
}
|
||||
if (canProc)
|
||||
{
|
||||
if (queueCommand(defender, getStringCrc(reacCommand.toLowerCase()), attacker, "", COMMAND_PRIORITY_DEFAULT))
|
||||
{
|
||||
if (canProc) {
|
||||
if (queueCommand(defender, getStringCrc(reacCommand.toLowerCase()), attacker, "", COMMAND_PRIORITY_DEFAULT)) {
|
||||
LOG("procCommand", "Reac -- " + reacCommand + " activated");
|
||||
utils.setScriptVar(defender, REAC_BASE + cooldownGroup, getGameTime());
|
||||
}
|
||||
@@ -195,9 +174,8 @@ public class proc extends script.base_script
|
||||
if (procEffect != null && !procEffect.equals(""))
|
||||
{
|
||||
String[] weaponProcEffects = split(procEffect, ',');
|
||||
for (int i = 0; i < weaponProcEffects.length; ++i)
|
||||
{
|
||||
currentProcList.addElement(weaponProcEffects[i]);
|
||||
for (String weaponProcEffect : weaponProcEffects) {
|
||||
currentProcList.addElement(weaponProcEffect);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,42 +184,35 @@ public class proc extends script.base_script
|
||||
if (hasObjVar(weapon, "procEffect"))
|
||||
{
|
||||
String[] weaponProcEffects = getStringArrayObjVar(weapon, "procEffect");
|
||||
for (int i = 0; i < weaponProcEffects.length; ++i)
|
||||
{
|
||||
currentProcList.addElement(weaponProcEffects[i]);
|
||||
for (String weaponProcEffect : weaponProcEffects) {
|
||||
currentProcList.addElement(weaponProcEffect);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (utils.hasScriptVar(player, "procBuffEffects"))
|
||||
{
|
||||
String[] buffProcEffects = utils.getStringArrayScriptVar(player, "procBuffEffects");
|
||||
for (int i = 0; i < buffProcEffects.length; ++i)
|
||||
{
|
||||
currentProcList.addElement(buffProcEffects[i]);
|
||||
for (String buffProcEffect : buffProcEffects) {
|
||||
currentProcList.addElement(buffProcEffect);
|
||||
}
|
||||
}
|
||||
if (utils.hasScriptVar(player, "cyberneticItems"))
|
||||
{
|
||||
String[] installedCybernetics = utils.getStringArrayScriptVar(player, "cyberneticItems");
|
||||
String procString = null;
|
||||
for (int i = 0; i < installedCybernetics.length; ++i)
|
||||
{
|
||||
procString = dataTableGetString(CYBERNETICS_TABLE, installedCybernetics[i], "procEffectString");
|
||||
if (procString != null && !procString.equals(""))
|
||||
{
|
||||
for (String installedCybernetic : installedCybernetics) {
|
||||
procString = dataTableGetString(CYBERNETICS_TABLE, installedCybernetic, "procEffectString");
|
||||
if (procString != null && !procString.equals("")) {
|
||||
currentProcList.addElement(procString);
|
||||
}
|
||||
procString = null;
|
||||
}
|
||||
}
|
||||
if (utils.hasScriptVar(player, "expertiseProcReacList"))
|
||||
{
|
||||
Vector expertiseList = utils.getResizeableStringArrayScriptVar(player, "expertiseProcReacList");
|
||||
for (int i = 0; i < expertiseList.size(); ++i)
|
||||
{
|
||||
if (((String)expertiseList.get(i)).endsWith("_proc"))
|
||||
{
|
||||
currentProcList.addElement(((String)expertiseList.get(i)));
|
||||
for (Object anExpertiseList : expertiseList) {
|
||||
if (((String) anExpertiseList).endsWith("_proc")) {
|
||||
currentProcList.addElement(anExpertiseList);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -249,11 +220,9 @@ public class proc extends script.base_script
|
||||
{
|
||||
Vector tempProcList = new Vector();
|
||||
tempProcList.setSize(0);
|
||||
for (int i = 0; i < currentProcList.size(); ++i)
|
||||
{
|
||||
if (!tempProcList.contains(((String)currentProcList.get(i))))
|
||||
{
|
||||
tempProcList.addElement(((String)currentProcList.get(i)));
|
||||
for (Object aCurrentProcList : currentProcList) {
|
||||
if (!tempProcList.contains(aCurrentProcList)) {
|
||||
tempProcList.addElement(aCurrentProcList);
|
||||
}
|
||||
}
|
||||
utils.setScriptVar(player, "currentProcList", tempProcList);
|
||||
@@ -287,32 +256,24 @@ public class proc extends script.base_script
|
||||
"utility_belt",
|
||||
"shoes"
|
||||
};
|
||||
for (int intI = 0; intI < strWear.length; intI++)
|
||||
{
|
||||
obj_id wearable = getObjectInSlot(player, strWear[intI]);
|
||||
if (!isIdNull(wearable))
|
||||
{
|
||||
if (static_item.isStaticItem(wearable))
|
||||
{
|
||||
dictionary wearableData = null;
|
||||
String wearableName = static_item.getStaticItemName(wearable);
|
||||
if (static_item.getStaticObjectType(wearableName) == 2)
|
||||
{
|
||||
obj_id wearable;
|
||||
dictionary wearableData;
|
||||
String reacEffect;
|
||||
|
||||
for (String aStrWear : strWear) {
|
||||
wearable = getObjectInSlot(player, aStrWear);
|
||||
if (!isIdNull(wearable)) {
|
||||
if (static_item.isStaticItem(wearable)) {
|
||||
if (static_item.getStaticObjectType(static_item.getStaticItemName(wearable)) == 2) {
|
||||
wearableData = static_item.getStaticArmorDictionary(wearable);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
wearableData = static_item.getStaticItemDictionary(wearable);
|
||||
}
|
||||
if (wearableData != null)
|
||||
{
|
||||
String reacEffect = wearableData.getString("reactive_effect");
|
||||
if (reacEffect != null && !reacEffect.equals(""))
|
||||
{
|
||||
String[] wearableReacEffects = split(reacEffect, ',');
|
||||
for (int i = 0; i < wearableReacEffects.length; ++i)
|
||||
{
|
||||
currentReacList.addElement(wearableReacEffects[i]);
|
||||
if (wearableData != null) {
|
||||
reacEffect = wearableData.getString("reactive_effect");
|
||||
if (reacEffect != null && !reacEffect.equals("")) {
|
||||
for (String wearableReacEffect : split(reacEffect, ',')) {
|
||||
currentReacList.addElement(wearableReacEffect);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -322,20 +283,17 @@ public class proc extends script.base_script
|
||||
if (utils.hasScriptVar(player, "reacBuffEffects"))
|
||||
{
|
||||
String[] buffReacEffects = utils.getStringArrayScriptVar(player, "reacBuffEffects");
|
||||
for (int i = 0; i < buffReacEffects.length; ++i)
|
||||
{
|
||||
currentReacList.addElement(buffReacEffects[i]);
|
||||
for (String buffReacEffect : buffReacEffects) {
|
||||
currentReacList.addElement(buffReacEffect);
|
||||
}
|
||||
}
|
||||
if (utils.hasScriptVar(player, "cyberneticItems"))
|
||||
{
|
||||
String[] installedCybernetics = utils.getStringArrayScriptVar(player, "cyberneticItems");
|
||||
String reacString = null;
|
||||
for (int i = 0; i < installedCybernetics.length; ++i)
|
||||
{
|
||||
reacString = dataTableGetString(CYBERNETICS_TABLE, installedCybernetics[i], "reacEffectString");
|
||||
if (reacString != null && !reacString.equals(""))
|
||||
{
|
||||
String reacString;
|
||||
for (String installedCybernetic : installedCybernetics) {
|
||||
reacString = dataTableGetString(CYBERNETICS_TABLE, installedCybernetic, "reacEffectString");
|
||||
if (reacString != null && !reacString.equals("")) {
|
||||
currentReacList.addElement(reacString);
|
||||
}
|
||||
reacString = null;
|
||||
@@ -344,11 +302,9 @@ public class proc extends script.base_script
|
||||
if (utils.hasScriptVar(player, "expertiseProcReacList"))
|
||||
{
|
||||
Vector expertiseList = utils.getResizeableStringArrayScriptVar(player, "expertiseProcReacList");
|
||||
for (int i = 0; i < expertiseList.size(); ++i)
|
||||
{
|
||||
if (((String)expertiseList.get(i)).endsWith("_reac"))
|
||||
{
|
||||
currentReacList.addElement(((String)expertiseList.get(i)));
|
||||
for (Object anExpertiseList : expertiseList) {
|
||||
if (((String) anExpertiseList).endsWith("_reac")) {
|
||||
currentReacList.addElement(anExpertiseList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user