From c46685be9cd97871bceaa4b74b824f4096d6bd48 Mon Sep 17 00:00:00 2001 From: Cekis Date: Fri, 18 Mar 2016 16:37:40 +0000 Subject: [PATCH] More Java optimizations and code review for library and spawning systems. --- .../compiled/game/script/library/buff.java | 513 ++++---- .../compiled/game/script/library/proc.java | 240 ++-- .../compiled/game/script/library/prose.java | 10 +- .../compiled/game/script/library/pvp.java | 380 +++--- .../compiled/game/script/library/quests.java | 204 ++-- .../compiled/game/script/library/regions.java | 207 ++-- .../game/script/library/resource.java | 198 ++- .../compiled/game/script/library/respec.java | 163 +-- .../script/library/reverse_engineering.java | 109 +- .../game/script/library/scenario.java | 189 +-- .../game/script/library/scheduled_drop.java | 126 +- .../compiled/game/script/library/scout.java | 30 +- .../game/script/library/sequencer.java | 50 +- .../compiled/game/script/library/session.java | 6 - .../compiled/game/script/library/ship_ai.java | 251 ++-- .../compiled/game/script/library/skill.java | 386 +++--- .../game/script/library/skill_template.java | 84 +- .../compiled/game/script/library/slicing.java | 52 +- .../compiled/game/script/library/slots.java | 25 +- .../game/script/library/spawning.java | 88 +- .../game/script/library/squad_leader.java | 63 +- .../game/script/library/static_item.java | 488 +++----- .../compiled/game/script/library/stealth.java | 1080 +++++++---------- .../game/script/library/storyteller.java | 338 ++---- .../game/script/library/structure.java | 176 +-- .../compiled/game/script/library/sui.java | 482 ++++---- .../game/script/library/target_dummy.java | 186 +-- .../compiled/game/script/library/tcg.java | 175 +-- .../game/script/library/temp_schematic.java | 18 +- .../compiled/game/script/library/theater.java | 400 +++--- .../game/script/library/township.java | 68 +- .../compiled/game/script/library/trace.java | 30 +- .../game/script/library/trainerlocs.java | 154 ++- .../game/script/library/transition.java | 133 +- .../compiled/game/script/library/travel.java | 253 ++-- .../compiled/game/script/library/trial.java | 1061 ++++++---------- .../game/script/library/turnstile.java | 62 +- .../compiled/game/script/library/turret.java | 103 +- .../game/script/library/uberlair.java | 59 +- .../compiled/game/script/library/utils.java | 2 +- .../compiled/game/script/library/vehicle.java | 194 +-- .../game/script/library/vendor_lib.java | 78 +- .../compiled/game/script/library/weapons.java | 675 ++++------- .../compiled/game/script/library/xp.java | 725 ++++------- .../systems/spawning/dropship/base.java | 8 +- .../spawning/dropship/emperorsday_lambda.java | 24 +- .../spawning/dropship/emperorsday_yt1300.java | 12 +- .../systems/spawning/dropship/lambda.java | 19 +- .../spawning/dropship/player_shuttle.java | 18 +- .../systems/spawning/imperial/probot_egg.java | 34 +- .../script/systems/spawning/mob_spawner.java | 49 +- .../systems/spawning/patrol_point_setup.java | 9 +- .../spawning/patrol_spawned_tracker.java | 11 +- .../script/systems/spawning/spawn_base.java | 228 ++-- .../systems/spawning/spawn_egg_manager.java | 39 +- .../script/systems/spawning/spawn_master.java | 15 +- .../spawning/spawn_npc_lair_tracker.java | 9 +- .../script/systems/spawning/spawn_player.java | 153 +-- .../systems/spawning/spawn_tangible.java | 10 +- .../systems/spawning/spawn_template.java | 13 +- .../systems/spawning/spawned_tracker.java | 11 +- .../script/systems/spawning/spawner_area.java | 34 +- .../systems/spawning/spawner_find_node.java | 22 +- .../systems/spawning/spawner_patrol.java | 81 +- .../systems/spawning/spawner_random.java | 40 +- .../spawning/spawner_random_proxy.java | 40 +- .../systems/spawning/theater_spawnegg.java | 19 +- 67 files changed, 3963 insertions(+), 7249 deletions(-) mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/buff.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/proc.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/prose.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/pvp.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/regions.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/resource.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/respec.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/reverse_engineering.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/scenario.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/scheduled_drop.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/scout.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/sequencer.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/session.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/ship_ai.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/skill.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/skill_template.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/slicing.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/slots.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/spawning.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/squad_leader.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/static_item.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/stealth.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/storyteller.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/structure.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/sui.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/target_dummy.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/tcg.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/temp_schematic.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/theater.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/township.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/trace.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/trainerlocs.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/transition.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/travel.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/trial.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/turnstile.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/turret.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/uberlair.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/vehicle.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/vendor_lib.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/weapons.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/xp.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/systems/spawning/dropship/base.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/systems/spawning/dropship/emperorsday_lambda.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/systems/spawning/dropship/emperorsday_yt1300.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/systems/spawning/dropship/lambda.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/systems/spawning/dropship/player_shuttle.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/systems/spawning/imperial/probot_egg.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/systems/spawning/mob_spawner.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/systems/spawning/patrol_point_setup.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/systems/spawning/patrol_spawned_tracker.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/systems/spawning/spawn_base.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/systems/spawning/spawn_egg_manager.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/systems/spawning/spawn_master.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/systems/spawning/spawn_npc_lair_tracker.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/systems/spawning/spawn_player.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/systems/spawning/spawn_tangible.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/systems/spawning/spawn_template.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/systems/spawning/spawned_tracker.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/systems/spawning/spawner_find_node.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/systems/spawning/spawner_patrol.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/systems/spawning/spawner_random.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/systems/spawning/spawner_random_proxy.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/systems/spawning/theater_spawnegg.java diff --git a/sku.0/sys.server/compiled/game/script/library/buff.java b/sku.0/sys.server/compiled/game/script/library/buff.java old mode 100644 new mode 100755 index 31f2a84c1..95b8dadd7 --- a/sku.0/sys.server/compiled/game/script/library/buff.java +++ b/sku.0/sys.server/compiled/game/script/library/buff.java @@ -1,15 +1,11 @@ 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; +import script.combat_engine.buff_data; +import script.deltadictionary; +import script.obj_id; -import script.library.utils; -import script.library.beast_lib; +import java.util.Vector; public class buff extends script.base_script { @@ -109,27 +105,23 @@ public class buff extends script.base_script if (groupOne != 0 || groupTwo != 0) { int priority = bdata.priority; - for (int i = 0; i < buffCRCs.length; i++) - { - buff_data oldBuffData = combat_engine.getBuffData(buffCRCs[i]); - if (oldBuffData == null) - { + buff_data oldBuffData; + + for (int buffCRC : buffCRCs) { + oldBuffData = combat_engine.getBuffData(buffCRC); + if (oldBuffData == null) { continue; } - obj_id effectOwner = getBuffOwner(target, buffCRCs[i]); int oldPriority = oldBuffData.priority; - if (priority < oldPriority) - { + if (priority < oldPriority) { int[] oldGroups = getGroups(oldBuffData); - if (oldGroups == null || oldGroups.length != 3) - { + if (oldGroups == null || oldGroups.length != 3) { continue; } int oldGroupOne = oldGroups[0]; int oldGroupTwo = oldGroups[1]; int oldBlockGroup = oldGroups[2]; - if ((groupOne != 0 && (groupOne == oldGroupOne || groupOne == oldGroupTwo)) || (groupTwo != 0 && (groupTwo == oldGroupOne || groupTwo == oldGroupTwo)) || (oldBlockGroup != 0 && (groupOne == oldBlockGroup || groupTwo == oldBlockGroup))) - { + if ((groupOne != 0 && (groupOne == oldGroupOne || groupOne == oldGroupTwo)) || (groupTwo != 0 && (groupTwo == oldGroupOne || groupTwo == oldGroupTwo)) || (oldBlockGroup != 0 && (groupOne == oldBlockGroup || groupTwo == oldBlockGroup))) { return false; } } @@ -256,29 +248,21 @@ public class buff extends script.base_script boolean isStackable = bdata.maxStacks > 1; if (discarded != null && discarded.length > 0) { - for (int i = 0; i < discarded.length; i++) - { - obj_id caster = getBuffCaster(target, discarded[i]); - if (nameCrc == discarded[i]) - { - float oldBuffTime = getBuffTimeRemaining(target, discarded[i]); - if (!isStackable) - { - if (oldBuffTime <= duration) - { - _removeBuff(target, discarded[i]); + obj_id caster; + for (int aDiscarded : discarded) { + caster = getBuffCaster(target, aDiscarded); + if (nameCrc == aDiscarded) { + float oldBuffTime = getBuffTimeRemaining(target, aDiscarded); + if (!isStackable) { + if (oldBuffTime <= duration) { + _removeBuff(target, aDiscarded); } } - } - else - { - if (owner != caster && isStackable) - { + } else { + if (owner != caster && isStackable) { continue; - } - else - { - _removeBuff(target, discarded[i]); + } else { + _removeBuff(target, aDiscarded); } } } @@ -342,10 +326,8 @@ public class buff extends script.base_script public static boolean removeBuffs(obj_id target, Vector names) throws InterruptedException { boolean success = true; - for (int i = 0; i < names.size(); i++) - { - if (!removeBuff(target, ((String)names.get(i)))) - { + for (Object name : names) { + if (!removeBuff(target, ((String) name))) { success = false; } } @@ -354,10 +336,8 @@ public class buff extends script.base_script public static boolean removeBuffs(obj_id target, String[] names) throws InterruptedException { boolean success = true; - for (int i = 0; i < names.length; i++) - { - if (!removeBuff(target, names[i])) - { + for (String name : names) { + if (!removeBuff(target, name)) { success = false; } } @@ -407,33 +387,28 @@ public class buff extends script.base_script { return true; } - for (int i = 0; i < buffs.length; i++) - { - buff_data bdata = combat_engine.getBuffData(buffs[i]); - if (bdata == null) - { + buff_data bdata; + for (int buff : buffs) { + bdata = combat_engine.getBuffData(buff); + if (bdata == null) { LOG("buff.scriptlib", "removeAllBuffs bdata is null"); continue; } int removeOnDeath = bdata.removeOnDeath; int removeOnRespec = bdata.removeOnRespec; - if (removeOnDeath == 0 && fromDeath) - { + if (removeOnDeath == 0 && fromDeath) { continue; } - if (removeOnRespec == 0 && fromRespec) - { + if (removeOnRespec == 0 && fromRespec) { continue; } - if (isMob(target)) - { + if (isMob(target)) { int removeOnCombatEnd = bdata.aiRemoveOnCombatEnd; - if (removeOnCombatEnd == 0 && !isDead(target) && !isIncapacitated(target)) - { + if (removeOnCombatEnd == 0 && !isDead(target) && !isIncapacitated(target)) { continue; } } - _removeBuff(target, buffs[i]); + _removeBuff(target, buff); } return true; } @@ -452,13 +427,10 @@ public class buff extends script.base_script { return true; } - for (int i = 0; i < buffs.length; i++) - { - buff_data bdata = combat_engine.getBuffData(buffs[i]); - String curBuff = bdata.buffName; - if (bdata.debuff == 1 && getBuffOwner(target, buffs[i]) == owner) - { - removeBuff(target, buffs[i]); + for (int buff : buffs) { + buff_data bdata = combat_engine.getBuffData(buff); + if (bdata.debuff == 1 && getBuffOwner(target, buff) == owner) { + removeBuff(target, buff); } } return true; @@ -476,17 +448,16 @@ public class buff extends script.base_script } Vector matchedBuffs = new Vector(); matchedBuffs.setSize(0); - for (int i = 0; i < buffs.length; i++) - { + buff_data bdata; + String tempEffect; + for (int buff : buffs) { int j = 1; - buff_data bdata = combat_engine.getBuffData(buffs[i]); - String tempEffect = getEffectParam(bdata, 1); + bdata = combat_engine.getBuffData(buff); + tempEffect = getEffectParam(bdata, 1); boolean matched = false; - while (!matched && j < 6 && tempEffect != null && tempEffect.length() > 0) - { - if (tempEffect.equals(effect)) - { - utils.addElement(matchedBuffs, buffs[i]); + while (!matched && j < 6 && tempEffect != null && tempEffect.length() > 0) { + if (tempEffect.equals(effect)) { + utils.addElement(matchedBuffs, buff); matched = true; } j++; @@ -497,15 +468,11 @@ public class buff extends script.base_script { return null; } - int[] _matchedBuffs = new int[0]; - if (matchedBuffs != null) - { - _matchedBuffs = new int[matchedBuffs.size()]; - for (int _i = 0; _i < matchedBuffs.size(); ++_i) - { - _matchedBuffs[_i] = ((Integer)matchedBuffs.get(_i)).intValue(); - } - } + int[] _matchedBuffs = new int[matchedBuffs.size()]; + for (int _i = 0; _i < matchedBuffs.size(); ++_i) + { + _matchedBuffs[_i] = (Integer) matchedBuffs.get(_i); + } return _matchedBuffs; } public static int[] getAllBuffs(obj_id target) throws InterruptedException @@ -540,10 +507,8 @@ public class buff extends script.base_script public static boolean hasAnyBuffInList(obj_id target, String buffList) throws InterruptedException { String[] buffs = split(buffList, ','); - for (int i = 0; i < buffs.length; i++) - { - if (hasBuff(target, buffs[i])) - { + for (String buff : buffs) { + if (hasBuff(target, buff)) { return true; } } @@ -551,10 +516,8 @@ public class buff extends script.base_script } public static boolean hasAnyBuffInList(obj_id target, String[] buffList) throws InterruptedException { - for (int i = 0; i < buffList.length; i++) - { - if (hasBuff(target, buffList[i])) - { + for (String aBuffList : buffList) { + if (hasBuff(target, aBuffList)) { return true; } } @@ -576,13 +539,14 @@ public class buff extends script.base_script } removeAllBuffs(target, true); boolean success = true; + obj_id owner; for (int i = 0; i < buffs.length; i++) { if (buffs_d[i] <= 0.0f) { continue; } - obj_id owner = getBuffOwner(target, buffs[i]); + owner = getBuffOwner(target, buffs[i]); if (isIdValid(owner) && owner != target) { continue; @@ -733,18 +697,14 @@ public class buff extends script.base_script { return 0; } - for (int i = 0; i < buffs.length; i++) - { - int[] groups = getGroups(buffs[i]); - if (groups == null || groups.length == 0) - { + for (int buff : buffs) { + int[] groups = getGroups(buff); + if (groups == null || groups.length == 0) { continue; } - for (int j = 0; j < groups.length; j++) - { - if (groups[j] == groupCrc) - { - return buffs[i]; + for (int group : groups) { + if (group == groupCrc) { + return buff; } } } @@ -759,23 +719,19 @@ public class buff extends script.base_script } Vector allGroupBuffs = new Vector(); allGroupBuffs.setSize(0); - for (int i = 0; i < buffs.length; i++) - { - String tempGroupName = getStringGroupTwo(buffs[i]); - if (tempGroupName.startsWith(groupName)) - { - utils.addElement(allGroupBuffs, buffs[i]); + String tempGroupName; + for (int buff : buffs) { + tempGroupName = getStringGroupTwo(buff); + if (tempGroupName.startsWith(groupName)) { + utils.addElement(allGroupBuffs, buff); } } int[] _allGroupBuffs = new int[0]; - if (allGroupBuffs != null) - { - _allGroupBuffs = new int[allGroupBuffs.size()]; - for (int _i = 0; _i < allGroupBuffs.size(); ++_i) - { - _allGroupBuffs[_i] = ((Integer)allGroupBuffs.get(_i)).intValue(); - } - } + _allGroupBuffs = new int[allGroupBuffs.size()]; + for (int _i = 0; _i < allGroupBuffs.size(); ++_i) + { + _allGroupBuffs[_i] = (Integer) allGroupBuffs.get(_i); + } return _allGroupBuffs; } public static int getPriority(String name) throws InterruptedException @@ -882,17 +838,18 @@ public class buff extends script.base_script switch (effNum) { case 1: - return bdata.effect1Param; + return bdata.effect1Param; case 2: - return bdata.effect2Param; + return bdata.effect2Param; case 3: - return bdata.effect3Param; + return bdata.effect3Param; case 4: - return bdata.effect4Param; + return bdata.effect4Param; case 5: - return bdata.effect5Param; + return bdata.effect5Param; + default: + return null; } - return null; } public static float getEffectValue(String name, int effNum) throws InterruptedException { @@ -912,17 +869,18 @@ public class buff extends script.base_script switch (effNum) { case 1: - return bdata.effect1Value; + return bdata.effect1Value; case 2: - return bdata.effect2Value; + return bdata.effect2Value; case 3: - return bdata.effect3Value; + return bdata.effect3Value; case 4: - return bdata.effect4Value; + return bdata.effect4Value; case 5: - return bdata.effect5Value; + return bdata.effect5Value; + default: + return 0; } - return 0; } public static boolean isDebuff(String name) throws InterruptedException { @@ -957,9 +915,10 @@ public class buff extends script.base_script } public static boolean isGroupBuff(int nameCrc) throws InterruptedException { + String effect; for (int i = 1; i <= MAX_EFFECTS; i++) { - String effect = getEffectParam(nameCrc, i); + effect = getEffectParam(nameCrc, i); if (effect != null && effect.equals("group")) { return true; @@ -974,7 +933,7 @@ public class buff extends script.base_script public static boolean isAuraBuff(int nameCrc) throws InterruptedException { String groupTwo = getStringGroupTwo(nameCrc); - return groupTwo.indexOf("aura") > -1; + return groupTwo.contains("aura"); } public static boolean isOwnedBuff(String name) throws InterruptedException { @@ -1038,40 +997,33 @@ public class buff extends script.base_script if (groupOne != 0 || groupTwo != 0) { int priority = bdata.priority; - for (int i = 0; i < buffs.length; i++) - { - buff_data oldBuffData = combat_engine.getBuffData(buffs[i]); - if (oldBuffData == null) - { + buff_data oldBuffData; + obj_id effectOwner; + for (int buff : buffs) { + oldBuffData = combat_engine.getBuffData(buff); + if (oldBuffData == null) { continue; } - obj_id effectOwner = getBuffOwner(target, buffs[i]); - if (isIdValid(effectOwner) && effectOwner != target) - { + effectOwner = getBuffOwner(target, buff); + if (isIdValid(effectOwner) && effectOwner != target) { continue; } int oldPriority = oldBuffData.priority; - if (priority >= oldPriority) - { + if (priority >= oldPriority) { int[] oldGroups = getGroups(oldBuffData); - if (oldGroups == null || oldGroups.length != 3) - { + if (oldGroups == null || oldGroups.length != 3) { return null; } int oldGroupOne = oldGroups[0]; int oldGroupTwo = oldGroups[1]; - if ((groupOne != 0 && (groupOne == oldGroupOne || groupOne == oldGroupTwo)) || (groupTwo != 0 && (groupTwo == oldGroupOne || groupTwo == oldGroupTwo))) - { - discarded[discardCount++] = buffs[i]; + if ((groupOne != 0 && (groupOne == oldGroupOne || groupOne == oldGroupTwo)) || (groupTwo != 0 && (groupTwo == oldGroupOne || groupTwo == oldGroupTwo))) { + discarded[discardCount++] = buff; } } } } int[] returnArray = new int[discardCount]; - for (int i = 0; i < discardCount; ++i) - { - returnArray[i] = discarded[i]; - } + System.arraycopy(discarded, 0, returnArray, 0, discardCount); return returnArray; } public static obj_id getBuffOwner(obj_id target, String name) throws InterruptedException @@ -1088,8 +1040,7 @@ public class buff extends script.base_script { return null; } - obj_id owner = utils.getObjIdScriptVar(target, "groupBuff." + nameCrc); - return owner; + return utils.getObjIdScriptVar(target, "groupBuff." + nameCrc); } public static void addGroupBuffEffect(obj_id target, obj_id owner, int[] buffList, float[] strList, float[] durList) throws InterruptedException { @@ -1125,19 +1076,17 @@ public class buff extends script.base_script { return; } - for (int i = 0; i < buffList.length; i++) - { - obj_id owner = utils.getObjIdScriptVar(target, "groupBuff." + buffList[i]); - if (owner != target) - { - _removeBuff(target, buffList[i]); - utils.removeScriptVar(target, "groupBuff." + buffList[i]); - if (beast_lib.isBeastMaster(target)) - { - obj_id beast = beast_lib.getBeastOnPlayer(target); - if (isIdValid(beast) && !isIdNull(beast)) - { - _removeBuff(beast, buffList[i]); + obj_id owner; + obj_id beast; + for (int aBuffList : buffList) { + owner = utils.getObjIdScriptVar(target, "groupBuff." + aBuffList); + if (owner != target) { + _removeBuff(target, aBuffList); + utils.removeScriptVar(target, "groupBuff." + aBuffList); + if (beast_lib.isBeastMaster(target)) { + beast = beast_lib.getBeastOnPlayer(target); + if (isIdValid(beast) && !isIdNull(beast)) { + _removeBuff(beast, aBuffList); } } } @@ -1156,12 +1105,11 @@ public class buff extends script.base_script } Vector buffList = new Vector(); buffList.setSize(0); - for (int i = 0; i < buffCrcList.length; i++) - { - obj_id owner = utils.getObjIdScriptVar(target, "groupBuff." + buffCrcList[i]); - if (isIdValid(owner) && owner == target && isGroupBuff(buffCrcList[i])) - { - buffList = utils.addElement(buffList, buffCrcList[i]); + obj_id owner; + for (int aBuffCrcList : buffCrcList) { + owner = utils.getObjIdScriptVar(target, "groupBuff." + aBuffCrcList); + if (isIdValid(owner) && owner == target && isGroupBuff(aBuffCrcList)) { + buffList = utils.addElement(buffList, aBuffCrcList); } } int[] _buffList = new int[0]; @@ -1170,7 +1118,7 @@ public class buff extends script.base_script _buffList = new int[buffList.size()]; for (int _i = 0; _i < buffList.size(); ++_i) { - _buffList[_i] = ((Integer)buffList.get(_i)).intValue(); + _buffList[_i] = (Integer) buffList.get(_i); } } return _buffList; @@ -1188,12 +1136,12 @@ public class buff extends script.base_script } Vector buffList = new Vector(); buffList.setSize(0); - for (int i = 0; i < buffCrcList.length; i++) - { - obj_id owner = utils.getObjIdScriptVar(target, "groupBuff." + buffCrcList[i]); - if (isIdValid(owner) && owner != target && isGroupBuff(buffCrcList[i])) - { - buffList = utils.addElement(buffList, buffCrcList[i]); + obj_id owner; + + for (int aBuffCrcList : buffCrcList) { + owner = utils.getObjIdScriptVar(target, "groupBuff." + aBuffCrcList); + if (isIdValid(owner) && owner != target && isGroupBuff(aBuffCrcList)) { + buffList = utils.addElement(buffList, aBuffCrcList); } } int[] _buffList = new int[0]; @@ -1202,7 +1150,7 @@ public class buff extends script.base_script _buffList = new int[buffList.size()]; for (int _i = 0; _i < buffList.size(); ++_i) { - _buffList[_i] = ((Integer)buffList.get(_i)).intValue(); + _buffList[_i] = (Integer) buffList.get(_i); } } return _buffList; @@ -1226,7 +1174,6 @@ public class buff extends script.base_script { return null; } - float modifier = squad_leader.getLeadershipMod(player); float[] strengthList = new float[buffList.length]; for (int i = 0; i < buffList.length; i++) { @@ -1258,22 +1205,13 @@ public class buff extends script.base_script { return true; } - for (int i = 0; i < buffs.length; i++) - { - if (isDebuff(buffs[i]) && getState(buffs[i]) == stateType) - { - _removeBuff(target, buffs[i]); + for (int buff : buffs) { + if (isDebuff(buff) && getState(buff) == stateType) { + _removeBuff(target, buff); removed = true; } } - if (removed) - { - return true; - } - else - { - return false; - } + return removed; } public static boolean toggleStance(obj_id player, String attemptedBuff) throws InterruptedException { @@ -1288,20 +1226,19 @@ public class buff extends script.base_script return false; } String groupAtt = attemptedBuffData.buffGroup1; - for (int i = 0; i < buffs.length; i++) - { - buff_data bdata = combat_engine.getBuffData(buffs[i]); - if (bdata == null) - { + buff_data bdata; + String curBuff; + String groupCur; + for (int buff : buffs) { + bdata = combat_engine.getBuffData(buff); + if (bdata == null) { continue; } - String curBuff = bdata.buffName; - String groupCur = bdata.buffGroup1; - if (groupCur.equals(groupAtt)) - { + curBuff = bdata.buffName; + groupCur = bdata.buffGroup1; + if (groupCur.equals(groupAtt)) { removeBuff(player, curBuff); - if (!curBuff.equals(attemptedBuff.toLowerCase())) - { + if (!curBuff.equals(attemptedBuff.toLowerCase())) { applyBuff(player, player, attemptedBuff); return false; } @@ -1388,15 +1325,11 @@ public class buff extends script.base_script } public static obj_id getBuffCaster(obj_id target, int nameCrc) throws InterruptedException { - obj_id caster = obj_id.NULL_ID; - caster = caster.getObjId(_getBuffCaster(target, nameCrc)); - return caster; + return obj_id.getObjId(_getBuffCaster(target, nameCrc)); } public static obj_id getBuffCaster(obj_id target, String nameCrc) throws InterruptedException { - obj_id caster = obj_id.NULL_ID; - caster = caster.getObjId(_getBuffCaster(target, getStringCrc(nameCrc.toLowerCase()))); - return caster; + return obj_id.getObjId(_getBuffCaster(target, getStringCrc(nameCrc.toLowerCase()))); } public static float getBuffTimeRemaining(obj_id target, int nameCrc) throws InterruptedException { @@ -1415,23 +1348,19 @@ public class buff extends script.base_script { return null; } - for (int i = 0; i < allDotBuffs.length; ++i) - { - String param1 = getEffectParam(allDotBuffs[i], 1); - if (param1.equals(type)) - { - utils.addElement(allDotBuffsOfType, allDotBuffs[i]); + String param1; + for (int allDotBuff : allDotBuffs) { + param1 = getEffectParam(allDotBuff, 1); + if (param1.equals(type)) { + utils.addElement(allDotBuffsOfType, allDotBuff); } } int[] _allDotBuffsOfType = new int[0]; - if (allDotBuffsOfType != null) - { - _allDotBuffsOfType = new int[allDotBuffsOfType.size()]; - for (int _i = 0; _i < allDotBuffsOfType.size(); ++_i) - { - _allDotBuffsOfType[_i] = ((Integer)allDotBuffsOfType.get(_i)).intValue(); - } - } + _allDotBuffsOfType = new int[allDotBuffsOfType.size()]; + for (int _i = 0; _i < allDotBuffsOfType.size(); ++_i) + { + _allDotBuffsOfType[_i] = (Integer) allDotBuffsOfType.get(_i); + } return _allDotBuffsOfType; } public static boolean performBuffDotImmunity(obj_id target, String dotType) throws InterruptedException @@ -1443,9 +1372,8 @@ public class buff extends script.base_script { return false; } - for (int i = 0; i < allDotBuffs.length; ++i) - { - removeBuff(target, allDotBuffs[i]); + for (int allDotBuff : allDotBuffs) { + removeBuff(target, allDotBuff); } return true; } @@ -1454,20 +1382,14 @@ public class buff extends script.base_script { return false; } - for (int i = 0; i < allBuffDotsOfType.length; ++i) - { - removeBuff(target, allBuffDotsOfType[i]); + for (int anAllBuffDotsOfType : allBuffDotsOfType) { + removeBuff(target, anAllBuffDotsOfType); } return true; } public static boolean isBuffDot(String buffName) throws InterruptedException { - String effectName = buff.getEffectParam(buffName, 2); - if (effectName.equals("dot")) - { - return true; - } - return false; + return buff.getEffectParam(buffName, 2).equals("dot"); } public static void reduceBuffDotStackCount(obj_id target, String dotType, int count) throws InterruptedException { @@ -1476,16 +1398,12 @@ public class buff extends script.base_script { return; } - for (int i = 0; i < allBuffsOfType.length; i++) - { - long stackCount = getBuffStackCount(target, allBuffsOfType[i]); - if (stackCount <= count) - { - removeBuff(target, allBuffsOfType[i]); - } - else - { - decrementBuffStack(target, allBuffsOfType[i], count); + for (int anAllBuffsOfType : allBuffsOfType) { + long stackCount = getBuffStackCount(target, anAllBuffsOfType); + if (stackCount <= count) { + removeBuff(target, anAllBuffsOfType); + } else { + decrementBuffStack(target, anAllBuffsOfType, count); } } } @@ -1496,24 +1414,17 @@ public class buff extends script.base_script { return; } - for (int i = 0; i < allBuffsOfType.length; i++) - { - long stackCount = getBuffStackCount(target, allBuffsOfType[i]); - if (stackCount <= 1) - { - removeBuff(target, allBuffsOfType[i]); - } - else - { - reduction = Math.round((float)stackCount * ((float)reduction / 100.0f)); + for (int anAllBuffsOfType : allBuffsOfType) { + long stackCount = getBuffStackCount(target, anAllBuffsOfType); + if (stackCount <= 1) { + removeBuff(target, anAllBuffsOfType); + } else { + reduction = Math.round((float) stackCount * ((float) reduction / 100.0f)); reduction = reduction < 1 ? 1 : reduction; - if (stackCount <= reduction) - { - removeBuff(target, allBuffsOfType[i]); - } - else - { - decrementBuffStack(target, allBuffsOfType[i], reduction); + if (stackCount <= reduction) { + removeBuff(target, anAllBuffsOfType); + } else { + decrementBuffStack(target, anAllBuffsOfType, reduction); } } } @@ -1527,11 +1438,9 @@ public class buff extends script.base_script int[] allBuffs = buff.getAllBuffs(player); if (allBuffs != null && allBuffs.length > 0) { - for (int i = 0; i < allBuffs.length; ++i) - { - if (buff.isAuraBuff(allBuffs[i])) - { - buff.removeBuff(player, allBuffs[i]); + for (int allBuff : allBuffs) { + if (buff.isAuraBuff(allBuff)) { + buff.removeBuff(player, allBuff); } } } @@ -1550,12 +1459,11 @@ public class buff extends script.base_script int[] allBuffs = getAllBuffs(player); if (allBuffs != null && allBuffs.length > 0) { - for (int i = 0; i < allBuffs.length; ++i) - { - String tempEffect = getEffectParam(allBuffs[i], 1); - if (effect.equals(tempEffect)) - { - return allBuffs[i]; + String tempEffect; + for (int allBuff : allBuffs) { + tempEffect = getEffectParam(allBuff, 1); + if (effect.equals(tempEffect)) { + return allBuff; } } } @@ -1574,14 +1482,12 @@ public class buff extends script.base_script if (isIdValid(groupId)) { obj_id[] groupPlayers = getGroupMemberIds(groupId); - for (int i = 0; i < groupPlayers.length; i++) - { - if (isIdValid(groupPlayers[i]) && exists(groupPlayers[i]) && pvpCanHelp(caster, groupPlayers[i]) && getDistance(groupPlayers[i], caster) < 100.0f) - { - toBuff.add(groupPlayers[i]); - obj_id thisBeast = beast_lib.getBeastOnPlayer(groupPlayers[i]); - if (isIdValid(thisBeast) && exists(thisBeast)) - { + obj_id thisBeast; + for (obj_id groupPlayer : groupPlayers) { + if (isIdValid(groupPlayer) && exists(groupPlayer) && pvpCanHelp(caster, groupPlayer) && getDistance(groupPlayer, caster) < 100.0f) { + toBuff.add(groupPlayer); + thisBeast = beast_lib.getBeastOnPlayer(groupPlayer); + if (isIdValid(thisBeast) && exists(thisBeast)) { toBuff.add(thisBeast); } } @@ -1592,11 +1498,8 @@ public class buff extends script.base_script toBuff.add(caster); } obj_id[] buffList = new obj_id[0]; - if (toBuff != null) - { - buffList = new obj_id[toBuff.size()]; - toBuff.toArray(buffList); - } + buffList = new obj_id[toBuff.size()]; + toBuff.toArray(buffList); applyBuff(buffList, caster, buffName); } public static boolean decayBuff(obj_id target, String buffName) throws InterruptedException @@ -1638,30 +1541,24 @@ public class buff extends script.base_script { return true; } - for (int i = 0; i < buffs.length; ++i) - { - buff_data bdata = combat_engine.getBuffData(buffs[i]); - if (bdata == null) - { + buff_data bdata; + for (int buff : buffs) { + bdata = combat_engine.getBuffData(buff); + if (bdata == null) { LOG("buff.scriptlib", "decayAllBuffsFromPvpDeath bdata is null"); continue; } int decayOnPvpDeath = bdata.decayOnPvpDeath; int removalOnDeath = bdata.removeOnDeath; - if (decayOnPvpDeath == 0 && removalOnDeath == 0) - { + if (decayOnPvpDeath == 0 && removalOnDeath == 0) { + continue; + } else if (decayOnPvpDeath == 0 && removalOnDeath == 1) { + _removeBuff(target, buff); + continue; + } else if (removalOnDeath == 0) { continue; } - else if (decayOnPvpDeath == 0 && removalOnDeath == 1) - { - _removeBuff(target, buffs[i]); - continue; - } - else if (removalOnDeath == 0) - { - continue; - } - _decayBuff(target, buffs[i], percent); + _decayBuff(target, buff, percent); } return true; } diff --git a/sku.0/sys.server/compiled/game/script/library/proc.java b/sku.0/sys.server/compiled/game/script/library/proc.java old mode 100644 new mode 100755 index 30c0aaf40..311b8e541 --- a/sku.0/sys.server/compiled/game/script/library/proc.java +++ b/sku.0/sys.server/compiled/game/script/library/proc.java @@ -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); } } } diff --git a/sku.0/sys.server/compiled/game/script/library/prose.java b/sku.0/sys.server/compiled/game/script/library/prose.java old mode 100644 new mode 100755 index 69d334821..85c10f462 --- a/sku.0/sys.server/compiled/game/script/library/prose.java +++ b/sku.0/sys.server/compiled/game/script/library/prose.java @@ -1,12 +1,8 @@ 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.obj_id; +import script.prose_package; +import script.string_id; public class prose extends script.base_script { diff --git a/sku.0/sys.server/compiled/game/script/library/pvp.java b/sku.0/sys.server/compiled/game/script/library/pvp.java old mode 100644 new mode 100755 index 13538c791..89e130f76 --- a/sku.0/sys.server/compiled/game/script/library/pvp.java +++ b/sku.0/sys.server/compiled/game/script/library/pvp.java @@ -1,23 +1,8 @@ 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.library.buff; -import script.library.colors; -import script.library.factions; -import script.library.force_rank; -import script.library.pet_lib; -import script.library.prose; -import script.library.sui; -import script.library.trace; -import script.library.utils; -import java.lang.Math; +import java.util.Vector; public class pvp extends script.base_script { @@ -123,7 +108,7 @@ public class pvp extends script.base_script { damArray[i] = new obj_var(attackerList[i].toString(), utils.getIntScriptVar(victim, VAR_ATTACKER_LIST + "." + attackerList[i] + ".damage")); } - if (damArray == null || damArray.length == 0) + if (damArray.length == 0) { trace.log("pvp_rating", "pvp.scriptlib._packageCombatWinners:-> damArray is bunk. Bailing..", victim, trace.TL_WARNING); return null; @@ -157,11 +142,9 @@ public class pvp extends script.base_script } public static prose_package getPvPRatedProsePackage(obj_id winner, obj_id loser, boolean winnerPackage) throws InterruptedException { - String stringId = ""; - String stringFile = "pvp_rating"; - String[] phrases = null; - obj_id actor = null; - obj_id target = null; + String[] phrases; + obj_id actor; + obj_id target; if (winnerPackage) { actor = winner; @@ -206,9 +189,8 @@ public class pvp extends script.base_script phrases[2] = "win3"; } } - stringId = phrases[rand(0, phrases.length - 1)]; prose_package pp_msg = new prose_package(); - pp_msg.stringId = new string_id(stringFile, stringId); + pp_msg.stringId = new string_id("pvp_rating", phrases[rand(0, phrases.length - 1)]); pp_msg.actor.set(actor); pp_msg.target.set(utils.getRealPlayerFirstName(target)); pp_msg.digitInteger = getCurrentPvPRating(actor); @@ -216,10 +198,9 @@ public class pvp extends script.base_script } public static prose_package getPvPThrottleProsePackage(obj_id winner, obj_id loser, boolean winnerPackage) throws InterruptedException { - String stringId = ""; - String stringFile = "pvp_rating"; - obj_id actor = null; - obj_id target = null; + String stringId; + obj_id actor; + obj_id target; if (winnerPackage) { actor = winner; @@ -253,7 +234,7 @@ public class pvp extends script.base_script } } prose_package pp_msg = new prose_package(); - pp_msg.stringId = new string_id(stringFile, stringId); + pp_msg.stringId = new string_id("pvp_rating", stringId); pp_msg.actor.set(actor); pp_msg.target.set(utils.getRealPlayerFirstName(target)); pp_msg.digitInteger = getCurrentPvPRating(actor); @@ -261,10 +242,9 @@ public class pvp extends script.base_script } public static prose_package getPvPRatingFloorProsePackage(obj_id winner, obj_id loser, boolean winnerPackage) throws InterruptedException { - String stringId = ""; - String stringFile = "pvp_rating"; - obj_id actor = null; - obj_id target = null; + String stringId; + obj_id actor; + obj_id target; if (winnerPackage) { actor = winner; @@ -298,7 +278,7 @@ public class pvp extends script.base_script } } prose_package pp_msg = new prose_package(); - pp_msg.stringId = new string_id(stringFile, stringId); + pp_msg.stringId = new string_id("pvp_rating", stringId); pp_msg.actor.set(actor); pp_msg.target.set(utils.getRealPlayerFirstName(target)); pp_msg.digitInteger = getCurrentPvPRating(actor); @@ -309,7 +289,7 @@ public class pvp extends script.base_script int totalDamageTally = 0; if (utils.hasScriptVar(victim, VAR_TOTAL_DAMAGE_TALLY)) { - totalDamageTally = (int)utils.getIntScriptVar(victim, VAR_TOTAL_DAMAGE_TALLY); + totalDamageTally = utils.getIntScriptVar(victim, VAR_TOTAL_DAMAGE_TALLY); } if (totalDamageTally < 0) { @@ -320,7 +300,6 @@ public class pvp extends script.base_script { return; } - boolean victimDeathCountsForPoints = false; boolean onlyThrottledAttackers = true; obj_id messageWinner = null; int victimRatingDelta = 0; @@ -331,78 +310,56 @@ public class pvp extends script.base_script dictionary darkJediPvPAction = new dictionary(); darkJediPvPAction.put("victim", victim); darkJediPvPAction.put("totalDamageToVictim", totalDamageTally); - for (int i = 0; i < winners.length; i++) - { - obj_var winnerVar = winners[i]; + obj_id winner; + + for (obj_var winnerVar : winners) { int dam = winnerVar.getIntData(); - obj_id winner = utils.stringToObjId(winnerVar.getName()); - float percentContribution = ((float)dam / totalDamageTally); + winner = utils.stringToObjId(winnerVar.getName()); + float percentContribution = ((float) dam / totalDamageTally); trace.log("pvp_rating", "Calculating point exchange for winner " + winnerVar.getName(), victim, trace.TL_DEBUG); - if ((!isIdValid(winner)) || (!winner.isLoaded()) || (winner.isBeingDestroyed()) || (winner == victim)) - { + if ((!isIdValid(winner)) || (!winner.isLoaded()) || (winner.isBeingDestroyed()) || (winner == victim)) { trace.log("pvp_rating", "pvp.scriptlib.adjustPvPRatings: killer is invalid, !isLoaded, or isBeingDestroyed. ignoring...", winner, trace.TL_WARNING); - continue; + return; } - else - { - messageWinner = winner; - if (!hasKilledVictimRecently(winner, victim)) - { - onlyThrottledAttackers = false; - if (getDistance(winner, victim) > MAX_DISTANCE) - { - continue; - } - if (!pvpCanAttack(victim, winner)) - { - continue; - } - if (canAffectForceRankXPChange(victim, winner)) - { - if (force_rank.getCouncilAffiliation(victim) == force_rank.DARK_COUNCIL && force_rank.getCouncilAffiliation(winner) == force_rank.DARK_COUNCIL) - { - darkJediXPRequests.put(winner, percentContribution); - darkJediPvPAction.put(winner, percentContribution); - } - else - { - int xpAdjustment = getAdjustedForceRankXPDelta(victim, winner, percentContribution, false); - if (xpAdjustment != 0) - { - force_rank.adjustForceRankXP(winner, xpAdjustment); - } - victimXPDelta += getAdjustedForceRankXPDelta(victim, winner, percentContribution, true); - trace.log("force_rank", "Winner " + utils.getRealPlayerFirstName(winner) + "(" + winner + ") was awarded " + xpAdjustment + " Council XP for their " + percentContribution * 100 + "% contribution to the death of %TU", victim, trace.TL_CS_LOG | trace.TL_DEBUG); - } - } - else - { - if (force_rank.getCouncilAffiliation(victim) == force_rank.DARK_COUNCIL && force_rank.getCouncilAffiliation(winner) == force_rank.DARK_COUNCIL) - { - darkJediPvPAction.put(winner, percentContribution); - } - } - int winnerDelta = getAdjustedPvPRatingDelta(victim, winner, percentContribution, false); - int winnerCur = getCurrentPvPRating(winner); - trace.log(PVP_CS_LOG, "Winner " + utils.getRealPlayerFirstName(winner) + "(" + winner + ") was awarded " + winnerDelta + " PvP Rating Points for their " + percentContribution * 100 + "% contribution to the death of %TU", victim, trace.TL_CS_LOG | trace.TL_DEBUG); - setCurrentPvPRating(winner, winnerCur + winnerDelta); - victimRatingDelta += getAdjustedPvPRatingDelta(victim, winner, percentContribution, true); - prose_package ppr = getPvPRatedProsePackage(winner, victim, true); - sendSystemMessageProse(winner, ppr); - registerPlayerKill(winner, victim); + messageWinner = winner; + if (!hasKilledVictimRecently(winner, victim)) { + onlyThrottledAttackers = false; + if (getDistance(winner, victim) > MAX_DISTANCE) { + continue; } - else - { - if (force_rank.getCouncilAffiliation(victim) == force_rank.DARK_COUNCIL && force_rank.getCouncilAffiliation(winner) == force_rank.DARK_COUNCIL) - { + if (!pvpCanAttack(victim, winner)) { + continue; + } + if (canAffectForceRankXPChange(victim, winner)) { + if (force_rank.getCouncilAffiliation(victim) == force_rank.DARK_COUNCIL && force_rank.getCouncilAffiliation(winner) == force_rank.DARK_COUNCIL) { + darkJediXPRequests.put(winner, percentContribution); + darkJediPvPAction.put(winner, percentContribution); + } else { + int xpAdjustment = getAdjustedForceRankXPDelta(victim, winner, percentContribution, false); + if (xpAdjustment != 0) { + force_rank.adjustForceRankXP(winner, xpAdjustment); + } + victimXPDelta += getAdjustedForceRankXPDelta(victim, winner, percentContribution, true); + trace.log("force_rank", "Winner " + utils.getRealPlayerFirstName(winner) + "(" + winner + ") was awarded " + xpAdjustment + " Council XP for their " + percentContribution * 100 + "% contribution to the death of %TU", victim, trace.TL_CS_LOG | trace.TL_DEBUG); + } + } else { + if (force_rank.getCouncilAffiliation(victim) == force_rank.DARK_COUNCIL && force_rank.getCouncilAffiliation(winner) == force_rank.DARK_COUNCIL) { darkJediPvPAction.put(winner, percentContribution); } - else - { - prose_package pp = getPvPThrottleProsePackage(winner, victim, true); - sendSystemMessageProse(winner, pp); - trace.log(PVP_CS_LOG, "PvP points not awarded to " + utils.getRealPlayerFirstName(winner) + "(" + winner + ") for participation in death of %TU - recently killed.", victim, trace.TL_CS_LOG | trace.TL_DEBUG); - } + } + int winnerDelta = getAdjustedPvPRatingDelta(victim, winner, percentContribution, false); + trace.log(PVP_CS_LOG, "Winner " + utils.getRealPlayerFirstName(winner) + "(" + winner + ") was awarded " + winnerDelta + " PvP Rating Points for their " + percentContribution * 100 + "% contribution to the death of %TU", victim, trace.TL_CS_LOG | trace.TL_DEBUG); + setCurrentPvPRating(winner, getCurrentPvPRating(winner) + winnerDelta); + victimRatingDelta += getAdjustedPvPRatingDelta(victim, winner, percentContribution, true); + sendSystemMessageProse(winner, getPvPRatedProsePackage(winner, victim, true)); + registerPlayerKill(winner, victim); + } else { + if (force_rank.getCouncilAffiliation(victim) == force_rank.DARK_COUNCIL && force_rank.getCouncilAffiliation(winner) == force_rank.DARK_COUNCIL) { + darkJediPvPAction.put(winner, percentContribution); + } else { + prose_package pp = getPvPThrottleProsePackage(winner, victim, true); + sendSystemMessageProse(winner, pp); + trace.log(PVP_CS_LOG, "PvP points not awarded to " + utils.getRealPlayerFirstName(winner) + "(" + winner + ") for participation in death of %TU - recently killed.", victim, trace.TL_CS_LOG | trace.TL_DEBUG); } } } @@ -415,15 +372,12 @@ public class pvp extends script.base_script { trace.log(PVP_CS_LOG, "%TU lost a total of " + victimRatingDelta + " PvP rating points to normal pvp for this death.", victim, trace.TL_CS_LOG); setCurrentPvPRating(victim, getCurrentPvPRating(victim) + victimRatingDelta); - prose_package pp = getPvPRatedProsePackage(messageWinner, victim, false); - sendSystemMessageProse(victim, pp); + sendSystemMessageProse(victim, getPvPRatedProsePackage(messageWinner, victim, false)); } else if (onlyThrottledAttackers && isIdValid(messageWinner)) { - prose_package pp = getPvPThrottleProsePackage(messageWinner, victim, false); - sendSystemMessageProse(victim, pp); + sendSystemMessageProse(victim, getPvPThrottleProsePackage(messageWinner, victim, false)); } - return; } public static boolean canAffectForceRankXPChange(obj_id victim, obj_id winner) throws InterruptedException { @@ -457,16 +411,13 @@ public class pvp extends script.base_script public static int getRawForceRankXPDelta(obj_id player, boolean playerWon, obj_id opponent) throws InterruptedException { int playerRank = force_rank.getForceRank(player); - int opponentRank = force_rank.getForceRank(opponent); if (playerRank < 0) { return 0; } - String columnName = ""; String rowName = ""; String rowPrefix = ""; String rowSuffix = ""; - columnName = "rank" + playerRank; if (isInOpposingPvPFactions(player, opponent)) { rowPrefix = FRS_DT_ROW_NONJEDI_PREFIX; @@ -475,6 +426,7 @@ public class pvp extends script.base_script { rowPrefix = FRS_DT_ROW_PADAWAN_PREFIX; } + int opponentRank = force_rank.getForceRank(opponent); if (opponentRank > -1) { rowPrefix = FRS_DT_RANKED_JEDI_PREFIX + opponentRank; @@ -492,7 +444,7 @@ public class pvp extends script.base_script rowSuffix = FRS_DT_ROW_LOSS_SUFFIX; } rowName = rowPrefix + rowSuffix; - int xpDelta = dataTableGetInt(FRS_XP_DATATABLE, rowName, columnName); + int xpDelta = dataTableGetInt(FRS_XP_DATATABLE, rowName, "rank" + playerRank); if (xpDelta == -1) { return 0; @@ -506,13 +458,9 @@ public class pvp extends script.base_script } public static int getAdjustedForceRankXPDelta(obj_id victim, obj_id killer, double percentContribution, boolean gettingVictimsDelta) throws InterruptedException { - String wonlost = "winning the battle against"; - if (gettingVictimsDelta) - { - wonlost = "losing the battle to"; - } - obj_id targetPlayer = null; - obj_id opponent = null; + String wonlost = (gettingVictimsDelta ? "losing the battle to" : "winning the battle against"); + obj_id targetPlayer; + obj_id opponent; if (gettingVictimsDelta) { targetPlayer = victim; @@ -531,7 +479,7 @@ public class pvp extends script.base_script disparity = MAX_RATING_DISPARITY; } trace.log("pvp_rating", "Target " + utils.getRealPlayerFirstName(targetPlayer) + "'s PvP rating is " + targetRat + "; Opponent " + utils.getRealPlayerFirstName(opponent) + "'s rating is " + opponentRat + " for a final disparity of " + disparity, opponent, trace.TL_DEBUG); - float pvpRatingXPAdjustment = ((float)disparity / (float)MAX_RATING_DISPARITY) * (float)MAX_RATING_AFFECT_ON_XP; + float pvpRatingXPAdjustment = ((float)disparity / (float)MAX_RATING_DISPARITY) * MAX_RATING_AFFECT_ON_XP; trace.log("pvp_rating", "Rating Disparity is " + disparity + ", creating an XP mod of " + (pvpRatingXPAdjustment * 100) + "% (" + pvpRatingXPAdjustment + ")", null, trace.TL_DEBUG); int targetDelta = getRawForceRankXPDelta(targetPlayer, !gettingVictimsDelta, opponent); trace.log("pvp_rating", utils.getRealPlayerFirstName(targetPlayer) + "'s raw target player XP Delta for " + wonlost + " opponent " + utils.getRealPlayerFirstName(opponent) + " is " + targetDelta, targetPlayer, trace.TL_DEBUG); @@ -558,8 +506,8 @@ public class pvp extends script.base_script trace.log("pvp_rating", "pvp.scriptlib.getAdjustedPvPRatingDelta:-> percentInvolvement > 1.0 (" + percentInvolvement + "). Bailing.", loser, trace.TL_WARNING | trace.TL_DEBUG); return 0; } - obj_id targetPlayer = null; - obj_id opponent = null; + obj_id targetPlayer; + obj_id opponent; if (gettingVictimsDelta) { targetPlayer = loser; @@ -570,9 +518,7 @@ public class pvp extends script.base_script targetPlayer = winner; opponent = loser; } - int targetRating = getCurrentPvPRating(targetPlayer); - int opponentRating = getCurrentPvPRating(opponent); - int targetDelta = getPvPRatingDelta(targetRating, opponentRating, (!gettingVictimsDelta)); + int targetDelta = getPvPRatingDelta(getCurrentPvPRating(targetPlayer), getCurrentPvPRating(opponent), (!gettingVictimsDelta)); trace.log("pvp_rating", utils.getRealPlayerFirstName(targetPlayer) + "'s raw RATING DELTA, based on a battle against " + utils.getRealPlayerFirstName(opponent) + " is " + targetDelta, targetPlayer, trace.TL_DEBUG); targetDelta = _massageDeltaWithRules(targetDelta, !gettingVictimsDelta); trace.log("pvp_rating", "After adjusting " + utils.getRealPlayerFirstName(targetPlayer) + "'s raw RATING DELTA, based on Min/Max loss/gain rules, the adjusted delta is " + targetDelta, targetPlayer, trace.TL_DEBUG); @@ -647,26 +593,12 @@ public class pvp extends script.base_script } public static void updateDamageContributorList(obj_id target, obj_id attackr, int dam) throws InterruptedException { - obj_id realAttacker = attackr; - if (!isIdValid(target) || (!isIdValid(realAttacker))) + if (!isIdValid(target) || (!isIdValid(attackr))) { trace.log("pvp_rating.scriptlib", "updateDamageContributorList:-> Target or Attacker is invalid. Bailing.", target, trace.TL_WARNING | trace.TL_DEBUG); return; } - if (pet_lib.isPet(realAttacker)) - { - if (!COUNT_PET_DAMAGE) - { - return; - } - if (!pet_lib.hasMaster(realAttacker)) - { - return; - } - realAttacker = getMaster(attackr); - dam = (int)((float)dam * COUNT_PET_DAMAGE_PERCENT); - } - else if (!isPlayer(realAttacker)) + if (pet_lib.isPet(attackr) || !isPlayer(attackr)) { return; } @@ -679,23 +611,21 @@ public class pvp extends script.base_script Vector attackerList = utils.getResizeableObjIdBatchScriptVar(target, VAR_ATTACKER_LIST); if (attackerList != null && attackerList.size() > 0) { - if (utils.getElementPositionInArray(attackerList, realAttacker) == -1) + if (utils.getElementPositionInArray(attackerList, attackr) == -1) { - attackerList = utils.addElement(attackerList, realAttacker); + attackerList = utils.addElement(attackerList, attackr); utils.setBatchScriptVar(target, VAR_ATTACKER_LIST, attackerList); } } else { - attackerList = utils.addElement(attackerList, realAttacker); + attackerList = utils.addElement(attackerList, attackr); utils.setBatchScriptVar(target, VAR_ATTACKER_LIST, attackerList); } - String basePath = VAR_ATTACKER_LIST + "." + realAttacker; - String damPath = basePath + ".damage"; + String damPath = VAR_ATTACKER_LIST + "." + attackr + ".damage"; int totalDamage = dam + utils.getIntScriptVar(target, damPath); utils.setScriptVar(target, damPath, totalDamage); } - return; } public static boolean hasKilledVictimRecently(obj_id attacker, obj_id victim) throws InterruptedException { @@ -744,7 +674,6 @@ public class pvp extends script.base_script utils.setResizeableBatchObjVar(attacker, VAR_PVP_LAST_KILLS, victimList); } setObjVar(attacker, VAR_PVP_LAST_UPDATE, getGameTime() + PVP_TRACKING_INTERVAL); - return; } public static boolean cleanupCreditForPvPKills(obj_id whichPlayer) throws InterruptedException { @@ -752,8 +681,7 @@ public class pvp extends script.base_script utils.removeScriptVarTree(whichPlayer, "creditForPvPKillsTracking"); if (hasObjVar(whichPlayer, VAR_PVP_LAST_UPDATE)) { - int last_update = getIntObjVar(whichPlayer, VAR_PVP_LAST_UPDATE); - if (last_update < getGameTime()) + if (getIntObjVar(whichPlayer, VAR_PVP_LAST_UPDATE) < getGameTime()) { removeObjVar(whichPlayer, VAR_PVP_LAST_KILLS); removeObjVar(whichPlayer, VAR_PVP_LAST_UPDATE); @@ -763,10 +691,8 @@ public class pvp extends script.base_script } public static void updatePvPDamageTimeStamp(obj_id player) throws InterruptedException { - int now = getGameTime(); setupClearPvPDamageCallback(player); - utils.setScriptVar(player, VAR_LAST_PVP_DAMAGE_TIME, now); - return; + utils.setScriptVar(player, VAR_LAST_PVP_DAMAGE_TIME, getGameTime()); } public static void setupClearPvPDamageCallback(obj_id player) throws InterruptedException { @@ -776,7 +702,6 @@ public class pvp extends script.base_script } messageTo(player, "checkPvPDamageTime", null, CONTRIB_CLEAR_INTERVAL, false); utils.setScriptVar(player, VAR_LAST_PVP_DAMAGE_MSG_SENT, true); - return; } public static boolean isBountyHunter(obj_id player) throws InterruptedException { @@ -788,18 +713,10 @@ public class pvp extends script.base_script } public static boolean isInOpposingPvPFactions(obj_id player1, obj_id player2) throws InterruptedException { - if (isPlayer(player1) && pvpGetType(player1) == PVPTYPE_NEUTRAL) - { + if (isPlayer(player1) && pvpGetType(player1) == PVPTYPE_NEUTRAL) { return false; - } - else if (isPlayer(player2) && pvpGetType(player2) == PVPTYPE_NEUTRAL) - { - return false; - } - else - { - return (pvpAreFactionsOpposed(pvpGetAlignedFaction(player1), pvpGetAlignedFaction(player2))); - } + } else + return !(isPlayer(player2) && pvpGetType(player2) == PVPTYPE_NEUTRAL) && (pvpAreFactionsOpposed(pvpGetAlignedFaction(player1), pvpGetAlignedFaction(player2))); } public static boolean updatePlayerDamageTracking(obj_id player, obj_id attacker, obj_id wpn, int[] damage) throws InterruptedException { @@ -812,9 +729,8 @@ public class pvp extends script.base_script return false; } long tmpTotal = 0; - for (int i = 0; i < damage.length; i++) - { - tmpTotal += damage[i]; + for (int aDamage : damage) { + tmpTotal += aDamage; } if (tmpTotal > Integer.MAX_VALUE) { @@ -823,8 +739,7 @@ public class pvp extends script.base_script int totalDamage = (int)tmpTotal; if (isPvpDamageSource(player, attacker)) { - int currentDamage = utils.getIntScriptVar(player, SCRIPTVAR_PVP_DAMAGE); - long newTotal = currentDamage + totalDamage; + long newTotal = utils.getIntScriptVar(player, SCRIPTVAR_PVP_DAMAGE) + totalDamage; if (newTotal > Integer.MAX_VALUE) { newTotal = Integer.MAX_VALUE; @@ -834,8 +749,7 @@ public class pvp extends script.base_script } else { - int currentDamage = utils.getIntScriptVar(player, SCRIPTVAR_PVE_DAMAGE); - long newTotal = currentDamage + totalDamage; + long newTotal = utils.getIntScriptVar(player, SCRIPTVAR_PVE_DAMAGE) + totalDamage; if (newTotal > Integer.MAX_VALUE) { newTotal = Integer.MAX_VALUE; @@ -874,9 +788,7 @@ public class pvp extends script.base_script { return; } - int now = getGameTime(); - int stamp = utils.getIntScriptVar(player, SCRIPTVAR_PVP_STAMP); - int delta = now - stamp; + int delta = getGameTime() - utils.getIntScriptVar(player, SCRIPTVAR_PVP_STAMP); if (delta < BUFFER_TIME) { return; @@ -905,9 +817,7 @@ public class pvp extends script.base_script { return false; } - int now = getGameTime(); - int stamp = utils.getIntScriptVar(player, SCRIPTVAR_PVP_STAMP); - int delta = now - stamp; + int delta = getGameTime() - utils.getIntScriptVar(player, SCRIPTVAR_PVP_STAMP); if (delta >= BUFFER_TIME) { return false; @@ -964,16 +874,13 @@ public class pvp extends script.base_script { players = utils.getResizeableObjIdBatchScriptVar(controller, BATTLEFIELD_ACTIVE_PLAYERS); } - dictionary params = new dictionary(); if (players != null && players.size() > 0) { - for (int i = 0, j = players.size(); i < j; i++) - { - if (!isIdValid(((obj_id)players.get(i))) || !exists(((obj_id)players.get(i)))) - { + for (Object player : players) { + if (!isIdValid(((obj_id) player)) || !exists(((obj_id) player))) { continue; } - sendSystemMessage(((obj_id)players.get(i)), announcement); + sendSystemMessage(((obj_id) player), announcement); } } } @@ -987,20 +894,19 @@ public class pvp extends script.base_script } if (players != null && players.size() > 0) { - for (int i = 0, j = players.size(); i < j; i++) - { - if (((String)players.get(i)) == null || ((String)players.get(i)).length() < 1) - { + String[] playerInfo; + obj_id player; + + for (Object player1 : players) { + if (player1 == null || ((String) player1).length() < 1) { continue; } - String[] playerInfo = split(((String)players.get(i)), '^'); - if (playerInfo == null || playerInfo.length < 1) - { + playerInfo = split(((String) player1), '^'); + if (playerInfo == null || playerInfo.length < 1) { continue; } - obj_id player = utils.stringToObjId(playerInfo[0]); - if (!isIdValid(player)) - { + player = utils.stringToObjId(playerInfo[0]); + if (!isIdValid(player)) { continue; } messageTo(player, message, params, 1.0f, false); @@ -1017,20 +923,19 @@ public class pvp extends script.base_script } if (players != null && players.size() > 0) { - for (int i = 0, j = players.size(); i < j; i++) - { - if (((String)players.get(i)) == null || ((String)players.get(i)).length() < 1) - { + String[] playerInfo; + obj_id player; + + for (Object player1 : players) { + if (player1 == null || ((String) player1).length() < 1) { continue; } - String[] playerInfo = split(((String)players.get(i)), '^'); - if (playerInfo == null || playerInfo.length < 1) - { + playerInfo = split(((String) player1), '^'); + if (playerInfo == null || playerInfo.length < 1) { continue; } - obj_id player = utils.stringToObjId(playerInfo[0]); - if (!isIdValid(player) || !exists(player)) - { + player = utils.stringToObjId(playerInfo[0]); + if (!isIdValid(player) || !exists(player)) { continue; } messageTo(player, message, params, 1.0f, false); @@ -1052,26 +957,22 @@ public class pvp extends script.base_script if (activelTeam != null && activelTeam.size() > 0) { int count = 0; - for (int i = 0, j = activelTeam.size(); i < j; i++) - { - if (((String)activelTeam.get(i)) == null || ((String)activelTeam.get(i)).length() < 1) - { + String[] activeMember; + dictionary member; + for (Object anActivelTeam : activelTeam) { + if (anActivelTeam == null || ((String) anActivelTeam).length() < 1) { continue; } - String[] activeMember = split(((String)activelTeam.get(i)), '^'); - if (activeMember.length < 9) - { + activeMember = split(((String) anActivelTeam), '^'); + if (activeMember.length < 9) { continue; } - dictionary member = new dictionary(); + member = new dictionary(); member.put("player", utils.stringToObjId(activeMember[0])); member.put("name", activeMember[2]); - if (scriptVar.equals(BATTLEFIELD_ACTIVE_REBEL_PLAYERS)) - { + if (scriptVar.equals(BATTLEFIELD_ACTIVE_REBEL_PLAYERS)) { member.put("faction", factions.FACTION_FLAG_REBEL); - } - else if (scriptVar.equals(BATTLEFIELD_ACTIVE_IMPERIAL_PLAYERS)) - { + } else if (scriptVar.equals(BATTLEFIELD_ACTIVE_IMPERIAL_PLAYERS)) { member.put("faction", factions.FACTION_FLAG_IMPERIAL); } member.put("kills", utils.stringToInt(activeMember[3])); @@ -1108,11 +1009,15 @@ public class pvp extends script.base_script return null; } String[][] scoreData = new String[battlefieldPlayers.size()][8]; + String color; + String factionName; + String name; + for (int i = 0, j = battlefieldPlayers.size(); i < j; i++) { int faction = ((dictionary)battlefieldPlayers.get(i)).getInt("faction"); - String color = COLOR_IMPERIALS; - String factionName = "Imperial"; + color = COLOR_IMPERIALS; + factionName = "Imperial"; if (faction == factions.FACTION_FLAG_REBEL) { color = COLOR_REBELS; @@ -1123,7 +1028,7 @@ public class pvp extends script.base_script color = ""; } scoreData[i][1] = color + factionName; - String name = ((dictionary)battlefieldPlayers.get(i)).getString("name"); + name = ((dictionary) battlefieldPlayers.get(i)).getString("name"); if (name == null || name.length() < 1) { name = "Unknown"; @@ -1279,14 +1184,11 @@ public class pvp extends script.base_script { return false; } - for (int i = 0, j = terminals.size(); i < j; i++) - { - if (!isIdValid(((obj_id)terminals.get(i))) || !exists(((obj_id)terminals.get(i)))) - { + for (Object terminal1 : terminals) { + if (!isIdValid(((obj_id) terminal1)) || !exists(((obj_id) terminal1))) { continue; } - if (((obj_id)terminals.get(i)) == terminal) - { + if (terminal1 == terminal) { return true; } } @@ -1322,14 +1224,11 @@ public class pvp extends script.base_script utils.setBatchScriptVar(controller, "battlefield.terminals", terminals); return; } - for (int i = 0, j = terminals.size(); i < j; i++) - { - if (!isIdValid(((obj_id)terminals.get(i))) || !exists(((obj_id)terminals.get(i)))) - { + for (Object terminal1 : terminals) { + if (!isIdValid(((obj_id) terminal1)) || !exists(((obj_id) terminal1))) { continue; } - if (((obj_id)terminals.get(i)) == terminal) - { + if (terminal1 == terminal) { return; } } @@ -1366,19 +1265,16 @@ public class pvp extends script.base_script { return false; } - int terminalCount = getIntObjVar(controller, "battlefield.terminalCount"); - if (terminalCount != terminals.size()) + if (getIntObjVar(controller, "battlefield.terminalCount") != terminals.size()) { return false; } - for (int i = 0, j = terminals.size(); i < j; i++) - { - if (!isIdValid(((obj_id)terminals.get(i))) || !exists(((obj_id)terminals.get(i)))) - { + for (Object terminal : terminals) { + if (!isIdValid(((obj_id) terminal)) || !exists(((obj_id) terminal))) { continue; } - utils.removeScriptVar(((obj_id)terminals.get(i)), "battlefield.captured"); - messageTo(((obj_id)terminals.get(i)), "receiveBattlefieldReset", null, 1.0f, false); + utils.removeScriptVar(((obj_id) terminal), "battlefield.captured"); + messageTo(((obj_id) terminal), "receiveBattlefieldReset", null, 1.0f, false); } return true; } @@ -1437,11 +1333,7 @@ public class pvp extends script.base_script return false; } obj_id runner = utils.getObjIdScriptVar(controller, "battlefield.runner"); - if (isIdValid(runner) && exists(runner)) - { - return true; - } - return false; + return isIdValid(runner) && exists(runner); } public static void bfActiveWarpPlayerToStart(obj_id controller, obj_id player) throws InterruptedException { @@ -1450,7 +1342,7 @@ public class pvp extends script.base_script return; } int battlefieldState = utils.getIntScriptVar(controller, "battlefield.state"); - location loc = null; + location loc; if (factions.isRebel(player)) { loc = utils.getLocationScriptVar(controller, "battlefieldRebelSpawn"); diff --git a/sku.0/sys.server/compiled/game/script/library/quests.java b/sku.0/sys.server/compiled/game/script/library/quests.java index 1955ff003..e78cf7078 100755 --- a/sku.0/sys.server/compiled/game/script/library/quests.java +++ b/sku.0/sys.server/compiled/game/script/library/quests.java @@ -1,17 +1,8 @@ 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.library.battlefield; -import script.library.regions; -import script.library.group; -import script.library.badge; +import java.util.Vector; public class quests extends script.base_script { @@ -32,14 +23,7 @@ public class quests extends script.base_script } public static boolean hasQuest(obj_id player, String QUEST_ID) throws InterruptedException { - if (getQuestStatus(player, QUEST_ID) == IS_ON_QUEST) - { - return true; - } - else - { - return false; - } + return getQuestStatus(player, QUEST_ID) == IS_ON_QUEST; } public static void removeQuestStatus(obj_id player, String questId) throws InterruptedException { @@ -142,7 +126,6 @@ public class quests extends script.base_script destroyObject(waypoint); removeLocationTarget(name); removeObjVar(player, questId + ".waypoint." + name); - return; } } public static void clearAllWaypoints(obj_id player, String questId) throws InterruptedException @@ -157,10 +140,12 @@ public class quests extends script.base_script return; } int count = waypointList.getNumItems(); + obj_var waypointVar; + obj_id waypoint; for (int i = 0; i < count; ++i) { - obj_var waypointVar = waypointList.getObjVar(i); - obj_id waypoint = waypointVar.getObjIdData(); + waypointVar = waypointList.getObjVar(i); + waypoint = waypointVar.getObjIdData(); setWaypointVisible(waypoint, false); setWaypointActive(waypoint, false); destroyObject(waypoint); @@ -177,15 +162,15 @@ public class quests extends script.base_script } public static obj_id spawnAttacker(String template, location loc, obj_id target) throws InterruptedException { - obj_id attacker = createObject(template, loc); - return attacker; + return createObject(template, loc); } public static obj_id[] spawnAttackers(String msgHandlerName, int number, String template, location loc, obj_id target) throws InterruptedException { obj_id[] attackers = new obj_id[number]; + location newloc; for (int i = 0; i < number; i++) { - location newloc = new location(loc); + newloc = new location(loc); newloc.x = loc.x + rand(-2, +2); newloc.z = loc.z + rand(-2, +2); attackers[i] = spawnAttacker(msgHandlerName, template, newloc, target); @@ -195,9 +180,10 @@ public class quests extends script.base_script public static obj_id[] spawnAttackers(int number, String template, location loc, obj_id target) throws InterruptedException { obj_id[] attackers = new obj_id[number]; + location newloc; for (int i = 0; i < number; i++) { - location newloc = new location(loc); + newloc = new location(loc); newloc.x = loc.x + rand(-2, +2); newloc.z = loc.z + rand(-2, +2); attackers[i] = spawnAttacker(template, newloc, target); @@ -226,14 +212,12 @@ public class quests extends script.base_script } public static location getTargetLocation(obj_id self) throws InterruptedException { - obj_id containedBy = getTopMostContainer(self); - location target = new location(); + location target = null; int x = 0; + location questLoc; while (x < 10) { - location here = getLocation(self); - region quest = locations.getCityRegion(here); - location questLoc = locations.getGoodLocationOutsideOfRegion(quest, 100f, 100f, 100f); + questLoc = locations.getGoodLocationOutsideOfRegion(locations.getCityRegion(getLocation(self)), 100f, 100f, 100f); if (questLoc != null) { target = questLoc; @@ -244,27 +228,26 @@ public class quests extends script.base_script } public static String getConvoType(obj_id self) throws InterruptedException { - String convoType = "npc_mission/static_businessman_deliver"; + String convoType; String type = "businessman"; - if (checkForSerendipity(self) == false) + if (!checkForSerendipity(self)) { if (!hasObjVar(self, "questType")) { - int questType = rand(1, 4); - switch (questType) + switch (rand(1, 4)) { case 1: - type = "businessman"; - break; + type = "businessman"; + break; case 2: - type = "criminal"; - break; + type = "criminal"; + break; case 3: - type = "noble"; - break; + type = "noble"; + break; case 4: - type = "scientist"; - break; + type = "scientist"; + break; } convoType = "npc_mission/static_" + type + "_deliver"; } @@ -286,27 +269,26 @@ public class quests extends script.base_script } public static String getDataTableName(obj_id self) throws InterruptedException { - String datatable = "datatables/npc/static_quest/businessman_deliveries.iff"; + String datatable; String type = "businessman"; - if (checkForSerendipity(self) == false) + if (!checkForSerendipity(self)) { if (!hasObjVar(self, "questType")) { - int questType = rand(1, 4); - switch (questType) + switch (rand(1, 4)) { case 1: - type = "businessman"; - break; + type = "businessman"; + break; case 2: - type = "criminal"; - break; + type = "criminal"; + break; case 3: - type = "noble"; - break; + type = "noble"; + break; case 4: - type = "scientist"; - break; + type = "scientist"; + break; } datatable = "datatables/npc/static_quest/" + type + "_deliveries.iff"; } @@ -329,25 +311,24 @@ public class quests extends script.base_script public static String getType(obj_id self) throws InterruptedException { String type = "businessman"; - if (checkForSerendipity(self) == false) + if (!checkForSerendipity(self)) { if (!hasObjVar(self, "questType")) { - int questType = rand(1, 4); - switch (questType) + switch (rand(1, 4)) { case 1: - type = "businessman"; - break; + type = "businessman"; + break; case 2: - type = "criminal"; - break; + type = "criminal"; + break; case 3: - type = "noble"; - break; + type = "noble"; + break; case 4: - type = "scientist"; - break; + type = "scientist"; + break; } } else @@ -376,17 +357,11 @@ public class quests extends script.base_script } public static boolean checkForItem(obj_id inv) throws InterruptedException { - String datatable = quests.getDataTableName(getSelf()); - int questNum = getIntObjVar(getSelf(), "quest"); - String giveMe = dataTableGetString(datatable, 0, questNum); + String giveMe = dataTableGetString(quests.getDataTableName(getSelf()), 0, getIntObjVar(getSelf(), "quest")); boolean hadIt = false; - obj_id[] contents = getContents(inv); - for (int i = 0; i < contents.length; i++) - { - String itemInInventory = getTemplateName(contents[i]); - if (itemInInventory.equals(giveMe)) - { - destroyObject(contents[i]); + for (obj_id content : getContents(inv)) { + if (getTemplateName(content).equals(giveMe)) { + destroyObject(content); hadIt = true; } } @@ -395,20 +370,27 @@ public class quests extends script.base_script public static location getThemeParkLocation(obj_id self) throws InterruptedException { location target = null; + + obj_id bldg; + location building; + location questLoc; + region[] rgnFoos; + region[] rgnTest; + region quest; + int x = 0; while (x < 10) { - location here = getLocation(self); - obj_id bldg = getTopMostContainer(self); + bldg = getTopMostContainer(self); if (bldg == null) { return null; } - location building = getLocation(bldg); - region[] rgnFoos = getRegionsWithGeographicalAtPoint(building, regions.GEO_CITY); + building = getLocation(bldg); + rgnFoos = getRegionsWithGeographicalAtPoint(building, regions.GEO_CITY); if (rgnFoos == null) { - region[] rgnTest = getRegionsAtPoint(building); + rgnTest = getRegionsAtPoint(building); if (rgnTest == null) { return null; @@ -418,7 +400,7 @@ public class quests extends script.base_script rgnFoos = rgnTest; } } - region quest = rgnFoos[0]; + quest = rgnFoos[0]; if (quest == null) { quest = locations.getCityRegion(building); @@ -427,30 +409,27 @@ public class quests extends script.base_script return null; } } - location questLoc = locations.getGoodLocationOutsideOfRegion(quest, 64f, 64f, 100f, false, true); + questLoc = locations.getGoodLocationOutsideOfRegion(quest, 64f, 64f, 100f, false, true); if (questLoc != null) { target = questLoc; } - x = x + 1; + x++; } if (target != null) { float xCoord = target.x; float zCoord = target.z; - float newY = getHeightAtLocation(xCoord, zCoord); - target.y = newY; + target.y = getHeightAtLocation(xCoord, zCoord); } return target; } public static void giveThemeParkReward(obj_id self, obj_id player, int questNum) throws InterruptedException { - String datatable = getStringObjVar(self, "quest_table"); - datatable = "datatables/theme_park/" + datatable + ".iff"; + String datatable = "datatables/theme_park/" + getStringObjVar(self, "quest_table") + ".iff"; String questID = dataTableGetString(datatable, questNum, "temp_objvar"); String gatingString = dataTableGetString(datatable, questNum, "overall_objvar"); String playerScript = dataTableGetString(datatable, questNum, "player_script"); - String CONVO = dataTableGetString(datatable, questNum, "convo"); String messageCONVO = "theme_park/messages"; int gating = getIntObjVar(player, gatingString); if (group.isGrouped(player)) @@ -523,7 +502,7 @@ public class quests extends script.base_script setObjVar(rewardObject2, objvar2, value2); } } - if (reward3 != null && !reward3.equals("") && !reward2.equals("none")) + if (reward3 != null && !reward3.equals("") && reward2 != null && !reward2.equals("none")) { obj_id rewardObject3 = createObject(reward3, playerInv, ""); string_id gift3 = new string_id(messageCONVO, "theme_park_reward"); @@ -535,7 +514,7 @@ public class quests extends script.base_script setObjVar(rewardObject3, objvar3, value3); } } - if (reward4 != null && !reward4.equals("") && !reward2.equals("none")) + if (reward4 != null && !reward4.equals("") && reward2 != null && !reward2.equals("none")) { obj_id rewardObject4 = createObject(reward4, playerInv, ""); string_id gift4 = new string_id(messageCONVO, "theme_park_reward"); @@ -604,7 +583,6 @@ public class quests extends script.base_script { detachScript(player, playerScript); } - return; } public static int getQuestId(String questName) throws InterruptedException { @@ -853,21 +831,17 @@ public class quests extends script.base_script } } String[] _result = new String[0]; - if (result != null) - { - _result = new String[result.size()]; - result.toArray(_result); - } + _result = new String[result.size()]; + result.toArray(_result); return _result; } public static String getDataEntry(String questName, String columnName) throws InterruptedException { String result = null; - String datatable = "datatables/player/quests.iff"; int questRow = getQuestId(questName); if (questRow > -1) { - result = dataTableGetString(datatable, questRow, columnName); + result = dataTableGetString("datatables/player/quests.iff", questRow, columnName); } return result; } @@ -942,7 +916,7 @@ public class quests extends script.base_script } if (havePlanet) { - if (tokens[0].indexOf(".iff") < 0) + if (!tokens[0].contains(".iff")) { planet = tokens[0]; } @@ -973,7 +947,7 @@ public class quests extends script.base_script } } } - else if (!havePlanet && haveParameter) + else if (!havePlanet) { int attempts = 0; while (result == null && attempts < 15) @@ -990,7 +964,7 @@ public class quests extends script.base_script } } } - else if (havePlanet && haveParameter) + else if (haveParameter) { String currentScene = getCurrentSceneName(); if (currentScene != null && currentScene.equals(planet)) @@ -1016,8 +990,7 @@ public class quests extends script.base_script waitForPlanetWarp = new location(0.0f, 0.0f, 0.0f, planet); } } - else if (havePlanet && !haveParameter) - { + else { String currentScene = getCurrentSceneName(); if (currentScene != null && currentScene.equals(planet)) { @@ -1171,12 +1144,12 @@ public class quests extends script.base_script LOG("newquests", "location generating a random location about 1 kilometer away " + result); } } - else if (!haveTarget && haveParameter) + else if (!haveTarget) { result = locations.getRandomGoodLocation(getLocation(self), parameter - 100.0f, parameter + 100.0f, 32.0f); LOG("newquests", "location generating a random location between " + (parameter - 100.0f) + " and " + (parameter + 100.0f) + " meters away"); } - else if (planetName != null && !haveX && !haveZ && !haveCell && haveParameter) + else if (planetName != null && !haveX && haveParameter) { String currentScene = getCurrentSceneName(); if (currentScene != null && currentScene.equals(planetName)) @@ -1190,7 +1163,7 @@ public class quests extends script.base_script LOG("newquests", "location generating a random location on " + planetName + " between " + (parameter - 100.0f) + " and " + (parameter + 100.0f) + " meters away"); } } - else if (planetName != null && !haveX && !haveZ && !haveCell && !haveParameter) + else if (planetName != null && !haveX) { String currentScene = getCurrentSceneName(); if (currentScene != null && currentScene.equals(planetName)) @@ -1204,7 +1177,7 @@ public class quests extends script.base_script LOG("newquests", "location a location will be generated when the player travels to " + planetName); } } - else if (planetName != null && haveX && haveZ && !haveCell && !haveParameter) + else if (planetName != null && !haveCell && !haveParameter) { result = new location(); result.x = x; @@ -1212,7 +1185,7 @@ public class quests extends script.base_script result.area = planetName; LOG("newquests", "location generating a location at " + result); } - else if (planetName != null && haveX && haveZ && !haveCell && haveParameter) + else if (planetName != null && !haveCell) { result = new location(); result.x = x; @@ -1221,7 +1194,7 @@ public class quests extends script.base_script radius = parameter; LOG("newquests", "location generating a location at " + result); } - else if (planetName != null && haveX && haveZ && haveCell && !haveParameter) + else if (planetName != null && !haveParameter) { result = new location(); result.x = x; @@ -1230,7 +1203,7 @@ public class quests extends script.base_script result.cell = cell; LOG("newquests", "location generating a location at " + result); } - else if (planetName != null && haveX && haveZ && haveCell && haveParameter) + else if (planetName != null) { result = new location(); result.x = x; @@ -1247,7 +1220,7 @@ public class quests extends script.base_script addLocationTarget(questName, result, radius); LOG("newquests", "location adding location target at " + result); } - else if (waitForPlanetWarp == true) + else if (waitForPlanetWarp) { setObjVar(self, "quest." + questName + ".generate", waitForPlanetWarp); } @@ -1266,9 +1239,8 @@ public class quests extends script.base_script } public static obj_id getTargetForQuest(obj_id self, String questName) throws InterruptedException { - deltadictionary scriptVars = self.getScriptVars(); String objvarname = "encounter.target." + questName; - obj_id result = scriptVars.getObjId(objvarname); + obj_id result = self.getScriptVars().getObjId(objvarname); LOG("newquests", "quest target " + objvarname + "=" + result + " self=" + self); return result; } @@ -1477,10 +1449,6 @@ public class quests extends script.base_script public static boolean safeHasObjVar(obj_id self, String objvarName) throws InterruptedException { obj_var ov = getObjVar(self, objvarName); - if (ov != null && ((ov.getName()).equals(objvarName))) - { - return true; - } - return false; + return ov != null && ((ov.getName()).equals(objvarName)); } } diff --git a/sku.0/sys.server/compiled/game/script/library/regions.java b/sku.0/sys.server/compiled/game/script/library/regions.java old mode 100644 new mode 100755 index 5dd18d189..ba60eb1a4 --- a/sku.0/sys.server/compiled/game/script/library/regions.java +++ b/sku.0/sys.server/compiled/game/script/library/regions.java @@ -1,14 +1,8 @@ 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.library.gcw; +import script.location; +import script.obj_id; +import script.region; public class regions extends script.base_script { @@ -170,129 +164,69 @@ public class regions extends script.base_script } public static int getDeliverMissionRegionType(String strRegionName) throws InterruptedException { - if (strRegionName.equals("anchorhead")) - { - return MISSION_TATOOINE_ANCHORHEAD; - } - else if (strRegionName.equals("bestine")) - { - return MISSION_TATOOINE_BESTINE; - } - else if (strRegionName.equals("mos_eisley")) - { - return MISSION_TATOOINE_MOS_EISLEY; - } - else if (strRegionName.equals("mos_entha")) - { - return MISSION_TATOOINE_MOS_ENTHA; - } - else if (strRegionName.equals("mos_espa")) - { - return MISSION_TATOOINE_MOS_ESPA; - } - else if (strRegionName.equals("mos_taike")) - { - return MISSION_TATOOINE_MOS_TAIKE; - } - else if (strRegionName.equals("wayfar")) - { - return MISSION_TATOOINE_WAYFAR; - } - else if (strRegionName.equals("deeja_peak")) - { - return MISSION_NABOO_DEEJA_PEAK; - } - else if (strRegionName.equals("theed")) - { - return MISSION_NABOO_THEED; - } - else if (strRegionName.equals("keren")) - { - return MISSION_NABOO_KEREN; - } - else if (strRegionName.equals("kaadara")) - { - return MISSION_NABOO_KAADARA; - } - else if (strRegionName.equals("moenia")) - { - return MISSION_NABOO_MOENIA; - } - else if (strRegionName.equals("coronet")) - { - return MISSION_CORELLIA_CORONET; - } - else if (strRegionName.equals("tyrena")) - { - return MISSION_CORELLIA_TYRENA; - } - else if (strRegionName.equals("bela_vistal")) - { - return MISSION_CORELLIA_BELA_VISTAL; - } - else if (strRegionName.equals("vreni_island")) - { - return MISSION_CORELLIA_VRENI_ISLAND; - } - else if (strRegionName.equals("kor_vella")) - { - return MISSION_CORELLIA_KOR_VELLA; - } - else if (strRegionName.equals("daoba_guerfel")) - { - return MISSION_CORELLIA_DAOBA_GUERFEL; - } - else if (strRegionName.equals("doaba_guerfel")) - { - return MISSION_CORELLIA_DAOBA_GUERFEL; - } - else if (strRegionName.equals("narmle")) - { - return MISSION_RORI_NARMLE; - } - else if (strRegionName.equals("restuss")) - { - return MISSION_RORI_RESTUSS; - } - else if (strRegionName.equals("dearic")) - { - return MISSION_TALUS_DEARIC; - } - else if (strRegionName.equals("nashal")) - { - return MISSION_TALUS_NASHAL; - } - else if (strRegionName.equals("yavin4_labor_outpost")) - { - return MISSION_YAVIN4_LABOR_OUTPOST; - } - else if (strRegionName.equals("yavin4_mining_outpost")) - { - return MISSION_YAVIN4_MINING_OUTPOST; - } - else if (strRegionName.equals("endor_neutral_outpost")) - { - return MISSION_ENDOR_NEUTRAL_OUTPOST; - } - else if (strRegionName.equals("dantooine_mining_outpost")) - { - return MISSION_DANTOOINE_MINING_OUTPOST; - } - else if (strRegionName.equals("dantooine_pirate_outpost")) - { - return MISSION_DANTOOINE_PIRATE_OUTPOST; - } - else if (strRegionName.equals("dathomir_trade_outpost")) - { - return MISSION_DATHOMIR_TRADE_OUTPOST; - } - else if (strRegionName.equals("dathomir_survey_outpost")) - { - return MISSION_DATHOMIR_SURVEY_OUTPOST; - } - else if (strRegionName.equals("lok_nyms_stronghold")) - { - return MISSION_LOK_NYMS_STRONGHOLD; + switch (strRegionName) { + case "anchorhead": + return MISSION_TATOOINE_ANCHORHEAD; + case "bestine": + return MISSION_TATOOINE_BESTINE; + case "mos_eisley": + return MISSION_TATOOINE_MOS_EISLEY; + case "mos_entha": + return MISSION_TATOOINE_MOS_ENTHA; + case "mos_espa": + return MISSION_TATOOINE_MOS_ESPA; + case "mos_taike": + return MISSION_TATOOINE_MOS_TAIKE; + case "wayfar": + return MISSION_TATOOINE_WAYFAR; + case "deeja_peak": + return MISSION_NABOO_DEEJA_PEAK; + case "theed": + return MISSION_NABOO_THEED; + case "keren": + return MISSION_NABOO_KEREN; + case "kaadara": + return MISSION_NABOO_KAADARA; + case "moenia": + return MISSION_NABOO_MOENIA; + case "coronet": + return MISSION_CORELLIA_CORONET; + case "tyrena": + return MISSION_CORELLIA_TYRENA; + case "bela_vistal": + return MISSION_CORELLIA_BELA_VISTAL; + case "vreni_island": + return MISSION_CORELLIA_VRENI_ISLAND; + case "kor_vella": + return MISSION_CORELLIA_KOR_VELLA; + case "daoba_guerfel": + return MISSION_CORELLIA_DAOBA_GUERFEL; + case "doaba_guerfel": + return MISSION_CORELLIA_DAOBA_GUERFEL; + case "narmle": + return MISSION_RORI_NARMLE; + case "restuss": + return MISSION_RORI_RESTUSS; + case "dearic": + return MISSION_TALUS_DEARIC; + case "nashal": + return MISSION_TALUS_NASHAL; + case "yavin4_labor_outpost": + return MISSION_YAVIN4_LABOR_OUTPOST; + case "yavin4_mining_outpost": + return MISSION_YAVIN4_MINING_OUTPOST; + case "endor_neutral_outpost": + return MISSION_ENDOR_NEUTRAL_OUTPOST; + case "dantooine_mining_outpost": + return MISSION_DANTOOINE_MINING_OUTPOST; + case "dantooine_pirate_outpost": + return MISSION_DANTOOINE_PIRATE_OUTPOST; + case "dathomir_trade_outpost": + return MISSION_DATHOMIR_TRADE_OUTPOST; + case "dathomir_survey_outpost": + return MISSION_DATHOMIR_SURVEY_OUTPOST; + case "lok_nyms_stronghold": + return MISSION_LOK_NYMS_STRONGHOLD; } return 0; } @@ -369,11 +303,10 @@ public class regions extends script.base_script { return false; } - for (int i = 0; i < regions.length; i++) - { - String regionName = regions[i].getName(); - if (isIdValid(gcw.getPvpRegionControllerIdByName(object, regionName))) - { + String regionName; + for (script.region region : regions) { + regionName = region.getName(); + if (isIdValid(gcw.getPvpRegionControllerIdByName(object, regionName))) { return true; } } diff --git a/sku.0/sys.server/compiled/game/script/library/resource.java b/sku.0/sys.server/compiled/game/script/library/resource.java old mode 100644 new mode 100755 index 13711cecb..3fc509aab --- a/sku.0/sys.server/compiled/game/script/library/resource.java +++ b/sku.0/sys.server/compiled/game/script/library/resource.java @@ -1,16 +1,8 @@ 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.library.buff; -import script.library.city; -import script.library.utils; +import java.util.Vector; public class resource extends script.base_script { @@ -212,7 +204,7 @@ public class resource extends script.base_script { containerTemplate = DEFAULT_CONTAINER; } - int chunks = (int)(amt / CONTAINER_VOLUME_MAX); + int chunks = amt / CONTAINER_VOLUME_MAX; if (amt % CONTAINER_VOLUME_MAX > 0) { chunks++; @@ -222,11 +214,7 @@ public class resource extends script.base_script if (total > 0) { obj_id crate = createObject(containerTemplate, targetContainer, ""); - if ((crate == null) || (crate == obj_id.NULL_ID)) - { - } - else - { + if ((crate != null) && (crate != obj_id.NULL_ID)) { int containerAmount = CONTAINER_VOLUME_MAX; if (total < CONTAINER_VOLUME_MAX) { @@ -242,12 +230,8 @@ public class resource extends script.base_script { return null; } - obj_id[] _ret = new obj_id[0]; - if (ret != null) - { - _ret = new obj_id[ret.size()]; - ret.toArray(_ret); - } + obj_id[] _ret = new obj_id[ret.size()]; + ret.toArray(_ret); return _ret; } public static obj_id[] create(obj_id resourceId, int amt, obj_id targetContainer) throws InterruptedException @@ -277,7 +261,7 @@ public class resource extends script.base_script return null; } obj_id resourceId = null; - if ((loc == null || loc.compareTo(new location()) == 0 || (loc.cell != null && loc.cell != obj_id.NULL_ID)) && isIdValid(targetContainer)) + if ((loc.compareTo(new location()) == 0 || (loc.cell != null && loc.cell != obj_id.NULL_ID)) && isIdValid(targetContainer)) { obj_id topmost = getTopMostContainer(targetContainer); if (topmost != targetContainer) @@ -358,7 +342,6 @@ public class resource extends script.base_script { rangeVal = 1; } - int resVal = getSkillStatMod(user, "surveying") / 20; int range_min = getIntObjVar(tool, VAR_SURVEY_RANGE_MIN); int range_max = getIntObjVar(tool, VAR_SURVEY_RANGE_MAX); int res_min = getIntObjVar(tool, VAR_SURVEY_RESOLUTION_MIN); @@ -415,8 +398,7 @@ public class resource extends script.base_script } if (!isResourceDerivedFrom(typeId, resource_class)) { - prose_package pp = prose.getPackage(SID_WRONG_TOOL, type); - sendSystemMessageProse(user, pp); + sendSystemMessageProse(user, prose.getPackage(SID_WRONG_TOOL, type)); return SAMPLE_STOP_LOOP; } float density = getResourceEfficiency(typeId, getLocation(user)); @@ -426,8 +408,7 @@ public class resource extends script.base_script } else if (density < 0.1f) { - prose_package proseFailed = prose.getPackage(SID_EFFICIENCY_TOO_LOW, type); - sendSystemMessageProse(user, proseFailed); + sendSystemMessageProse(user, prose.getPackage(SID_EFFICIENCY_TOO_LOW, type)); return SAMPLE_STOP_LOOP; } int modVal = getSkillStatMod(user, "surveying"); @@ -438,8 +419,7 @@ public class resource extends script.base_script float famt = BASE_SAMPLE_AMOUNT * deltaDensity; if (famt < 1) { - prose_package proseFailed = prose.getPackage(SID_TRACE_AMOUNT, type); - sendSystemMessageProse(user, proseFailed); + sendSystemMessageProse(user, prose.getPackage(SID_TRACE_AMOUNT, type)); return SAMPLE_STOP_LOOP; } location nodecritloc = null; @@ -528,7 +508,6 @@ public class resource extends script.base_script } else { - int critRoll = rand(1, 100); int rollResult = 10; if (isGod(user)) { @@ -536,7 +515,7 @@ public class resource extends script.base_script } if (roll <= rollResult) { - critRoll = rand(1, 100); + int critRoll = rand(1, 100); if (critRoll <= 50) { sendSystemMessage(user, SID_CRITICAL_SUCCESS); @@ -602,10 +581,10 @@ public class resource extends script.base_script } } } - int expertiseResourceIncrease = (int)getSkillStatisticModifier(user, "expertise_resource_sampling_increase"); + int expertiseResourceIncrease = getSkillStatisticModifier(user, "expertise_resource_sampling_increase"); if (expertiseResourceIncrease > 0) { - amt += (int)(amt * (float)(expertiseResourceIncrease / 100.0f)); + amt += (int)(amt * expertiseResourceIncrease / 100.0f); } if (buff.hasBuff(user, "tcg_series4_falleens_fist")) { @@ -636,29 +615,28 @@ public class resource extends script.base_script merriam.put("resource", typeId); messageTo(user, "forceSensitiveQuestInfo", merriam, 1, false); } - prose_package proseSuccess = prose.getPackage(SID_SAMPLE_LOCATED, type, amt); - sendSystemMessageProse(user, proseSuccess); + sendSystemMessageProse(user, prose.getPackage(SID_SAMPLE_LOCATED, type, amt)); if (isResourceDerivedFrom(typeId, "radioactive")) + { + int pe = resource.getResourceAttribute(typeId, "res_potential_energy"); + if (pe > 500) { - int pe = resource.getResourceAttribute(typeId, "res_potential_energy"); - if (pe > 500) + int damage = (pe - 500) / 2; + if (damage < 1) { - int damage = (pe - 500) / 2; - if (damage < 1) - { - damage = 1; - } - int current = getAttrib(user, HEALTH); - if (damage > current) - { - damage = (current - 1); - } - addAttribModifier(user, HEALTH, (damage * -1), 0, 0, MOD_POOL); - int fatigue = damage / 4; - addShockWound(user, fatigue); - sendSystemMessage(user, SID_EFFECTS_OF_RADIATION_SICKNESS); + damage = 1; } + int current = getAttrib(user, HEALTH); + if (damage > current) + { + damage = (current - 1); + } + addAttribModifier(user, HEALTH, (damage * -1), 0, 0, MOD_POOL); + int fatigue = damage / 4; + addShockWound(user, fatigue); + sendSystemMessage(user, SID_EFFECTS_OF_RADIATION_SICKNESS); } + } return SAMPLE_CONTINUE_LOOP; } else @@ -674,13 +652,11 @@ public class resource extends script.base_script } else { - prose_package proseFailed = prose.getPackage(SID_DENSITY_BELOW_THESHOLD, type); - sendSystemMessageProse(user, proseFailed); + sendSystemMessageProse(user, prose.getPackage(SID_DENSITY_BELOW_THESHOLD, type)); return SAMPLE_STOP_LOOP; } setObjVar(user, VAR_SAMPLE_STAMP, getGameTime() - TIME_FAIL_BONUS); - prose_package proseFailed = prose.getPackage(SID_SAMPLE_FAILED, type); - sendSystemMessageProse(user, proseFailed); + sendSystemMessageProse(user, prose.getPackage(SID_SAMPLE_FAILED, type)); return SAMPLE_CONTINUE_LOOP_NOSAMPLE; } public static String getResourceContainerTemplate(obj_id typeId) throws InterruptedException @@ -704,38 +680,48 @@ public class resource extends script.base_script } Vector dsrc = new Vector(); dsrc.setSize(0); - String resource_class = getStringObjVar(tool, resource.VAR_SURVEY_CLASS); + dsrc = utils.addElement(dsrc, utils.packStringId(SID_SUI_SURVEY_TOOL_PROPERTIES_RESOURCE_HEADER)); + prose_package ppResource = prose.getPackage(SID_SUI_SURVEY_TOOL_PROPERTIES_RESOURCE); - prose.setTO(ppResource, resource_class); + prose.setTO(ppResource, getStringObjVar(tool, resource.VAR_SURVEY_CLASS)); dsrc = utils.addElement(dsrc, " \0" + packOutOfBandProsePackage(null, ppResource)); dsrc = utils.addElement(dsrc, " "); + int res_min = getIntObjVar(tool, resource.VAR_SURVEY_RESOLUTION_MIN); int res_max = getIntObjVar(tool, resource.VAR_SURVEY_RESOLUTION_MAX); int res_val = getIntObjVar(tool, resource.VAR_SURVEY_RESOLUTION_VALUE); dsrc = utils.addElement(dsrc, utils.packStringId(SID_SUI_SURVEY_TOOL_PROPERTIES_RESOLUTION)); + prose_package ppResMin = prose.getPackage(SID_SUI_SURVEY_TOOL_PROPERTIES_RESOLUTION_MIN); prose.setDI(ppResMin, res_min); dsrc = utils.addElement(dsrc, " \0" + packOutOfBandProsePackage(null, ppResMin)); + prose_package ppResMax = prose.getPackage(SID_SUI_SURVEY_TOOL_PROPERTIES_RESOLUTION_MAX); prose.setDI(ppResMax, res_max); dsrc = utils.addElement(dsrc, " \0" + packOutOfBandProsePackage(null, ppResMax)); + prose_package ppResVal = prose.getPackage(SID_SUI_SURVEY_TOOL_PROPERTIES_RESOLUTION_VAL); prose.setDI(ppResVal, res_val); dsrc = utils.addElement(dsrc, " \0" + packOutOfBandProsePackage(null, ppResVal)); dsrc = utils.addElement(dsrc, " "); + int range_min = getIntObjVar(tool, resource.VAR_SURVEY_RANGE_MIN); int range_max = getIntObjVar(tool, resource.VAR_SURVEY_RANGE_MAX); int range_val = getIntObjVar(tool, resource.VAR_SURVEY_RANGE_VALUE); + dsrc = utils.addElement(dsrc, utils.packStringId(SID_SUI_SURVEY_TOOL_PROPERTIES_RANGE)); prose_package ppRangeMin = prose.getPackage(SID_SUI_SURVEY_TOOL_PROPERTIES_RANGE_MIN); prose.setDI(ppRangeMin, range_min); + dsrc = utils.addElement(dsrc, " \0" + packOutOfBandProsePackage(null, ppRangeMin)); prose_package ppRangeMax = prose.getPackage(SID_SUI_SURVEY_TOOL_PROPERTIES_RANGE_MAX); prose.setDI(ppRangeMax, range_max); + dsrc = utils.addElement(dsrc, " \0" + packOutOfBandProsePackage(null, ppRangeMax)); prose_package ppRangeVal = prose.getPackage(SID_SUI_SURVEY_TOOL_PROPERTIES_RANGE_VAL); prose.setDI(ppRangeVal, range_val); + dsrc = utils.addElement(dsrc, " \0" + packOutOfBandProsePackage(null, ppRangeVal)); if ((dsrc != null) && (dsrc.size() > 0)) { @@ -953,12 +939,12 @@ public class resource extends script.base_script { return ""; } - dictionary row = dataTableGetRow(DATATABLE_RESOURCES, rowNum); int i = 0; String res = null; - while ((res == null) || (res.equals(""))) + int numRows = dataTableGetNumRows(DATATABLE_RESOURCES); + while ((res == null) || (res.equals("")) || i > numRows) { - res = row.getString("CLASS " + i++); + res = dataTableGetRow(DATATABLE_RESOURCES, rowNum).getString("CLASS " + i++); } return res; } @@ -972,16 +958,13 @@ public class resource extends script.base_script obj_id[] items = getInventoryAndEquipment(target); if ((items != null) && (items.length > 0)) { - for (int i = 0; i < items.length; i++) - { - if (isGameObjectTypeOf(getGameObjectType(items[i]), GOT_resource_container)) - { - obj_id rId = getResourceContainerResourceType(items[i]); - if (isIdValid(rId)) - { - if (isResourceDerivedFrom(rId, "energy") || isResourceDerivedFrom(rId, "radioactive")) - { - cnt += getPotentialEnergyValue(items[i]); + obj_id rId; + for (obj_id item : items) { + if (isGameObjectTypeOf(getGameObjectType(item), GOT_resource_container)) { + rId = getResourceContainerResourceType(item); + if (isIdValid(rId)) { + if (isResourceDerivedFrom(rId, "energy") || isResourceDerivedFrom(rId, "radioactive")) { + cnt += getPotentialEnergyValue(item); } } } @@ -1005,8 +988,7 @@ public class resource extends script.base_script { return 0; } - float ratio = getEnergyPowerRatio(rType); - return Math.round(ratio * amt); + return Math.round(getEnergyPowerRatio(rType) * amt); } public static float getEnergyPowerRatio(obj_id rType) throws InterruptedException { @@ -1047,24 +1029,19 @@ public class resource extends script.base_script dictionary resourceInfo = new dictionary(); if ((items != null) && (items.length > 0)) { - for (int i = 0; i < items.length; i++) - { - if (isGameObjectTypeOf(getGameObjectType(items[i]), GOT_resource_container)) - { - obj_id resourceType = getResourceContainerResourceType(items[i]); - if (isIdValid(resourceType)) - { - if (isResourceDerivedFrom(resourceType, "energy_renewable_site_limited_geothermal")) - { - if (tempListUniqueList.size() == 0) - { + obj_id resourceType; + for (obj_id item : items) { + if (isGameObjectTypeOf(getGameObjectType(item), GOT_resource_container)) { + resourceType = getResourceContainerResourceType(item); + if (isIdValid(resourceType)) { + if (isResourceDerivedFrom(resourceType, "energy_renewable_site_limited_geothermal")) { + if (tempListUniqueList.size() == 0) { tempListUniqueList.addElement(resourceType); resourceName = getResourceName(resourceType); resourceQuality = getResourceAttribute(resourceType, "res_quality"); } - if (tempListUniqueList.contains(resourceType)) - { - cnt += getResourceContainerQuantity(items[i]); + if (tempListUniqueList.contains(resourceType)) { + cnt += getResourceContainerQuantity(item); } } } @@ -1099,29 +1076,25 @@ public class resource extends script.base_script { return false; } - for (int i = 0, j = contents.length; i < j; i++) - { - if (!isIdValid(contents[i]) || !exists(contents[i])) - { + obj_id container; + String parent; + + for (obj_id content : contents) { + if (!isIdValid(content) || !exists(content)) { continue; } - if (!isResourceContainer(contents[i])) - { + if (!isResourceContainer(content)) { continue; } - obj_id container = getResourceContainerResourceType(contents[i]); - if (!isIdValid(container)) - { + container = getResourceContainerResourceType(content); + if (!isIdValid(container)) { continue; } - String name = getResourceClass(container); - String typeName = getResourceName(container); - String parent = getResourceParentClass(name); + parent = getResourceParentClass(getResourceClass(container)); parent = getResourceParentClass(parent); parent = getResourceParentClass(parent); - if (resource.equals(parent) && getResourceContainerQuantity(contents[i]) >= quantity) - { - removeResourceFromContainer(contents[i], getResourceContainerResourceType(contents[i]), quantity); + if (resource.equals(parent) && getResourceContainerQuantity(content) >= quantity) { + removeResourceFromContainer(content, getResourceContainerResourceType(content), quantity); return true; } } @@ -1134,28 +1107,23 @@ public class resource extends script.base_script { return false; } - for (int i = 0, j = contents.length; i < j; i++) - { - if (!isIdValid(contents[i]) || !exists(contents[i])) - { + obj_id container; + String parent; + for (obj_id content : contents) { + if (!isIdValid(content) || !exists(content)) { continue; } - if (!isResourceContainer(contents[i])) - { + if (!isResourceContainer(content)) { continue; } - obj_id container = getResourceContainerResourceType(contents[i]); - if (!isIdValid(container)) - { + container = getResourceContainerResourceType(content); + if (!isIdValid(container)) { continue; } - String name = getResourceClass(container); - String typeName = getResourceName(container); - String parent = getResourceParentClass(name); + parent = getResourceParentClass(getResourceClass(container)); parent = getResourceParentClass(parent); parent = getResourceParentClass(parent); - if (resource.equals(parent) && getResourceContainerQuantity(contents[i]) >= quantity) - { + if (resource.equals(parent) && getResourceContainerQuantity(content) >= quantity) { return true; } } diff --git a/sku.0/sys.server/compiled/game/script/library/respec.java b/sku.0/sys.server/compiled/game/script/library/respec.java old mode 100644 new mode 100755 index ff80e2f03..28b7a9f2d --- a/sku.0/sys.server/compiled/game/script/library/respec.java +++ b/sku.0/sys.server/compiled/game/script/library/respec.java @@ -1,20 +1,8 @@ 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.library.bounty_hunter; -import script.library.buff; -import script.library.performance; -import script.library.pet_lib; -import script.library.static_item; -import script.library.trace; -import script.library.xp; +import java.util.Enumeration; public class respec extends script.base_script { @@ -114,7 +102,6 @@ public class respec extends script.base_script { attachScript(player, "systems.respec.click_combat_respec"); } - return; } public static void handleNpcRespec(obj_id player, String skillTemplateName) throws InterruptedException { @@ -140,11 +127,10 @@ public class respec extends script.base_script String msg = "NPC_RESPEC: %TU has initiated a respec via NPC for " + cost + " credits. Current combat level is " + getLevel(player) + "; current skill template is " + oldTemplate; trace.log("respec", msg, player, trace.TL_CS_LOG); pet_lib.destroyOfficerPets(player); - obj_id inv = utils.getInventoryContainer(player); obj_id weapon = getCurrentWeapon(player); if (isIdValid(weapon)) { - putInOverloaded(weapon, inv); + putInOverloaded(weapon, utils.getInventoryContainer(player)); } if (cost > 0) { @@ -180,13 +166,6 @@ public class respec extends script.base_script { targetLevel = getTraderLevel(player); } - obj_id respecHandler = getObjIdObjVar(player, "npcRespec.tokenId"); - if (!isMob(respecHandler)) - { - int count = getCount(respecHandler); - int newCount = count - 1; - boolean adjustedCount = newCount > 0 ? setCount(respecHandler, newCount) : destroyObject(respecHandler); - } earnProfessionSkillsViaNpc(player, skillTemplateName, true, targetLevel); int numBought = 0; if (hasObjVar(player, "respecsBought")) @@ -212,7 +191,6 @@ public class respec extends script.base_script { messageTo(player, "removeSmugglingBonuses", null, 1.0f, false); } - return; } public static void earnProfessionSkillsViaNpc(obj_id player, String skillTemplateName, boolean withItems, int level) throws InterruptedException { @@ -220,11 +198,10 @@ public class respec extends script.base_script callable.storeCallables(player); revokeAllSkillsAndExperience(player); buff.removeAllBuffs(player, true, true); - obj_id inv = utils.getInventoryContainer(player); obj_id weapon = getCurrentWeapon(player); if (isIdValid(weapon)) { - putInOverloaded(weapon, inv); + putInOverloaded(weapon, utils.getInventoryContainer(player)); } if (level > 0) { @@ -326,13 +303,11 @@ public class respec extends script.base_script { if (!hasObjVar(player, PROF_LEVEL_ARRAY)) { - int[] newArray = - { + return new int[]{ -1, -1, -1 }; - return newArray; } return getIntArrayObjVar(player, PROF_LEVEL_ARRAY); } @@ -417,7 +392,6 @@ public class respec extends script.base_script { messageTo(player, "removeSmugglingBonuses", null, 1.0f, false); } - return; } public static int getReallocationCost(obj_id player) throws InterruptedException { @@ -430,12 +404,7 @@ public class respec extends script.base_script } public static boolean hasFreeReallocation(obj_id player) throws InterruptedException { - int numFreeRemain = numFreeAllocations(player); - if (0 > numFreeRemain) - { - return false; - } - return true; + return 0 <= numFreeAllocations(player); } public static int numFreeAllocations(obj_id player) throws InterruptedException { @@ -456,19 +425,20 @@ public class respec extends script.base_script int level = 0; if ((skillList != null) && (skillList.length != 0)) { - for (int i = 0; i < skillList.length; i++) - { - dictionary xpReqs = getSkillPrerequisiteExperience(skillList[i]); - if ((xpReqs == null) || (xpReqs.isEmpty())) - { + dictionary xpReqs; + Enumeration e; + String xpType; + + for (String aSkillList : skillList) { + xpReqs = getSkillPrerequisiteExperience(aSkillList); + if ((xpReqs == null) || (xpReqs.isEmpty())) { continue; } - java.util.Enumeration e = xpReqs.keys(); - String xpType = (String)(e.nextElement()); + e = xpReqs.keys(); + xpType = (String) (e.nextElement()); int xpCost = xpReqs.getInt(xpType); int idx = utils.getElementPositionInArray(xpTypes, xpType); - if (idx > -1) - { + if (idx > -1) { totalXp += (xpCost * xpMults[idx]); } } @@ -476,14 +446,10 @@ public class respec extends script.base_script int[] levelList = dataTableGetIntColumn("datatables/player/old_player_level.iff", "xp_required"); if ((levelList != null) && (levelList.length != 0)) { - for (int i = 0; i < levelList.length; i++) - { - if (levelList[i] <= totalXp) - { + for (int xpAmountForLevel : levelList) { + if (xpAmountForLevel <= totalXp) { level++; - } - else - { + } else { break; } } @@ -499,16 +465,16 @@ public class respec extends script.base_script { CustomerServiceLog("click_respec", "Player %TU :: *** Skill List ***", player); String[] skillList = getSkillListingForPlayer(player); - for (int i = 0; i < skillList.length; i++) - { - CustomerServiceLog("click_respec", "Player %TU :: " + skillList[i], player); + for (String aSkillList : skillList) { + CustomerServiceLog("click_respec", "Player %TU :: " + aSkillList, player); } CustomerServiceLog("click_respec", "Player %TU :: *** Experience List ***", player); dictionary xpList = getExperiencePoints(player); java.util.Enumeration e = xpList.keys(); + String xpType; while (e.hasMoreElements()) { - String xpType = (String)(e.nextElement()); + xpType = (String) (e.nextElement()); int xpCost = xpList.getInt(xpType); CustomerServiceLog("click_respec", "Player %TU :: " + xpType + " = " + xpCost, player); } @@ -536,24 +502,18 @@ public class respec extends script.base_script if (newXpAmount > oldXpAmount) { setWorkingSkill(player, skillList[0]); - for (int i = 0; i < skillList.length; i++) - { - int skillCost = getSkillXpCost(player, skillList[i]); - if (skillCost <= newXpAmount) - { + for (String aSkillList : skillList) { + int skillCost = getSkillXpCost(player, aSkillList); + if (skillCost <= newXpAmount) { newXpAmount -= skillCost; - if (!hasSkill(player, skillList[i])) - { - grantSkill(player, skillList[i]); - if (withItems) - { + if (!hasSkill(player, aSkillList)) { + grantSkill(player, aSkillList); + if (withItems) { skill_template.grantRoadmapItem(player); } } setWorkingSkill(player, skill_template.getNextWorkingSkill(player)); - } - else - { + } else { break; } } @@ -601,8 +561,7 @@ public class respec extends script.base_script } java.util.Enumeration e = xpReqs.keys(); String xpType = (String)(e.nextElement()); - int xpCost = xpReqs.getInt(xpType); - return xpCost; + return xpReqs.getInt(xpType); } public static int getCurrentXpTotal(obj_id player) throws InterruptedException { @@ -623,12 +582,9 @@ public class respec extends script.base_script { xp_type = "crafting"; } - String workingSkill = skillList[skillList.length - 1]; - for (int i = 0; i < skillList.length; i++) - { - if (hasSkill(player, skillList[i])) - { - totalXp += getSkillXpCost(player, skillList[i]); + for (String aSkillList : skillList) { + if (hasSkill(player, aSkillList)) { + totalXp += getSkillXpCost(player, aSkillList); } } totalXp += getExperiencePoints(player, xp_type); @@ -733,15 +689,12 @@ public class respec extends script.base_script String templateSkills = dataTableGetString(skill_template.TEMPLATE_TABLE, skillTemplateName, "template"); String[] skillList = split(templateSkills, ','); setWorkingSkill(player, skillList[0]); - for (int i = 0; i < skillList.length; i++) - { - if (workingSkill != null && skillList[i].equals(workingSkill)) - { + for (String aSkillList : skillList) { + if (workingSkill != null && aSkillList.equals(workingSkill)) { break; } - grantSkill(player, skillList[i]); - if (withItems) - { + grantSkill(player, aSkillList); + if (withItems) { skill_template.grantRoadmapItem(player); } setWorkingSkill(player, skill_template.getNextWorkingSkill(player)); @@ -803,22 +756,18 @@ public class respec extends script.base_script "entertainer", "crafting" }; - for (int i = 0; i < xpTypes.length; i++) - { - curXp = getExperiencePoints(player, xpTypes[i]); - grantExperiencePoints(player, xpTypes[i], -curXp); + for (String xpType : xpTypes) { + curXp = getExperiencePoints(player, xpType); + grantExperiencePoints(player, xpType, -curXp); } String[] skillList = getSkillListingForPlayer(player); int attempts = skillList.length; - if ((skillList != null) && (skillList.length != 0)) + if ((skillList.length != 0)) { while (skillList.length > 0 && attempts > 0) { - for (int i = 0; i < skillList.length; i++) - { - String skillName = skillList[i]; - if (!skillName.startsWith("costume") && !skillName.startsWith("class_chronicles") && !skillName.startsWith("species_") && !skillName.startsWith("social_language_") && !skillName.startsWith("social_politician_") && !skillName.startsWith("pilot_") && !skillName.startsWith("swg_") && !skillName.startsWith("utility_") && !skillName.startsWith("common_") && !skillName.startsWith("pvp_") && !skillName.startsWith("internal_expertise_") && !skillName.equals("expertise")) - { + for (String skillName : skillList) { + if (!skillName.startsWith("costume") && !skillName.startsWith("class_chronicles") && !skillName.startsWith("species_") && !skillName.startsWith("social_language_") && !skillName.startsWith("social_politician_") && !skillName.startsWith("pilot_") && !skillName.startsWith("swg_") && !skillName.startsWith("utility_") && !skillName.startsWith("common_") && !skillName.startsWith("pvp_") && !skillName.startsWith("internal_expertise_") && !skillName.equals("expertise")) { skill.revokeSkillSilent(player, skillName); } } @@ -835,16 +784,18 @@ public class respec extends script.base_script public static void contentPathHandoff(obj_id self) throws InterruptedException { location origin = getLocation(self); - location fighting = new location(3521f, 0.0f, -4821f, origin.area); location crafty = new location(3309.0f, 6.0f, -4785.0f, origin.area); String profession = getSkillTemplate(self); obj_id objInv = utils.getInventoryContainer(self); + String questNewbieStart = "quest/speeder_quest"; String questNewbieStartBH = "quest/speeder_quest"; String questCrafterEntertainer = "quest/tatooine_eisley_noncombat"; + int crafter = profession.indexOf("trader"); int entertainer = profession.indexOf("entertainer"); int bountyhunter = profession.indexOf("bounty_hunter"); + if (crafter > -1 || entertainer > -1) { if (!groundquests.isQuestActiveOrComplete(self, questCrafterEntertainer)) @@ -888,7 +839,7 @@ public class respec extends script.base_script { return 0.0f; } - float oldSkillPct = 0.0f; + float oldSkillPct; if (template.startsWith("trader") || template.startsWith("entertainer")) { String oldSkills = dataTableGetString(skill_template.TEMPLATE_TABLE, template, "template"); @@ -898,10 +849,8 @@ public class respec extends script.base_script return 0.0f; } int oldSkillCount = 0; - for (int i = 0; i < oldSkillList.length; i++) - { - if (hasSkill(self, oldSkillList[i])) - { + for (String anOldSkillList : oldSkillList) { + if (hasSkill(self, anOldSkillList)) { oldSkillCount++; } } @@ -1088,8 +1037,7 @@ public class respec extends script.base_script { return 0; } - int version = dataTableGetInt(EXPERTISE_VERSION_TABLE, row, "version"); - return version; + return dataTableGetInt(EXPERTISE_VERSION_TABLE, row, "version"); } public static boolean checkRespecDecay(obj_id player) throws InterruptedException { @@ -1160,15 +1108,8 @@ public class respec extends script.base_script { return false; } - int timeTillNextDecayOnPlayer = 0; - if (hasObjVar(player, OBJVAR_RESPEC_DECAY_TIME)) - { - timeTillNextDecayOnPlayer = getIntObjVar(player, OBJVAR_RESPEC_DECAY_TIME); - } - int timeTillNextDecay = 0; - int now = getCalendarTime(); - int secondsUntil = secondsUntilNextMonthlyTime(1, 10, 0, 0); - timeTillNextDecay = now + secondsUntil; + + int timeTillNextDecay = getCalendarTime() + secondsUntilNextMonthlyTime(1, 10, 0, 0); setObjVar(player, OBJVAR_RESPEC_DECAY_TIME, timeTillNextDecay); return true; } diff --git a/sku.0/sys.server/compiled/game/script/library/reverse_engineering.java b/sku.0/sys.server/compiled/game/script/library/reverse_engineering.java old mode 100644 new mode 100755 index 8c9a55dc5..6c023da55 --- a/sku.0/sys.server/compiled/game/script/library/reverse_engineering.java +++ b/sku.0/sys.server/compiled/game/script/library/reverse_engineering.java @@ -56,11 +56,10 @@ public class reverse_engineering extends script.base_script if (isIdValid(player)) { String[] possiblePowerUps = POWERUP_SLOTS; - for (int i = 0; i < possiblePowerUps.length; i++) - { - obj_id thingInPlayersSlot = getObjectInSlot(player, possiblePowerUps[i]); - if (isPoweredUpItem(thingInPlayersSlot)) - { + obj_id thingInPlayersSlot; + for (String possiblePowerUp : possiblePowerUps) { + thingInPlayersSlot = getObjectInSlot(player, possiblePowerUp); + if (isPoweredUpItem(thingInPlayersSlot)) { applyPowerupItemEquipped(player, thingInPlayersSlot); } } @@ -91,7 +90,6 @@ public class reverse_engineering extends script.base_script { sendSystemMessage(player, new string_id("spam", "powerup_must_equip_item")); } - return; } public static void applyPowerupItemEquipped(obj_id player, obj_id itemWithPowerUp) throws InterruptedException { @@ -115,10 +113,9 @@ public class reverse_engineering extends script.base_script { finalPower = 1; } - addSkillModModifier(player, slotName + "_powerup", mod, (int)finalPower, -1, false, false); + addSkillModModifier(player, slotName + "_powerup", mod, finalPower, -1, false, false); applyBuffIcon(player, itemWithPowerUp); recalcPoolsIfNeeded(player, mod); - return; } public static boolean isPoweredUpItem(obj_id item) throws InterruptedException { @@ -127,9 +124,10 @@ public class reverse_engineering extends script.base_script public static int getPowerupType(obj_id item) throws InterruptedException { int powerupType = -1; + String staticName; for (int i = 0; i < POWERUP_ITEMS.length; i++) { - String staticName = getStaticItemName(item); + staticName = getStaticItemName(item); if (staticName.equals(POWERUP_ITEMS[i])) { powerupType = i; @@ -139,11 +137,8 @@ public class reverse_engineering extends script.base_script } public static float getDieTime(float lifeSpan, obj_id tempObject) throws InterruptedException { - float timeStamp = getFloatObjVar(tempObject, ENGINEERING_TIMESTAMP); - float deathStamp = timeStamp + reverse_engineering.EXPIRATION_TIME; - float rightNow = getGameTime(); - float dieTime = deathStamp - rightNow; - return dieTime; + float deathStamp = getFloatObjVar(tempObject, ENGINEERING_TIMESTAMP) + reverse_engineering.EXPIRATION_TIME; + return deathStamp - getGameTime(); } public static String getMyEquippedSlot(obj_id itemWithPowerUp) throws InterruptedException { @@ -152,12 +147,11 @@ public class reverse_engineering extends script.base_script if (isIdValid(containingMe)) { String[] possibleSlots = POWERUP_SLOTS; - for (int i = 0; i < possibleSlots.length; i++) - { - obj_id thingInPlayersSlot = getObjectInSlot(containingMe, possibleSlots[i]); - if (thingInPlayersSlot == itemWithPowerUp) - { - return possibleSlots[i]; + obj_id thingInPlayersSlot; + for (String possibleSlot : possibleSlots) { + thingInPlayersSlot = getObjectInSlot(containingMe, possibleSlot); + if (thingInPlayersSlot == itemWithPowerUp) { + return possibleSlot; } } } @@ -166,40 +160,34 @@ public class reverse_engineering extends script.base_script public static String getMyBuffIconInt(obj_id powerUp) throws InterruptedException { int powerupType = getPowerupType(powerUp); - String buffName = ""; + String buffName; switch (powerupType) { case 0: - buffName = POWERUP_CHEST; - break; + buffName = POWERUP_CHEST; + break; case 1: - buffName = POWERUP_SHIRT; - break; + buffName = POWERUP_SHIRT; + break; case 2: - buffName = POWERUP_WEAPON; - break; + buffName = POWERUP_WEAPON; + break; default: - return null; + return null; } return buffName; } public static String getMyBuffIconString(obj_id itemWithPowerUp) throws InterruptedException { - String buffName = ""; - String slotName = getMyEquippedSlot(itemWithPowerUp); - if (slotName.equals("chest2")) - { - buffName = POWERUP_CHEST; + switch(getMyEquippedSlot(itemWithPowerUp)){ + case "chest2": + return POWERUP_CHEST; + case "chest1": + return POWERUP_SHIRT; + case "hold_r": + default: + return POWERUP_WEAPON; } - if (slotName.equals("chest1")) - { - buffName = POWERUP_SHIRT; - } - if (slotName.equals("hold_r")) - { - buffName = POWERUP_WEAPON; - } - return buffName; } public static void applyBuffIcon(obj_id player, obj_id itemWithPowerUp) throws InterruptedException { @@ -207,8 +195,8 @@ public class reverse_engineering extends script.base_script } public static void applyBuffIcon(obj_id player, obj_id powerUp, obj_id itemWithPowerUp) throws InterruptedException { - String buffName = ""; - float expiration = 0f; + String buffName; + float expiration; if (!isIdValid(powerUp)) { buffName = getMyBuffIconString(itemWithPowerUp); @@ -226,7 +214,6 @@ public class reverse_engineering extends script.base_script { buff.applyBuff(player, buffName, expiration); } - return; } public static void removeBuffIcon(obj_id player, obj_id itemWithPowerUp) throws InterruptedException { @@ -235,7 +222,6 @@ public class reverse_engineering extends script.base_script { buff.removeBuff(player, buffName); } - return; } public static void recalcPoolsIfNeeded(obj_id player, String mod) throws InterruptedException { @@ -246,7 +232,6 @@ public class reverse_engineering extends script.base_script combat.cacheCombatData(player); trial.bumpSession(player, "displayDefensiveMods"); messageTo(player, "setDisplayOnlyDefensiveMods", trial.getSessionDict(player, "displayDefensiveMods"), 5, false); - return; } public static void addModsAndScript(obj_id player, obj_id powerUp, obj_id itemToPowerUp) throws InterruptedException { @@ -254,17 +239,14 @@ public class reverse_engineering extends script.base_script } public static void addModsAndScript(obj_id player, obj_id powerUp, obj_id itemToPowerUp, float remainingTime) throws InterruptedException { - String mod = getStringObjVar(powerUp, ENGINEERING_MODIFIER); - int ratio = getIntObjVar(powerUp, ENGINEERING_RATIO); - int power = getIntObjVar(powerUp, ENGINEERING_POWER); float timeStamp = getGameTime(); if (remainingTime > 0f) { timeStamp = remainingTime; } - setObjVar(itemToPowerUp, ENGINEERING_MODIFIER, mod); - setObjVar(itemToPowerUp, ENGINEERING_RATIO, ratio); - setObjVar(itemToPowerUp, ENGINEERING_POWER, power); + setObjVar(itemToPowerUp, ENGINEERING_MODIFIER, getStringObjVar(powerUp, ENGINEERING_MODIFIER)); + setObjVar(itemToPowerUp, ENGINEERING_RATIO, getIntObjVar(powerUp, ENGINEERING_RATIO)); + setObjVar(itemToPowerUp, ENGINEERING_POWER, getIntObjVar(powerUp, ENGINEERING_POWER)); setObjVar(itemToPowerUp, ENGINEERING_TIMESTAMP, timeStamp); if (!isPoweredUpItem(itemToPowerUp)) { @@ -287,15 +269,11 @@ public class reverse_engineering extends script.base_script } trial.bumpSession(itemWithPowerUp, "displayDefensiveMods"); messageTo(itemWithPowerUp, "setDisplayOnlyDefensiveMods", trial.getSessionDict(itemWithPowerUp, "displayDefensiveMods"), 5, false); - return; } public static void removePlayerPowerUpMods(obj_id player, obj_id itemWithPowerUp) throws InterruptedException { - String slotName = getMyEquippedSlot(itemWithPowerUp); - String mod = getStringObjVar(itemWithPowerUp, ENGINEERING_MODIFIER); - removeAttribOrSkillModModifier(player, slotName + "_powerup"); - recalcPoolsIfNeeded(player, mod); - return; + removeAttribOrSkillModModifier(player, getMyEquippedSlot(itemWithPowerUp) + "_powerup"); + recalcPoolsIfNeeded(player, getStringObjVar(itemWithPowerUp, ENGINEERING_MODIFIER)); } public static void powerUpAttached(obj_id player, obj_id itemWithPowerUp) throws InterruptedException { @@ -311,25 +289,18 @@ public class reverse_engineering extends script.base_script { return; } - int power = getIntObjVar(itemWithPowerUp, ENGINEERING_POWER); String mod = getStringObjVar(itemWithPowerUp, ENGINEERING_MODIFIER); - int ratio = getIntObjVar(itemWithPowerUp, ENGINEERING_RATIO); - int finalPower = power / ratio; + int finalPower = getIntObjVar(itemWithPowerUp, ENGINEERING_POWER) / getIntObjVar(itemWithPowerUp, ENGINEERING_RATIO); if (finalPower < 1) { finalPower = 1; } - addSkillModModifier(player, slotName + "_powerup", mod, (int)finalPower, -1, false, false); + addSkillModModifier(player, slotName + "_powerup", mod, finalPower, -1, false, false); recalcPoolsIfNeeded(player, mod); - return; } public static boolean canMakePowerUp(String mod) throws InterruptedException { - if (dataTableGetInt(SPECIAL_MOD_TABLE, mod, "no_pup") > 0) - { - return false; - } - return true; + return dataTableGetInt(SPECIAL_MOD_TABLE, mod, "no_pup") <= 0; } public static boolean canStaticItemBeReversedEngineered(obj_id item) throws InterruptedException { diff --git a/sku.0/sys.server/compiled/game/script/library/scenario.java b/sku.0/sys.server/compiled/game/script/library/scenario.java old mode 100644 new mode 100755 index 6bf9f638e..265ccd645 --- a/sku.0/sys.server/compiled/game/script/library/scenario.java +++ b/sku.0/sys.server/compiled/game/script/library/scenario.java @@ -1,21 +1,8 @@ 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.library.factions; -import script.library.poi; -import script.library.utils; -import script.library.chat; -import script.library.group; -import script.library.combat; -import script.library.ai_lib; -import script.ai.ai_combat; +import java.util.Vector; public class scenario extends script.base_script { @@ -107,16 +94,13 @@ public class scenario extends script.base_script { return false; } - int idx = params.getInt(DICT_IDX); - String scenario_name = params.getString(COL_NAME); - String convo = params.getString(COL_CONVO); if (hasObjVar(master, VAR_SCENARIO_BASE)) { removeObjVar(master, VAR_SCENARIO_BASE); } - setObjVar(master, VAR_SCENARIO_IDX, idx); - setObjVar(master, VAR_SCENARIO_NAME, scenario_name); - setObjVar(master, VAR_SCENARIO_CONVO, convo); + setObjVar(master, VAR_SCENARIO_IDX, params.getInt(DICT_IDX)); + setObjVar(master, VAR_SCENARIO_NAME, params.getString(COL_NAME)); + setObjVar(master, VAR_SCENARIO_CONVO, params.getString(COL_CONVO)); return messageTo(master, HANDLER_INIT_SCENARIO, params, 2, true); } public static boolean createTeam(obj_id master, String team_name, String team_faction) throws InterruptedException @@ -158,11 +142,10 @@ public class scenario extends script.base_script Vector team_members = getResizeableObjIdArrayObjVar(master, member_path); if (team_members != null && team_members.size() > 0) { - for (int i = 0; i < team_members.size(); i++) - { - obj_id target = ((obj_id)team_members.get(i)); - if (isIdValid(target)) - { + obj_id target; + for (Object team_member : team_members) { + target = ((obj_id) team_member); + if (isIdValid(target)) { factions.setFaction(target, team_faction); } } @@ -179,8 +162,6 @@ public class scenario extends script.base_script { return null; } - String team_path = VAR_TEAM + "." + team_name; - String fac_path = team_path + ".faction"; return getStringObjVar(master, VAR_TEAM + "." + team_name + ".faction"); } public static obj_id createTeamNpc(obj_id master, String team_name, String type, String ident, location here) throws InterruptedException @@ -247,8 +228,7 @@ public class scenario extends script.base_script } else { - obj_id self = getSelf(); - obj_id master = poi.getBaseObject(self); + obj_id master = poi.getBaseObject(getSelf()); if ((master == null) || (master == obj_id.NULL_ID)) { return null; @@ -257,10 +237,13 @@ public class scenario extends script.base_script if (teamsList != null) { int teamCount = teamsList.getNumItems(); + obj_var ov; + obj_var_list team; + for (int i = 0; i < teamCount; i++) { - obj_var ov = teamsList.getObjVar(i); - obj_var_list team = (obj_var_list)(ov); + ov = teamsList.getObjVar(i); + team = (obj_var_list) (ov); if (team != null) { if (team.hasObjVar("members." + actor)) @@ -290,7 +273,7 @@ public class scenario extends script.base_script if (idx != -1) { Vector member_alive = getResizeableIntArrayObjVar(master, VAR_TEAM + "." + team_name + ".member_alive"); - return (((Integer)member_alive.get(idx)).intValue() == 1); + return ((Integer) member_alive.get(idx) == 1); } return false; } @@ -482,7 +465,7 @@ public class scenario extends script.base_script { for (int i = 0; i < team.size(); i++) { - if (((obj_id)team.get(i)) == member) + if (team.get(i) == member) { return i; } @@ -504,13 +487,12 @@ public class scenario extends script.base_script return false; } String creditPath = VAR_TEAM + "." + team_name + ".kill_credits"; - for (int i = 0; i < killers.length; i++) - { - LOG("SCENARIO", "granting kill credit to " + getName(killers[i]) + " " + team_name); - String path = creditPath + "." + killers[i]; + String path; + for (obj_id killer : killers) { + LOG("SCENARIO", "granting kill credit to " + getName(killer) + " " + team_name); + path = creditPath + "." + killer; int cnt = 0; - if (hasObjVar(master, path)) - { + if (hasObjVar(master, path)) { cnt = getIntObjVar(master, path); } cnt++; @@ -599,33 +581,16 @@ public class scenario extends script.base_script poi.complete(poiMaster); return true; } - public static boolean complete() throws InterruptedException - { - obj_id self = getSelf(); - obj_id master = poi.getBaseObject(self); - if ((master == null) || (master == obj_id.NULL_ID)) - { - return false; - } - return complete(master); + public static boolean complete() throws InterruptedException { + obj_id master = poi.getBaseObject(getSelf()); + return !((master == null) || (master == obj_id.NULL_ID)) && complete(master); } - public static boolean isComplete(obj_id poiMaster) throws InterruptedException - { - if (poiMaster == null) - { - return false; - } - return getBooleanObjVar(poiMaster, VAR_SCENARIO_COMPLETE); + public static boolean isComplete(obj_id poiMaster) throws InterruptedException { + return poiMaster != null && getBooleanObjVar(poiMaster, VAR_SCENARIO_COMPLETE); } - public static boolean isComplete() throws InterruptedException - { - obj_id self = getSelf(); - obj_id master = poi.getBaseObject(self); - if ((master == null) || (master == obj_id.NULL_ID)) - { - return false; - } - return isComplete(master); + public static boolean isComplete() throws InterruptedException { + obj_id master = poi.getBaseObject(getSelf()); + return !((master == null) || (master == obj_id.NULL_ID)) && isComplete(master); } public static boolean setPlayerProgress(obj_id player, int progress) throws InterruptedException { @@ -633,8 +598,7 @@ public class scenario extends script.base_script { return false; } - obj_id self = getSelf(); - obj_id master = poi.getBaseObject(self); + obj_id master = poi.getBaseObject(getSelf()); if ((master == null) || (master == obj_id.NULL_ID)) { return false; @@ -648,8 +612,7 @@ public class scenario extends script.base_script { return false; } - obj_id self = getSelf(); - obj_id master = poi.getBaseObject(self); + obj_id master = poi.getBaseObject(getSelf()); if ((master == null) || (master == obj_id.NULL_ID)) { return false; @@ -664,8 +627,7 @@ public class scenario extends script.base_script { return -1; } - obj_id self = getSelf(); - obj_id master = poi.getBaseObject(self); + obj_id master = poi.getBaseObject(getSelf()); if ((master == null) || (master == obj_id.NULL_ID)) { return -1; @@ -689,18 +651,17 @@ public class scenario extends script.base_script int numItems = ovl.getNumItems(); if (numItems > 0) { + obj_var ov; + String ovName; + obj_id tmp; for (int i = 0; i < numItems; i++) { - obj_var ov = ovl.getObjVar(i); - String ovName = ov.getName(); + ov = ovl.getObjVar(i); + ovName = ov.getName(); if (ovName.startsWith(prefix)) { - obj_id tmp = getObjIdObjVar(poiMaster, "poi.stringList." + ovName); - if ((tmp == null) || (tmp == obj_id.NULL_ID)) - { - } - else - { + tmp = getObjIdObjVar(poiMaster, "poi.stringList." + ovName); + if ((tmp != null) && (tmp != obj_id.NULL_ID)) { actors = utils.addElement(actors, tmp); } } @@ -715,11 +676,8 @@ public class scenario extends script.base_script else { obj_id[] _actors = new obj_id[0]; - if (actors != null) - { - _actors = new obj_id[actors.size()]; - actors.toArray(_actors); - } + _actors = new obj_id[actors.size()]; + actors.toArray(_actors); return _actors; } } @@ -787,29 +745,24 @@ public class scenario extends script.base_script return false; } obj_id[] primaryKillers = getObjIdArrayObjVar(self, VAR_PRIMARY_KILLERS); - if ((primaryKillers == null) || (primaryKillers.length == 0)) - { - } - else - { + if ((primaryKillers != null) && (primaryKillers.length != 0)) { + obj_id pk; + obj_id groupId; + obj_id[] members; for (int i = 0; i < primaryKillers.length; i++) { - obj_id pk = primaryKillers[i]; - if ((pk == null) || (pk == obj_id.NULL_ID)) - { - } - else - { + pk = primaryKillers[i]; + if ((pk != null) && (pk != obj_id.NULL_ID)) { if (isPlayer(pk)) { - obj_id groupId = getGroupObject(pk); + groupId = getGroupObject(pk); if (isIdValid(groupId)) { poi.grantCredit(self, pk); } - else + else { - obj_id[] members = getGroupMemberIds(groupId); + members = getGroupMemberIds(groupId); if (members != null && members.length > 0) { for (int n = 0; i < members.length; i++) @@ -819,25 +772,18 @@ public class scenario extends script.base_script } } } - else + else { if (group.isGroupObject(pk)) { - obj_id[] members = getGroupMemberIds(pk); - if ((members == null) || (members.length == 0)) - { - } - else - { + members = getGroupMemberIds(pk); + if ((members != null) && (members.length != 0)) { for (int n = 0; i < members.length; i++) { poi.grantCredit(self, members[n]); } } } - else - { - } } } } @@ -863,14 +809,9 @@ public class scenario extends script.base_script if (isIdValid(poiMaster)) { obj_id[] members = getActorsWithNamePrefix(poiMaster, prefix); - if ((members == null) || (members.length == 0)) - { - } - else - { - for (int i = 0; i < members.length; i++) - { - faceTo(members[i], target); + if ((members != null) && (members.length != 0)) { + for (obj_id member : members) { + faceTo(member, target); } } } @@ -883,21 +824,13 @@ public class scenario extends script.base_script { int formation = rand(0, 1); obj_id[] members = getActorsWithNamePrefix(poiMaster, prefix); - if ((members == null) || (members.length == 0)) - { - } - else - { + if ((members != null) && (members.length != 0)) { int pos = 1; - for (int i = 0; i < members.length; i++) - { - if ((members[i] == leader) && (leader != formTarget)) - { + for (obj_id member : members) { + if ((member == leader) && (leader != formTarget)) { ai_lib.aiFollow(leader, formTarget); - } - else - { - ai_lib.followInFormation(members[i], leader, formation, pos); + } else { + ai_lib.followInFormation(member, leader, formation, pos); pos++; } } diff --git a/sku.0/sys.server/compiled/game/script/library/scheduled_drop.java b/sku.0/sys.server/compiled/game/script/library/scheduled_drop.java old mode 100644 new mode 100755 index 7234cd8b7..87de9071a --- a/sku.0/sys.server/compiled/game/script/library/scheduled_drop.java +++ b/sku.0/sys.server/compiled/game/script/library/scheduled_drop.java @@ -1,15 +1,9 @@ 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.dictionary; +import script.obj_id; -import script.library.static_item; -import script.library.utils; +import java.util.Vector; public class scheduled_drop extends script.base_script { @@ -99,9 +93,8 @@ public class scheduled_drop extends script.base_script { return 0; } - for (int i = 0, j = promotionList.length; i < j; i++) - { - weight += promotionList[i].getInt("promotionWeight"); + for (dictionary aPromotionList : promotionList) { + weight += aPromotionList.getInt("promotionWeight"); } return weight; } @@ -141,15 +134,15 @@ public class scheduled_drop extends script.base_script } Vector allStaticItems = new Vector(); allStaticItems.setSize(0); - for (int i = 0, j = promotionNames.length; i < j; i++) - { - for (int k = 0, l = allItems.length; k < l; k++) - { - String promotionList = dataTableGetString(DATATABLE_SCHEDULE, promotionNames[i], DATATABLE_SCHEDULE_PROMO_LIST); - if (allPromotionLists[k].equals(promotionList)) - { - dictionary cardEntry = new dictionary(); - cardEntry.put("promotionName", promotionNames[i]); + String promotionList; + dictionary cardEntry; + + for (String promotionName : promotionNames) { + for (int k = 0, l = allItems.length; k < l; k++) { + promotionList = dataTableGetString(DATATABLE_SCHEDULE, promotionName, DATATABLE_SCHEDULE_PROMO_LIST); + if (allPromotionLists[k].equals(promotionList)) { + cardEntry = new dictionary(); + cardEntry.put("promotionName", promotionName); cardEntry.put("promotionList", allPromotionLists[k]); cardEntry.put("promotionItem", allItems[k]); cardEntry.put("promotionWeight", allWeights[k]); @@ -185,11 +178,10 @@ public class scheduled_drop extends script.base_script scheduledPromotions.setSize(0); int currentDate = getCalendarTime(); testingSpam(self, "currentDate: " + currentDate + " realTime: " + getCalendarTimeStringLocal(currentDate)); - for (int i = 0, promotionsLength = promotions.length; i < promotionsLength; i++) - { - dictionary currentPromotion = dataTableGetRow(DATATABLE_SCHEDULE, promotions[i]); - if (!(currentPromotion.getString(DATATABLE_SCHEDULE_PROMO_TYPE)).equals(promotionType)) - { + dictionary currentPromotion; + for (String promotion : promotions) { + currentPromotion = dataTableGetRow(DATATABLE_SCHEDULE, promotion); + if (!(currentPromotion.getString(DATATABLE_SCHEDULE_PROMO_TYPE)).equals(promotionType)) { continue; } int startHour = currentPromotion.getInt(DATATABLE_SCHEDULE_PROMO_START_HOUR); @@ -207,8 +199,7 @@ public class scheduled_drop extends script.base_script int endYear = currentPromotion.getInt(DATATABLE_SCHEDULE_PROMO_END_YEAR); int endDate = getCalendarTime(endYear, endMonth, endDay, endHour, endMinute, endSecond); testingSpam(self, "Scheduled Promotion: " + currentPromotion.getString(DATATABLE_SCHEDULE_PROMO_NAME) + " Start: " + startDate + " End: " + endDate); - if (startDate <= currentDate && endDate >= currentDate) - { + if (startDate <= currentDate && endDate >= currentDate) { scheduledPromotions = utils.addElement(scheduledPromotions, currentPromotion.getString(DATATABLE_SCHEDULE_PROMO_NAME)); } } @@ -227,13 +218,12 @@ public class scheduled_drop extends script.base_script public static dictionary[] getPromotionMaxDrops(String[] promotions) throws InterruptedException { obj_id self = getSelf(); - Vector maxDrops = new Vector(); - maxDrops.setSize(0); String[] allPromotions = getSchedulerPromotions(); int[] allDrops = getSchedulerMaxDrops(); Vector promotionsWithDrops = new Vector(); promotionsWithDrops.setSize(0); testingSpam(self, "getPromotionMaxDrops allPromotions.length: " + allPromotions.length + " promotions.length: " + promotions.length); + dictionary tempPromotion; for (int i = 0, j = promotions.length; i < j; i++) { for (int k = 0, l = allPromotions.length; k < l; k++) @@ -241,7 +231,7 @@ public class scheduled_drop extends script.base_script testingSpam(self, "allPromotions[" + k + "]: " + allPromotions[k] + " promotions[" + i + "]: " + promotions[i] + " allDrops[" + k + "]: " + allDrops[k]); if (promotions[i].equals(allPromotions[k])) { - dictionary tempPromotion = new dictionary(); + tempPromotion = new dictionary(); tempPromotion.put("promotion", promotions[i]); tempPromotion.put("promotionMaxDrops", modifyPromotionCountByServer(allDrops[k])); promotionsWithDrops = utils.addElement(promotionsWithDrops, tempPromotion); @@ -259,7 +249,7 @@ public class scheduled_drop extends script.base_script public static int modifyPromotionCountByServer(int promotionCount) throws InterruptedException { String serverName = toLower(getConfigSetting("CentralServer", "clusterName")); - float percentOfCount = 0.0f; + float percentOfCount; if (serverName == null || serverName.length() <= 0) { percentOfCount = 0.01f; @@ -276,13 +266,11 @@ public class scheduled_drop extends script.base_script } public static int getLastClusterUpdateTime() throws InterruptedException { - obj_id planet = getPlanetByName("tatooine"); - return getIntObjVar(planet, CLUSTER_OBJVAR_LAST_UPDATE); + return getIntObjVar(getPlanetByName("tatooine"), CLUSTER_OBJVAR_LAST_UPDATE); } public static void setLastClusterUpdateTime(int date) throws InterruptedException { - obj_id planet = getPlanetByName("tatooine"); - setObjVar(planet, CLUSTER_OBJVAR_LAST_UPDATE, date); + setObjVar(getPlanetByName("tatooine"), CLUSTER_OBJVAR_LAST_UPDATE, date); } public static void removeLastClusterUpdateTime() throws InterruptedException { @@ -297,9 +285,8 @@ public class scheduled_drop extends script.base_script { obj_id planet = getPlanetByName("tatooine"); String[] promotions = getSchedulerPromotions(); - for (int i = 0, j = promotions.length; i < j; i++) - { - removeObjVar(planet, "tcg." + promotions[i] + ".count"); + for (String promotion : promotions) { + removeObjVar(planet, "tcg." + promotion + ".count"); } } public static void setClusterPromotions(dictionary[] promotionsWithMaxDrops) throws InterruptedException @@ -314,9 +301,8 @@ public class scheduled_drop extends script.base_script messageTo(planet, "clearPromotions", null, 1.0f, false); return; } - for (int i = 0, j = promotionsWithMaxDrops.length; i < j; i++) - { - messageTo(planet, "setPromotion", promotionsWithMaxDrops[i], 1.0f, false); + for (dictionary promotionsWithMaxDrop : promotionsWithMaxDrops) { + messageTo(planet, "setPromotion", promotionsWithMaxDrop, 1.0f, false); } } public static void instantiatePromotionsOnCluster() throws InterruptedException @@ -330,17 +316,10 @@ public class scheduled_drop extends script.base_script String[] currentPromotions = getScheduledPromotions("card"); obj_id self = getSelf(); testingSpam(self, "Card promotions length: " + currentPromotions.length); - if (currentPromotions == null) - { - setClusterPromotions(null); - } - else - { - setClusterPromotions(getPromotionMaxDrops(currentPromotions)); - } + setClusterPromotions(getPromotionMaxDrops(currentPromotions)); currentPromotions = getScheduledPromotions("item"); testingSpam(self, "Item promotions length: " + currentPromotions.length); - if (currentPromotions != null && currentPromotions.length > 0) + if (currentPromotions.length > 0) { setClusterPromotions(getPromotionMaxDrops(currentPromotions)); } @@ -354,12 +333,10 @@ public class scheduled_drop extends script.base_script } Vector validatedPromotions = new Vector(); validatedPromotions.setSize(0); - for (int i = 0, j = promotionNames.length; i < j; i++) - { - int countLeft = getIntObjVar(planet, "tcg." + promotionNames[i] + ".count"); - if (countLeft > 0 || countLeft == -1) - { - validatedPromotions = utils.addElement(validatedPromotions, promotionNames[i]); + for (String promotionName : promotionNames) { + int countLeft = getIntObjVar(planet, "tcg." + promotionName + ".count"); + if (countLeft > 0 || countLeft == -1) { + validatedPromotions = utils.addElement(validatedPromotions, promotionName); } } String[] _validatedPromotions = new String[0]; @@ -375,21 +352,21 @@ public class scheduled_drop extends script.base_script switch (systemToDrop) { case SYSTEM_COMBAT_NORMAL: - return CARD_DELAY_COMBAT_NORMAL; + return CARD_DELAY_COMBAT_NORMAL; case SYSTEM_COMBAT_ELITE: - return CARD_DELAY_COMBAT_ELITE; + return CARD_DELAY_COMBAT_ELITE; case SYSTEM_COMBAT_BOSS: - return CARD_DELAY_COMBAT_BOSS; + return CARD_DELAY_COMBAT_BOSS; case SYSTEM_COMBAT_SPACE: - return CARD_DELAY_COMBAT_SPACE; + return CARD_DELAY_COMBAT_SPACE; case SYSTEM_ENTERTAINER: - return CARD_DELAY_ENTERTAINER; + return CARD_DELAY_ENTERTAINER; case SYSTEM_CRAFTER: - return CARD_DELAY_CRAFTER; + return CARD_DELAY_CRAFTER; case SYSTEM_UNKNOWN: - return CARD_DELAY_DEFAULT; + return CARD_DELAY_DEFAULT; default: - return CARD_DELAY_DEFAULT; + return CARD_DELAY_DEFAULT; } } public static boolean hasCardDelay(obj_id player, int systemToDrop) throws InterruptedException @@ -418,17 +395,17 @@ public class scheduled_drop extends script.base_script switch (systemToDrop) { case SYSTEM_COMBAT_NORMAL: - return (rand(1, DROP_CHANCE_COMBAT_NORMAL) == 1 ? true : false); + return (rand(1, DROP_CHANCE_COMBAT_NORMAL) == 1); case SYSTEM_COMBAT_ELITE: - return (rand(1, DROP_CHANCE_COMBAT_ELITE) == 1 ? true : false); + return (rand(1, DROP_CHANCE_COMBAT_ELITE) == 1); case SYSTEM_COMBAT_BOSS: - return (rand(1, DROP_CHANCE_COMBAT_BOSS) == 1 ? true : false); + return (rand(1, DROP_CHANCE_COMBAT_BOSS) == 1); case SYSTEM_COMBAT_SPACE: - return (rand(1, DROP_CHANCE_COMBAT_SPACE) == 1 ? true : false); + return (rand(1, DROP_CHANCE_COMBAT_SPACE) == 1); case SYSTEM_ENTERTAINER: - return (rand(1, DROP_CHANCE_ENTERTAINER) == 1 ? true : false); + return (rand(1, DROP_CHANCE_ENTERTAINER) == 1); case SYSTEM_CRAFTER: - return (rand(1, DROP_CHANCE_CRAFTER) == 1 ? true : false); + return (rand(1, DROP_CHANCE_CRAFTER) == 1); case SYSTEM_UNKNOWN: return false; default: @@ -438,10 +415,7 @@ public class scheduled_drop extends script.base_script public static obj_id dropCard(int systemToDrop, obj_id container) throws InterruptedException { obj_id self = getSelf(); - obj_id card = null; String typeName = "card"; - String staticItemName = ""; - String promotionName = ""; instantiatePromotionsOnCluster(); if (!isIdValid(container) || !exists(container)) { @@ -469,6 +443,8 @@ public class scheduled_drop extends script.base_script } dictionary[] promotionalItems = getStaticItemsForAllPromotions(promotions); int index = getRandomStaticItem(promotionalItems); + String staticItemName = ""; + String promotionName; if (promotionalItems.length > index && index >= 0) { staticItemName = promotionalItems[index].getString("promotionItem"); @@ -479,7 +455,7 @@ public class scheduled_drop extends script.base_script CustomerServiceLog("tcg", "ERROR dropCard() tcg.getRandomStaticItem(promotionalItems) out of bounds index for type: " + staticItemName + "."); return null; } - card = static_item.createNewItemFunction(staticItemName, container); + obj_id card = static_item.createNewItemFunction(staticItemName, container); if (!isIdValid(card) || !exists(card)) { if (isIdValid(self) && isGod(self) && hasObjVar(self, "qa_tcg")) diff --git a/sku.0/sys.server/compiled/game/script/library/scout.java b/sku.0/sys.server/compiled/game/script/library/scout.java old mode 100644 new mode 100755 index 6ffc1765c..b7f15afa6 --- a/sku.0/sys.server/compiled/game/script/library/scout.java +++ b/sku.0/sys.server/compiled/game/script/library/scout.java @@ -1,19 +1,6 @@ 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.library.utils; -import script.library.ai_lib; -import script.library.pet_lib; -import script.library.combat; -import script.ai.ai_combat; -import script.library.skill; public class scout extends script.base_script { @@ -95,7 +82,7 @@ public class scout extends script.base_script return false; } } - int maskMod = 0; + int maskMod; if (concealed) { maskMod = concealBonus; @@ -195,8 +182,6 @@ public class scout extends script.base_script else { breakScentMask(player, false); - float dist = utils.getDistance2D(getLocation(player), getLocation(npc)); - dieRoll = rand(1, 100); return false; } return true; @@ -311,14 +296,11 @@ public class scout extends script.base_script } obj_id[] contents = getContents(pInv); obj_id kit = null; - for (int i = 0; i < contents.length; i++) - { - if (hasObjVar(contents[i], "camokit")) - { - String kitPlanet = getStringObjVar(contents[i], "camokit"); - if (kitPlanet.equals(planetName)) - { - kit = contents[i]; + + for (obj_id content : contents) { + if (hasObjVar(content, "camokit")) { + if (getStringObjVar(content, "camokit").equals(planetName)) { + kit = content; break; } } diff --git a/sku.0/sys.server/compiled/game/script/library/sequencer.java b/sku.0/sys.server/compiled/game/script/library/sequencer.java old mode 100644 new mode 100755 index f639e2045..4c51e85cd --- a/sku.0/sys.server/compiled/game/script/library/sequencer.java +++ b/sku.0/sys.server/compiled/game/script/library/sequencer.java @@ -1,15 +1,7 @@ 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.library.utils; -import script.ai.ai_combat; +import script.dictionary; +import script.obj_id; public class sequencer extends script.base_script { @@ -66,8 +58,7 @@ public class sequencer extends script.base_script } public static boolean cleanUpSequenceObject(obj_id objObject, String strIdentifier) throws InterruptedException { - obj_id objMaster = getMasterSequenceObject(objObject); - return utils.removeScriptVar(objMaster, strIdentifier); + return utils.removeScriptVar(getMasterSequenceObject(objObject), strIdentifier); } public static obj_id getMasterSequenceObject(obj_id objObject) throws InterruptedException { @@ -83,35 +74,26 @@ public class sequencer extends script.base_script } return objMaster; } - public static boolean isValidSequenceIdentifier(String strIdentifier) throws InterruptedException - { + public static boolean isValidSequenceIdentifier(String strIdentifier) throws InterruptedException { obj_id objMaster = getMasterSequenceObject(getSelf()); - if (isIdValid(objMaster)) - { - return utils.hasScriptVar(objMaster, strIdentifier); - } - return false; + return isIdValid(objMaster) && utils.hasScriptVar(objMaster, strIdentifier); } public static void walkToSequenceObject(obj_id objNPC, obj_id objSeq) throws InterruptedException { - location locWalkTo = getLocation(objSeq); - pathTo(objNPC, locWalkTo); + pathTo(objNPC, getLocation(objSeq)); } public static void walkToSequenceObject(obj_id objNPC, String strObject) throws InterruptedException { - obj_id objSeq = getSequenceObject(strObject); - walkToSequenceObject(objNPC, objSeq); + walkToSequenceObject(objNPC, getSequenceObject(strObject)); } public static void runToSequenceObject(obj_id objNPC, obj_id objSeq) throws InterruptedException { - location locWalkTo = getLocation(objSeq); setMovementRun(objNPC); - pathTo(objNPC, locWalkTo); + pathTo(objNPC, getLocation(objSeq)); } public static void runToSequenceObject(obj_id objNPC, String strObject) throws InterruptedException { - obj_id objSeq = getSequenceObject(strObject); - runToSequenceObject(objNPC, objSeq); + runToSequenceObject(objNPC, getSequenceObject(strObject)); } public static void doCombatAnimation(obj_id objNPC, obj_id objSeq, String strAnimation) throws InterruptedException { @@ -133,18 +115,14 @@ public class sequencer extends script.base_script } doCombatResults(strAnimation, cbtAttackerResults, cbtDefenderResults); } - return; } public static void doCombatAnimation(obj_id objNPC, String strObject, String strAnimation) throws InterruptedException { - obj_id objSeq = getSequenceObject(strObject); - doCombatAnimation(objSeq, objNPC, strAnimation); + doCombatAnimation(getSequenceObject(strObject), objNPC, strAnimation); } public static void faceToSequenceObject(obj_id objNPC, String strObject) throws InterruptedException { - obj_id objSeq = getSequenceObject(strObject); - faceTo(objNPC, objSeq); - return; + faceTo(objNPC, getSequenceObject(strObject)); } public static attacker_results makeDummyAttackerResults(obj_id objAttacker) throws InterruptedException { @@ -179,16 +157,12 @@ public class sequencer extends script.base_script } public static void continueEventSequence(String strContinueTag) throws InterruptedException { - obj_id self = getSelf(); - obj_id objMaster = getMasterSequenceObject(self); dictionary dctParams = new dictionary(); dctParams.put("strContinueTag", strContinueTag); - messageTo(objMaster, "doEvents", dctParams, 0, false); - return; + messageTo(getMasterSequenceObject(getSelf()), "doEvents", dctParams, 0, false); } public static void stopSequence(obj_id objTarget) throws InterruptedException { messageTo(objTarget, "interruptSequence", null, 0, false); - return; } } diff --git a/sku.0/sys.server/compiled/game/script/library/session.java b/sku.0/sys.server/compiled/game/script/library/session.java old mode 100644 new mode 100755 index c7a199c7d..f3803a3a1 --- a/sku.0/sys.server/compiled/game/script/library/session.java +++ b/sku.0/sys.server/compiled/game/script/library/session.java @@ -1,12 +1,6 @@ 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; public class session extends script.base_script { diff --git a/sku.0/sys.server/compiled/game/script/library/ship_ai.java b/sku.0/sys.server/compiled/game/script/library/ship_ai.java old mode 100644 new mode 100755 index 9a6d5eb01..c0d9b2c1c --- a/sku.0/sys.server/compiled/game/script/library/ship_ai.java +++ b/sku.0/sys.server/compiled/game/script/library/ship_ai.java @@ -1,19 +1,13 @@ 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.library.utils; -import java.util.Random; -import java.util.Vector; +import script.dictionary; +import script.obj_id; import script.transform; import script.vector; +import java.util.Random; +import java.util.Vector; + public class ship_ai extends script.base_script { public ship_ai() @@ -97,12 +91,16 @@ public class ship_ai extends script.base_script { final int points = 20; transform path[] = new transform[points]; + float radian; + float x; + float y; + float z; for (int i = 0; i < points; ++i) { - final float radian = (float)Math.PI * 2.0f * ((float)i / (float)points); - final float x = position_w.x + (float)Math.sin(radian) * radius; - final float y = position_w.y; - final float z = position_w.z + (float)Math.cos(radian) * radius; + radian = (float)Math.PI * 2.0f * ((float)i / (float)points); + x = position_w.x + (float)Math.sin(radian) * radius; + y = position_w.y; + z = position_w.z + (float)Math.cos(radian) * radius; path[i] = transform.identity.setPosition_p(x, y, z); } return path; @@ -111,10 +109,12 @@ public class ship_ai extends script.base_script { final int points = 20; transform path[] = new transform[points]; + vector direction; + vector position; for (int i = 0; i < points; ++i) { - final vector direction = vector.randomUnit(); - vector position = (transform_w.getPosition_p()).add(direction.multiply(minDist + (float)Math.random() * (maxDist - minDist))); + direction = vector.randomUnit(); + position = (transform_w.getPosition_p()).add(direction.multiply(minDist + (float)Math.random() * (maxDist - minDist))); path[i] = transform.identity.setPosition_p(position); } return path; @@ -134,9 +134,8 @@ public class ship_ai extends script.base_script public static void squadClearPatrolPath(int squadId) throws InterruptedException { obj_id[] unitList = squadGetUnitList(squadId); - for (int i = 0; i < unitList.length; ++i) - { - _spaceUnitClearPatrolPath(unitList[i]); + for (obj_id anUnitList : unitList) { + _spaceUnitClearPatrolPath(anUnitList); } } public static void unitFollow(obj_id unit, obj_id followedUnit, vector direction_o, float distance) throws InterruptedException @@ -158,9 +157,8 @@ public class ship_ai extends script.base_script public static void squadSetAttackOrders(int squadId, int attackOrders) throws InterruptedException { obj_id[] unitList = squadGetUnitList(squadId); - for (int i = 0; i < unitList.length; ++i) - { - unitSetAttackOrders(unitList[i], attackOrders); + for (obj_id anUnitList : unitList) { + unitSetAttackOrders(anUnitList, attackOrders); } } public static void unitSetLeashDistance(obj_id unit, float distance) throws InterruptedException @@ -170,9 +168,8 @@ public class ship_ai extends script.base_script public static void squadSetLeashDistance(int squadId, float distance) throws InterruptedException { obj_id[] unitList = squadGetUnitList(squadId); - for (int i = 0; i < unitList.length; ++i) - { - unitSetLeashDistance(unitList[i], distance); + for (obj_id anUnitList : unitList) { + unitSetLeashDistance(anUnitList, distance); } } public static void unitSetPilotType(obj_id unit, String pilotType) throws InterruptedException @@ -240,22 +237,15 @@ public class ship_ai extends script.base_script public static void unitRemoveFromAllAttackTargetLists(obj_id unit) throws InterruptedException { obj_id[] whoIsTargetingMeList = unitGetWhoIsTargetingMe(unit); - for (int index = 0; index < whoIsTargetingMeList.length; ++index) - { - if (exists(whoIsTargetingMeList[index]) && (whoIsTargetingMeList[index].isLoaded())) - { - if (!space_utils.isPlayerControlledShip(whoIsTargetingMeList[index])) - { - unitRemoveAttackTarget(whoIsTargetingMeList[index], unit); + for (obj_id aWhoIsTargetingMeList : whoIsTargetingMeList) { + if (exists(aWhoIsTargetingMeList) && (aWhoIsTargetingMeList.isLoaded())) { + if (!space_utils.isPlayerControlledShip(aWhoIsTargetingMeList)) { + unitRemoveAttackTarget(aWhoIsTargetingMeList, unit); + } else { + LOG("space", aWhoIsTargetingMeList + " was passed into getWhoistargetingme but it's a PLAYER"); } - else - { - LOG("space", whoIsTargetingMeList[index] + " was passed into getWhoistargetingme but it's a PLAYER"); - } - } - else - { - LOG("space", whoIsTargetingMeList[index] + " was passed into unitGetWhoIsTargetingMe but doesn't exist on the server"); + } else { + LOG("space", aWhoIsTargetingMeList + " was passed into unitGetWhoIsTargetingMe but doesn't exist on the server"); } } } @@ -270,28 +260,24 @@ public class ship_ai extends script.base_script public static void squadSetPrimaryTarget(int squadId, obj_id targetUnit) throws InterruptedException { obj_id[] unitList = squadGetUnitList(squadId); - for (int i = 0; i < unitList.length; ++i) - { - unitAddDamageTaken(unitList[i], targetUnit, 100000.0f); + for (obj_id anUnitList : unitList) { + unitAddDamageTaken(anUnitList, targetUnit, 100000.0f); } } public static void squadAddTarget(int squadId, obj_id targetUnit) throws InterruptedException { obj_id[] unitList = squadGetUnitList(squadId); - for (int i = 0; i < unitList.length; ++i) - { - unitAddDamageTaken(unitList[i], targetUnit, 100.0f); + for (obj_id anUnitList : unitList) { + unitAddDamageTaken(anUnitList, targetUnit, 100.0f); } } public static void squadSetPrimaryTarget(int squadId, int targetSquadId) throws InterruptedException { obj_id[] unitList = squadGetUnitList(squadId); obj_id[] targetUnitList = squadGetUnitList(targetSquadId); - for (int i = 0; i < unitList.length; ++i) - { - for (int j = 0; j < targetUnitList.length; ++j) - { - unitAddDamageTaken(unitList[i], targetUnitList[j], (float)Math.random() * 100000.0f + 100000.0f); + for (obj_id anUnitList : unitList) { + for (obj_id aTargetUnitList : targetUnitList) { + unitAddDamageTaken(anUnitList, aTargetUnitList, (float) Math.random() * 100000.0f + 100000.0f); } } } @@ -299,11 +285,9 @@ public class ship_ai extends script.base_script { obj_id[] unitList = squadGetUnitList(squadId); obj_id[] targetUnitList = squadGetUnitList(targetSquadId); - for (int i = 0; i < unitList.length; ++i) - { - for (int j = 0; j < targetUnitList.length; ++j) - { - unitAddDamageTaken(unitList[i], targetUnitList[j], (float)Math.random() * 100.0f + 100.0f); + for (obj_id anUnitList : unitList) { + for (obj_id aTargetUnitList : targetUnitList) { + unitAddDamageTaken(anUnitList, aTargetUnitList, (float) Math.random() * 100.0f + 100.0f); } } } @@ -346,45 +330,30 @@ public class ship_ai extends script.base_script { Random random = new Random(); final int value = Math.abs(random.nextInt()) % 6; - int formation = FORMATION_INVALID; + int formation; switch (value) { case 0: - - { formation = FORMATION_CLAW; - } - break; + break; case 1: - - { formation = FORMATION_WALL; - } - break; + break; case 2: - - { formation = FORMATION_SPHERE; - } - break; + break; case 3: - - { formation = FORMATION_DELTA; - } - break; + break; case 4: - - { formation = FORMATION_BROAD; - } - break; + break; case 5: - - { formation = FORMATION_X; - } - break; + break; + default: + formation = FORMATION_INVALID; + break; } _spaceSquadSetFormation(squadId, formation); } @@ -472,29 +441,12 @@ public class ship_ai extends script.base_script { return _spaceSquadIsSquadIdValid(squadId); } - public static boolean isShipDead(obj_id ship) throws InterruptedException - { - if (!isIdValid(ship)) - { - return true; - } - if (!ship.isLoaded()) - { - return true; - } - return (hasObjVar(ship, "ship.isDead")); + public static boolean isShipDead(obj_id ship) throws InterruptedException { + return !isIdValid(ship) || !ship.isLoaded() || (hasObjVar(ship, "ship.isDead")); } - public static boolean isPlayerShip(obj_id ship) throws InterruptedException - { + public static boolean isPlayerShip(obj_id ship) throws InterruptedException { obj_id pilot = getPilotId(ship); - if (isIdValid(pilot)) - { - return (isPlayer(pilot)); - } - else - { - return false; - } + return isIdValid(pilot) && (isPlayer(pilot)); } public static boolean isShipAggro(obj_id ship) throws InterruptedException { @@ -525,17 +477,14 @@ public class ship_ai extends script.base_script { return false; } - String shipName = getStringObjVar(ship, "ship.shipName"); - String enemyFactionList = dataTableGetString("datatables/space_mobile/space_mobile.iff", shipName, "enemyFactions"); + String enemyFactionList = dataTableGetString("datatables/space_mobile/space_mobile.iff", getStringObjVar(ship, "ship.shipName"), "enemyFactions"); if (enemyFactionList == null) { return false; } String[] enemiesList = split(enemyFactionList, ','); - for (int i = 0; i < enemiesList.length; i++) - { - if (enemiesList[i].equals(targetFaction)) - { + for (String anEnemiesList : enemiesList) { + if (anEnemiesList.equals(targetFaction)) { return true; } } @@ -561,17 +510,14 @@ public class ship_ai extends script.base_script { return false; } - String shipName = getStringObjVar(ship, "ship.shipName"); - String allyFactionList = dataTableGetString("datatables/space_mobile/space_mobile.iff", shipName, "alliedFactions"); + String allyFactionList = dataTableGetString("datatables/space_mobile/space_mobile.iff", getStringObjVar(ship, "ship.shipName"), "alliedFactions"); if (allyFactionList == null) { return false; } String[] allyList = split(allyFactionList, ','); - for (int i = 0; i < allyList.length; i++) - { - if (allyList[i].equals(targetFaction)) - { + for (String anAllyList : allyList) { + if (anAllyList.equals(targetFaction)) { return true; } } @@ -611,13 +557,11 @@ public class ship_ai extends script.base_script obj_id[] groupMembers = getGroupMemberIds(group); Vector groupShips = new Vector(); groupShips.add(primaryTarget); - for (int i = 0; i < groupMembers.length; i++) - { - if (groupMembers[i].isLoaded()) - { - obj_id ship = getPilotedShip(groupMembers[i]); - if (isIdValid(ship) && ship != primaryTarget && getDistance(ship, primaryTarget) < 120.0f) - { + obj_id ship; + for (obj_id groupMember : groupMembers) { + if (groupMember.isLoaded()) { + ship = getPilotedShip(groupMember); + if (isIdValid(ship) && ship != primaryTarget && getDistance(ship, primaryTarget) < 120.0f) { groupShips.add(ship); } } @@ -631,42 +575,24 @@ public class ship_ai extends script.base_script String result; switch (behavior) { - default: - - { - result = "invalid"; - } - break; case BEHAVIOR_IDLE: - - { result = "BEHAVIOR_IDLE"; - } - break; + break; case BEHAVIOR_MOVETO: - - { result = "BEHAVIOR_MOVETO"; - } - break; + break; case BEHAVIOR_PATROL: - - { result = "BEHAVIOR_PATROL"; - } - break; + break; case BEHAVIOR_FOLLOW: - - { result = "BEHAVIOR_FOLLOW"; - } - break; + break; case BEHAVIOR_TRACK: - - { result = "BEHAVIOR_TRACK"; - } - break; + break; + default: + result = "invalid"; + break; } return result; } @@ -675,30 +601,18 @@ public class ship_ai extends script.base_script String result; switch (attackOrders) { - default: - - { - result = "invalid"; - } - break; case ATTACK_ORDERS_HOLD_FIRE: - - { result = "ATTACK_ORDERS_HOLD_FIRE"; - } - break; + break; case ATTACK_ORDERS_RETURN_FIRE: - - { result = "ATTACK_ORDERS_DEFEND"; - } - break; + break; case ATTACK_ORDERS_ATTACK_FREELY: - - { result = "ATTACK_ORDERS_ATTACK_FREELY"; - } - break; + break; + default: + result = "invalid"; + break; } return result; } @@ -708,9 +622,8 @@ public class ship_ai extends script.base_script } public static void spaceAttack(obj_id ship, obj_id[] targets) throws InterruptedException { - for (int i = 0; i < targets.length; i++) - { - unitAddDamageTaken(ship, targets[i], 100000.0f); + for (obj_id target : targets) { + unitAddDamageTaken(ship, target, 100000.0f); } } public static obj_id spaceGetPrimaryTarget(obj_id ship) throws InterruptedException diff --git a/sku.0/sys.server/compiled/game/script/library/skill.java b/sku.0/sys.server/compiled/game/script/library/skill.java old mode 100644 new mode 100755 index 18e4ff8f2..5812dad63 --- a/sku.0/sys.server/compiled/game/script/library/skill.java +++ b/sku.0/sys.server/compiled/game/script/library/skill.java @@ -1,21 +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.library.prose; -import script.library.utils; -import script.library.list; -import script.library.jedi; -import script.library.combat; -import script.library.pclib; -import script.library.space_flags; -import script.library.buff; +import java.util.Arrays; +import java.util.Enumeration; +import java.util.Vector; public class skill extends script.base_script { @@ -88,8 +77,7 @@ public class skill extends script.base_script messageTo(target, HANDLER_SKILL_GRANTED, d, 0, true); return true; } - boolean litmus = grantSkill(target, skillName); - return litmus; + return grantSkill(target, skillName); } public static boolean grantSkillToPlayer(obj_id player, String skillName) throws InterruptedException { @@ -147,11 +135,11 @@ public class skill extends script.base_script { if (space_flags.isSpaceTrack(player, space_flags.PRIVATEER_TATOOINE)) { - soundFile = soundFile = "sound/music_themequest_acc_criminal.snd"; + soundFile = "sound/music_themequest_acc_criminal.snd"; } else { - soundFile = soundFile = "sound/music_themequest_acc_general.snd"; + soundFile = "sound/music_themequest_acc_general.snd"; } } else if (skillName.startsWith("pilot_rebel")) @@ -214,23 +202,13 @@ public class skill extends script.base_script } return false; } - public static boolean hasRequiredSkillsForSkillPurchase(obj_id player, String skillName) throws InterruptedException - { - if (!isIdValid(player) || (!isPlayer(player)) || skillName == null || skillName.equals("")) - { + public static boolean hasRequiredSkillsForSkillPurchase(obj_id player, String skillName) throws InterruptedException { + if (!isIdValid(player) || (!isPlayer(player)) || skillName == null || skillName.equals("")) { return false; } String[] pSkills = getSkillListingForPlayer(player); String[] skillReqs = getSkillPrerequisiteSkills(skillName); - if (skillReqs == null) - { - return true; - } - if (pSkills == null) - { - return false; - } - return utils.isSubset(pSkills, skillReqs); + return skillReqs == null || pSkills != null && utils.isSubset(pSkills, skillReqs); } public static boolean hasRequiredXpForSkillPurchase(obj_id player, String skillName) throws InterruptedException { @@ -245,9 +223,10 @@ public class skill extends script.base_script } boolean qualifies = true; java.util.Enumeration e = xpReqs.keys(); + String xpType; while (e.hasMoreElements()) { - String xpType = (String)(e.nextElement()); + xpType = (String) (e.nextElement()); int xpCost = xpReqs.getInt(xpType); if (getExperiencePoints(player, xpType) < xpCost) { @@ -269,9 +248,10 @@ public class skill extends script.base_script } boolean qualifies = true; java.util.Enumeration e = xpReqs.keys(); + String xpType; while (e.hasMoreElements()) { - String xpType = (String)(e.nextElement()); + xpType = (String) (e.nextElement()); int xpCost = xpReqs.getInt(xpType); if (xpCost != 0) { @@ -299,20 +279,14 @@ public class skill extends script.base_script return null; } Vector ret = new Vector(Arrays.asList(reqs)); - for (int i = 0; i < reqs.length; i++) - { - String[] tmp = getAllRequiredSkills(reqs[i]); - if ((tmp == null) || (tmp.length == 0)) - { - } - else - { - for (int n = 0; n < tmp.length; n++) - { - int pos = utils.getElementPositionInArray(ret, tmp[n]); - if (pos == -1) - { - ret = utils.addElement(ret, tmp[n]); + String[] tmp; + for (String req : reqs) { + tmp = getAllRequiredSkills(req); + if ((tmp != null) && (tmp.length != 0)) { + for (String aTmp : tmp) { + int pos = utils.getElementPositionInArray(ret, aTmp); + if (pos == -1) { + ret = utils.addElement(ret, aTmp); } } } @@ -338,11 +312,12 @@ public class skill extends script.base_script { return false; } + String skill_list; for (int i = 0; i < templates.length; i++) { if ((toLower(templates[i])).equals(toLower(template))) { - String skill_list = dataTableGetString(DATATABLE_SKILL_TEMPLATE, i, DATATABLE_BASE_SKILLS); + skill_list = dataTableGetString(DATATABLE_SKILL_TEMPLATE, i, DATATABLE_BASE_SKILLS); if (skill_list.startsWith("\"")) { skill_list = skill_list.substring(1); @@ -353,35 +328,21 @@ public class skill extends script.base_script } if (!skill_list.equals("")) { - int recurseIntVal = dataTableGetInt(DATATABLE_SKILL_TEMPLATE, i, DATATABLE_RECURSE); - boolean recurse = false; - switch (recurseIntVal) - { - case 0: - break; - case 1: - recurse = true; - break; - default: - break; - } + boolean recurse = dataTableGetInt(DATATABLE_SKILL_TEMPLATE, i, DATATABLE_RECURSE) == 1; boolean litmus = true; java.util.StringTokenizer skills = new java.util.StringTokenizer(toLower(skill_list), ","); + String skillName; + String[] reqs; while (skills.hasMoreTokens()) { - String skillName = skills.nextToken(); + skillName = skills.nextToken(); litmus &= grantSkill(target, skillName); if (recurse) { - String[] reqs = getAllRequiredSkills(skillName); - if ((reqs == null) || (reqs.length == 0)) - { - } - else - { - for (int n = 0; n < reqs.length; n++) - { - litmus &= grantSkill(target, reqs[n]); + reqs = getAllRequiredSkills(skillName); + if ((reqs != null) && (reqs.length != 0)) { + for (String req : reqs) { + litmus &= grantSkill(target, req); } } } @@ -390,9 +351,10 @@ public class skill extends script.base_script if ((inherits_list != null) && (!inherits_list.equals(""))) { java.util.StringTokenizer inheritTokens = new java.util.StringTokenizer(toLower(inherits_list), ","); + String inheritTemplate; while (inheritTokens.hasMoreTokens()) { - String inheritTemplate = inheritTokens.nextToken(); + inheritTemplate = inheritTokens.nextToken(); if (!inheritTemplate.equals("")) { litmus &= assignSkillTemplate(target, inheritTemplate); @@ -417,9 +379,8 @@ public class skill extends script.base_script { return false; } - for (int i = 0; i < skills.length; i++) - { - revokeSkill(target, skills[i]); + for (String skill : skills) { + revokeSkill(target, skill); CustomerServiceLog("Skill", "skill.revokeAllSkills(): (" + target + ") " + getName(target) + " is having all skills revoked!"); } return true; @@ -428,15 +389,12 @@ public class skill extends script.base_script { String[] skillList = getSkillListingForPlayer(player); int attempts = skillList.length; - if ((skillList != null) && (skillList.length != 0)) + if ((skillList.length != 0)) { while (skillList.length > 0 && attempts > 0) { - for (int i = 0; i < skillList.length; i++) - { - String skillName = skillList[i]; - if (!skillName.startsWith("species_") && !skillName.startsWith("social_language_") && !skillName.startsWith("social_politician_") && !skillName.startsWith("utility_") && !skillName.startsWith("common_") && !skillName.startsWith("demo_") && !skillName.startsWith("force_title_") && !skillName.startsWith("force_sensitive_") && !skillName.startsWith("combat_melee_basic") && !skillName.startsWith("pilot_") && !skillName.startsWith("internal_expertise_") && !skillName.startsWith("combat_ranged_weapon_basic") && !skillName.equals("expertise")) - { + for (String skillName : skillList) { + if (!skillName.startsWith("species_") && !skillName.startsWith("social_language_") && !skillName.startsWith("social_politician_") && !skillName.startsWith("utility_") && !skillName.startsWith("common_") && !skillName.startsWith("demo_") && !skillName.startsWith("force_title_") && !skillName.startsWith("force_sensitive_") && !skillName.startsWith("combat_melee_basic") && !skillName.startsWith("pilot_") && !skillName.startsWith("internal_expertise_") && !skillName.startsWith("combat_ranged_weapon_basic") && !skillName.equals("expertise")) { revokeSkillSilent(player, skillName); } } @@ -462,96 +420,75 @@ public class skill extends script.base_script } Vector qualifiedSkills = new Vector(); qualifiedSkills.setSize(0); - for (int i = 0; i < teachableSkills.length; i++) - { + dictionary d; + Object o; + String xpType; + Enumeration species_keys; + String key; + String trainer_type; + String branch; + String skillName; + + for (String teachableSkill : teachableSkills) { boolean qualifies = true; - dictionary d = getSkillPrerequisiteExperience(teachableSkills[i]); - if (d == null || d.isEmpty()) - { - } - else - { - java.util.Enumeration keys = d.keys(); - int n = 0; - while (keys.hasMoreElements()) - { - Object o = keys.nextElement(); - if (o instanceof String) - { - String xpType = (String)o; + d = getSkillPrerequisiteExperience(teachableSkill); + if (d != null && !d.isEmpty()) { + Enumeration keys = d.keys(); + while (keys.hasMoreElements()) { + o = keys.nextElement(); + if (o instanceof String) { + xpType = (String) o; int xpCost = d.getInt(xpType); int playerXP = getExperiencePoints(target, xpType); - if (playerXP >= xpCost) - { - } - else - { + if (playerXP < xpCost) { qualifies = false; } - } - else - { + } else { return null; } } } - dictionary species = getSkillPrerequisiteSpecies(teachableSkills[i]); - if (species != null && !d.isEmpty()) - { - java.util.Enumeration species_keys = species.keys(); - while (species_keys.hasMoreElements()) - { - Object o = species_keys.nextElement(); - if (o instanceof String) - { - String key = (String)o; - if (species.getBoolean(key)) - { + dictionary species = getSkillPrerequisiteSpecies(teachableSkill); + assert d != null; + if (species != null && !d.isEmpty()) { + species_keys = species.keys(); + while (species_keys.hasMoreElements()) { + o = species_keys.nextElement(); + if (o instanceof String) { + key = (String) o; + if (species.getBoolean(key)) { qualifies = false; } } } } - String trainer_type = getStringObjVar(teacher, "trainer"); - if (trainer_type != null && trainer_type.equals("trainer_fs")) - { - if (qualifies) - { - if (fs_quests.isVillageEligible(target)) - { - String branch = fs_quests.getBranchFromSkill(teachableSkills[i]); - if (!fs_quests.hasUnlockedBranch(target, branch)) - { + trainer_type = getStringObjVar(teacher, "trainer"); + if (trainer_type != null && trainer_type.equals("trainer_fs")) { + if (qualifies) { + if (fs_quests.isVillageEligible(target)) { + branch = fs_quests.getBranchFromSkill(teachableSkill); + if (!fs_quests.hasUnlockedBranch(target, branch)) { qualifies = false; } - } - else - { + } else { qualifies = false; } } } - if (hasObjVar(target, "newbie.hasSkill") && !hasObjVar(target, "newbie.trained")) - { - String skillName = getStringObjVar(target, "newbie.hasSkill"); - if (skillName.equals(teachableSkills[i])) - { + if (hasObjVar(target, "newbie.hasSkill") && !hasObjVar(target, "newbie.trained")) { + skillName = getStringObjVar(target, "newbie.hasSkill"); + if (skillName.equals(teachableSkill)) { qualifies = true; } } - if (qualifies) - { - qualifiedSkills = utils.addElement(qualifiedSkills, teachableSkills[i]); + if (qualifies) { + qualifiedSkills = utils.addElement(qualifiedSkills, teachableSkill); } } if ((qualifiedSkills != null) && (qualifiedSkills.size() > 0)) { - String[] _qualifiedSkills = new String[0]; - if (qualifiedSkills != null) - { - _qualifiedSkills = new String[qualifiedSkills.size()]; - qualifiedSkills.toArray(_qualifiedSkills); - } + String[] _qualifiedSkills = new String[qualifiedSkills.size()]; + qualifiedSkills.toArray(_qualifiedSkills); return _qualifiedSkills; } return null; @@ -560,7 +497,6 @@ public class skill extends script.base_script { if (!isIdValid(target) || !isIdValid(teacher)) { - obj_id self = getSelf(); return null; } if (isPlayer(teacher)) @@ -575,21 +511,15 @@ public class skill extends script.base_script } Vector delta = new Vector(); delta.setSize(0); - for (int i = 0; i < teacherSkills.length; i++) - { - if (utils.getElementPositionInArray(targetSkills, teacherSkills[i]) == -1) - { - delta = utils.addElement(delta, teacherSkills[i]); + for (String teacherSkill : teacherSkills) { + if (utils.getElementPositionInArray(targetSkills, teacherSkill) == -1) { + delta = utils.addElement(delta, teacherSkill); } } if ((delta != null) && (delta.size() != 0)) { - String[] _delta = new String[0]; - if (delta != null) - { - _delta = new String[delta.size()]; - delta.toArray(_delta); - } + String[] _delta = new String[delta.size()]; + delta.toArray(_delta); return _delta; } return null; @@ -627,21 +557,15 @@ public class skill extends script.base_script } Vector delta = new Vector(); delta.setSize(0); - for (int i = 0; i < teacherSkills.length; i++) - { - if (utils.getElementPositionInArray(targetSkills, teacherSkills[i]) == -1) - { - delta = utils.addElement(delta, teacherSkills[i]); + for (String teacherSkill : teacherSkills) { + if (utils.getElementPositionInArray(targetSkills, teacherSkill) == -1) { + delta = utils.addElement(delta, teacherSkill); } } if ((delta != null) && (delta.size() != 0)) { - String[] _delta = new String[0]; - if (delta != null) - { - _delta = new String[delta.size()]; - delta.toArray(_delta); - } + String[] _delta = new String[delta.size()]; + delta.toArray(_delta); return _delta; } return null; @@ -658,11 +582,8 @@ public class skill extends script.base_script { return -1; } - int deltaPercent = params.getInt(DICT_DELTA_PERCENT); - if ((retCode == CODE_PASS) && (deltaPercent >= 0)) - { - } - return deltaPercent; + + return params.getInt(DICT_DELTA_PERCENT); } public static dictionary skillModCheck(obj_id target, String skillmod, String scale) throws InterruptedException { @@ -675,30 +596,29 @@ public class skill extends script.base_script int modmin = 1; int modmax = 100; int scaleIdx = scale.indexOf(DELIM_RANGE); - if (scale.equals("")) - { - } - else if (scaleIdx > 0) - { - java.util.StringTokenizer rng = new java.util.StringTokenizer(scale, DELIM_RANGE); - String smin = ""; - String smax = ""; - if (rng.countTokens() == 2) - { - smin = rng.nextToken(); - smax = rng.nextToken(); - } - else - { - ret.put(DICT_CODE, CODE_ERROR); - return ret; - } - modmin = utils.stringToInt(smin); - modmax = utils.stringToInt(smax); - } - else - { - modmax = utils.stringToInt(scale); + if (!scale.equals("")) { + if (scaleIdx > 0) + { + java.util.StringTokenizer rng = new java.util.StringTokenizer(scale, DELIM_RANGE); + String smin; + String smax; + if (rng.countTokens() == 2) + { + smin = rng.nextToken(); + smax = rng.nextToken(); + } + else + { + ret.put(DICT_CODE, CODE_ERROR); + return ret; + } + modmin = utils.stringToInt(smin); + modmax = utils.stringToInt(smax); + } + else + { + modmax = utils.stringToInt(scale); + } } if ((modmin < 0) || (modmax <= 0) || (modmin >= modmax)) { @@ -826,10 +746,7 @@ public class skill extends script.base_script { int randomNumber = rand(0, numAvailable - 1); strSkillsNeeded[i] = strSkills[randomNumber]; - for (int j = randomNumber; j < numAvailable - 1; ++j) - { - strSkills[j] = strSkills[j + 1]; - } + System.arraycopy(strSkills, randomNumber + 1, strSkills, randomNumber, numAvailable - 1 - randomNumber); strSkills[--numAvailable] = null; } if (strSkillsNeeded.length > 0) @@ -854,14 +771,12 @@ public class skill extends script.base_script { if (grantSkillToPlayer(player, skillName)) { - prose_package pp = prose.getPackage(PROSE_SKILL_LEARNED, new string_id(SKILL_N, skillName)); - sendSystemMessageProse(player, pp); + sendSystemMessageProse(player, prose.getPackage(PROSE_SKILL_LEARNED, new string_id(SKILL_N, skillName))); return true; } else { - prose_package pp = prose.getPackage(PROSE_TRAIN_FAILED, new string_id(SKILL_N, skillName)); - sendSystemMessageProse(player, pp); + sendSystemMessageProse(player, prose.getPackage(PROSE_TRAIN_FAILED, new string_id(SKILL_N, skillName))); return false; } } @@ -875,7 +790,6 @@ public class skill extends script.base_script } newbieTutorialHighlightUIElement(objPlayer, "/GroundHUD.MFDStatus.vsp.role.targetLevel", 5.0f); setPlayerStatsForLevel(objPlayer, intNewLevel); - return; } public static void setPlayerStatsForLevel(obj_id objPlayer, int intLevel) throws InterruptedException { @@ -957,7 +871,6 @@ public class skill extends script.base_script } recalcPlayerPools(objPlayer, true); } - return; } public static int getPlayerStatForLevel(obj_id player, int intLevel, String statString) throws InterruptedException { @@ -1106,7 +1019,6 @@ public class skill extends script.base_script ppStatGainSpam.digitInteger = actionDelta; sendSystemMessageProse(player, ppStatGainSpam); } - return; } public static String getProfessionName(String strTemplate) throws InterruptedException { @@ -1157,12 +1069,11 @@ public class skill extends script.base_script setMaxAttrib(objPlayer, ACTION, intBaseAction); setMaxAttrib(objPlayer, HEALTH, intBaseHealth); int[] myBuffs = buff.getAllBuffs(objPlayer); - for (int i = 0; i < myBuffs.length; i++) - { - String thisBuffEffect = buff.getEffectParam(myBuffs[i], 1); - float thisBuffValue = buff.getEffectValue(myBuffs[i], 1); - if (thisBuffEffect != null && thisBuffValue < 0 && thisBuffEffect.equals("healthPercent")) - { + String thisBuffEffect; + for (int myBuff : myBuffs) { + thisBuffEffect = buff.getEffectParam(myBuff, 1); + float thisBuffValue = buff.getEffectValue(myBuff, 1); + if (thisBuffEffect != null && thisBuffValue < 0 && thisBuffEffect.equals("healthPercent")) { boolHealEverything = false; break; } @@ -1173,7 +1084,6 @@ public class skill extends script.base_script setAttrib(objPlayer, HEALTH, getMaxAttrib(objPlayer, HEALTH)); } } - return; } public static void grantAllPoliticianSkills(obj_id player) throws InterruptedException { @@ -1199,11 +1109,9 @@ public class skill extends script.base_script "social_politician_master" }; setObjVar(player, "clickRespec.granting", true); - for (int i = 0; i < skillNames.length; i++) - { - if (!hasSkill(player, skillNames[i])) - { - grantSkill(player, skillNames[i]); + for (String skillName : skillNames) { + if (!hasSkill(player, skillName)) { + grantSkill(player, skillName); } } removeObjVar(player, "clickRespec.granting"); @@ -1255,24 +1163,18 @@ public class skill extends script.base_script "class_munitions_phase2_novice", "class_engineering_phase2_novice" }; - for (int i = 0; i < phaseFourSkills.length; i++) - { - if (hasSkill(player, phaseFourSkills[i])) - { + for (String phaseFourSkill : phaseFourSkills) { + if (hasSkill(player, phaseFourSkill)) { return PHASE_FOUR; } } - for (int i = 0; i < phaseThreeSkills.length; i++) - { - if (hasSkill(player, phaseThreeSkills[i])) - { + for (String phaseThreeSkill : phaseThreeSkills) { + if (hasSkill(player, phaseThreeSkill)) { return PHASE_THREE; } } - for (int i = 0; i < phaseTwoSkills.length; i++) - { - if (hasSkill(player, phaseTwoSkills[i])) - { + for (String phaseTwoSkill : phaseTwoSkills) { + if (hasSkill(player, phaseTwoSkill)) { return PHASE_TWO; } } @@ -1312,30 +1214,18 @@ public class skill extends script.base_script profession = "trader_eng"; } } - for (int i = 0; i < expertiseSkills.length; ++i) - { - int row = dataTableSearchColumnForString(expertiseSkills[i], "NAME", DATATABLE_EXPERTISE); - if (row < 0) - { + for (String expertiseSkill : expertiseSkills) { + int row = dataTableSearchColumnForString(expertiseSkill, "NAME", DATATABLE_EXPERTISE); + if (row < 0) { continue; } String reqProf = dataTableGetString(DATATABLE_EXPERTISE, row, "REQ_PROF"); - if (!reqProf.equals(profession)) - { - if (reqProf.equals("trader") && isTrader) - { - continue; - } - else if (reqProf.equals("all")) - { - continue; - } - else - { + if (!reqProf.equals(profession)) { + if ((!reqProf.equals("trader") || !isTrader) && !reqProf.equals("all")) { sendSystemMessage(player, SID_EXPERTISE_WRONG_PROFESSION); utils.fullExpertiseReset(player, false); CustomerServiceLog("SuspectedCheaterChannel: ", "DualProfessionCheat: Player " + getFirstName(player) + "(" + player + ") has an expertise that is not for thier profession. All expertises have been revoked."); - CustomerServiceLog("SuspectedCheaterChannel: ", "DualProfessionCheat: Player " + getFirstName(player) + "(" + player + ")'s profession is " + profession + " and the skill they have is " + expertiseSkills[i] + "."); + CustomerServiceLog("SuspectedCheaterChannel: ", "DualProfessionCheat: Player " + getFirstName(player) + "(" + player + ")'s profession is " + profession + " and the skill they have is " + expertiseSkill + "."); return false; } } diff --git a/sku.0/sys.server/compiled/game/script/library/skill_template.java b/sku.0/sys.server/compiled/game/script/library/skill_template.java old mode 100644 new mode 100755 index 59aed7818..14e7c8241 --- a/sku.0/sys.server/compiled/game/script/library/skill_template.java +++ b/sku.0/sys.server/compiled/game/script/library/skill_template.java @@ -1,14 +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.dictionary; +import script.obj_id; +import script.string_id; -import script.library.utils; +import java.util.Vector; public class skill_template extends script.base_script { @@ -44,11 +40,7 @@ public class skill_template extends script.base_script } public static boolean isValidWorkingSkill(String skillName) throws InterruptedException { - if (skillName == null || skillName.equals("")) - { - return false; - } - return true; + return !(skillName == null || skillName.equals("")); } public static String getNextWorkingSkill(obj_id player) throws InterruptedException { @@ -154,8 +146,7 @@ public class skill_template extends script.base_script return null; } java.util.Enumeration e = xpReqs.keys(); - String xpType = (String)(e.nextElement()); - return xpType; + return (String)(e.nextElement()); } public static boolean isQualifiedForWorkingSkill(obj_id player) throws InterruptedException { @@ -180,11 +171,7 @@ public class skill_template extends script.base_script java.util.Enumeration e = xpReqs.keys(); String xpType = (String)(e.nextElement()); int xpCost = xpReqs.getInt(xpType); - if (getExperiencePoints(player, xpType) < xpCost) - { - return false; - } - return true; + return getExperiencePoints(player, xpType) >= xpCost; } public static boolean earnWorkingSkill(obj_id player) throws InterruptedException { @@ -212,11 +199,9 @@ public class skill_template extends script.base_script { return; } - for (int i = 0; i < skillList.length; i++) - { - if (!hasSkill(player, skillList[i])) - { - setWorkingSkill(player, skillList[i]); + for (String aSkillList : skillList) { + if (!hasSkill(player, aSkillList)) { + setWorkingSkill(player, aSkillList); break; } } @@ -246,36 +231,24 @@ public class skill_template extends script.base_script Vector allNewObjectsResizable = new Vector(); allNewObjectsResizable.setSize(0); boolean success = true; - for (int i = 0; i < items.length; i++) - { - obj_id newItem = null; - if (items[i].endsWith(".iff")) - { - newItem = createObjectInInventoryAllowOverload(items[i], player); + obj_id newItem; + for (String item : items) { + if (item.endsWith(".iff")) { + newItem = createObjectInInventoryAllowOverload(item, player); + } else { + newItem = static_item.createNewItemFunction(item, player); } - else - { - newItem = static_item.createNewItemFunction(items[i], player); - } - if (!isIdValid(newItem)) - { - LOG("roadmap", "ERROR - Could not create roadmap item (" + items[i] + ")"); + if (!isIdValid(newItem)) { + LOG("roadmap", "ERROR - Could not create roadmap item (" + item + ")"); success = false; - } - else - { + } else { utils.addElement(allNewObjectsResizable, newItem); } } string_id itemDesc = utils.unpackString(getRoadmapItemDesc(skillTemplate, skillName)); - prose_package pp = prose.getPackage(new string_id("base_player", "skill_template_item_reward"), itemDesc); - sendSystemMessageProse(player, pp); - obj_id[] allNewObjects = new obj_id[0]; - if (allNewObjectsResizable != null) - { - allNewObjects = new obj_id[allNewObjectsResizable.size()]; - allNewObjectsResizable.toArray(allNewObjects); - } + sendSystemMessageProse(player, prose.getPackage(new string_id("base_player", "skill_template_item_reward"), itemDesc)); + obj_id[] allNewObjects = new obj_id[allNewObjectsResizable.size()]; + allNewObjectsResizable.toArray(allNewObjects); showLootBox(player, allNewObjects); return success; } @@ -288,6 +261,7 @@ public class skill_template extends script.base_script } String[] templateNames = dataTableGetStringColumn(ITEM_REWARD_TABLE, "roadmapTemplateName"); String[] templateSkills = dataTableGetStringColumn(ITEM_REWARD_TABLE, "roadmapSkillName"); + String itemDesc; for (int i = row; i < templateSkills.length; i++) { if (!templateNames[i].equals(skillTemplate)) @@ -296,7 +270,7 @@ public class skill_template extends script.base_script } if (templateSkills[i].equals(workingSkill)) { - String itemDesc = dataTableGetString(ITEM_REWARD_TABLE, i, "stringId"); + itemDesc = dataTableGetString(ITEM_REWARD_TABLE, i, "stringId"); if (itemDesc != null && !itemDesc.equals("")) { return itemDesc; @@ -314,6 +288,10 @@ public class skill_template extends script.base_script } String[] templateNames = dataTableGetStringColumn(ITEM_REWARD_TABLE, "roadmapTemplateName"); String[] templateSkills = dataTableGetStringColumn(ITEM_REWARD_TABLE, "roadmapSkillName"); + String defaultItem; + String wookieeItem; + String ithorianItem; + for (int i = row; i < templateSkills.length; i++) { if (!templateNames[i].equals(skillTemplate)) @@ -322,11 +300,11 @@ public class skill_template extends script.base_script } if (templateSkills[i].equals(workingSkill)) { - String defaultItem = dataTableGetString(ITEM_REWARD_TABLE, i, "itemDefault"); + defaultItem = dataTableGetString(ITEM_REWARD_TABLE, i, "itemDefault"); int species = getSpecies(player); if (species == SPECIES_WOOKIEE) { - String wookieeItem = dataTableGetString(ITEM_REWARD_TABLE, i, "itemWookiee"); + wookieeItem = dataTableGetString(ITEM_REWARD_TABLE, i, "itemWookiee"); if (wookieeItem != null && !wookieeItem.equals("")) { return wookieeItem; @@ -334,7 +312,7 @@ public class skill_template extends script.base_script } else if (species == SPECIES_ITHORIAN) { - String ithorianItem = dataTableGetString(ITEM_REWARD_TABLE, i, "itemIthorian"); + ithorianItem = dataTableGetString(ITEM_REWARD_TABLE, i, "itemIthorian"); if (ithorianItem != null && !ithorianItem.equals("")) { return ithorianItem; diff --git a/sku.0/sys.server/compiled/game/script/library/slicing.java b/sku.0/sys.server/compiled/game/script/library/slicing.java old mode 100644 new mode 100755 index f3839dc4b..62520c093 --- a/sku.0/sys.server/compiled/game/script/library/slicing.java +++ b/sku.0/sys.server/compiled/game/script/library/slicing.java @@ -1,17 +1,11 @@ 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.dictionary; +import script.obj_id; +import script.prose_package; +import script.string_id; -import script.library.sui; -import script.library.utils; -import script.library.jedi; -import script.library.powerup; +import java.util.Vector; public class slicing extends script.base_script { @@ -122,9 +116,10 @@ public class slicing extends script.base_script int rows = dataTableGetNumRows(table); Vector categories = new Vector(); categories.setSize(0); + String is_this_cat; for (int i = 0; i < rows; i++) { - String is_this_cat = dataTableGetString(table, i, "SLICE_CAT"); + is_this_cat = dataTableGetString(table, i, "SLICE_CAT"); if (is_this_cat == null || is_this_cat.equals("")) { continue; @@ -169,9 +164,14 @@ public class slicing extends script.base_script int cats = 0; int type = 0; utils.setScriptVar(player, "slicing.cat", idx); + String is_this_cat; + String slice; + String stat; + String color_prefix; + String status_suffix; for (int i = 0; i < rows; i++) { - String is_this_cat = dataTableGetString(table, i, "SLICE_CAT"); + is_this_cat = dataTableGetString(table, i, "SLICE_CAT"); if (!is_this_cat.equals("")) { cats++; @@ -179,15 +179,15 @@ public class slicing extends script.base_script } if (cats == idx) { - String slice = dataTableGetString(table, i, "SLICE"); - String stat = dataTableGetString(table, i, "STAT"); + slice = dataTableGetString(table, i, "SLICE"); + stat = dataTableGetString(table, i, "STAT"); int req = dataTableGetInt(table, i, "SKILL_REQ"); int rank = dataTableGetInt(table, i, "RANK"); int cur_rank = getIntObjVar(item, "slice.rank." + stat); if (skillMod >= req) { - String color_prefix = ""; - String status_suffix = ""; + color_prefix = ""; + status_suffix = ""; if (rank > cur_rank + 1) { color_prefix = "\\#888888"; @@ -208,7 +208,6 @@ public class slicing extends script.base_script } public static void handleSlicingSelect(obj_id player, int idx) throws InterruptedException { - int cat = utils.getIntScriptVar(player, "slicing.cat"); int row = utils.getIntScriptVar(player, "slicing." + idx); obj_id item = utils.getObjIdScriptVar(player, "slicing.slice_item"); String query = utils.getStringScriptVar(player, "slicing.type"); @@ -262,7 +261,6 @@ public class slicing extends script.base_script apply_status = new string_id("slicing/slicing", "cant_apply_cost"); utils.setScriptVar(player, "slicing.apply_status", 5); } - String component_line = null; String component = effect.getString("COMPONENT"); String component_path = "object/tangible/smuggler/" + component + ".iff"; string_id component_sid = new string_id("smuggler/items", component); @@ -271,11 +269,8 @@ public class slicing extends script.base_script obj_id pInv = utils.getInventoryContainer(player); obj_id[] contents = utils.getContents(pInv, true); int found = 0; - for (int i = 0; i < contents.length; i++) - { - String tn = getTemplateName(contents[i]); - if (tn.equals(component_path)) - { + for (obj_id content : contents) { + if (getTemplateName(content).equals(component_path)) { found = 1; break; } @@ -357,13 +352,10 @@ public class slicing extends script.base_script obj_id pInv = utils.getInventoryContainer(player); obj_id[] contents = utils.getContents(pInv, true); int found = 0; - for (int i = 0; i < contents.length; i++) - { - String tn = getTemplateName(contents[i]); - if (tn.equals(component_path)) - { + for (obj_id content : contents) { + if (getTemplateName(content).equals(component_path)) { found = 1; - consumeComponent(contents[i]); + consumeComponent(content); break; } } diff --git a/sku.0/sys.server/compiled/game/script/library/slots.java b/sku.0/sys.server/compiled/game/script/library/slots.java old mode 100644 new mode 100755 index 9c9d43527..922bc21fa --- a/sku.0/sys.server/compiled/game/script/library/slots.java +++ b/sku.0/sys.server/compiled/game/script/library/slots.java @@ -1,12 +1,8 @@ package script.library; -import script.*; -import script.base_class.*; -import script.combat_engine.*; -import java.util.Arrays; -import java.util.Hashtable; +import script.obj_id; + import java.util.Vector; -import script.base_script; public class slots extends script.base_script { @@ -81,12 +77,10 @@ public class slots extends script.base_script } Vector ret = new Vector(); ret.setSize(0); - for (int i = 0; i < slots.length; i++) - { - String name = slots[i]; - obj_id item = getObjectInSlot(target, name); - if (isIdValid(item)) - { + obj_id item; + for (String name : slots) { + item = getObjectInSlot(target, name); + if (isIdValid(item)) { ret = utils.addElement(ret, name); } } @@ -95,11 +89,8 @@ public class slots extends script.base_script return null; } String[] _ret = new String[0]; - if (ret != null) - { - _ret = new String[ret.size()]; - ret.toArray(_ret); - } + _ret = new String[ret.size()]; + ret.toArray(_ret); return _ret; } public static String[] getOccupiedEqSlots(obj_id target) throws InterruptedException diff --git a/sku.0/sys.server/compiled/game/script/library/spawning.java b/sku.0/sys.server/compiled/game/script/library/spawning.java old mode 100644 new mode 100755 index 62d86ee16..0a4fea374 --- a/sku.0/sys.server/compiled/game/script/library/spawning.java +++ b/sku.0/sys.server/compiled/game/script/library/spawning.java @@ -1,15 +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.dictionary; +import script.location; +import script.obj_id; -import script.library.utils; -import script.library.space_utils; +import java.util.Vector; public class spawning extends script.base_script { @@ -24,7 +19,6 @@ public class spawning extends script.base_script return; } messageTo(objSpawners[rand(0, objSpawners.length - 1)], "doSpawnEvent", null, 0, false); - return; } public static location getRandomLocationInCircle(location locTest, float fltSize) throws InterruptedException { @@ -55,11 +49,7 @@ public class spawning extends script.base_script { int intSpawnCount = getIntObjVar(self, "intSpawnCount"); int intCurrentSpawnCount = utils.getIntScriptVar(self, "intCurrentSpawnCount"); - if (intCurrentSpawnCount >= intSpawnCount) - { - return false; - } - return true; + return intCurrentSpawnCount < intSpawnCount; } public static void incrementSpawnCount(obj_id self) throws InterruptedException { @@ -70,7 +60,6 @@ public class spawning extends script.base_script { utils.setScriptVar(self, "intCurrentSpawnCount", intCurrentSpawnCount); } - return; } public static void addToSpawnDebugList(obj_id self, obj_id spawned) throws InterruptedException { @@ -98,9 +87,8 @@ public class spawning extends script.base_script obj_id[] objContents = getContents(objParent); if ((objContents != null) && (objContents.length > 0)) { - for (int intI = 0; intI < objContents.length; intI++) - { - getObjectsWithObjVar(objContents[intI], strObjVarName, objArray); + for (obj_id objContent : objContents) { + getObjectsWithObjVar(objContent, strObjVarName, objArray); } } return objArray; @@ -110,14 +98,12 @@ public class spawning extends script.base_script Vector objContents = new Vector(); objContents.setSize(0); obj_id[] objCells = getContents(objObject); - for (int intI = 0; intI < objCells.length; intI++) - { - obj_id[] objTestContents = getContents(objCells[intI]); - if ((objTestContents != null) && (objTestContents.length > 0)) - { - for (int intJ = 0; intJ < objTestContents.length; intJ++) - { - objContents = utils.addElement(objContents, objTestContents[intJ]); + obj_id[] objTestContents; + for (obj_id objCell : objCells) { + objTestContents = getContents(objCell); + if ((objTestContents != null) && (objTestContents.length > 0)) { + for (obj_id objTestContent : objTestContents) { + objContents = utils.addElement(objContents, objTestContent); } } } @@ -147,19 +133,17 @@ public class spawning extends script.base_script Vector spawnedList = utils.getResizeableObjIdArrayScriptVar(spawner, "myCreations"); for (int i = 0; i < spawnedList.size(); i++) { - if (((obj_id)spawnedList.get(i)) == deadGuy) + if (spawnedList.get(i) == deadGuy) { - spawnedList.remove(((obj_id)spawnedList.get(i))); + spawnedList.remove(spawnedList.get(i)); continue; } - if (((obj_id)spawnedList.get(i)) == null) + if (spawnedList.get(i) == null) { - spawnedList.remove(((obj_id)spawnedList.get(i))); - continue; + spawnedList.remove(spawnedList.get(i)); } } utils.setScriptVar(spawner, "myCreations", spawnedList); - return; } public static obj_id createSpawnInLegacyCell(obj_id dungeon, location creatureLocation, String creatureName) throws InterruptedException { @@ -207,14 +191,24 @@ public class spawning extends script.base_script { return false; } + dictionary objToSpawn; + String object; + String spawnRoom; + obj_id room; + obj_id objectCreated; + String script; + String[] scripts; + String objVars; + String objName; + for (int i = 0; i < numberOfObjectsToSpawn; i++) { - dictionary objToSpawn = dataTableGetRow(table, i); + objToSpawn = dataTableGetRow(table, i); if (objToSpawn == null) { continue; } - String object = objToSpawn.getString("object"); + object = objToSpawn.getString("object"); if (object == null || object.length() <= 0) { continue; @@ -223,46 +217,44 @@ public class spawning extends script.base_script float yCoord = objToSpawn.getFloat("loc_y"); float zCoord = objToSpawn.getFloat("loc_z"); float yaw = objToSpawn.getFloat("yaw"); - String spawnRoom = objToSpawn.getString("room"); + spawnRoom = objToSpawn.getString("room"); if (spawnRoom == null || spawnRoom.length() <= 0) { continue; } - obj_id room = getCellId(dungeon, spawnRoom); + room = getCellId(dungeon, spawnRoom); if (!isValidId(room)) { continue; } - location objectLocation = new location(xCoord, yCoord, zCoord, planet, room); - obj_id objectCreated = createObject(object, objectLocation); + objectCreated = createObject(object, new location(xCoord, yCoord, zCoord, planet, room)); if (!isValidId(objectCreated)) { continue; } setYaw(objectCreated, yaw); - String script = objToSpawn.getString("script"); + script = objToSpawn.getString("script"); if (script != null && script.length() > 0) { - String[] scripts = split(script, ','); - for (int j = 0; j < scripts.length; j++) - { - if (!hasScript(objectCreated, scripts[j])) - { - attachScript(objectCreated, scripts[j]); + scripts = split(script, ','); + for (String script1 : scripts) { + if (!hasScript(objectCreated, script1)) { + attachScript(objectCreated, script1); } } } - String objVars = objToSpawn.getString("objvar"); + objVars = objToSpawn.getString("objvar"); if (objVars != null && objVars.length() > 0) { utils.setObjVarsListUsingSemiColon(objectCreated, objVars); } - String objName = objToSpawn.getString("name"); + objName = objToSpawn.getString("name"); if (objName != null && objName.length() > 0) { setName(objectCreated, objName); } } + return true; } } diff --git a/sku.0/sys.server/compiled/game/script/library/squad_leader.java b/sku.0/sys.server/compiled/game/script/library/squad_leader.java old mode 100644 new mode 100755 index a8aa6565e..3b2beecd9 --- a/sku.0/sys.server/compiled/game/script/library/squad_leader.java +++ b/sku.0/sys.server/compiled/game/script/library/squad_leader.java @@ -1,16 +1,8 @@ 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.library.chat; -import script.library.skill; -import script.library.prose; +import java.util.Vector; public class squad_leader extends script.base_script { @@ -40,22 +32,20 @@ public class squad_leader extends script.base_script ++i; } command = command.substring(i, textlen); - if (command == null || command.equals("")) + if (command.equals("")) { sendSystemMessage(squadLeader, SID_MESSAGE_PARAMETERS); return; } if (groupMembers != null) { - for (int j = 0; j < groupMembers.length; ++j) - { - displayCommand(squadLeader, groupMembers[j], command); + for (obj_id groupMember : groupMembers) { + displayCommand(squadLeader, groupMember, command); } } else { sendSystemMessage(squadLeader, SID_NOT_IN_A_GROUP); - return; } } public static boolean sendSquadWaypoint(obj_id officer, location wayLoc) throws InterruptedException @@ -64,15 +54,13 @@ public class squad_leader extends script.base_script { return false; } - obj_id groupId = getGroupObject(officer); - obj_id[] groupMembers = getGroupMemberIds(groupId); + obj_id[] groupMembers = getGroupMemberIds(getGroupObject(officer)); dictionary dict = new dictionary(); dict.put("wayLoc", wayLoc); if (groupMembers != null) { - for (int i = 0; i < groupMembers.length; ++i) - { - messageTo(groupMembers[i], "createOfficerGroupWaypoint", dict, 0, false); + for (obj_id groupMember : groupMembers) { + messageTo(groupMember, "createOfficerGroupWaypoint", dict, 0, false); } } else @@ -86,13 +74,7 @@ public class squad_leader extends script.base_script { if (groupMember != null) { - prose_package pp = prose.getPackage(SID_SYS_SL, getName(squadLeader), command); - sendSystemMessageProse(groupMember, pp); - return; - } - else - { - return; + sendSystemMessageProse(groupMember, prose.getPackage(SID_SYS_SL, getName(squadLeader), command)); } } public static boolean hasSkillsToSendCommand(obj_id squadLeader, int groupSize) throws InterruptedException @@ -100,11 +82,7 @@ public class squad_leader extends script.base_script String skillPointScale = MIN_SKILL_VALUE + ".." + MAX_SKILL_VALUE; int percent = skill.check(squadLeader, SKILL_NAME, skillPointScale); int groupPercent = groupSize / MAX_GROUP_SIZE; - if (percent >= groupPercent) - { - return true; - } - return false; + return percent >= groupPercent; } public static obj_id[] getSquadTargets(obj_id self, String requiredSkill) throws InterruptedException { @@ -149,17 +127,10 @@ public class squad_leader extends script.base_script { obj_id self = getSelf(); String varName = "combat." + command + "String"; - String text = getStringObjVar(self, varName); - return text; + return getStringObjVar(self, varName); } public static void barkSquadCommand(String command, String defaultText) throws InterruptedException { - obj_id self = getSelf(); - String text = getSquadCommandText(command); - if ((text == null) || text.equals("")) - { - text = defaultText; - } } public static obj_id[] getValidGroupMembers(obj_id self) throws InterruptedException { @@ -171,13 +142,11 @@ public class squad_leader extends script.base_script obj_id[] groupMembers = getGroupMemberIds(gid); Vector validMembers = new Vector(); validMembers.setSize(0); - for (int i = 0; i < groupMembers.length; i++) - { - if (!(isIdValid(groupMembers[i]) && exists(groupMembers[i]) && isPlayer(groupMembers[i]) && getDistance(self, groupMembers[i]) < 64.0f)) - { + for (obj_id groupMember : groupMembers) { + if (!(isIdValid(groupMember) && exists(groupMember) && isPlayer(groupMember) && getDistance(self, groupMember) < 64.0f)) { continue; } - validMembers = utils.addElement(validMembers, groupMembers[i]); + validMembers = utils.addElement(validMembers, groupMember); } obj_id[] _validMembers = new obj_id[0]; if (validMembers != null) @@ -206,8 +175,7 @@ public class squad_leader extends script.base_script { return; } - obj_id rallyPoint = getObjIdObjVar(player, "sl.rallyPoint.id"); - destroyWaypointInDatapad(rallyPoint, player); + destroyWaypointInDatapad(getObjIdObjVar(player, "sl.rallyPoint.id"), player); removeObjVar(player, "sl.rallyPoint"); } public static int getCalledShotAccuracyBonus(obj_id attacker, obj_id defender) throws InterruptedException @@ -260,7 +228,6 @@ public class squad_leader extends script.base_script { skillMod = 200; } - float modifier = (skillMod + 75f) / 200f; - return modifier; + return (skillMod + 75f) / 200f; } } diff --git a/sku.0/sys.server/compiled/game/script/library/static_item.java b/sku.0/sys.server/compiled/game/script/library/static_item.java old mode 100644 new mode 100755 index e2993327c..2ae699f2c --- a/sku.0/sys.server/compiled/game/script/library/static_item.java +++ b/sku.0/sys.server/compiled/game/script/library/static_item.java @@ -1,18 +1,9 @@ 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.library.jedi; -import java.lang.Math; -import script.library.loot; -import script.library.pgc_quests; -import script.library.storyteller; +import script.dictionary; +import script.location; +import script.obj_id; +import script.string_id; public class static_item extends script.base_script { @@ -73,8 +64,7 @@ public class static_item extends script.base_script return null; } } - dictionary itemData = new dictionary(); - itemData = dataTableGetRow(MASTER_ITEM_TABLE, itemName); + dictionary itemData = dataTableGetRow(MASTER_ITEM_TABLE, itemName); if (charges > 0) { itemData.put("charges", itemData.getInt("charges") + charges); @@ -134,21 +124,19 @@ public class static_item extends script.base_script } public static void initializeObject(obj_id object, dictionary itemData) throws InterruptedException { - String scriptList = itemData.getString("scripts"); String itemName = itemData.getString("name"); if (itemName == null || itemName.equals("")) { LOG("create", object + " InitializeObject FAILED: No NAME field in datatable or bad dictionary passed in"); return; } + String scriptList = itemData.getString("scripts"); if (scriptList != null && !scriptList.equals("")) { String[] scriptArray = split(scriptList, ','); - for (int i = 0; i < scriptArray.length; i++) - { - if (!hasScript(object, scriptArray[i])) - { - attachScript(object, scriptArray[i]); + for (String aScriptArray : scriptArray) { + if (!hasScript(object, aScriptArray)) { + attachScript(object, aScriptArray); } } } @@ -180,17 +168,15 @@ public class static_item extends script.base_script case 5: break; } - return; } public static boolean initializeArmor(obj_id object, String itemName) throws InterruptedException { - dictionary itemData = new dictionary(); int row = dataTableSearchColumnForString(itemName, 0, ARMOR_STAT_BALANCE_TABLE); if (row == -1) { return false; } - itemData = dataTableGetRow(ARMOR_STAT_BALANCE_TABLE, row); + dictionary itemData = dataTableGetRow(ARMOR_STAT_BALANCE_TABLE, row); float condition = itemData.getFloat("condition_multiplier"); float generalProtection = itemData.getFloat("protection"); int armorLevel = itemData.getInt("armor_level"); @@ -223,34 +209,22 @@ public class static_item extends script.base_script if (attributeBonus != null && !attributeBonus.equals("")) { String[] stringArray = split(attributeBonus, ','); - for (int i = 0; i < stringArray.length; i++) - { - String[] attributeArray = split(stringArray[i], '='); - for (int x = 0; x < attributeArray.length; x++) - { + String[] attributeArray; + for (String aStringArray : stringArray) { + attributeArray = split(aStringArray, '='); + for (String anAttributeArray : attributeArray) { int attribute = 0; - if (attributeArray[0].equalsIgnoreCase("health")) - { + if (attributeArray[0].equalsIgnoreCase("health")) { attribute = HEALTH; - } - else if (attributeArray[0].equalsIgnoreCase("action")) - { + } else if (attributeArray[0].equalsIgnoreCase("action")) { attribute = ACTION; - } - else if (attributeArray[0].equalsIgnoreCase("mind")) - { + } else if (attributeArray[0].equalsIgnoreCase("mind")) { attribute = MIND; - } - else if (attributeArray[0].equalsIgnoreCase("constitution")) - { + } else if (attributeArray[0].equalsIgnoreCase("constitution")) { attribute = CONSTITUTION; - } - else if (attributeArray[0].equalsIgnoreCase("stamina")) - { + } else if (attributeArray[0].equalsIgnoreCase("stamina")) { attribute = STAMINA; - } - else if (attributeArray[0].equalsIgnoreCase("willpower")) - { + } else if (attributeArray[0].equalsIgnoreCase("willpower")) { attribute = WILLPOWER; } setAttributeBonus(object, attribute, utils.stringToInt(attributeArray[1])); @@ -261,9 +235,11 @@ public class static_item extends script.base_script if (dict != null) { java.util.Enumeration keys = dict.keys(); + String skillModName; + while (keys.hasMoreElements()) { - String skillModName = (String)keys.nextElement(); + skillModName = (String)keys.nextElement(); int skillModValue = dict.getInt(skillModName); setSkillModBonus(object, skillModName, skillModValue); } @@ -275,11 +251,10 @@ public class static_item extends script.base_script if (colorMods != null && !colorMods.equals("")) { String[] colorArray = split(colorMods, ','); - for (int i = 0; i < colorArray.length; i++) - { - String[] colorIndex = split(colorArray[i], '='); - for (int x = 0; x < colorIndex.length; x++) - { + String[] colorIndex; + for (String aColorArray : colorArray) { + colorIndex = split(aColorArray, '='); + for (String aColorIndex : colorIndex) { hue.setColor(object, "/private/" + colorIndex[0], Integer.parseInt(colorIndex[1])); } } @@ -288,13 +263,12 @@ public class static_item extends script.base_script } public static boolean initializeWeapon(obj_id object, String itemName) throws InterruptedException { - dictionary itemData = new dictionary(); int row = dataTableSearchColumnForString(itemName, 0, WEAPON_STAT_BALANCE_TABLE); if (row == -1) { return false; } - itemData = dataTableGetRow(WEAPON_STAT_BALANCE_TABLE, row); + dictionary itemData = dataTableGetRow(WEAPON_STAT_BALANCE_TABLE, row); int minDamage = itemData.getInt("min_damage"); int maxDamage = itemData.getInt("max_damage"); int attackSpeed = itemData.getInt("attack_speed"); @@ -342,9 +316,11 @@ public class static_item extends script.base_script if (dict != null) { java.util.Enumeration keys = dict.keys(); + String skillModName; + while (keys.hasMoreElements()) { - String skillModName = (String)keys.nextElement(); + skillModName = (String)keys.nextElement(); int skillModValue = dict.getInt(skillModName); setSkillModBonus(object, skillModName, skillModValue); } @@ -368,26 +344,18 @@ public class static_item extends script.base_script if (attributeBonus != null && !attributeBonus.equals("")) { String[] stringArray = split(attributeBonus, ','); - for (int i = 0; i < stringArray.length; i++) - { - String[] attributeArray = split(stringArray[i], '='); - for (int x = 0; x < attributeArray.length; x++) - { + String[] attributeArray; + for (String aStringArray : stringArray) { + attributeArray = split(aStringArray, '='); + for (String anAttributeArray : attributeArray) { int attribute = 0; - if (attributeArray[0].equalsIgnoreCase("health")) - { + if (attributeArray[0].equalsIgnoreCase("health")) { attribute = HEALTH; - } - else if (attributeArray[0].equalsIgnoreCase("action")) - { + } else if (attributeArray[0].equalsIgnoreCase("action")) { attribute = ACTION; - } - else if (attributeArray[0].equalsIgnoreCase("constitution")) - { + } else if (attributeArray[0].equalsIgnoreCase("constitution")) { attribute = CONSTITUTION; - } - else if (attributeArray[0].equalsIgnoreCase("stamina")) - { + } else if (attributeArray[0].equalsIgnoreCase("stamina")) { attribute = STAMINA; } setAttributeBonus(object, attribute, utils.stringToInt(attributeArray[1])); @@ -398,9 +366,10 @@ public class static_item extends script.base_script if (dict != null) { java.util.Enumeration keys = dict.keys(); + String skillModName; while (keys.hasMoreElements()) { - String skillModName = (String)keys.nextElement(); + skillModName = (String)keys.nextElement(); int skillModValue = dict.getInt(skillModName); setSkillModBonus(object, skillModName, skillModValue); } @@ -412,11 +381,10 @@ public class static_item extends script.base_script if (colorMods != null && !colorMods.equals("")) { String[] colorArray = split(colorMods, ','); - for (int i = 0; i < colorArray.length; i++) - { - String[] colorIndex = split(colorArray[i], '='); - for (int x = 0; x < colorIndex.length; x++) - { + String[] colorIndex; + for (String aColorArray : colorArray) { + colorIndex = split(aColorArray, '='); + for (String aColorIndex : colorIndex) { hue.setColor(object, "/private/" + colorIndex[0], Integer.parseInt(colorIndex[1])); } } @@ -425,7 +393,6 @@ public class static_item extends script.base_script } public static boolean initializeStorytellerObject(obj_id newObject, String itemName) throws InterruptedException { - dictionary itemData = new dictionary(); if (!dataTableOpen(storyteller.STORYTELLER_DATATABLE)) { return false; @@ -435,13 +402,10 @@ public class static_item extends script.base_script { return false; } - itemData = dataTableGetRow(storyteller.STORYTELLER_DATATABLE, row); - String template = itemData.getString("template_name"); + dictionary itemData = dataTableGetRow(storyteller.STORYTELLER_DATATABLE, row); int type = itemData.getInt("type"); - String objvarString = itemData.getString("objvar"); - String scriptString = itemData.getString("scripts"); - setObjVarString(newObject, objvarString, type); - setScriptString(newObject, scriptString, type); + setObjVarString(newObject, itemData.getString("objvar"), type); + setScriptString(newObject, itemData.getString("scripts"), type); String name = getString(new string_id("static_item_n", itemName)) + getString(new string_id("storyteller", "token_label")); if (pgc_quests.isPgcRelicObject(newObject)) { @@ -456,34 +420,12 @@ public class static_item extends script.base_script } public static void setObjVarString(obj_id object, String objVarString, int type) throws InterruptedException { - switch (type) - { - case storyteller.PROP: - break; - case storyteller.STATIC_EFFECT: - break; - case storyteller.IMMEDIATE_EFFECT: - break; - case storyteller.COMBAT_NPC: - break; - case storyteller.FLAVOR_NPC: - break; - case storyteller.OTHER: - break; - case storyteller.THEATER: - break; - } if (objVarString != null && objVarString.length() > 0) { - if (objVarString.equals("none")) - { - } - else - { + if (!objVarString.equals("none")) { utils.setObjVarsList(object, objVarString); } } - return; } public static void setScriptString(obj_id object, String scriptString) throws InterruptedException { @@ -494,25 +436,21 @@ public class static_item extends script.base_script switch (type) { case storyteller.PROP: - attachScript(object, "systems.storyteller.prop_token"); - break; + attachScript(object, "systems.storyteller.prop_token"); + break; case storyteller.STATIC_EFFECT: - attachScript(object, "systems.storyteller.effect_token"); - break; case storyteller.IMMEDIATE_EFFECT: - attachScript(object, "systems.storyteller.effect_token"); - break; + attachScript(object, "systems.storyteller.effect_token"); + break; case storyteller.COMBAT_NPC: - attachScript(object, "systems.storyteller.npc_token"); - break; case storyteller.FLAVOR_NPC: - attachScript(object, "systems.storyteller.npc_token"); - break; + attachScript(object, "systems.storyteller.npc_token"); + break; case storyteller.OTHER: - break; + break; case storyteller.THEATER: - attachScript(object, "systems.storyteller.theater_token"); - break; + attachScript(object, "systems.storyteller.theater_token"); + break; } if (scriptString == null || scriptString.equals("") || scriptString.equals("none")) { @@ -523,19 +461,13 @@ public class static_item extends script.base_script { return; } - for (int i = 0; i < parse.length; i++) - { - attachScript(object, parse[i]); + for (String aParse : parse) { + attachScript(object, aParse); } } public static boolean validateLevelRequired(obj_id player, int requiredLevel) throws InterruptedException { - int playerLevel = getLevel(player); - if (playerLevel < requiredLevel) - { - return false; - } - return true; + return getLevel(player) >= requiredLevel; } public static boolean validateLevelRequired(obj_id player, obj_id item) throws InterruptedException { @@ -597,33 +529,27 @@ public class static_item extends script.base_script } int count = getCount(item); int newCount = count - amount; - if (count < amount) - { - return; - } - else if (newCount <= 0) - { - destroyObject(item); - } - else - { - setCount(item, newCount); + if (count >= amount) { + if (newCount <= 0) + { + destroyObject(item); + } + else + { + setCount(item, newCount); + } } } public static void decrementUnstackedStaticItemAmount(obj_id[] items, int amount) throws InterruptedException { int totalCount = amount; - for (int i = 0; i < items.length; i++) - { - int itemCount = getCount(items[i]); - if (itemCount <= totalCount) - { - destroyObject(items[i]); - } - else if (itemCount > totalCount) - { + for (obj_id item : items) { + int itemCount = getCount(item); + if (itemCount <= totalCount) { + destroyObject(item); + } else if (itemCount > totalCount) { totalCount = itemCount - totalCount; - setCount(items[i], totalCount); + setCount(item, totalCount); return; } totalCount = totalCount - itemCount; @@ -636,8 +562,7 @@ public class static_item extends script.base_script LOG("create", " Bad itemName passed into the getMasterItemDictionary " + itemName); return null; } - dictionary itemData = new dictionary(); - itemData = dataTableGetRow(MASTER_ITEM_TABLE, itemName); + dictionary itemData = dataTableGetRow(MASTER_ITEM_TABLE, itemName); if (itemData == null) { LOG("create", itemName + " Initalize from getMasterItemDictionary could not happen because row in datatable is bad"); @@ -666,14 +591,7 @@ public class static_item extends script.base_script public static boolean isStaticItem(obj_id item) throws InterruptedException { String itemName = getStaticItemName(item); - if (itemName == null || itemName.equals("")) - { - return false; - } - else - { - return true; - } + return !(itemName == null || itemName.equals("")); } public static boolean isStaticItem(String itemName) throws InterruptedException { @@ -699,14 +617,14 @@ public class static_item extends script.base_script switch (getStaticObjectType(itemName)) { case 1: - itemData = getStaticItemWeaponDictionary(itemName); - break; + itemData = getStaticItemWeaponDictionary(itemName); + break; case 2: - itemData = getStaticArmorDictionary(itemName); - break; + itemData = getStaticArmorDictionary(itemName); + break; case 3: - itemData = getStaticItemDictionary(itemName); - break; + itemData = getStaticItemDictionary(itemName); + break; } return itemData; } @@ -717,8 +635,7 @@ public class static_item extends script.base_script LOG("create", " Itemname is Bad " + itemName); return null; } - dictionary itemData = new dictionary(); - itemData = dataTableGetRow(WEAPON_STAT_BALANCE_TABLE, itemName); + dictionary itemData = dataTableGetRow(WEAPON_STAT_BALANCE_TABLE, itemName); if (itemData == null) { LOG("create", itemName + " Initalize from getStaticItemWeaponDictionary could not happen because row in datatable is bad"); @@ -745,8 +662,7 @@ public class static_item extends script.base_script LOG("create", " Itemname is Bad " + itemName); return null; } - dictionary itemData = new dictionary(); - itemData = dataTableGetRow(ITEM_STAT_BALANCE_TABLE, itemName); + dictionary itemData = dataTableGetRow(ITEM_STAT_BALANCE_TABLE, itemName); if (itemData == null) { LOG("create", itemName + " Initalize from getStaticItemDictionary could not happen because row in datatable is bad"); @@ -773,8 +689,7 @@ public class static_item extends script.base_script LOG("create", " Itemname is Bad " + itemName); return null; } - dictionary itemData = new dictionary(); - itemData = dataTableGetRow(ARMOR_STAT_BALANCE_TABLE, itemName); + dictionary itemData = dataTableGetRow(ARMOR_STAT_BALANCE_TABLE, itemName); if (itemData == null) { LOG("create", itemName + " Initalize from getStaticArmorDictionary could not happen because row in datatable is bad"); @@ -796,18 +711,16 @@ public class static_item extends script.base_script } public static void versionUpdate(obj_id self, dictionary itemData) throws InterruptedException { - String itemName = itemData.getString("name"); - obj_id player = utils.getContainingPlayer(self); - obj_id bioLink = getBioLink(self); - String currentTemplate = getTemplateName(self); String staticName = getStaticItemName(self); - if (staticName.equals("") || staticName == null) + if (staticName.equals("")) { return; } int itemRow = dataTableSearchColumnForString(staticName, "name", MASTER_ITEM_TABLE); String tableTemplate = dataTableGetString(MASTER_ITEM_TABLE, itemRow, "template_name"); - if (!currentTemplate.equals(tableTemplate)) + obj_id player = utils.getContainingPlayer(self); + obj_id bioLink = getBioLink(self); + if (!getTemplateName(self).equals(tableTemplate)) { CustomerServiceLog("versionUpdate: ", "Old Item's (" + self + ") object template has changed. A new one must be created."); obj_id container = getContainedBy(self); @@ -859,6 +772,7 @@ public class static_item extends script.base_script { setBioLink(self, bioLink); } + String itemName = itemData.getString("name"); setStaticItemName(self, itemName); String objVarList = itemData.getString("creation_objvars"); if (objVarList != null && !objVarList.equals("")) @@ -872,28 +786,24 @@ public class static_item extends script.base_script setCount(self, chargeList); } initializeObject(self, itemData); - return; } public static void validateWornEffects(obj_id player) throws InterruptedException { obj_id[] equipSlots = metrics.getWornItems(player); if (equipSlots != null && equipSlots.length > 0) { - for (int i = 0; i < equipSlots.length; i++) - { - String itemName = getStaticItemName(equipSlots[i]); - if (itemName != null && !itemName.equals("")) - { - dictionary itemData = getStaticObjectTypeDictionary(itemName); - if (itemData != null) - { + String itemName; + dictionary itemData; + for (obj_id equipSlot : equipSlots) { + itemName = getStaticItemName(equipSlot); + if (itemName != null && !itemName.equals("")) { + itemData = getStaticObjectTypeDictionary(itemName); + if (itemData != null) { String buffName = itemData.getString("buff_name"); - if (buffName != null && !buffName.equals("")) - { - if (validateLevelRequiredForWornEffect(player, (equipSlots[i]))) - { - applyWornBuffs(equipSlots[i], getContainedBy(equipSlots[i])); - checkForAddSetBonus(equipSlots[i], getContainedBy(equipSlots[i])); + if (buffName != null && !buffName.equals("")) { + if (validateLevelRequiredForWornEffect(player, (equipSlot))) { + applyWornBuffs(equipSlot, getContainedBy(equipSlot)); + checkForAddSetBonus(equipSlot, getContainedBy(equipSlot)); } } } @@ -930,35 +840,29 @@ public class static_item extends script.base_script return; } String buffName = itemData.getString("buff_name"); - String clientEffect = itemData.getString("client_effect"); - int requiredLevel = itemData.getInt("required_level_for_effect"); - int playerLevel = getLevel(player); if (buffName == null || buffName.equals("")) { LOG("create", "Worn Buff Name is bad"); return; } - if (static_item.validateLevelRequired(player, requiredLevel)) + if (static_item.validateLevelRequired(player, itemData.getInt("required_level_for_effect"))) { if (buff.canApplyBuff(player, buffName)) { buff.applyBuff(player, player, buffName); - playClientEffectObj(player, clientEffect, player, ""); + playClientEffectObj(player, itemData.getString("client_effect"), player, ""); } else { utils.setScriptVar(self, "buffNotApplied", true); sendSystemMessage(player, ALREADY_HAVE_SIMILAR_BUFF); - return; } } else { utils.setScriptVar(self, "buffNotApplied", true); sendSystemMessage(player, SID_ITEM_LEVEL_TOO_LOW); - return; } - return; } public static void removeWornBuffs(obj_id self, obj_id player) throws InterruptedException { @@ -988,7 +892,6 @@ public class static_item extends script.base_script { utils.removeScriptVar(self, "buffNotApplied"); } - return; } public static void checkForAddSetBonus(obj_id item, obj_id player) throws InterruptedException { @@ -1010,7 +913,6 @@ public class static_item extends script.base_script } } } - return; } public static void checkForRemoveSetBonus(obj_id item, obj_id player) throws InterruptedException { @@ -1032,7 +934,7 @@ public class static_item extends script.base_script buff.removeBuff(player, setBonusBuffName); } String lowerSetBonusBuffName = getSetBonusBuffName(item, setBonusIndex, numberOfSetItems); - if (!lowerSetBonusBuffName.equals(null) && !lowerSetBonusBuffName.equals("none")) + if (lowerSetBonusBuffName != null && !lowerSetBonusBuffName.equals("none")) { if (!buff.hasBuff(player, lowerSetBonusBuffName)) { @@ -1042,7 +944,7 @@ public class static_item extends script.base_script else { lowerSetBonusBuffName = getSetBonusBuffName(item, setBonusIndex, (numberOfSetItems - 1)); - if (!lowerSetBonusBuffName.equals(null) && !lowerSetBonusBuffName.equals("none")) + if (lowerSetBonusBuffName !=null && !lowerSetBonusBuffName.equals("none")) { if (!buff.hasBuff(player, lowerSetBonusBuffName)) { @@ -1051,7 +953,6 @@ public class static_item extends script.base_script } } } - return; } public static boolean isSetBonusItem(obj_id item) throws InterruptedException { @@ -1084,12 +985,9 @@ public class static_item extends script.base_script obj_id[] equippedItems = metrics.getWornItems(player); if (equippedItems != null && equippedItems.length > 0) { - for (int i = 0; i < equippedItems.length; i++) - { - if (isSetBonusItem(equippedItems[i])) - { - if (setBonusIndex == getSetBonusIndex(equippedItems[i])) - { + for (obj_id equippedItem : equippedItems) { + if (isSetBonusItem(equippedItem)) { + if (setBonusIndex == getSetBonusIndex(equippedItem)) { numSetItems++; } } @@ -1115,8 +1013,7 @@ public class static_item extends script.base_script } public static String getItemType(String itemName) throws InterruptedException { - dictionary itemData = new dictionary(); - itemData = dataTableGetRow(MASTER_ITEM_TABLE, itemName); + dictionary itemData = dataTableGetRow(MASTER_ITEM_TABLE, itemName); if (itemData == null) { return ""; @@ -1137,24 +1034,24 @@ public class static_item extends script.base_script dictionary masterItemData = getMasterItemDictionary(itemName); String itemType = static_item.getItemType(itemName); dictionary specificItemData = null; - if (itemType.equals("weapon")) - { - specificItemData = getStaticItemWeaponDictionary(itemName); - } - else if (itemType.equals("armor")) - { - specificItemData = getStaticArmorDictionary(itemName); - } - else if (itemType.equals("item")) - { - specificItemData = getStaticItemDictionary(itemName); + switch (itemType) { + case "weapon": + specificItemData = getStaticItemWeaponDictionary(itemName); + break; + case "armor": + specificItemData = getStaticArmorDictionary(itemName); + break; + case "item": + specificItemData = getStaticItemDictionary(itemName); + break; } if (specificItemData != null) { java.util.Enumeration e = specificItemData.keys(); + String s; while (e.hasMoreElements()) { - String s = (e.nextElement()).toString(); + s = (e.nextElement()).toString(); masterItemData.put(s, specificItemData.get(s)); } } @@ -1162,18 +1059,16 @@ public class static_item extends script.base_script } public static void getAttributes(obj_id player, String staticItemName, String[] names, String[] attribs) throws InterruptedException { - String itemType = static_item.getItemType(staticItemName); - if (itemType.equals("weapon")) - { - getStaticWeaponObjectAttributes(player, staticItemName, names, attribs); - } - else if (itemType.equals("armor")) - { - getStaticArmorObjectAttributes(player, staticItemName, names, attribs); - } - else if (itemType.equals("item")) - { - getStaticItemObjectAttributes(player, staticItemName, names, attribs); + switch (static_item.getItemType(staticItemName)) { + case "weapon": + getStaticWeaponObjectAttributes(player, staticItemName, names, attribs); + break; + case "armor": + getStaticArmorObjectAttributes(player, staticItemName, names, attribs); + break; + case "item": + getStaticItemObjectAttributes(player, staticItemName, names, attribs); + break; } } public static void getStaticWeaponObjectAttributes(obj_id player, String staticItemName, String[] names, String[] attribs) throws InterruptedException @@ -1203,7 +1098,7 @@ public class static_item extends script.base_script int damageType = itemData.getInt("damage_type"); String wpn_damage_type = "cat_wpn_damage.wpn_damage_type"; names[free] = wpn_damage_type; - String damageTypeStr = "kinetic"; + String damageTypeStr; if (damageType == 1) { damageTypeStr = "kinetic"; @@ -1244,9 +1139,10 @@ public class static_item extends script.base_script if (dict != null) { java.util.Enumeration keys = dict.keys(); + String skillModName; while (keys.hasMoreElements()) { - String skillModName = (String)keys.nextElement(); + skillModName = (String)keys.nextElement(); int skillModValue = dict.getInt(skillModName); names[free] = statstf + skillModName; attribs[free++] = Integer.toString(skillModValue); @@ -1282,18 +1178,17 @@ public class static_item extends script.base_script int damageType = itemData.getInt("damage_type"); String wpn_damage_type = "cat_wpn_damage.wpn_damage_type"; names[free] = wpn_damage_type; - String damageTypeStr = "kinetic"; - if (damageType == 1) - { - damageTypeStr = "kinetic"; - } - else if (damageType == 2) - { - damageTypeStr = "energy"; - } - else - { - damageTypeStr = "unknown"; + String damageTypeStr; + switch(damageType){ + case 1: + damageTypeStr = "kinetic"; + break; + case 2: + damageTypeStr = "energy"; + break; + default: + damageTypeStr = "unknown"; + break; } attribs[free++] = at + "armor_eff_" + damageTypeStr; int tier = itemData.getInt("tier"); @@ -1307,9 +1202,10 @@ public class static_item extends script.base_script if (dict != null) { java.util.Enumeration keys = dict.keys(); + String skillModName; while (keys.hasMoreElements()) { - String skillModName = (String)keys.nextElement(); + skillModName = (String)keys.nextElement(); int skillModValue = dict.getInt(skillModName); names[free] = statstf + skillModName; attribs[free++] = Integer.toString(skillModValue); @@ -1391,9 +1287,10 @@ public class static_item extends script.base_script if (dict != null) { java.util.Enumeration keys = dict.keys(); + String skillModName; while (keys.hasMoreElements()) { - String skillModName = (String)keys.nextElement(); + skillModName = (String)keys.nextElement(); int skillModValue = dict.getInt(skillModName); names[free] = statstf + skillModName; attribs[free++] = Integer.toString(skillModValue); @@ -1405,7 +1302,7 @@ public class static_item extends script.base_script names[free] = "tier"; attribs[free++] = "" + tier; names[free] = "tooltip.tier"; - attribs[free++] = "" + tier; + attribs[free] = "" + tier; } public static dictionary parseSkillModifiers(obj_id player, String skillMods) throws InterruptedException { @@ -1413,11 +1310,10 @@ public class static_item extends script.base_script if (skillMods != null && !skillMods.equals("")) { String[] stringArray = split(skillMods, ','); - for (int i = 0; i < stringArray.length; i++) - { - String[] modsArray = split(stringArray[i], '='); - for (int x = 0; x < modsArray.length; x += 2) - { + String[] modsArray; + for (String aStringArray : stringArray) { + modsArray = split(aStringArray, '='); + for (int x = 0; x < modsArray.length; x += 2) { dict.put(modsArray[0], utils.stringToInt(modsArray[1])); } } @@ -1460,11 +1356,7 @@ public class static_item extends script.base_script return null; } String strAppearance = dctItemInfo.getString("strBaseAppearance"); - if (strAppearance.endsWith(".iff")) - { - } - else - { + if (!strAppearance.endsWith(".iff")) { String[] strTemplates = dataTableGetStringColumnNoDefaults("datatables/item/dynamic_item/appearances/" + strAppearance + ".iff", "strTemplate"); if ((strTemplates == null) || (strTemplates.length < 1)) { @@ -1550,7 +1442,7 @@ public class static_item extends script.base_script { String armorBalanceTable = "datatables/item/dynamic_item/root_balance_data/armor_data.iff"; String modifiersTable = "datatables/item/dynamic_item/modifiers/armor_mods.iff"; - String armorTypeTable = "datatables/item/dynamic_item/types/armor.iff"; + //String armorTypeTable = "datatables/item/dynamic_item/types/armor.iff"; int minLevel = dataTableGetInt(armorBalanceTable, 0, "minLevel"); int protectIncreasePerLevel = dataTableGetInt(armorBalanceTable, 0, "protectIncreasePerLevel"); int minRawProtection = dataTableGetInt(armorBalanceTable, 0, "minRawProtection"); @@ -1563,10 +1455,10 @@ public class static_item extends script.base_script float minSpecialMod = dataTableGetFloat(armorBalanceTable, 0, "minSpecialMod"); float maxSpecialMod = dataTableGetFloat(armorBalanceTable, 0, "maxSpecialMod"); float baseSpecialMod = dataTableGetFloat(armorBalanceTable, 0, "baseSpecialMod"); - float baseMod = minBaseMod; - float primaryMod = minPrimaryMod; - float specialMod = minSpecialMod; - int armorTypeModRow = 0; + float baseMod; + float primaryMod; + float specialMod; + int armorTypeModRow; if (boolSetupData) { baseMod = rand(minBaseMod, maxBaseMod); @@ -1696,7 +1588,6 @@ public class static_item extends script.base_script } public static obj_id setupDynamicWeapon(obj_id objWeapon, String itemName, int intLevel, dictionary dctWeaponStats, dictionary dctItemInfo, boolean boolSetupData) throws InterruptedException { - obj_id self = getSelf(); dictionary dctItemNames = new dictionary(); if (boolSetupData) { @@ -1706,8 +1597,8 @@ public class static_item extends script.base_script dctItemNames.put("strBaseName", strBaseName); } } - float fltMinDamageVal = 0; - float fltMaxDamageVal = 0; + float fltMinDamageVal; + float fltMaxDamageVal; if (boolSetupData) { fltMinDamageVal = rand(0f, 1f); @@ -1734,7 +1625,7 @@ public class static_item extends script.base_script int intMaxDamage = intMaxDamageMin + (int)fltMax; float fltAttackSpeed = dctWeaponStats.getFloat(strWeaponString + "_attack_speed"); float fltMaxRange = dctWeaponStats.getFloat(strWeaponString + "_max_range"); - int intDamageType = DAMAGE_NONE; + int intDamageType; if (boolSetupData) { intDamageType = dctItemInfo.getInt("baseDamageType"); @@ -1855,11 +1746,9 @@ public class static_item extends script.base_script setObjVar(item, "skillmod.bonus." + statBonusNames[i], statBonuses[i]); } } - return; } public static int generateStatMod(int level) throws InterruptedException { - final float VARIANCE = 0.125f; final float BASE_MOD = 0.2f; final float MAX_MOD = 0.312f; final float FLOOR_CHANCE = 60.0f; @@ -1867,12 +1756,7 @@ public class static_item extends script.base_script float exponentIncrement = 18 / varianceIncrements; float baseMod = level * BASE_MOD; float maxMod = level * MAX_MOD; - float currentIncrement = 0.0f; - float finalModFloat = baseMod; - if (varianceIncrements < 1) - { - varianceIncrements = 1.0f; - } + float currentIncrement; if (exponentIncrement < 1) { exponentIncrement = 1.0f; @@ -1891,7 +1775,6 @@ public class static_item extends script.base_script currentIncrement = (float)Math.pow(FLOOR_CHANCE, 1 + (f / 100)); if (roll < currentIncrement) { - finalModFloat = baseMod; break; } baseMod++; @@ -1900,8 +1783,7 @@ public class static_item extends script.base_script { baseMod = maxMod; } - int statMod = (int)baseMod; - return statMod; + return (int)baseMod; } public static String getArmorNameSuffix(obj_id item) throws InterruptedException { @@ -1953,10 +1835,9 @@ public class static_item extends script.base_script { if (fltRange != 0) { - int intPrice = getIntObjVar(objObject, "junkDealer.intPrice"); float fltDiff = (float)(intMaxValue - intMinValue); fltDiff = fltDiff * fltRange; - intPrice = intMinValue + (int)fltDiff; + int intPrice = intMinValue + (int)fltDiff; setObjVar(objObject, "junkDealer.intPrice", intPrice); } else @@ -1965,7 +1846,6 @@ public class static_item extends script.base_script intPrice = intPrice + rand(intMinValue, intMaxValue); setObjVar(objObject, "junkDealer.intPrice", intPrice); } - return; } public static dictionary applyWeaponItemModifers(obj_id objWeapon, String strModifier, int intMinDamage, int intMaxDamage, dictionary dctItemNames) throws InterruptedException { @@ -2075,20 +1955,14 @@ public class static_item extends script.base_script setName(objItem, strName); } } - return; } public static boolean isDynamicItem(obj_id objItem) throws InterruptedException { - if (hasObjVar(objItem, "dynamic_item")) - { - return true; - } - return false; + return hasObjVar(objItem, "dynamic_item"); } public static boolean isUniqueStaticItem(obj_id item) throws InterruptedException { - String item_name = getStaticItemName(item); - dictionary dict = getMasterItemDictionary(item_name); + dictionary dict = getMasterItemDictionary(getStaticItemName(item)); if (dict != null) { return dict.getInt("unique") == 1; @@ -2112,21 +1986,15 @@ public class static_item extends script.base_script return false; } } - public static boolean canCreateUniqueStaticItem(obj_id container, String itemName) throws InterruptedException - { - if (!isPlayer(getOwner(container))) - { - return true; - } - return (!utils.playerHasStaticItemInBankOrInventory(getOwner(container), itemName)); + public static boolean canCreateUniqueStaticItem(obj_id container, String itemName) throws InterruptedException { + return !isPlayer(getOwner(container)) || (!utils.playerHasStaticItemInBankOrInventory(getOwner(container), itemName)); } public static boolean canEquip(obj_id player, obj_id item) throws InterruptedException { dictionary itemData = static_item.getMasterItemDictionary(item); - int requiredLevel = itemData.getInt("required_level"); String requiredSkill = itemData.getString("required_skill"); boolean canEquip = true; - if (!static_item.validateLevelRequired(player, requiredLevel)) + if (!static_item.validateLevelRequired(player, itemData.getInt("required_level"))) { canEquip = false; } @@ -2157,7 +2025,6 @@ public class static_item extends script.base_script { setObjVar(object, ORIG_OWNER, player); } - return; } public static boolean userIsOrigOwner(obj_id object, obj_id player) throws InterruptedException { @@ -2171,11 +2038,7 @@ public class static_item extends script.base_script { return false; } - if (origOwner == currentOwner) - { - return true; - } - return false; + return origOwner == currentOwner; } public static string_id getStaticItemStringIdName(obj_id object) throws InterruptedException { @@ -2187,7 +2050,6 @@ public class static_item extends script.base_script { return null; } - String staticItemName = getStaticItemName(object); - return new string_id(STATIC_ITEM_NAME, staticItemName); + return new string_id(STATIC_ITEM_NAME, getStaticItemName(object)); } } diff --git a/sku.0/sys.server/compiled/game/script/library/stealth.java b/sku.0/sys.server/compiled/game/script/library/stealth.java old mode 100644 new mode 100755 index b6221ba34..22c9253d8 --- a/sku.0/sys.server/compiled/game/script/library/stealth.java +++ b/sku.0/sys.server/compiled/game/script/library/stealth.java @@ -1,36 +1,9 @@ package script.library; +import script.combat_engine.combat_data; 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 java.lang.Math; -import java.util.StringTokenizer; -import script.library.ai_lib; -import script.library.beast_lib; -import script.library.buff; -import script.library.city; -import script.library.colors; -import script.library.combat; -import script.library.dot; -import script.library.factions; -import script.library.group; -import script.library.locations; -import script.library.loot; -import script.library.luck; -import script.library.money; -import script.library.pet_lib; -import script.library.prose; -import script.library.static_item; -import script.library.sui; -import script.library.utils; -import script.library.vehicle; -import script.library.xp; -import script.library.weapons; +import java.util.Vector; public class stealth extends script.base_script { @@ -191,7 +164,6 @@ public class stealth extends script.base_script public static void createRangerLoot(int level, String object, obj_id container, int count) throws InterruptedException { object = toLower(object); - String template = ""; int type = 1; int trigType = 1; int power = getPowerLevel(level, false); @@ -204,65 +176,63 @@ public class stealth extends script.base_script switch (trigHash) { case (265639046): - trigType = TRIGGER_TYPE_PROXIMITY; - break; + trigType = TRIGGER_TYPE_PROXIMITY; + break; case (-1964272009): - trigType = TRIGGER_TYPE_TIMER; - break; + trigType = TRIGGER_TYPE_TIMER; + break; case (-1799474985): - trigType = TRIGGER_TYPE_REMOTE; - break; + trigType = TRIGGER_TYPE_REMOTE; + break; default: - trapHash = getStringCrc(object); - break; + trapHash = getStringCrc(object); + break; } switch (trapHash) { case (-2001914999): - for (int i = 0; i < count; i++) - { - type = ALL_TRAP_TYPES[rand(0, ALL_TRAP_TYPES.length - 1)]; - trigType = ALL_TRIGGER_TYPES[rand(0, ALL_TRIGGER_TYPES.length - 1)]; - createTrapObject(container, getPowerLevel(level, true), type, 1, trigType, getPowerLevel(level, true), rand(5, 20)); - } - break; + for (int i = 0; i < count; i++) + { + type = ALL_TRAP_TYPES[rand(0, ALL_TRAP_TYPES.length - 1)]; + trigType = ALL_TRIGGER_TYPES[rand(0, ALL_TRIGGER_TYPES.length - 1)]; + createTrapObject(container, getPowerLevel(level, true), type, 1, trigType, getPowerLevel(level, true), rand(5, 20)); + } + break; case (-279247418): - createMotionSensorObject(container, power, count); - break; + createMotionSensorObject(container, power, count); + break; case (-1752438899): - createChaffFlareObject(container, power, count); - break; + createChaffFlareObject(container, power, count); + break; case (487387167): - createHEPObject(container, power, count); - break; + createHEPObject(container, power, count); + break; case (1253827732): - createBioProbeObject(container, power, count); - break; + createBioProbeObject(container, power, count); + break; case (579649147): - createTrackingBeaconObject(container, power, count); - break; + createTrackingBeaconObject(container, power, count); + break; case (240293015): - createTrapObject(container, power, TRAP_CALTROP, count, trigType, power, 10); - break; + createTrapObject(container, power, TRAP_CALTROP, count, trigType, power, 10); + break; case (1254944108): - createTrapObject(container, power, TRAP_FLASHBANG, count, trigType, power, 10); - break; + createTrapObject(container, power, TRAP_FLASHBANG, count, trigType, power, 10); + break; case (546611802): - createTrapObject(container, power, TRAP_HX2, count, trigType, power, 10); - break; + createTrapObject(container, power, TRAP_HX2, count, trigType, power, 10); + break; case (-1152836626): - createTrapObject(container, power, TRAP_KAMINODART, count, trigType, power, 10); + createTrapObject(container, power, TRAP_KAMINODART, count, trigType, power, 10); + break; } - return; } public static void createRangerLoot(obj_id mob, int level, String object, obj_id container) throws InterruptedException { createRangerLoot(level, object, container, -1); - return; } public static int getNumLootItems(int level, obj_id destContainer) throws InterruptedException { - float lvl = level; int numItems = 1 + (int)Math.ceil((level / 30)); int free = getVolumeFree(destContainer); if (free < numItems) @@ -374,27 +344,26 @@ public class stealth extends script.base_script } public static obj_id createTrapObject(obj_id container, int power, int trapType, int count, int triggerType, int triggerAccuracy, int triggerParam) throws InterruptedException { - String template = ""; + String template; switch (trapType) { case TRAP_CALTROP: - template = "object/tangible/scout/trap/trap_ap_caltrop.iff"; - break; + template = "object/tangible/scout/trap/trap_ap_caltrop.iff"; + break; case TRAP_FLASHBANG: - template = "object/tangible/scout/trap/trap_ap_flashbang.iff"; - break; + template = "object/tangible/scout/trap/trap_ap_flashbang.iff"; + break; case TRAP_HX2: - template = "object/tangible/scout/trap/trap_ap_hx2mine.iff"; - break; + template = "object/tangible/scout/trap/trap_ap_hx2mine.iff"; + break; case TRAP_KAMINODART: - template = "object/tangible/scout/trap/trap_ap_kaminoandart.iff"; - break; + template = "object/tangible/scout/trap/trap_ap_kaminoandart.iff"; + break; default: - template = "object/tangible/scout/trap/trap_ap_hx2mine.iff"; - break; + template = "object/tangible/scout/trap/trap_ap_hx2mine.iff"; + break; } - obj_id trap = null; - trap = createObject(template, container, ""); + obj_id trap = createObject(template, container, ""); if (!isIdValid(trap)) { return null; @@ -407,10 +376,8 @@ public class stealth extends script.base_script public static boolean canPlaceMotionSensor(obj_id player, obj_id sensor) throws InterruptedException { obj_id[] stuff = getNonCreaturesInRange(getLocation(player), TRAP_MIN_DISTANCE_BETWEEN * 2); - for (int i = 0; i < stuff.length; i++) - { - if (hasObjVar(stuff[i], TRAP_TYPE) || hasObjVar(stuff[i], BEACON_BATTERY)) - { + for (obj_id aStuff : stuff) { + if (hasObjVar(aStuff, TRAP_TYPE) || hasObjVar(aStuff, BEACON_BATTERY)) { sendSystemMessage(player, new string_id("spam", "other_trap")); return false; } @@ -455,7 +422,6 @@ public class stealth extends script.base_script dic.put("wasFiltered", wasFiltered); dic.put("sensorLoc", getLocation(sensor)); messageTo(owner, "msgMotionSensorTripped", dic, 1, false); - return; } public static void cleanComponentFromContainer(obj_id component, obj_id container) throws InterruptedException { @@ -473,17 +439,15 @@ public class stealth extends script.base_script return; } int numItems = ovl.getNumItems(); - String name = ""; + obj_var ov; for (int i = 0; i < numItems; i++) { - obj_var ov = ovl.getObjVar(i); + ov = ovl.getObjVar(i); if (ov != null) { - name = "trap." + ov.getName(); - removeObjVar(container, name); + removeObjVar(container, "trap." + ov.getName()); } } - return; } public static boolean canActivateTrackingBeacon(obj_id player, obj_id beacon, boolean silent) throws InterruptedException { @@ -536,7 +500,6 @@ public class stealth extends script.base_script messageTo(beacon, "msgTrackingBeaconUpdate", dic, BEACON_INTERVAL, true); messageTo(target, "msgTrackingBeaconLocationRequest", dic, 0, false); } - return; } public static void stopTrackingBeacon(obj_id beacon, obj_id player) throws InterruptedException { @@ -552,7 +515,6 @@ public class stealth extends script.base_script removeObjVar(beacon, BEACON_TARGET); removeObjVar(beacon, BEACON_TARGET_NAME); } - return; } public static void updateTrackingBeaconDisplay(obj_id beacon) throws InterruptedException { @@ -602,7 +564,6 @@ public class stealth extends script.base_script { stopTrackingBeacon(beacon, player); } - return; } public static void updateTrackingBeaconData(obj_id beacon, obj_id target, location targetLoc, String targetName) throws InterruptedException { @@ -651,7 +612,6 @@ public class stealth extends script.base_script } public static void bioProbe(obj_id player, obj_id probe, obj_id target) throws InterruptedException { - float effectiveness = getIntObjVar(probe, DETECT_EFFECTIVENESS); float timeToDecay = getFloatObjVar(probe, BIO_PROBE_STORAGE_TIME); setObjVar(probe, BIO_PROBE_SAMPLE_TIME, getGameTime()); messageTo(probe, "msgDecaySample", null, timeToDecay, true); @@ -667,7 +627,6 @@ public class stealth extends script.base_script prose_package pp = prose.getPackage(new string_id("spam", "got_probe")); pp = prose.setTT(pp, target); sendSystemMessageProse(player, pp); - return; } public static void doChaffFlareEffect(obj_id player, obj_id flare) throws InterruptedException { @@ -678,23 +637,19 @@ public class stealth extends script.base_script obj_id[] stuff = getObjectsInRange(player, flareDistance); boolean foundSomething = false; prose_package pp = prose.getPackage(new string_id("spam", "chaff_uncover")); - flareDistance += (detectSkill / 10); pp = prose.setTT(pp, player); - for (int i = 0; i < stuff.length; i++) - { - if (!hasObjVar(stuff[i], TRAP_TYPE) || !validateTrapTarget(stuff[i], player)) - { + for (obj_id aStuff : stuff) { + if (!hasObjVar(aStuff, TRAP_TYPE) || !validateTrapTarget(aStuff, player)) { continue; } - int hidePower = getIntObjVar(stuff[i], CAMO_SKILL); + int hidePower = getIntObjVar(aStuff, CAMO_SKILL); int chaffPower = getIntObjVar(flare, DETECT_EFFECTIVENESS); - if (hidePower > chaffPower) - { + if (hidePower > chaffPower) { continue; } - pp = prose.setTU(pp, stuff[i]); + pp = prose.setTU(pp, aStuff); foundSomething = true; - unconcealDevice(player, stuff[i]); + unconcealDevice(player, aStuff); } if (foundSomething) { @@ -705,7 +660,6 @@ public class stealth extends script.base_script { sendSystemMessage(player, new string_id("spam", "chaff_nothing")); } - return; } public static boolean canDisarmTrap(obj_id player, obj_id trap) throws InterruptedException { @@ -750,8 +704,7 @@ public class stealth extends script.base_script { chanceToDetect = MAX_CHANCE_TO_DISARM; } - float roll = rand(0f, 100f); - if (roll < chanceToDetect) + if (rand(0f, 100f) < chanceToDetect) { if (hasObjVar(trap, stealth.TRAP_FREQUENCY)) { @@ -781,7 +734,6 @@ public class stealth extends script.base_script doTrapDetonateEffect(trap, getIntObjVar(trap, TRAP_TYPE), target, PERCENT_EFFECT_MOD_DISARM_FAIL); sendSystemMessage(player, new string_id("spam", "fail_disarm")); } - return; } public static boolean canDetectCamouflage(obj_id player) throws InterruptedException { @@ -790,14 +742,13 @@ public class stealth extends script.base_script public static void detectCamouflage(obj_id player, boolean findMobiles, boolean findInanimate, float distance, float baseChanceToDetect) throws InterruptedException { obj_id[] stuff = getObjectsInRange(player, distance); - Vector detected = new Vector(); - Vector times = new Vector(); + Vector detected; + Vector times; int now = getGameTime(); boolean foundSomething = false; - obj_id target = null; - prose_package pp = prose.getPackage(new string_id("spam", "revealed_by")); - String invis = ""; - boolean objIsMobile = false; + obj_id target; + String invis; + boolean objIsMobile; location playerLoc = getLocation(player); playClientEffectLoc(getPlayerCreaturesInRange(playerLoc, 100.0f), "appearance/pt_spy_reveal_wave.prt", playerLoc, 0.0f); if (utils.isProfession(player, utils.SPY)) @@ -827,78 +778,57 @@ public class stealth extends script.base_script { playClientEffectLoc(player, "appearance/pt_fireworks_secondary_shockwave2.prt", getLocation(player), 0.0f); } - for (int i = 0; i < stuff.length; i++) - { + for (obj_id aStuff : stuff) { objIsMobile = false; - target = stuff[i]; - if (!isIdValid(target)) - { + target = aStuff; + if (!isIdValid(target)) { continue; } - if (isPlayer(target) || ai_lib.isHumanoid(target) || isMob(target)) - { + if (isPlayer(target) || ai_lib.isHumanoid(target) || isMob(target)) { objIsMobile = true; - if (!pvpCanAttack(player, target)) - { + if (!pvpCanAttack(player, target)) { continue; } invis = getInvisBuff(target); - if (invis == null) - { + if (invis == null) { + continue; + } else if (buff.getPriority(invis) > MAX_INVIS_BUFF_TO_DETECT) { continue; } - else if (buff.getPriority(invis) > MAX_INVIS_BUFF_TO_DETECT) - { - continue; - } - if (invis.startsWith("invis_sp_buff_invis_notrace") || invis.startsWith("invis_sp_diversion_stealth")) - { + if (invis.startsWith("invis_sp_buff_invis_notrace") || invis.startsWith("invis_sp_diversion_stealth")) { continue; } detected = utils.getResizeableStringBatchObjVar(target, DETECT_ATTEMPTS); times = utils.getResizeableStringBatchObjVar(target, DETECT_TIMES); - if (detected == null) - { + if (detected == null) { detected = new Vector(); } - if (times == null) - { + if (times == null) { times = new Vector(); } - if (detected.size() != times.size()) - { + if (detected.size() != times.size()) { continue; } int idx = detected.indexOf(player); - if (idx > -1) - { - int when = (((Integer)times.get(idx))).intValue(); - if (when - now < PLAYER_DETECT_SAFETY_INTERVAL) - { + if (idx > -1) { + int when = (Integer) times.get(idx); + if (when - now < PLAYER_DETECT_SAFETY_INTERVAL) { continue; } - times.setElementAt(new Integer(now), idx); - } - else - { + times.setElementAt(now, idx); + } else { detected.add(player); - times.add(new Integer(now)); + times.add(now); } utils.setResizeableBatchObjVar(target, DETECT_ATTEMPTS, detected); utils.setResizeableBatchObjVar(target, DETECT_TIMES, times); - } - else if (!hasObjVar(target, CONCEALED_OBJECT) || !validateTrapTarget(target, player)) - { + } else if (!hasObjVar(target, CONCEALED_OBJECT) || !validateTrapTarget(target, player)) { continue; } - if (activeDetectHiddenTarget(target, player, baseChanceToDetect)) - { - if (objIsMobile) - { + if (activeDetectHiddenTarget(target, player, baseChanceToDetect)) { + if (objIsMobile) { checkForAndMakeVisible(target); - } - else - { + } else { unconcealDevice(player, target); } foundSomething = true; @@ -914,7 +844,6 @@ public class stealth extends script.base_script { sendSystemMessage(player, new string_id("spam", "no_detect")); } - return; } public static boolean canConcealDevice(obj_id player, obj_id target) throws InterruptedException { @@ -1020,10 +949,8 @@ public class stealth extends script.base_script } } obj_id[] stuff = getNonCreaturesInRange(getLocation(player), TRAP_MIN_DISTANCE_BETWEEN); - for (int i = 0; i < stuff.length; i++) - { - if (hasObjVar(stuff[i], TRAP_TYPE)) - { + for (obj_id aStuff : stuff) { + if (hasObjVar(aStuff, TRAP_TYPE)) { sendSystemMessage(player, new string_id("spam", "other_trap")); return false; } @@ -1032,10 +959,8 @@ public class stealth extends script.base_script } public static boolean inTrapRestrictedRegion(obj_id player) throws InterruptedException { - for (int i = 0; i < TRAP_RESTRICTED_REGIONS.length; i++) - { - if (groundquests.isInNamedRegion(player, TRAP_RESTRICTED_REGIONS[i])) - { + for (String TRAP_RESTRICTED_REGION : TRAP_RESTRICTED_REGIONS) { + if (groundquests.isInNamedRegion(player, TRAP_RESTRICTED_REGION)) { return true; } } @@ -1049,30 +974,31 @@ public class stealth extends script.base_script } if (hasObjVar(self, TRAP_TYPE)) { - int trapTypeInt = getIntObjVar(self, TRAP_TYPE); - if (trapTypeInt == TRAP_CALTROP) - { - float trapRadiusFlt = TRAP_CALTROP_BLAST_RADIUS; - names[free] = "trap_radius"; - attribs[free++] = "" + trapRadiusFlt + "m"; - } - if (trapTypeInt == TRAP_FLASHBANG) - { - float trapRadiusFlt = TRAP_FLASHBANG_BLAST_RADIUS; - names[free] = "trap_radius"; - attribs[free++] = "" + trapRadiusFlt + "m"; - } - if (trapTypeInt == TRAP_HX2) - { - float trapRadiusFlt = TRAP_HX2_BLAST_RADIUS; - names[free] = "trap_radius"; - attribs[free++] = "" + trapRadiusFlt + "m"; - } - if (trapTypeInt == TRAP_KAMINODART) - { - float trapRadiusFlt = TRAP_KAMINODART_BLAST_RADIUS; - names[free] = "trap_radius"; - attribs[free++] = "" + trapRadiusFlt + "m"; + switch (getIntObjVar(self, TRAP_TYPE)) { + case TRAP_CALTROP: { + float trapRadiusFlt = TRAP_CALTROP_BLAST_RADIUS; + names[free] = "trap_radius"; + attribs[free++] = "" + trapRadiusFlt + "m"; + break; + } + case TRAP_FLASHBANG: { + float trapRadiusFlt = TRAP_FLASHBANG_BLAST_RADIUS; + names[free] = "trap_radius"; + attribs[free++] = "" + trapRadiusFlt + "m"; + break; + } + case TRAP_HX2: { + float trapRadiusFlt = TRAP_HX2_BLAST_RADIUS; + names[free] = "trap_radius"; + attribs[free++] = "" + trapRadiusFlt + "m"; + break; + } + case TRAP_KAMINODART: { + float trapRadiusFlt = TRAP_KAMINODART_BLAST_RADIUS; + names[free] = "trap_radius"; + attribs[free++] = "" + trapRadiusFlt + "m"; + break; + } } } if (hasObjVar(self, TRAP_POWER)) @@ -1121,9 +1047,8 @@ public class stealth extends script.base_script names[free] = "trigger_filter"; attribs[free++] = "" + getStringObjVar(self, BIO_PROBE_TARGET_NAME); } - free = utils.addClassRequirementAttributes(player, self, names, attribs, free, "trap."); - free = utils.addClassRequirementAttributes(player, self, names, attribs, free, "trap.trigger."); - return; + utils.addClassRequirementAttributes(player, self, names, attribs, free, "trap."); + utils.addClassRequirementAttributes(player, self, names, attribs, free, "trap.trigger."); } public static boolean tryDetonateTrap(obj_id trap, obj_id target) throws InterruptedException { @@ -1163,27 +1088,24 @@ public class stealth extends script.base_script switch (trapType) { case TRAP_HX2: - targets = getCreaturesInRange(getLocation(trap), TRAP_HX2_BLAST_RADIUS); - break; + targets = getCreaturesInRange(getLocation(trap), TRAP_HX2_BLAST_RADIUS); + break; case TRAP_FLASHBANG: - targets = getCreaturesInRange(getLocation(trap), TRAP_FLASHBANG_BLAST_RADIUS); - break; + targets = getCreaturesInRange(getLocation(trap), TRAP_FLASHBANG_BLAST_RADIUS); + break; case TRAP_CALTROP: - targets = getCreaturesInRange(getLocation(trap), TRAP_CALTROP_BLAST_RADIUS); - break; + targets = getCreaturesInRange(getLocation(trap), TRAP_CALTROP_BLAST_RADIUS); + break; case TRAP_KAMINODART: - targets = getCreaturesInRange(getLocation(trap), TRAP_KAMINODART_BLAST_RADIUS); - break; + targets = getCreaturesInRange(getLocation(trap), TRAP_KAMINODART_BLAST_RADIUS); + break; } Vector finalTargets = new Vector(); obj_id filter = getBioProbeTarget(trap); - for (int i = 0; i < targets.length; i++) - { - if (!isIdValid(filter) || targets[i] == filter) - { - if (validateTrapTarget(trap, targets[i])) - { - finalTargets.add(targets[i]); + for (obj_id target : targets) { + if (!isIdValid(filter) || target == filter) { + if (validateTrapTarget(trap, target)) { + finalTargets.add(target); } } } @@ -1196,29 +1118,29 @@ public class stealth extends script.base_script switch (trapType) { case TRAP_HX2: - dictionary params = new dictionary(); - obj_id owner = getOwner(trap); - if (!isIdValid(breacher)) - { - breacher = (obj_id)targets.elementAt(0); + dictionary params = new dictionary(); + obj_id owner = getOwner(trap); if (!isIdValid(breacher)) { - break; + breacher = (obj_id)targets.elementAt(0); + if (!isIdValid(breacher)) + { + break; + } } - } - params.put("target", breacher); - params.put("owner", owner); - messageTo(trap, "co_mine_hx2", params, 0, false); - break; + params.put("target", breacher); + params.put("owner", owner); + messageTo(trap, "co_mine_hx2", params, 0, false); + break; case TRAP_FLASHBANG: - doFlashBangDetonate(trap, targets, percentMod); - break; + doFlashBangDetonate(trap, targets, percentMod); + break; case TRAP_CALTROP: - doCaltropDetonate(trap, targets, percentMod); - break; + doCaltropDetonate(trap, targets, percentMod); + break; case TRAP_KAMINODART: - doKaminoDartDetonate(trap, targets, percentMod); - break; + doKaminoDartDetonate(trap, targets, percentMod); + break; } } else @@ -1246,7 +1168,7 @@ public class stealth extends script.base_script int duration = (int)(KAMINODART_MAX_DURATION * (trapPower / 1000)); int strength = (int)(KAMINODART_MAX_STRENGTH * (trapPower / 1000)); obj_id owner = getOwner(trap); - boolean isInvis = false; + boolean isInvis; String invis = null; boolean attackerPresent = false; if (isIdValid(owner) && exists(owner)) @@ -1257,25 +1179,21 @@ public class stealth extends script.base_script isInvis = invis != null && invis.length() > 0; duration += duration * percentMod; strength += strength * percentMod; - obj_id curObj = null; + obj_id curObj; prose_package pp = prose.getPackage(new string_id("spam", "kamino_trap_hit")); - playClientEffectLoc(trap, "clienteffect/lair_damage_light.cef", getLocation(curObj), 0.0f); - for (int i = 0; i < targets.size(); i++) - { - curObj = (obj_id)targets.get(i); + //playClientEffectLoc(trap, "clienteffect/lair_damage_light.cef", getLocation(curObj), 0.0f); + for (Object target : targets) { + curObj = (obj_id) target; playClientEffectLoc(curObj, "clienteffect/lair_damage_light.cef", getLocation(curObj), 0.0f); dot.applyDotEffect(curObj, owner, dot.DOT_POISON, "rangerTrapKaminoDart", HEALTH, potency, strength, duration, true, null); pp = prose.setTT(pp, curObj); - if (attackerPresent) - { - if (isInvis && rand(1, 100) < 50) - { + if (attackerPresent) { + if (isInvis && rand(1, 100) < 50) { continue; } startCombat(curObj, owner); } } - return; } public static void doCaltropDetonate(obj_id trap, Vector targets) throws InterruptedException { @@ -1286,10 +1204,9 @@ public class stealth extends script.base_script float trapPower = getIntObjVar(trap, TRAP_POWER); float duration = CALTROP_MAX_DURATION * (trapPower / 1000); float snareAmount = CALTROP_MAX_SNARE * (trapPower / 1000); - obj_id curObj = null; - prose_package pp = prose.getPackage(new string_id("spam", "caltrop_trap_hit")); + obj_id curObj; obj_id owner = getOwner(trap); - boolean isInvis = false; + boolean isInvis; String invis = null; boolean attackerPresent = false; if (isIdValid(owner) && exists(owner)) @@ -1305,17 +1222,13 @@ public class stealth extends script.base_script { snareAmount = 95; } - for (int i = 0; i < targets.size(); i++) - { - curObj = (obj_id)targets.get(i); - if (buff.canApplyBuff(curObj, "caltropSnare")) - { + for (Object target : targets) { + curObj = (obj_id) target; + if (buff.canApplyBuff(curObj, "caltropSnare")) { playClientEffectLoc(curObj, "clienteffect/lair_damage_light.cef", getLocation(curObj), 0.0f); buff.applyBuff(curObj, "caltropSnare", duration, snareAmount); - if (attackerPresent) - { - if (isInvis && rand(1, 100) < 50) - { + if (attackerPresent) { + if (isInvis && rand(1, 100) < 50) { continue; } startCombat(curObj, owner); @@ -1332,10 +1245,9 @@ public class stealth extends script.base_script float trapPower = getIntObjVar(trap, TRAP_POWER); float duration = FLASHBANG_MAX_DURATION * (trapPower / 1000); float amount = FLASHBANG_MAX_COMBAT_SLOW * (trapPower / 1000); - obj_id curObj = null; - prose_package pp = prose.getPackage(new string_id("spam", "flashbang_trap_hit")); + obj_id curObj; obj_id owner = getOwner(trap); - boolean isInvis = false; + boolean isInvis; String invis = null; boolean attackerPresent = false; if (isIdValid(owner) && exists(owner)) @@ -1348,30 +1260,21 @@ public class stealth extends script.base_script playClientEffectLoc(trap, "appearance/pt_flash_bomb.prt", getLocation(trap), 0.0f); duration += duration * percentMod; amount += amount * percentMod; - for (int i = 0; i < targets.size(); i++) - { - curObj = (obj_id)targets.get(i); - if (buff.canApplyBuff(curObj, "flashBang")) - { - if (isPlayer(curObj)) - { + for (Object target : targets) { + curObj = (obj_id) target; + if (buff.canApplyBuff(curObj, "flashBang")) { + if (isPlayer(curObj)) { doAnimationAction(curObj, "cover_ears_mocking"); } buff.applyBuff(curObj, "flashBang", duration, amount); - if (attackerPresent) - { - if (isInvis && rand(1, 100) < 50) - { + if (attackerPresent) { + if (isInvis && rand(1, 100) < 50) { continue; } startCombat(curObj, owner); } } - else - { - } } - return; } public static boolean safePvPCanAttack(obj_id trap, obj_id target) throws InterruptedException { @@ -1398,27 +1301,22 @@ public class stealth extends script.base_script { return false; } - if (targetIsPlayer && actorIsPlayer) + if (targetIsPlayer) { if (pvpAreFactionsOpposed(actorFaction, targetFaction)) { - if (actorPvPType == PVPTYPE_DECLARED && targetPvPType == PVPTYPE_DECLARED) + if (targetPvPType == PVPTYPE_DECLARED) { return true; } } } - if (actorIsPlayer && !targetIsPlayer) + if (!targetIsPlayer) { - if (targetFaction != 0) - { - if (actorFaction != targetFaction) - { - return pvpAreFactionsOpposed(actorFaction, targetFaction); - } - return false; + if (targetFaction != 0) { + return actorFaction != targetFaction && pvpAreFactionsOpposed(actorFaction, targetFaction); } - else + else { return true; } @@ -1473,7 +1371,6 @@ public class stealth extends script.base_script } location loc = getLocation(player); int triggerType = getIntObjVar(invTrap, TRIGGER_TYPE); - String template = getTemplateName(invTrap); obj_id trap = utils.cloneObject(invTrap, loc); int time = getGameTime(); if (!isIdValid(trap)) @@ -1483,41 +1380,41 @@ public class stealth extends script.base_script switch (triggerType) { case TRIGGER_TYPE_TIMER: - dictionary parms = new dictionary(); - parms.put("armed", time); - messageTo(trap, "msgTryDetonateTimer", parms, getIntObjVar(trap, TIMER_TIME), false); - setObjVar(trap, "armed", time); - break; + dictionary parms = new dictionary(); + parms.put("armed", time); + messageTo(trap, "msgTryDetonateTimer", parms, getIntObjVar(trap, TIMER_TIME), false); + setObjVar(trap, "armed", time); + break; case TRIGGER_TYPE_REMOTE: - obj_id pInv = utils.getInventoryContainer(player); - int free = getVolumeFree(pInv); - if (free < 1) - { - sendSystemMessage(player, new string_id("spam", "no_room_remote_trigger")); - return false; - } - String remote = "object/tangible/scout/trap/trap_ap_tr_remote.iff"; - obj_id remoteTrigger = createObject(remote, pInv, ""); - if (!isIdValid(remoteTrigger)) - { - destroyObject(trap); - return false; - } - String frequency = "" + rand(0, 999) + "." + rand(0, 999) + "." + rand(0, 999); - - setObjVar(remoteTrigger, stealth.TRAP_FREQUENCY, frequency); - setObjVar(trap, stealth.TRAP_FREQUENCY, frequency); - setObjVar(trap, stealth.TRAP_MY_PROXIMITY_TRIGGER, remoteTrigger); - setObjVar(remoteTrigger, stealth.TRAP_MY_TRAP, trap); - sendSystemMessage(player, new string_id("spam", "trap_keyed_remote")); - setObjVar(trap, "armed", time); - setObjVar(remoteTrigger, "armed", true); - break; + obj_id pInv = utils.getInventoryContainer(player); + int free = getVolumeFree(pInv); + if (free < 1) + { + sendSystemMessage(player, new string_id("spam", "no_room_remote_trigger")); + return false; + } + String remote = "object/tangible/scout/trap/trap_ap_tr_remote.iff"; + obj_id remoteTrigger = createObject(remote, pInv, ""); + if (!isIdValid(remoteTrigger)) + { + destroyObject(trap); + return false; + } + String frequency = "" + rand(0, 999) + "." + rand(0, 999) + "." + rand(0, 999); + + setObjVar(remoteTrigger, stealth.TRAP_FREQUENCY, frequency); + setObjVar(trap, stealth.TRAP_FREQUENCY, frequency); + setObjVar(trap, stealth.TRAP_MY_PROXIMITY_TRIGGER, remoteTrigger); + setObjVar(remoteTrigger, stealth.TRAP_MY_TRAP, trap); + sendSystemMessage(player, new string_id("spam", "trap_keyed_remote")); + setObjVar(trap, "armed", time); + setObjVar(remoteTrigger, "armed", true); + break; case TRIGGER_TYPE_PROXIMITY: - dictionary timeArmed = new dictionary(); - timeArmed.put("armed", time); - messageTo(trap, "msgArmProximity", timeArmed, 0, false); - break; + dictionary timeArmed = new dictionary(); + timeArmed.put("armed", time); + messageTo(trap, "msgArmProximity", timeArmed, 0, false); + break; } playClientEffectObj(trap, "appearance/pt_trap_reticule.prt", trap, "", null, "trapReticle"); doAnimationAction(player, "point_down"); @@ -1556,11 +1453,9 @@ public class stealth extends script.base_script return getObjIdObjVar(trap, TRAP_MY_PROXIMITY_TRIGGER); } obj_id[] stuff = getContents(trap); - for (int i = 0; i < stuff.length; i++) - { - if (hasScript(stuff[i], "systems.skills.stealth.traptrigger")) - { - return stuff[i]; + for (obj_id aStuff : stuff) { + if (hasScript(aStuff, "systems.skills.stealth.traptrigger")) { + return aStuff; } } return null; @@ -1568,14 +1463,12 @@ public class stealth extends script.base_script public static boolean doTheftLoot(obj_id thief, obj_id mark) throws InterruptedException { obj_id thiefInventory = utils.getInventoryContainer(thief); - int free = getVolumeFree(thiefInventory); - prose_package pp = new prose_package(); - if (free < 1) + if (getVolumeFree(thiefInventory) < 1) { sendSystemMessage(thief, new string_id("spam", "cant_steal_inventory_full")); return false; } - int stealFlags = stealFlags = STEAL_CREDITS | STEAL_LOOT; + int stealFlags = STEAL_CREDITS | STEAL_LOOT; if (utils.hasScriptVar(mark, STEAL_TYPE)) { stealFlags = utils.getIntScriptVar(mark, STEAL_TYPE); @@ -1591,29 +1484,29 @@ public class stealth extends script.base_script Vector types = new Vector(); if (isFlagSet(stealFlags, STEAL_CREDITS)) { - types.add(new Integer(STEAL_CREDITS)); + types.add(STEAL_CREDITS); } if (isFlagSet(stealFlags, STEAL_LOOT)) { - types.add(new Integer(STEAL_LOOT)); + types.add(STEAL_LOOT); } if (isFlagSet(stealFlags, STEAL_TEMPLATE)) { - types.add(new Integer(STEAL_TEMPLATE)); + types.add(STEAL_TEMPLATE); } if (isFlagSet(stealFlags, STEAL_MARKED_ITEMS)) { - types.add(new Integer(STEAL_MARKED_ITEMS)); + types.add(STEAL_MARKED_ITEMS); } if (isFlagSet(stealFlags, STEAL_STEALING_TABLE)) { - types.add(new Integer(STEAL_STEALING_TABLE)); + types.add(STEAL_STEALING_TABLE); } boolean gotSomething = false; while (types.size() > 0 && !gotSomething) { int roll = rand(0, types.size() - 1); - int flag = (((Integer)types.get(roll))).intValue(); + int flag = (Integer) types.get(roll); int markLevel = getLevel(mark); int thiefLevel = getLevel(thief); int stealRoll = rand(1, 100); @@ -1622,169 +1515,162 @@ public class stealth extends script.base_script switch (flag) { case STEAL_CREDITS: - if (isPlayer(mark)) - { - break; - } - int amt = (int)(getNpcCash(mark) * .2f); - if (amt > 0) - { - dictionary d = new dictionary(); - d.put(money.DICT_AMOUNT, amt); - boolean boolReturn = transferBankCreditsFromNamedAccount(money.ACCT_NPC_LOOT, thief, amt, "handleStealCashSuccess", "handleStealCashFail", d); - utils.moneyInMetric(mark, money.ACCT_NPC_LOOT, amt); - gotSomething = true; - } - break; - case STEAL_LOOT: - if (isPlayer(mark)) - { - break; - } - int lootRoll = rand(1, 100); - if (lootRoll >= STEAL_RARE_ITEM) - { - if (thiefLevel <= (markLevel + 10)) + if (isPlayer(mark)) { - if (!hasCompletedCollection(thief, "spy_unarmed_01")) - { - long slotValueOne = getCollectionSlotValue(thief, "col_spy_unarmed_01_01"); - long slotValueTwo = getCollectionSlotValue(thief, "col_spy_unarmed_01_02"); - long slotValueThree = getCollectionSlotValue(thief, "col_spy_unarmed_01_03"); - long slotValueFour = getCollectionSlotValue(thief, "col_spy_unarmed_01_04"); - if (slotValueOne == 0) - { - modifyCollectionSlotValue(thief, "col_spy_unarmed_01_01", 1); - } - else if (slotValueTwo == 0) - { - modifyCollectionSlotValue(thief, "col_spy_unarmed_01_02", 1); - } - else if (slotValueThree == 0) - { - modifyCollectionSlotValue(thief, "col_spy_unarmed_01_03", 1); - } - else if (slotValueFour == 0) - { - modifyCollectionSlotValue(thief, "col_spy_unarmed_01_04", 1); - } - } - gotSomething = loot.generateTheftLootRare(thiefInventory, mark, 1, thief); break; } - gotSomething = loot.generateTheftLoot(thiefInventory, mark, STEAL_LOOT_CHANCE_MOD, 1); - break; - } - if (lootRoll >= STEAL_REGULAR_ITEM && lootRoll < STEAL_RARE_ITEM) - { - if (thiefLevel <= (markLevel + 10)) + int amt = (int)(getNpcCash(mark) * .2f); + if (amt > 0) { - boolean gotCollectionItem = false; - gotCollectionItem = loot.addCollectionLoot(mark, true, thief); - gotSomething = gotCollectionItem; - if (!gotCollectionItem) + dictionary d = new dictionary(); + d.put(money.DICT_AMOUNT, amt); + utils.moneyInMetric(mark, money.ACCT_NPC_LOOT, amt); + gotSomething = true; + } + break; + case STEAL_LOOT: + if (isPlayer(mark)) + { + break; + } + int lootRoll = rand(1, 100); + if (lootRoll >= STEAL_RARE_ITEM) + { + if (thiefLevel <= (markLevel + 10)) + { + if (!hasCompletedCollection(thief, "spy_unarmed_01")) + { + long slotValueOne = getCollectionSlotValue(thief, "col_spy_unarmed_01_01"); + long slotValueTwo = getCollectionSlotValue(thief, "col_spy_unarmed_01_02"); + long slotValueThree = getCollectionSlotValue(thief, "col_spy_unarmed_01_03"); + long slotValueFour = getCollectionSlotValue(thief, "col_spy_unarmed_01_04"); + if (slotValueOne == 0) + { + modifyCollectionSlotValue(thief, "col_spy_unarmed_01_01", 1); + } + else if (slotValueTwo == 0) + { + modifyCollectionSlotValue(thief, "col_spy_unarmed_01_02", 1); + } + else if (slotValueThree == 0) + { + modifyCollectionSlotValue(thief, "col_spy_unarmed_01_03", 1); + } + else if (slotValueFour == 0) + { + modifyCollectionSlotValue(thief, "col_spy_unarmed_01_04", 1); + } + } + gotSomething = loot.generateTheftLootRare(thiefInventory, mark, 1, thief); + break; + } + gotSomething = loot.generateTheftLoot(thiefInventory, mark, STEAL_LOOT_CHANCE_MOD, 1); + break; + } + if (lootRoll >= STEAL_REGULAR_ITEM && lootRoll < STEAL_RARE_ITEM) + { + if (thiefLevel <= (markLevel + 10)) + { + boolean gotCollectionItem; + gotCollectionItem = loot.addCollectionLoot(mark, true, thief); + gotSomething = gotCollectionItem; + if (!gotCollectionItem) + { + gotSomething = loot.generateTheftLoot(thiefInventory, mark, STEAL_LOOT_CHANCE_MOD, 1); + break; + } + break; + } + else { gotSomething = loot.generateTheftLoot(thiefInventory, mark, STEAL_LOOT_CHANCE_MOD, 1); break; } - break; } - else + if (lootRoll < STEAL_REGULAR_ITEM) { gotSomething = loot.generateTheftLoot(thiefInventory, mark, STEAL_LOOT_CHANCE_MOD, 1); break; } - } - if (lootRoll < STEAL_REGULAR_ITEM) - { - gotSomething = loot.generateTheftLoot(thiefInventory, mark, STEAL_LOOT_CHANCE_MOD, 1); break; - } - break; case STEAL_TEMPLATE: - Vector itms = getStealableTemplates(mark); - if (itms.size() < 1) - { - break; - } - String templateLoot = (String)itms.get(rand(0, itms.size() - 1)); - if (templateLoot == null || templateLoot.length() < 1) - { - break; - } - obj_id templateObj = null; - if (templateLoot.startsWith("static:")) - { - java.util.StringTokenizer st = new java.util.StringTokenizer(templateLoot, ":"); - if (st.countTokens() == 2) + Vector itms = getStealableTemplates(mark); + if (itms.size() < 1) { - st.nextToken(); - String itemName = st.nextToken(); - templateObj = static_item.createNewItemFunction(templateLoot, thiefInventory); + break; } - } - else - { - templateObj = createObjectOverloaded(templateLoot, thiefInventory); - } - gotSomething = templateObj != null; - if (gotSomething) - { - utils.setScriptVar(thiefInventory, "theft_in_progress", 1); - loot.notifyThiefOfItemStolen(thiefInventory, templateObj); - } - break; + String templateLoot = (String)itms.get(rand(0, itms.size() - 1)); + if (templateLoot == null || templateLoot.length() < 1) + { + break; + } + obj_id templateObj = null; + if (templateLoot.startsWith("static:")) + { + java.util.StringTokenizer st = new java.util.StringTokenizer(templateLoot, ":"); + if (st.countTokens() == 2) + { + templateObj = static_item.createNewItemFunction(templateLoot, thiefInventory); + } + } + else + { + templateObj = createObjectOverloaded(templateLoot, thiefInventory); + } + gotSomething = templateObj != null; + if (gotSomething) + { + utils.setScriptVar(thiefInventory, "theft_in_progress", 1); + loot.notifyThiefOfItemStolen(thiefInventory, templateObj); + } + break; case STEAL_MARKED_ITEMS: - obj_id[] stuff = utils.getFilteredPlayerContents(mark); - Vector eligibleItems = new Vector(); - for (int i = 0; i < stuff.length; i++) - { - if (isItemStealable(stuff[i])) + obj_id[] stuff = utils.getFilteredPlayerContents(mark); + Vector eligibleItems = new Vector(); + for (obj_id aStuff : stuff) { + if (isItemStealable(aStuff)) { + eligibleItems.add(aStuff); + } + } + if (eligibleItems.size() < 1) { - eligibleItems.add(stuff[i]); + break; + } + obj_id markedObj = (obj_id)eligibleItems.get(rand(0, eligibleItems.size() - 1)); + gotSomething = putIn(markedObj, thiefInventory); + if (gotSomething) + { + CustomerServiceLog("stealing", "%TU stole an item (" + markedObj + " - " + getName(markedObj) + ") from player %TT", thief, mark); + utils.setScriptVar(thiefInventory, "theft_in_progress", 1); + loot.notifyThiefOfItemStolen(thiefInventory, markedObj); } - } - if (eligibleItems.size() < 1) - { break; - } - obj_id markedObj = (obj_id)eligibleItems.get(rand(0, eligibleItems.size() - 1)); - gotSomething = putIn(markedObj, thiefInventory); - if (gotSomething) - { - CustomerServiceLog("stealing", "%TU stole an item (" + markedObj + " - " + getName(markedObj) + ") from player %TT", thief, mark); - utils.setScriptVar(thiefInventory, "theft_in_progress", 1); - loot.notifyThiefOfItemStolen(thiefInventory, markedObj); - } - break; case STEAL_STEALING_TABLE: - String tableTemplate = getStealableTemplateFromTable(mark); - if (tableTemplate == null || tableTemplate.length() < 1) - { - break; - } - obj_id tableObj = null; - if (tableTemplate.startsWith("static:")) - { - java.util.StringTokenizer st = new java.util.StringTokenizer(tableTemplate, ":"); - if (st.countTokens() == 2) + String tableTemplate = getStealableTemplateFromTable(mark); + if (tableTemplate == null || tableTemplate.length() < 1) { - st.nextToken(); - String itemName = st.nextToken(); - tableObj = static_item.createNewItemFunction(tableTemplate, thiefInventory); + break; } - } - else - { - tableObj = createObjectOverloaded(tableTemplate, thiefInventory); - } - gotSomething = tableObj != null; - if (gotSomething) - { - utils.setScriptVar(thiefInventory, "theft_in_progress", 1); - loot.notifyThiefOfItemStolen(thiefInventory, tableObj); - } - break; + obj_id tableObj = null; + if (tableTemplate.startsWith("static:")) + { + java.util.StringTokenizer st = new java.util.StringTokenizer(tableTemplate, ":"); + if (st.countTokens() == 2) + { + tableObj = static_item.createNewItemFunction(tableTemplate, thiefInventory); + } + } + else + { + tableObj = createObjectOverloaded(tableTemplate, thiefInventory); + } + gotSomething = tableObj != null; + if (gotSomething) + { + utils.setScriptVar(thiefInventory, "theft_in_progress", 1); + loot.notifyThiefOfItemStolen(thiefInventory, tableObj); + } + break; } } stealFlags &= ~flag; @@ -1802,11 +1688,7 @@ public class stealth extends script.base_script String type = loot.getCreatureType(name); String table = "datatables/loot/stealing_loot.iff"; int row = dataTableSearchColumnForInt(getStringCrc(type), "npc_type", table); - if (row < 0) - { - return false; - } - return true; + return row >= 0; } public static String getStealableTemplateFromTable(obj_id mark) throws InterruptedException { @@ -1823,7 +1705,7 @@ public class stealth extends script.base_script while (true) { stuff.add(dataTableGetString(table, row, "stealableObjects")); - weights.add(new Integer(dataTableGetInt(table, row, "weight"))); + weights.add(dataTableGetInt(table, row, "weight")); row++; if (row >= rows || dataTableGetInt(table, row, "npc_type") != 0) { @@ -1834,7 +1716,7 @@ public class stealth extends script.base_script int[] weightArray = new int[weights.size()]; for (int i = 0; i < weightArray.length; i++) { - weightArray[i] = (((Integer)weights.get(i))).intValue(); + weightArray[i] = (Integer) weights.get(i); total += weightArray[i]; } if (total < 1) @@ -1950,11 +1832,7 @@ public class stealth extends script.base_script } } showFlyTextPrivate(thief, thief, new string_id("spam", "stealin_on"), 1.5f, colors.TOMATO); - if (doTheftLoot(thief, mark)) - { - } - else - { + if (!doTheftLoot(thief, mark)) { sendSystemMessage(thief, new string_id("spam", "stolen_nothing")); } return true; @@ -1975,13 +1853,10 @@ public class stealth extends script.base_script int sGuildId = getGuildId(player); if (stuff.length > 0) { - for (int i = 0; i < stuff.length; i++) - { - if (ai_lib.isHumanoid(stuff[i])) - { - boolean isInSameGuild = (sGuildId != 0) && (getGuildId(stuff[i]) == sGuildId); - if (!isInSameGuild && !group.inSameGroup(player, stuff[i])) - { + for (obj_id aStuff : stuff) { + if (ai_lib.isHumanoid(aStuff)) { + boolean isInSameGuild = (sGuildId != 0) && (getGuildId(aStuff) == sGuildId); + if (!isInSameGuild && !group.inSameGroup(player, aStuff)) { skill -= witnessPenalty; } } @@ -2038,24 +1913,22 @@ public class stealth extends script.base_script switch (getStringCrc(buffName)) { case (-879194497): - modName = "camouflage"; - break; case (1252380095): - modName = "camouflage"; - break; + modName = "camouflage"; + break; case (815407714): case (-1923109470): - break; + break; case (-121504680): - modName = "cover"; - break; + modName = "cover"; + break; case (1206342977): case (-50098035): - modName = "stealth"; - break; + modName = "stealth"; + break; case (342850470): - modName = ""; - break; + modName = ""; + break; } int mod = 0; if (modName.length() > 0) @@ -2154,6 +2027,7 @@ public class stealth extends script.base_script modChanceToDetectMod = modDiff / 4.0f; finalChanceToDetect = finalChanceToDetect + modChanceToDetectMod; } + assert invis != null; if (invis.startsWith("invis_forceCloak") || (invis.startsWith("invis_fs_buff_invis"))) { finalChanceToDetect = (finalChanceToDetect - 10.0f); @@ -2252,6 +2126,7 @@ public class stealth extends script.base_script finalChanceToDetect = finalChanceToDetect + modChanceToDetectMod; sendConsoleMessage(objectToReceiveDetailedOutput, "passiveDetectInfo: stealtherSkillMod < detectorSkillMod, modDiff=" + modDiff + ", modChanceToDetectMod (modDiff / 4.0f)=" + modChanceToDetectMod + ", finalChanceToDetect (finalChanceToDetect + modChanceToDetectMod)=" + finalChanceToDetect); } + assert invis != null; if (invis.startsWith("invis_forceCloak") || (invis.startsWith("invis_fs_buff_invis"))) { finalChanceToDetect = (finalChanceToDetect - 10.0f); @@ -2518,12 +2393,10 @@ public class stealth extends script.base_script return; } obj_id[] hateList = getHateList(player); - for (int i = 0; i < hateList.length; i++) - { - if (isIdValid(hateList[i]) && exists(hateList[i])) - { - removeHateTarget(hateList[i], player); - removeHateTarget(player, hateList[i]); + for (obj_id aHateList : hateList) { + if (isIdValid(aHateList) && exists(aHateList)) { + removeHateTarget(aHateList, player); + removeHateTarget(player, aHateList); } } clearHateList(player); @@ -2591,8 +2464,7 @@ public class stealth extends script.base_script { return; } - obj_id beast = beast_lib.getBeastOnPlayer(player); - makeCreatureVisible(beast); + makeCreatureVisible(beast_lib.getBeastOnPlayer(player)); } public static void makePassiveRevealed(obj_id target) throws InterruptedException { @@ -2614,14 +2486,10 @@ public class stealth extends script.base_script obj_id groupObj = getGroupObject(target); obj_id[] groupMembers = getGroupMemberIds(groupObj); int numGroupMembers = groupMembers.length; - for (int f = 0; f < numGroupMembers; f++) - { - obj_id groupie = groupMembers[f]; - if (isIdValid(groupie) && exists(groupie) && groupie != target) - { + for (obj_id groupie : groupMembers) { + if (isIdValid(groupie) && exists(groupie) && groupie != target) { addPassiveReveal(target, groupie, 1); - if (isIdValid(beast) && exists(beast)) - { + if (isIdValid(beast) && exists(beast)) { addPassiveReveal(beast, groupie, 1); } } @@ -2639,7 +2507,6 @@ public class stealth extends script.base_script setState(player, STATE_COVER, true); setCreatureCoverVisibility(player, false); cleanupHate(player); - obj_id beast = makeBeastInvisible(player, clientEffect); makePassiveRevealed(player); if (flyText != null) { @@ -2691,19 +2558,11 @@ public class stealth extends script.base_script } public static boolean checkRevealRecourse(obj_id player) throws InterruptedException { - if (buff.hasBuff(player, "sp_sneak_recourse")) - { - return true; - } - return false; + return buff.hasBuff(player, "sp_sneak_recourse"); } public static boolean checkAttackRevealRecourse(obj_id player) throws InterruptedException { - if (buff.hasBuff(player, "sp_attack_invis_recourse")) - { - return true; - } - return false; + return buff.hasBuff(player, "sp_attack_invis_recourse"); } public static boolean canPerformForceCloak(obj_id player) throws InterruptedException { @@ -2923,7 +2782,6 @@ public class stealth extends script.base_script { decoyStealth(mobile); } - return; } public static boolean canPerformCamouflageSelf(obj_id player) throws InterruptedException { @@ -2977,7 +2835,6 @@ public class stealth extends script.base_script { sendSystemMessage(player, new string_id("spam", "failedcamo")); } - return; } public static boolean canPerformCamouflageAlly(obj_id player, obj_id target) throws InterruptedException { @@ -3083,13 +2940,10 @@ public class stealth extends script.base_script int sGuildId = getGuildId(player); boolean isInSameGuild = false; obj_id[] stuff = getCreaturesInRange(player, 20f); - for (int i = 0; i < stuff.length; i++) - { - if (isPlayer(stuff[i]) || ai_lib.isNpc(stuff[i])) - { - isInSameGuild = (sGuildId != 0) && (getGuildId(stuff[i]) == sGuildId); - if (!isInSameGuild && !group.inSameGroup(player, stuff[i])) - { + for (obj_id aStuff : stuff) { + if (isPlayer(aStuff) || ai_lib.isNpc(aStuff)) { + isInSameGuild = (sGuildId != 0) && (getGuildId(aStuff) == sGuildId); + if (!isInSameGuild && !group.inSameGroup(player, aStuff)) { sendSystemMessage(player, new string_id("spam", "cant_urban_stealth_people_in_area")); return false; } @@ -3189,7 +3043,6 @@ public class stealth extends script.base_script utils.removeScriptVar(player, "supressVisible"); sendSystemMessage(player, new string_id("spam", "stealthfail")); } - return; } public static boolean canPerformCover(obj_id player) throws InterruptedException { @@ -3379,11 +3232,9 @@ public class stealth extends script.base_script return null; } String curBuff = ""; - for (int i = 0; i < buffs.length; i++) - { - curBuff = buff.getBuffNameFromCrc(buffs[i]); - if (curBuff != null && curBuff.startsWith("invis_")) - { + for (int aBuff : buffs) { + curBuff = buff.getBuffNameFromCrc(aBuff); + if (curBuff != null && curBuff.startsWith("invis_")) { return curBuff; } } @@ -3411,14 +3262,11 @@ public class stealth extends script.base_script } obj_id[] contents = getContents(pInv); obj_id hep = null; - for (int i = 0; i < contents.length; i++) - { - if (hasObjVar(contents[i], "isHEP")) - { - power = getCount(contents[i]); - if (power >= HEP_UPKEEP_COST) - { - hep = contents[i]; + for (obj_id content : contents) { + if (hasObjVar(content, "isHEP")) { + power = getCount(content); + if (power >= HEP_UPKEEP_COST) { + hep = content; break; } } @@ -3443,14 +3291,11 @@ public class stealth extends script.base_script } obj_id[] contents = getContents(pInv); obj_id kit = null; - for (int i = 0; i < contents.length; i++) - { - if (hasObjVar(contents[i], "camokit")) - { - String kitPlanet = getStringObjVar(contents[i], "camokit"); - if (kitPlanet.equals(planetName)) - { - kit = contents[i]; + for (obj_id content : contents) { + if (hasObjVar(content, "camokit")) { + String kitPlanet = getStringObjVar(content, "camokit"); + if (kitPlanet.equals(planetName)) { + kit = content; break; } } @@ -3484,10 +3329,8 @@ public class stealth extends script.base_script } obj_id[] stuff = getNonCreaturesInRange(loc, 50f); int numStructures = 0; - for (int i = 0; i < stuff.length; i++) - { - if (isGameObjectTypeOf(stuff[i], GOT_building) || isGameObjectTypeOf(stuff[i], GOT_installation)) - { + for (obj_id aStuff : stuff) { + if (isGameObjectTypeOf(aStuff, GOT_building) || isGameObjectTypeOf(aStuff, GOT_installation)) { numStructures++; } } @@ -3503,20 +3346,11 @@ public class stealth extends script.base_script } public static boolean isFlagSet(int mask, int flag) throws InterruptedException { - if ((mask & flag) == flag) - { - return true; - } - return false; + return (mask & flag) == flag; } public static boolean isPvPTrap(obj_id trap) throws InterruptedException { - int triggerTypeInt = getIntObjVar(trap, TRIGGER_TYPE); - if (triggerTypeInt == TRIGGER_TYPE_PROXIMITY) - { - return true; - } - return false; + return getIntObjVar(trap, TRIGGER_TYPE) == TRIGGER_TYPE_PROXIMITY; } public static obj_id createDecoy(obj_id spy) throws InterruptedException { @@ -3529,32 +3363,32 @@ public class stealth extends script.base_script switch (species) { case SPECIES_RODIAN: - speciesString = "rodian"; - break; + speciesString = "rodian"; + break; case SPECIES_TRANDOSHAN: - speciesString = "trandoshan"; - break; + speciesString = "trandoshan"; + break; case SPECIES_MON_CALAMARI: - speciesString = "moncal"; - break; + speciesString = "moncal"; + break; case SPECIES_WOOKIEE: - speciesString = "wookiee"; - break; + speciesString = "wookiee"; + break; case SPECIES_BOTHAN: - speciesString = "bothan"; - break; + speciesString = "bothan"; + break; case SPECIES_TWILEK: - speciesString = "twilek"; - break; + speciesString = "twilek"; + break; case SPECIES_ZABRAK: - speciesString = "zabrak"; - break; + speciesString = "zabrak"; + break; case SPECIES_ITHORIAN: - speciesString = "ithorian"; - break; + speciesString = "ithorian"; + break; case SPECIES_SULLUSTAN: - speciesString = "sullustan"; - break; + speciesString = "sullustan"; + break; } if (gender == GENDER_FEMALE) { @@ -3575,13 +3409,13 @@ public class stealth extends script.base_script custom_var[] var_list = getAllCustomVars(spy); if (var_list != null && var_list.length > 0) { - for (int i = 0; i < var_list.length; i++) - { - ranged_int_custom_var ricv = (ranged_int_custom_var)var_list[i]; - String var = ricv.getVarName(); + ranged_int_custom_var ricv; + String var; + for (custom_var aVar_list : var_list) { + ricv = (ranged_int_custom_var) aVar_list; + var = ricv.getVarName(); int value = ricv.getValue(); - if (value != 0) - { + if (value != 0) { setRangedIntCustomVarValue(hologram, var, value); } } @@ -3591,33 +3425,29 @@ public class stealth extends script.base_script utils.setObjVar(hologram, "hologram_performer", 1); if (contents != null && contents.length > 0) { - for (int i = 0; i < contents.length; i++) - { - if (isIdValid(contents[i])) - { - if (getContainerType(contents[i]) == 0) - { - if (!(getTemplateName(contents[i])).endsWith("player.iff")) - { - if (headSlotItem == contents[i] && isPlayerHelmetHidden(spy)) - { + custom_var[] object_var; + obj_id newObject; + ranged_int_custom_var ricv; + String var; + + for (obj_id content : contents) { + if (isIdValid(content)) { + if (getContainerType(content) == 0) { + if (!(getTemplateName(content)).endsWith("player.iff")) { + if (headSlotItem == content && isPlayerHelmetHidden(spy)) { continue; } - if (getGameObjectType(contents[i]) == GOT_misc_appearance_only_invisible) - { + if (getGameObjectType(content) == GOT_misc_appearance_only_invisible) { continue; } - custom_var[] object_var = getAllCustomVars(contents[i]); - obj_id newObject = createObject(getTemplateName(contents[i]), hologram, ""); - if (object_var != null && isIdValid(newObject)) - { - for (int q = 0; q < object_var.length; q++) - { - ranged_int_custom_var ricv = (ranged_int_custom_var)object_var[q]; - String var = ricv.getVarName(); + object_var = getAllCustomVars(content); + newObject = createObject(getTemplateName(content), hologram, ""); + if (object_var != null && isIdValid(newObject)) { + for (custom_var anObject_var : object_var) { + ricv = (ranged_int_custom_var) anObject_var; + var = ricv.getVarName(); int value = ricv.getValue(); - if (value != 0) - { + if (value != 0) { setRangedIntCustomVarValue(newObject, var, value); } } @@ -3634,21 +3464,20 @@ public class stealth extends script.base_script obj_id newObject = createObject(getTemplateName(backpack), hologram, "back"); if (object_var != null && isIdValid(newObject)) { - for (int q = 0; q < object_var.length; q++) - { - ranged_int_custom_var ricv = (ranged_int_custom_var)object_var[q]; - String var = ricv.getVarName(); + ranged_int_custom_var ricv; + String var; + for (custom_var anObject_var : object_var) { + ricv = (ranged_int_custom_var) anObject_var; + var = ricv.getVarName(); int value = ricv.getValue(); - if (value != 0) - { + if (value != 0) { setRangedIntCustomVarValue(newObject, var, value); } } } } obj_id spyWeapon = getCurrentWeapon(spy); - weapon_data weaponData = weapons.getNewWeaponData(spyWeapon); - obj_id holoWeapon = null; + obj_id holoWeapon; if (isDefaultWeapon(spyWeapon)) { holoWeapon = getCurrentWeapon(hologram); @@ -3681,14 +3510,13 @@ public class stealth extends script.base_script int[] buffCrc = buff.getAllBuffs(spy); if (buffCrc != null && buffCrc.length > 0) { - for (int i = 0; i < buffCrc.length; i++) - { - String curBuff = buff.getBuffNameFromCrc(buffCrc[i]); - if (curBuff != null && curBuff.startsWith("invis_")) - { + String curBuff; + for (int aBuffCrc : buffCrc) { + curBuff = buff.getBuffNameFromCrc(aBuffCrc); + if (curBuff != null && curBuff.startsWith("invis_")) { continue; } - buff.applyBuff(hologram, buffCrc[i], 360.0f); + buff.applyBuff(hologram, aBuffCrc, 360.0f); } } float dodgeChance = combat.getDefenderDodgeChance(spy); diff --git a/sku.0/sys.server/compiled/game/script/library/storyteller.java b/sku.0/sys.server/compiled/game/script/library/storyteller.java old mode 100644 new mode 100755 index beec97da0..96d76127b --- a/sku.0/sys.server/compiled/game/script/library/storyteller.java +++ b/sku.0/sys.server/compiled/game/script/library/storyteller.java @@ -1,21 +1,9 @@ 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.library.ai_lib; -import script.library.city; -import script.library.beast_lib; -import script.library.instance; -import script.library.pet_lib; -import script.library.player_structure; -import script.library.space_utils; -import script.library.utils; +import java.util.Arrays; +import java.util.Vector; public class storyteller extends script.base_script { @@ -143,28 +131,26 @@ public class storyteller extends script.base_script { return null; } - float yaw = getYaw(player); - return createTheaterObject(token, inBuildout, getLocation(player), yaw); + return createTheaterObject(token, inBuildout, getLocation(player), getYaw(player)); } public static obj_id createTheaterObject(obj_id token, boolean inBuildout, location createLoc, float yaw) throws InterruptedException { String itemName = getStaticItemName(token); - dictionary dict = new dictionary(); int row = dataTableSearchColumnForString(itemName, "name", storyteller.STORYTELLER_DATATABLE); if (row == -1) { return null; } - dict = dataTableGetRow(storyteller.STORYTELLER_DATATABLE, itemName); + dictionary dict = dataTableGetRow(storyteller.STORYTELLER_DATATABLE, itemName); String template = dict.getString("template_name"); - String objVarString = dict.getString("objvar"); - String scriptString = dict.getString("scripts"); obj_id theater = create.object(template, createLoc); setYaw(theater, yaw); if (!isIdValid(theater)) { return null; } + String objVarString = dict.getString("objvar"); + String scriptString = dict.getString("scripts"); static_item.setObjVarString(theater, objVarString); static_item.setScriptString(theater, scriptString); setStaticItemName(theater, getStaticItemName(token)); @@ -180,8 +166,7 @@ public class storyteller extends script.base_script { return null; } - float yaw = getYaw(player); - return createPropObject(token, player, inBuildout, getLocation(player), yaw); + return createPropObject(token, player, inBuildout, getLocation(player), getYaw(player)); } public static obj_id createPropObject(obj_id token, obj_id player, boolean inBuildout, location createLoc, float yaw) throws InterruptedException { @@ -189,19 +174,15 @@ public class storyteller extends script.base_script if (canDeployStorytellerToken(player, createLoc, token)) { String itemName = getStaticItemName(token); - dictionary dict = new dictionary(); - dictionary dict_m = new dictionary(); int row = dataTableSearchColumnForString(itemName, "name", STORYTELLER_DATATABLE); if (row == -1) { return null; } - dict = dataTableGetRow(STORYTELLER_DATATABLE, itemName); + dictionary dict = dataTableGetRow(STORYTELLER_DATATABLE, itemName); String template = dict.getString("template_name"); String objVarString = dict.getString("objvar"); String scriptString = dict.getString("scripts"); - dict_m = dataTableGetRow(STATIC_ITEM_DATATABLE, itemName); - String finalName = dict_m.getString("string_name"); prop = create.object(template, createLoc); if (isIdValid(prop)) { @@ -222,6 +203,7 @@ public class storyteller extends script.base_script setObjVar(prop, "storytellerid", player); setObjVar(prop, "storytellerName", getName(player)); } + String finalName = dataTableGetRow(STATIC_ITEM_DATATABLE, itemName).getString("string_name"); setObjVar(prop, "storytellerCreationLoc", createLoc); setObjVar(prop, "storytellerTokenName", itemName); attachScript(prop, STORYTELLER_PROP_CONTROL_SCRIPT); @@ -238,19 +220,15 @@ public class storyteller extends script.base_script obj_id prop = null; if (canDeployStorytellerToken(player, createLoc, tokenName)) { - dictionary dict = new dictionary(); - dictionary dict_m = new dictionary(); int row = dataTableSearchColumnForString(tokenName, "name", STORYTELLER_DATATABLE); if (row == -1) { return null; } - dict = dataTableGetRow(STORYTELLER_DATATABLE, tokenName); + dictionary dict = dataTableGetRow(STORYTELLER_DATATABLE, tokenName); String template = dict.getString("template_name"); String objVarString = dict.getString("objvar"); String scriptString = dict.getString("scripts"); - dict_m = dataTableGetRow(STATIC_ITEM_DATATABLE, tokenName); - String finalName = dict_m.getString("string_name"); prop = create.object(template, createLoc); if (isIdValid(prop)) { @@ -271,6 +249,7 @@ public class storyteller extends script.base_script setObjVar(prop, "storytellerid", player); setObjVar(prop, "storytellerName", getName(player)); } + String finalName = dataTableGetRow(STATIC_ITEM_DATATABLE, tokenName).getString("string_name"); setObjVar(prop, "storytellerCreationLoc", createLoc); setObjVar(prop, "storytellerTokenName", tokenName); attachScript(prop, STORYTELLER_PROP_CONTROL_SCRIPT); @@ -284,8 +263,7 @@ public class storyteller extends script.base_script public static obj_id createNpcAtLocation(obj_id token) throws InterruptedException { obj_id player = utils.getContainingPlayer(token); - float yaw = getYaw(player); - return createNpcAtLocation(token, player, getLocation(player), yaw); + return createNpcAtLocation(token, player, getLocation(player), getYaw(player)); } public static obj_id createNpcAtLocation(obj_id token, obj_id player, location createLoc, float yaw) throws InterruptedException { @@ -407,13 +385,12 @@ public class storyteller extends script.base_script public static void removeStorytellerPersistedEffect(obj_id self) throws InterruptedException { obj_id[] players = getPlayerCreaturesInRange(getLocation(self), 165.0f); - if (players != null || players.length > 0) + if (players != null && players.length > 0) { stopClientEffectObjByLabel(players, self, "storyteller_persisted_effect", false); removeObjVar(self, storyteller.EFFECT_ACTIVE_OBJVAR); removeTriggerVolume("storytellerPersistedEffect"); } - return; } public static boolean allowTokenPlacementInInteriors(obj_id token) throws InterruptedException { @@ -469,12 +446,7 @@ public class storyteller extends script.base_script } public static boolean isTokenFlaggedWithDailyUsage(String tokenName) throws InterruptedException { - int dailyUses = getTokenDailyUsageAmount(tokenName); - if (dailyUses > 0) - { - return true; - } - return false; + return getTokenDailyUsageAmount(tokenName) > 0; } public static int getTokenDailyUsesAvailable(obj_id token) throws InterruptedException { @@ -500,11 +472,9 @@ public class storyteller extends script.base_script } public static boolean hasTokenUsesAvailable(obj_id token) throws InterruptedException { - int num = 0; if (isTokenFlaggedWithDailyUsage(getStaticItemName(token))) { - num = getTokenDailyUsesAvailable(token); - if (num > 0) + if (getTokenDailyUsesAvailable(token) > 0) { return true; } @@ -532,7 +502,6 @@ public class storyteller extends script.base_script setObjVar(token, STORYTELLER_DAILY_COUNT_OBJVAR, dailyCount); sendDirtyAttributesNotification(token); } - return; } public static void resetTokenDailyCount(obj_id token) throws InterruptedException { @@ -556,15 +525,12 @@ public class storyteller extends script.base_script } } } - return; } public static void setTokenDailyCountResetTime(obj_id token) throws InterruptedException { - int currentTime = getCalendarTime(); int timeUntilAlarm = createDailyAlarmClock(token, "storytellerEffectTokenDailyAlarm", null, 4, 0, 0); - int alarmStamp = currentTime + timeUntilAlarm; + int alarmStamp = getCalendarTime() + timeUntilAlarm; setObjVar(token, storyteller.STORYTELLER_DAILY_COUNT_RESET, alarmStamp); - return; } public static boolean canDeployStorytellerToken(obj_id player, location here, obj_id token) throws InterruptedException { @@ -710,13 +676,9 @@ public class storyteller extends script.base_script region[] regionsHere = getRegionsAtPoint(here); if (regionsHere != null && regionsHere.length > 0) { - for (int i = 0; i < regionsHere.length; i++) - { - region testRegion = regionsHere[i]; - String regionName = testRegion.getName(); - int nameCheck = regionName.indexOf("storytellerblocked"); - if (nameCheck > -1) - { + for (region testRegion : regionsHere) { + int nameCheck = testRegion.getName().indexOf("storytellerblocked"); + if (nameCheck > -1) { return true; } } @@ -797,56 +759,39 @@ public class storyteller extends script.base_script obj_id[] storytellerObjects = getAllObjectsWithObjVar(getLocation(player), 165.0f, "storytellerid"); if (storytellerObjects != null && storytellerObjects.length > 0) { - for (int i = 0; i < storytellerObjects.length; i++) - { - obj_id object = storytellerObjects[i]; - obj_id myStoryteller = getObjIdObjVar(object, "storytellerid"); - if (isIdValid(myStoryteller)) - { + obj_id myStoryteller; + obj_id[] playerInStory; + String effectName; + for (obj_id object : storytellerObjects) { + myStoryteller = getObjIdObjVar(object, "storytellerid"); + if (isIdValid(myStoryteller)) { if (myStoryteller == storytellerPlayer) - { - if (hasObjVar(object, storyteller.EFFECT_ACTIVE_OBJVAR) && hasObjVar(object, storyteller.EFFECT_TOKEN_NAME)) - { - String storytellerTokenName = getStringObjVar(object, storyteller.EFFECT_TOKEN_NAME); - location here = getLocation(object); - String effectName = storyteller.getEffectName(storytellerTokenName); - obj_id[] playerInStory = - { - player - }; + if (hasObjVar(object, storyteller.EFFECT_ACTIVE_OBJVAR) && hasObjVar(object, storyteller.EFFECT_TOKEN_NAME)) { + effectName = storyteller.getEffectName(getStringObjVar(object, storyteller.EFFECT_TOKEN_NAME)); + playerInStory = new obj_id[]{player}; playClientEffectObj(playerInStory, effectName, object, "", null, "storyteller_persisted_effect"); } - } } } } - return; } public static void stopStorytellerEffectsInAreaToPlayer(obj_id player, obj_id storytellerPlayer) throws InterruptedException { obj_id[] storytellerObjects = getAllObjectsWithObjVar(getLocation(player), 165.0f, "storytellerid"); if (storytellerObjects != null && storytellerObjects.length > 0) { - for (int i = 0; i < storytellerObjects.length; i++) - { - obj_id object = storytellerObjects[i]; - obj_id myStoryteller = getObjIdObjVar(object, "storytellerid"); - if (isIdValid(myStoryteller)) - { - if (myStoryteller == storytellerPlayer) - { - if (hasObjVar(object, storyteller.EFFECT_ACTIVE_OBJVAR) && hasObjVar(object, storyteller.EFFECT_TOKEN_NAME)) - { - String storytellerTokenName = getStringObjVar(object, storyteller.EFFECT_TOKEN_NAME); - location here = getLocation(object); - String effectName = storyteller.getEffectName(storytellerTokenName); + obj_id myStoryteller; + for (obj_id object : storytellerObjects) { + myStoryteller = getObjIdObjVar(object, "storytellerid"); + if (isIdValid(myStoryteller)) { + if (myStoryteller == storytellerPlayer) { + if (hasObjVar(object, storyteller.EFFECT_ACTIVE_OBJVAR) && hasObjVar(object, storyteller.EFFECT_TOKEN_NAME)) { stopClientEffectObjByLabel(player, object, "storyteller_persisted_effect", false); } } } } } - return; } public static String[] recordBlueprintData(obj_id blueprint, obj_id[] storytellerObjects, obj_id player) throws InterruptedException { @@ -854,43 +799,35 @@ public class storyteller extends script.base_script blueprintString.setSize(0); Vector validStorytellerObjects = new Vector(); validStorytellerObjects.setSize(0); - for (int i = 0; i < storytellerObjects.length; i++) - { - obj_id object = storytellerObjects[i]; - obj_id objectOwner = getObjIdObjVar(object, "storytellerid"); - if (!isIdValid(objectOwner) || objectOwner != player) - { + obj_id objectOwner; + obj_id blueprintAuthor; + String tokenName; + String[] excludedTokens = {"st_fn_storyteller_vendor"}; + location tokLoc; + + for (obj_id object : storytellerObjects) { + objectOwner = getObjIdObjVar(object, "storytellerid"); + if (!isIdValid(objectOwner) || objectOwner != player) { continue; } - if (hasObjVar(object, storyteller.BLUEPRINT_AUTHOR_OBJVAR)) - { - obj_id blueprintAuthor = getObjIdObjVar(object, storyteller.BLUEPRINT_AUTHOR_OBJVAR); - if (!isIdValid(blueprintAuthor) || blueprintAuthor != player) - { + if (hasObjVar(object, storyteller.BLUEPRINT_AUTHOR_OBJVAR)) { + blueprintAuthor = getObjIdObjVar(object, storyteller.BLUEPRINT_AUTHOR_OBJVAR); + if (!isIdValid(blueprintAuthor) || blueprintAuthor != player) { continue; } } - String tokenName = getStaticItemName(object); - if (tokenName == null || tokenName.length() < 1) - { + tokenName = getStaticItemName(object); + if (tokenName == null || tokenName.length() < 1) { continue; } - String[] excludedTokens = - { - "st_fn_storyteller_vendor" - }; boolean isExcludedToken = false; - location tokLoc = getLocation(object); obj_id whatAmIStandingOn = getStandingOn(object); - for (int q = 0; q < excludedTokens.length; q++) - { - if (tokenName.equals(excludedTokens[q]) || storyteller.getTokenType(tokenName) == storyteller.OTHER || isIdValid(tokLoc.cell) || (isIdValid(whatAmIStandingOn) && player_structure.isBuilding(whatAmIStandingOn))) - { + for (String excludedToken : excludedTokens) { + if (tokenName.equals(excludedToken) || storyteller.getTokenType(tokenName) == storyteller.OTHER || isIdValid(getLocation(object).cell) || (isIdValid(whatAmIStandingOn) && player_structure.isBuilding(whatAmIStandingOn))) { isExcludedToken = true; } } - if (isExcludedToken) - { + if (isExcludedToken) { continue; } utils.addElement(validStorytellerObjects, object); @@ -905,82 +842,69 @@ public class storyteller extends script.base_script } return _blueprintString; } - location centerLoc = new location(); float maxX = -99999.0f; float maxZ = -99999.0f; float minX = 99999.0f; float minZ = 99999.0f; - for (int j = 0; j < validStorytellerObjects.size(); j++) - { - obj_id object = ((obj_id)validStorytellerObjects.get(j)); - obj_id objectOwner = getObjIdObjVar(object, "storytellerid"); - if (!isIdValid(objectOwner) || objectOwner != player) - { + obj_id object; + for (Object validStorytellerObject : validStorytellerObjects) { + object = ((obj_id) validStorytellerObject); + objectOwner = getObjIdObjVar(object, "storytellerid"); + if (!isIdValid(objectOwner) || objectOwner != player) { continue; } location objLoc = getLocation(object); - if (objLoc.x > maxX) - { + if (objLoc.x > maxX) { maxX = objLoc.x; } - if (objLoc.z > maxZ) - { + if (objLoc.z > maxZ) { maxZ = objLoc.z; } - if (objLoc.x < minX) - { + if (objLoc.x < minX) { minX = objLoc.x; } - if (objLoc.z < minZ) - { + if (objLoc.z < minZ) { minZ = objLoc.z; } } - centerLoc = new location(maxX - ((maxX - minX) / 2), 0.0f, maxZ - ((maxZ - minZ) / 2)); - for (int i = 0; i < validStorytellerObjects.size(); i++) - { - obj_id validStoryObject = ((obj_id)validStorytellerObjects.get(i)); - String tokenName = getStaticItemName(validStoryObject); - location playerLoc = getLocation(player); + obj_id validStoryObject; + location playerLoc; + for (Object validStorytellerObject : validStorytellerObjects) { + validStoryObject = ((obj_id) validStorytellerObject); + tokenName = getStaticItemName(validStoryObject); + playerLoc = getLocation(player); float playerYaw = getYaw(player); location objLoc = getLocation(validStoryObject); float objYaw = getYaw(validStoryObject); - if (playerYaw != 0) - { + if (playerYaw != 0) { objLoc = storyteller.rotateSavedBlueprintDataXZ(playerLoc, objLoc, playerYaw); } - float yawDiff = playerYaw - objYaw; float terrainHeight = objLoc.y; location creationLoc = getLocationObjVar(validStoryObject, "storytellerCreationLoc"); - if (creationLoc != null) - { + if (creationLoc != null) { terrainHeight = creationLoc.y; } float locX = objLoc.x - playerLoc.x; float locY = objLoc.y - terrainHeight; float locZ = objLoc.z - playerLoc.z; - if (locY < 0.001f) - { + if (locY < 0.001f) { locY = 0.0f; } int combatLevel = 0; int difficulty = 0; - if (isMob(validStoryObject)) - { + if (isMob(validStoryObject)) { combatLevel = getLevel(validStoryObject); difficulty = getIntObjVar(validStoryObject, "difficultyClass"); } String effect = "none"; - if (hasObjVar(validStoryObject, storyteller.EFFECT_ACTIVE_OBJVAR) && hasObjVar(validStoryObject, storyteller.EFFECT_TOKEN_NAME)) - { + if (hasObjVar(validStoryObject, storyteller.EFFECT_ACTIVE_OBJVAR) && hasObjVar(validStoryObject, storyteller.EFFECT_TOKEN_NAME)) { effect = getStringObjVar(validStoryObject, storyteller.EFFECT_TOKEN_NAME); String effectEntry = buildBlueprintObjectData(storyteller.BLUEPRINT_TOKEN_NEEDED, effect, 0.0f, 0.0f, 0.0f, 0.0f, 0, 0, "none"); utils.addElement(blueprintString, effectEntry); } - String newEntry = buildBlueprintObjectData(storyteller.BLUEPRINT_TOKEN_NEEDED, tokenName, locX, locY, locZ, yawDiff, combatLevel, difficulty, effect); + String newEntry = buildBlueprintObjectData(storyteller.BLUEPRINT_TOKEN_NEEDED, tokenName, locX, locY, locZ, playerYaw - objYaw, combatLevel, difficulty, effect); utils.addElement(blueprintString, newEntry); - if (blueprintString.size() >= BLUEPRINT_MAX_NUM_OBJECTS) - { + if (blueprintString.size() >= BLUEPRINT_MAX_NUM_OBJECTS) { break; } } @@ -1015,8 +939,7 @@ public class storyteller extends script.base_script } public static int getBlueprintObjectDataSize(String blueprintObjectData) throws InterruptedException { - String[] parse = split(blueprintObjectData, '~'); - return parse.length; + return split(blueprintObjectData, '~').length; } public static int getRequiredBlueprintDataSize() throws InterruptedException { @@ -1025,11 +948,7 @@ public class storyteller extends script.base_script } public static boolean validateBlueprintData(String blueprintObjectData) throws InterruptedException { - if (getBlueprintObjectDataSize(blueprintObjectData) == getRequiredBlueprintDataSize()) - { - return true; - } - return false; + return getBlueprintObjectDataSize(blueprintObjectData) == getRequiredBlueprintDataSize(); } public static obj_id createBlueprintObject(String objectData, obj_id blueprintController, obj_id player, location targetLoc, float targetYaw) throws InterruptedException { @@ -1095,16 +1014,14 @@ public class storyteller extends script.base_script } public static void handleBlueprintObjectElevation(obj_id blueprintObject, dictionary params) throws InterruptedException { - if (params != null || !params.isEmpty()) + if (params != null && !params.isEmpty()) { float yOffset = params.getFloat("yOffset"); - obj_id player = params.getObjId("player"); location here = getLocation(blueprintObject); setObjVar(blueprintObject, "storytellerCreationLoc", here); location newElevationLoc = new location(here.x, here.y + yOffset, here.z); setLocation(blueprintObject, newElevationLoc); } - return; } public static location getBlueprintObjectLocation(String spawnString, location centerLoc) throws InterruptedException { @@ -1115,52 +1032,39 @@ public class storyteller extends script.base_script } public static boolean isBlueprintTokenLoaded(String spawnString) throws InterruptedException { - String[] parse = split(spawnString, '~'); - if (utils.stringToInt(parse[0]) == 1) - { - return true; - } - return false; + return utils.stringToInt(split(spawnString, '~')[0]) == 1; } public static String getBlueprintItemName(String spawnString) throws InterruptedException { - String[] parse = split(spawnString, '~'); - return parse[1]; + return split(spawnString, '~')[1]; } public static float getBlueprintItemLocX(String spawnString) throws InterruptedException { - String[] parse = split(spawnString, '~'); - return utils.stringToFloat(parse[2]); + return utils.stringToFloat(split(spawnString, '~')[2]); } public static float getBlueprintItemLocY(String spawnString) throws InterruptedException { - String[] parse = split(spawnString, '~'); - return utils.stringToFloat(parse[3]); + return utils.stringToFloat(split(spawnString, '~')[3]); } public static float getBlueprintItemLocZ(String spawnString) throws InterruptedException { - String[] parse = split(spawnString, '~'); - return utils.stringToFloat(parse[4]); + return utils.stringToFloat(split(spawnString, '~')[4]); } public static float getBlueprintItemYaw(String spawnString) throws InterruptedException { - String[] parse = split(spawnString, '~'); - return utils.stringToFloat(parse[5]); + return utils.stringToFloat(split(spawnString, '~')[5]); } public static int getBlueprintItemCombatLevel(String spawnString) throws InterruptedException { - String[] parse = split(spawnString, '~'); - return utils.stringToInt(parse[6]); + return utils.stringToInt(split(spawnString, '~')[6]); } public static int getBlueprintItemDifficulty(String spawnString) throws InterruptedException { - String[] parse = split(spawnString, '~'); - return utils.stringToInt(parse[7]); + return utils.stringToInt(split(spawnString, '~')[7]); } public static String getBlueprintItemEffect(String spawnString) throws InterruptedException { - String[] parse = split(spawnString, '~'); - return parse[8]; + return split(spawnString, '~')[8]; } public static void blueprintParseConversion(obj_id blueprint) throws InterruptedException { @@ -1194,19 +1098,9 @@ public class storyteller extends script.base_script { utils.setBatchObjVar(blueprint, storyteller.BLUEPRINT_OBJECTS_OBJVAR, blueprintObjects); } - return; } - public static boolean doIAutoDeclineStorytellerInvites(obj_id player) throws InterruptedException - { - if (hasObjVar(player, storyteller.VAR_AUTODECLINE_STORY_INVITES)) - { - return true; - } - if (utils.hasScriptVar(player, "battlefield.active")) - { - return true; - } - return false; + public static boolean doIAutoDeclineStorytellerInvites(obj_id player) throws InterruptedException { + return hasObjVar(player, storyteller.VAR_AUTODECLINE_STORY_INVITES) || utils.hasScriptVar(player, "battlefield.active"); } public static int storyAssistantSui(obj_id storytellerPlayer, String storytellerName, obj_id player) throws InterruptedException { @@ -1214,8 +1108,7 @@ public class storyteller extends script.base_script prose_package pp = prose.getPackage(new string_id("storyteller", "assistant_invite")); prose.setTO(pp, storytellerName); String msg = "\0" + packOutOfBandProsePackage(null, pp); - int pid = sui.msgbox(storytellerPlayer, player, msg, 2, title, sui.YES_NO, "storyAssistantHandler"); - return pid; + return sui.msgbox(storytellerPlayer, player, msg, 2, title, sui.YES_NO, "storyAssistantHandler"); } public static void storyAssistantAcepted(obj_id storytellerPlayer, String storytellerName, obj_id player) throws InterruptedException { @@ -1228,7 +1121,6 @@ public class storyteller extends script.base_script messageTo(storytellerPlayer, "handleStorytellerAssistantHasBeenAdded", webster, 0, false); utils.setScriptVar(player, "storytellerAssistant", storytellerPlayer); utils.setScriptVar(player, "storytellerAssistantName", storytellerName); - return; } public static void storyPlayerRemoveAssistant(obj_id storytellerPlayer, String storytellerName, obj_id player) throws InterruptedException { @@ -1241,7 +1133,6 @@ public class storyteller extends script.base_script dictionary webster = new dictionary(); webster.put("removedPlayerName", getName(player)); messageTo(storytellerPlayer, "handleStorytellerAssistantHasBeenRemoved", webster, 0, false); - return; } public static int storyInviteSui(obj_id storytellerPlayer, String storytellerName, obj_id player) throws InterruptedException { @@ -1249,8 +1140,7 @@ public class storyteller extends script.base_script prose_package pp = prose.getPackage(new string_id("storyteller", "sui_invite_body")); prose.setTO(pp, storytellerName); String msg = "\0" + packOutOfBandProsePackage(null, pp); - int pid = sui.msgbox(storytellerPlayer, player, msg, 2, title, sui.YES_NO, "storyInviteHandler"); - return pid; + return sui.msgbox(storytellerPlayer, player, msg, 2, title, sui.YES_NO, "storyInviteHandler"); } public static void storyInviteAcepted(obj_id storytellerPlayer, String storytellerName, obj_id player, obj_id storytellerAssistant) throws InterruptedException { @@ -1272,7 +1162,6 @@ public class storyteller extends script.base_script utils.setScriptVar(player, "storytellerid", storytellerPlayer); utils.setScriptVar(player, "storytellerName", storytellerName); showStorytellerEffectsInAreaToPlayer(player, storytellerPlayer); - return; } public static void storyPlayerRemovedFromStory(obj_id storytellerPlayer, String storytellerName, obj_id player) throws InterruptedException { @@ -1285,7 +1174,6 @@ public class storyteller extends script.base_script dictionary webster = new dictionary(); webster.put("removedPlayerName", getName(player)); messageTo(storytellerPlayer, "handleStorytellerPlayerHasBeenRemoved", webster, 0, false); - return; } public static boolean storytellerCombatCheck(obj_id attacker, obj_id target) throws InterruptedException { @@ -1361,14 +1249,7 @@ public class storyteller extends script.base_script { obj_id attackerNpcStoryteller = getObjIdObjVar(attacker, "storytellerid"); obj_id targetNpcStoryteller = getObjIdObjVar(target, "storytellerid"); - if (attackerNpcStoryteller == targetNpcStoryteller) - { - return true; - } - else - { - return false; - } + return attackerNpcStoryteller == targetNpcStoryteller; } else { @@ -1383,14 +1264,7 @@ public class storyteller extends script.base_script { obj_id playerStorytellerId = utils.getObjIdScriptVar(storyPlayer, "storytellerid"); obj_id npcStorytellerId = getObjIdObjVar(storyNpc, "storytellerid"); - if (isIdValid(playerStorytellerId) && isIdValid(npcStorytellerId) && playerStorytellerId == npcStorytellerId) - { - return true; - } - else - { - return false; - } + return isIdValid(playerStorytellerId) && isIdValid(npcStorytellerId) && playerStorytellerId == npcStorytellerId; } else { @@ -1431,9 +1305,9 @@ public class storyteller extends script.base_script }; Vector storytellerTokenTypes = new Vector(); storytellerTokenTypes.setSize(0); - for (int i = 0; i < sid_storytellerTokenTypes.length; i++) - { - String tokenType = utils.packStringId(new string_id("storyteller", sid_storytellerTokenTypes[i])); + String tokenType; + for (String sid_storytellerTokenType : sid_storytellerTokenTypes) { + tokenType = utils.packStringId(new string_id("storyteller", sid_storytellerTokenType)); storytellerTokenTypes = utils.addElement(storytellerTokenTypes, tokenType); } String[] _storytellerTokenTypes = new String[0]; @@ -1530,11 +1404,8 @@ public class storyteller extends script.base_script utils.copyArray(finalList, tempList); finalList[0] = "item_costume_kit"; int nextFinalListSlot = 1; - for (int k = 0; k < tempList.length; k++) - { - String ref = tempList[k]; - if (!ref.equals("item_costume_kit")) - { + for (String ref : tempList) { + if (!ref.equals("item_costume_kit")) { finalList[nextFinalListSlot] = ref; ++nextFinalListSlot; } @@ -1623,9 +1494,7 @@ public class storyteller extends script.base_script { return; } - int oldPid = utils.getIntScriptVar(storytellerVendor, scriptvar_path + ".pid"); String[] tokenReferences = utils.getStringBatchScriptVar(storytellerVendor, scriptvar_path + ".tokenReferences"); - String[] tokens = utils.getStringBatchScriptVar(storytellerVendor, scriptvar_path + ".tokens"); int tokenType = utils.getIntScriptVar(storytellerVendor, scriptvar_path + ".tokenType"); utils.removeScriptVar(storytellerVendor, scriptvar_path + ".pid"); utils.removeBatchScriptVar(storytellerVendor, scriptvar_path + ".tokenReferences"); @@ -1692,7 +1561,6 @@ public class storyteller extends script.base_script } givePurchasedToken(storytellerVendor, player, token_reference, tokenName, cost, 0); storyteller.displayStorytellerTokenPurchaseSUI(player, tokenType, storytellerVendor); - return; } public static boolean requestNumCharges(int tokenType, String token_reference) throws InterruptedException { @@ -1708,11 +1576,7 @@ public class storyteller extends script.base_script { return true; } - if (token_reference.equals("item_costume_kit")) - { - return true; - } - return false; + return token_reference.equals("item_costume_kit"); } public static void storytellerSellTokenWithCharges(dictionary params, obj_id storytellerVendor) throws InterruptedException { @@ -1753,7 +1617,6 @@ public class storyteller extends script.base_script givePurchasedToken(storytellerVendor, player, token_reference, tokenName, cost * numCharges, numCharges); storyteller.displayStorytellerTokenPurchaseSUI(player, tokenType, storytellerVendor); } - return; } public static void givePurchasedToken(obj_id storytellerVendor, obj_id player, String tokenReference, String tokenName, int cost, int numCharges) throws InterruptedException { @@ -1765,8 +1628,7 @@ public class storyteller extends script.base_script } if (!money.hasFunds(player, money.MT_TOTAL, cost)) { - prose_package pp = prose.getPackage(new string_id("storyteller", "token_purchase_not_enough_credits"), tokenName); - sendSystemMessageProse(player, pp); + sendSystemMessageProse(player, prose.getPackage(new string_id("storyteller", "token_purchase_not_enough_credits"), tokenName)); } else { @@ -1793,10 +1655,8 @@ public class storyteller extends script.base_script } CustomerServiceLog("storyteller", "(" + player + ")" + getName(player) + " has purchased (" + item + ")" + getName(item)); logBalance("storyteller;" + getGameTime() + ";item;" + tokenReference + ";" + cost); - prose_package pp = prose.getPackage(new string_id("storyteller", "token_purchase_complete"), player, item); - sendSystemMessageProse(player, pp); + sendSystemMessageProse(player, prose.getPackage(new string_id("storyteller", "token_purchase_complete"), player, item)); } - return; } public static void confirmCleanuptime(obj_id object) throws InterruptedException { diff --git a/sku.0/sys.server/compiled/game/script/library/structure.java b/sku.0/sys.server/compiled/game/script/library/structure.java old mode 100644 new mode 100755 index cbefd44f2..a09616af7 --- a/sku.0/sys.server/compiled/game/script/library/structure.java +++ b/sku.0/sys.server/compiled/game/script/library/structure.java @@ -1,17 +1,11 @@ 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.dictionary; +import script.location; +import script.obj_id; +import script.string_id; -import script.library.skill; -import script.library.utils; -import script.library.list; -import script.library.datatable; +import java.util.Vector; public class structure extends script.base_script { @@ -108,11 +102,7 @@ public class structure extends script.base_script return false; } obj_id topMost = getTopMostContainer(target); - if ((topMost == target) || (topMost == null)) - { - return false; - } - return true; + return !((topMost == target) || (topMost == null)); } public static String getRandomCell(obj_id structure) throws InterruptedException { @@ -154,11 +144,7 @@ public class structure extends script.base_script if (!cellName.equals("")) { obj_id cellId = getCellId(structure, cellName); - if ((cellId == null) || (cellId == obj_id.NULL_ID)) - { - } - else - { + if ((cellId != null) && (cellId != obj_id.NULL_ID)) { return cellId; } } @@ -188,11 +174,12 @@ public class structure extends script.base_script String[] tpfs = dataTableGetStringColumn(DATATABLE_STRUCTURE_VERSION, DATATABLE_COL_STRUCTURE); if ((tpfs != null) && (tpfs.length > 0)) { + String dataScript; for (int i = 0; i < tpfs.length; i++) { if (tpfs[i].equals(facilityTemplate)) { - String dataScript = dataTableGetString(DATATABLE_STRUCTURE_VERSION, i, DATATABLE_COL_SCRIPT); + dataScript = dataTableGetString(DATATABLE_STRUCTURE_VERSION, i, DATATABLE_COL_SCRIPT); if (dataScript.equals(scriptName)) { return dataTableGetInt(DATATABLE_STRUCTURE_VERSION, i, columnName); @@ -229,11 +216,7 @@ public class structure extends script.base_script } int current = getIntObjVar(facility, VAR_STRUCTURE_VERSION_TERMINAL); int latest = getFacilityTerminalVersion(facility, scriptName); - if (current >= latest) - { - return true; - } - return false; + return current >= latest; } public static boolean isCurrentSpawnVersion(obj_id facility, String scriptName) throws InterruptedException { @@ -243,11 +226,7 @@ public class structure extends script.base_script } int current = getIntObjVar(facility, VAR_STRUCTURE_VERSION_SPAWN); int latest = getFacilitySpawnVersion(facility, scriptName); - if (current >= latest) - { - return true; - } - return false; + return current >= latest; } public static obj_id[] getPlayersInStructure(obj_id facility) throws InterruptedException { @@ -260,52 +239,36 @@ public class structure extends script.base_script switch (getContainerType(facility)) { case 0: - break; + break; case 1: - obj_id[] contents = getContents(facility); - if ((contents == null) || (contents.length == 0)) - { - return null; - } - for (int i = 0; i < contents.length; i++) - { - if ((getTemplateName(contents[i])).equals(TEMPLATE_CELL)) + obj_id[] contents = getContents(facility); + if ((contents == null) || (contents.length == 0)) { - cells = utils.addElement(cells, contents[i]); + return null; } - } - break; - case 2: - case 3: - case 4: - default: - break; + for (obj_id content : contents) { + if ((getTemplateName(content)).equals(TEMPLATE_CELL)) { + cells = utils.addElement(cells, content); + } + } + break; } if ((cells == null) || (cells.size() == 0)) { return null; } obj_id[] cellsArray = new obj_id[0]; - if (cells != null) - { - cellsArray = new obj_id[cells.size()]; - cells.toArray(cellsArray); - } + cellsArray = new obj_id[cells.size()]; + cells.toArray(cellsArray); Vector players = new Vector(); players.setSize(0); - for (int i = 0; i < cellsArray.length; i++) - { - obj_id[] cellContents = getContents(cellsArray[i]); - if ((cellContents == null) || (cellContents.length == 0)) - { - } - else - { - for (int n = 0; n < cellContents.length; n++) - { - if (isPlayer(cellContents[n])) - { - players = utils.addElement(players, cellContents[n]); + obj_id[] cellContents; + for (obj_id aCellsArray : cellsArray) { + cellContents = getContents(aCellsArray); + if ((cellContents != null) && (cellContents.length != 0)) { + for (obj_id cellContent : cellContents) { + if (isPlayer(cellContent)) { + players = utils.addElement(players, cellContent); } } } @@ -316,12 +279,8 @@ public class structure extends script.base_script } else { - obj_id[] _players = new obj_id[0]; - if (players != null) - { - _players = new obj_id[players.size()]; - players.toArray(_players); - } + obj_id[] _players = new obj_id[players.size()]; + players.toArray(_players); return _players; } } @@ -344,10 +303,6 @@ public class structure extends script.base_script if ((coowners != null) && (coowners.size() > 0)) { setObjVar(structure, utils.VAR_COOWNERS, coowners); - if (isHouse) - { - setObjVar(player, VAR_PLAYER_HOME, structure); - } return true; } } @@ -355,13 +310,9 @@ public class structure extends script.base_script { obj_id[] newCoOwners = new obj_id[1]; newCoOwners[0] = player; - if ((newCoOwners != null) && (newCoOwners.length > 0)) + if ((newCoOwners.length > 0)) { setObjVar(structure, utils.VAR_COOWNERS, newCoOwners); - if (isHouse) - { - setObjVar(player, VAR_PLAYER_HOME, structure); - } return true; } } @@ -395,9 +346,6 @@ public class structure extends script.base_script { setObjVar(structure, utils.VAR_COOWNERS, coowners); } - if (isHouse) - { - } return true; } return false; @@ -442,11 +390,7 @@ public class structure extends script.base_script return false; } obj_id[] terminals = createStructureTerminals(facility, datatable); - if ((terminals == null) || (terminals.length == 0)) - { - return false; - } - return true; + return !((terminals == null) || (terminals.length == 0)); } public static obj_id[] createStructureTerminals(obj_id facility, String datatable) throws InterruptedException { @@ -481,11 +425,7 @@ public class structure extends script.base_script obj_id CELL_ID = obj_id.NULL_ID; LOG("structureTerminal", "retrieved terminal data..."); LOG("structureTerminal", "loc = " + X + ", " + Y + ". " + Z + " H = " + relativeHeading + " cell = " + CELL_NAME); - if (CELL_NAME.equals(WORLD_DELTA)) - { - } - else - { + if (!CELL_NAME.equals(WORLD_DELTA)) { CELL_ID = getCellId(facility, CELL_NAME); } if (CELL_ID == null) @@ -494,7 +434,7 @@ public class structure extends script.base_script } else { - obj_id terminal_id = obj_id.NULL_ID; + obj_id terminal_id; location spot = new location(X, Y, Z, sceneName, CELL_ID); float HEADING = relativeHeading; if (CELL_ID == obj_id.NULL_ID) @@ -546,9 +486,8 @@ public class structure extends script.base_script { return false; } - for (int i = 0; i < terminals.length; i++) - { - destroyObject(terminals[i]); + for (obj_id terminal : terminals) { + destroyObject(terminal); } removeObjVar(facility, VAR_STRUCTURE_TERMINALS); return true; @@ -652,14 +591,7 @@ public class structure extends script.base_script count++; } } while (doContinue); - if (count > 0) - { - return true; - } - else - { - return false; - } + return count > 0; } public static boolean cleanupFillerSpawns(obj_id building) throws InterruptedException { @@ -668,14 +600,9 @@ public class structure extends script.base_script return false; } obj_id[] eggs = getObjIdArrayObjVar(building, VAR_FILLER_SPAWN_CURRENT_EGG); - if ((eggs == null) || (eggs.length == 0)) - { - } - else - { - for (int i = 0; i < eggs.length; i++) - { - destroyObject(eggs[i]); + if ((eggs != null) && (eggs.length != 0)) { + for (obj_id egg : eggs) { + destroyObject(egg); } } removeObjVar(building, VAR_FILLER_SPAWN_CURRENT_BASE); @@ -692,11 +619,16 @@ public class structure extends script.base_script if (dataTableOpen(table)) { String[] buildingTemplates = dataTableGetStringColumn(table, DATATABLE_COL_TEMPLATE); + dictionary d; + location bLoc; + location loc; + String lookup; + String[] eggs; for (int i = 0; i < buildingTemplates.length; i++) { if (buildingTemplates[i].equals(buildingTemplate)) { - dictionary d = new dictionary(); + d = new dictionary(); int idx = dataTableGetInt(table, i, DATATABLE_COL_IDX); if ((spawnIdx == -1) || (spawnIdx == idx)) { @@ -704,8 +636,8 @@ public class structure extends script.base_script float dx = dataTableGetFloat(table, i, DATATABLE_COL_X); float dy = dataTableGetFloat(table, i, DATATABLE_COL_Y); float dz = dataTableGetFloat(table, i, DATATABLE_COL_Z); - location bLoc = getLocation(building); - location loc = new location(bLoc.x + dx, bLoc.y + dy, bLoc.z + dz, bLoc.area, bLoc.cell); + bLoc = getLocation(building); + loc = new location(bLoc.x + dx, bLoc.y + dy, bLoc.z + dz, bLoc.area, bLoc.cell); float bYaw = getYaw(building); if (bYaw != 0.0f) { @@ -713,15 +645,15 @@ public class structure extends script.base_script loc = utils.rotatePointXZ(bLoc, dist, bYaw); } d.put(DICT_LOC, loc); - String lookup = DATATABLE_FILLER_BASE + getCurrentSceneName() + DATATABLE_FILLER_EGG_ENDING; + lookup = DATATABLE_FILLER_BASE + getCurrentSceneName() + DATATABLE_FILLER_EGG_ENDING; if (dataTableOpen(lookup)) { - String[] eggs = dataTableGetStringColumn(lookup, DATATABLE_COL_TEMPLATE); + eggs = dataTableGetStringColumn(lookup, DATATABLE_COL_TEMPLATE); switch (eggIdx) { case -1: - eggIdx = rand(0, eggs.length - 1); - default: + eggIdx = rand(0, eggs.length - 1); + default: if (eggIdx < eggs.length) { d.put(DICT_TEMPLATE, eggs[eggIdx]); diff --git a/sku.0/sys.server/compiled/game/script/library/sui.java b/sku.0/sys.server/compiled/game/script/library/sui.java old mode 100644 new mode 100755 index 52e6efd34..278db15b9 --- a/sku.0/sys.server/compiled/game/script/library/sui.java +++ b/sku.0/sys.server/compiled/game/script/library/sui.java @@ -400,11 +400,7 @@ public class sui extends script.base_script { return false; } - if (!flushSUIPage(pid)) - { - return false; - } - return true; + return flushSUIPage(pid); } public static boolean setPageProperties(int pid, dictionary params) throws InterruptedException { @@ -416,16 +412,20 @@ public class sui extends script.base_script setPageTitle(pid, params); setPageButtons(pid, params); java.util.Enumeration keys = params.keys(); + String key; + String[] s; + Object val; + String sVal; while (keys.hasMoreElements()) { - String key = (String)(keys.nextElement()); + key = (String) (keys.nextElement()); if (key.indexOf('-') > -1) { - String[] s = split(key, '-'); + s = split(key, '-'); if ((s != null) && (s.length == 2)) { - Object val = params.get(key); - String sVal = null; + val = params.get(key); + sVal = null; if (val != null) { if (val instanceof string_id) @@ -436,9 +436,6 @@ public class sui extends script.base_script { sVal = (String)(val); } - else - { - } if (sVal != null) { setSUIProperty(pid, s[0], s[1], sVal); @@ -481,8 +478,7 @@ public class sui extends script.base_script { return false; } - int btns = params.getInt(BUTTONS); - setButtonStyle(pid, btns); + setButtonStyle(pid, params.getInt(BUTTONS)); return true; } public static void setButtonStyle(int pid, int btns) throws InterruptedException @@ -490,51 +486,51 @@ public class sui extends script.base_script switch (btns) { case OK_ONLY: - hideBtnCancel(pid); - hideBtnRevert(pid); - break; + hideBtnCancel(pid); + hideBtnRevert(pid); + break; case OK_CANCEL: - hideBtnRevert(pid); - break; + hideBtnRevert(pid); + break; case YES_NO: - hideBtnRevert(pid); - setSUIProperty(pid, BTN_CANCEL, PROP_TEXT, "@no"); - setSUIProperty(pid, BTN_OK, PROP_TEXT, "@yes"); - break; + hideBtnRevert(pid); + setSUIProperty(pid, BTN_CANCEL, PROP_TEXT, "@no"); + setSUIProperty(pid, BTN_OK, PROP_TEXT, "@yes"); + break; case YES_NO_CANCEL: - setSUIProperty(pid, BTN_REVERT, PROP_TEXT, "@no"); - setSUIProperty(pid, BTN_CANCEL, PROP_TEXT, "@cancel"); - setSUIProperty(pid, BTN_OK, PROP_TEXT, "@yes"); - break; + setSUIProperty(pid, BTN_REVERT, PROP_TEXT, "@no"); + setSUIProperty(pid, BTN_CANCEL, PROP_TEXT, "@cancel"); + setSUIProperty(pid, BTN_OK, PROP_TEXT, "@yes"); + break; case YES_NO_MAYBE: - setSUIProperty(pid, BTN_REVERT, PROP_TEXT, "@maybe"); - setSUIProperty(pid, BTN_CANCEL, PROP_TEXT, "@no"); - setSUIProperty(pid, BTN_OK, PROP_TEXT, "@yes"); - break; + setSUIProperty(pid, BTN_REVERT, PROP_TEXT, "@maybe"); + setSUIProperty(pid, BTN_CANCEL, PROP_TEXT, "@no"); + setSUIProperty(pid, BTN_OK, PROP_TEXT, "@yes"); + break; case YES_NO_ABSTAIN: - setSUIProperty(pid, BTN_REVERT, PROP_TEXT, "@abstain"); - setSUIProperty(pid, BTN_CANCEL, PROP_TEXT, "@no"); - setSUIProperty(pid, BTN_OK, PROP_TEXT, "@yes"); - break; + setSUIProperty(pid, BTN_REVERT, PROP_TEXT, "@abstain"); + setSUIProperty(pid, BTN_CANCEL, PROP_TEXT, "@no"); + setSUIProperty(pid, BTN_OK, PROP_TEXT, "@yes"); + break; case RETRY_CANCEL: - hideBtnRevert(pid); - setSUIProperty(pid, BTN_CANCEL, PROP_TEXT, "@cancel"); - setSUIProperty(pid, BTN_OK, PROP_TEXT, "@retry"); - break; + hideBtnRevert(pid); + setSUIProperty(pid, BTN_CANCEL, PROP_TEXT, "@cancel"); + setSUIProperty(pid, BTN_OK, PROP_TEXT, "@retry"); + break; case ABORT_RETRY_CANCEL: - setSUIProperty(pid, BTN_REVERT, PROP_TEXT, "@retry"); - setSUIProperty(pid, BTN_CANCEL, PROP_TEXT, "@cancel"); - setSUIProperty(pid, BTN_OK, PROP_TEXT, "@abort"); - break; + setSUIProperty(pid, BTN_REVERT, PROP_TEXT, "@retry"); + setSUIProperty(pid, BTN_CANCEL, PROP_TEXT, "@cancel"); + setSUIProperty(pid, BTN_OK, PROP_TEXT, "@abort"); + break; case OK_REFRESH: - hideBtnRevert(pid); - setSUIProperty(pid, BTN_CANCEL, PROP_TEXT, "@refresh"); - break; + hideBtnRevert(pid); + setSUIProperty(pid, BTN_CANCEL, PROP_TEXT, "@refresh"); + break; case OK_CANCEL_REFRESH: - setSUIProperty(pid, BTN_REVERT, PROP_TEXT, "@refresh"); - break; + setSUIProperty(pid, BTN_REVERT, PROP_TEXT, "@refresh"); + break; default: - break; + break; } } public static void hideBtnCancel(int pid) throws InterruptedException @@ -615,46 +611,46 @@ public class sui extends script.base_script switch (buttons) { case OK_CANCEL: - msgboxHideBtnLeft(pid); - setSUIProperty(pid, MSGBOX_BTN_CANCEL, PROP_TEXT, "@cancel"); - setSUIProperty(pid, MSGBOX_BTN_OK, PROP_TEXT, "@ok"); - break; + msgboxHideBtnLeft(pid); + setSUIProperty(pid, MSGBOX_BTN_CANCEL, PROP_TEXT, "@cancel"); + setSUIProperty(pid, MSGBOX_BTN_OK, PROP_TEXT, "@ok"); + break; case YES_NO: - msgboxHideBtnLeft(pid); - setSUIProperty(pid, MSGBOX_BTN_CANCEL, PROP_TEXT, "@no"); - setSUIProperty(pid, MSGBOX_BTN_OK, PROP_TEXT, "@yes"); - break; + msgboxHideBtnLeft(pid); + setSUIProperty(pid, MSGBOX_BTN_CANCEL, PROP_TEXT, "@no"); + setSUIProperty(pid, MSGBOX_BTN_OK, PROP_TEXT, "@yes"); + break; case YES_NO_CANCEL: - setSUIProperty(pid, MSGBOX_BTN_REVERT, PROP_TEXT, "@no"); - setSUIProperty(pid, MSGBOX_BTN_CANCEL, PROP_TEXT, "@cancel"); - setSUIProperty(pid, MSGBOX_BTN_OK, PROP_TEXT, "@yes"); - break; + setSUIProperty(pid, MSGBOX_BTN_REVERT, PROP_TEXT, "@no"); + setSUIProperty(pid, MSGBOX_BTN_CANCEL, PROP_TEXT, "@cancel"); + setSUIProperty(pid, MSGBOX_BTN_OK, PROP_TEXT, "@yes"); + break; case YES_NO_MAYBE: - setSUIProperty(pid, MSGBOX_BTN_REVERT, PROP_TEXT, "@maybe"); - setSUIProperty(pid, MSGBOX_BTN_CANCEL, PROP_TEXT, "@no"); - setSUIProperty(pid, MSGBOX_BTN_OK, PROP_TEXT, "@yes"); - break; + setSUIProperty(pid, MSGBOX_BTN_REVERT, PROP_TEXT, "@maybe"); + setSUIProperty(pid, MSGBOX_BTN_CANCEL, PROP_TEXT, "@no"); + setSUIProperty(pid, MSGBOX_BTN_OK, PROP_TEXT, "@yes"); + break; case YES_NO_ABSTAIN: - setSUIProperty(pid, MSGBOX_BTN_REVERT, PROP_TEXT, "@abstain"); - setSUIProperty(pid, MSGBOX_BTN_CANCEL, PROP_TEXT, "@no"); - setSUIProperty(pid, MSGBOX_BTN_OK, PROP_TEXT, "@yes"); - break; + setSUIProperty(pid, MSGBOX_BTN_REVERT, PROP_TEXT, "@abstain"); + setSUIProperty(pid, MSGBOX_BTN_CANCEL, PROP_TEXT, "@no"); + setSUIProperty(pid, MSGBOX_BTN_OK, PROP_TEXT, "@yes"); + break; case RETRY_CANCEL: - msgboxHideBtnLeft(pid); - setSUIProperty(pid, MSGBOX_BTN_CANCEL, PROP_TEXT, "@cancel"); - setSUIProperty(pid, MSGBOX_BTN_OK, PROP_TEXT, "@retry"); - break; + msgboxHideBtnLeft(pid); + setSUIProperty(pid, MSGBOX_BTN_CANCEL, PROP_TEXT, "@cancel"); + setSUIProperty(pid, MSGBOX_BTN_OK, PROP_TEXT, "@retry"); + break; case ABORT_RETRY_CANCEL: - setSUIProperty(pid, MSGBOX_BTN_REVERT, PROP_TEXT, "@retry"); - setSUIProperty(pid, MSGBOX_BTN_CANCEL, PROP_TEXT, "@cancel"); - setSUIProperty(pid, MSGBOX_BTN_OK, PROP_TEXT, "@abort"); - break; + setSUIProperty(pid, MSGBOX_BTN_REVERT, PROP_TEXT, "@retry"); + setSUIProperty(pid, MSGBOX_BTN_CANCEL, PROP_TEXT, "@cancel"); + setSUIProperty(pid, MSGBOX_BTN_OK, PROP_TEXT, "@abort"); + break; case OK_ONLY: default: - msgboxHideBtnLeft(pid); - msgboxHideBtnMiddle(pid); - setSUIProperty(pid, MSGBOX_BTN_OK, PROP_TEXT, "@ok"); - break; + msgboxHideBtnLeft(pid); + msgboxHideBtnMiddle(pid); + setSUIProperty(pid, MSGBOX_BTN_OK, PROP_TEXT, "@ok"); + break; } } public static void msgboxHideBtnLeft(int pid) throws InterruptedException @@ -693,8 +689,7 @@ public class sui extends script.base_script } public static int msgbox(obj_id owner, obj_id target, prose_package prompt, int buttons, String box_title, int style, String suiHandler) throws InterruptedException { - String oob = packOutOfBandProsePackage(null, prompt); - return msgbox(owner, target, "\0" + oob, buttons, box_title, style, suiHandler); + return msgbox(owner, target, "\0" + packOutOfBandProsePackage(null, prompt), buttons, box_title, style, suiHandler); } public static int msgbox(obj_id owner, obj_id target, prose_package prompt, String suiHandler) throws InterruptedException { @@ -766,10 +761,7 @@ public class sui extends script.base_script prose_package pp = prose.getPackage(PROSE_OVER_MAX_ENTRIES, "", maxArraySize); sendSystemMessageProse(target, pp); String[] newSrc = new String[maxArraySize]; - for (int i = 0; i < maxArraySize; i++) - { - newSrc[i] = dsrc[i]; - } + System.arraycopy(dsrc, 0, newSrc, 0, maxArraySize); dsrc = newSrc; } LOG("sui", "inputbox: clearing datasource dataInput"); @@ -825,7 +817,6 @@ public class sui extends script.base_script return -1; } String scriptvar_pid = VAR_FILTER_BASE + "." + target + ".pid"; - String scriptvar_handler = VAR_FILTER_BASE + "." + target + ".handler"; if (utils.hasScriptVar(owner, scriptvar_pid)) { int oldpid = utils.getIntScriptVar(owner, scriptvar_pid); @@ -836,12 +827,7 @@ public class sui extends script.base_script cleanupFilteredInputbox(owner, target); } dictionary params = null; - if (maxLength < 1) - { - maxLength = MAX_INPUT_LENGTH; - } - else - { + if (maxLength >= 1) { params = new dictionary(); params.put(INPUTBOX_INPUT + "-MaxLength", maxLength); } @@ -903,9 +889,7 @@ public class sui extends script.base_script { attachScript(owner, SCRIPT_FILTER_OWNER); } - int cnt = utils.getIntScriptVar(owner, VAR_FILTER_COUNT); - cnt++; - utils.setScriptVar(owner, VAR_FILTER_COUNT, cnt); + utils.setScriptVar(owner, VAR_FILTER_COUNT, utils.getIntScriptVar(owner, VAR_FILTER_COUNT) + 1); } public static void cleanupFilteredInputbox(obj_id owner, obj_id player) throws InterruptedException { @@ -956,14 +940,14 @@ public class sui extends script.base_script switch (buttons) { case OK_CANCEL: - setSUIProperty(pid, INPUTBOX_BTN_CANCEL, PROP_TEXT, "@cancel"); - setSUIProperty(pid, INPUTBOX_BTN_OK, PROP_TEXT, "@ok"); - break; + setSUIProperty(pid, INPUTBOX_BTN_CANCEL, PROP_TEXT, "@cancel"); + setSUIProperty(pid, INPUTBOX_BTN_OK, PROP_TEXT, "@ok"); + break; case OK_ONLY: default: - msgboxHideBtnMiddle(pid); - setSUIProperty(pid, INPUTBOX_BTN_OK, PROP_TEXT, "@ok"); - break; + msgboxHideBtnMiddle(pid); + setSUIProperty(pid, INPUTBOX_BTN_OK, PROP_TEXT, "@ok"); + break; } } public static void inputboxHideBtnMiddle(int pid) throws InterruptedException @@ -976,18 +960,18 @@ public class sui extends script.base_script switch (style) { case INPUT_COMBO: - setSUIProperty(pid, INPUTBOX_INPUT, "Enabled", "false"); - setSUIProperty(pid, INPUTBOX_INPUT, "Visible", "false"); - setSUIProperty(pid, INPUTBOX_COMBO, "Enabled", "true"); - setSUIProperty(pid, INPUTBOX_COMBO, "Visible", "true"); - break; + setSUIProperty(pid, INPUTBOX_INPUT, "Enabled", "false"); + setSUIProperty(pid, INPUTBOX_INPUT, "Visible", "false"); + setSUIProperty(pid, INPUTBOX_COMBO, "Enabled", "true"); + setSUIProperty(pid, INPUTBOX_COMBO, "Visible", "true"); + break; case INPUT_NORMAL: default: - setSUIProperty(pid, INPUTBOX_INPUT, "Enabled", "true"); - setSUIProperty(pid, INPUTBOX_INPUT, "Visible", "true"); - setSUIProperty(pid, INPUTBOX_COMBO, "Enabled", "false"); - setSUIProperty(pid, INPUTBOX_COMBO, "Visible", "false"); - break; + setSUIProperty(pid, INPUTBOX_INPUT, "Enabled", "true"); + setSUIProperty(pid, INPUTBOX_INPUT, "Visible", "true"); + setSUIProperty(pid, INPUTBOX_COMBO, "Enabled", "false"); + setSUIProperty(pid, INPUTBOX_COMBO, "Visible", "false"); + break; } } public static int inputbox(obj_id owner, obj_id target, String prompt, int buttons, String box_title, int style, String[] dsrc, String suiHandler) throws InterruptedException @@ -1067,10 +1051,7 @@ public class sui extends script.base_script prose_package pp = prose.getPackage(PROSE_OVER_MAX_ENTRIES, "", maxArraySize); sendSystemMessageProse(target, pp); prose_package[] newSrc = new prose_package[maxArraySize]; - for (int i = 0; i < maxArraySize; i++) - { - newSrc[i] = dsrc[i]; - } + System.arraycopy(dsrc, 0, newSrc, 0, maxArraySize); dsrc = newSrc; } } @@ -1080,18 +1061,15 @@ public class sui extends script.base_script setSUIProperty(pid, LISTBOX_TITLE, PROP_TEXT, box_title); setSUIProperty(pid, LISTBOX_PROMPT, PROP_TEXT, prompt); listboxButtonSetup(pid, buttons); - if (dsrc != null) - { - clearSUIDataSource(pid, LISTBOX_DATASOURCE); - int ubound = dsrc.length; - for (int i = 0; i < ubound; i++) - { - addSUIDataItem(pid, LISTBOX_DATASOURCE, "" + i); - String oob = ""; - oob = packOutOfBandProsePackage(oob, -1, dsrc[i]); - setSUIPropertyOOB(pid, LISTBOX_DATASOURCE + "." + i, PROP_TEXT, oob); - } - } + clearSUIDataSource(pid, LISTBOX_DATASOURCE); + int ubound = dsrc.length; + for (int i = 0; i < ubound; i++) + { + addSUIDataItem(pid, LISTBOX_DATASOURCE, "" + i); + String oob = ""; + oob = packOutOfBandProsePackage(oob, -1, dsrc[i]); + setSUIPropertyOOB(pid, LISTBOX_DATASOURCE + "." + i, PROP_TEXT, oob); + } subscribeToSUIProperty(pid, LISTBOX_LIST, PROP_SELECTEDROW); subscribeToSUIProperty(pid, LISTBOX_TITLE, PROP_TEXT); if (show) @@ -1150,10 +1128,7 @@ public class sui extends script.base_script prose_package pp = prose.getPackage(PROSE_OVER_MAX_ENTRIES, "", maxArraySize); sendSystemMessageProse(target, pp); String[] newSrc = new String[maxArraySize]; - for (int i = 0; i < maxArraySize; i++) - { - newSrc[i] = dsrc[i]; - } + System.arraycopy(dsrc, 0, newSrc, 0, maxArraySize); dsrc = newSrc; } } @@ -1163,16 +1138,13 @@ public class sui extends script.base_script setSUIProperty(pid, LISTBOX_TITLE, PROP_TEXT, box_title); setSUIProperty(pid, LISTBOX_PROMPT, PROP_TEXT, prompt); listboxButtonSetup(pid, buttons); - if (dsrc != null) - { - clearSUIDataSource(pid, LISTBOX_DATASOURCE); - int ubound = dsrc.length; - for (int i = 0; i < ubound; i++) - { - addSUIDataItem(pid, LISTBOX_DATASOURCE, "" + i); - setSUIProperty(pid, LISTBOX_DATASOURCE + "." + i, PROP_TEXT, dsrc[i]); - } - } + clearSUIDataSource(pid, LISTBOX_DATASOURCE); + int ubound = dsrc.length; + for (int i = 0; i < ubound; i++) + { + addSUIDataItem(pid, LISTBOX_DATASOURCE, "" + i); + setSUIProperty(pid, LISTBOX_DATASOURCE + "." + i, PROP_TEXT, dsrc[i]); + } subscribeToSUIProperty(pid, LISTBOX_LIST, PROP_SELECTEDROW); subscribeToSUIProperty(pid, LISTBOX_TITLE, PROP_TEXT); if (show) @@ -1237,63 +1209,63 @@ public class sui extends script.base_script switch (buttons) { case OK_CANCEL: - setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT, "@cancel"); - setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT, "@ok"); - break; + setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT, "@cancel"); + setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT, "@ok"); + break; case YES_NO: - setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT, "@no"); - setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT, "@yes"); - break; + setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT, "@no"); + setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT, "@yes"); + break; case OK_REFRESH: - setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT, "@refresh"); - setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT, "@ok"); - break; + setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT, "@refresh"); + setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT, "@ok"); + break; case OK_CANCEL_REFRESH: - listboxUseOtherButton(pid, "@refresh"); - setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT, "@cancel"); - setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT, "@ok"); - break; + listboxUseOtherButton(pid, "@refresh"); + setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT, "@cancel"); + setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT, "@ok"); + break; case REFRESH_CANCEL: - setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT, "@refresh"); - setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT, "@cancel"); - break; + setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT, "@refresh"); + setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT, "@cancel"); + break; case REFRESH_ONLY: - listboxHideBtnMiddle(pid); - setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT, "@refresh"); - break; + listboxHideBtnMiddle(pid); + setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT, "@refresh"); + break; case OK_CANCEL_ALL: - listboxUseOtherButton(pid, "@all"); - setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT, "@cancel"); - setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT, "@ok"); - break; + listboxUseOtherButton(pid, "@all"); + setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT, "@cancel"); + setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT, "@ok"); + break; case MOVEUP_MOVEDOWN_DONE: - listboxUseOtherButton(pid, "@movedown"); - setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT, "@done"); - setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT, "@moveup"); - break; + listboxUseOtherButton(pid, "@movedown"); + setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT, "@done"); + setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT, "@moveup"); + break; case BET_MAX_BET_ONE_QUIT: - listboxUseOtherButton(pid, "@bet_one"); - setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT, "@quit"); - setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT, "@bet_max"); - break; + listboxUseOtherButton(pid, "@bet_one"); + setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT, "@quit"); + setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT, "@bet_max"); + break; case BET_MAX_BET_ONE_SPIN: - listboxUseOtherButton(pid, "@bet_one"); - setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT, "@spin"); - setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT, "@bet_max"); - break; + listboxUseOtherButton(pid, "@bet_one"); + setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT, "@spin"); + setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT, "@bet_max"); + break; case REFRESH_LEAVE_GAME: - setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT, "@leave_game"); - setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT, "@refresh"); - break; + setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT, "@leave_game"); + setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT, "@refresh"); + break; case REMOVE_CANCEL: - setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT, "@cancel"); - setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT, "@remove"); - break; + setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT, "@cancel"); + setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT, "@remove"); + break; case OK_ONLY: default: - msgboxHideBtnMiddle(pid); - setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT, "@ok"); - break; + msgboxHideBtnMiddle(pid); + setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT, "@ok"); + break; } } public static void listboxHideBtnMiddle(int pid) throws InterruptedException @@ -1309,7 +1281,7 @@ public class sui extends script.base_script } public static boolean getListboxOtherButtonPressed(dictionary params) throws InterruptedException { - return (Boolean.valueOf(params.getString("this." + LISTBOX_PROP_OTHER_PRESSED))).booleanValue(); + return Boolean.valueOf(params.getString("this." + LISTBOX_PROP_OTHER_PRESSED)); } public static int listbox(obj_id owner, obj_id target, String prompt, int buttons, String box_title, String[] dsrc, String suiHandler, boolean show) throws InterruptedException { @@ -1566,23 +1538,22 @@ public class sui extends script.base_script public static int getIntButtonPressed(dictionary params) throws InterruptedException { String bp = params.getString(PROP_BUTTONPRESSED); - if ((bp == null) || (bp.equals(""))) - { - } - else if (bp.equals(OK)) - { - if (params.containsKey("this.otherPressed")) - { - if ((params.getString("this.otherPressed")).equals("true")) - { - return BP_REVERT; - } - } - return BP_OK; - } - else if (bp.equals(REVERT)) - { - return BP_REVERT; + if ((bp != null) && (!bp.equals(""))) { + if (bp.equals(OK)) + { + if (params.containsKey("this.otherPressed")) + { + if ((params.getString("this.otherPressed")).equals("true")) + { + return BP_REVERT; + } + } + return BP_OK; + } + else if (bp.equals(REVERT)) + { + return BP_REVERT; + } } return BP_CANCEL; } @@ -1593,13 +1564,16 @@ public class sui extends script.base_script public static boolean setSUIObjVars(obj_id target, int pid, dictionary params) throws InterruptedException { java.util.Enumeration keys = params.keys(); + Object key; + Object value; + while (keys.hasMoreElements()) { - Object key = keys.nextElement(); - Object value = params.get(key); + key = keys.nextElement(); + value = params.get(key); if (value instanceof Integer) { - int v = (((Integer)value)).intValue(); + int v = (Integer) value; setObjVar(target, "sui." + pid + "." + key, v); } else if (value instanceof int[]) @@ -1612,7 +1586,7 @@ public class sui extends script.base_script } else if (value instanceof Float) { - float v = (((Float)value)).floatValue(); + float v = (Float) value; setObjVar(target, "sui." + pid + "." + key, v); } else if (value instanceof float[]) @@ -1724,8 +1698,7 @@ public class sui extends script.base_script public static void setAssociateRange(obj_id player, int pid, obj_id target, String key) throws InterruptedException { float range = 16f; - String tbl = "datatables/sui/associate_range.iff"; - float dta = dataTableGetFloat(tbl, key, "RANGE"); + float dta = dataTableGetFloat("datatables/sui/associate_range.iff", key, "RANGE"); if (dta > 0f) { range = dta; @@ -1758,17 +1731,11 @@ public class sui extends script.base_script { setSUIProperty(pid, THIS, PROP_SOUND, sound == null ? "" : sound); } - public static boolean hasPid(obj_id player, String pidName) throws InterruptedException - { - if (!isIdValid(player) || !exists(player)) - { + public static boolean hasPid(obj_id player, String pidName) throws InterruptedException { + if (!isIdValid(player) || !exists(player)) { return false; } - if (pidName == null || pidName.equals("")) - { - return false; - } - return utils.hasScriptVar(player, "pid." + pidName); + return !(pidName == null || pidName.equals("")) && utils.hasScriptVar(player, "pid." + pidName); } public static void setPid(obj_id player, int pid, String pidName) throws InterruptedException { @@ -1963,53 +1930,53 @@ public class sui extends script.base_script switch (buttons) { case OK_CANCEL: - setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT, "@cancel"); - setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT, "@ok"); - break; + setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT, "@cancel"); + setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT, "@ok"); + break; case YES_NO: - setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT, "@no"); - setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT, "@yes"); - break; + setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT, "@no"); + setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT, "@yes"); + break; case OK_REFRESH: - setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT, "@refresh"); - setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT, "@ok"); - break; + setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT, "@refresh"); + setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT, "@ok"); + break; case OK_CANCEL_REFRESH: - TableUseOtherButton(pid, "@refresh"); - setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT, "@cancel"); - setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT, "@ok"); - break; + TableUseOtherButton(pid, "@refresh"); + setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT, "@cancel"); + setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT, "@ok"); + break; case REFRESH_CANCEL: - setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT, "@refresh"); - setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT, "@cancel"); - break; + setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT, "@refresh"); + setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT, "@cancel"); + break; case REFRESH_ONLY: - TableHideBtnMiddle(pid); - setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT, "@refresh"); - break; + TableHideBtnMiddle(pid); + setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT, "@refresh"); + break; case OK_CANCEL_ALL: - TableUseOtherButton(pid, "@all"); - setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT, "@cancel"); - setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT, "@ok"); - break; + TableUseOtherButton(pid, "@all"); + setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT, "@cancel"); + setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT, "@ok"); + break; case MOVEUP_MOVEDOWN_DONE: - TableUseOtherButton(pid, "@movedown"); - setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT, "@done"); - setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT, "@moveup"); - break; + TableUseOtherButton(pid, "@movedown"); + setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT, "@done"); + setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT, "@moveup"); + break; case REFRESH_LEAVE_GAME: - setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT, "@leave_game"); - setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT, "@refresh"); - break; + setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT, "@leave_game"); + setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT, "@refresh"); + break; case REMOVE_CANCEL: - setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT, "@cancel"); - setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT, "@remove"); - break; + setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT, "@cancel"); + setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT, "@remove"); + break; case OK_ONLY: default: - msgboxHideBtnMiddle(pid); - setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT, "@ok"); - break; + msgboxHideBtnMiddle(pid); + setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT, "@ok"); + break; } } public static void TableHideBtnMiddle(int pid) throws InterruptedException @@ -2044,8 +2011,7 @@ public class sui extends script.base_script } public static String getEventType(dictionary params) throws InterruptedException { - String eventType = params.getString("eventType"); - return eventType; + return params.getString("eventType"); } public static void cancelCountdownTimer(obj_id self, int event) throws InterruptedException { diff --git a/sku.0/sys.server/compiled/game/script/library/target_dummy.java b/sku.0/sys.server/compiled/game/script/library/target_dummy.java old mode 100644 new mode 100755 index 659a905c4..1fab7fcd2 --- a/sku.0/sys.server/compiled/game/script/library/target_dummy.java +++ b/sku.0/sys.server/compiled/game/script/library/target_dummy.java @@ -1,18 +1,12 @@ package script.library; +import script.combat_engine.combat_data; +import script.combat_engine.hit_result; 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.library.combat; -import script.library.space_utils; -import script.library.sui; -import script.library.utils; +import java.util.Arrays; import java.util.Enumeration; +import java.util.Vector; public class target_dummy extends script.base_script { @@ -150,7 +144,7 @@ public class target_dummy extends script.base_script } location controllerLocation = getLocation(controller); location awayLoc = utils.getRandomAwayLocation(controllerLocation, 1.f, 2.f); - if ((awayLoc.cell != null) || isIdValid(awayLoc.cell)) + if ((awayLoc.cell != null) && isIdValid(awayLoc.cell)) { awayLoc = (location)controllerLocation.clone(); } @@ -243,7 +237,6 @@ public class target_dummy extends script.base_script removeObjVar(controller, target_dummy.TARGET_DUMMY_ID_OBJVAR); removeTargetDummyFromPermissions(targetDummy); destroyObject(targetDummy); - return; } public static void removeTargetDummyFromPermissions(obj_id targetDummy) throws InterruptedException { @@ -255,7 +248,6 @@ public class target_dummy extends script.base_script permissionsRemoveAllowed(structure, targetDummy.toString()); } } - return; } public static void removeTargetDummyFromPermissionsViaController(obj_id controller, obj_id targetDummy) throws InterruptedException { @@ -267,7 +259,6 @@ public class target_dummy extends script.base_script permissionsRemoveAllowed(structure, targetDummy.toString()); } } - return; } public static obj_id setTargetDummyOwner(obj_id controller) throws InterruptedException { @@ -285,9 +276,6 @@ public class target_dummy extends script.base_script setOwner(controller, owner); CustomerServiceLog("target_dummy", "target_dummy.scriptlib:setTargetDummyOwner - Target Dummy Controller: " + controller + " Ownership given to Owner OID: " + owner); } - else - { - } } return owner; } @@ -385,7 +373,6 @@ public class target_dummy extends script.base_script } public static boolean initializeTargetDummy(obj_id targetDummy, int combatLevel, int difficulty) throws InterruptedException { - boolean result = false; String creatureName = getCreatureName(targetDummy); dictionary creatureDict = utils.dataTableGetRow(create.CREATURE_TABLE, creatureName); if (creatureDict != null) @@ -393,15 +380,15 @@ public class target_dummy extends script.base_script creatureDict.put("difficultyClass", difficulty); create.initializeCreature(targetDummy, creatureName, creatureDict, combatLevel); setNpcDifficulty(targetDummy, difficulty); - result = false; obj_id controller = target_dummy.getTargetDummyController(targetDummy); if (isIdValid(controller)) { setObjVar(controller, "intCombatDifficulty", combatLevel); setObjVar(controller, "difficultyClass", difficulty); + return true; } } - return result; + return false; } public static int getTargetDummyDifficulty(obj_id targetDummy) throws InterruptedException { @@ -426,7 +413,6 @@ public class target_dummy extends script.base_script String prompt = utils.packStringId(new string_id("target_dummy", "combat_level_prompt")); String name = utils.packStringId(new string_id("target_dummy", "combat_level_name")); sui.inputbox(targetDummy, player, prompt, sui.OK_CANCEL, name, sui.INPUT_NORMAL, null, "handleTargetDummyLevelSelect", null); - return; } public static void promptForCombatDifficulty(obj_id targetDummy, obj_id player) throws InterruptedException { @@ -441,8 +427,7 @@ public class target_dummy extends script.base_script elite, boss }; - int pid = sui.listbox(targetDummy, player, prompt, sui.OK_CANCEL, title, difficulties, "handleTargetDummyDifficultySelect"); - return; + sui.listbox(targetDummy, player, prompt, sui.OK_CANCEL, title, difficulties, "handleTargetDummyDifficultySelect"); } public static void showTargetDummyDefenseListSui(obj_id targetDummy, obj_id player) throws InterruptedException { @@ -458,7 +443,6 @@ public class target_dummy extends script.base_script { utils.setScriptVar(player, "targetDummy.pidTargetDummyDefenses", pid); } - return; } public static String[] getTargetDummySkillModsOptions(obj_id targetDummy) throws InterruptedException { @@ -477,14 +461,12 @@ public class target_dummy extends script.base_script String prompt = utils.packStringId(new string_id("target_dummy", "combat_defensive_skill_mod_prompt")); prompt += " " + utils.packStringId(new string_id("target_dummy", target_dummy.TARGET_DUMMY_DEFENSES[skill_mod_selected])) + " :"; sui.inputbox(targetDummy, player, prompt, "handleTargetDummyDefensiveSkillModSet"); - return; } public static void setTargetDummyDefensiveValue(obj_id targetDummy, obj_id player, int value) throws InterruptedException { int skillModIndex = utils.getIntScriptVar(player, "targetDummySkillModSelected"); String skillModName = target_dummy.TARGET_DUMMY_DEFENSES[skillModIndex]; setTargetDummyDefensiveValue(targetDummy, player, value, skillModName); - return; } public static void setTargetDummyDefensiveValue(obj_id targetDummy, obj_id player, int value, String skillModName) throws InterruptedException { @@ -535,7 +517,6 @@ public class target_dummy extends script.base_script { setObjVar(controller, "target_dummy_defense." + skillModName, value); } - return; } public static void confirmClearYourCombatData(obj_id targetDummy, obj_id player) throws InterruptedException { @@ -543,7 +524,6 @@ public class target_dummy extends script.base_script String prompt = utils.packStringId(new string_id("target_dummy", "data_cleared_confirm_prompt")); String handler = "confirmClearYourCombatData"; buildConfirmClearCombatDataSui(targetDummy, player, title, prompt, handler); - return; } public static void confirmClearAllCombatData(obj_id targetDummy, obj_id player) throws InterruptedException { @@ -551,7 +531,6 @@ public class target_dummy extends script.base_script String prompt = utils.packStringId(new string_id("target_dummy", "data_all_cleared_confirm_prompt")); String handler = "confirmClearAllCombatData"; buildConfirmClearCombatDataSui(targetDummy, player, title, prompt, handler); - return; } public static void buildConfirmClearCombatDataSui(obj_id targetDummy, obj_id player, String title, String prompt, String handler) throws InterruptedException { @@ -565,7 +544,6 @@ public class target_dummy extends script.base_script setSUIProperty(pid, sui.MSGBOX_BTN_CANCEL, sui.PROP_TEXT, cancel_button); utils.setScriptVar(player, "clearCombatData.openSui", pid); sui.showSUIPage(pid); - return; } public static void clearYourCombatData(obj_id targetDummy, obj_id player) throws InterruptedException { @@ -580,7 +558,6 @@ public class target_dummy extends script.base_script removeObjVar(controller, target_dummy.BASE_TARGET_DUMMY_VAR); } } - return; } public static void clearAllCombatData(obj_id targetDummy, obj_id player) throws InterruptedException { @@ -595,7 +572,6 @@ public class target_dummy extends script.base_script removeObjVar(controller, target_dummy.BASE_TARGET_DUMMY_VAR); } } - return; } public static void sendTargetDummyCombatData(obj_id attacker, obj_id defender, combat_data actionData, hit_result hitData) throws InterruptedException { @@ -607,7 +583,6 @@ public class target_dummy extends script.base_script { recoredCombatResultViaController(attacker, defender, actionData, hitData); } - return; } public static void recoredCombatResultViaController(obj_id attacker, obj_id targetDummy, combat_data actionData, hit_result hitData) throws InterruptedException { @@ -616,7 +591,6 @@ public class target_dummy extends script.base_script { recoredCombatResult(attacker, controller, actionData, hitData); } - return; } public static void recoredCombatResult(obj_id attacker, obj_id controller, combat_data actionData, hit_result hitData) throws InterruptedException { @@ -626,14 +600,10 @@ public class target_dummy extends script.base_script boolean attackParried = hitData.parry; int damageDone = hitData.damage; boolean criticalHit = hitData.critical; - int criticalDamage = hitData.critDamage; boolean strikethroughHit = hitData.strikethrough; - float strikethroughAmmount = hitData.strikethroughAmmount; boolean glancingHit = hitData.glancing; boolean evadedDamage = hitData.evadeResult; - float evadeAmmount = hitData.evadeAmmount; boolean blockedHit = hitData.blockResult; - int blockAmount = hitData.block; obj_id combatDataOwner = attacker; if (beast_lib.isBeast(attacker)) { @@ -670,8 +640,7 @@ public class target_dummy extends script.base_script storeCumulativeCombatData(specificAttackData, INDEX_NUM_OF_ATTACKS, 1); if (!hitData.success) { - int indexOfAvoidanceType = -1; - int numAvoided = 1; + int indexOfAvoidanceType; if (attackMissed) { indexOfAvoidanceType = INDEX_NUM_MISSED; @@ -688,11 +657,8 @@ public class target_dummy extends script.base_script { indexOfAvoidanceType = INDEX_NUM_MISSED; } - if (indexOfAvoidanceType > -1) - { - storeCumulativeCombatData(allAttacksData, indexOfAvoidanceType, 1); - storeCumulativeCombatData(specificAttackData, indexOfAvoidanceType, 1); - } + storeCumulativeCombatData(allAttacksData, indexOfAvoidanceType, 1); + storeCumulativeCombatData(specificAttackData, indexOfAvoidanceType, 1); } else { @@ -736,13 +702,10 @@ public class target_dummy extends script.base_script utils.setScriptVar(controller, baseAllAttacksVar, allAttacksData); utils.setScriptVar(controller, baseSpecificAttackVar, specificAttackData); utils.setScriptVar(controller, baseAttackerVar + "." + LAST_ATTACK_TIME_VAR, getGameTime()); - return; } public static void storeCumulativeCombatData(int[] dataArray, int index, int newData) throws InterruptedException { - int previousData = dataArray[index]; - dataArray[index] = previousData + newData; - return; + dataArray[index] = dataArray[index] + newData; } public static void storeComparisonCombatData(int[] dataArray, int newData) throws InterruptedException { @@ -760,25 +723,14 @@ public class target_dummy extends script.base_script { dataArray[INDEX_SMALLEST_ATTACK] = newData; } - return; } public static boolean recordAsNormalHit(hit_result hitData) throws InterruptedException { - boolean criticalHit = hitData.critical; - boolean strikethroughHit = hitData.strikethrough; - boolean glancingHit = hitData.glancing; - boolean evadedDamage = hitData.evadeResult; - boolean blockedHit = hitData.blockResult; - if (!criticalHit && !strikethroughHit) - { - return true; - } - return false; + return !hitData.critical && !hitData.strikethrough; } public static void reportCombatData(obj_id player, obj_id targetDummy) throws InterruptedException { reportCombatDataViaController(player, targetDummy, obj_id.NULL_ID); - return; } public static void reportCombatDataViaController(obj_id player, obj_id targetDummy, obj_id controller) throws InterruptedException { @@ -816,11 +768,10 @@ public class target_dummy extends script.base_script { sendSystemMessage(player, new string_id("target_dummy", "placement_no_combat_data")); } - return; } public static String getCombatDataReportString(obj_id reportDataObject, obj_id player) throws InterruptedException { - String report = ""; + String report; String baseAttackerVar = BASE_TARGET_DUMMY_VAR + "." + player; if (utils.hasScriptVarTree(reportDataObject, baseAttackerVar)) { @@ -828,13 +779,16 @@ public class target_dummy extends script.base_script Vector attackTypes = new Vector(); attackTypes.setSize(0); Enumeration keys = vars.keys(); + String key; + String[] data; + String attackType; while (keys.hasMoreElements()) { - String key = (String)(keys.nextElement()); + key = (String) (keys.nextElement()); if (key.startsWith(baseAttackerVar + ".")) { - String[] data = split(key, '.'); - String attackType = data[2]; + data = split(key, '.'); + attackType = data[2]; if (!attackType.equals(LAST_ATTACK_TIME_VAR)) { utils.addElement(attackTypes, attackType); @@ -846,17 +800,15 @@ public class target_dummy extends script.base_script int[] initialDamageDoneArray = new int[numItems - 1]; String[] sortedAttackTypes = new String[numItems]; int initialIdx = 0; - for (int i = 0; i < numItems; i++) - { - String attackName = ((String)attackTypes.get(i)); - if (attackName.equals(ALL_ATTACKS_SUB_VAR)) - { + String attackName; + String baseSpecificAttackVar; + for (Object attackType1 : attackTypes) { + attackName = ((String) attackType1); + if (attackName.equals(ALL_ATTACKS_SUB_VAR)) { sortedAttackTypes[0] = attackName; - } - else - { + } else { initialAttackTypes[initialIdx] = attackName; - String baseSpecificAttackVar = baseAttackerVar + "." + attackName; + baseSpecificAttackVar = baseAttackerVar + "." + attackName; int[] tempAttackData = utils.getIntArrayScriptVar(reportDataObject, baseSpecificAttackVar); initialDamageDoneArray[initialIdx] = tempAttackData[INDEX_TOTAL_DAMAGE_DONE]; initialIdx = initialIdx + 1; @@ -865,20 +817,18 @@ public class target_dummy extends script.base_script int[] ascendingDataArray = new int[initialDamageDoneArray.length]; utils.copyArray(initialDamageDoneArray, ascendingDataArray); Arrays.sort(ascendingDataArray); + String name; for (int j = 0; j < ascendingDataArray.length; j++) { - int data = ascendingDataArray[j]; - int index = utils.getElementPositionInArray(initialDamageDoneArray, data); - String name = initialAttackTypes[index]; + int index = utils.getElementPositionInArray(initialDamageDoneArray, ascendingDataArray[j]); + name = initialAttackTypes[index]; sortedAttackTypes[(ascendingDataArray.length) - j] = name; initialDamageDoneArray[index] = -1; } - int numAttackTypes = sortedAttackTypes.length; report = utils.packStringId(REPORT_TITLE_SID) + addLineBreaks(1); - for (int idx = 0; idx < numAttackTypes; idx++) - { - String attackTypeName = sortedAttackTypes[idx]; - String attackTypeVarName = baseAttackerVar + "." + attackTypeName; + String attackTypeVarName; + for (String attackTypeName : sortedAttackTypes) { + attackTypeVarName = baseAttackerVar + "." + attackTypeName; int[] attackData = utils.getIntArrayScriptVar(reportDataObject, attackTypeVarName); int numAttacks = attackData[INDEX_NUM_OF_ATTACKS]; int totalDamageDone = attackData[INDEX_TOTAL_DAMAGE_DONE]; @@ -893,7 +843,6 @@ public class target_dummy extends script.base_script int numEvadedDamage = attackData[INDEX_NUM_EVADED_HITS]; int numBlockedHit = attackData[INDEX_NUM_BLOCKED_HITS]; int numSuccessfulAttacks = attackData[INDEX_NUM_SUCCESSFUL_HITS]; - int numNormalHits = attackData[INDEX_NUM_NORMAL_HITS]; int averageDamage = totalDamageDone / numAttacks; float percentageMissed = getPercentage(numMissed, numAttacks); float percentageDodged = getPercentage(numDodged, numAttacks); @@ -903,7 +852,6 @@ public class target_dummy extends script.base_script float percentageGlancing = getPercentage(numGlancingHit, numAttacks); float percentageEvaded = getPercentage(numEvadedDamage, numAttacks); float percentageBlocked = getPercentage(numBlockedHit, numAttacks); - float percentageNormal = getPercentage(numNormalHits, numAttacks); report += YELLOW + utils.packStringId(REPORT_ATTACK_TYPE_SID); report += WHITE + utils.packStringId(new string_id("cmd_n", attackTypeName)) + addLineBreaks(1); report += GREEN + utils.packStringId(REPORT_NUM_ATTACKS_SID) + WHITE + numAttacks + addLineBreaks(1); @@ -939,13 +887,12 @@ public class target_dummy extends script.base_script showRawCombatData(player, controller); } } - return; } public static void showRawCombatData(obj_id player, obj_id controller) throws InterruptedException { if (isGod(player)) { - String report = ""; + String report; String baseAttackerVar = BASE_TARGET_DUMMY_VAR + "." + player; if (utils.hasScriptVarTree(controller, baseAttackerVar)) { @@ -953,13 +900,16 @@ public class target_dummy extends script.base_script Vector attackTypes = new Vector(); attackTypes.setSize(0); Enumeration keys = vars.keys(); + String key; + String[] data; + String attackType; while (keys.hasMoreElements()) { - String key = (String)(keys.nextElement()); + key = (String) (keys.nextElement()); if (key.startsWith(baseAttackerVar + ".")) { - String[] data = split(key, '.'); - String attackType = data[2]; + data = split(key, '.'); + attackType = data[2]; if (!attackType.equals(LAST_ATTACK_TIME_VAR)) { utils.addElement(attackTypes, attackType); @@ -967,21 +917,19 @@ public class target_dummy extends script.base_script } } report = utils.packStringId(REPORT_TITLE_SID) + addLineBreaks(1); - for (int i = 0; i < attackTypes.size(); i++) - { - String attackTypeName = ((String)attackTypes.get(i)); - String attackTypeVarName = baseAttackerVar + "." + attackTypeName; + String attackTypeName; + String attackTypeVarName; + + for (Object attackType1 : attackTypes) { + attackTypeName = ((String) attackType1); + attackTypeVarName = baseAttackerVar + "." + attackTypeName; int[] attackData = utils.getIntArrayScriptVar(controller, attackTypeVarName); report += attackTypeName + ": { "; - for (int j = 0; j < attackData.length; j++) - { + for (int j = 0; j < attackData.length; j++) { report += attackData[j]; - if (j == attackData.length - 1) - { + if (j == attackData.length - 1) { report += " }" + sui.newLine(); - } - else - { + } else { report += ", "; } } @@ -1005,7 +953,6 @@ public class target_dummy extends script.base_script utils.setScriptVar(player, "target_dummy.rawCombatReportSui", pid); sui.showSUIPage(pid); } - return; } public static float getPercentage(float num, float total) throws InterruptedException { @@ -1021,7 +968,6 @@ public class target_dummy extends script.base_script { detachScript(targetDummy, "ai.creature_combat"); } - return; } public static void freezeMob(obj_id targetDummy) throws InterruptedException { @@ -1046,11 +992,8 @@ public class target_dummy extends script.base_script removeAttackerFromCombat(targetDummy, player); if (enemies != null && enemies.length > 0) { - for (int i = 0; i < enemies.length; i++) - { - obj_id enemy = enemies[i]; - if (isIdValid(enemy) && enemy != player) - { + for (obj_id enemy : enemies) { + if (isIdValid(enemy) && enemy != player) { removeAttackerFromCombat(targetDummy, enemy); } } @@ -1070,20 +1013,17 @@ public class target_dummy extends script.base_script destroyObject(targetDummy); } } - return; } public static void removeAttackerFromCombat(obj_id targetDummy, obj_id player) throws InterruptedException { removeHateTarget(targetDummy, player); removeHateTarget(player, targetDummy); stopCombat(player); - return; } public static void enterIntoCombat(obj_id targetDummy, obj_id player) throws InterruptedException { startCombat(targetDummy, player); addHate(targetDummy, player, 1000.0f); - return; } public static final String DATA = "datatables/tcg/target_dummy_extras.iff"; public static final String TYPE_COLUMN = "target_dummy_type"; @@ -1097,11 +1037,10 @@ public class target_dummy extends script.base_script }; public static boolean hasTargetDummyExtras(obj_id targetDummy) throws InterruptedException { - for (int i = 0; i < EXTRA_TYPES.length; i++) - { - String testExtra = getTargetDummyAnim(targetDummy, EXTRA_TYPES[i]); - if (testExtra != null && testExtra.length() > 0) - { + String testExtra; + for (String EXTRA_TYPE : EXTRA_TYPES) { + testExtra = getTargetDummyAnim(targetDummy, EXTRA_TYPE); + if (testExtra != null && testExtra.length() > 0) { return true; } } @@ -1110,32 +1049,22 @@ public class target_dummy extends script.base_script public static boolean hasTargetDummyRandomAnim(obj_id targetDummy) throws InterruptedException { String testAnim = getTargetDummyAnim(targetDummy, RANDON_ANIM_COLUMN); - if (testAnim != null && testAnim.length() > 0) - { - return true; - } - return false; + return testAnim != null && testAnim.length() > 0; } public static boolean hasTargetDummyTrickAnim(obj_id targetDummy) throws InterruptedException { String testTrick = getTargetDummyAnim(targetDummy, TRICK_ANIM_COLUMN); - if (testTrick != null && testTrick.length() > 0) - { - return true; - } - return false; + return testTrick != null && testTrick.length() > 0; } public static void doTargetDummyRandomAnim(obj_id targetDummy) throws InterruptedException { String animName = getTargetDummyAnim(targetDummy, RANDON_ANIM_COLUMN); doTargetDummyAnimation(targetDummy, animName); - return; } public static void doTargetDummyTrick(obj_id targetDummy) throws InterruptedException { String trickName = getTargetDummyAnim(targetDummy, TRICK_ANIM_COLUMN); doTargetDummyAnimation(targetDummy, trickName); - return; } public static String getTargetDummyAnim(obj_id targetDummy, String column) throws InterruptedException { @@ -1158,7 +1087,6 @@ public class target_dummy extends script.base_script doAnimationAction(targetDummy, animName); setObjVar(targetDummy, TARGET_DUMMY_LAST_EXTRAS_ANIM, animName); } - return; } public static String getTargetDummyExtrasData(obj_id targetDummy, String column) throws InterruptedException { diff --git a/sku.0/sys.server/compiled/game/script/library/tcg.java b/sku.0/sys.server/compiled/game/script/library/tcg.java old mode 100644 new mode 100755 index b10ac961a..32b13f025 --- a/sku.0/sys.server/compiled/game/script/library/tcg.java +++ b/sku.0/sys.server/compiled/game/script/library/tcg.java @@ -1,19 +1,9 @@ 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.library.beast_lib; -import script.library.incubator; -import script.library.spawning; -import script.library.static_item; -import script.library.target_dummy; -import script.library.utils; +import java.util.Arrays; +import java.util.Vector; public class tcg extends script.base_script { @@ -95,20 +85,12 @@ public class tcg extends script.base_script }; public static boolean isBarnRanchhand(obj_id target) throws InterruptedException { - if (hasScript(target, BARN_RANCHHAND_SCRIPT)) - { - return true; - } - return false; + return hasScript(target, BARN_RANCHHAND_SCRIPT); } public static boolean isBarnStructure(obj_id building) throws InterruptedException { String template = getTemplateName(building); - if (template.equals(BARN_STRUCTURE_TEMPLATE)) - { - return true; - } - return false; + return template.equals(BARN_STRUCTURE_TEMPLATE); } public static void barnStoreBeastPrompt(obj_id player, obj_id ranchhand) throws InterruptedException { @@ -132,17 +114,15 @@ public class tcg extends script.base_script vectorBcdsList.setSize(0); Vector vectorBeastNames = new Vector(); vectorBeastNames.setSize(0); - for (int i = 0; i < initialBcdsList.length; i++) - { - obj_id bcd = initialBcdsList[i]; - String beastName = beast_lib.getBCDBeastName(bcd); - if (beastName != null && beastName.length() > 0) - { + String beastName; + for (obj_id bcd : initialBcdsList) { + beastName = beast_lib.getBCDBeastName(bcd); + if (beastName != null && beastName.length() > 0) { utils.addElement(vectorBeastNames, toUpper(beastName, 0)); utils.addElement(vectorBcdsList, bcd); } } - if (vectorBeastNames != null && vectorBcdsList != null && vectorBeastNames.size() > 0 && vectorBcdsList.size() > 0) + if (vectorBeastNames.size() > 0 && vectorBcdsList.size() > 0) { obj_id[] finalBcdsList = utils.toStaticObjIdArray(vectorBcdsList); String[] finalBeastNames = utils.toStaticStringArray(vectorBeastNames); @@ -162,7 +142,6 @@ public class tcg extends script.base_script barnSelectPlayerBeastSui(player, ranchhand, finalBcdsList, finalBeastNames, promptRef, promptExtra, "handleBarnBeastStorage"); } } - return; } public static void barnSelectPlayerBeastSui(obj_id player, obj_id ranchhand, obj_id[] beastControlDevices, String[] beastNames, String promptRef, String promptExtra, String handler) throws InterruptedException { @@ -200,7 +179,6 @@ public class tcg extends script.base_script utils.setScriptVar(player, "barnRanchHand.pid", pid); utils.setScriptVar(player, "barnRanchHand." + handler, sortedBeastControlDevices); } - return; } public static void barnReclaimBeastPrompt(obj_id player, obj_id barn, obj_id ranchhand) throws InterruptedException { @@ -215,25 +193,20 @@ public class tcg extends script.base_script vectorBcdsList.setSize(0); Vector vectorBeastNames = new Vector(); vectorBeastNames.setSize(0); - for (int i = 0; i < initialStorageList.length; i++) - { - String bcdSlot = initialStorageList[i]; - String beastName = ""; - if (hasObjVar(barn, "barnStorage." + bcdSlot + ".beast.beastName")) - { + String beastName; + for (String bcdSlot : initialStorageList) { + beastName = ""; + if (hasObjVar(barn, "barnStorage." + bcdSlot + ".beast.beastName")) { beastName = getStringObjVar(barn, "barnStorage." + bcdSlot + ".beast.beastName"); - } - else if (hasObjVar(barn, "barnStorage." + bcdSlot + ".tempName")) - { + } else if (hasObjVar(barn, "barnStorage." + bcdSlot + ".tempName")) { beastName = getStringObjVar(barn, "barnStorage." + bcdSlot + ".tempName"); } - if (beastName != null && beastName.length() > 0) - { + if (beastName != null && beastName.length() > 0) { utils.addElement(vectorBeastNames, toUpper(beastName, 0)); utils.addElement(vectorBcdsList, bcdSlot); } } - if (vectorBeastNames != null && vectorBcdsList != null && vectorBeastNames.size() > 0 && vectorBcdsList.size() > 0) + if (vectorBeastNames.size() > 0 && vectorBcdsList.size() > 0) { String[] finalBcdsList = utils.toStaticStringArray(vectorBcdsList); String[] finalBeastNames = utils.toStaticStringArray(vectorBeastNames); @@ -249,7 +222,6 @@ public class tcg extends script.base_script barnSelectStoredBeastSui(player, ranchhand, finalBcdsList, finalBeastNames, "barn_beast_selection_reclaim_prompt", promptExtra, "handleBarnBeastReclaim"); } } - return; } public static void barnDisplayBeastPrompt(obj_id player, obj_id barn, obj_id ranchhand) throws InterruptedException { @@ -264,28 +236,20 @@ public class tcg extends script.base_script vectorBcdsList.setSize(0); Vector vectorBeastNames = new Vector(); vectorBeastNames.setSize(0); - for (int i = 0; i < initialStorageList.length; i++) - { - String bcdSlot = initialStorageList[i]; - String beastName = ""; - if (hasObjVar(barn, "barnStorage." + bcdSlot + ".beast.beastName")) - { + String beastName; + for (String bcdSlot : initialStorageList) { + beastName = ""; + if (hasObjVar(barn, "barnStorage." + bcdSlot + ".beast.beastName")) { beastName = getStringObjVar(barn, "barnStorage." + bcdSlot + ".beast.beastName"); - } - else if (hasObjVar(barn, "barnStorage." + bcdSlot + ".tempName")) - { + } else if (hasObjVar(barn, "barnStorage." + bcdSlot + ".tempName")) { beastName = getStringObjVar(barn, "barnStorage." + bcdSlot + ".tempName"); } - if (hasObjVar(barn, "barnStorage." + bcdSlot + "." + BEAST_ROAMING)) - { + if (hasObjVar(barn, "barnStorage." + bcdSlot + "." + BEAST_ROAMING)) { beastName = beastName + " [Displayed]"; - } - else - { + } else { beastName = beastName + " [Stored]"; } - if (beastName != null && beastName.length() > 0) - { + if (beastName.length() > 0) { utils.addElement(vectorBeastNames, toUpper(beastName, 0)); utils.addElement(vectorBcdsList, bcdSlot); } @@ -295,14 +259,13 @@ public class tcg extends script.base_script { prompt = "barn_lite_beast_selection_display_prompt"; } - if (vectorBeastNames != null && vectorBcdsList != null && vectorBeastNames.size() > 0 && vectorBcdsList.size() > 0) + if (vectorBeastNames.size() > 0 && vectorBcdsList.size() > 0) { String[] finalBcdsList = utils.toStaticStringArray(vectorBcdsList); String[] finalBeastNames = utils.toStaticStringArray(vectorBeastNames); barnSelectStoredBeastSui(player, ranchhand, finalBcdsList, finalBeastNames, prompt, "", "handleBarnBeastDisplay"); } } - return; } public static void barnSelectStoredBeastSui(obj_id player, obj_id ranchhand, String[] beastControlSlots, String[] beastNames, String promptRef, String promptExtra, String handler) throws InterruptedException { @@ -320,12 +283,11 @@ public class tcg extends script.base_script String[] sortedBeastControlSlots = new String[beastControlSlots.length]; utils.copyArray(beastNames, alphabetizedBeastNames); Arrays.sort(alphabetizedBeastNames); + for (int j = 0; j < alphabetizedBeastNames.length; j++) { - String alphabetizedName = alphabetizedBeastNames[j]; - int index = utils.getElementPositionInArray(beastNames, alphabetizedName); - String sortedBeast = beastControlSlots[index]; - sortedBeastControlSlots[j] = sortedBeast; + int index = utils.getElementPositionInArray(beastNames, alphabetizedBeastNames[j]); + sortedBeastControlSlots[j] = beastControlSlots[index]; beastNames[index] = "_"; } String title = utils.packStringId(new string_id("tcg", "barn_beast_selection_title")); @@ -340,7 +302,6 @@ public class tcg extends script.base_script utils.setScriptVar(player, "barnRanchHand.pid", pid); utils.setScriptVar(player, "barnRanchHand." + handler, sortedBeastControlSlots); } - return; } public static boolean transferBeastControlDeviceToBarn(obj_id selectedBeastControlDevice, obj_id player, obj_id barn) throws InterruptedException { @@ -355,20 +316,14 @@ public class tcg extends script.base_script { setObjVar(barn, nextAvailableStorageSlot + ".tempName", beast_lib.getBeastLocalizedName(selectedBeastControlDevice)); } - for (int i = 0; i < BEAST_OBJVARS.length; i++) - { - String beastObjvar = BEAST_OBJVARS[i]; - if (hasObjVar(selectedBeastControlDevice, beastObjvar)) - { - obj_var_list beastData = getObjVarList(selectedBeastControlDevice, beastObjvar); - if (beastData != null) - { + obj_var_list beastData; + for (String beastObjvar : BEAST_OBJVARS) { + if (hasObjVar(selectedBeastControlDevice, beastObjvar)) { + beastData = getObjVarList(selectedBeastControlDevice, beastObjvar); + if (beastData != null) { setBCDDataObjVars(player, barn, nextAvailableStorageSlot + "." + beastObjvar + ".", beastData); - } - else - { - if (hasObjVar(barn, nextAvailableStorageSlot)) - { + } else { + if (hasObjVar(barn, nextAvailableStorageSlot)) { removeObjVar(barn, nextAvailableStorageSlot); } CustomerServiceLog("playerStructure", "Player: " + player + " " + getPlayerName(player) + " could not store a beast in the barn. The BCD was not destroyed. Reason: Beast in datapad had no objvars or objvars were corrupted. Barn: " + barn); @@ -414,18 +369,13 @@ public class tcg extends script.base_script bcd = createObject(bcdTemplate, datapad, ""); if (isIdValid(bcd)) { - for (int i = 0; i < BEAST_OBJVARS.length; i++) - { - String beastObjvar = BEAST_OBJVARS[i]; - if (hasObjVar(barn, "barnStorage." + selectedStorageSlot + "." + beastObjvar)) - { - obj_var_list beastData = getObjVarList(barn, "barnStorage." + selectedStorageSlot + "." + beastObjvar); - if (beastData != null) - { + obj_var_list beastData; + for (String beastObjvar : BEAST_OBJVARS) { + if (hasObjVar(barn, "barnStorage." + selectedStorageSlot + "." + beastObjvar)) { + beastData = getObjVarList(barn, "barnStorage." + selectedStorageSlot + "." + beastObjvar); + if (beastData != null) { setBCDDataObjVars(player, bcd, beastObjvar + ".", beastData); - } - else - { + } else { CustomerServiceLog("playerStructure", "Player: " + player + " " + getPlayerName(player) + " did not claim beast BCD from barn. Resason: barnStorage has null or corrupted beast data for: " + selectedStorageSlot + ". Beast Obj Var: " + beastObjvar + "."); destroyObject(bcd); return obj_id.NULL_ID; @@ -490,28 +440,23 @@ public class tcg extends script.base_script } else if (data.isStringObjVar(dataObjvarName)) { - String stringData = data.getStringObjVar(dataObjvarName); - setObjVar(target, objvarNamePrefix + dataObjvarName, stringData); + setObjVar(target, objvarNamePrefix + dataObjvarName, data.getStringObjVar(dataObjvarName)); } else if (data.isStringArrayObjVar(dataObjvarName)) { - String[] stringArrayData = data.getStringArrayObjVar(dataObjvarName); - setObjVar(target, objvarNamePrefix + dataObjvarName, stringArrayData); + setObjVar(target, objvarNamePrefix + dataObjvarName, data.getStringArrayObjVar(dataObjvarName)); } else if (data.isObjIdObjVar(dataObjvarName)) { - obj_id objIdData = data.getObjIdObjVar(dataObjvarName); - setObjVar(target, objvarNamePrefix + dataObjvarName, objIdData); + setObjVar(target, objvarNamePrefix + dataObjvarName, data.getObjIdObjVar(dataObjvarName)); } else if (data.isObjIdArrayObjVar(dataObjvarName)) { - obj_id[] objIdArrayData = data.getObjIdArrayObjVar(dataObjvarName); - setObjVar(target, objvarNamePrefix + dataObjvarName, objIdArrayData); + setObjVar(target, objvarNamePrefix + dataObjvarName, data.getObjIdArrayObjVar(dataObjvarName)); } else if (data.isBooleanObjVar(dataObjvarName)) { - boolean booleanData = data.getBooleanObjVar(dataObjvarName); - setObjVar(target, objvarNamePrefix + dataObjvarName, booleanData); + setObjVar(target, objvarNamePrefix + dataObjvarName, data.getBooleanObjVar(dataObjvarName)); } else { @@ -521,7 +466,6 @@ public class tcg extends script.base_script } } } - return; } public static String getNextAvailableBarnStorageSlot(obj_id barn, obj_id player) throws InterruptedException { @@ -581,9 +525,7 @@ public class tcg extends script.base_script String[] slots = new String[numItems]; for (int i = 0; i < numItems; i++) { - obj_var beastDataObjvar = beastData.getObjVar(i); - String beastDataObjvarName = beastDataObjvar.getName(); - slots[i] = beastDataObjvarName; + slots[i] = beastData.getObjVar(i).getName(); } return slots; } @@ -618,8 +560,7 @@ public class tcg extends script.base_script public static obj_id barnDisplayBeast(obj_id ranchhand, String storageSlot, obj_id barn) throws InterruptedException { location here = getLocation(ranchhand); - location spawnCenter = new location(-7.0f, 0.0f, -2.4f, here.area, here.cell); - location spawnLocation = spawning.getRandomLocationInCircle(spawnCenter, 5.0f); + location spawnLocation = spawning.getRandomLocationInCircle(new location(-7.0f, 0.0f, -2.4f, here.area, here.cell), 5.0f); return barnDisplayBeast(ranchhand, storageSlot, barn, spawnLocation); } public static obj_id barnDisplayBeast(obj_id ranchhand, String storageSlot, obj_id barn, location where) throws InterruptedException @@ -840,7 +781,6 @@ public class tcg extends script.base_script { beast_lib.removeAttentionPenaltyDebuff(getMaster(beast)); } - return; } public static boolean isBarnLiteDevice(obj_id object) throws InterruptedException { @@ -879,9 +819,9 @@ public class tcg extends script.base_script { return false; } - for (int i = 0; i < staticObjects.length; i++) - { - obj_id unpackedObject = static_item.createNewItemFunction(staticObjects[i], player); + obj_id unpackedObject; + for (String staticObject : staticObjects) { + unpackedObject = static_item.createNewItemFunction(staticObject, player); CustomerServiceLog("tcg", "Packed item: " + objectPacked + " " + getName(objectPacked) + " unpacked: " + unpackedObject + " " + getName(unpackedObject) + " for player: " + player + " " + getName(player) + "."); } return true; @@ -944,30 +884,30 @@ public class tcg extends script.base_script { if (!useBeastLibraryHue) { - if (primaryPalette != null || primaryPalette.length() > 0) + if (primaryPalette != null && primaryPalette.length() > 0) { setRoamingBeastHue(beast, primaryPalette, primaryHue); } - if (secondaryPalette != null || secondaryPalette.length() > 0) + if (secondaryPalette != null && secondaryPalette.length() > 0) { setRoamingBeastHue(beast, secondaryPalette, secondaryHue); } - if (thirdPalette != null || thirdPalette.length() > 0) + if (thirdPalette != null && thirdPalette.length() > 0) { setRoamingBeastHue(beast, thirdPalette, thirdHue); } } else { - if (primaryPalette != null || primaryPalette.length() > 0) + if (primaryPalette != null && primaryPalette.length() > 0) { beast_lib.setBeastHuePrimary(beast, primaryPalette, primaryHue); } - if (secondaryPalette != null || secondaryPalette.length() > 0) + if (secondaryPalette != null && secondaryPalette.length() > 0) { beast_lib.setBeastHueSecondary(beast, secondaryPalette, secondaryHue); } - if (thirdPalette != null || thirdPalette.length() > 0) + if (thirdPalette != null && thirdPalette.length() > 0) { beast_lib.setBeastHueThird(beast, thirdPalette, thirdHue); } @@ -1025,7 +965,6 @@ public class tcg extends script.base_script blog("tcg.scriptlib = showRoamingBeasts --- NEED ROAMING BEAST FOUND AT bcdSlot: " + bcdSlot); if (isBarnLiteDevice(barn)) { - location here = getLocation(barn); location spawnLoc = spawning.getRandomLocationAtDistance(getLocation(barn), 2.0f); tcg.barnDisplayBeast(ranchhand, bcdSlot, barn, spawnLoc); } diff --git a/sku.0/sys.server/compiled/game/script/library/temp_schematic.java b/sku.0/sys.server/compiled/game/script/library/temp_schematic.java old mode 100644 new mode 100755 index 11917362b..7808f9cbd --- a/sku.0/sys.server/compiled/game/script/library/temp_schematic.java +++ b/sku.0/sys.server/compiled/game/script/library/temp_schematic.java @@ -1,14 +1,8 @@ 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.library.prose; +import script.obj_id; +import script.prose_package; +import script.string_id; public class temp_schematic extends script.base_script { @@ -64,10 +58,8 @@ public class temp_schematic extends script.base_script int total = useCount + getIntObjVar(player, ovpath); setObjVar(player, ovpath, total); string_id product_name = getProductNameFromSchematic(schematic); - prose_package ppTempGrant = prose.getPackage(PROSE_TEMP_GRANT, product_name, useCount); - sendSystemMessageProse(player, ppTempGrant); - prose_package ppUsesLeft = prose.getPackage(PROSE_USES_LEFT, product_name, total); - sendSystemMessageProse(player, ppUsesLeft); + sendSystemMessageProse(player, prose.getPackage(PROSE_TEMP_GRANT, product_name, useCount)); + sendSystemMessageProse(player, prose.getPackage(PROSE_USES_LEFT, product_name, total)); if (isIdValid(bioLink)) { setObjVar(player, VAR_TEMP_SCHEMATIC_BIO_LINK + "." + schematic, bioLink); diff --git a/sku.0/sys.server/compiled/game/script/library/theater.java b/sku.0/sys.server/compiled/game/script/library/theater.java old mode 100644 new mode 100755 index 9db3f1bfd..d7b417061 --- a/sku.0/sys.server/compiled/game/script/library/theater.java +++ b/sku.0/sys.server/compiled/game/script/library/theater.java @@ -1,16 +1,8 @@ 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.library.utils; -import script.library.player_structure; -import script.library.regions; +import java.util.Vector; public class theater extends script.base_script { @@ -54,20 +46,15 @@ public class theater extends script.base_script region[] regionList = getRegionsAtPoint(loc); if (regionList != null) { - for (int i = 0; i < regionList.length; ++i) - { - if (regionList[i] != null) - { - if (regionList[i].getPvPType() == regions.PVP_REGION_TYPE_BATTLEFIELD_PVP) - { + for (region aRegionList : regionList) { + if (aRegionList != null) { + if (aRegionList.getPvPType() == regions.PVP_REGION_TYPE_BATTLEFIELD_PVP) { return false; } - if (regionList[i].getPvPType() == regions.PVP_REGION_TYPE_BATTLEFIELD_PVE) - { + if (aRegionList.getPvPType() == regions.PVP_REGION_TYPE_BATTLEFIELD_PVE) { return false; } - if (regionList[i].getGeographicalType() == regions.GEO_CITY) - { + if (aRegionList.getGeographicalType() == regions.GEO_CITY) { return false; } } @@ -90,25 +77,17 @@ public class theater extends script.base_script switch (spawnMethod) { case SPAWN_RADIAL: - break; + break; case SPAWN_DATATABLE_OFFSET: - children = spawnDatatableOffset(target); - break; + children = spawnDatatableOffset(target); + break; default: - return false; + return false; } dictionary d = new dictionary(); - if ((children == null) || (children.length == 0)) - { - } - else - { + if ((children != null) && (children.length != 0)) { obj_id[] buildings = utils.getBuildingsInObjIdList(children); - if ((buildings == null) || (buildings.length == 0)) - { - } - else - { + if ((buildings != null) && (buildings.length != 0)) { d.put(DICT_CHILDREN, buildings); } } @@ -175,82 +154,66 @@ public class theater extends script.base_script default: break; } - int numCols = dataTableGetNumColumns(tbl); + obj_var ov; + String name; + String[] entries; + String tpf; + location spawnLoc; + location goodLoc; + obj_id child; + for (int i = 0; i < numListItems; i++) { - obj_var ov = spawnList.getObjVar(i); - String name = ov.getName(); + ov = spawnList.getObjVar(i); + name = ov.getName(); int amt = ov.getIntData(); if (dataTableHasColumn(tbl, name)) { - String[] entries = dataTableGetStringColumn(tbl, name); - if ((entries == null) || (entries.length == 0)) - { - } - else - { + entries = dataTableGetStringColumn(tbl, name); + if ((entries != null) && (entries.length != 0)) { for (int n = 0; n < amt; n++) { int roll = rand(0, entries.length - 1); - String tpf = entries[roll]; - int cnt = 0; + tpf = entries[roll]; while (tpf.equals("")) { roll = rand(0, entries.length - 1); tpf = entries[roll]; } - location spawnLoc = utils.getRandomLocationInRing(myLoc, ringMin, ringMax); - if (spawnLoc == null) - { - } - else - { - location goodLoc = locations.getGoodLocationAroundLocation(spawnLoc, iArea, iArea, sArea, sArea); - if (goodLoc == null) - { - } - else - { + spawnLoc = utils.getRandomLocationInRing(myLoc, ringMin, ringMax); + if (spawnLoc != null) { + goodLoc = locations.getGoodLocationAroundLocation(spawnLoc, iArea, iArea, sArea, sArea); + if (goodLoc != null) { spawnLoc = (location)goodLoc.clone(); } if (spawnLoc.cell == obj_id.NULL_ID) { spawnLoc.y = getHeightAtLocation(spawnLoc.x, spawnLoc.z); } - if (spawnLoc != null) - { - float fltNewSize = getDistance(myLoc, spawnLoc); - if (fltNewSize > fltSize) - { - fltSize = fltNewSize; - } - obj_id child = createObject(tpf, spawnLoc); - if ((child == null) || (child == obj_id.NULL_ID)) - { - } - else - { - setYaw(child, rand(-180, 180)); - children = utils.addElement(children, child); - if (!faction.equals("")) - { - factions.setFaction(child, faction); - } - switch (persistFlag) - { - case PERSIST_ALL: - break; - } - setObjVar(child, VAR_PARENT, target); - } - } + float fltNewSize = getDistance(myLoc, spawnLoc); + if (fltNewSize > fltSize) + { + fltSize = fltNewSize; + } + child = createObject(tpf, spawnLoc); + if ((child != null) && (child != obj_id.NULL_ID)) { + setYaw(child, rand(-180, 180)); + children = utils.addElement(children, child); + if (!faction.equals("")) + { + factions.setFaction(child, faction); + } + switch (persistFlag) + { + case PERSIST_ALL: + break; + } + setObjVar(child, VAR_PARENT, target); + } } } } } - else - { - } } setObjVar(target, "poi.fltSize", fltSize + 20); if ((children == null) || (children.size() == 0)) @@ -261,18 +224,13 @@ public class theater extends script.base_script { setObjVar(target, VAR_CHILDREN, children); } - obj_id[] _children = new obj_id[0]; - if (children != null) - { - _children = new obj_id[children.size()]; - children.toArray(_children); - } + obj_id[] _children = new obj_id[children.size()]; + children.toArray(_children); return _children; } public static obj_id[] spawnDatatableOffset(obj_id target) throws InterruptedException { float fltSize = 0; - location[] locWaypoints = new location[0]; if ((target == null) || (target == obj_id.NULL_ID)) { return null; @@ -286,7 +244,7 @@ public class theater extends script.base_script { return null; } - String faction = ""; + String faction; if (hasObjVar(target, factions.FACTION)) { faction = getStringObjVar(target, factions.FACTION); @@ -321,46 +279,41 @@ public class theater extends script.base_script Vector objWaypoints = new Vector(); objWaypoints.setSize(0); float[] fltX = dataTableGetFloatColumn(tbl, X); - float[] fltY = dataTableGetFloatColumn(tbl, Y); float[] fltZ = dataTableGetFloatColumn(tbl, Z); float[] fltYaw = dataTableGetFloatColumn(tbl, YAW); String[] strTemplates = dataTableGetStringColumn(tbl, TEMPLATE); int numRows = strTemplates.length; + String tpf; + location here; + obj_id child; for (int i = 0; i < numRows; i++) { - String tpf = strTemplates[i]; + tpf = strTemplates[i]; float dx = fltX[i]; - float dy = fltY[i]; float dz = fltZ[i]; float yaw = fltYaw[i]; - location here = (location)myLoc.clone(); + here = (location) myLoc.clone(); here = player_structure.transformDeltaWorldCoord(here, dx, dz, tYaw); float fltNewSize = getDistance(myLoc, here); if (fltNewSize > fltSize) { fltSize = fltNewSize; } - obj_id child = createObject(tpf, here); - if (!isIdValid(child)) - { - } - else - { - if (tpf.equals("object/tangible/poi/theater/poi_mob_spawner.iff")) - { - objMobSpawners = utils.addElement(objMobSpawners, child); - } - else if (tpf.equals("object/tangible/poi/theater/poi_objective_spawner.iff")) - { - objObjectiveSpawners = utils.addElement(objObjectiveSpawners, child); - } - else if (tpf.equals("object/path_waypoint/path_waypoint.iff")) - { - objWaypoints = utils.addElement(objWaypoints, child); - } - else if (tpf.equals("object/tangible/poi/theater/poi_mob_spawner_large.iff")) - { - objLargeMobSpawners = utils.addElement(objLargeMobSpawners, child); + child = createObject(tpf, here); + if (isIdValid(child)) { + switch (tpf) { + case "object/tangible/poi/theater/poi_mob_spawner.iff": + objMobSpawners = utils.addElement(objMobSpawners, child); + break; + case "object/tangible/poi/theater/poi_objective_spawner.iff": + objObjectiveSpawners = utils.addElement(objObjectiveSpawners, child); + break; + case "object/path_waypoint/path_waypoint.iff": + objWaypoints = utils.addElement(objWaypoints, child); + break; + case "object/tangible/poi/theater/poi_mob_spawner_large.iff": + objLargeMobSpawners = utils.addElement(objLargeMobSpawners, child); + break; } setYaw(child, yaw + tYaw); children = utils.addElement(children, child); @@ -389,9 +342,6 @@ public class theater extends script.base_script { setObjVar(target, "theater.objLargeMobSpawners", objLargeMobSpawners); } - if (objWaypoints != null && objWaypoints.size() > 0) - { - } if ((children == null) || (children.size() == 0)) { return null; @@ -400,17 +350,12 @@ public class theater extends script.base_script { setObjVar(target, VAR_CHILDREN, children); } - obj_id[] _children = new obj_id[0]; - if (children != null) - { - _children = new obj_id[children.size()]; - children.toArray(_children); - } + obj_id[] _children = new obj_id[children.size()]; + children.toArray(_children); return _children; } public static void spawnDatatableOffsetQueued(obj_id target, int intIndex) throws InterruptedException { - boolean boolFinished = false; if ((target == null) || (target == obj_id.NULL_ID)) { return; @@ -424,7 +369,7 @@ public class theater extends script.base_script { return; } - String faction = ""; + String faction; if (hasObjVar(target, factions.FACTION)) { faction = getStringObjVar(target, factions.FACTION); @@ -453,94 +398,82 @@ public class theater extends script.base_script Vector children = new Vector(); children.setSize(0); float[] fltX = dataTableGetFloatColumn(tbl, X); - float[] fltY = dataTableGetFloatColumn(tbl, Y); float[] fltZ = dataTableGetFloatColumn(tbl, Z); float[] fltYaw = dataTableGetFloatColumn(tbl, YAW); String[] strTemplates = dataTableGetStringColumn(tbl, TEMPLATE); int numRows = strTemplates.length; + obj_id child; + String tpf; + location here; + for (int i = 0; i < numRows; i++) { - obj_id child = null; - String tpf = strTemplates[i]; - if (tpf.equals("object/tangible/poi/theater/poi_mob_spawner.iff")) - { - float dx = fltX[i]; - float dy = fltY[i]; - float dz = fltZ[i]; - float yaw = fltYaw[i]; - location here = (location)myLoc.clone(); - here = player_structure.transformDeltaWorldCoord(here, dx, dz, tYaw); - child = createObject(tpf, here); - if (isIdValid(child)) - { - objMobSpawners = utils.addElement(objMobSpawners, child); - children = utils.addElement(children, child); - } - } - else if (tpf.equals("object/tangible/poi/theater/poi_objective_spawner.iff")) - { - float dx = fltX[i]; - float dy = fltY[i]; - float dz = fltZ[i]; - float yaw = fltYaw[i]; - location here = (location)myLoc.clone(); - here = player_structure.transformDeltaWorldCoord(here, dx, dz, tYaw); - child = createObject(tpf, here); - if (isIdValid(child)) - { - objObjectiveSpawners = utils.addElement(objObjectiveSpawners, child); - children = utils.addElement(children, child); - } - } - else if (tpf.equals("object/path_waypoint/path_waypoint.iff")) - { - float dx = fltX[i]; - float dy = fltY[i]; - float dz = fltZ[i]; - float yaw = fltYaw[i]; - location here = (location)myLoc.clone(); - here = player_structure.transformDeltaWorldCoord(here, dx, dz, tYaw); - child = createObject(tpf, here); - if (isIdValid(child)) - { - objWaypoints = utils.addElement(objWaypoints, child); - children = utils.addElement(children, child); - } - } - else if (tpf.equals("object/tangible/poi/theater/poi_mob_spawner_large.iff")) - { - float dx = fltX[i]; - float dy = fltY[i]; - float dz = fltZ[i]; - float yaw = fltYaw[i]; - location here = (location)myLoc.clone(); - here = player_structure.transformDeltaWorldCoord(here, dx, dz, tYaw); - child = createObject(tpf, here); - if (isIdValid(child)) - { - objLargeMobSpawners = utils.addElement(objLargeMobSpawners, child); - children = utils.addElement(children, child); - } - } - else - { - int intStringIndex = tpf.indexOf("corral"); - if (intStringIndex > -1) - { + tpf = strTemplates[i]; + switch (tpf) { + case "object/tangible/poi/theater/poi_mob_spawner.iff": { float dx = fltX[i]; - float dy = fltY[i]; float dz = fltZ[i]; - float yaw = fltYaw[i]; - location here = (location)myLoc.clone(); + here = (location) myLoc.clone(); here = player_structure.transformDeltaWorldCoord(here, dx, dz, tYaw); child = createObject(tpf, here); - if (isIdValid(child)) - { - setYaw(child, yaw + tYaw); - setObjVar(child, VAR_PARENT, target); + if (isIdValid(child)) { + objMobSpawners = utils.addElement(objMobSpawners, child); children = utils.addElement(children, child); } + break; } + case "object/tangible/poi/theater/poi_objective_spawner.iff": { + float dx = fltX[i]; + float dz = fltZ[i]; + here = (location) myLoc.clone(); + here = player_structure.transformDeltaWorldCoord(here, dx, dz, tYaw); + child = createObject(tpf, here); + if (isIdValid(child)) { + objObjectiveSpawners = utils.addElement(objObjectiveSpawners, child); + children = utils.addElement(children, child); + } + break; + } + case "object/path_waypoint/path_waypoint.iff": { + float dx = fltX[i]; + float dz = fltZ[i]; + here = (location) myLoc.clone(); + here = player_structure.transformDeltaWorldCoord(here, dx, dz, tYaw); + child = createObject(tpf, here); + if (isIdValid(child)) { + objWaypoints = utils.addElement(objWaypoints, child); + children = utils.addElement(children, child); + } + break; + } + case "object/tangible/poi/theater/poi_mob_spawner_large.iff": { + float dx = fltX[i]; + float dz = fltZ[i]; + here = (location) myLoc.clone(); + here = player_structure.transformDeltaWorldCoord(here, dx, dz, tYaw); + child = createObject(tpf, here); + if (isIdValid(child)) { + objLargeMobSpawners = utils.addElement(objLargeMobSpawners, child); + children = utils.addElement(children, child); + } + break; + } + default: + int intStringIndex = tpf.indexOf("corral"); + if (intStringIndex > -1) { + float dx = fltX[i]; + float dz = fltZ[i]; + float yaw = fltYaw[i]; + here = (location) myLoc.clone(); + here = player_structure.transformDeltaWorldCoord(here, dx, dz, tYaw); + child = createObject(tpf, here); + if (isIdValid(child)) { + setYaw(child, yaw + tYaw); + setObjVar(child, VAR_PARENT, target); + children = utils.addElement(children, child); + } + } + break; } } if (objMobSpawners.size() > 0) @@ -612,11 +545,7 @@ public class theater extends script.base_script here.z += (dx * fltS) + (dz * fltC); obj_id child = createObject(tpf, here); debugSpeakMsg(target, "a child " + child); - if ((child == null) || (child == obj_id.NULL_ID)) - { - } - else - { + if ((child != null) && (child != obj_id.NULL_ID)) { setYaw(child, yaw + tYaw); children = utils.addElement(children, child); if (!faction.equals("")) @@ -646,29 +575,18 @@ public class theater extends script.base_script } public static boolean shouldSpawn(String tpf) throws InterruptedException { - if (tpf.equals("object/tangible/poi/theater/poi_mob_spawner.iff")) - { - return false; - } - else if (tpf.equals("object/tangible/poi/theater/poi_objective_spawner.iff")) - { - return false; - } - else if (tpf.equals("object/path_waypoint/path_waypoint.iff")) - { - return false; - } - else if (tpf.equals("object/tangible/poi/theater/poi_mob_spawner_large.iff")) - { - return false; - } - else - { - int intStringIndex = tpf.indexOf("corral"); - if (intStringIndex > -1) - { + switch (tpf) { + case "object/tangible/poi/theater/poi_mob_spawner.iff": + case "object/tangible/poi/theater/poi_objective_spawner.iff": + case "object/path_waypoint/path_waypoint.iff": + case "object/tangible/poi/theater/poi_mob_spawner_large.iff": return false; - } + default: + int intStringIndex = tpf.indexOf("corral"); + if (intStringIndex > -1) { + return false; + } + break; } return true; } @@ -676,14 +594,10 @@ public class theater extends script.base_script { location locTest = getLocation(target); region rgnPathRegion = getRegion(target.toString(), locTest.area); - if (rgnPathRegion == null) - { - } - else - { + if (rgnPathRegion != null) { deleteRegion(rgnPathRegion); } - if ((target == null) || (target == obj_id.NULL_ID)) + if ((target == obj_id.NULL_ID)) { return false; } @@ -696,14 +610,8 @@ public class theater extends script.base_script { return false; } - for (int i = 0; i < children.length; i++) - { - obj_id child = children[i]; - if ((child == null) || (child == obj_id.NULL_ID)) - { - } - else - { + for (obj_id child : children) { + if ((child != null) && (child != obj_id.NULL_ID)) { destroyObject(child); } } diff --git a/sku.0/sys.server/compiled/game/script/library/township.java b/sku.0/sys.server/compiled/game/script/library/township.java old mode 100644 new mode 100755 index 0dcec6944..dedea884c --- a/sku.0/sys.server/compiled/game/script/library/township.java +++ b/sku.0/sys.server/compiled/game/script/library/township.java @@ -1,14 +1,8 @@ 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.library.space_skill; +import java.util.Vector; public class township extends script.base_script { @@ -48,11 +42,7 @@ public class township extends script.base_script LOG("force_sensitive", "township.isTownshipEligible -- player is invalid."); return false; } - if (getLevel(player) >= MIN_LEVEL || space_skill.isMasterPilot(player)) - { - return true; - } - return false; + return getLevel(player) >= MIN_LEVEL || space_skill.isMasterPilot(player); } public static boolean giveTravelListFromAurilia(obj_id player, obj_id npc) throws InterruptedException { @@ -90,20 +80,17 @@ public class township extends script.base_script { return false; } - for (int i = 0; i < subGroups.length; ++i) - { - boolean foundAlready = false; - for (int j = 0; j < resizeGroups.size(); ++j) - { - if (subGroups[i].equals(((String)resizeGroups.get(j)))) - { + boolean foundAlready; + for (String subGroup : subGroups) { + foundAlready = false; + for (Object resizeGroup : resizeGroups) { + if (subGroup.equals(resizeGroup)) { foundAlready = true; } } - if (!foundAlready) - { - utils.addElement(localizedGroups, "@nexus:" + subGroups[i]); - utils.addElement(resizeGroups, subGroups[i]); + if (!foundAlready) { + utils.addElement(localizedGroups, "@nexus:" + subGroup); + utils.addElement(resizeGroups, subGroup); } } utils.setScriptVar(player, GROUPS_SCRIPT_VAR, resizeGroups); @@ -135,8 +122,6 @@ public class township extends script.base_script String[] locations = dataTableGetStringColumn(DATATABLE_TOWNSHIP, DATATABLE_COLUMN_LOCATIONS); Vector resizeLocations = new Vector(); resizeLocations.setSize(0); - Vector resizeGroups = new Vector(); - resizeGroups.setSize(0); Vector localizedLocations = new Vector(); localizedLocations.setSize(0); if (subGroups == null || locations == null) @@ -180,23 +165,18 @@ public class township extends script.base_script { return 0; } - int totalCount = 0; obj_id crystal = utils.getStaticItemInInventory(player, MIDLITHE_CRYSTAL); if (!isIdValid(crystal)) { return 0; } - totalCount = getCount(crystal); - return totalCount; + return getCount(crystal); } public static void clearAllNovaOrionQuestStatus(obj_id player) throws InterruptedException { String[] questsToReset = dataTableGetStringColumnNoDefaults(NOVA_ORION_RESET_DATATABLE, "quest_name"); - for (int i = 0; i < questsToReset.length; i++) - { - String groundQuestName = questsToReset[i]; - if (groundquests.isQuestActiveOrComplete(player, groundQuestName)) - { + for (String groundQuestName : questsToReset) { + if (groundquests.isQuestActiveOrComplete(player, groundQuestName)) { groundquests.clearQuest(player, groundQuestName); } } @@ -205,9 +185,7 @@ public class township extends script.base_script removeObjVar(player, OBJVAR_NOVA_ORION_FACTION); } String[] slotsToReset = dataTableGetStringColumnNoDefaults(NOVA_ORION_RESET_DATATABLE, "rank_slot_name"); - for (int p = 0; p < slotsToReset.length; p++) - { - String slotRankName = slotsToReset[p]; + for (String slotRankName : slotsToReset) { long slotValue = getCollectionSlotValue(player, slotRankName); modifyCollectionSlotValue(player, slotRankName, (-1 * slotValue)); } @@ -219,18 +197,21 @@ public class township extends script.base_script if (questList != null) { int spaceQuests = questList.getNumItems(); + String questType; + obj_var_list typeList; + obj_var quest; + String spaceQuestName; + String questSeries; for (int sq = 0; sq < spaceQuests; ++sq) { - obj_var spaceFields = questList.getObjVar(sq); - String questType = spaceFields.getName(); - obj_var_list typeList = questList.getObjVarList(questType); + questType = questList.getObjVar(sq).getName(); + typeList = questList.getObjVarList(questType); int questCount = typeList.getNumItems(); for (int j = 0; j < questCount; j++) { - obj_var quest = typeList.getObjVar(j); - String spaceQuestName = quest.getName(); - String spaceTable = "/datatables/spacequest/" + questType + "/" + spaceQuestName + ".iff"; - String questSeries = dataTableGetString(spaceTable, 0, "questSeries"); + quest = typeList.getObjVar(j); + spaceQuestName = quest.getName(); + questSeries = dataTableGetString("/datatables/spacequest/" + questType + "/" + spaceQuestName + ".iff", 0, "questSeries"); if (questSeries != null && questSeries.length() > 0) { if (questSeries.equals("nova_orion")) @@ -241,7 +222,6 @@ public class township extends script.base_script } } } - return; } public static string_id getNovaOrionRumor(obj_id player) throws InterruptedException { diff --git a/sku.0/sys.server/compiled/game/script/library/trace.java b/sku.0/sys.server/compiled/game/script/library/trace.java old mode 100644 new mode 100755 index f7120a2a5..1dd6f54f8 --- a/sku.0/sys.server/compiled/game/script/library/trace.java +++ b/sku.0/sys.server/compiled/game/script/library/trace.java @@ -1,15 +1,6 @@ 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 java.lang.reflect.*; -import java.lang.Thread.*; +import script.obj_id; public class trace extends script.base_script { @@ -31,11 +22,7 @@ public class trace extends script.base_script } public static boolean isFlagSet(int mask, int flag) throws InterruptedException { - if ((mask & flag) == flag) - { - return true; - } - return false; + return (mask & flag) == flag; } public static void log(String channelOrLogFile, String message, obj_id logAbout, int traceLevelMask) throws InterruptedException { @@ -65,24 +52,15 @@ public class trace extends script.base_script LOG(channelOrLogFile, "[" + logAbout + "]:" + message); } } - return; } public static boolean isDebugDefined() throws InterruptedException { String flag = getConfigSetting("GameServer", "scriptDebugTrace"); - if (flag == null || flag.length() < 1) - { - return false; - } - return true; + return !(flag == null || flag.length() < 1); } public static boolean pipeDebugToCsLog() throws InterruptedException { String flag = getConfigSetting("GameServer", "pipeScriptDebugToCsLog"); - if (flag == null || flag.length() < 1) - { - return false; - } - return true; + return !(flag == null || flag.length() < 1); } } diff --git a/sku.0/sys.server/compiled/game/script/library/trainerlocs.java b/sku.0/sys.server/compiled/game/script/library/trainerlocs.java old mode 100644 new mode 100755 index 57a2206d3..cd1a21d9e --- a/sku.0/sys.server/compiled/game/script/library/trainerlocs.java +++ b/sku.0/sys.server/compiled/game/script/library/trainerlocs.java @@ -1,14 +1,8 @@ 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.library.utils; +import script.location; +import script.obj_id; +import script.string_id; public class trainerlocs extends script.base_script { @@ -36,79 +30,75 @@ public class trainerlocs extends script.base_script { location targetLoc = new location(); targetLoc.area = track; - String waypName = "error"; - if (track.equals("naboo")) - { - if (profession.equals("imperial")) - { - targetLoc.x = 5182f; - targetLoc.y = -192f; - targetLoc.z = 6750f; - waypName = "barn_sinkko"; - } - else if (profession.equals("rebel")) - { - targetLoc.x = 4767f; - targetLoc.y = 4.22f; - targetLoc.z = -4812f; - waypName = "v3_fx"; - } - else - { - targetLoc.x = -5495f; - targetLoc.y = 14.00f; - targetLoc.z = 4476f; - waypName = "dinge"; - } - } - else if (track.equals("corellia")) - { - if (profession.equals("imperial")) - { - targetLoc.x = -2184f; - targetLoc.y = 20.0f; - targetLoc.z = 2273f; - targetLoc.area = "talus"; - waypName = "hakassha_sireen"; - } - else if (profession.equals("rebel")) - { - targetLoc.x = -5170f; - targetLoc.y = 21.00f; - targetLoc.z = -2295f; - waypName = "kreezo"; - } - else - { - targetLoc.x = -275f; - targetLoc.y = 28f; - targetLoc.z = -4695f; - waypName = "rhea"; - } - } - else - { - if (profession.equals("imperial")) - { - targetLoc.x = -1132f; - targetLoc.y = 13.32f; - targetLoc.z = -3542f; - waypName = "akal_colzet"; - } - else if (profession.equals("rebel")) - { - targetLoc.x = -2991f; - targetLoc.y = 5f; - targetLoc.z = 2123f; - waypName = "da_la_socuna"; - } - else - { - targetLoc.x = 3381f; - targetLoc.y = 5f; - targetLoc.z = -4799f; - waypName = "dravis"; - } + String waypName; + switch (track) { + case "naboo": + switch (profession) { + case "imperial": + targetLoc.x = 5182f; + targetLoc.y = -192f; + targetLoc.z = 6750f; + waypName = "barn_sinkko"; + break; + case "rebel": + targetLoc.x = 4767f; + targetLoc.y = 4.22f; + targetLoc.z = -4812f; + waypName = "v3_fx"; + break; + default: + targetLoc.x = -5495f; + targetLoc.y = 14.00f; + targetLoc.z = 4476f; + waypName = "dinge"; + break; + } + break; + case "corellia": + switch (profession) { + case "imperial": + targetLoc.x = -2184f; + targetLoc.y = 20.0f; + targetLoc.z = 2273f; + targetLoc.area = "talus"; + waypName = "hakassha_sireen"; + break; + case "rebel": + targetLoc.x = -5170f; + targetLoc.y = 21.00f; + targetLoc.z = -2295f; + waypName = "kreezo"; + break; + default: + targetLoc.x = -275f; + targetLoc.y = 28f; + targetLoc.z = -4695f; + waypName = "rhea"; + break; + } + break; + default: + switch (profession) { + case "imperial": + targetLoc.x = -1132f; + targetLoc.y = 13.32f; + targetLoc.z = -3542f; + waypName = "akal_colzet"; + break; + case "rebel": + targetLoc.x = -2991f; + targetLoc.y = 5f; + targetLoc.z = 2123f; + waypName = "da_la_socuna"; + break; + default: + targetLoc.x = 3381f; + targetLoc.y = 5f; + targetLoc.z = -4799f; + waypName = "dravis"; + break; + } + break; } obj_id wayp = createWaypointInDatapad(player, targetLoc); String playerArea = getLocation(player).area; diff --git a/sku.0/sys.server/compiled/game/script/library/transition.java b/sku.0/sys.server/compiled/game/script/library/transition.java old mode 100644 new mode 100755 index a4895b368..c91ffe5d9 --- a/sku.0/sys.server/compiled/game/script/library/transition.java +++ b/sku.0/sys.server/compiled/game/script/library/transition.java @@ -1,21 +1,8 @@ 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.library.callable; -import script.library.space_dungeon; -import script.library.sui; -import script.library.utils; -import script.library.groundquests; -import script.library.space_quest; -import script.library.pclib; -import script.library.pet_lib; +import script.location; +import script.obj_id; +import script.string_id; public class transition extends script.base_script { @@ -35,8 +22,7 @@ public class transition extends script.base_script return bad_zone_data; } String zoneLine = getStringObjVar(gate, "zoneLine"); - string_id zoneString = new string_id(STF, zoneLine); - return zoneString; + return new string_id(STF, zoneLine); } public static void zonePlayer(obj_id gate, obj_id player) throws InterruptedException { @@ -75,8 +61,7 @@ public class transition extends script.base_script notifyPlayerOfInvalidPermission(player, transit); return; } - String destination = dataTableGetString(dataTable, transit, "destination"); - String[] parse = split(destination, ':'); + String[] parse = split(dataTableGetString(dataTable, transit, "destination"), ':'); callable.storeCallables(player); String script = dataTableGetString(dataTable, transit, "script"); if (!script.equals("none")) @@ -152,133 +137,89 @@ public class transition extends script.base_script doLogging("doPublicInstanceZone", "Requested clusterwide data for " + instance + "*"); utils.setScriptVar(getSelf(), "playerId", player); } - public static boolean hasPermissionForZone(obj_id player, String zone, String flagType) throws InterruptedException - { + public static boolean hasPermissionForZone(obj_id player, String zone, String flagType) throws InterruptedException { String requiredFlag = dataTableGetString(dataTable, zone, flagType); - if (requiredFlag == null || requiredFlag.equals("")) - { + if (requiredFlag == null || requiredFlag.equals("")) { return true; } String[] parse = split(requiredFlag, ':'); - if (parse.length == 1) - { - if (parse[0].equals("none")) - { - if (flagType.equals("initialRequiredFlag")) - { - return hasPermissionForZone(player, zone, "finalRequiredFlag"); - } - else - { - return true; - } + if (parse.length == 1) { + if (parse[0].equals("none")) { + return !flagType.equals("initialRequiredFlag") || hasPermissionForZone(player, zone, "finalRequiredFlag"); } - if (hasObjVar(player, parse[0])) - { + if (hasObjVar(player, parse[0])) { return true; } - if (utils.hasScriptVar(player, parse[0])) - { + if (utils.hasScriptVar(player, parse[0])) { utils.setScriptVar(player, "tempFlag", parse[0]); return true; } - if (parse[0].equals("level")) - { + if (parse[0].equals("level")) { int level = getLevel(player); - if (level >= utils.stringToInt(parse[1])) - { + if (level >= utils.stringToInt(parse[1])) { return true; } } } - if (parse.length == 2) - { - if (parse[0].equals("won")) - { - if (groundquests.hasCompletedQuest(player, parse[1])) - { + if (parse.length == 2) { + if (parse[0].equals("won")) { + if (groundquests.hasCompletedQuest(player, parse[1])) { return true; } } - if (parse[0].equals("has")) - { - if (groundquests.isQuestActive(player, parse[1])) - { + if (parse[0].equals("has")) { + if (groundquests.isQuestActive(player, parse[1])) { return true; } } - if (parse[0].equals("item")) - { - if (utils.playerHasItemByTemplateInInventoryOrEquipped(player, parse[1])) - { + if (parse[0].equals("item")) { + if (utils.playerHasItemByTemplateInInventoryOrEquipped(player, parse[1])) { return true; } - if (utils.playerHasItemWithObjVarInInventoryOrEquipped(player, parse[1])) - { + if (utils.playerHasItemWithObjVarInInventoryOrEquipped(player, parse[1])) { return true; } } - if (parse[0].equals("level")) - { + if (parse[0].equals("level")) { int level = getLevel(player); - if (level >= utils.stringToInt(parse[1])) - { + if (level >= utils.stringToInt(parse[1])) { return true; } } } - if (parse.length == 3) - { - if (parse[0].equals("won")) - { - if (space_quest.hasWonQuest(player, parse[1], parse[2])) - { + if (parse.length == 3) { + if (parse[0].equals("won")) { + if (space_quest.hasWonQuest(player, parse[1], parse[2])) { return true; } } - if (parse[0].equals("has")) - { - if (space_quest.hasQuest(player, parse[1], parse[2])) - { + if (parse[0].equals("has")) { + if (space_quest.hasQuest(player, parse[1], parse[2])) { return true; } } - if (parse[0].equals("task")) - { - if (groundquests.isTaskActive(player, parse[2], parse[3])) - { + if (parse[0].equals("task")) { + if (groundquests.isTaskActive(player, parse[2], parse[3])) { return true; } } - if (parse[0].equals("item")) - { - if (utils.playerHasItemByTemplateWithObjVarInInventoryOrEquipped(player, parse[1], parse[2])) - { + if (parse[0].equals("item")) { + if (utils.playerHasItemByTemplateWithObjVarInInventoryOrEquipped(player, parse[1], parse[2])) { return true; } } - if (parse[0].equals("level")) - { + if (parse[0].equals("level")) { int level = getLevel(player); - if (level >= utils.stringToInt(parse[1])) - { + if (level >= utils.stringToInt(parse[1])) { return true; } } } - if (isGod(player)) - { + if (isGod(player)) { sendSystemMessageTestingOnly(player, "You are passing the permissions check because you are in god mode"); return true; } - if (flagType.equals("initialRequiredFlag")) - { - return hasPermissionForZone(player, zone, "finalRequiredFlag"); - } - else - { - return false; - } + return flagType.equals("initialRequiredFlag") && hasPermissionForZone(player, zone, "finalRequiredFlag"); } public static void notifyPlayerOfInvalidPermission(obj_id player, String zone) throws InterruptedException { diff --git a/sku.0/sys.server/compiled/game/script/library/travel.java b/sku.0/sys.server/compiled/game/script/library/travel.java old mode 100644 new mode 100755 index 8d1ccbc04..34b5e8b1d --- a/sku.0/sys.server/compiled/game/script/library/travel.java +++ b/sku.0/sys.server/compiled/game/script/library/travel.java @@ -1,19 +1,11 @@ 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.dictionary; +import script.location; +import script.obj_id; +import script.string_id; -import script.library.city; -import script.library.instance; -import script.library.performance; -import script.library.sui; -import script.library.utils; -import java.lang.Math; +import java.util.Vector; public class travel extends script.base_script { @@ -108,7 +100,6 @@ public class travel extends script.base_script { s_yaw = s_yaw + 360.0f; } - int rotation = (int)(s_yaw + 1) / 90; float[] transform = transformDeltaWorldYaw(structure, arrival_x, arrival_z); arrival_x = transform[0]; arrival_z = transform[1]; @@ -148,7 +139,6 @@ public class travel extends script.base_script { s_yaw = s_yaw + 360.0f; } - int rotation = (int)(s_yaw + 1) / 90; Vector object_list = new Vector(); object_list.setSize(0); for (int i = idx + 1; i < num_items; i++) @@ -194,36 +184,29 @@ public class travel extends script.base_script obj_loc = new location(x, y, z, planet, cell_id); object = createObjectInCell(obj_template, structure, cell, obj_loc); } - if (obj_loc == null) + if (heading != 0.0f) + { + + } + { - LOG("LOG_CHANNEL", "Unable to create " + obj_template); - } - else - { - if (heading != 0.0f) - { - - } - - { - setYaw(object, heading); - object_list = utils.addElement(object_list, object); - } - if (is_terminal == 1) - { - setObjVar(object, VAR_STARPORT, structure); - } - if (is_transport == 1) - { - setObjVar(object, VAR_STARPORT, structure); - attachScript(object, SCRIPT_SHUTTLE); - } - if (is_pilot == 1) - { - setObjVar(object, VAR_STARPORT, structure); - attachScript(object, SCRIPT_SHUTTLE_PILOT); - } - } + setYaw(object, heading); + object_list = utils.addElement(object_list, object); + } + if (is_terminal == 1) + { + setObjVar(object, VAR_STARPORT, structure); + } + if (is_transport == 1) + { + setObjVar(object, VAR_STARPORT, structure); + attachScript(object, SCRIPT_SHUTTLE); + } + if (is_pilot == 1) + { + setObjVar(object, VAR_STARPORT, structure); + attachScript(object, SCRIPT_SHUTTLE_PILOT); + } if (object_list.size() > 0) { setObjVar(structure, VAR_BASE_OBJECT, object_list); @@ -442,19 +425,10 @@ public class travel extends script.base_script { return false; } - if (hasObjVar(object, VAR_DEPARTURE_PLANET)) - { + if (hasObjVar(object, VAR_DEPARTURE_PLANET)) { String ticket_planet = getTicketDeparturePlanet(object); String ticket_point = getTicketDeparturePoint(object); - if (!ticket_planet.equals(depart_planet)) - { - return false; - } - if (!ticket_point.equals(depart_point)) - { - return false; - } - return true; + return ticket_planet.equals(depart_planet) && ticket_point.equals(depart_point); } else { @@ -467,14 +441,7 @@ public class travel extends script.base_script { return false; } - if (hasObjVar(structure, VAR_IS_SHUTTLEPORT)) - { - return true; - } - else - { - return false; - } + return hasObjVar(structure, VAR_IS_SHUTTLEPORT); } public static boolean isTravelShuttle(obj_id object) throws InterruptedException { @@ -482,14 +449,7 @@ public class travel extends script.base_script { return false; } - if (hasScript(object, SCRIPT_SHUTTLE)) - { - return true; - } - else - { - return false; - } + return hasScript(object, SCRIPT_SHUTTLE); } public static boolean isTravelShuttlePilot(obj_id object) throws InterruptedException { @@ -497,14 +457,7 @@ public class travel extends script.base_script { return false; } - if (hasScript(object, SCRIPT_SHUTTLE_PILOT)) - { - return true; - } - else - { - return false; - } + return hasScript(object, SCRIPT_SHUTTLE_PILOT); } public static boolean isShuttleAvailable(obj_id starport) throws InterruptedException { @@ -513,14 +466,7 @@ public class travel extends script.base_script return false; } int available = getIntObjVar(starport, VAR_SHUTTLE_AVAILABLE); - if (available == 1) - { - return true; - } - else - { - return false; - } + return available == 1; } public static boolean qualifiesForGcwTravelPerks(obj_id player) throws InterruptedException { @@ -637,24 +583,21 @@ public class travel extends script.base_script if ((planetTravelPoints != null) && (planetTravelPoints.length > 0)) { int numStarport = 0; - for (int i = 0; i < planetTravelPoints.length; ++i) - { - if (getPlanetTravelPointInterplanetary(planet, planetTravelPoints[i])) - { + String gcwContestedRegion; + + for (String planetTravelPoint : planetTravelPoints) { + if (getPlanetTravelPointInterplanetary(planet, planetTravelPoint)) { ++numStarport; int score = 50; - String gcwContestedRegion = getPlanetTravelPointGcwContestedRegion(planet, planetTravelPoints[i]); - if ((gcwContestedRegion != null) && (gcwContestedRegion.length() > 0)) - { + gcwContestedRegion = getPlanetTravelPointGcwContestedRegion(planet, planetTravelPoint); + if ((gcwContestedRegion != null) && (gcwContestedRegion.length() > 0)) { score = getGcwImperialScorePercentile(gcwContestedRegion); - if ((370444368) == faction) - { + if ((370444368) == faction) { score = 100 - score; } } - if (score > highestScore) - { - availableStarport = planetTravelPoints[i]; + if (score > highestScore) { + availableStarport = planetTravelPoint; highestScore = score; } } @@ -676,11 +619,9 @@ public class travel extends script.base_script } location loc = getLocation(player); obj_id[] items = getObjectsInRange(loc, MAXIMUM_SHUTTLE_DISTANCE); - for (int i = 0; i < items.length; i++) - { - if (isTravelShuttle(items[i])) - { - return items[i]; + for (obj_id item : items) { + if (isTravelShuttle(item)) { + return item; } } return null; @@ -702,14 +643,7 @@ public class travel extends script.base_script { return false; } - if (distance > MAXIMUM_SHUTTLE_DISTANCE) - { - return false; - } - else - { - return true; - } + return distance <= MAXIMUM_SHUTTLE_DISTANCE; } public static boolean isValidRoute(String planet1, String point1, String planet2, String point2) throws InterruptedException { @@ -761,11 +695,9 @@ public class travel extends script.base_script obj_id shuttle = obj_id.NULL_ID; if (starport_objects != null) { - for (int i = 0; i < starport_objects.length; i++) - { - if (travel.isTravelShuttle(starport_objects[i])) - { - shuttle = starport_objects[i]; + for (obj_id starport_object : starport_objects) { + if (travel.isTravelShuttle(starport_object)) { + shuttle = starport_object; break; } } @@ -831,15 +763,8 @@ public class travel extends script.base_script return false; } boolean interplanetary; - if (isShuttlePort(structure)) - { - interplanetary = false; - } - else - { - interplanetary = true; - } - boolean setup = false; + interplanetary = !isShuttlePort(structure); + boolean setup; if (civic) { setup = city.addStarport(structure, arrival_loc, travel_cost, interplanetary); @@ -921,11 +846,9 @@ public class travel extends script.base_script obj_id[] base_objects = getBaseObjects(structure); if (base_objects != null) { - for (int i = 0; i < base_objects.length; i++) - { - if (isIdValid(base_objects[i])) - { - destroyObject(base_objects[i]); + for (obj_id base_object : base_objects) { + if (isIdValid(base_object)) { + destroyObject(base_object); } } } @@ -952,7 +875,7 @@ public class travel extends script.base_script return false; } } - if (planet2.equals("kashyyyk_main")) + else if (planet2.equals("kashyyyk_main")) { if (!features.hasEpisode3Expansion(player)) { @@ -960,7 +883,7 @@ public class travel extends script.base_script return false; } } - if (planet1.equals(planet2)) + else if (planet1.equals(planet2)) { if (point1.equals(point2)) { @@ -1018,8 +941,6 @@ public class travel extends script.base_script hasTravelVoucher = true; } int total_money = getTotalMoney(player); - int cash = getCashBalance(player); - int bank = getBankBalance(player); if (total_money < total_cost) { hasEnoughMoney = false; @@ -1207,11 +1128,6 @@ public class travel extends script.base_script if (roundtrip) { obj_id return_ticket = createObjectOverloaded(BASE_TRAVEL_TICKET, inv); - if (ticket == null) - { - LOG("LOG_CHANNEL", "player_travel::OnPurchaseTicket -- Unable to create return ticket."); - return null; - } setObjVar(return_ticket, VAR_DEPARTURE_PLANET, planet2); setObjVar(return_ticket, VAR_DEPARTURE_POINT, point2); setObjVar(return_ticket, VAR_ARRIVAL_PLANET, planet1); @@ -1255,7 +1171,7 @@ public class travel extends script.base_script return false; } } - if (planet.equals("kashyyyk_main")) + else if (planet.equals("kashyyyk_main")) { if (!features.hasEpisode3Expansion(player)) { @@ -1306,26 +1222,24 @@ public class travel extends script.base_script switch (rotation) { case 0: - break; + break; case 1: - X = z; - Z = -x; - break; + X = z; + Z = -x; + break; case 2: - Z = -z; - X = -x; - break; + Z = -z; + X = -x; + break; case 3: - X = -z; - Z = x; - break; + X = -z; + Z = x; + break; } - float[] delta_world = - { + return new float[]{ X, Z }; - return delta_world; } public static float[] transformDeltaWorldYaw(obj_id object, float x, float z) throws InterruptedException { @@ -1337,12 +1251,10 @@ public class travel extends script.base_script float yaw_radians = (float)Math.toRadians(yaw); float X = (x * (float)Math.cos(yaw_radians)) + (z * (float)Math.sin(yaw_radians)); float Z = (z * (float)Math.cos(yaw_radians)) - (x * (float)Math.sin(yaw_radians)); - float[] delta_world = - { + return new float[]{ X, Z }; - return delta_world; } public static boolean testBoardShuttle(obj_id player, obj_id shuttle) throws InterruptedException { @@ -1357,14 +1269,13 @@ public class travel extends script.base_script dsrc.setSize(0); obj_id inventory = getObjectInSlot(player, "inventory"); obj_id[] inv_contents = utils.getContents(inventory, false); - for (int i = 0; i < inv_contents.length; i++) - { - if (isTravelTicketValid(inv_contents[i], planet, depart_point)) - { - String ticket_planet = getTicketArrivalPlanet(inv_contents[i]); - String ticket_point = getTicketArrivalPoint(inv_contents[i]); + String ticket_planet; + + for (obj_id inv_content : inv_contents) { + if (isTravelTicketValid(inv_content, planet, depart_point)) { + ticket_planet = getTicketArrivalPlanet(inv_content); ticket_planet = (ticket_planet.substring(0, 1)).toUpperCase() + (ticket_planet.substring(1)).toLowerCase(); - dsrc = utils.addElement(dsrc, ticket_planet + " -- " + ticket_point); + dsrc = utils.addElement(dsrc, ticket_planet + " -- " + getTicketArrivalPoint(inv_content)); } } if (dsrc.size() < 1) @@ -1394,11 +1305,9 @@ public class travel extends script.base_script } Vector ret = new Vector(); ret.setSize(0); - for (int i = 0; i < allPts.length; i++) - { - if (getPlanetTravelPointInterplanetary(planet, allPts[i]) == isStarport) - { - ret = utils.addElement(ret, allPts[i]); + for (String allPt : allPts) { + if (getPlanetTravelPointInterplanetary(planet, allPt) == isStarport) { + ret = utils.addElement(ret, allPt); } } return ret; @@ -1449,11 +1358,7 @@ public class travel extends script.base_script sendSystemMessage(player, new string_id("beast", "beast_cant_travel")); return false; } - if (movePlayerToDestination(player, planet2, point2)) - { - return true; - } - return false; + return movePlayerToDestination(player, planet2, point2); } public static boolean isTravelBlocked(obj_id player, boolean isLaunch) throws InterruptedException { diff --git a/sku.0/sys.server/compiled/game/script/library/trial.java b/sku.0/sys.server/compiled/game/script/library/trial.java old mode 100644 new mode 100755 index 0ab3738a0..dd186e00a --- a/sku.0/sys.server/compiled/game/script/library/trial.java +++ b/sku.0/sys.server/compiled/game/script/library/trial.java @@ -1,20 +1,13 @@ 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.dictionary; +import script.location; +import script.obj_id; +import script.string_id; -import script.library.beast_lib; -import script.library.utils; -import script.library.colors; -import script.library.space_dungeon; -import script.library.stealth; -import script.library.attrib; -import script.library.prose; +import java.util.Arrays; +import java.util.Collections; +import java.util.Vector; public class trial extends script.base_script { @@ -255,7 +248,7 @@ public class trial extends script.base_script public static final int HP_UNCLE_JOE = 818125; public static final int HP_JOES_ADDS = 355325; public static final int TIME_UPLINK_WIN = 60 * 60 * 2; - public static final int TIME_DECREPIT_ADD = 60 * 90 * 1; + public static final int TIME_DECREPIT_ADD = 60 * 90; public static final int TIME_DECREPIT_WIN = 60 * 60 * 3; public static final int TIME_BATTLEFIELD_WIN = 60 * 60 * 3; public static final int TIME_WORKING_ADD = 60 * 60 * 2; @@ -303,7 +296,6 @@ public class trial extends script.base_script tokenTypes[i] = 0; } setObjVar(self, "item.set.tokens_held", tokenTypes); - return; } public static void verifyBox(obj_id self) throws InterruptedException { @@ -319,13 +311,9 @@ public class trial extends script.base_script { newTokenTypes[i] = 0; } - for (int i = 0; i < tokenTypes.length; i++) - { - newTokenTypes[i] = tokenTypes[i]; - } + System.arraycopy(tokenTypes, 0, newTokenTypes, 0, tokenTypes.length); setObjVar(self, "item.set.tokens_held", newTokenTypes); } - return; } public static String generateNewKeyCode(obj_id dungeon) throws InterruptedException { @@ -377,69 +365,59 @@ public class trial extends script.base_script switch (timer) { case 10: - showFlyText(terminal, new string_id(DECREPIT_STF, "ten"), 1.0f, colors.GREEN); - dict.put("timer", 9); - messageTo(terminal, "showStatusFlyText", dict, 1, false); - return; + showFlyText(terminal, new string_id(DECREPIT_STF, "ten"), 1.0f, colors.GREEN); + dict.put("timer", 9); + messageTo(terminal, "showStatusFlyText", dict, 1, false); + return; case 9: - showFlyText(terminal, new string_id(DECREPIT_STF, "nine"), 1.0f, colors.GREEN); - dict.put("timer", 8); - messageTo(terminal, "showStatusFlyText", dict, 1, false); - return; + showFlyText(terminal, new string_id(DECREPIT_STF, "nine"), 1.0f, colors.GREEN); + dict.put("timer", 8); + messageTo(terminal, "showStatusFlyText", dict, 1, false); + return; case 8: - showFlyText(terminal, new string_id(DECREPIT_STF, "eight"), 1.0f, colors.GREEN); - dict.put("timer", 7); - messageTo(terminal, "showStatusFlyText", dict, 1, false); - return; + showFlyText(terminal, new string_id(DECREPIT_STF, "eight"), 1.0f, colors.GREEN); + dict.put("timer", 7); + messageTo(terminal, "showStatusFlyText", dict, 1, false); + return; case 7: - showFlyText(terminal, new string_id(DECREPIT_STF, "seven"), 1.0f, colors.GREEN); - dict.put("timer", 6); - messageTo(terminal, "showStatusFlyText", dict, 1, false); - return; + showFlyText(terminal, new string_id(DECREPIT_STF, "seven"), 1.0f, colors.GREEN); + dict.put("timer", 6); + messageTo(terminal, "showStatusFlyText", dict, 1, false); + return; case 6: - showFlyText(terminal, new string_id(DECREPIT_STF, "six"), 1.0f, colors.GREEN); - dict.put("timer", 5); - messageTo(terminal, "showStatusFlyText", dict, 1, false); - return; + showFlyText(terminal, new string_id(DECREPIT_STF, "six"), 1.0f, colors.GREEN); + dict.put("timer", 5); + messageTo(terminal, "showStatusFlyText", dict, 1, false); + return; case 5: - showFlyText(terminal, new string_id(DECREPIT_STF, "five"), 1.0f, colors.GREEN); - dict.put("timer", 4); - messageTo(terminal, "showStatusFlyText", dict, 1, false); - return; + showFlyText(terminal, new string_id(DECREPIT_STF, "five"), 1.0f, colors.GREEN); + dict.put("timer", 4); + messageTo(terminal, "showStatusFlyText", dict, 1, false); + return; case 4: - showFlyText(terminal, new string_id(DECREPIT_STF, "four"), 1.0f, colors.GREEN); - dict.put("timer", 3); - messageTo(terminal, "showStatusFlyText", dict, 1, false); - return; + showFlyText(terminal, new string_id(DECREPIT_STF, "four"), 1.0f, colors.GREEN); + dict.put("timer", 3); + messageTo(terminal, "showStatusFlyText", dict, 1, false); + return; case 3: - showFlyText(terminal, new string_id(DECREPIT_STF, "three"), 1.0f, colors.GREEN); - dict.put("timer", 2); - messageTo(terminal, "showStatusFlyText", dict, 1, false); - return; + showFlyText(terminal, new string_id(DECREPIT_STF, "three"), 1.0f, colors.GREEN); + dict.put("timer", 2); + messageTo(terminal, "showStatusFlyText", dict, 1, false); + return; case 2: - showFlyText(terminal, new string_id(DECREPIT_STF, "two"), 1.0f, colors.GREEN); - dict.put("timer", 1); - messageTo(terminal, "showStatusFlyText", dict, 1, false); - return; + showFlyText(terminal, new string_id(DECREPIT_STF, "two"), 1.0f, colors.GREEN); + dict.put("timer", 1); + messageTo(terminal, "showStatusFlyText", dict, 1, false); + return; case 1: - showFlyText(terminal, new string_id(DECREPIT_STF, "one"), 1.0f, colors.GREEN); - dict.put("timer", 0); - messageTo(terminal, "showStatusFlyText", dict, 1, false); - return; + showFlyText(terminal, new string_id(DECREPIT_STF, "one"), 1.0f, colors.GREEN); + dict.put("timer", 0); + messageTo(terminal, "showStatusFlyText", dict, 1, false); } } - public static boolean isTrapActive(obj_id dungeon) throws InterruptedException - { + public static boolean isTrapActive(obj_id dungeon) throws InterruptedException { dungeon = getTop(dungeon); - boolean triggered = true; - if (utils.hasScriptVar(dungeon, TRAP_STATE)) - { - return utils.getBooleanScriptVar(dungeon, TRAP_STATE); - } - else - { - return false; - } + return utils.hasScriptVar(dungeon, TRAP_STATE) && utils.getBooleanScriptVar(dungeon, TRAP_STATE); } public static boolean isTrapPrimed(obj_id dungeon) throws InterruptedException { @@ -451,10 +429,8 @@ public class trial extends script.base_script return false; } boolean primed = false; - for (int i = 0; i < sensors.length; i++) - { - if (isSensorActive(sensors[i])) - { + for (obj_id sensor : sensors) { + if (isSensorActive(sensor)) { primed = true; } } @@ -751,16 +727,14 @@ public class trial extends script.base_script { return; } - for (int i = 0; i < assemblyUnits.length; i++) - { - if (isDisabled(assemblyUnits[i])) - { - clearCondition(assemblyUnits[i], CONDITION_DISABLED); + for (obj_id assemblyUnit : assemblyUnits) { + if (isDisabled(assemblyUnit)) { + clearCondition(assemblyUnit, CONDITION_DISABLED); } - int maxHitPoints = getMaxHitpoints(assemblyUnits[i]); - setHitpoints(assemblyUnits[i], maxHitPoints); - setInvulnerable(assemblyUnits[i], true); - trial.bumpSession(assemblyUnits[i]); + int maxHitPoints = getMaxHitpoints(assemblyUnit); + setHitpoints(assemblyUnit, maxHitPoints); + setInvulnerable(assemblyUnit, true); + trial.bumpSession(assemblyUnit); } } public static void clearMdeArea(obj_id dungeon) throws InterruptedException @@ -781,9 +755,8 @@ public class trial extends script.base_script { return; } - for (int i = 0; i < assemblyUnits.length; i++) - { - utils.setScriptVar(assemblyUnits[i], WORKING_ASSEMBLY_STAGE, 0); + for (obj_id assemblyUnit : assemblyUnits) { + utils.setScriptVar(assemblyUnit, WORKING_ASSEMBLY_STAGE, 0); } } public static boolean isActiveHand(obj_id unit) throws InterruptedException @@ -858,7 +831,6 @@ public class trial extends script.base_script public static boolean isUplinkDefeated(obj_id dungeon) throws InterruptedException { dungeon = getTop(dungeon); - boolean result = false; if (utils.hasScriptVar(dungeon, UPLINK_VICTORY_STATE)) { return utils.getBooleanScriptVar(dungeon, UPLINK_VICTORY_STATE); @@ -872,7 +844,6 @@ public class trial extends script.base_script public static boolean isUplinkActive(obj_id dungeon) throws InterruptedException { dungeon = getTop(dungeon); - boolean result = false; if (utils.hasScriptVar(dungeon, UPLINK_ACTIVE)) { return utils.getBooleanScriptVar(dungeon, UPLINK_ACTIVE); @@ -952,61 +923,29 @@ public class trial extends script.base_script { utils.setScriptVar(npc, VOLCANO_THREE_IS_BOSS, true); } - public static boolean isVolcanoCommander(obj_id npc) throws InterruptedException - { - if (utils.hasScriptVar(npc, VOLCANO_THREE_IS_BOSS)) - { - return utils.getBooleanScriptVar(npc, VOLCANO_THREE_IS_BOSS); - } - else - { - return false; - } + public static boolean isVolcanoCommander(obj_id npc) throws InterruptedException { + return utils.hasScriptVar(npc, VOLCANO_THREE_IS_BOSS) && utils.getBooleanScriptVar(npc, VOLCANO_THREE_IS_BOSS); } public static void markAsVolcanoCorpse(obj_id npc) throws InterruptedException { utils.setScriptVar(npc, VOLCANO_THREE_IS_CORPSE, true); } - public static boolean isVolcanoCorpse(obj_id npc) throws InterruptedException - { - if (utils.hasScriptVar(npc, VOLCANO_THREE_IS_CORPSE)) - { - return utils.getBooleanScriptVar(npc, VOLCANO_THREE_IS_CORPSE); - } - else - { - return false; - } + public static boolean isVolcanoCorpse(obj_id npc) throws InterruptedException { + return utils.hasScriptVar(npc, VOLCANO_THREE_IS_CORPSE) && utils.getBooleanScriptVar(npc, VOLCANO_THREE_IS_CORPSE); } public static void markAsVolcanoBeetle(obj_id npc) throws InterruptedException { utils.setScriptVar(npc, VOLCANO_FOUR_IS_BEETLE, true); } - public static boolean isVolcanoBeetle(obj_id npc) throws InterruptedException - { - if (utils.hasScriptVar(npc, VOLCANO_FOUR_IS_BEETLE)) - { - return utils.getBooleanScriptVar(npc, VOLCANO_FOUR_IS_BEETLE); - } - else - { - return false; - } + public static boolean isVolcanoBeetle(obj_id npc) throws InterruptedException { + return utils.hasScriptVar(npc, VOLCANO_FOUR_IS_BEETLE) && utils.getBooleanScriptVar(npc, VOLCANO_FOUR_IS_BEETLE); } public static void markAsHkCorpse(obj_id npc) throws InterruptedException { utils.setScriptVar(npc, VOLCANO_FINAL_IS_CORPSE, true); } - public static boolean isHkCorpse(obj_id npc) throws InterruptedException - { - if (utils.hasScriptVar(npc, VOLCANO_FINAL_IS_CORPSE)) - { - return utils.getBooleanScriptVar(npc, VOLCANO_FINAL_IS_CORPSE); - } - else - { - return false; - } + public static boolean isHkCorpse(obj_id npc) throws InterruptedException { + return utils.hasScriptVar(npc, VOLCANO_FINAL_IS_CORPSE) && utils.getBooleanScriptVar(npc, VOLCANO_FINAL_IS_CORPSE); } public static dictionary getSessionDict(obj_id subject) throws InterruptedException { @@ -1089,15 +1028,10 @@ public class trial extends script.base_script session += 1; utils.setScriptVar(subject, uniqueSession, session); } - public static boolean isCellPublic(obj_id dungeon, String cellName) throws InterruptedException - { + public static boolean isCellPublic(obj_id dungeon, String cellName) throws InterruptedException { dungeon = getTop(dungeon); obj_id cellId = getCellId(dungeon, cellName); - if (!isIdValid(cellId)) - { - return false; - } - return permissionsIsPublic(cellId); + return isIdValid(cellId) && permissionsIsPublic(cellId); } public static void makeCellPublic(obj_id dungeon, String cellName) throws InterruptedException { @@ -1142,16 +1076,13 @@ public class trial extends script.base_script } Vector eventPlayers = new Vector(); eventPlayers.setSize(0); - for (int i = 0; i < cellIds.length; i++) - { - obj_id[] contents = getContents(cellIds[i]); - if (contents != null && contents.length > 0) - { - for (int k = 0; k < contents.length; k++) - { - if (isPlayer(contents[k])) - { - eventPlayers = utils.addElement(eventPlayers, contents[k]); + obj_id[] contents; + for (obj_id cellId : cellIds) { + contents = getContents(cellId); + if (contents != null && contents.length > 0) { + for (obj_id content : contents) { + if (isPlayer(content)) { + eventPlayers = utils.addElement(eventPlayers, content); } } } @@ -1160,12 +1091,8 @@ public class trial extends script.base_script { return null; } - obj_id[] convertedArray = new obj_id[0]; - if (eventPlayers != null) - { - convertedArray = new obj_id[eventPlayers.size()]; - eventPlayers.toArray(convertedArray); - } + obj_id[] convertedArray = new obj_id[eventPlayers.size()]; + eventPlayers.toArray(convertedArray); if (convertedArray.length > 0) { return convertedArray; @@ -1183,34 +1110,26 @@ public class trial extends script.base_script validTargets.setSize(0); if (players != null && players.length > 0) { - for (int i = 0; i < players.length; i++) - { - if (!isIncapacitated(players[i]) && !isDead(players[i])) - { - utils.addElement(validTargets, players[i]); + for (obj_id player : players) { + if (!isIncapacitated(player) && !isDead(player)) { + utils.addElement(validTargets, player); } } } if (pets != null && pets.length > 0) { - for (int q = 0; q < pets.length; q++) - { - if (!isIncapacitated(pets[q]) && !isDead(pets[q])) - { - utils.addElement(validTargets, pets[q]); + for (obj_id pet : pets) { + if (!isIncapacitated(pet) && !isDead(pet)) { + utils.addElement(validTargets, pet); } } } - if (validTargets == null || validTargets.size() == 0) + if (validTargets.size() == 0) { return null; } - obj_id[] returnList = new obj_id[0]; - if (validTargets != null) - { - returnList = new obj_id[validTargets.size()]; - validTargets.toArray(returnList); - } + obj_id[] returnList = new obj_id[validTargets.size()]; + validTargets.toArray(returnList); return returnList; } public static obj_id[] getValidTargetsInCell(obj_id dungeon, String cell) throws InterruptedException @@ -1220,29 +1139,23 @@ public class trial extends script.base_script public static obj_id[] getNonStealthedTargetsInCell(obj_id dungeon, String cell) throws InterruptedException { obj_id[] players = getPlayersInCell(dungeon, cell); - Vector validTargets = new Vector(); - validTargets.setSize(0); if (players == null || players.length == 0) { return null; } - for (int i = 0; i < players.length; i++) - { - if (!isIncapacitated(players[i]) && !isDead(players[i]) && !stealth.hasInvisibleBuff(players[i])) - { - utils.addElement(validTargets, players[i]); + Vector validTargets = new Vector(); + validTargets.setSize(0); + for (obj_id player : players) { + if (!isIncapacitated(player) && !isDead(player) && !stealth.hasInvisibleBuff(player)) { + utils.addElement(validTargets, player); } } - if (validTargets == null || validTargets.size() == 0) + if (validTargets.size() == 0) { return null; } - obj_id[] returnList = new obj_id[0]; - if (validTargets != null) - { - returnList = new obj_id[validTargets.size()]; - validTargets.toArray(returnList); - } + obj_id[] returnList = new obj_id[validTargets.size()]; + validTargets.toArray(returnList); return returnList; } public static obj_id[] getPlayersInCell(obj_id dungeon, String cell) throws InterruptedException @@ -1258,24 +1171,18 @@ public class trial extends script.base_script obj_id[] contents = getContents(cellId); if (contents != null && contents.length > 0) { - for (int k = 0; k < contents.length; k++) - { - if (isPlayer(contents[k])) - { - utils.addElement(players, contents[k]); + for (obj_id content : contents) { + if (isPlayer(content)) { + utils.addElement(players, content); } } } - if (players == null || players.size() == 0) + if (players.size() == 0) { return null; } - obj_id[] returnPlayers = new obj_id[0]; - if (players != null) - { - returnPlayers = new obj_id[players.size()]; - players.toArray(returnPlayers); - } + obj_id[] returnPlayers = new obj_id[players.size()]; + players.toArray(returnPlayers); return returnPlayers; } public static obj_id[] getPlayersInCell(obj_id dungeon, obj_id cell) throws InterruptedException @@ -1295,36 +1202,29 @@ public class trial extends script.base_script { searchCells[j] = getCellId(dungeon, cells[j]); } - if (searchCells == null || searchCells.length == 0) + if (searchCells.length == 0) { return null; } Vector players = new Vector(); players.setSize(0); - for (int i = 0; i < searchCells.length; i++) - { - obj_id[] contents = getContents(searchCells[i]); - if (contents != null && contents.length > 0) - { - for (int k = 0; k < contents.length; k++) - { - if (isPlayer(contents[k])) - { - utils.addElement(players, contents[k]); + obj_id[] contents; + for (obj_id searchCell : searchCells) { + contents = getContents(searchCell); + if (contents != null && contents.length > 0) { + for (obj_id content : contents) { + if (isPlayer(content)) { + utils.addElement(players, content); } } } } - if (players == null || players.size() == 0) + if (players.size() == 0) { return null; } - obj_id[] returnPlayers = new obj_id[0]; - if (players != null) - { - returnPlayers = new obj_id[players.size()]; - players.toArray(returnPlayers); - } + obj_id[] returnPlayers = new obj_id[players.size()]; + players.toArray(returnPlayers); return returnPlayers; } public static obj_id[] getObjectsInDungeonWithScript(obj_id dungeon, String script) throws InterruptedException @@ -1345,30 +1245,23 @@ public class trial extends script.base_script } Vector objectsWithScript = new Vector(); objectsWithScript.setSize(0); - for (int i = 0; i < cells.length; i++) - { - obj_id[] contents = getContents(cells[i]); - if (contents != null && contents.length > 0) - { - for (int k = 0; k < contents.length; k++) - { - if (hasScript(contents[k], script)) - { - utils.addElement(objectsWithScript, contents[k]); + obj_id[] contents; + for (obj_id cell : cells) { + contents = getContents(cell); + if (contents != null && contents.length > 0) { + for (obj_id content : contents) { + if (hasScript(content, script)) { + utils.addElement(objectsWithScript, content); } } } } - if (objectsWithScript == null || objectsWithScript.size() == 0) + if (objectsWithScript.size() == 0) { return null; } - obj_id[] returnList = new obj_id[0]; - if (objectsWithScript != null) - { - returnList = new obj_id[objectsWithScript.size()]; - objectsWithScript.toArray(returnList); - } + obj_id[] returnList = new obj_id[objectsWithScript.size()]; + objectsWithScript.toArray(returnList); return returnList; } public static obj_id[] getAllObjectsInDungeon(obj_id dungeon) throws InterruptedException @@ -1385,27 +1278,21 @@ public class trial extends script.base_script } Vector objects = new Vector(); objects.setSize(0); - for (int i = 0; i < cells.length; i++) - { - obj_id[] contents = getContents(cells[i]); - if (contents != null && contents.length > 0) - { - for (int k = 0; k < contents.length; k++) - { - utils.addElement(objects, contents[k]); + obj_id[] contents; + for (obj_id cell : cells) { + contents = getContents(cell); + if (contents != null && contents.length > 0) { + for (obj_id content : contents) { + utils.addElement(objects, content); } } } - if (objects == null || objects.size() == 0) + if (objects.size() == 0) { return null; } - obj_id[] returnList = new obj_id[0]; - if (objects != null) - { - returnList = new obj_id[objects.size()]; - objects.toArray(returnList); - } + obj_id[] returnList = new obj_id[objects.size()]; + objects.toArray(returnList); return returnList; } public static obj_id[] getObjectsInDungeonWithObjVar(obj_id dungeon, String objvar) throws InterruptedException @@ -1426,30 +1313,23 @@ public class trial extends script.base_script } Vector objectsWithObjVar = new Vector(); objectsWithObjVar.setSize(0); - for (int i = 0; i < cells.length; i++) - { - obj_id[] contents = getContents(cells[i]); - if (contents != null && contents.length > 0) - { - for (int k = 0; k < contents.length; k++) - { - if (hasObjVar(contents[k], objvar)) - { - utils.addElement(objectsWithObjVar, contents[k]); + obj_id[] contents; + for (obj_id cell : cells) { + contents = getContents(cell); + if (contents != null && contents.length > 0) { + for (obj_id content : contents) { + if (hasObjVar(content, objvar)) { + utils.addElement(objectsWithObjVar, content); } } } } - if (objectsWithObjVar == null || objectsWithObjVar.size() == 0) + if (objectsWithObjVar.size() == 0) { return null; } - obj_id[] returnList = new obj_id[0]; - if (objectsWithObjVar != null) - { - returnList = new obj_id[objectsWithObjVar.size()]; - objectsWithObjVar.toArray(returnList); - } + obj_id[] returnList = new obj_id[objectsWithObjVar.size()]; + objectsWithObjVar.toArray(returnList); return returnList; } public static obj_id[] getObjectsInCellWithObjVar(obj_id dungeon, String cellName, String objvar) throws InterruptedException @@ -1473,24 +1353,18 @@ public class trial extends script.base_script obj_id[] contents = getContents(checkCell); if (contents != null && contents.length > 0) { - for (int k = 0; k < contents.length; k++) - { - if (hasObjVar(contents[k], objvar)) - { - utils.addElement(objectsWithObjVar, contents[k]); + for (obj_id content : contents) { + if (hasObjVar(content, objvar)) { + utils.addElement(objectsWithObjVar, content); } } } - if (objectsWithObjVar == null || objectsWithObjVar.size() == 0) + if (objectsWithObjVar.size() == 0) { return null; } - obj_id[] returnList = new obj_id[0]; - if (objectsWithObjVar != null) - { - returnList = new obj_id[objectsWithObjVar.size()]; - objectsWithObjVar.toArray(returnList); - } + obj_id[] returnList = new obj_id[objectsWithObjVar.size()]; + objectsWithObjVar.toArray(returnList); return returnList; } public static obj_id[] getObjectsInDungeonWithScriptVar(obj_id dungeon, String scriptVar) throws InterruptedException @@ -1511,30 +1385,23 @@ public class trial extends script.base_script } Vector objectsWithScriptVar = new Vector(); objectsWithScriptVar.setSize(0); - for (int i = 0; i < cells.length; i++) - { - obj_id[] contents = getContents(cells[i]); - if (contents != null && contents.length > 0) - { - for (int k = 0; k < contents.length; k++) - { - if (utils.hasScriptVar(contents[k], scriptVar)) - { - utils.addElement(objectsWithScriptVar, contents[k]); + obj_id[] contents; + for (obj_id cell : cells) { + contents = getContents(cell); + if (contents != null && contents.length > 0) { + for (obj_id content : contents) { + if (utils.hasScriptVar(content, scriptVar)) { + utils.addElement(objectsWithScriptVar, content); } } } } - if (objectsWithScriptVar == null || objectsWithScriptVar.size() == 0) + if (objectsWithScriptVar.size() == 0) { return null; } - obj_id[] returnList = new obj_id[0]; - if (objectsWithScriptVar != null) - { - returnList = new obj_id[objectsWithScriptVar.size()]; - objectsWithScriptVar.toArray(returnList); - } + obj_id[] returnList = new obj_id[objectsWithScriptVar.size()]; + objectsWithScriptVar.toArray(returnList); return returnList; } public static obj_id[] getValidTargetsInRadius(obj_id center, float range) throws InterruptedException @@ -1545,35 +1412,27 @@ public class trial extends script.base_script targets.setSize(0); if (pets != null && pets.length != 0) { - for (int i = 0; i < pets.length; i++) - { - if (isIdValid(pets[i]) && exists(pets[i]) && (hasScript(pets[i], "ai.pet") || beast_lib.isBeast(pets[i]) && canSee(center, pets[i]))) - { - utils.addElement(targets, pets[i]); + for (obj_id pet : pets) { + if (isIdValid(pet) && exists(pet) && (hasScript(pet, "ai.pet") || beast_lib.isBeast(pet) && canSee(center, pet))) { + utils.addElement(targets, pet); } } } if (players != null && players.length != 0) { - for (int k = 0; k < players.length; k++) - { - if (isIdValid(players[k]) && exists(players[k]) && !isIncapacitated(players[k]) && canSee(center, players[k])) - { - utils.addElement(targets, players[k]); + for (obj_id player : players) { + if (isIdValid(player) && exists(player) && !isIncapacitated(player) && canSee(center, player)) { + utils.addElement(targets, player); } } } - if (targets == null || targets.size() == 0) + if (targets.size() == 0) { doLogging("getValidTargetsInRadius", "There were no valid pets or players in the radial area"); return null; } - obj_id[] validTargets = new obj_id[0]; - if (targets != null) - { - validTargets = new obj_id[targets.size()]; - targets.toArray(validTargets); - } + obj_id[] validTargets = new obj_id[targets.size()]; + targets.toArray(validTargets); return validTargets; } public static obj_id[] getValidTargetsInRadiusIgnoreLOS(obj_id center, float range) throws InterruptedException @@ -1584,35 +1443,27 @@ public class trial extends script.base_script targets.setSize(0); if (pets != null && pets.length != 0) { - for (int i = 0; i < pets.length; i++) - { - if (isIdValid(pets[i]) && exists(pets[i]) && (hasScript(pets[i], "ai.pet") || beast_lib.isBeast(pets[i]))) - { - utils.addElement(targets, pets[i]); + for (obj_id pet : pets) { + if (isIdValid(pet) && exists(pet) && (hasScript(pet, "ai.pet") || beast_lib.isBeast(pet))) { + utils.addElement(targets, pet); } } } if (players != null && players.length != 0) { - for (int k = 0; k < players.length; k++) - { - if (isIdValid(players[k]) && exists(players[k]) && !isIncapacitated(players[k])) - { - utils.addElement(targets, players[k]); + for (obj_id player : players) { + if (isIdValid(player) && exists(player) && !isIncapacitated(player)) { + utils.addElement(targets, player); } } } - if (targets == null || targets.size() == 0) + if (targets.size() == 0) { doLogging("getValidTargetsInRadius", "There were no valid pets or players in the radial area"); return null; } - obj_id[] validTargets = new obj_id[0]; - if (targets != null) - { - validTargets = new obj_id[targets.size()]; - targets.toArray(validTargets); - } + obj_id[] validTargets = new obj_id[targets.size()]; + targets.toArray(validTargets); return validTargets; } public static obj_id[] getValidTargetsInCone(obj_id self, obj_id target, float range, float cone) throws InterruptedException @@ -1623,35 +1474,27 @@ public class trial extends script.base_script targets.setSize(0); if (pets != null && pets.length != 0) { - for (int i = 0; i < pets.length; i++) - { - if (isIdValid(pets[i]) && exists(pets[i]) && hasScript(pets[i], "ai.pet")) - { - utils.addElement(targets, pets[i]); + for (obj_id pet : pets) { + if (isIdValid(pet) && exists(pet) && hasScript(pet, "ai.pet")) { + utils.addElement(targets, pet); } } } if (players != null && players.length != 0) { - for (int k = 0; k < players.length; k++) - { - if (isIdValid(players[k]) && exists(players[k]) && !isIncapacitated(players[k])) - { - utils.addElement(targets, players[k]); + for (obj_id player : players) { + if (isIdValid(player) && exists(player) && !isIncapacitated(player)) { + utils.addElement(targets, player); } } } - if (targets == null || targets.size() == 0) + if (targets.size() == 0) { doLogging("getValidTargetsInCone", "There were no valid pets or players in the cone area"); return null; } - obj_id[] validTargets = new obj_id[0]; - if (targets != null) - { - validTargets = new obj_id[targets.size()]; - targets.toArray(validTargets); - } + obj_id[] validTargets = new obj_id[targets.size()]; + targets.toArray(validTargets); return validTargets; } public static obj_id[] getValidPlayersInRadius(obj_id self, float range) throws InterruptedException @@ -1661,25 +1504,19 @@ public class trial extends script.base_script targets.setSize(0); if (players != null && players.length != 0) { - for (int k = 0; k < players.length; k++) - { - if (isIdValid(players[k]) && exists(players[k]) && !isIncapacitated(players[k]) && canSee(self, players[k])) - { - utils.addElement(targets, players[k]); + for (obj_id player : players) { + if (isIdValid(player) && exists(player) && !isIncapacitated(player) && canSee(self, player)) { + utils.addElement(targets, player); } } } - if (targets == null || targets.size() == 0) + if (targets.size() == 0) { doLogging("getValidPlayersInRadius", "There were no valid players in the radial area"); return null; } - obj_id[] validTargets = new obj_id[0]; - if (targets != null) - { - validTargets = new obj_id[targets.size()]; - targets.toArray(validTargets); - } + obj_id[] validTargets = new obj_id[targets.size()]; + targets.toArray(validTargets); return validTargets; } public static void setDungeonCleanOutTimer(obj_id dungeon_controller) throws InterruptedException @@ -1756,18 +1593,13 @@ public class trial extends script.base_script if (cells != null) { obj_id[] objects = getAllObjectsInDungeon(object); - location ejectPoint = getLocation(object); if (objects != null && objects.length > 0) { - for (int i = 0; i < objects.length; i++) - { - if (isPlayer(objects[i])) - { - expelFromBuilding(objects[i]); - } - else - { - cleanupObject(objects[i]); + for (obj_id object1 : objects) { + if (isPlayer(object1)) { + expelFromBuilding(object1); + } else { + cleanupObject(object1); } } } @@ -1795,9 +1627,8 @@ public class trial extends script.base_script { return; } - for (int i = 0; i < objects.length; i++) - { - cleanupObject(objects[i]); + for (obj_id object : objects) { + cleanupObject(object); } } public static void setHp(obj_id target, int ammount) throws InterruptedException @@ -1882,21 +1713,14 @@ public class trial extends script.base_script } return object; } - public static boolean isChild(obj_id parent, obj_id child) throws InterruptedException - { - if (!isIdValid(parent) || !isIdValid(child)) - { + public static boolean isChild(obj_id parent, obj_id child) throws InterruptedException { + if (!isIdValid(parent) || !isIdValid(child)) { return false; } - if (utils.hasScriptVar(child, PARENT)) - { + if (utils.hasScriptVar(child, PARENT)) { return (utils.getObjIdScriptVar(child, PARENT) == parent); } - if (hasObjVar(child, PARENT)) - { - return (getObjIdObjVar(child, PARENT) == parent); - } - return false; + return hasObjVar(child, PARENT) && (getObjIdObjVar(child, PARENT) == parent); } public static obj_id[] getAllChildrenInDungeon(obj_id dungeon, obj_id parent) throws InterruptedException { @@ -1911,30 +1735,23 @@ public class trial extends script.base_script } Vector objects = new Vector(); objects.setSize(0); - for (int i = 0; i < cells.length; i++) - { - obj_id[] contents = getContents(cells[i]); - if (contents != null && contents.length > 0) - { - for (int k = 0; k < contents.length; k++) - { - if (isChild(parent, contents[k])) - { - utils.addElement(objects, contents[k]); + obj_id[] contents; + for (obj_id cell : cells) { + contents = getContents(cell); + if (contents != null && contents.length > 0) { + for (obj_id content : contents) { + if (isChild(parent, content)) { + utils.addElement(objects, content); } } } } - if (objects == null || objects.size() == 0) + if (objects.size() == 0) { return null; } - obj_id[] returnList = new obj_id[0]; - if (objects != null) - { - returnList = new obj_id[objects.size()]; - objects.toArray(returnList); - } + obj_id[] returnList = new obj_id[objects.size()]; + objects.toArray(returnList); return returnList; } public static obj_id[] getChildrenInRange(obj_id baseObject, obj_id parent, float range) throws InterruptedException @@ -1959,23 +1776,17 @@ public class trial extends script.base_script } Vector children = new Vector(); children.setSize(0); - for (int i = 0; i < objects.length; i++) - { - if (isChild(parent, objects[i])) - { - utils.addElement(children, objects[i]); + for (obj_id object : objects) { + if (isChild(parent, object)) { + utils.addElement(children, object); } } - if (children == null || children.size() == 0) + if (children.size() == 0) { return null; } - obj_id[] returnList = new obj_id[0]; - if (children != null) - { - returnList = new obj_id[children.size()]; - children.toArray(returnList); - } + obj_id[] returnList = new obj_id[children.size()]; + children.toArray(returnList); return returnList; } public static obj_id[] getObjectsInRangeWithScriptVar(obj_id baseObj, String scriptVar, float range) throws InterruptedException @@ -1984,8 +1795,7 @@ public class trial extends script.base_script { return null; } - location baseLoc = getLocation(baseObj); - return getObjectsInRangeWithScriptVar(baseLoc, scriptVar, range); + return getObjectsInRangeWithScriptVar(getLocation(baseObj), scriptVar, range); } public static obj_id[] getObjectsInRangeWithScriptVar(location baseLoc, String scriptVar, float range) throws InterruptedException { @@ -2000,23 +1810,17 @@ public class trial extends script.base_script } Vector withVar = new Vector(); withVar.setSize(0); - for (int i = 0; i < objects.length; i++) - { - if (utils.hasScriptVar(objects[i], scriptVar)) - { - utils.addElement(withVar, objects[i]); + for (obj_id object : objects) { + if (utils.hasScriptVar(object, scriptVar)) { + utils.addElement(withVar, object); } } - if (withVar == null || withVar.size() == 0) + if (withVar.size() == 0) { return null; } - obj_id[] returnList = new obj_id[0]; - if (withVar != null) - { - returnList = new obj_id[withVar.size()]; - withVar.toArray(returnList); - } + obj_id[] returnList = new obj_id[withVar.size()]; + withVar.toArray(returnList); return returnList; } public static void prepareCorpse(obj_id corpse) throws InterruptedException @@ -2038,19 +1842,13 @@ public class trial extends script.base_script public static obj_id getClosest(obj_id base, obj_id[] targets) throws InterruptedException { obj_id prefered = obj_id.NULL_ID; - for (int i = 0; i < targets.length; i++) - { - if (!isDead(targets[i])) - { - if (!isIdValid(prefered)) - { - prefered = targets[i]; - } - else - { - if (getDistance(base, targets[i]) < getDistance(base, prefered) && canSee(base, targets[i]) && !stealth.hasInvisibleBuff(targets[i])) - { - prefered = targets[i]; + for (obj_id target : targets) { + if (!isDead(target)) { + if (!isIdValid(prefered)) { + prefered = target; + } else { + if (getDistance(base, target) < getDistance(base, prefered) && canSee(base, target) && !stealth.hasInvisibleBuff(target)) { + prefered = target; } } } @@ -2061,20 +1859,14 @@ public class trial extends script.base_script { obj_id prefered = obj_id.NULL_ID; obj_id previous = obj_id.NULL_ID; - for (int i = 0; i < targets.length; i++) - { - if (!isDead(targets[i])) - { - if (!isIdValid(prefered)) - { - prefered = targets[i]; - } - else - { - if (getDistance(base, targets[i]) < getDistance(base, prefered) && canSee(base, targets[i])) - { + for (obj_id target : targets) { + if (!isDead(target)) { + if (!isIdValid(prefered)) { + prefered = target; + } else { + if (getDistance(base, target) < getDistance(base, prefered) && canSee(base, target)) { previous = prefered; - prefered = targets[i]; + prefered = target; } } } @@ -2084,17 +1876,12 @@ public class trial extends script.base_script public static obj_id getClosestObject(obj_id base, obj_id[] targets) throws InterruptedException { obj_id prefered = null; - for (int i = 0; i < targets.length; i++) - { - if (!isIdValid(prefered)) - { - prefered = targets[i]; - } - else - { - if (getDistance(base, targets[i]) < getDistance(base, prefered) && canSee(base, targets[i])) - { - prefered = targets[i]; + for (obj_id target : targets) { + if (!isIdValid(prefered)) { + prefered = target; + } else { + if (getDistance(base, target) < getDistance(base, prefered) && canSee(base, target)) { + prefered = target; } } } @@ -2111,17 +1898,8 @@ public class trial extends script.base_script utils.setScriptVar(object, TEMP_OBJECT, true); } } - public static boolean isTempObject(obj_id object) throws InterruptedException - { - if (utils.hasScriptVar(object, TEMP_OBJECT)) - { - return true; - } - if (hasObjVar(object, TEMP_OBJECT)) - { - return true; - } - return false; + public static boolean isTempObject(obj_id object) throws InterruptedException { + return utils.hasScriptVar(object, TEMP_OBJECT) || hasObjVar(object, TEMP_OBJECT); } public static obj_id[] getTempObjectsInDungeon(obj_id dungeon) throws InterruptedException { @@ -2132,23 +1910,17 @@ public class trial extends script.base_script } Vector tempObjects = new Vector(); tempObjects.setSize(0); - for (int i = 0; i < objects.length; i++) - { - if (isTempObject(objects[i])) - { - utils.addElement(tempObjects, objects[i]); + for (obj_id object : objects) { + if (isTempObject(object)) { + utils.addElement(tempObjects, object); } } - if (tempObjects == null || tempObjects.size() == 0) + if (tempObjects.size() == 0) { return null; } - obj_id[] _tempObjects = new obj_id[0]; - if (tempObjects != null) - { - _tempObjects = new obj_id[tempObjects.size()]; - tempObjects.toArray(_tempObjects); - } + obj_id[] _tempObjects = new obj_id[tempObjects.size()]; + tempObjects.toArray(_tempObjects); return _tempObjects; } public static obj_id[] getTempObjectsInBuildoutArea(obj_id baseObject) throws InterruptedException @@ -2160,23 +1932,17 @@ public class trial extends script.base_script } Vector tempObjects = new Vector(); tempObjects.setSize(0); - for (int i = 0; i < objects.length; i++) - { - if (trial.isTempObject(objects[i])) - { - tempObjects.add(objects[i]); + for (obj_id object : objects) { + if (trial.isTempObject(object)) { + tempObjects.add(object); } } - if (tempObjects == null || tempObjects.size() == 0) + if (tempObjects.size() == 0) { return null; } - obj_id[] _tempObjects = new obj_id[0]; - if (tempObjects != null) - { - _tempObjects = new obj_id[tempObjects.size()]; - tempObjects.toArray(_tempObjects); - } + obj_id[] _tempObjects = new obj_id[tempObjects.size()]; + tempObjects.toArray(_tempObjects); return _tempObjects; } public static String getNearestPatrolPoint(obj_id actor, String[] patrolPointList) throws InterruptedException @@ -2190,21 +1956,18 @@ public class trial extends script.base_script Vector ppl = new Vector(Arrays.asList(patrolPointList)); float distance = 2000.0f; int idx = 0; - for (int i = 0; i < points.length; i++) - { - if (getParent(actor) != getParent(points[i])) - { + String testName; + for (obj_id point : points) { + if (getParent(actor) != getParent(point)) { continue; } - String testName = getStringObjVar(points[i], "sequence_controller.patrolPointName"); - if (ppl.indexOf(testName) == -1) - { + testName = getStringObjVar(point, "sequence_controller.patrolPointName"); + if (ppl.indexOf(testName) == -1) { continue; } - if (getDistance(actor, points[i]) < distance && canSee(actor, points[i])) - { + if (getDistance(actor, point) < distance && canSee(actor, point)) { idx = ppl.lastIndexOf(testName); - distance = getDistance(actor, points[i]); + distance = getDistance(actor, point); } } return idx; @@ -2213,61 +1976,45 @@ public class trial extends script.base_script { Vector locList = new Vector(); locList.setSize(0); - for (int i = 0; i < patrolPointList.length; i++) - { - obj_id[] points = getAllObjectsWithObjVar(getLocation(actor), 2000.0f, "sequence_controller.patrolPointName"); - for (int k = 0; k < points.length; k++) - { - if ((getStringObjVar(points[k], "sequence_controller.patrolPointName")).equals(patrolPointList[i]) && trial.getParent(points[k]) == trial.getParent(actor)) - { - utils.addElement(locList, getLocation(points[k])); + obj_id[] points; + for (String aPatrolPointList : patrolPointList) { + points = getAllObjectsWithObjVar(getLocation(actor), 2000.0f, "sequence_controller.patrolPointName"); + for (obj_id point : points) { + if ((getStringObjVar(point, "sequence_controller.patrolPointName")).equals(aPatrolPointList) && trial.getParent(point) == trial.getParent(actor)) { + utils.addElement(locList, getLocation(point)); } } } - if (locList == null || locList.size() == 0) + if (locList.size() == 0) { return null; } - location[] returnList = new location[0]; - if (locList != null) - { - returnList = new location[locList.size()]; - locList.toArray(returnList); - } - location[] _locList = new location[0]; - if (locList != null) - { - _locList = new location[locList.size()]; - locList.toArray(_locList); - } + location[] returnList = new location[locList.size()]; + locList.toArray(returnList); + location[] _locList = new location[locList.size()]; + locList.toArray(_locList); return _locList; } public static obj_id[] getObjectsInListWithObjVar(obj_id[] list, String objvar) throws InterruptedException { Vector targetObjects = new Vector(); targetObjects.setSize(0); - for (int i = 0; i < list.length; i++) - { - if (isIdValid(list[i]) && exists(list[i]) && hasObjVar(list[i], objvar)) - { - utils.addElement(targetObjects, list[i]); + for (obj_id aList : list) { + if (isIdValid(aList) && exists(aList) && hasObjVar(aList, objvar)) { + utils.addElement(targetObjects, aList); } } - if (targetObjects == null || targetObjects.size() == 0) + if (targetObjects.size() == 0) { return null; } - obj_id[] returnList = new obj_id[0]; - if (targetObjects != null) - { - returnList = new obj_id[targetObjects.size()]; - targetObjects.toArray(returnList); - } + obj_id[] returnList = new obj_id[targetObjects.size()]; + targetObjects.toArray(returnList); return returnList; } public static location[] shuffleByIndex(String type, location[] ppl, int idx) throws InterruptedException { - location[] retarded = (location[])ppl.clone(); + location[] retarded = ppl.clone(); Vector oldPpl = new Vector(Arrays.asList(retarded)); Vector newPpl = new Vector(); newPpl.setSize(0); @@ -2280,48 +2027,32 @@ public class trial extends script.base_script } for (int q = 0; q < idx; q++) { - newPpl.addElement(((location)(((location)oldPpl.get(q))))); + newPpl.addElement(oldPpl.get(q)); } } if (type.equals("patrolOnce")) { - for (int i = idx; i < ppl.length; i++) - { - newPpl.add(ppl[i]); - } + newPpl.addAll(Arrays.asList(ppl).subList(idx, ppl.length)); } if (type.equals("patrolFlip")) { - for (int i = idx; i < ppl.length; i++) - { - newPpl.add(ppl[i]); - } + newPpl.addAll(Arrays.asList(ppl).subList(idx, ppl.length)); for (int q = ppl.length - 2; q > -1; q--) { newPpl.add(ppl[q]); } - for (int r = 0; r < idx; r++) - { - newPpl.add(ppl[r]); - } + newPpl.addAll(Arrays.asList(ppl).subList(0, idx)); } if (type.equals("patrolFlipOnce")) { - for (int i = idx; i < ppl.length; i++) - { - newPpl.add(ppl[i]); - } + newPpl.addAll(Arrays.asList(ppl).subList(idx, ppl.length)); } if (type.equals("patrolRandom") || type.equals("patrolRandomOnce")) { newPpl = new Vector(Arrays.asList(ppl)); } - location[] _newPpl = new location[0]; - if (newPpl != null) - { - _newPpl = new location[newPpl.size()]; - newPpl.toArray(_newPpl); - } + location[] _newPpl = new location[newPpl.size()]; + newPpl.toArray(_newPpl); return _newPpl; } public static obj_id[] getSpawnedChildren(obj_id object) throws InterruptedException @@ -2334,21 +2065,16 @@ public class trial extends script.base_script { return null; } - for (int i = 0; i < keyList.size(); i++) - { - Vector thisList = spawnList.getResizeableObjIdArray(((String)keyList.get(i))); - if (thisList == null || thisList.size() == 0) - { + Vector thisList; + for (Object aKeyList : keyList) { + thisList = spawnList.getResizeableObjIdArray(aKeyList); + if (thisList == null || thisList.size() == 0) { continue; } allChildren.addAll(thisList); } - obj_id[] returnList = new obj_id[0]; - if (allChildren != null) - { - returnList = new obj_id[allChildren.size()]; - allChildren.toArray(returnList); - } + obj_id[] returnList = new obj_id[allChildren.size()]; + allChildren.toArray(returnList); return returnList; } public static obj_id[] getObjectsInInstanceBySpawnId(obj_id baseObject, String spawn_id) throws InterruptedException @@ -2372,25 +2098,18 @@ public class trial extends script.base_script dictionary spawnList = utils.getDictionaryScriptVar(trial.getParent(baseObject), PROT_CHILD_ARRAY); Vector allSpawn = new Vector(); allSpawn.setSize(0); - for (int i = 0; i < idList.length; i++) - { - if (!spawnList.containsKey(idList[i])) - { + for (String anIdList : idList) { + if (!spawnList.containsKey(anIdList)) { continue; } - Vector thisList = spawnList.getResizeableObjIdArray(idList[i]); - if (thisList == null || thisList.size() == 0) - { + Vector thisList = spawnList.getResizeableObjIdArray(anIdList); + if (thisList == null || thisList.size() == 0) { continue; } allSpawn.addAll(thisList); } - obj_id[] returnList = new obj_id[0]; - if (allSpawn != null) - { - returnList = new obj_id[allSpawn.size()]; - allSpawn.toArray(returnList); - } + obj_id[] returnList = new obj_id[allSpawn.size()]; + allSpawn.toArray(returnList); return returnList; } public static obj_id[] getObjectsInInstanceByObjVar(obj_id baseObject, String obj_var) throws InterruptedException @@ -2406,24 +2125,17 @@ public class trial extends script.base_script } Vector allSpawns = new Vector(); allSpawns.setSize(0); - for (int i = 0; i < idList.length; i++) - { - obj_id[] thisVector = getObjectsInInstanceByObjVar(baseObject, idList[i]); - for (int q = 0; q < thisVector.length; q++) - { - allSpawns.add(thisVector[q]); - } + obj_id[] thisVector; + for (String anIdList : idList) { + thisVector = getObjectsInInstanceByObjVar(baseObject, anIdList); + Collections.addAll(allSpawns, thisVector); } - if (allSpawns == null || allSpawns.size() == 0) + if (allSpawns.size() == 0) { return null; } - obj_id[] _allSpawns = new obj_id[0]; - if (allSpawns != null) - { - _allSpawns = new obj_id[allSpawns.size()]; - allSpawns.toArray(_allSpawns); - } + obj_id[] _allSpawns = new obj_id[allSpawns.size()]; + allSpawns.toArray(_allSpawns); return _allSpawns; } public static void sendSequenceTrigger(String sequence_trigger) throws InterruptedException @@ -2438,14 +2150,9 @@ public class trial extends script.base_script dict.put("triggerName", sequence_trigger); messageTo(instance_id, "triggerFired", dict, 1.0f, false); } - public static boolean registerObjectWithSequencer(obj_id object) throws InterruptedException - { + public static boolean registerObjectWithSequencer(obj_id object) throws InterruptedException { obj_id instance_id = instance.getAreaInstanceController(object); - if (!isIdValid(instance_id)) - { - return false; - } - return registerObjectWithSequencer(instance_id, object); + return isIdValid(instance_id) && registerObjectWithSequencer(instance_id, object); } public static boolean registerObjectWithSequencer(obj_id sequencer, obj_id object) throws InterruptedException { @@ -2454,14 +2161,9 @@ public class trial extends script.base_script messageTo(sequencer, "registerObjectWithSequencer", dict, 0.0f, false); return true; } - public static boolean unregisterObjectWithSequencer(obj_id object) throws InterruptedException - { + public static boolean unregisterObjectWithSequencer(obj_id object) throws InterruptedException { obj_id instance_id = instance.getAreaInstanceController(object); - if (!isIdValid(instance_id)) - { - return false; - } - return unregisterObjectWithSequencer(instance_id, object); + return isIdValid(instance_id) && unregisterObjectWithSequencer(instance_id, object); } public static boolean unregisterObjectWithSequencer(obj_id sequencer, obj_id object) throws InterruptedException { @@ -2541,8 +2243,7 @@ public class trial extends script.base_script public static obj_id createSchedulerNPC(obj_id parent, obj_id patrolPoint, String npcName) throws InterruptedException { location loc = getLocation(parent); - obj_id npc = createSchedulerNPC(parent, patrolPoint, npcName, loc); - return npc; + return createSchedulerNPC(parent, patrolPoint, npcName, loc); } public static obj_id createSchedulerNPC(obj_id parent, obj_id patrolPoint, String npcName, location loc) throws InterruptedException { @@ -2619,7 +2320,7 @@ public class trial extends script.base_script { participantScriptVar = "gcw.imperial.participants"; } - if (participantScriptVar == null || participantScriptVar.length() < 1) + if (participantScriptVar.length() < 1) { CustomerServiceLog("gcw_city_invasion", "trial.addNonInstanceFactionParticipant: Player: " + who + " did not have the faction affiliation needed to be added to a participant list."); return false; @@ -2670,7 +2371,7 @@ public class trial extends script.base_script { participantScriptVar = "gcw.imperial.participants"; } - if (participantScriptVar == null || participantScriptVar.length() < 1) + if (participantScriptVar.length() < 1) { return false; } @@ -2685,7 +2386,7 @@ public class trial extends script.base_script } } utils.removeElement(sideParticipants, who); - if (sideParticipants.size() == 0) + if (sideParticipants == null || sideParticipants.size() == 0) { utils.removeScriptVar(parent, participantScriptVar); CustomerServiceLog("gcw_city_invasion", "trial.removeNonInstanceFactionParticipant: Player: " + who + " has been REMOVED as a valid participant of the GCW city invasion for city object: " + parent); @@ -2729,7 +2430,7 @@ public class trial extends script.base_script { participantScriptVar = "gcw.imperial.participants"; } - if (participantScriptVar == null || participantScriptVar.length() < 1) + if (participantScriptVar.length() < 1) { return false; } @@ -2738,18 +2439,15 @@ public class trial extends script.base_script if (utils.hasScriptVar(parent, participantScriptVar)) { sideParticipants = utils.getResizeableObjIdArrayScriptVar(parent, participantScriptVar); - if (sideParticipants != null && !utils.isElementInArray(sideParticipants, who)) + if (sideParticipants == null || !utils.isElementInArray(sideParticipants, who)) { return false; } - for (int i = 0; i < sideParticipants.size(); i++) - { - if (!isValidId(((obj_id)sideParticipants.get(i)))) - { + for (Object sideParticipant : sideParticipants) { + if (!isValidId(((obj_id) sideParticipant))) { continue; } - if (((obj_id)sideParticipants.get(i)) != who) - { + if (sideParticipant != who) { continue; } return true; @@ -2778,7 +2476,7 @@ public class trial extends script.base_script { participantScriptVar = "gcw.imperial.participants"; } - if (participantScriptVar == null || participantScriptVar.length() <= 0) + if (participantScriptVar.length() <= 0) { CustomerServiceLog("gcw_city_invasion", "trial.getNonInstanceFactionParticipants: Participant list not found. Returning NULL."); return null; @@ -2818,76 +2516,55 @@ public class trial extends script.base_script } int tokensOwed = price; boolean foundTokenHolderBox = false; - for (int i = 0; i < inventoryContents.length; i++) - { - if (!isIdValid(inventoryContents[i]) || !exists(inventoryContents[i])) - { + String itemName; + for (obj_id inventoryContent : inventoryContents) { + if (!isIdValid(inventoryContent) || !exists(inventoryContent)) { continue; } - String itemName = getStaticItemName(inventoryContents[i]); - if (itemName != null && !itemName.equals("")) - { - if (itemName.equals(tokenName)) - { - if (getCount(inventoryContents[i]) > 1) - { - if (getCount(inventoryContents[i]) > tokensOwed) - { - setCount(inventoryContents[i], (getCount(inventoryContents[i]) - tokensOwed)); + itemName = getStaticItemName(inventoryContent); + if (itemName != null && !itemName.equals("")) { + if (itemName.equals(tokenName)) { + if (getCount(inventoryContent) > 1) { + if (getCount(inventoryContent) > tokensOwed) { + setCount(inventoryContent, (getCount(inventoryContent) - tokensOwed)); tokensOwed = 0; + } else { + tokensOwed = tokensOwed - getCount(inventoryContent); + destroyObject(inventoryContent); } - else - { - tokensOwed = tokensOwed - getCount(inventoryContents[i]); - destroyObject(inventoryContents[i]); - } - } - else - { - destroyObject(inventoryContents[i]); + } else { + destroyObject(inventoryContent); tokensOwed--; } } - if (!foundTokenHolderBox && itemName.equals("item_heroic_token_box_01_01")) - { + if (!foundTokenHolderBox && itemName.equals("item_heroic_token_box_01_01")) { foundTokenHolderBox = true; int vTokens = 0; - if (hasObjVar(inventoryContents[i], "item.set.tokens_held")) - { - int[] virtualTokens = getIntArrayObjVar(inventoryContents[i], "item.set.tokens_held"); + if (hasObjVar(inventoryContent, "item.set.tokens_held")) { + int[] virtualTokens = getIntArrayObjVar(inventoryContent, "item.set.tokens_held"); int t = -1; - for (int k = 0; k < HEROIC_TOKENS.length; k++) - { - if (HEROIC_TOKENS[k].equals(tokenName)) - { + for (int k = 0; k < HEROIC_TOKENS.length; k++) { + if (HEROIC_TOKENS[k].equals(tokenName)) { t = k; vTokens = virtualTokens[t]; } } - if (t > -1) - { - if (vTokens > tokensOwed) - { + if (t > -1) { + if (vTokens > tokensOwed) { vTokens = vTokens - tokensOwed; virtualTokens[t] = vTokens; tokensOwed = 0; - } - else - { + } else { tokensOwed = tokensOwed - vTokens; virtualTokens[t] = 0; } - setObjVar(inventoryContents[i], "item.set.tokens_held", virtualTokens); + setObjVar(inventoryContent, "item.set.tokens_held", virtualTokens); } } } } } - if (tokensOwed == 0) - { - return true; - } - return false; + return tokensOwed == 0; } public static int getSpaceDutyTokenPrice(int level) throws InterruptedException { @@ -2908,38 +2585,28 @@ public class trial extends script.base_script return 0; } boolean foundTokenHolderBox = false; - for (int i = 0; i < inventoryContents.length; i++) - { - if (!isIdValid(inventoryContents[i]) || !exists(inventoryContents[i])) - { + String itemName; + for (obj_id inventoryContent : inventoryContents) { + if (!isIdValid(inventoryContent) || !exists(inventoryContent)) { continue; } - String itemName = getStaticItemName(inventoryContents[i]); - if (itemName != null && !itemName.equals("")) - { - if (itemName.equals(token)) - { - if (getCount(inventoryContents[i]) > 1) - { - tokenCount = tokenCount + getCount(inventoryContents[i]); - } - else - { + itemName = getStaticItemName(inventoryContent); + if (itemName != null && !itemName.equals("")) { + if (itemName.equals(token)) { + if (getCount(inventoryContent) > 1) { + tokenCount = tokenCount + getCount(inventoryContent); + } else { tokenCount++; } } - if (!foundTokenHolderBox && itemName.equals("item_heroic_token_box_01_01")) - { + if (!foundTokenHolderBox && itemName.equals("item_heroic_token_box_01_01")) { foundTokenHolderBox = true; - trial.verifyBox(inventoryContents[i]); + trial.verifyBox(inventoryContent); int t = 0; - if (hasObjVar(inventoryContents[i], "item.set.tokens_held")) - { - int[] virtualTokenArray = getIntArrayObjVar(inventoryContents[i], "item.set.tokens_held"); - for (int k = 0; k < trial.HEROIC_TOKENS.length; k++) - { - if (trial.HEROIC_TOKENS[k].equals(token)) - { + if (hasObjVar(inventoryContent, "item.set.tokens_held")) { + int[] virtualTokenArray = getIntArrayObjVar(inventoryContent, "item.set.tokens_held"); + for (int k = 0; k < trial.HEROIC_TOKENS.length; k++) { + if (trial.HEROIC_TOKENS[k].equals(token)) { t = k; } } diff --git a/sku.0/sys.server/compiled/game/script/library/turnstile.java b/sku.0/sys.server/compiled/game/script/library/turnstile.java old mode 100644 new mode 100755 index c0ce4a686..b0b679657 --- a/sku.0/sys.server/compiled/game/script/library/turnstile.java +++ b/sku.0/sys.server/compiled/game/script/library/turnstile.java @@ -1,16 +1,11 @@ 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.dictionary; +import script.obj_id; +import script.prose_package; +import script.string_id; -import script.library.player_structure; -import script.library.utils; -import script.library.xp; +import java.util.Vector; public class turnstile extends script.base_script { @@ -54,11 +49,9 @@ public class turnstile extends script.base_script obj_id[] contents = player_structure.getObjectsInBuilding(building); if (contents != null) { - for (int i = 0; i < contents.length; i++) - { - if (hasScript(contents[i], "terminal.vendor")) - { - setEntranceCharge(contents[i], fee); + for (obj_id content : contents) { + if (hasScript(content, "terminal.vendor")) { + setEntranceCharge(content, fee); } } } @@ -76,7 +69,7 @@ public class turnstile extends script.base_script } else { - prose_package pp = prose.getPackage(SID_WAIT_TURNSTILE, (int)(((removeTime + 900 - curTime) / 60) + 1)); + prose_package pp = prose.getPackage(SID_WAIT_TURNSTILE, ((removeTime + 900 - curTime) / 60) + 1); sendSystemMessageProse(player, pp); return false; } @@ -107,13 +100,8 @@ public class turnstile extends script.base_script } return getIntObjVar(building, VAR_TURNSTILE_TIME); } - public static boolean hasTurnstile(obj_id building) throws InterruptedException - { - if (building == null) - { - return false; - } - return hasObjVar(building, VAR_TURNSTILE_BASE); + public static boolean hasTurnstile(obj_id building) throws InterruptedException { + return building != null && hasObjVar(building, VAR_TURNSTILE_BASE); } public static boolean removeTurnstile(obj_id building) throws InterruptedException { @@ -130,11 +118,9 @@ public class turnstile extends script.base_script obj_id[] contents = player_structure.getObjectsInBuilding(building); if (contents != null) { - for (int i = 0; i < contents.length; i++) - { - if (hasScript(contents[i], "terminal.vendor")) - { - setEntranceCharge(contents[i], 0); + for (obj_id content : contents) { + if (hasScript(content, "terminal.vendor")) { + setEntranceCharge(content, 0); } } } @@ -229,11 +215,7 @@ public class turnstile extends script.base_script } obj_id[] patrons = getObjIdArrayObjVar(building, VAR_TURNSTILE_PATRON_IDS); int arrayPosition = utils.getElementPositionInArray(patrons, player); - if (arrayPosition == -1) - { - return false; - } - return true; + return arrayPosition != -1; } public static boolean hasExpired(obj_id building, obj_id player) throws InterruptedException { @@ -252,14 +234,7 @@ public class turnstile extends script.base_script { return false; } - if (timestamps[arrayPosition] < getGameTime()) - { - return true; - } - else - { - return false; - } + return timestamps[arrayPosition] < getGameTime(); } public static boolean cleanupExpiredPatrons(obj_id building) throws InterruptedException { @@ -291,9 +266,8 @@ public class turnstile extends script.base_script expired = utils.addElement(expired, patrons[i]); } } - for (int i = 0; i < expired.size(); i++) - { - removePatron(building, ((obj_id)expired.get(i))); + for (Object anExpired : expired) { + removePatron(building, ((obj_id) anExpired)); } return true; } diff --git a/sku.0/sys.server/compiled/game/script/library/turret.java b/sku.0/sys.server/compiled/game/script/library/turret.java old mode 100644 new mode 100755 index 6df7be84f..11c1d673b --- a/sku.0/sys.server/compiled/game/script/library/turret.java +++ b/sku.0/sys.server/compiled/game/script/library/turret.java @@ -1,16 +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.location; +import script.obj_id; +import script.region; -import script.library.utils; -import script.library.factions; -import script.library.battlefield; +import java.util.Vector; public class turret extends script.base_script { @@ -53,17 +47,8 @@ public class turret extends script.base_script } removeObjVar(turret, VAR_IS_ACTIVE); } - public static boolean isActive(obj_id turret) throws InterruptedException - { - if (!isIdValid(turret)) - { - return false; - } - if (hasObjVar(turret, VAR_IS_ACTIVE)) - { - return true; - } - return false; + public static boolean isActive(obj_id turret) throws InterruptedException { + return isIdValid(turret) && hasObjVar(turret, VAR_IS_ACTIVE); } public static void engageTarget(obj_id turret, obj_id target) throws InterruptedException { @@ -99,70 +84,44 @@ public class turret extends script.base_script { return true; } - if (utils.hasScriptVar(turret, SCRIPTVAR_ENGAGED)) - { - return true; - } - return false; + return utils.hasScriptVar(turret, SCRIPTVAR_ENGAGED); } - public static boolean createWeapon(obj_id turret) throws InterruptedException - { - if (!isIdValid(turret)) - { + public static boolean createWeapon(obj_id turret) throws InterruptedException { + if (!isIdValid(turret)) { return false; } - if (hasObjVar(turret, "objWeapon")) - { + if (hasObjVar(turret, "objWeapon")) { return false; } String strWeaponTemplate; - if (hasObjVar(turret, "strWeaponTemplate")) - { + if (hasObjVar(turret, "strWeaponTemplate")) { strWeaponTemplate = getStringObjVar(turret, "strWeaponTemplate"); - } - else - { + } else { strWeaponTemplate = "object/weapon/ranged/turret/turret_block_large.iff"; } obj_id objWeapon = createObject(strWeaponTemplate, turret, ""); - if (!isIdValid(objWeapon)) - { - return false; - } - return setObjVar(turret, "objWeapon", objWeapon); + return isIdValid(objWeapon) && setObjVar(turret, "objWeapon", objWeapon); } - public static boolean isValidTargetGeneric(obj_id turret, obj_id target) throws InterruptedException - { - if (!isIdValid(turret) || !isIdValid(target)) - { + public static boolean isValidTargetGeneric(obj_id turret, obj_id target) throws InterruptedException { + if (!isIdValid(turret) || !isIdValid(target)) { return false; } - if (target == turret) - { + if (target == turret) { return false; } location there = getLocation(target); location here = getLocation(turret); - if (!isIdValid(here.cell)) - { - if (there == null || isIdValid(there.cell)) - { + if (!isIdValid(here.cell)) { + if (there == null || isIdValid(there.cell)) { return false; } - } - else - { - if (there.cell != here.cell) - { + } else { + if (there.cell != here.cell) { return false; } } float dist = getDistance(getLocation(turret), getLocation(target)); - if (dist > TURRET_RANGE + 1) - { - return false; - } - return canGenericTurretAttackTarget(target); + return dist <= TURRET_RANGE + 1 && canGenericTurretAttackTarget(target); } public static boolean isGenericTurret(obj_id turret) throws InterruptedException { @@ -184,11 +143,7 @@ public class turret extends script.base_script return false; } String objvar = getStringObjVar(self, OBJVAR_CAN_ATTACK); - if (hasObjVar(target, objvar) || objvar.equals("all") || (objvar.equals("allPlayers") && isPlayer(target))) - { - return true; - } - return false; + return hasObjVar(target, objvar) || objvar.equals("all") || (objvar.equals("allPlayers") && isPlayer(target)); } public static boolean isValidTarget(obj_id turret, obj_id target) throws InterruptedException { @@ -219,11 +174,7 @@ public class turret extends script.base_script region btlField = battlefield.getBattlefield(turret); if (btlField != null) { - if (pvpIsEnemy(turret, target)) - { - return true; - } - return false; + return pvpIsEnemy(turret, target); } float dist = getDistance(getLocation(turret), getLocation(target)); if (dist > TURRET_RANGE + 1) @@ -298,11 +249,9 @@ public class turret extends script.base_script return; } Vector targets = utils.getResizeableObjIdBatchScriptVar(turret, SCRIPTVAR_TARGETS); - for (int i = 0; i < target.length; i++) - { - if (isValidTarget(turret, target[i]) && !utils.isElementInArray(targets, target)) - { - targets = utils.addElement(targets, target[i]); + for (obj_id aTarget : target) { + if (isValidTarget(turret, aTarget) && !utils.isElementInArray(targets, target)) { + targets = utils.addElement(targets, aTarget); } } if ((targets != null) && (targets.size() > 0)) diff --git a/sku.0/sys.server/compiled/game/script/library/uberlair.java b/sku.0/sys.server/compiled/game/script/library/uberlair.java old mode 100644 new mode 100755 index 01b5a7ddb..b376d5f97 --- a/sku.0/sys.server/compiled/game/script/library/uberlair.java +++ b/sku.0/sys.server/compiled/game/script/library/uberlair.java @@ -1,14 +1,8 @@ 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.library.poi; +import script.dictionary; +import script.location; +import script.obj_id; public class uberlair extends script.base_script { @@ -23,19 +17,20 @@ public class uberlair extends script.base_script String[] strLargeMobs = dataTableGetStringColumnNoDefaults(lairDatatable, "strLargeMobs"); String[] strLargeMobScript = dataTableGetStringColumnNoDefaults(lairDatatable, "strLargeMobScripts"); LOG("uberlairs", "objLargeMobSpawners length is " + objLargeMobSpawners.length); - for (int intI = 0; intI < objLargeMobSpawners.length; intI++) - { - if (strLargeMobs.length == 0) - { + String strMobToSpawn; + location locSpawnLocation; + obj_id objMob; + + for (obj_id objLargeMobSpawner : objLargeMobSpawners) { + if (strLargeMobs.length == 0) { LOG("DESIGNER_FATAL", lairType + " has large mob spawners but no large mobs!"); break; } - String strMobToSpawn = strLargeMobs[rand(0, strLargeMobs.length - 1)]; - location locSpawnLocation = getLocation(objLargeMobSpawners[intI]); - obj_id objMob = poi.createObject(poiBaseObject, strMobToSpawn, locSpawnLocation); + strMobToSpawn = strLargeMobs[rand(0, strLargeMobs.length - 1)]; + locSpawnLocation = getLocation(objLargeMobSpawner); + objMob = poi.createObject(poiBaseObject, strMobToSpawn, locSpawnLocation); ai_lib.setDefaultCalmBehavior(objMob, ai_lib.BEHAVIOR_SENTINEL); - if (strLargeMobScript.length > 0) - { + if (strLargeMobScript.length > 0) { attachScript(objMob, strLargeMobScript[0]); setObjVar(objMob, "uberlair.strScript", strLargeMobScript[0]); } @@ -43,7 +38,6 @@ public class uberlair extends script.base_script setObjVar(objMob, "uberlair.locSpawnLocation", locSpawnLocation); setObjVar(objMob, "uberlair.objParent", poiBaseObject); } - return; } public static void spawnNpcLairMobiles(obj_id poiBaseObject, obj_id[] objMobSpawners) throws InterruptedException { @@ -65,6 +59,9 @@ public class uberlair extends script.base_script setObjVar(poiBaseObject, "intTotalMobs", intTotalMobs); int intIndex = getIntObjVar(poiBaseObject, "intSpawnIndex"); int intCounter = 0; + String strMobToSpawn; + location locSpawnLocation; + obj_id objMob; for (int intI = intIndex; intI < intMobCount; intI++) { if (intCounter > SPAWNS_PER_EVENT) @@ -78,11 +75,11 @@ public class uberlair extends script.base_script LOG("DESIGNER_FATAL", lairType + " has large mob spawners but no large mobs!"); break; } - String strMobToSpawn = strMobs[rand(0, strMobs.length - 1)]; - location locSpawnLocation = getLocation(objMobSpawners[rand(0, objMobSpawners.length - 1)]); + strMobToSpawn = strMobs[rand(0, strMobs.length - 1)]; + locSpawnLocation = getLocation(objMobSpawners[rand(0, objMobSpawners.length - 1)]); locSpawnLocation.x = locSpawnLocation.x + rand(-2, 2); locSpawnLocation.z = locSpawnLocation.z + rand(-2, 2); - obj_id objMob = poi.createObject(poiBaseObject, strMobToSpawn, locSpawnLocation); + objMob = poi.createObject(poiBaseObject, strMobToSpawn, locSpawnLocation); ai_lib.setDefaultCalmBehavior(objMob, ai_lib.BEHAVIOR_SENTINEL); if (strMobScript.length > 0) { @@ -97,7 +94,6 @@ public class uberlair extends script.base_script setObjVar(poiBaseObject, "intSpawnCount", intMobCount); removeObjVar(poiBaseObject, "intSpawnIndex"); messageTo(poiBaseObject, "spawnFormations", null, 3, false); - return; } public static void respawnMobile(obj_id poiBaseObject, location locSpawnLocation, String strMobToSpawn, String strScript) throws InterruptedException { @@ -115,7 +111,6 @@ public class uberlair extends script.base_script attachScript(objMob, strScript); } setObjVar(poiBaseObject, "intSpawnCount", intCurrentSpawnCount); - return; } public static void createFormations(obj_id objParent) throws InterruptedException { @@ -125,12 +120,17 @@ public class uberlair extends script.base_script LOG("uber", "lairDatatable is " + lairDatatable); String[] strFormations = dataTableGetStringColumnNoDefaults(lairDatatable, "strFormations"); location[] locOffsets = getPatrolOffsets(getLocation(objParent), 50); + String strFormationDataTable; + String[] strMobs; + String[] strLeader; + obj_id objLeader; + dictionary dctParams; for (int intI = 0; intI < strFormations.length; intI++) { - String strFormationDataTable = "datatables/uberlair/formations/" + strFormations[intI] + ".iff"; + strFormationDataTable = "datatables/uberlair/formations/" + strFormations[intI] + ".iff"; LOG("uber", "formation datatable is " + strFormationDataTable); - String[] strMobs = dataTableGetStringColumnNoDefaults(strFormationDataTable, "strMobs"); - String[] strLeader = dataTableGetStringColumnNoDefaults(strFormationDataTable, "strLeader"); + strMobs = dataTableGetStringColumnNoDefaults(strFormationDataTable, "strMobs"); + strLeader = dataTableGetStringColumnNoDefaults(strFormationDataTable, "strLeader"); if (strMobs.length == 0) { LOG("DESIGNER_FATAL", "mobs in a formation file of " + strFormationDataTable + " is blank"); @@ -141,12 +141,12 @@ public class uberlair extends script.base_script LOG("DESIGNER_FATAL", "leader in a formation file of " + strFormationDataTable + " is blank"); return; } - obj_id objLeader = poi.createObject(objParent, strLeader[0], locOffsets[intI]); + objLeader = poi.createObject(objParent, strLeader[0], locOffsets[intI]); LOG("uber", "created leader at " + locOffsets[intI]); if (objLeader != null) { attachScript(objLeader, "systems.npc_lair.uber_lair_formation_leader"); - dictionary dctParams = new dictionary(); + dctParams = new dictionary(); dctParams.put("locWaypoints", locOffsets); dctParams.put("strFormationMembers", strMobs); dctParams.put("intOffset", intI); @@ -155,7 +155,6 @@ public class uberlair extends script.base_script messageTo(objLeader, "createFormation", dctParams, 3, false); } } - return; } public static location[] getPatrolOffsets(location locParentLocation, float fltDistance) throws InterruptedException { diff --git a/sku.0/sys.server/compiled/game/script/library/utils.java b/sku.0/sys.server/compiled/game/script/library/utils.java index 4ef39e954..9a6454e1a 100755 --- a/sku.0/sys.server/compiled/game/script/library/utils.java +++ b/sku.0/sys.server/compiled/game/script/library/utils.java @@ -872,7 +872,7 @@ public class utils extends script.base_script } public static Vector addElement(Vector array, boolean element) throws InterruptedException { - return addElement(array, new Boolean(element)); + return addElement(array, Boolean.valueOf(element)); } public static Vector addElement(Vector array, int element) throws InterruptedException { diff --git a/sku.0/sys.server/compiled/game/script/library/vehicle.java b/sku.0/sys.server/compiled/game/script/library/vehicle.java old mode 100644 new mode 100755 index d4a1c869b..7d225611b --- a/sku.0/sys.server/compiled/game/script/library/vehicle.java +++ b/sku.0/sys.server/compiled/game/script/library/vehicle.java @@ -1,24 +1,6 @@ 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.library.callable; -import script.library.colors; -import script.library.money; -import script.library.pet_lib; -import script.library.hue; -import script.library.space_transition; -import script.library.group; -import script.library.ai_lib; -import script.library.space_dungeon; -import script.library.buff; -import script.library.instance; public class vehicle extends script.base_script { @@ -127,8 +109,7 @@ public class vehicle extends script.base_script String vi_name = s_varInfoNames[var_index]; float vi_conversion = s_varInfoConversions[var_index]; int ivalue = getRangedIntCustomVarValue(vehicle, vi_name); - float value = ((float)ivalue) / vi_conversion; - return value; + return ((float)ivalue) / vi_conversion; } public static void setMinimumSpeed(obj_id vehicle, float value) throws InterruptedException { @@ -249,61 +230,22 @@ public class vehicle extends script.base_script } public static boolean getStrafe(obj_id vehicle) throws InterruptedException { - float value = getValue(vehicle, VAR_STRAFE); - return value > 0.0f ? true : false; + return getValue(vehicle, VAR_STRAFE) > 0.0f; } - public static boolean isRidingVehicle(obj_id objPlayer) throws InterruptedException - { - if (!isMob(objPlayer)) - { + public static boolean isRidingVehicle(obj_id objPlayer) throws InterruptedException { + if (!isMob(objPlayer)) { return false; } obj_id objMount = getMountId(objPlayer); - if (isIdValid(objMount)) - { - if (hasScript(objMount, "systems.vehicle_system.vehicle_base") || isBattlefieldVehicle(objMount)) - { - return true; - } - else - { - return false; - } - } - else - { - return false; - } + return isIdValid(objMount) && (hasScript(objMount, "systems.vehicle_system.vehicle_base") || isBattlefieldVehicle(objMount)); } - public static boolean isRidingBattlefieldVehicle(obj_id objPlayer) throws InterruptedException - { + public static boolean isRidingBattlefieldVehicle(obj_id objPlayer) throws InterruptedException { obj_id objMount = getMountId(objPlayer); - if (isIdValid(objMount)) - { - if (isBattlefieldVehicle(objMount)) - { - return true; - } - else - { - return false; - } - } - else - { - return false; - } + return isIdValid(objMount) && isBattlefieldVehicle(objMount); } public static boolean isDriveableVehicle(obj_id objThing) throws InterruptedException { - if (hasScript(objThing, "systems.vehicle_system.vehicle_base")) - { - return true; - } - else - { - return false; - } + return hasScript(objThing, "systems.vehicle_system.vehicle_base"); } public static boolean isVehicle(obj_id obj) throws InterruptedException { @@ -343,7 +285,6 @@ public class vehicle extends script.base_script params.put("type", MOD_TYPE_MAX_SPEED); messageTo(vehicle, "revertVehicleMod", params, duration, false); setMaximumSpeed(vehicle, currentMaxSpeed * factor); - return; } public static String getVehicleReference(obj_id controlDevice) throws InterruptedException { @@ -472,7 +413,7 @@ public class vehicle extends script.base_script { return; } - int decayAmt = 0; + int decayAmt; if (utils.hasScriptVar(vehicle, "decay.stamp")) { int stamp = utils.getIntScriptVar(vehicle, "decay.stamp"); @@ -568,18 +509,9 @@ public class vehicle extends script.base_script } return false; } - public static boolean canQuickUnpack(obj_id master) throws InterruptedException - { + public static boolean canQuickUnpack(obj_id master) throws InterruptedException { location yourLoc = getLocation(master); - if (isIdValid(yourLoc.cell)) - { - return false; - } - if (isInRestrictedScene(master)) - { - return false; - } - return true; + return !isIdValid(yourLoc.cell) && !isInRestrictedScene(master); } public static boolean isInValidCallState(obj_id player) throws InterruptedException { @@ -645,7 +577,7 @@ public class vehicle extends script.base_script obj_id objVehicle = callable.getCallable(master, callable.CALLABLE_TYPE_RIDEABLE); if (isIdValid(objVehicle)) { - if (!objVehicle.isLoaded() == false) + if (objVehicle.isLoaded()) { messageTo(objVehicle, "handlePackRequest", null, 0, false); } @@ -698,7 +630,6 @@ public class vehicle extends script.base_script colorIdx = getIntObjVar(vehicleControlDevice, "creature_attribs.hue"); } hue.setColor(vehicle, hue.INDEX_1, colorIdx); - return; } public static void saveVehicleInfo(obj_id vehicleControlDevice, obj_id vehicle) throws InterruptedException { @@ -720,16 +651,13 @@ public class vehicle extends script.base_script ranged_int_custom_var[] ri = hue.getPalcolorVars(vehicle); if (ri != null && ri.length > 0) { - boolean wasUpdated = false; - for (int i = 0; i < ri.length; i++) - { - int val = ri[i].getValue(); - if (val > -1) - { - String varpath = VAR_PALVAR_VARS + "." + ri[i].getVarName(); + String varpath; + for (ranged_int_custom_var aRi : ri) { + int val = aRi.getValue(); + if (val > -1) { + varpath = VAR_PALVAR_VARS + "." + aRi.getVarName(); int cur = getIntObjVar(vehicleControlDevice, varpath); - if (cur != val) - { + if (cur != val) { setObjVar(vehicleControlDevice, varpath, val); } } @@ -748,12 +676,12 @@ public class vehicle extends script.base_script if (ovl != null) { int numItem = ovl.getNumItems(); + obj_var ov; + for (int i = 0; i < numItem; i++) { - obj_var ov = ovl.getObjVar(i); - String var = ov.getName(); - int idx = ov.getIntData(); - hue.setColor(vehicle, var, idx); + ov = ovl.getObjVar(i); + hue.setColor(vehicle, ov.getName(), ov.getIntData()); } } } @@ -872,7 +800,6 @@ public class vehicle extends script.base_script int strafe = dataTableGetInt(datatable, row, "strafe"); setStrafe(vehicle, strafe != 0); } - return; } public static boolean mountPermissionCheck(obj_id vehicle, obj_id rider, boolean verbose) throws InterruptedException { @@ -953,11 +880,7 @@ public class vehicle extends script.base_script return false; } String name = getVehicleTemplate(vehicleControlDevice); - if (isJetPackTemplate(name)) - { - return true; - } - return false; + return isJetPackTemplate(name); } public static boolean isJetPackVehicle(obj_id vehicle) throws InterruptedException { @@ -966,11 +889,7 @@ public class vehicle extends script.base_script return false; } String name = getTemplateName(vehicle); - if (isJetPackTemplate(name)) - { - return true; - } - return false; + return isJetPackTemplate(name); } public static boolean isJetPackTemplate(String template) throws InterruptedException { @@ -978,19 +897,15 @@ public class vehicle extends script.base_script { return false; } - if (template.equals("object/mobile/vehicle/jetpack.iff")) + else if (template.equals("object/mobile/vehicle/jetpack.iff")) { return true; } - if (template.equals("object/mobile/vehicle/tcg_merr_sonn_jt12_jetpack.iff")) + else if (template.equals("object/mobile/vehicle/tcg_merr_sonn_jt12_jetpack.iff")) { return true; } - if (template.equals("object/mobile/vehicle/tcg_hk47_jetpack.iff")) - { - return true; - } - return false; + return template.equals("object/mobile/vehicle/tcg_hk47_jetpack.iff"); } public static void applyVehicleBuffs(obj_id player, obj_id vehicle) throws InterruptedException { @@ -1000,9 +915,8 @@ public class vehicle extends script.base_script LOG("mount", template + " bailed out because template is bad"); return; } - dictionary vehicleData = new dictionary(); - vehicleData = dataTableGetRow(VEHICLE_STAT_TABLE, template); - if (vehicleData == null || vehicleData.equals("")) + dictionary vehicleData = dataTableGetRow(VEHICLE_STAT_TABLE, template); + if (vehicleData == null || vehicleData.size() == 0) { LOG("mount", vehicleData + " bailed out because row in datatable is bad"); return; @@ -1029,7 +943,6 @@ public class vehicle extends script.base_script { buff.applyBuff(vehicle, vehicleBuffName); } - return; } public static boolean canRepairDisabledVehicle(obj_id controlDevice) throws InterruptedException { @@ -1038,11 +951,7 @@ public class vehicle extends script.base_script { return false; } - if (dataTableGetInt(create.VEHICLE_TABLE, ref, "CAN_REPAIR_DISABLED") == 1) - { - return true; - } - return false; + return dataTableGetInt(create.VEHICLE_TABLE, ref, "CAN_REPAIR_DISABLED") == 1; } public static boolean checkForMountAndDismountPlayer(obj_id player) throws InterruptedException { @@ -1124,10 +1033,8 @@ public class vehicle extends script.base_script if (datapadContents != null) { int count = 0; - for (int i = 0; i < datapadContents.length; ++i) - { - if (isIdValid(datapadContents[i]) && getGameObjectType(datapadContents[i]) == GOT_data_vehicle_control_device) - { + for (obj_id datapadContent : datapadContents) { + if (isIdValid(datapadContent) && getGameObjectType(datapadContent) == GOT_data_vehicle_control_device) { ++count; } } @@ -1136,10 +1043,8 @@ public class vehicle extends script.base_script obj_id[] hangarContents = getContents(playerHangarSlot); if (hangarContents != null && hangarContents.length > 0) { - for (int q = 0; q < hangarContents.length; ++q) - { - if (isIdValid(hangarContents[q]) && getGameObjectType(hangarContents[q]) == GOT_data_vehicle_control_device) - { + for (obj_id hangarContent : hangarContents) { + if (isIdValid(hangarContent) && getGameObjectType(hangarContent) == GOT_data_vehicle_control_device) { ++count; } } @@ -1149,11 +1054,9 @@ public class vehicle extends script.base_script { obj_id[] vehicleControlDevices = new obj_id[count]; count = 0; - for (int j = 0; j < datapadContents.length; ++j) - { - if (isIdValid(datapadContents[j]) && getGameObjectType(datapadContents[j]) == GOT_data_vehicle_control_device) - { - vehicleControlDevices[count++] = datapadContents[j]; + for (obj_id datapadContent : datapadContents) { + if (isIdValid(datapadContent) && getGameObjectType(datapadContent) == GOT_data_vehicle_control_device) { + vehicleControlDevices[count++] = datapadContent; } } if (includeHangerSlot && isIdValid(playerHangarSlot)) @@ -1161,11 +1064,9 @@ public class vehicle extends script.base_script obj_id[] hangarContents = getContents(playerHangarSlot); if (hangarContents != null && hangarContents.length > 0) { - for (int k = 0; k < hangarContents.length; ++k) - { - if (isIdValid(hangarContents[k]) && getGameObjectType(hangarContents[k]) == GOT_data_vehicle_control_device) - { - vehicleControlDevices[count++] = hangarContents[k]; + for (obj_id hangarContent : hangarContents) { + if (isIdValid(hangarContent) && getGameObjectType(hangarContent) == GOT_data_vehicle_control_device) { + vehicleControlDevices[count++] = hangarContent; } } } @@ -1185,10 +1086,9 @@ public class vehicle extends script.base_script if (hangarContents != null && hangarContents.length > 0) { int count = 0; - for (int q = 0; q < hangarContents.length; ++q) - { - if (isIdValid(hangarContents[q]) && getGameObjectType(hangarContents[q]) == GOT_data_vehicle_control_device) - { + + for (obj_id hangarContent : hangarContents) { + if (isIdValid(hangarContent) && getGameObjectType(hangarContent) == GOT_data_vehicle_control_device) { ++count; } } @@ -1196,11 +1096,9 @@ public class vehicle extends script.base_script { obj_id[] vehicleHangarSlotControlDevices = new obj_id[count]; count = 0; - for (int k = 0; k < hangarContents.length; ++k) - { - if (isIdValid(hangarContents[k]) && getGameObjectType(hangarContents[k]) == GOT_data_vehicle_control_device) - { - vehicleHangarSlotControlDevices[count++] = hangarContents[k]; + for (obj_id hangarContent : hangarContents) { + if (isIdValid(hangarContent) && getGameObjectType(hangarContent) == GOT_data_vehicle_control_device) { + vehicleHangarSlotControlDevices[count++] = hangarContent; } } return vehicleHangarSlotControlDevices; diff --git a/sku.0/sys.server/compiled/game/script/library/vendor_lib.java b/sku.0/sys.server/compiled/game/script/library/vendor_lib.java old mode 100644 new mode 100755 index cfd4d93ab..93fc4a4a0 --- a/sku.0/sys.server/compiled/game/script/library/vendor_lib.java +++ b/sku.0/sys.server/compiled/game/script/library/vendor_lib.java @@ -1,17 +1,11 @@ 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.dictionary; +import script.location; +import script.obj_id; +import script.string_id; import java.util.Vector; -import script.library.create; -import script.library.player_structure; -import script.library.static_item; public class vendor_lib extends script.base_script { @@ -291,8 +285,8 @@ public class vendor_lib extends script.base_script } public static void finalizePackUp(obj_id player, obj_id vendor, obj_id packer, boolean isAbandoned) throws InterruptedException { - obj_id vcd = null; - obj_id datapad = null; + obj_id vcd; + obj_id datapad; final boolean isLoadedAndAuthoritative = player.isLoaded() && player.isAuthoritative(); CustomerServiceLog("vendorpackup", "Player " + getPlayerName(packer) + " (" + packer + ") is attempting to pack vendor (" + vendor + ",abandoned=" + isAbandoned + ") owned by player " + getPlayerName(player) + " (" + player + ")"); if (isLoadedAndAuthoritative) @@ -336,7 +330,6 @@ public class vendor_lib extends script.base_script fixLoadWith(vendor, player, maxDepth); } CustomerServiceLog("vendorpackup", "Player " + getPlayerName(packer) + " (" + packer + ") packed vendor (" + vendor + ",abandoned=" + isAbandoned + ") owned by player " + getPlayerName(player) + " (" + player + ") into device (" + vcd + ")"); - return; } public static boolean isVendorPackUpEnabled() throws InterruptedException { @@ -383,11 +376,9 @@ public class vendor_lib extends script.base_script blog("vendor_lib.getAllGreeterDatatableColumnNames: prevalidation completed"); Vector greeterColNames = new Vector(); greeterColNames.setSize(0); - for (int i = 0; i < preParsedColListLength; i++) - { - if (preParsedColList[i].startsWith("greeter")) - { - greeterColNames = utils.addElement(greeterColNames, preParsedColList[i]); + for (String aPreParsedColList : preParsedColList) { + if (aPreParsedColList.startsWith("greeter")) { + greeterColNames = utils.addElement(greeterColNames, aPreParsedColList); } } if (greeterColNames.size() <= 0) @@ -396,11 +387,8 @@ public class vendor_lib extends script.base_script } blog("vendor_lib.getAllGreeterDatatableColumnNames: greeter col name list being returned."); String[] _greeterColNames = new String[0]; - if (greeterColNames != null) - { - _greeterColNames = new String[greeterColNames.size()]; - greeterColNames.toArray(_greeterColNames); - } + _greeterColNames = new String[greeterColNames.size()]; + greeterColNames.toArray(_greeterColNames); return _greeterColNames; } public static boolean buildNpcInPlayerStructure(obj_id controller, obj_id player, String npcType, boolean newGreeter) throws InterruptedException @@ -454,7 +442,7 @@ public class vendor_lib extends script.base_script blog("vendor_lib.buildNpcInPlayerStructure: Unable to create a nonvendor: validateNpcPlacementInStructure said NO."); return false; } - location loc = null; + location loc; if (where == null) { loc = getLocation(owner); @@ -562,11 +550,7 @@ public class vendor_lib extends script.base_script { return true; } - if (player_structure.isAdmin(structure, player)) - { - return true; - } - return false; + return player_structure.isAdmin(structure, player); } public static boolean validateNonVendorInStructure(obj_id nonVendor) throws InterruptedException { @@ -579,11 +563,7 @@ public class vendor_lib extends script.base_script { return false; } - if (!player_structure.isPlayerStructure(structure) || player_structure.isCivic(structure)) - { - return false; - } - return true; + return !(!player_structure.isPlayerStructure(structure) || player_structure.isCivic(structure)); } public static String getGreeterNonVendorCreatureType(obj_id object, String greeterOrNonVendorType) throws InterruptedException { @@ -609,7 +589,7 @@ public class vendor_lib extends script.base_script blog("vendor_lib.getGreeterNonVendorCreatureType creatureTypes received"); for (int i = 0; i < creatureTypes.length; i++) { - if (greeterOrNonVendorType.indexOf(creatureTypes[i]) == -1) + if (!greeterOrNonVendorType.contains(creatureTypes[i])) { blog("vendor_lib.getGreeterNonVendorCreatureType greeterOrNonVendorType: " + greeterOrNonVendorType + " " + creatureTypes[i]); continue; @@ -630,11 +610,7 @@ public class vendor_lib extends script.base_script { return false; } - if (getBooleanObjVar(object, vendor_lib.SPECIAL_VENDOR_IDENTIFIER) != true) - { - return false; - } - return true; + return getBooleanObjVar(object, vendor_lib.SPECIAL_VENDOR_IDENTIFIER); } public static obj_id setObjectOwner(obj_id controller) throws InterruptedException { @@ -686,11 +662,7 @@ public class vendor_lib extends script.base_script { return false; } - if (!player_structure.isPlayerStructure(structure)) - { - return false; - } - return true; + return player_structure.isPlayerStructure(structure); } public static boolean isObjectInSameCellAsController(obj_id controller, obj_id object) throws InterruptedException { @@ -721,11 +693,7 @@ public class vendor_lib extends script.base_script { return false; } - if (controllerLoc.cell != objLocation.cell) - { - return false; - } - return true; + return controllerLoc.cell == objLocation.cell; } public static boolean recreateObject(obj_id controller, obj_id player) throws InterruptedException { @@ -753,7 +721,7 @@ public class vendor_lib extends script.base_script { npcType = GREETER_VAR_PREFIX; } - if (npcType == null || npcType.equals("")) + if (npcType.equals("")) { return false; } @@ -792,7 +760,7 @@ public class vendor_lib extends script.base_script { npcType = GREETER_VAR_PREFIX; } - if (npcType == null || npcType.equals("")) + if (npcType.equals("")) { return false; } @@ -819,11 +787,7 @@ public class vendor_lib extends script.base_script return false; } location here = getLocation(controller); - if (getContainedBy(controller) == here.cell) - { - return true; - } - return false; + return getContainedBy(controller) == here.cell; } public static boolean removeObjectFromController(obj_id controller, obj_id greeter) throws InterruptedException { diff --git a/sku.0/sys.server/compiled/game/script/library/weapons.java b/sku.0/sys.server/compiled/game/script/library/weapons.java old mode 100644 new mode 100755 index 3d1bd87c9..364fdc2f8 --- a/sku.0/sys.server/compiled/game/script/library/weapons.java +++ b/sku.0/sys.server/compiled/game/script/library/weapons.java @@ -1,20 +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.combat; -import script.library.factions; -import script.library.heavyweapons; -import script.library.powerup; -import script.library.smuggler; -import script.library.trace; -import script.library.utils; +import java.util.Vector; public class weapons extends script.base_script { @@ -138,7 +128,7 @@ public class weapons extends script.base_script public static int _GetTableValue(String col, String searchArg, int VIA_what) throws InterruptedException { String searchCol = COL_SCHEMATIC_NAME; - int row = -1; + int row; if (VIA_what == VIA_TEMPLATE) { searchCol = COL_TEMPLATE_HASH; @@ -440,10 +430,10 @@ public class weapons extends script.base_script } public static obj_id _createFromDictionary(dictionary dat, obj_id container, float speed, float damage, float effeciency, float elementalVal, boolean overloadInv) throws InterruptedException { - obj_id obj = null; + obj_id obj; if (!dat.containsKey(COL_TEMPLATE)) { - return obj; + return null; } if (overloadInv) { @@ -455,7 +445,7 @@ public class weapons extends script.base_script } if (obj == null) { - return obj; + return null; } setWeaponAttributes(obj, dat, speed, damage, effeciency, elementalVal); return obj; @@ -505,8 +495,6 @@ public class weapons extends script.base_script { accuracy = minAccuracy; } - int minRange = getMinRangeDistance(dat); - int maxRange = getMaxRangeDistance(dat); int minAttackCost = getAttackCostLow(dat); int maxAttackCost = getAttackCostHigh(dat); int valueRange = maxAttackCost - minAttackCost; @@ -528,14 +516,13 @@ public class weapons extends script.base_script setWeaponMaxDamage(weapon, damageHigh); setWeaponAttackSpeed(weapon, (float)speed / 100.0f); setWeaponWoundChance(weapon, (float)woundChance / 10.0f); - setMaxHitpoints(weapon, (int)(hp)); - setHitpoints(weapon, (int)(hp)); + setMaxHitpoints(weapon, hp); + setHitpoints(weapon, hp); setWeaponAccuracy(weapon, accuracy); setWeaponDamageType(weapon, damType); setWeaponAttackCost(weapon, attackCost); setWeaponElementalDamage(weapon, elementalType, elementalValue); setHeavyWeaponAoeSplashPercent(weapon); - return; } public static void setWeaponAttributes(obj_id weapon, dictionary dat, float percentOfMax) throws InterruptedException { @@ -548,8 +535,7 @@ public class weapons extends script.base_script { return null; } - dictionary dic = dataTableGetRow(WEAPON_DATA_TABLE, row); - return dic; + return dataTableGetRow(WEAPON_DATA_TABLE, row); } public static dictionary getWeaponDat(obj_id weapon) throws InterruptedException { @@ -563,8 +549,7 @@ public class weapons extends script.base_script { return null; } - dictionary dict = dataTableGetRow(WEAPON_CORE_TABLE, row); - return dict; + return dataTableGetRow(WEAPON_CORE_TABLE, row); } public static obj_id createPossibleWeapon(String name, obj_id container, float percentOfMax) throws InterruptedException { @@ -602,7 +587,7 @@ public class weapons extends script.base_script public static obj_id createWeapon(String name, obj_id container, int VIA_what, float speed, float damage, float effeciency, float elementalVal, boolean overloadInv) throws InterruptedException { String col = COL_SCHEMATIC_NAME; - int row = -1; + int row; if (VIA_what == VIA_TEMPLATE) { col = COL_TEMPLATE_HASH; @@ -623,7 +608,7 @@ public class weapons extends script.base_script } dictionary dic = dataTableGetRow(WEAPON_DATA_TABLE, row); obj_id weapon = _createFromDictionary(dic, container, speed, damage, effeciency, elementalVal, overloadInv); - if (weapon != null && name.indexOf("component") > -1) + if (weapon != null && name.contains("component")) { attachScript(weapon, "item.special.serialize_component"); } @@ -638,19 +623,14 @@ public class weapons extends script.base_script { String type = toLower(fragment); String[] allWeaps = dataTableGetStringColumn(WEAPON_DATA_TABLE, COL_TEMPLATE); - String lookFor = "all"; - if (type.equals("melee")) - { - lookFor = "special"; - } Vector names = new Vector(); - String template = ""; + String template; for (int i = 0; i < allWeaps.length; i++) { template = dataTableGetString(WEAPON_DATA_TABLE, i, COL_TEMPLATE); - if (template != null && (type.equals("all") || template.indexOf(type) > -1)) + if (template != null && (type.equals("all") || template.contains(type))) { - if (template.indexOf("component") > -1) + if (template.contains("component")) { continue; } @@ -677,11 +657,11 @@ public class weapons extends script.base_script return -1; } int numCreated = 0; - dictionary dic = null; + dictionary dic; for (int i = 0; i < allWeaps.length; i++) { dic = dataTableGetRow(WEAPON_DATA_TABLE, i); - if (nameFragment.equals("all") || (dic.getString(col)).indexOf(nameFragment) > -1) + if (nameFragment.equals("all") || (dic.getString(col)).contains(nameFragment)) { numCreated = (_createFromDictionary(dic, container, percentOfMax) != null ? numCreated + 1 : numCreated); } @@ -698,21 +678,18 @@ public class weapons extends script.base_script nameFragment = toLower(nameFragment); String[] allEntries = dataTableGetStringColumnNoDefaults(WEAPON_DATA_TABLE, col); trace.log(WEAPONS, "Got " + allEntries.length + " schematic entries from col " + col); - for (int i = 0; i < allEntries.length; i++) - { - if (!nameFragment.equals("all") && (toLower(allEntries[i])).indexOf(nameFragment) < 0) - { - trace.log(WEAPONS, allEntries[i] + " does will not be adjusted."); + String path; + for (String allEntry : allEntries) { + if (!nameFragment.equals("all") && !(toLower(allEntry)).contains(nameFragment)) { + trace.log(WEAPONS, allEntry + " does will not be adjusted."); continue; } - trace.log(WEAPONS, allEntries[i] + " will be " + (grant ? "granted" : "revoked")); - String path = "object/draft_schematic/weapon/"; - if ((grant ? grantSchematic(player, path + allEntries[i] + ".iff") : revokeSchematic(player, path + allEntries[i] + ".iff"))) - { - sendSystemMessageTestingOnly(player, "Schematic " + (grant ? "granted: " : "revoked: ") + allEntries[i]); + trace.log(WEAPONS, allEntry + " will be " + (grant ? "granted" : "revoked")); + path = "object/draft_schematic/weapon/"; + if ((grant ? grantSchematic(player, path + allEntry + ".iff") : revokeSchematic(player, path + allEntry + ".iff"))) { + sendSystemMessageTestingOnly(player, "Schematic " + (grant ? "granted: " : "revoked: ") + allEntry); } } - return; } public static obj_id createLimitedUseSchematic(String name, int numUses, obj_id container, String schematicNameKey) throws InterruptedException { @@ -724,12 +701,12 @@ public class weapons extends script.base_script } public static obj_id createLimitedUseSchematic(String name, int VIA_what, int numUses, obj_id container, String schematicNameKey, String skillRequired) throws InterruptedException { - if ((toLower(name)).indexOf("component") > -1) + if ((toLower(name)).contains("component")) { return null; } String col = COL_SCHEMATIC_NAME; - int row = -1; + int row; if (VIA_what == VIA_TEMPLATE) { col = COL_TEMPLATE_HASH; @@ -751,7 +728,7 @@ public class weapons extends script.base_script obj_id obj = createObject("object/tangible/loot/loot_schematic/generic_limited_use.iff", container, ""); if (obj == null) { - return obj; + return null; } setObjVar(obj, "loot_schematic.schematic", "object/draft_schematic/weapon/" + schematicName + ".iff"); setObjVar(obj, "loot_schematic.uses", numUses); @@ -813,7 +790,6 @@ public class weapons extends script.base_script } validateWeaponData(weapon, weaponDat); } - return; } public static boolean coredWeaponConversion(obj_id weapon) throws InterruptedException { @@ -832,12 +808,12 @@ public class weapons extends script.base_script CustomerServiceLog("weap_conversion_bad", "WEAPON TEMPLATE IS: " + template); return false; } - int damageType = 0; - int elementalType = 0; - int elementalValue = 0; - int accuracy = 0; - float coreBonus = 0.0f; - float craftedBonus = 0.0f; + int damageType; + int elementalType; + int elementalValue; + int accuracy; + float coreBonus; + float craftedBonus; coreBonus = getWeaponCoreQualityMin(weapon); craftedBonus = coreBonus + getWeaponComponentBonusesMinDamage(weapon); int tableMin = getCoreMinDamage(weapon, weaponCoreDat); @@ -936,12 +912,7 @@ public class weapons extends script.base_script int currentElementalDamage = getWeaponElementalValue(weapon); int minElementalDamage = getElementalValueLow(weaponDat); int maxElementalDamage = getElementalValueHigh(weaponDat); - if (currentElementalDamageType != clickMasterDamageType) - { - - } - - { + if (currentElementalDamageType != clickMasterDamageType){ setWeaponElementalType(weapon, clickMasterDamageType); } if (currentElementalDamage < minElementalDamage || currentElementalDamage > maxElementalDamage) @@ -983,8 +954,8 @@ public class weapons extends script.base_script int clickMasterMaxDamage = getMaxDamageHighCap(weaponDat); int clickMasterLowMinDamage = getMinDamageLowCap(weaponDat); int clickMasterLowMaxDamage = getMaxDamageLowCap(weaponDat); - int finalMinDamage = 0; - int finalMaxDamage = 0; + int finalMinDamage; + int finalMaxDamage; finalMinDamage = (int)(clickMasterLowMinDamage + ((clickMasterMinDamage - clickMasterLowMinDamage) * .99f)); finalMaxDamage = (int)(clickMasterLowMaxDamage + ((clickMasterMaxDamage - clickMasterLowMaxDamage) * .99f)); setObjVar(saber, jedi.VAR_SABER_DEFAULT_STATS + "." + jedi.VAR_MIN_DMG, finalMinDamage); @@ -1093,10 +1064,6 @@ public class weapons extends script.base_script float currentDamageType = getFloatObjVar(crate, "crafting_attributes.crafting:damageType"); int clickMasterDamageType = getDamageType(weaponDat); if (currentDamageType != clickMasterDamageType) - { - - } - { setObjVar(crate, "crafting_attributes.crafting:damageType", (float)(clickMasterDamageType)); } @@ -1107,10 +1074,6 @@ public class weapons extends script.base_script float currentElementalDamage = getFloatObjVar(crate, "crafting_attributes.crafting:elementalValue"); int clickMasterElementalDamage = ((getElementalValueLow(weaponDat) + getElementalValueHigh(weaponDat)) / 2); if (weaponElementalType != clickMasterElementalDamageType) - { - - } - { setObjVar(crate, "crafting_attributes.crafting:elementalType", (float)(clickMasterElementalDamageType)); } @@ -1126,14 +1089,7 @@ public class weapons extends script.base_script { int currentVersion = getConversionId(object); int masterVersion = CONVERSION_VERSION; - if (currentVersion == masterVersion) - { - return true; - } - else - { - return false; - } + return currentVersion == masterVersion; } public static void validateWeaponFactoryCrateFromSchematic(obj_id crate) throws InterruptedException { @@ -1147,12 +1103,7 @@ public class weapons extends script.base_script if (weaponObjectTemplate != null && !weaponObjectTemplate.equals("")) { dictionary weaponDat = getWeaponDat(weaponObjectTemplate); - if (weaponDat == null) - { - return; - } - else - { + if (weaponDat != null) { validateWeaponFacoryCrateRange(crate, weaponDat); } } @@ -1257,7 +1208,6 @@ public class weapons extends script.base_script dctWeaponStats.put("attackSpeed", fltAttackSpeed); dctWeaponStats.put("damageRadius", fltDamageRadius); utils.setScriptVar(objWeapon, "dctWeaponStats", dctWeaponStats); - return; } public static void adjustWeaponRangeForExpertise(obj_id player, obj_id self, boolean modify) throws InterruptedException { @@ -1302,10 +1252,6 @@ public class weapons extends script.base_script int currentDamageType = getWeaponDamageType(weapon); int damageType = getNewWeaponDamageType(weapon); if (currentDamageType != damageType) - { - - } - { setWeaponDamageType(weapon, damageType); } @@ -1324,10 +1270,6 @@ public class weapons extends script.base_script int currentDamageType = getWeaponDamageType(weapon); int damageType = getDamageType(weaponDat); if (currentDamageType != damageType) - { - - } - { setWeaponDamageType(weapon, damageType); } @@ -1383,8 +1325,7 @@ public class weapons extends script.base_script { return 0; } - int appBonus = dataTableGetInt(WEAPON_APP_BONUS_TABLE, row, "ele_bonus"); - return appBonus; + return dataTableGetInt(WEAPON_APP_BONUS_TABLE, row, "ele_bonus"); } public static int getCoreMinDamage(obj_id prototype, dictionary weaponDat) throws InterruptedException { @@ -1405,8 +1346,7 @@ public class weapons extends script.base_script } int wpType = dataTableGetInt(WEAPON_APP_TABLE, row, WEAPON_APP_TYPE); String weaponType = WEAPON_TYPES[wpType]; - int minDamage = weaponDat.getInt(weaponType + "_min_damage"); - return minDamage; + return weaponDat.getInt(weaponType + "_min_damage"); } public static int getCoreMaxDamage(obj_id prototype, dictionary weaponDat) throws InterruptedException { @@ -1426,9 +1366,7 @@ public class weapons extends script.base_script return -1; } int wpType = dataTableGetInt(WEAPON_APP_TABLE, row, WEAPON_APP_TYPE); - String weaponType = WEAPON_TYPES[wpType]; - int maxDamage = weaponDat.getInt(weaponType + "_max_damage"); - return maxDamage; + return weaponDat.getInt(WEAPON_TYPES[wpType] + "_max_damage"); } public static int getWeaponSpeed(obj_id prototype) throws InterruptedException { @@ -1443,8 +1381,7 @@ public class weapons extends script.base_script CustomerServiceLog("weaponsCraftingError", "getWeaponSpeed::Could not find template(" + template + ") in weapon appearance table for prototype " + prototype); return 1; } - int speed = dataTableGetInt(WEAPON_APP_TABLE, row, WEAPON_APP_SPEED); - return speed; + return dataTableGetInt(WEAPON_APP_TABLE, row, WEAPON_APP_SPEED); } public static int getNewWeaponWoundChance(obj_id prototype) throws InterruptedException { @@ -1459,8 +1396,7 @@ public class weapons extends script.base_script CustomerServiceLog("weaponsCraftingError", "getNewWeaponWoundChance::Could not find template(" + template + ") in weapon appearance table for prototype " + prototype); return 0; } - int woundChance = dataTableGetInt(WEAPON_APP_TABLE, row, WEAPON_APP_WOUND); - return woundChance; + return dataTableGetInt(WEAPON_APP_TABLE, row, WEAPON_APP_WOUND); } public static int getNewWeaponAttackCost(obj_id prototype) throws InterruptedException { @@ -1475,8 +1411,7 @@ public class weapons extends script.base_script CustomerServiceLog("weaponsCraftingError", "getNewWeaponAttackCost::Could not find template(" + template + ") in weapon appearance table for prototype " + prototype); return 0; } - int attackCost = dataTableGetInt(WEAPON_APP_TABLE, row, WEAPON_APP_COST); - return attackCost; + return dataTableGetInt(WEAPON_APP_TABLE, row, WEAPON_APP_COST); } public static int getNewWeaponAccuracy(obj_id prototype) throws InterruptedException { @@ -1491,8 +1426,7 @@ public class weapons extends script.base_script CustomerServiceLog("weaponsCraftingError", "getNewWeaponAccuracy::Could not find template(" + template + ") in weapon appearance table for prototype " + prototype); return 0; } - int wpnAcc = dataTableGetInt(WEAPON_APP_TABLE, row, WEAPON_APP_ACC); - return wpnAcc; + return dataTableGetInt(WEAPON_APP_TABLE, row, WEAPON_APP_ACC); } public static int getNewWeaponTableElementType(obj_id prototype) throws InterruptedException { @@ -1507,8 +1441,7 @@ public class weapons extends script.base_script CustomerServiceLog("weaponsCraftingError", "getNewWeaponTableElementType::Could not find template(" + template + ") in weapon appearance table for prototype " + prototype); return -1; } - int elementType = dataTableGetInt(WEAPON_APP_TABLE, row, WEAPON_APP_ELEMENT_TYPE); - return elementType; + return dataTableGetInt(WEAPON_APP_TABLE, row, WEAPON_APP_ELEMENT_TYPE); } public static int getNewWeaponTableElementalValue(obj_id prototype, dictionary weaponDat) throws InterruptedException { @@ -1529,8 +1462,7 @@ public class weapons extends script.base_script } int wpType = dataTableGetInt(WEAPON_APP_TABLE, row, WEAPON_APP_TYPE); String weaponType = WEAPON_TYPES[wpType]; - int elementalValue = weaponDat.getInt("elemental_" + weaponType + "_average_damage"); - return elementalValue; + return weaponDat.getInt("elemental_" + weaponType + "_average_damage"); } public static int getNewWeaponDamageType(obj_id prototype) throws InterruptedException { @@ -1545,8 +1477,7 @@ public class weapons extends script.base_script CustomerServiceLog("weaponsCraftingError", "getNewWeaponDamageType::Could not find template(" + template + ") in weapon appearance table for prototype " + prototype); return -1; } - int damageType = dataTableGetInt(WEAPON_APP_TABLE, row, WEAPON_APP_DAMAGE_TYPE); - return damageType; + return dataTableGetInt(WEAPON_APP_TABLE, row, WEAPON_APP_DAMAGE_TYPE); } public static int getNewWeaponMaxRange(obj_id prototype) throws InterruptedException { @@ -1561,8 +1492,7 @@ public class weapons extends script.base_script CustomerServiceLog("weaponsCraftingError", "getNewWeaponMaxRange::Could not find template(" + template + ") in weapon appearance table for prototype " + prototype); return -1; } - int maxRange = dataTableGetInt(WEAPON_APP_TABLE, row, WEAPON_APP_MAX_RANGE); - return maxRange; + return dataTableGetInt(WEAPON_APP_TABLE, row, WEAPON_APP_MAX_RANGE); } public static int getNewWeaponMinRange(obj_id prototype) throws InterruptedException { @@ -1577,8 +1507,7 @@ public class weapons extends script.base_script CustomerServiceLog("weaponsCraftingError", "getNewWeaponMinRange::Could not find template(" + template + ") in weapon appearance table for prototype " + prototype); return -1; } - int minRange = dataTableGetInt(WEAPON_APP_TABLE, row, WEAPON_APP_MIN_RANGE); - return minRange; + return dataTableGetInt(WEAPON_APP_TABLE, row, WEAPON_APP_MIN_RANGE); } public static boolean performSocketing(obj_id prototype, String[] expMods) throws InterruptedException { @@ -1596,9 +1525,8 @@ public class weapons extends script.base_script { int sockets = 0; int experimentModTotal = 0; - for (int j = 0; j < mods.length; ++j) - { - experimentModTotal += mods[j]; + for (int mod : mods) { + experimentModTotal += mod; } if (experimentModTotal > craftinglib.socketThreshold) { @@ -1625,25 +1553,22 @@ public class weapons extends script.base_script } public static String getDamageTypeString(int type) throws InterruptedException { - boolean initializedDamageTypeNames = false; - if (!initializedDamageTypeNames) - { - initializedDamageTypeNames = true; - int next = 0; - DAMAGE_TYPE_NAMES[next++] = "kinetic"; - DAMAGE_TYPE_NAMES[next++] = "energy"; - DAMAGE_TYPE_NAMES[next++] = "blast"; - DAMAGE_TYPE_NAMES[next++] = "stun"; - DAMAGE_TYPE_NAMES[next++] = "restraint"; - DAMAGE_TYPE_NAMES[next++] = "elemental_heat"; - DAMAGE_TYPE_NAMES[next++] = "elemental_cold"; - DAMAGE_TYPE_NAMES[next++] = "elemental_acid"; - DAMAGE_TYPE_NAMES[next++] = "elemental_electrical"; - DAMAGE_TYPE_NAMES[next++] = "environmental_heat"; - DAMAGE_TYPE_NAMES[next++] = "environmental_cold"; - DAMAGE_TYPE_NAMES[next++] = "environmental_acid"; - DAMAGE_TYPE_NAMES[next++] = "environmental_electrical"; - } + int next = 0; + + DAMAGE_TYPE_NAMES[next++] = "kinetic"; + DAMAGE_TYPE_NAMES[next++] = "energy"; + DAMAGE_TYPE_NAMES[next++] = "blast"; + DAMAGE_TYPE_NAMES[next++] = "stun"; + DAMAGE_TYPE_NAMES[next++] = "restraint"; + DAMAGE_TYPE_NAMES[next++] = "elemental_heat"; + DAMAGE_TYPE_NAMES[next++] = "elemental_cold"; + DAMAGE_TYPE_NAMES[next++] = "elemental_acid"; + DAMAGE_TYPE_NAMES[next++] = "elemental_electrical"; + DAMAGE_TYPE_NAMES[next++] = "environmental_heat"; + DAMAGE_TYPE_NAMES[next++] = "environmental_cold"; + DAMAGE_TYPE_NAMES[next++] = "environmental_acid"; + DAMAGE_TYPE_NAMES[next] = "environmental_electrical"; + int i = 0; int c = 1; while (c < type) @@ -1656,32 +1581,28 @@ public class weapons extends script.base_script public static boolean storeWeaponCraftingValues(obj_id prototype, obj_id schematicId, draft_schematic schematic) throws InterruptedException { draft_schematic.slot[] slots = schematic.getSlots(); - draft_schematic.attribute[] objectAttribs = schematic.getAttribs(); - draft_schematic.attribute[] experimentalAttribs = schematic.getExperimentalAttribs(); - for (int i = 0; i < slots.length; ++i) - { - obj_id componentId = slots[i].ingredients[0].ingredient; - if (!isIdValid(componentId) || !exists(componentId)) - { + obj_id componentId; + String reStatMod; + String statModified; + for (draft_schematic.slot slot : slots) { + componentId = slot.ingredients[0].ingredient; + if (!isIdValid(componentId) || !exists(componentId)) { componentId = schematicId; - if (!isIdValid(componentId) || !exists(componentId)) - { + if (!isIdValid(componentId) || !exists(componentId)) { continue; } } - if (hasObjVar(componentId, "reverse_engineering.reverse_engineering_modifier")) - { + if (hasObjVar(componentId, "reverse_engineering.reverse_engineering_modifier")) { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ingredient " + componentId + " has the objvar reverse_engineering.reverse_engineering_modifier"); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting RE Bit data now on prototype " + prototype); - String reStatMod = getStringObjVar(componentId, "reverse_engineering.reverse_engineering_modifier"); + reStatMod = getStringObjVar(componentId, "reverse_engineering.reverse_engineering_modifier"); int ratio = getIntObjVar(componentId, "reverse_engineering.reverse_engineering_ratio"); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ratio " + ratio + " on prototype " + prototype); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::reStatMod " + reStatMod + " on prototype " + prototype); setObjVar(prototype, craftinglib.OBJVAR_RE_RATIO, ratio); setObjVar(prototype, craftinglib.OBJVAR_RE_STAT_MODIFIED, reStatMod); } - if (hasObjVar(componentId, "reverse_engineering.reverse_engineering_power")) - { + if (hasObjVar(componentId, "reverse_engineering.reverse_engineering_power")) { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ingredient " + componentId + " has the objvar reverse_engineering.reverse_engineering_power"); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting RE Bit data now on prototype " + prototype); float powerMod = getIntObjVar(componentId, "reverse_engineering.reverse_engineering_power"); @@ -1690,132 +1611,107 @@ public class weapons extends script.base_script CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::powerMod after modification of 40% " + powerMod + " on prototype " + prototype); setObjVar(prototype, craftinglib.OBJVAR_RE_VALUE, powerMod); } - if (hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreQualityLow")) - { + if (hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreQualityLow")) { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ingredient " + componentId + " has the objvar" + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreQualityLow"); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting coreQualityLow data now on prototype " + prototype); float coreQualityLow = getFloatObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreQualityLow"); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::coreQualityLow " + coreQualityLow + " on prototype " + prototype); setObjVar(prototype, OBJVAR_WP_CORE_QUALITY_MIN, coreQualityLow); } - if (hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreQualityHigh")) - { + if (hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreQualityHigh")) { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ingredient " + componentId + " has the objvar" + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreQualityHigh"); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting coreQualityHigh data now on prototype " + prototype); float coreQualityHigh = getFloatObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreQualityHigh"); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::coreQualityHigh " + coreQualityHigh + " on prototype " + prototype); setObjVar(prototype, OBJVAR_WP_CORE_QUALITY_MAX, coreQualityHigh); } - if (hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "appearanceBonusLow")) - { + if (hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "appearanceBonusLow")) { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ingredient " + componentId + " has the objvar" + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "appearanceBonusLow"); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting coreQuality data now on prototype " + prototype); float appBonus = getFloatObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "appearanceBonusLow"); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::appearanceBonusLow " + appBonus + " on prototype " + prototype); setObjVar(prototype, OBJVAR_MODIFIER_APPEARANCE_BONUS_MIN, appBonus); } - if (hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "appearanceBonusHigh")) - { + if (hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "appearanceBonusHigh")) { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ingredient " + componentId + " has the objvar" + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "appearanceBonusHigh"); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting coreQuality data now on prototype " + prototype); float appBonus = getFloatObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "appearanceBonusHigh"); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::appearanceBonusHigh " + appBonus + " on prototype " + prototype); setObjVar(prototype, OBJVAR_MODIFIER_APPEARANCE_BONUS_MAX, appBonus); } - if (hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "gasQualityLow")) - { + if (hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "gasQualityLow")) { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ingredient " + componentId + " has the objvar " + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "gasQualityLow"); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting gasQualityLow data now on prototype " + prototype); - if (!hasObjVar(componentId, OBJVAR_MODIFIER_GAS_QUALITY_MIN)) - { + if (!hasObjVar(componentId, OBJVAR_MODIFIER_GAS_QUALITY_MIN)) { float gasQualityLow = getIntObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "gasQualityLow"); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::gasQualityLow " + gasQualityLow + " on prototype " + prototype); setObjVar(prototype, OBJVAR_MODIFIER_GAS_QUALITY_MIN, gasQualityLow); - } - else - { + } else { float gasQualityLow = getIntObjVar(componentId, OBJVAR_MODIFIER_GAS_QUALITY_MIN); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::gasQualityLow " + gasQualityLow + " on prototype " + prototype); setObjVar(prototype, OBJVAR_MODIFIER_GAS_QUALITY_MIN, gasQualityLow); } } - if (hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "gasQualityHigh")) - { + if (hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "gasQualityHigh")) { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ingredient " + componentId + " has the objvar " + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "gasQualityHigh"); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting gasQualityHigh data now on prototype " + prototype); - if (!hasObjVar(componentId, OBJVAR_MODIFIER_GAS_QUALITY_MAX)) - { + if (!hasObjVar(componentId, OBJVAR_MODIFIER_GAS_QUALITY_MAX)) { float gasQualityHigh = getIntObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "gasQualityHigh"); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::gasQualityHigh " + gasQualityHigh + " on prototype " + prototype); setObjVar(prototype, OBJVAR_MODIFIER_GAS_QUALITY_MAX, gasQualityHigh); - } - else - { + } else { float gasQualityHigh = getIntObjVar(componentId, OBJVAR_MODIFIER_GAS_QUALITY_MAX); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::gasQualityHigh " + gasQualityHigh + " on prototype " + prototype); setObjVar(prototype, OBJVAR_MODIFIER_GAS_QUALITY_MAX, gasQualityHigh); } } - if (hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "meleeComponentQualityLow")) - { + if (hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "meleeComponentQualityLow")) { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ingredient " + componentId + " has the objvar " + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "meleeComponentQualityLow"); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting meleeComponentQualityLow data now on prototype " + prototype); - if (!hasObjVar(componentId, OBJVAR_MODIFIER_MELEE_QUALITY_MIN)) - { + if (!hasObjVar(componentId, OBJVAR_MODIFIER_MELEE_QUALITY_MIN)) { float meleeQuality = getIntObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "meleeComponentQualityLow"); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::meleeComponentQualityLow " + meleeQuality + " on prototype " + prototype); setObjVar(prototype, OBJVAR_MODIFIER_MELEE_QUALITY_MIN, meleeQuality); - } - else - { + } else { float meleeQuality = getIntObjVar(componentId, OBJVAR_MODIFIER_MELEE_QUALITY_MIN); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::meleeComponentQualityLow " + meleeQuality + " on prototype " + prototype); setObjVar(prototype, OBJVAR_MODIFIER_MELEE_QUALITY_MIN, meleeQuality); } } - if (hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "meleeComponentQualityHigh")) - { + if (hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "meleeComponentQualityHigh")) { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ingredient " + componentId + " has the objvar " + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "meleeComponentQualityHigh"); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting meleeComponentQualityHigh data now on prototype " + prototype); - if (!hasObjVar(componentId, OBJVAR_MODIFIER_MELEE_QUALITY_MAX)) - { + if (!hasObjVar(componentId, OBJVAR_MODIFIER_MELEE_QUALITY_MAX)) { float meleeQuality = getIntObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "meleeComponentQualityHigh"); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::meleeComponentQualityHigh " + meleeQuality + " on prototype " + prototype); setObjVar(prototype, OBJVAR_MODIFIER_MELEE_QUALITY_MAX, meleeQuality); - } - else - { + } else { float meleeQuality = getIntObjVar(componentId, OBJVAR_MODIFIER_MELEE_QUALITY_MAX); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::meleeComponentQualityHigh " + meleeQuality + " on prototype " + prototype); setObjVar(prototype, OBJVAR_MODIFIER_MELEE_QUALITY_MAX, meleeQuality); } } - if (hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "elementalValue")) - { + if (hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "elementalValue")) { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ingredient " + componentId + " has the objvar " + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "elementalValue"); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting elementalValue data now on prototype " + prototype); float elementalValue = getFloatObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "elementalValue"); - if (elementalValue >= 0.0f) - { + if (elementalValue >= 0.0f) { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::elementalValue " + elementalValue + " on prototype " + prototype); setObjVar(prototype, OBJVAR_ELEMENTAL_VALUE, elementalValue); } } - if (hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "elementalType")) - { + if (hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "elementalType")) { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ingredient " + componentId + " has the objvar " + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "elementalType"); float elementalType = getFloatObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "elementalType"); - if (elementalType >= 0) - { + if (elementalType >= 0) { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting elementalType data now on prototype " + prototype); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::elementalType " + elementalType + " on prototype " + prototype); setObjVar(prototype, OBJVAR_ELEMENTAL_TYPE, elementalType); } } - if (hasObjVar(componentId, craftinglib.OBJVAR_RE_STAT_MODIFIED)) - { + if (hasObjVar(componentId, craftinglib.OBJVAR_RE_STAT_MODIFIED)) { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ingredient " + componentId + " has the objvar " + craftinglib.OBJVAR_RE_STAT_MODIFIED); - String statModified = getStringObjVar(componentId, craftinglib.OBJVAR_RE_STAT_MODIFIED); + statModified = getStringObjVar(componentId, craftinglib.OBJVAR_RE_STAT_MODIFIED); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting statModified data now on prototype " + prototype); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::statModified " + statModified + " on prototype " + prototype); setObjVar(prototype, craftinglib.OBJVAR_RE_STAT_MODIFIED, statModified); @@ -1824,73 +1720,63 @@ public class weapons extends script.base_script CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ratio " + ratio + " on prototype " + prototype); setObjVar(prototype, craftinglib.OBJVAR_RE_RATIO, ratio); } - if (hasObjVar(componentId, craftinglib.OBJVAR_RE_VALUE)) - { + if (hasObjVar(componentId, craftinglib.OBJVAR_RE_VALUE)) { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ingredient " + componentId + " has the objvar " + craftinglib.OBJVAR_RE_VALUE); float powerBit = getFloatObjVar(componentId, craftinglib.OBJVAR_RE_VALUE); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting powerBit data now on prototype " + prototype); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::powerBit " + powerBit + " on prototype " + prototype); setObjVar(prototype, craftinglib.OBJVAR_RE_VALUE, powerBit); } - if (hasObjVar(componentId, OBJVAR_WP_CORE_QUALITY_MIN)) - { + if (hasObjVar(componentId, OBJVAR_WP_CORE_QUALITY_MIN)) { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ingredient " + componentId + " has the objvar " + OBJVAR_WP_CORE_QUALITY_MIN); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting coreQualityLow data now on prototype " + prototype); float coreQuality = getFloatObjVar(componentId, OBJVAR_WP_CORE_QUALITY_MIN); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::coreQualityLow " + coreQuality + " on prototype " + prototype); setObjVar(prototype, OBJVAR_WP_CORE_QUALITY_MIN, coreQuality); } - if (hasObjVar(componentId, OBJVAR_WP_CORE_QUALITY_MAX)) - { + if (hasObjVar(componentId, OBJVAR_WP_CORE_QUALITY_MAX)) { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ingredient " + componentId + " has the objvar " + OBJVAR_WP_CORE_QUALITY_MAX); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting coreQualityHigh data now on prototype " + prototype); float coreQuality = getFloatObjVar(componentId, OBJVAR_WP_CORE_QUALITY_MAX); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::coreQualityHigh " + coreQuality + " on prototype " + prototype); setObjVar(prototype, OBJVAR_WP_CORE_QUALITY_MAX, coreQuality); } - if (hasObjVar(componentId, OBJVAR_MODIFIER_GAS_QUALITY_MIN)) - { + if (hasObjVar(componentId, OBJVAR_MODIFIER_GAS_QUALITY_MIN)) { float gasQuality = getFloatObjVar(componentId, OBJVAR_MODIFIER_GAS_QUALITY_MIN); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ingredient " + componentId + " has the objvar " + OBJVAR_MODIFIER_GAS_QUALITY_MIN); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting gasQualityLow data now to " + gasQuality + " on prototype " + prototype); setObjVar(prototype, OBJVAR_MODIFIER_GAS_QUALITY_MIN, gasQuality); } - if (hasObjVar(componentId, OBJVAR_MODIFIER_GAS_QUALITY_MAX)) - { + if (hasObjVar(componentId, OBJVAR_MODIFIER_GAS_QUALITY_MAX)) { float gasQuality = getFloatObjVar(componentId, OBJVAR_MODIFIER_GAS_QUALITY_MAX); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ingredient " + componentId + " has the objvar " + OBJVAR_MODIFIER_GAS_QUALITY_MAX); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting gasQualityHigh data now to " + gasQuality + " on prototype " + prototype); setObjVar(prototype, OBJVAR_MODIFIER_GAS_QUALITY_MAX, gasQuality); } - if (hasObjVar(componentId, OBJVAR_ELEMENTAL_VALUE)) - { + if (hasObjVar(componentId, OBJVAR_ELEMENTAL_VALUE)) { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ingredient " + componentId + " has the objvar " + OBJVAR_ELEMENTAL_VALUE); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting elementalValue data now on prototype " + prototype); float elementalValue = getFloatObjVar(componentId, OBJVAR_ELEMENTAL_VALUE); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::elementalValue " + elementalValue + " on prototype " + prototype); setObjVar(prototype, OBJVAR_ELEMENTAL_VALUE, elementalValue); } - if (hasObjVar(componentId, OBJVAR_ELEMENTAL_TYPE)) - { + if (hasObjVar(componentId, OBJVAR_ELEMENTAL_TYPE)) { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ingredient " + componentId + " has the objvar " + OBJVAR_ELEMENTAL_TYPE); float elementalType = getFloatObjVar(componentId, OBJVAR_ELEMENTAL_TYPE); - if (elementalType >= 0) - { + if (elementalType >= 0) { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting elementalType data now on prototype " + prototype); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::elementalType " + elementalType + " on prototype " + prototype); setObjVar(prototype, OBJVAR_ELEMENTAL_TYPE, elementalType); } } - if (hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreLevel")) - { + if (hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreLevel")) { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ingredient " + componentId + " has the objvar " + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreLevel"); - int corelevel = (int)getFloatObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreLevel"); + int corelevel = (int) getFloatObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreLevel"); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting corelevel data now on prototype " + prototype); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::corelevel " + corelevel + " on prototype " + prototype); setObjVar(prototype, OBJVAR_WP_LEVEL, corelevel); } - if (hasObjVar(componentId, weapons.OBJVAR_MODIFIER_COMPONENT_BONUS_MIN) && !hasObjVar(prototype, OBJVAR_NEW_WP_WEAPON)) - { + if (hasObjVar(componentId, weapons.OBJVAR_MODIFIER_COMPONENT_BONUS_MIN) && !hasObjVar(prototype, OBJVAR_NEW_WP_WEAPON)) { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::componentBonus::ingredient " + componentId + " has the objvar " + weapons.OBJVAR_MODIFIER_COMPONENT_BONUS_MIN); float previousBonus = getFloatObjVar(prototype, weapons.OBJVAR_MODIFIER_COMPONENT_BONUS_MIN); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::componentBonus::previousBonusMin " + previousBonus + " from prototype " + prototype); @@ -1899,8 +1785,7 @@ public class weapons extends script.base_script CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::componentBonus::setting componentBonus data now on prototype " + prototype); setObjVar(prototype, OBJVAR_MODIFIER_COMPONENT_BONUS_MIN, (previousBonus + componentBonus)); } - if (hasObjVar(componentId, weapons.OBJVAR_MODIFIER_COMPONENT_BONUS_MAX) && !hasObjVar(prototype, OBJVAR_NEW_WP_WEAPON)) - { + if (hasObjVar(componentId, weapons.OBJVAR_MODIFIER_COMPONENT_BONUS_MAX) && !hasObjVar(prototype, OBJVAR_NEW_WP_WEAPON)) { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::componentBonus::ingredient " + componentId + " has the objvar " + weapons.OBJVAR_MODIFIER_COMPONENT_BONUS_MAX); float previousBonus = getFloatObjVar(prototype, weapons.OBJVAR_MODIFIER_COMPONENT_BONUS_MAX); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::componentBonus::previousBonusMax " + previousBonus + " from prototype " + prototype); @@ -1909,35 +1794,28 @@ public class weapons extends script.base_script CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::componentBonus::setting componentBonus data now on prototype " + prototype); setObjVar(prototype, OBJVAR_MODIFIER_COMPONENT_BONUS_MAX, (previousBonus + componentBonus)); } - if (hasObjVar(componentId, OBJVAR_MODIFIER_MELEE_QUALITY_MIN)) - { + if (hasObjVar(componentId, OBJVAR_MODIFIER_MELEE_QUALITY_MIN)) { float meleeQuality = getFloatObjVar(componentId, OBJVAR_MODIFIER_MELEE_QUALITY_MIN); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ingredient " + componentId + " has the objvar " + OBJVAR_MODIFIER_MELEE_QUALITY_MIN); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting meleeQuality_min data now to " + meleeQuality + " on prototype " + prototype); setObjVar(prototype, OBJVAR_MODIFIER_MELEE_QUALITY_MIN, meleeQuality); } - if (hasObjVar(componentId, OBJVAR_MODIFIER_MELEE_QUALITY_MAX)) - { + if (hasObjVar(componentId, OBJVAR_MODIFIER_MELEE_QUALITY_MAX)) { float meleeQuality = getFloatObjVar(componentId, OBJVAR_MODIFIER_MELEE_QUALITY_MAX); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ingredient " + componentId + " has the objvar " + OBJVAR_MODIFIER_MELEE_QUALITY_MAX); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting meleeQuality_max data now to " + meleeQuality + " on prototype " + prototype); setObjVar(prototype, OBJVAR_MODIFIER_MELEE_QUALITY_MAX, meleeQuality); } - if (hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "combat_critical_ranged") || hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "combat_critical_melee")) - { - if (isRangedCore(prototype) || isMeleeCore(prototype) || isHeavyCore(prototype)) - { - int critBonus = 0; - if (hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "combat_critical_ranged")) - { + if (hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "combat_critical_ranged") || hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "combat_critical_melee")) { + if (isRangedCore(prototype) || isMeleeCore(prototype) || isHeavyCore(prototype)) { + int critBonus; + if (hasObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "combat_critical_ranged")) { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ingredient " + componentId + " has the objvar " + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "combat_critical_ranged"); critBonus = getIntObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "combat_critical_ranged"); setObjVar(prototype, OBJVAR_CRIT_BONUS_RANGED, critBonus); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting critBonus data now to " + critBonus + " on prototype " + prototype); setCategorizedSkillModBonus(prototype, "weapon", "combat_critical_ranged", critBonus); - } - else - { + } else { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ingredient " + componentId + " has the objvar " + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "combat_critical_melee"); critBonus = getIntObjVar(componentId, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "combat_critical_melee"); setObjVar(prototype, OBJVAR_CRIT_BONUS_MELEE, critBonus); @@ -1946,33 +1824,27 @@ public class weapons extends script.base_script } } } - if (hasObjVar(componentId, "attribute.bonus")) - { + if (hasObjVar(componentId, "attribute.bonus")) { LOG("sissynoid", "attribute.bonus found"); int[] attribsModified = getAttributeBonuses(componentId); - if (attribsModified != null && attribsModified.length > 0) - { + if (attribsModified != null && attribsModified.length > 0) { CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::ingredient " + componentId + " has an attribute bonus."); int[] attribBonus = new int[NUM_ATTRIBUTES]; - for (int j = 0; j < attribsModified.length; ++j) - { - if (attribsModified[j] > 0) - { + for (int j = 0; j < attribsModified.length; ++j) { + if (attribsModified[j] > 0) { attribBonus[j] = attribsModified[j]; CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting Attribute Bonus " + ATTRIBUTES[j] + " To " + attribsModified[j]); } } setAttributeBonuses(prototype, attribBonus); } - if (hasObjVar(componentId, "attribute.bonus") && hasObjVar(prototype, "armor.general_protection")) - { + if (hasObjVar(componentId, "attribute.bonus") && hasObjVar(prototype, "armor.general_protection")) { CustomerServiceLog("new_weapon_crafting", "Cybernetics: Component(" + componentId + ") is being added to a Cybernetic(" + prototype + ") that has an Armor Core; Armor Value Reduction will occur by design."); LOG("sissynoid", "Cybernetic has Armor Core and Modules - Nerf the Core: prototype: " + prototype); setObjVar(prototype, "modifyCyberneticArmorValue", true); } } - if (hasObjVar(componentId, "cybernetic.special_protection")) - { + if (hasObjVar(componentId, "cybernetic.special_protection")) { LOG("sissynoid", "Cybernetic Protection Module found!"); int protectionType = getIntObjVar(componentId, "cybernetic.special_protection"); setObjVar(prototype, "cybernetic.special_protection.type", protectionType); @@ -1981,17 +1853,14 @@ public class weapons extends script.base_script CustomerServiceLog("new_weapon_crafting", "Cybernetics: Component(" + componentId + ") has Special Protection - Adding these to the Cybernetic(" + prototype + "): protection type: (" + protectionType + ") and Value: (" + protectionValue + ")."); LOG("sissynoid", "WEAPON SCRIPTLIB: protection module type: " + protectionType + " and Value: " + protectionValue); } - if (hasObjVar(componentId, OBJVAR_CRIT_BONUS_MELEE) || hasObjVar(componentId, OBJVAR_CRIT_BONUS_RANGED)) - { - if (hasObjVar(componentId, OBJVAR_CRIT_BONUS_MELEE)) - { + if (hasObjVar(componentId, OBJVAR_CRIT_BONUS_MELEE) || hasObjVar(componentId, OBJVAR_CRIT_BONUS_RANGED)) { + if (hasObjVar(componentId, OBJVAR_CRIT_BONUS_MELEE)) { int critBonus = getIntObjVar(componentId, OBJVAR_CRIT_BONUS_MELEE); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting critBonus data now to " + critBonus + " on prototype " + prototype); setCategorizedSkillModBonus(prototype, "weapon", "combat_critical_melee", critBonus); setObjVar(prototype, OBJVAR_CRIT_BONUS_MELEE, critBonus); } - if (hasObjVar(componentId, OBJVAR_CRIT_BONUS_RANGED)) - { + if (hasObjVar(componentId, OBJVAR_CRIT_BONUS_RANGED)) { int critBonus = getIntObjVar(componentId, OBJVAR_CRIT_BONUS_RANGED); CustomerServiceLog("new_weapon_crafting", "storeWeaponCraftingValues::setting critBonus data now to " + critBonus + " on prototype " + prototype); setCategorizedSkillModBonus(prototype, "weapon", "combat_critical_ranged", critBonus); @@ -2007,272 +1876,203 @@ public class weapons extends script.base_script { return false; } - for (int i = 0; i < itemAttributes.length; ++i) - { - float attribValue = itemAttributes[i].currentValue; - if (((itemAttributes[i].name).getAsciiId()).equals("gasQualityLow")) - { - if (hasObjVar(prototype, OBJVAR_MODIFIER_GAS_QUALITY_MIN)) - { - if (!hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "gasQualityLow")) - { + for (draft_schematic.attribute itemAttribute : itemAttributes) { + float attribValue = itemAttribute.currentValue; + if (((itemAttribute.name).getAsciiId()).equals("gasQualityLow")) { + if (hasObjVar(prototype, OBJVAR_MODIFIER_GAS_QUALITY_MIN)) { + if (!hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "gasQualityLow")) { CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::we(" + prototype + ") dont have the objvar " + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "gasQualityLow"); attribValue = getFloatObjVar(prototype, OBJVAR_MODIFIER_GAS_QUALITY_MIN); CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::new gasQualityLow value is " + attribValue); - } - else - { + } else { CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::we(" + prototype + ") have the objvar " + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "gasQualityLow"); attribValue /= NEW_COMPONENT_MODIFIER; CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::new gasQualityLow value is " + attribValue); } - if (attribValue > NEW_COMPONENT_CAP) - { + if (attribValue > NEW_COMPONENT_CAP) { attribValue = NEW_COMPONENT_CAP; setObjVar(prototype, OBJVAR_MODIFIER_GAS_QUALITY_MIN, attribValue); CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::gasQualityLow on prototype(" + prototype + ")was higher than the cap of " + NEW_COMPONENT_CAP + ", so we lowered it to the cap."); } setObjVar(prototype, OBJVAR_MODIFIER_GAS_QUALITY_MIN, attribValue); - } - else if (hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "gasQualityLow")) - { + } else if (hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "gasQualityLow")) { attribValue = getFloatObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "gasQualityLow"); attribValue /= NEW_COMPONENT_MODIFIER; - if (attribValue > NEW_COMPONENT_CAP) - { + if (attribValue > NEW_COMPONENT_CAP) { attribValue = NEW_COMPONENT_CAP; CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::gasQualityLow on prototype(" + prototype + ")was higher than the cap of " + NEW_COMPONENT_CAP + ", so we lowered it to the cap."); } setObjVar(prototype, OBJVAR_MODIFIER_GAS_QUALITY_MIN, attribValue); } } - if (((itemAttributes[i].name).getAsciiId()).equals("gasQualityHigh")) - { - if (hasObjVar(prototype, OBJVAR_MODIFIER_GAS_QUALITY_MAX)) - { - if (!hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "gasQualityHigh")) - { + if (((itemAttribute.name).getAsciiId()).equals("gasQualityHigh")) { + if (hasObjVar(prototype, OBJVAR_MODIFIER_GAS_QUALITY_MAX)) { + if (!hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "gasQualityHigh")) { CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::we(" + prototype + ") dont have the objvar " + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "gasQualityHigh"); attribValue = getFloatObjVar(prototype, OBJVAR_MODIFIER_GAS_QUALITY_MAX); CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::new gasQualityHigh value is " + attribValue); - } - else - { + } else { CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::we(" + prototype + ") have the objvar " + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "gasQualityHigh"); attribValue /= NEW_COMPONENT_MODIFIER; CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::new gasQualityHigh value is " + attribValue); } - if (attribValue > NEW_COMPONENT_CAP) - { + if (attribValue > NEW_COMPONENT_CAP) { attribValue = NEW_COMPONENT_CAP; setObjVar(prototype, OBJVAR_MODIFIER_GAS_QUALITY_MAX, attribValue); CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::gasQualityHigh on prototype(" + prototype + ")was higher than the cap of " + NEW_COMPONENT_CAP + ", so we lowered it to the cap."); } setObjVar(prototype, OBJVAR_MODIFIER_GAS_QUALITY_MAX, attribValue); - } - else if (hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "gasQualityHigh")) - { + } else if (hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "gasQualityHigh")) { attribValue = getFloatObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "gasQualityHigh"); attribValue /= NEW_COMPONENT_MODIFIER; - if (attribValue > NEW_COMPONENT_CAP) - { + if (attribValue > NEW_COMPONENT_CAP) { attribValue = NEW_COMPONENT_CAP; CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::gasQualityLow on prototype(" + prototype + ")was higher than the cap of " + NEW_COMPONENT_CAP + ", so we lowered it to the cap."); } setObjVar(prototype, OBJVAR_MODIFIER_GAS_QUALITY_MAX, attribValue); } } - if (((itemAttributes[i].name).getAsciiId()).equals("componentBonusLow")) - { - if (hasObjVar(prototype, OBJVAR_MODIFIER_COMPONENT_BONUS_MIN)) - { - if (!hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "componentBonusLow")) - { + if (((itemAttribute.name).getAsciiId()).equals("componentBonusLow")) { + if (hasObjVar(prototype, OBJVAR_MODIFIER_COMPONENT_BONUS_MIN)) { + if (!hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "componentBonusLow")) { CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::we(" + prototype + ") dont have the objvar " + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "componentBonusLow"); attribValue = getFloatObjVar(prototype, OBJVAR_MODIFIER_COMPONENT_BONUS_MIN); CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::new componentBonusLow value is " + attribValue); - } - else - { + } else { CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::we(" + prototype + ") have the objvar " + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "componentBonusLow"); attribValue /= NEW_COMPONENT_MODIFIER; CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::new componentBonusLow value is " + attribValue); } - if (attribValue > NEW_COMPONENT_CAP) - { + if (attribValue > NEW_COMPONENT_CAP) { attribValue = NEW_COMPONENT_CAP; setObjVar(prototype, OBJVAR_MODIFIER_COMPONENT_BONUS_MIN, attribValue); CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::componentBonusLow on prototype(" + prototype + ")was higher than the cap of " + NEW_COMPONENT_CAP + ", so we lowered it to the cap."); } setObjVar(prototype, OBJVAR_MODIFIER_COMPONENT_BONUS_MIN, attribValue); - } - else if (hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "componentBonusLow")) - { + } else if (hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "componentBonusLow")) { attribValue = getFloatObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "componentBonusLow"); attribValue /= NEW_COMPONENT_MODIFIER; - if (attribValue > NEW_COMPONENT_CAP) - { + if (attribValue > NEW_COMPONENT_CAP) { attribValue = NEW_COMPONENT_CAP; CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::gasQualityHigh on prototype(" + prototype + ")was higher than the cap of " + NEW_COMPONENT_CAP + ", so we lowered it to the cap."); } setObjVar(prototype, OBJVAR_MODIFIER_COMPONENT_BONUS_MIN, attribValue); } } - if (((itemAttributes[i].name).getAsciiId()).equals("componentBonusHigh")) - { - if (hasObjVar(prototype, OBJVAR_MODIFIER_COMPONENT_BONUS_MAX)) - { - if (!hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "componentBonusHigh")) - { + if (((itemAttribute.name).getAsciiId()).equals("componentBonusHigh")) { + if (hasObjVar(prototype, OBJVAR_MODIFIER_COMPONENT_BONUS_MAX)) { + if (!hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "componentBonusHigh")) { CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::we(" + prototype + ") dont have the objvar " + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "componentBonusHigh"); attribValue = getFloatObjVar(prototype, OBJVAR_MODIFIER_COMPONENT_BONUS_MAX); CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::new componentBonusHigh value is " + attribValue); - } - else - { + } else { CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::we(" + prototype + ") have the objvar " + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "componentBonusHigh"); attribValue /= NEW_COMPONENT_MODIFIER; CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::new componentBonusHigh value is " + attribValue); } - if (attribValue > NEW_COMPONENT_CAP) - { + if (attribValue > NEW_COMPONENT_CAP) { attribValue = NEW_COMPONENT_CAP; setObjVar(prototype, OBJVAR_MODIFIER_COMPONENT_BONUS_MAX, attribValue); CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::componentBonusHigh on prototype(" + prototype + ")was higher than the cap of " + NEW_COMPONENT_CAP + ", so we lowered it to the cap."); } setObjVar(prototype, OBJVAR_MODIFIER_COMPONENT_BONUS_MAX, attribValue); - } - else if (hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "componentBonusHigh")) - { + } else if (hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "componentBonusHigh")) { attribValue = getFloatObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "componentBonusHigh"); attribValue /= NEW_COMPONENT_MODIFIER; - if (attribValue > NEW_COMPONENT_CAP) - { + if (attribValue > NEW_COMPONENT_CAP) { attribValue = NEW_COMPONENT_CAP; CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::gasQualityLow on prototype(" + prototype + ")was higher than the cap of " + NEW_COMPONENT_CAP + ", so we lowered it to the cap."); } setObjVar(prototype, OBJVAR_MODIFIER_COMPONENT_BONUS_MAX, attribValue); } } - if (((itemAttributes[i].name).getAsciiId()).equals("meleeComponentQualityLow")) - { - if (hasObjVar(prototype, OBJVAR_MODIFIER_MELEE_QUALITY_MIN)) - { - if (!hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "meleeComponentQualityLow")) - { + if (((itemAttribute.name).getAsciiId()).equals("meleeComponentQualityLow")) { + if (hasObjVar(prototype, OBJVAR_MODIFIER_MELEE_QUALITY_MIN)) { + if (!hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "meleeComponentQualityLow")) { CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::we(" + prototype + ") dont have the objvar " + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "meleeComponentQualityLow"); attribValue = getFloatObjVar(prototype, OBJVAR_MODIFIER_MELEE_QUALITY_MIN); CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::new meleeComponentQualityLow value is " + attribValue); - } - else - { + } else { CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::we(" + prototype + ") have the objvar " + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "meleeComponentQualityLow"); attribValue /= NEW_COMPONENT_MODIFIER; CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::new meleeComponentQualityLow value is " + attribValue); } - if (attribValue > NEW_COMPONENT_CAP) - { + if (attribValue > NEW_COMPONENT_CAP) { attribValue = NEW_COMPONENT_CAP; setObjVar(prototype, OBJVAR_MODIFIER_MELEE_QUALITY_MIN, attribValue); CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::meleeComponentQualityLow on prototype(" + prototype + ")was higher than the cap of " + NEW_COMPONENT_CAP + ", so we lowered it to the cap."); } setObjVar(prototype, OBJVAR_MODIFIER_MELEE_QUALITY_MIN, attribValue); - } - else if (hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "meleeComponentQualityLow")) - { + } else if (hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "meleeComponentQualityLow")) { attribValue = getFloatObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "meleeComponentQualityLow"); attribValue /= NEW_COMPONENT_MODIFIER; - if (attribValue > NEW_COMPONENT_CAP) - { + if (attribValue > NEW_COMPONENT_CAP) { attribValue = NEW_COMPONENT_CAP; CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::gasQualityLow on prototype(" + prototype + ")was higher than the cap of " + NEW_COMPONENT_CAP + ", so we lowered it to the cap."); } setObjVar(prototype, OBJVAR_MODIFIER_MELEE_QUALITY_MIN, attribValue); } } - if (((itemAttributes[i].name).getAsciiId()).equals("meleeComponentQualityHigh")) - { - if (hasObjVar(prototype, OBJVAR_MODIFIER_MELEE_QUALITY_MAX)) - { - if (!hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "meleeComponentQualityHigh")) - { + if (((itemAttribute.name).getAsciiId()).equals("meleeComponentQualityHigh")) { + if (hasObjVar(prototype, OBJVAR_MODIFIER_MELEE_QUALITY_MAX)) { + if (!hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "meleeComponentQualityHigh")) { CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::we(" + prototype + ") dont have the objvar " + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "meleeComponentQualityHigh"); attribValue = getFloatObjVar(prototype, OBJVAR_MODIFIER_MELEE_QUALITY_MAX); CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::new meleeComponentQualityHigh value is " + attribValue); - } - else - { + } else { CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::we(" + prototype + ") have the objvar " + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "meleeComponentQualityHigh"); attribValue /= NEW_COMPONENT_MODIFIER; CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::new meleeComponentQualityHigh value is " + attribValue); } - if (attribValue > NEW_COMPONENT_CAP) - { + if (attribValue > NEW_COMPONENT_CAP) { attribValue = NEW_COMPONENT_CAP; setObjVar(prototype, OBJVAR_MODIFIER_MELEE_QUALITY_MAX, attribValue); CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::meleeComponentQualityHigh on prototype(" + prototype + ")was higher than the cap of " + NEW_COMPONENT_CAP + ", so we lowered it to the cap."); } setObjVar(prototype, OBJVAR_MODIFIER_MELEE_QUALITY_MAX, attribValue); - } - else if (hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "meleeComponentQualityHigh")) - { + } else if (hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "meleeComponentQualityHigh")) { attribValue = getFloatObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "meleeComponentQualityHigh"); attribValue /= NEW_COMPONENT_MODIFIER; - if (attribValue > NEW_COMPONENT_CAP) - { + if (attribValue > NEW_COMPONENT_CAP) { attribValue = NEW_COMPONENT_CAP; CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::gasQualityLow on prototype(" + prototype + ")was higher than the cap of " + NEW_COMPONENT_CAP + ", so we lowered it to the cap."); } setObjVar(prototype, OBJVAR_MODIFIER_MELEE_QUALITY_MAX, attribValue); } } - if (((itemAttributes[i].name).getAsciiId()).equals("coreQualityLow")) - { - if (hasObjVar(prototype, OBJVAR_WP_CORE_QUALITY_MIN)) - { - if (!hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreQualityLow")) - { + if (((itemAttribute.name).getAsciiId()).equals("coreQualityLow")) { + if (hasObjVar(prototype, OBJVAR_WP_CORE_QUALITY_MIN)) { + if (!hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreQualityLow")) { CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::we(" + prototype + ") dont have the objvar " + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreQualityLow"); attribValue = getFloatObjVar(prototype, OBJVAR_WP_CORE_QUALITY_MIN); CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::new gasQualityLow value is " + attribValue); - } - else - { + } else { CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::we(" + prototype + ") have the objvar " + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreQualityLow"); attribValue /= WP_CORE_MODIFIER; CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::new coreQualityLow value is " + attribValue); } setObjVar(prototype, OBJVAR_WP_CORE_QUALITY_MIN, attribValue); setObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreQualityLow", attribValue); - } - else if (hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreQualityLow")) - { + } else if (hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreQualityLow")) { attribValue = getFloatObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreQualityLow"); attribValue /= WP_CORE_MODIFIER; setObjVar(prototype, OBJVAR_WP_CORE_QUALITY_MIN, attribValue); } } - if (((itemAttributes[i].name).getAsciiId()).equals("coreQualityHigh")) - { - if (hasObjVar(prototype, OBJVAR_WP_CORE_QUALITY_MAX)) - { - if (!hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreQualityHigh")) - { + if (((itemAttribute.name).getAsciiId()).equals("coreQualityHigh")) { + if (hasObjVar(prototype, OBJVAR_WP_CORE_QUALITY_MAX)) { + if (!hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreQualityHigh")) { CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::we(" + prototype + ") dont have the objvar " + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreQualityHigh"); attribValue = getFloatObjVar(prototype, OBJVAR_WP_CORE_QUALITY_MAX); CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::new gasQualityHigh value is " + attribValue); - } - else - { + } else { CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::we(" + prototype + ") have the objvar " + craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreQualityHigh"); attribValue /= WP_CORE_MODIFIER; CustomerServiceLog("new_weapon_crafting", "setComponentObjVars::new coreQualityHigh value is " + attribValue); } setObjVar(prototype, OBJVAR_WP_CORE_QUALITY_MAX, attribValue); setObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreQualityHigh", attribValue); - } - else if (hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreQualityHigh")) - { + } else if (hasObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreQualityHigh")) { attribValue = getFloatObjVar(prototype, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + "." + "coreQualityHigh"); attribValue /= WP_CORE_MODIFIER; setObjVar(prototype, OBJVAR_WP_CORE_QUALITY_MAX, attribValue); @@ -2281,13 +2081,8 @@ public class weapons extends script.base_script } return true; } - public static boolean isCoredWeapon(obj_id weapon) throws InterruptedException - { - if (!isIdValid(weapon) || !exists(weapon)) - { - return false; - } - return hasObjVar(weapon, OBJVAR_NEW_WP_WEAPON); + public static boolean isCoredWeapon(obj_id weapon) throws InterruptedException { + return !(!isIdValid(weapon) || !exists(weapon)) && hasObjVar(weapon, OBJVAR_NEW_WP_WEAPON); } public static float getWeaponComponentBonusesMinDamage(obj_id weapon) throws InterruptedException { @@ -2345,26 +2140,17 @@ public class weapons extends script.base_script { return false; } - String template = getTemplateName(core); - if (template.equals("object/tangible/component/weapon/core/weapon_core_ranged_base.iff")) - { - return true; - } - else if (template.equals("object/tangible/component/weapon/core/weapon_core_ranged_advanced.iff")) - { - return true; - } - else if (template.equals("object/tangible/component/weapon/core/weapon_core_ranged_basic.iff")) - { - return true; - } - else if (template.equals("object/tangible/component/weapon/core/weapon_core_ranged_standard.iff")) - { - return true; - } - else - { - return false; + switch (getTemplateName(core)) { + case "object/tangible/component/weapon/core/weapon_core_ranged_base.iff": + return true; + case "object/tangible/component/weapon/core/weapon_core_ranged_advanced.iff": + return true; + case "object/tangible/component/weapon/core/weapon_core_ranged_basic.iff": + return true; + case "object/tangible/component/weapon/core/weapon_core_ranged_standard.iff": + return true; + default: + return false; } } public static boolean isHeavyCore(obj_id core) throws InterruptedException @@ -2373,22 +2159,15 @@ public class weapons extends script.base_script { return false; } - String template = getTemplateName(core); - if (template.equals("object/tangible/component/weapon/core/weapon_core_heavy_base.iff")) - { - return true; - } - else if (template.equals("object/tangible/component/weapon/core/weapon_core_heavy_advanced.iff")) - { - return true; - } - else if (template.equals("object/tangible/component/weapon/core/weapon_core_heavy_standard.iff")) - { - return true; - } - else - { - return false; + switch (getTemplateName(core)) { + case "object/tangible/component/weapon/core/weapon_core_heavy_base.iff": + return true; + case "object/tangible/component/weapon/core/weapon_core_heavy_advanced.iff": + return true; + case "object/tangible/component/weapon/core/weapon_core_heavy_standard.iff": + return true; + default: + return false; } } public static boolean isMeleeCore(obj_id core) throws InterruptedException @@ -2397,26 +2176,17 @@ public class weapons extends script.base_script { return false; } - String template = getTemplateName(core); - if (template.equals("object/tangible/component/weapon/core/weapon_core_melee_base.iff")) - { - return true; - } - else if (template.equals("object/tangible/component/weapon/core/weapon_core_melee_basic.iff")) - { - return true; - } - else if (template.equals("object/tangible/component/weapon/core/weapon_core_melee_standard.iff")) - { - return true; - } - else if (template.equals("object/tangible/component/weapon/core/weapon_core_melee_advanced.iff")) - { - return true; - } - else - { - return false; + switch (getTemplateName(core)) { + case "object/tangible/component/weapon/core/weapon_core_melee_base.iff": + return true; + case "object/tangible/component/weapon/core/weapon_core_melee_basic.iff": + return true; + case "object/tangible/component/weapon/core/weapon_core_melee_standard.iff": + return true; + case "object/tangible/component/weapon/core/weapon_core_melee_advanced.iff": + return true; + default: + return false; } } public static float verifyDamageRangeMin(obj_id weapon, float currentDamage, dictionary coreData) throws InterruptedException @@ -2543,8 +2313,8 @@ public class weapons extends script.base_script { return false; } - float coreBonus = 0.0f; - float craftedBonus = 0.0f; + float coreBonus; + float craftedBonus; int coreLevel = getCoreLevel(item); if (coreLevel <= 0) { @@ -2621,18 +2391,13 @@ public class weapons extends script.base_script if (isIdValid(player) && isIdValid(weapon)) { String weaponTemplate = getTemplateName(weapon); - if (weaponTemplate.indexOf("grenade") <= -1 && !utils.hasScriptVar(weapon, "illegalStorytellerWeapon")) + if (!weaponTemplate.contains("grenade") && !utils.hasScriptVar(weapon, "illegalStorytellerWeapon")) { String msg = "Weapon gained from a storyteller NPC via an exploit was detected in " + source + ". Player (" + player + ") and weapon | " + getName(weapon) + " | " + weaponTemplate + " | (" + weapon + ")."; CustomerServiceLog("storyteller_weapon_exploit", msg); CustomerServiceLog("storyteller_weapon_exploit", logWeaponStats(weapon)); - obj_id playerInv = utils.getInventoryContainer(player); - if (isIdValid(playerInv)) - { - } } } - return; } public static String logWeaponStats(obj_id weapon) throws InterruptedException { diff --git a/sku.0/sys.server/compiled/game/script/library/xp.java b/sku.0/sys.server/compiled/game/script/library/xp.java old mode 100644 new mode 100755 index c72f02838..ee791e623 --- a/sku.0/sys.server/compiled/game/script/library/xp.java +++ b/sku.0/sys.server/compiled/game/script/library/xp.java @@ -1,25 +1,9 @@ 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 java.lang.Math; -import java.util.*; -import script.library.beast_lib; -import script.library.buff; -import script.library.collection; -import script.library.combat; -import script.library.gcw; -import script.library.group; -import script.library.performance; -import script.library.pet_lib; -import script.library.space_flags; -import script.library.utils; +import java.util.Iterator; +import java.util.Vector; public class xp extends script.base_script { @@ -184,7 +168,7 @@ public class xp extends script.base_script { return 0; } - if (xp_type.indexOf(" ") > -1) + if (xp_type.contains(" ")) { return 0; } @@ -229,7 +213,7 @@ public class xp extends script.base_script { return false; } - if (xp_type.indexOf(" ") > -1) + if (xp_type.contains(" ")) { return false; } @@ -371,16 +355,13 @@ public class xp extends script.base_script String[] xpMods = dataTableGetStringColumn(TBL_SPECIES_XP, species); if (xpMods != null && xpMods.length > 0) { - for (int i = 0; i < xpMods.length; i++) - { - if (xpMods[i].startsWith(xp_type)) - { - String[] s = split(xpMods[i], ':'); - if ((s != null) && (s.length == 2)) - { + String[] s; + for (String xpMod : xpMods) { + if (xpMod.startsWith(xp_type)) { + s = split(xpMod, ':'); + if ((s != null) && (s.length == 2)) { int val = utils.stringToInt(s[1]); - if (val != -1) - { + if (val != -1) { return (100f + val) / 100f; } } @@ -397,10 +378,8 @@ public class xp extends script.base_script String[] xpList = utils.getStringArrayScriptVar(target, "buff.xpBonus.types"); if (xpList != null && xpList.length > 0) { - for (int i = 0; i < xpList.length; i++) - { - if (xpList[i].equals(xp_type)) - { + for (String aXpList : xpList) { + if (aXpList.equals(xp_type)) { mod += utils.getFloatScriptVar(target, "buff.xpBonus.value"); } } @@ -411,10 +390,8 @@ public class xp extends script.base_script String[] xpList = utils.getStringArrayScriptVar(target, "buff.xpBonusGeneral.types"); if (xpList != null && xpList.length > 0) { - for (int i = 0; i < xpList.length; i++) - { - if (xpList[i].equals(xp_type)) - { + for (String aXpList : xpList) { + if (aXpList.equals(xp_type)) { mod += utils.getFloatScriptVar(target, "buff.xpBonusGeneral.value"); } } @@ -432,7 +409,6 @@ public class xp extends script.base_script resultData.put("player", player); resultData.put("amt", amt); grant(player, SQUADLEADER, amt, false, "grantSquadLeaderXpResult", resultData, player); - return; } public static void grantSquadLeaderXpResult(obj_id player, int granted, int amt) throws InterruptedException { @@ -492,14 +468,11 @@ public class xp extends script.base_script return 1; } int count = 0; - for (int i = 0; i < members.length; i++) - { - if (members[i].isLoaded() && isPlayer(members[i])) - { + for (obj_id member : members) { + if (member.isLoaded() && isPlayer(member)) { count++; } - if (count >= MAX_GROUP_BONUS_COUNT) - { + if (count >= MAX_GROUP_BONUS_COUNT) { break; } } @@ -529,7 +502,7 @@ public class xp extends script.base_script float maxLevelDiff = 10f; if (level > 20) { - maxLevelDiff += (int)((level - 20) / 6); + maxLevelDiff += (level - 20) / 6; } xp += (int)(xp * (levelDiff / maxLevelDiff)); if (xp < 1) @@ -549,101 +522,81 @@ public class xp extends script.base_script } public static String getWeaponXpType(int weapon_type) throws InterruptedException { - String xp_type = "unknown_xp"; + String xp_type; switch (weapon_type) { case WEAPON_TYPE_RIFLE: - xp_type = COMBAT_RANGEDSPECIALIZE_RIFLE; - break; + xp_type = COMBAT_RANGEDSPECIALIZE_RIFLE; + break; case WEAPON_TYPE_LIGHT_RIFLE: - xp_type = COMBAT_RANGEDSPECIALIZE_CARBINE; - break; + xp_type = COMBAT_RANGEDSPECIALIZE_CARBINE; + break; case WEAPON_TYPE_PISTOL: - xp_type = COMBAT_RANGEDSPECIALIZE_PISTOL; - break; + xp_type = COMBAT_RANGEDSPECIALIZE_PISTOL; + break; case WEAPON_TYPE_HEAVY: case WEAPON_TYPE_GROUND_TARGETTING: case WEAPON_TYPE_DIRECTIONAL: - xp_type = COMBAT_RANGEDSPECIALIZE_RIFLE; - break; + xp_type = COMBAT_RANGEDSPECIALIZE_RIFLE; + break; case WEAPON_TYPE_1HAND_MELEE: - xp_type = COMBAT_MELEESPECIALIZE_ONEHAND; - break; + xp_type = COMBAT_MELEESPECIALIZE_ONEHAND; + break; case WEAPON_TYPE_2HAND_MELEE: - xp_type = COMBAT_MELEESPECIALIZE_TWOHAND; - break; + xp_type = COMBAT_MELEESPECIALIZE_TWOHAND; + break; case WEAPON_TYPE_UNARMED: - xp_type = COMBAT_MELEESPECIALIZE_UNARMED; - break; + xp_type = COMBAT_MELEESPECIALIZE_UNARMED; + break; case WEAPON_TYPE_POLEARM: - xp_type = COMBAT_MELEESPECIALIZE_POLEARM; - break; + xp_type = COMBAT_MELEESPECIALIZE_POLEARM; + break; case WEAPON_TYPE_THROWN: - xp_type = COMBAT_GRENADE; - break; + xp_type = COMBAT_GRENADE; + break; case WEAPON_TYPE_WT_1HAND_LIGHTSABER: - xp_type = COMBAT_MELEESPECIALIZE_ONEHAND; - break; + xp_type = COMBAT_MELEESPECIALIZE_ONEHAND; + break; case WEAPON_TYPE_WT_2HAND_LIGHTSABER: - xp_type = COMBAT_MELEESPECIALIZE_TWOHAND; - break; + xp_type = COMBAT_MELEESPECIALIZE_TWOHAND; + break; case WEAPON_TYPE_WT_POLEARM_LIGHTSABER: - xp_type = COMBAT_MELEESPECIALIZE_POLEARM; - break; + xp_type = COMBAT_MELEESPECIALIZE_POLEARM; + break; case combat.WEAPON_TYPE_FORCE_POWER: - xp_type = COMBAT_MELEESPECIALIZE_UNARMED; - break; + xp_type = COMBAT_MELEESPECIALIZE_UNARMED; + break; default: - xp_type = UNKNOWN; - break; + xp_type = UNKNOWN; + break; } return xp_type; } public static String getWeaponStringFromXPType(String strXPType) throws InterruptedException { - if (strXPType.equals(COMBAT_RANGEDSPECIALIZE_RIFLE)) - { - return "rifle"; - } - else if (strXPType.equals(COMBAT_RANGEDSPECIALIZE_CARBINE)) - { - return "carbine"; - } - else if (strXPType.equals(COMBAT_RANGEDSPECIALIZE_PISTOL)) - { - return "pistol"; - } - else if (strXPType.equals(COMBAT_RANGEDSPECIALIZE_HEAVY)) - { - return "heavy"; - } - else if (strXPType.equals(COMBAT_MELEESPECIALIZE_ONEHAND)) - { - return "onehandmelee"; - } - else if (strXPType.equals(COMBAT_MELEESPECIALIZE_TWOHAND)) - { - return "twohandmelee"; - } - else if (strXPType.equals(COMBAT_MELEESPECIALIZE_UNARMED)) - { - return "unarmed"; - } - else if (strXPType.equals(COMBAT_MELEESPECIALIZE_POLEARM)) - { - return "polearm"; - } - else if (strXPType.equals(COMBAT_JEDI_ONEHANDLIGHTSABER)) - { - return "onehandmelee"; - } - else if (strXPType.equals(COMBAT_JEDI_TWOHANDLIGHTSABER)) - { - return "twohandmelee"; - } - else if (strXPType.equals(COMBAT_JEDI_POLEARMLIGHTSABER)) - { - return "polearm"; + switch (strXPType) { + case COMBAT_RANGEDSPECIALIZE_RIFLE: + return "rifle"; + case COMBAT_RANGEDSPECIALIZE_CARBINE: + return "carbine"; + case COMBAT_RANGEDSPECIALIZE_PISTOL: + return "pistol"; + case COMBAT_RANGEDSPECIALIZE_HEAVY: + return "heavy"; + case COMBAT_MELEESPECIALIZE_ONEHAND: + return "onehandmelee"; + case COMBAT_MELEESPECIALIZE_TWOHAND: + return "twohandmelee"; + case COMBAT_MELEESPECIALIZE_UNARMED: + return "unarmed"; + case COMBAT_MELEESPECIALIZE_POLEARM: + return "polearm"; + case COMBAT_JEDI_ONEHANDLIGHTSABER: + return "onehandmelee"; + case COMBAT_JEDI_TWOHANDLIGHTSABER: + return "twohandmelee"; + case COMBAT_JEDI_POLEARMLIGHTSABER: + return "polearm"; } return ""; } @@ -653,8 +606,7 @@ public class xp extends script.base_script } public static boolean cleanupCreditForKills() throws InterruptedException { - obj_id self = getSelf(); - utils.removeScriptVarTree(self, VAR_CREDIT_FOR_KILLS); + utils.removeScriptVarTree(getSelf(), VAR_CREDIT_FOR_KILLS); return true; } public static void updateCombatXpList(obj_id target, obj_id attacker, obj_id wpn, int dam) throws InterruptedException @@ -805,7 +757,7 @@ public class xp extends script.base_script { damArray[i] = new obj_var(attackerList[i].toString(), utils.getIntScriptVar(target, VAR_ATTACKER_LIST + "." + attackerList[i] + ".damage")); } - if (damArray == null || damArray.length == 0) + if (damArray.length == 0) { return; } @@ -821,17 +773,14 @@ public class xp extends script.base_script } dictionary groupDamage = new dictionary(); int topDamage = Integer.MIN_VALUE; - int gDam = 0; - for (int i = 0; i < killers.length; i++) - { - obj_var attackerDamageVar = killers[i]; - obj_id attacker = utils.stringToObjId(attackerDamageVar.getName()); - if (isIdValid(attacker)) - { + int gDam; + obj_id attacker; + for (obj_var attackerDamageVar : killers) { + attacker = utils.stringToObjId(attackerDamageVar.getName()); + if (isIdValid(attacker)) { int attackerDamage = attackerDamageVar.getIntData(); gDam = updateGroupDamageDictionary(groupDamage, attacker, attackerDamage, target); - if (gDam > topDamage) - { + if (gDam > topDamage) { topDamage = gDam; } } @@ -839,13 +788,15 @@ public class xp extends script.base_script Vector primaryKillers = new Vector(); primaryKillers.setSize(0); java.util.Enumeration keys = groupDamage.keys(); + String key; + obj_id tmpId; while (keys.hasMoreElements()) { - String key = (String)(keys.nextElement()); + key = (String) (keys.nextElement()); int val = groupDamage.getInt(key); if (val >= topDamage) { - obj_id tmpId = utils.stringToObjId(key); + tmpId = utils.stringToObjId(key); if (isIdValid(tmpId)) { primaryKillers = utils.addElement(primaryKillers, tmpId); @@ -872,14 +823,10 @@ public class xp extends script.base_script } if (group.isGroupObject(winner)) { - for (int i = 0; i < killers.length; i++) - { - obj_var attackerDamageVar = killers[i]; - obj_id attacker = utils.stringToObjId(attackerDamageVar.getName()); - if (isIdValid(attacker)) - { - if (getGroupObject(attacker) == winner) - { + for (obj_var attackerDamageVar : killers) { + attacker = utils.stringToObjId(attackerDamageVar.getName()); + if (isIdValid(attacker)) { + if (getGroupObject(attacker) == winner) { incrementKillMeter(attacker, 1); } } @@ -890,12 +837,8 @@ public class xp extends script.base_script grantQuestKillCredit(winner, target); if (!hasObjVar(target, "combat.zeroXP")) { - obj_id[] killerList = new obj_id[0]; - if (primaryKillers != null) - { - killerList = new obj_id[primaryKillers.size()]; - primaryKillers.toArray(killerList); - } + obj_id[] killerList = new obj_id[primaryKillers.size()]; + primaryKillers.toArray(killerList); killers = grantCombatXp(target, killers); obj_id[] playerList = getPlayersFromKillerList(killerList); pet_lib.addToHarvestDroidArray(target, playerList); @@ -915,44 +858,30 @@ public class xp extends script.base_script { Vector players = new Vector(); players.setSize(0); - for (int i = 0; i < killerList.length; i++) - { - if (group.isGroupObject(killerList[i])) - { - obj_id[] groupMembers = utils.getGroupMemberIds(killerList[i]); - for (int k = 0; k < groupMembers.length; k++) - { - if (isIdValid(groupMembers[k]) && exists(groupMembers[k])) - { - if (pet_lib.isPet(groupMembers[k])) - { - utils.addElement(players, getMaster(groupMembers[k])); - } - else - { - utils.addElement(players, groupMembers[k]); + obj_id[] groupMembers; + for (obj_id aKillerList : killerList) { + if (group.isGroupObject(aKillerList)) { + groupMembers = utils.getGroupMemberIds(aKillerList); + for (obj_id groupMember : groupMembers) { + if (isIdValid(groupMember) && exists(groupMember)) { + if (pet_lib.isPet(groupMember)) { + utils.addElement(players, getMaster(groupMember)); + } else { + utils.addElement(players, groupMember); } } } - } - else - { - if (pet_lib.isPet(killerList[i])) - { - utils.addElement(players, getMaster(killerList[i])); - } - else - { - utils.addElement(players, killerList[i]); + } else { + if (pet_lib.isPet(aKillerList)) { + utils.addElement(players, getMaster(aKillerList)); + } else { + utils.addElement(players, aKillerList); } } } - if (players != null) - { - killerList = new obj_id[players.size()]; - players.toArray(killerList); + killerList = new obj_id[players.size()]; + players.toArray(killerList); - } return killerList; } public static void grantQuestKillCredit(obj_id winner, obj_id target) throws InterruptedException @@ -987,30 +916,23 @@ public class xp extends script.base_script { params.put("spawnedBy", getObjIdObjVar(target, "quest_spawner.spawned_by")); } - for (int i = 0; i < killList.length; i++) - { - if (!hasObjVar(target, "soloCollection")) - { - if (!exists(killList[i]) || !isIdValid(killList[i])) - { + obj_id collectionOwner; + for (obj_id aKillList : killList) { + if (!hasObjVar(target, "soloCollection")) { + if (!exists(aKillList) || !isIdValid(aKillList)) { continue; } - float distance = getDistance(target, killList[i]); - if (distance < 128.0f && distance >= 0.0f) - { - messageTo(killList[i], "receiveCreditForKill", params, 0.0f, false); + float distance = getDistance(target, aKillList); + if (distance < 128.0f && distance >= 0.0f) { + messageTo(aKillList, "receiveCreditForKill", params, 0.0f, false); } - } - else - { - obj_id collectionOwner = getObjIdObjVar(target, "soloCollection"); - if (!exists(collectionOwner) || !isIdValid(collectionOwner)) - { + } else { + collectionOwner = getObjIdObjVar(target, "soloCollection"); + if (!exists(collectionOwner) || !isIdValid(collectionOwner)) { continue; } float distance = getDistance(target, collectionOwner); - if (distance < 128.0f && distance >= 0.0f) - { + if (distance < 128.0f && distance >= 0.0f) { messageTo(collectionOwner, "receiveCreditForKill", params, 0.0f, false); } } @@ -1079,11 +1001,18 @@ public class xp extends script.base_script { allKillers[i] = utils.stringToObjId(killers[i].getName()); } + obj_var killerVar; + obj_id killer; + obj_id master; + obj_id gcw_gain_object; + obj_id beast; + dictionary params; + obj_id beastBCD; for (int i = 0; i < killers.length; i++) { - obj_var killerVar = killers[i]; - obj_id killer = allKillers[i]; - obj_id master = obj_id.NULL_ID; + killerVar = killers[i]; + killer = allKillers[i]; + master = obj_id.NULL_ID; if (beast_lib.isBeast(killer) && !ai_lib.aiIsDead(killer)) { master = getMaster(killer); @@ -1102,7 +1031,7 @@ public class xp extends script.base_script } } } - obj_id gcw_gain_object = null; + gcw_gain_object = null; if (isIdValid(master)) { if (!utils.isObjIdInArray(allKillers, master)) @@ -1126,15 +1055,15 @@ public class xp extends script.base_script xpTotal = applyGroupXpModifier(killer, xpTotal); if (isPlayer(killer) && beast_lib.isBeastMaster(killer)) { - obj_id beast = beast_lib.getBeastOnPlayer(killer); + beast = beast_lib.getBeastOnPlayer(killer); if (beast_lib.isValidBeast(beast) && getDistance(killer, beast) < MAX_DISTANCE && xpTotal > 1) { if (utils.isObjIdInArray(killList, killer) || utils.isObjIdInArray(killList, beast)) { beast_lib.grantBeastExperience(beast); - dictionary params = new dictionary(); + params = new dictionary(); params.put("targetId", target); - obj_id beastBCD = beast_lib.getBeastBCD(beast); + beastBCD = beast_lib.getBeastBCD(beast); messageTo(beastBCD, "beastKilledSomething", params, 1, false); } } @@ -1150,9 +1079,9 @@ public class xp extends script.base_script else { beast_lib.grantBeastExperience(killer); - dictionary params = new dictionary(); + params = new dictionary(); params.put("targetId", target); - obj_id beastBCD = beast_lib.getBeastBCD(killer); + beastBCD = beast_lib.getBeastBCD(killer); messageTo(beastBCD, "beastKilledSomething", params, 1, false); } } @@ -1194,12 +1123,8 @@ public class xp extends script.base_script { return null; } - obj_var[] _ret = new obj_var[0]; - if (ret != null) - { - _ret = new obj_var[ret.size()]; - ret.toArray(_ret); - } + obj_var[] _ret = new obj_var[ret.size()]; + ret.toArray(_ret); return _ret; } public static void grantCombatXpPerAttackType(obj_id player, obj_id target, int totalXp) throws InterruptedException @@ -1227,7 +1152,6 @@ public class xp extends script.base_script webster.put("target", target); messageTo(player, "handlePlayerCombatKill", webster, 1, false); } - dictionary d = new dictionary(); String damPath = basePath + ".damage"; int tally = utils.getIntScriptVar(target, damPath); tally -= utils.getIntScriptVar(target, xpListBasePath + "." + PERMISSIONS_ONLY); @@ -1240,62 +1164,44 @@ public class xp extends script.base_script int jediXp = 0; int generalXp = 0; int totalXpGranted = 0; - for (int i = 0; i < xpTypes.length; i++) - { - int val = utils.getIntScriptVar(target, xpListBasePath + "." + xpTypes[i]); - float xpPercent = ((float)(val) / (float)(tally)); + for (String xpType : xpTypes) { + int val = utils.getIntScriptVar(target, xpListBasePath + "." + xpType); + float xpPercent = ((float) (val) / (float) (tally)); int intNewTotal = totalXp; - if (xpTypes[i].equals(RAW_COMBAT)) - { - intNewTotal = (int)(intNewTotal * xpPercent); + if (xpType.equals(RAW_COMBAT)) { + intNewTotal = (int) (intNewTotal * xpPercent); bonusCombatXp += intNewTotal; - } - else if (xpTypes[i].equals(PARTIAL_COMBAT)) - { - intNewTotal = (int)(intNewTotal * xpPercent); - intNewTotal = (int)(intNewTotal * COMBAT_GENERAL_EXCHANGE_RATE); + } else if (xpType.equals(PARTIAL_COMBAT)) { + intNewTotal = (int) (intNewTotal * xpPercent); + intNewTotal = (int) (intNewTotal * COMBAT_GENERAL_EXCHANGE_RATE); bonusCombatXp += intNewTotal; - } - else if (xpTypes[i].equals(COMBAT_GENERAL)) - { - int amt = (int)(intNewTotal * xpPercent); - if (amt < 1) - { + } else if (xpType.equals(COMBAT_GENERAL)) { + int amt = (int) (intNewTotal * xpPercent); + if (amt < 1) { amt = 1; } generalXp += amt; - } - else if (isCombatXpType(xpTypes[i])) - { - int amt = (int)(intNewTotal * xpPercent); - if (amt < 1) - { + } else if (isCombatXpType(xpType)) { + int amt = (int) (intNewTotal * xpPercent); + if (amt < 1) { amt = 1; } - if (xpTypes[i].equals(COMBAT_JEDI_ONEHANDLIGHTSABER) || xpTypes[i].equals(COMBAT_JEDI_TWOHANDLIGHTSABER) || xpTypes[i].equals(COMBAT_JEDI_POLEARMLIGHTSABER) || xpTypes[i].equals(COMBAT_JEDI_FORCE_POWER) || xpTypes[i].equals(JEDI_GENERAL)) - { - if (isJedi(player)) - { + if (xpType.equals(COMBAT_JEDI_ONEHANDLIGHTSABER) || xpType.equals(COMBAT_JEDI_TWOHANDLIGHTSABER) || xpType.equals(COMBAT_JEDI_POLEARMLIGHTSABER) || xpType.equals(COMBAT_JEDI_FORCE_POWER) || xpType.equals(JEDI_GENERAL)) { + if (isJedi(player)) { jediXp += amt; } - } - else - { + } else { raw += amt; - if (!xpTypes[i].equals(COMBAT_THROWN)) - { - totalXpGranted += grantCombatStyleXp(player, xpTypes[i], amt); + if (!xpType.equals(COMBAT_THROWN)) { + totalXpGranted += grantCombatStyleXp(player, xpType, amt); } } - } - else if (!xpTypes[i].equals(UNKNOWN) && !xpTypes[i].equals(PERMISSIONS_ONLY) && !xpTypes[i].equals(PET_DAMAGE)) - { - int amt = (int)(intNewTotal * xpPercent); - if (amt < 1) - { + } else if (!xpType.equals(UNKNOWN) && !xpType.equals(PERMISSIONS_ONLY) && !xpType.equals(PET_DAMAGE)) { + int amt = (int) (intNewTotal * xpPercent); + if (amt < 1) { amt = 1; } - totalXpGranted += grantCombatStyleXp(player, xpTypes[i], amt); + totalXpGranted += grantCombatStyleXp(player, xpType, amt); } } if (isJedi(player)) @@ -1499,8 +1405,6 @@ public class xp extends script.base_script { return; } - prose_package pp = null; - pp = prose.getPackage(SID_FLYTEXT_XP, amount); float groupModPct = 1.0f; if (utils.hasScriptVar(player, "combat.xp.groupBonus")) { @@ -1509,16 +1413,13 @@ public class xp extends script.base_script } float flyScale = getCombatXpFlyScale(groupModPct); color flyColor = getCombatXpFlyColor(groupModPct); - showFlyTextPrivate(target, player, pp, flyScale, flyColor); + showFlyTextPrivate(target, player, prose.getPackage(SID_FLYTEXT_XP, amount), flyScale, flyColor); } public static float getGroupXpModifierPercentageOfMax(float groupMod) throws InterruptedException { - float groupModPct = 0; + float groupModPct; final float maxGroupMod = GROUP_XP_BONUS * MAX_GROUP_BONUS_COUNT; - if (maxGroupMod > 0) - { - groupModPct = (groupMod - 1) / maxGroupMod; - } + groupModPct = (groupMod - 1) / maxGroupMod; if (groupModPct > 1) { groupModPct = 1; @@ -1530,8 +1431,7 @@ public class xp extends script.base_script final float minScale = 1.5f; final float maxScale = 2.5f; final float scaleRange = maxScale - minScale; - float scale = minScale + (scaleRange * groupModPct); - return scale; + return minScale + (scaleRange * groupModPct); } public static color getCombatXpFlyColor(float groupModPct) throws InterruptedException { @@ -1559,197 +1459,68 @@ public class xp extends script.base_script } public static boolean isCombatXpType(String xpType) throws InterruptedException { - if (xpType.equals(COMBAT_GENERAL)) - { - return true; - } - if (xpType.equals(COMBAT_RANGEDSPECIALIZE_RIFLE)) - { - return true; - } - if (xpType.equals(COMBAT_RANGEDSPECIALIZE_CARBINE)) - { - return true; - } - if (xpType.equals(COMBAT_RANGEDSPECIALIZE_PISTOL)) - { - return true; - } - if (xpType.equals(COMBAT_RANGEDSPECIALIZE_HEAVY)) - { - return true; - } - if (xpType.equals(COMBAT_MELEESPECIALIZE_ONEHAND)) - { - return true; - } - if (xpType.equals(COMBAT_MELEESPECIALIZE_TWOHAND)) - { - return true; - } - if (xpType.equals(COMBAT_MELEESPECIALIZE_UNARMED)) - { - return true; - } - if (xpType.equals(COMBAT_MELEESPECIALIZE_POLEARM)) - { - return true; - } - if (xpType.equals(COMBAT_THROWN)) - { - return true; - } - if (xpType.equals(COMBAT_GRENADE)) - { - return true; - } - if (xpType.equals(JEDI_GENERAL)) - { - return true; - } - if (xpType.equals(COMBAT_JEDI_ONEHANDLIGHTSABER)) - { - return true; - } - if (xpType.equals(COMBAT_JEDI_TWOHANDLIGHTSABER)) - { - return true; - } - if (xpType.equals(COMBAT_JEDI_POLEARMLIGHTSABER)) - { - return true; - } - if (xpType.equals(COMBAT_JEDI_FORCE_POWER)) - { - return true; - } - if (xpType.equals(MEDICAL)) - { - return true; - } - if (xpType.equals(COMBATMEDIC)) - { - return true; - } - if (xpType.equals(CREATUREHANDLER)) - { - return true; - } - if (xpType.equals(QUEST_COMBAT)) - { - return true; - } - if (xpType.equals(QUEST_GENERAL)) - { - return true; + switch (xpType) { + case COMBAT_GENERAL: + case COMBAT_RANGEDSPECIALIZE_RIFLE: + case COMBAT_RANGEDSPECIALIZE_CARBINE: + case COMBAT_RANGEDSPECIALIZE_PISTOL: + case COMBAT_RANGEDSPECIALIZE_HEAVY: + case COMBAT_MELEESPECIALIZE_ONEHAND: + case COMBAT_MELEESPECIALIZE_TWOHAND: + case COMBAT_MELEESPECIALIZE_UNARMED: + case COMBAT_MELEESPECIALIZE_POLEARM: + case COMBAT_THROWN: + case COMBAT_GRENADE: + case JEDI_GENERAL: + case COMBAT_JEDI_ONEHANDLIGHTSABER: + case COMBAT_JEDI_TWOHANDLIGHTSABER: + case COMBAT_JEDI_POLEARMLIGHTSABER: + case COMBAT_JEDI_FORCE_POWER: + case MEDICAL: + case COMBATMEDIC: + case CREATUREHANDLER: + case QUEST_COMBAT: + case QUEST_GENERAL: + return true; } return false; } public static boolean isSocialXpType(String xpType) throws InterruptedException { - if (xpType.equals(MUSIC)) - { - return true; - } - if (xpType.equals(DANCE)) - { - return true; - } - if (xpType.equals(JUGGLING)) - { - return true; - } - if (xpType.equals(ENTERTAINER)) - { - return true; - } - if (xpType.equals(IMAGEDESIGNER)) - { - return true; - } - if (xpType.equals(QUEST_SOCIAL)) - { - return true; - } - if (xpType.equals(QUEST_COMBAT)) - { - return true; - } - if (xpType.equals(QUEST_GENERAL)) - { - return true; + switch (xpType) { + case MUSIC: + case DANCE: + case JUGGLING: + case ENTERTAINER: + case IMAGEDESIGNER: + case QUEST_SOCIAL: + case QUEST_COMBAT: + case QUEST_GENERAL: + return true; } return false; } public static boolean isCraftingXpType(String xpType) throws InterruptedException { - if (xpType.equals(HARVEST_INORGANIC)) - { - return true; - } - if (xpType.equals(CRAFTING_GENERAL)) - { - return true; - } - if (xpType.equals(CRAFTING_FOOD_GENERAL)) - { - return true; - } - if (xpType.equals(CRAFTING_MEDICINE_GENERAL)) - { - return true; - } - if (xpType.equals(CRAFTING_CLOTHING_ARMOR)) - { - return true; - } - if (xpType.equals(CRAFTING_CLOTHING_GENERAL)) - { - return true; - } - if (xpType.equals(CRAFTING_WEAPONS_GENERAL)) - { - return true; - } - if (xpType.equals(CRAFTING_WEAPONS_MELEE)) - { - return true; - } - if (xpType.equals(CRAFTING_WEAPONS_RANGED)) - { - return true; - } - if (xpType.equals(CRAFTING_WEAPONS_MUNITION)) - { - return true; - } - if (xpType.equals(CRAFTING_STRUCTURE_GENERAL)) - { - return true; - } - if (xpType.equals(CRAFTING_DROID_GENERAL)) - { - return true; - } - if (xpType.equals(CRAFTING_SHIPWRIGHT)) - { - return true; - } - if (xpType.equals(MERCHANT)) - { - return true; - } - if (xpType.equals(QUEST_CRAFTING)) - { - return true; - } - if (xpType.equals(QUEST_GENERAL)) - { - return true; - } - if (xpType.equals("crafting")) - { - return true; + switch (xpType) { + case HARVEST_INORGANIC: + case CRAFTING_GENERAL: + case CRAFTING_FOOD_GENERAL: + case CRAFTING_MEDICINE_GENERAL: + case CRAFTING_CLOTHING_ARMOR: + case CRAFTING_CLOTHING_GENERAL: + case CRAFTING_WEAPONS_GENERAL: + case CRAFTING_WEAPONS_MELEE: + case CRAFTING_WEAPONS_RANGED: + case CRAFTING_WEAPONS_MUNITION: + case CRAFTING_STRUCTURE_GENERAL: + case CRAFTING_DROID_GENERAL: + case CRAFTING_SHIPWRIGHT: + case MERCHANT: + case QUEST_CRAFTING: + case QUEST_GENERAL: + case "crafting": + return true; } return false; } @@ -1764,13 +1535,9 @@ public class xp extends script.base_script { return null; } - for (int i = 0; i < colXpType.length; i++) - { - String type = colXpType[i]; - if (type != null && !type.equals("") && !type.equals("unobtainable") && !type.equals("jedi")) - { - if (utils.getElementPositionInArray(xpTypes, type) == -1) - { + for (String type : colXpType) { + if (type != null && !type.equals("") && !type.equals("unobtainable") && !type.equals("jedi")) { + if (utils.getElementPositionInArray(xpTypes, type) == -1) { xpTypes = utils.addElement(xpTypes, type); } } @@ -1797,37 +1564,32 @@ public class xp extends script.base_script LOG("missions", "null missions"); return; } - for (int intI = 0; intI < objMissions.length; intI++) - { - String strMissionType = getMissionType(objMissions[intI]); + String strMissionType; + String strCreatureToKill; + string_id strName; + for (obj_id objMission : objMissions) { + strMissionType = getMissionType(objMission); LOG("missions", "type is " + strMissionType); - if (strMissionType.equals("hunting")) - { - String strCreatureToKill = getStringObjVar(objMissions[intI], "strCreatureToKill"); + if (strMissionType.equals("hunting")) { + strCreatureToKill = getStringObjVar(objMission, "strCreatureToKill"); final String strCreatureType = getCreatureName(objCreature); LOG("missions", "creature to kill is " + strCreatureToKill); LOG("missions", "creature type is " + strCreatureType); - if (strCreatureType.equals(strCreatureToKill)) - { - int intQuantityToKill = getIntObjVar(objMissions[intI], "intQuantityToKill"); + if (strCreatureType.equals(strCreatureToKill)) { + int intQuantityToKill = getIntObjVar(objMission, "intQuantityToKill"); intQuantityToKill = intQuantityToKill - 1; - if (intQuantityToKill <= 0) - { - messageTo(objMissions[intI], "huntingSuccess", null, 0, true); - } - else - { + if (intQuantityToKill <= 0) { + messageTo(objMission, "huntingSuccess", null, 0, true); + } else { LOG("missions", "Quanitty Ledft is " + intQuantityToKill); - setObjVar(objMissions[intI], "intQuantityToKill", intQuantityToKill); - string_id strName = new string_id("mob/creature_names", strCreatureType); - prose_package ppKillsLeft = prose.getPackage(new string_id("mission/mission_generic", "hunting_kills_remaining"), strName, intQuantityToKill); - sendSystemMessageProse(objPlayer, ppKillsLeft); + setObjVar(objMission, "intQuantityToKill", intQuantityToKill); + strName = new string_id("mob/creature_names", strCreatureType); + sendSystemMessageProse(objPlayer, prose.getPackage(new string_id("mission/mission_generic", "hunting_kills_remaining"), strName, intQuantityToKill)); return; } } } } - return; } public static obj_id[] getTopIndividualAttacker(obj_var[] killers) throws InterruptedException { @@ -1852,9 +1614,10 @@ public class xp extends script.base_script if (alphaValue > omegaValue) { tempArray = utils.addElement(tempArray, alphaObjId); + obj_var next; for (int a = 1; a < killers.length; a++) { - obj_var next = killers[a]; + next = killers[a]; int nextValue = next.getIntData(); if (nextValue == alphaValue) { @@ -1869,9 +1632,10 @@ public class xp extends script.base_script else if (alphaValue < omegaValue) { tempArray = utils.addElement(tempArray, omegaObjId); + obj_var next; for (int om = (killers.length - 2); om >= 0; om--) { - obj_var next = killers[om]; + next = killers[om]; int nextValue = next.getIntData(); if (nextValue == omegaValue) { @@ -1884,8 +1648,7 @@ public class xp extends script.base_script } } } - obj_id[] topAttacker = utils.toStaticObjIdArray(tempArray); - return topAttacker; + return utils.toStaticObjIdArray(tempArray); } public static boolean displayForceSensitiveXP(obj_id player, String type) throws InterruptedException { @@ -1931,7 +1694,7 @@ public class xp extends script.base_script utils.setScriptVar(player, "force_sensitive.xp_convert_type", type); for (int i = 0; i < valid_xp_types.size(); i++) { - dsrc[i] = "@exp_n:" + ((String)valid_xp_types.get(i)); + dsrc[i] = "@exp_n:" + valid_xp_types.get(i); } if (!hasScript(player, "quest.force_sensitive.fs_xp_convert")) { @@ -2013,7 +1776,7 @@ public class xp extends script.base_script public static int grantXpByTemplate(obj_id player, int amount) throws InterruptedException { String template = getSkillTemplate(player); - String xpType = xp.QUEST_COMBAT; + String xpType; if (!isIdValid(player) || template == null) { return 0; @@ -2040,7 +1803,7 @@ public class xp extends script.base_script public static int grantUnmodifiedXpByTemplate(obj_id player, int amount) throws InterruptedException { String template = getSkillTemplate(player); - String xpType = xp.QUEST_COMBAT; + String xpType; if (!isIdValid(player) || template == null) { return 0; @@ -2163,7 +1926,7 @@ public class xp extends script.base_script } public static int grantCollectionXP(obj_id player, String collectionName) throws InterruptedException { - float xpToGrant = 0; + float xpToGrant; int playerLevel = getLevel(player); if (playerLevel == 90) { @@ -2198,9 +1961,9 @@ public class xp extends script.base_script { return 0; } - float xpToGrant = 0.0f; - int xpForCurrentLevel = -1; - int xpForNextLevel = -1; + float xpToGrant; + int xpForCurrentLevel; + int xpForNextLevel; if (space_flags.hasCompletedTierFour(player)) { String tierFourSkill = profPrefix + space_flags.SKILL_NAMES[space_flags.TIER4_INDEXSTART]; @@ -2253,7 +2016,7 @@ public class xp extends script.base_script } public static float repeatCollectionXpModifier(obj_id player, long repeatSlotValue) throws InterruptedException { - float repeatMultiplier = 0.0f; + float repeatMultiplier; float adjustedRepeatSlotValue = (float)repeatSlotValue / 10.0f; repeatMultiplier = 1.0f - adjustedRepeatSlotValue; if (repeatMultiplier < 0.1f) diff --git a/sku.0/sys.server/compiled/game/script/systems/spawning/dropship/base.java b/sku.0/sys.server/compiled/game/script/systems/spawning/dropship/base.java old mode 100644 new mode 100755 index b832527f5..dc9afcd7c --- a/sku.0/sys.server/compiled/game/script/systems/spawning/dropship/base.java +++ b/sku.0/sys.server/compiled/game/script/systems/spawning/dropship/base.java @@ -1,12 +1,6 @@ package script.systems.spawning.dropship; -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.obj_id; public class base extends script.base_script { diff --git a/sku.0/sys.server/compiled/game/script/systems/spawning/dropship/emperorsday_lambda.java b/sku.0/sys.server/compiled/game/script/systems/spawning/dropship/emperorsday_lambda.java old mode 100644 new mode 100755 index da659ef83..2b36f1702 --- a/sku.0/sys.server/compiled/game/script/systems/spawning/dropship/emperorsday_lambda.java +++ b/sku.0/sys.server/compiled/game/script/systems/spawning/dropship/emperorsday_lambda.java @@ -1,15 +1,8 @@ package script.systems.spawning.dropship; -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.library.create; -import script.library.utils; +import script.dictionary; +import script.location; +import script.obj_id; public class emperorsday_lambda extends script.systems.spawning.dropship.base { @@ -39,9 +32,8 @@ public class emperorsday_lambda extends script.systems.spawning.dropship.base blog("emperorsday_lambda.changePosture: Init"); setPosture(self, POSTURE_UPRIGHT); location ownLocation = getLocation(self); - location behind = ownLocation; - behind.z = ownLocation.z - 20.0f; - faceTo(self, behind); + ownLocation.z = ownLocation.z - 20.0f; + faceTo(self, ownLocation); messageTo(self, "selfCleanUp", null, 60f, false); return SCRIPT_CONTINUE; } @@ -52,8 +44,7 @@ public class emperorsday_lambda extends script.systems.spawning.dropship.base if (isValidId(exitPoint)) { blog("emperorsday_lambda.changePosture: Facing to exit location"); - location exitLocation = getLocation(exitPoint); - faceTo(self, exitLocation); + faceTo(self, getLocation(exitPoint)); messageTo(self, "moveToExitPoint", null, 2, false); return SCRIPT_CONTINUE; } @@ -71,8 +62,7 @@ public class emperorsday_lambda extends script.systems.spawning.dropship.base } setMovementPercent(self, 16); blog("emperorsday_lambda.moveToExitPoint exit point valid"); - location loc = getLocation(exitPoint); - pathTo(self, loc); + pathTo(self, getLocation(exitPoint)); messageTo(self, "correctTakeOffThenCleanUp", null, 10, false); return SCRIPT_CONTINUE; } diff --git a/sku.0/sys.server/compiled/game/script/systems/spawning/dropship/emperorsday_yt1300.java b/sku.0/sys.server/compiled/game/script/systems/spawning/dropship/emperorsday_yt1300.java old mode 100644 new mode 100755 index dd8d4658c..c4be63e03 --- a/sku.0/sys.server/compiled/game/script/systems/spawning/dropship/emperorsday_yt1300.java +++ b/sku.0/sys.server/compiled/game/script/systems/spawning/dropship/emperorsday_yt1300.java @@ -1,15 +1,7 @@ package script.systems.spawning.dropship; -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.library.utils; -import script.library.create; +import script.dictionary; +import script.obj_id; public class emperorsday_yt1300 extends script.systems.spawning.dropship.base { diff --git a/sku.0/sys.server/compiled/game/script/systems/spawning/dropship/lambda.java b/sku.0/sys.server/compiled/game/script/systems/spawning/dropship/lambda.java old mode 100644 new mode 100755 index f97f71ae2..18ec202f2 --- a/sku.0/sys.server/compiled/game/script/systems/spawning/dropship/lambda.java +++ b/sku.0/sys.server/compiled/game/script/systems/spawning/dropship/lambda.java @@ -1,17 +1,13 @@ package script.systems.spawning.dropship; -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.library.utils; +import script.dictionary; import script.library.ai_lib; import script.library.create; -import script.library.gcw; +import script.library.utils; +import script.location; +import script.obj_id; + +import java.util.Vector; public class lambda extends script.systems.spawning.dropship.base { @@ -49,9 +45,10 @@ public class lambda extends script.systems.spawning.dropship.base obj_id leader = null; Vector spawns = new Vector(); spawns.setSize(0); + obj_id thisSpawn; for (int i = 0; i < spawnNames.length; i++) { - obj_id thisSpawn = create.object(spawnNames[i], here); + thisSpawn = create.object(spawnNames[i], here); if (isIdValid(thisSpawn) && !isIdValid(leader)) { leader = thisSpawn; diff --git a/sku.0/sys.server/compiled/game/script/systems/spawning/dropship/player_shuttle.java b/sku.0/sys.server/compiled/game/script/systems/spawning/dropship/player_shuttle.java old mode 100644 new mode 100755 index b4fd2fe34..48a83919b --- a/sku.0/sys.server/compiled/game/script/systems/spawning/dropship/player_shuttle.java +++ b/sku.0/sys.server/compiled/game/script/systems/spawning/dropship/player_shuttle.java @@ -1,15 +1,8 @@ package script.systems.spawning.dropship; -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.library.utils; -import script.library.ai_lib; +import script.dictionary; +import script.location; +import script.obj_id; public class player_shuttle extends script.systems.spawning.dropship.base { @@ -40,9 +33,8 @@ public class player_shuttle extends script.systems.spawning.dropship.base location locList[] = params.getLocationArray("explosionLocaitonList"); if (locList != null && locList.length > 0) { - for (int i = 0; i < locList.length; i++) - { - playClientEffectLoc(self, "clienteffect/combat_explosion_lair_large.cef", locList[i], 0); + for (location aLocList : locList) { + playClientEffectLoc(self, "clienteffect/combat_explosion_lair_large.cef", aLocList, 0); } } messageTo(self, "destroySelf", null, 0, false); diff --git a/sku.0/sys.server/compiled/game/script/systems/spawning/imperial/probot_egg.java b/sku.0/sys.server/compiled/game/script/systems/spawning/imperial/probot_egg.java old mode 100644 new mode 100755 index e7809a491..5b92c9b0b --- a/sku.0/sys.server/compiled/game/script/systems/spawning/imperial/probot_egg.java +++ b/sku.0/sys.server/compiled/game/script/systems/spawning/imperial/probot_egg.java @@ -1,17 +1,11 @@ package script.systems.spawning.imperial; -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.dictionary; import script.library.attrib; -import script.library.utils; import script.library.create; import script.library.pet_lib; +import script.library.utils; +import script.obj_id; public class probot_egg extends script.base_script { @@ -75,22 +69,12 @@ public class probot_egg extends script.base_script messageTo(self, "handleSpawnProbot", params, 1f, false); return SCRIPT_CONTINUE; } - int x = 0; - if (x <= 6) - { - obj_id probot = create.object("imperial_probot_drone", getLocation(self)); - if (isIdValid(probot)) - { - attachScript(probot, "ai.override_behavior.scout"); - messageTo(probot, "handleTargetAssignment", params, 1f, false); - } - } - else if (x <= 9) - { - } - else - { - } + obj_id probot = create.object("imperial_probot_drone", getLocation(self)); + if (isIdValid(probot)) + { + attachScript(probot, "ai.override_behavior.scout"); + messageTo(probot, "handleTargetAssignment", params, 1f, false); + } destroyObject(self); return SCRIPT_CONTINUE; } diff --git a/sku.0/sys.server/compiled/game/script/systems/spawning/mob_spawner.java b/sku.0/sys.server/compiled/game/script/systems/spawning/mob_spawner.java old mode 100644 new mode 100755 index fd11d34d5..80db36796 --- a/sku.0/sys.server/compiled/game/script/systems/spawning/mob_spawner.java +++ b/sku.0/sys.server/compiled/game/script/systems/spawning/mob_spawner.java @@ -1,20 +1,12 @@ package script.systems.spawning; -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.library.space_utils; -import script.library.planetary_map; +import script.dictionary; import script.library.create; -import script.library.objvar_mangle; import script.library.utils; -import java.lang.Math; -import script.library.hue; +import script.location; +import script.obj_id; + +import java.util.Vector; public class mob_spawner extends script.base_script { @@ -28,10 +20,8 @@ public class mob_spawner extends script.base_script } public int OnPreloadComplete(obj_id self) throws InterruptedException { - String strTest = "" + self; - location locTest = getLocation(self); - String strPlanet = locTest.area; - dictionary dctSpawnInfo = dataTableGetRow("datatables/spawning/ground_spawning/static/" + strPlanet + ".iff", strTest); + String strPlanet = getLocation(self).area; + dictionary dctSpawnInfo = dataTableGetRow("datatables/spawning/ground_spawning/static/" + strPlanet + ".iff", "" + self); if (dctSpawnInfo == null) { obj_id objTest = createObject("object/tangible/gravestone/gravestone01.iff", getLocation(self)); @@ -39,21 +29,17 @@ public class mob_spawner extends script.base_script return SCRIPT_CONTINUE; } String strType = dctSpawnInfo.getString("strType"); - String strMob = dctSpawnInfo.getString("strMob"); String strName = dctSpawnInfo.getString("strName"); float fltMinSpawnTime = dctSpawnInfo.getFloat("fltMinSpawnTime"); float fltMaxSpawnTime = dctSpawnInfo.getFloat("fltMaxSpawnTime"); Vector strScripts = new Vector(); strScripts.setSize(0); - String strMobToSpawn = ""; if (!strType.equals("")) { - String strFileName = "datatables/spawning/ground_spawning/types/" + strType + ".iff"; - String[] strSpawnList = dataTableGetStringColumnNoDefaults(strFileName, "strItem"); + String[] strSpawnList = dataTableGetStringColumnNoDefaults("datatables/spawning/ground_spawning/types/" + strType + ".iff", "strItem"); if ((strSpawnList == null) || (strSpawnList.length == 0)) { - obj_id objTest = createObject("object/tangible/gravestone/gravestone01.iff", getLocation(self)); - setName(objTest, "for object " + self + " bad entry of " + strType + " and planet " + strPlanet); + setName(createObject("object/tangible/gravestone/gravestone01.iff", getLocation(self)), "for object " + self + " bad entry of " + strType + " and planet " + strPlanet); return SCRIPT_CONTINUE; } utils.setScriptVar(self, "strSpawnList", strSpawnList); @@ -61,12 +47,13 @@ public class mob_spawner extends script.base_script else { String[] strSpawnList = new String[1]; - strSpawnList[0] = strMob; + strSpawnList[0] = dctSpawnInfo.getString("strMob"); utils.setScriptVar(self, "strSpawnList", strSpawnList); } + String strScript; for (int intI = 1; intI < 5; intI++) { - String strScript = dctSpawnInfo.getString("strScript" + intI); + strScript = dctSpawnInfo.getString("strScript" + intI); if (!strScript.equals("")) { strScripts = utils.addElement(strScripts, strScript); @@ -124,13 +111,10 @@ public class mob_spawner extends script.base_script } if ((strScripts != null) && (strScripts.length > 0)) { - for (int intI = 0; intI < strScripts.length; intI++) - { - if (!strScripts[intI].equals("")) - { - if (!hasScript(objNPC, strScripts[intI])) - { - attachScript(objNPC, strScripts[intI]); + for (String strScript : strScripts) { + if (!strScript.equals("")) { + if (!hasScript(objNPC, strScript)) { + attachScript(objNPC, strScript); } } } @@ -138,7 +122,6 @@ public class mob_spawner extends script.base_script attachScript(objNPC, "systems.spawning.mob_spawn_tracker"); utils.setScriptVar(objNPC, "objParent", self); utils.setScriptVar(objNPC, "fltRespawnTime", rand(fltMinSpawnTime, fltMaxSpawnTime)); - return; } public int respawnMob(obj_id self, dictionary params) throws InterruptedException { diff --git a/sku.0/sys.server/compiled/game/script/systems/spawning/patrol_point_setup.java b/sku.0/sys.server/compiled/game/script/systems/spawning/patrol_point_setup.java old mode 100644 new mode 100755 index 406dfcad3..b7c62a5ba --- a/sku.0/sys.server/compiled/game/script/systems/spawning/patrol_point_setup.java +++ b/sku.0/sys.server/compiled/game/script/systems/spawning/patrol_point_setup.java @@ -1,12 +1,7 @@ package script.systems.spawning; -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.dictionary; +import script.obj_id; public class patrol_point_setup extends script.base_script { diff --git a/sku.0/sys.server/compiled/game/script/systems/spawning/patrol_spawned_tracker.java b/sku.0/sys.server/compiled/game/script/systems/spawning/patrol_spawned_tracker.java old mode 100644 new mode 100755 index b45e9a327..366afffc5 --- a/sku.0/sys.server/compiled/game/script/systems/spawning/patrol_spawned_tracker.java +++ b/sku.0/sys.server/compiled/game/script/systems/spawning/patrol_spawned_tracker.java @@ -1,15 +1,10 @@ package script.systems.spawning; -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.dictionary; import script.library.ai_lib; import script.library.utils; +import script.location; +import script.obj_id; public class patrol_spawned_tracker extends script.base_script { diff --git a/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_base.java b/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_base.java old mode 100644 new mode 100755 index 2317b2045..ec3f2a357 --- a/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_base.java +++ b/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_base.java @@ -1,24 +1,10 @@ package script.systems.spawning; 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.library.*; -import script.library.skill; -import script.library.city; -import script.library.regions; -import script.library.locations; -import script.library.battlefield; -import script.library.utils; -import script.library.create; -import script.library.group; -import script.library.gcw; -import script.library.ai_lib; -import script.library.vehicle; +import java.util.Objects; +import java.util.Vector; public class spawn_base extends script.base_script { @@ -69,30 +55,26 @@ public class spawn_base extends script.base_script { return null; } - String strFileName = ""; - if (strRegion.equals("fictional")) - { - if ((strRegionName == null || strRegionName.equals("")) || (strPlanet == null || strPlanet.equals(""))) - { - return null; - } - strFileName = getFictionalRegionFileName(strPlanet, strRegionName); - } - else if (strRegion.equals("overload")) - { - if (strRegionName == null || strRegionName.equals("")) - { - return null; - } - strFileName = getOverLoadRegionFileName(strRegionName); - } - else - { - if (strPlanet == null || strPlanet.equals("")) - { - return null; - } - strFileName = "datatables/spawning/spawn_lists/" + strPlanet + "/" + strPlanet + "_" + strRegion + ".iff"; + String strFileName; + switch (strRegion) { + case "fictional": + if ((strRegionName == null || strRegionName.equals("")) || (strPlanet == null || strPlanet.equals(""))) { + return null; + } + strFileName = getFictionalRegionFileName(strPlanet, strRegionName); + break; + case "overload": + if (strRegionName == null || strRegionName.equals("")) { + return null; + } + strFileName = getOverLoadRegionFileName(strRegionName); + break; + default: + if (strPlanet == null || strPlanet.equals("")) { + return null; + } + strFileName = "datatables/spawning/spawn_lists/" + strPlanet + "/" + strPlanet + "_" + strRegion + ".iff"; + break; } if (strFileName == null) { @@ -125,10 +107,7 @@ public class spawn_base extends script.base_script } Vector validTemplateIndices = new Vector(); validTemplateIndices.setSize(0); - if (validTemplateIndices == null) - { - return null; - } + String strSpecificRegion; for (int i = 0; i < strTemplates.length; ++i) { int intMinDifficulty = intMinDifficulties[i]; @@ -138,7 +117,7 @@ public class spawn_base extends script.base_script int intGcwFaction = intGcwFactions[i]; int intGcwThreshold = intGcwThresholds[i]; int intGcwScoreType = intGcwScoreTypes[i]; - String strSpecificRegion = strGcwSpecificRegions == null || strGcwSpecificRegions.length == 0 ? "" : strGcwSpecificRegions[i]; + strSpecificRegion = strGcwSpecificRegions == null || strGcwSpecificRegions.length == 0 ? "" : strGcwSpecificRegions[i]; if (!checkGalacticCivilWarStandings(intGcwFaction, intGcwThreshold, intGcwScoreType, strSpecificRegion, currentLoc)) { continue; @@ -159,7 +138,7 @@ public class spawn_base extends script.base_script _validTemplateIndices = new int[validTemplateIndices.size()]; for (int _i = 0; _i < validTemplateIndices.size(); ++_i) { - _validTemplateIndices[_i] = ((Integer)validTemplateIndices.get(_i)).intValue(); + _validTemplateIndices[_i] = (Integer) validTemplateIndices.get(_i); } } return _validTemplateIndices; @@ -170,16 +149,13 @@ public class spawn_base extends script.base_script } public int getPlayerSpawnDiffibculty(obj_id objPlayer) throws InterruptedException { - obj_id objGroup = getGroupObject(objPlayer); - if (!isIdValid(objGroup)) + if (!isIdValid(getGroupObject(objPlayer))) { - int intPlayerLevel = getLevel(objPlayer); - return intPlayerLevel; + return getLevel(objPlayer); } else { - int intGroupLevel = skill.getGroupLevel(objPlayer); - return intGroupLevel; + return skill.getGroupLevel(objPlayer); } } public obj_id createTemplate(location locSpawnLocation, dictionary params, obj_id objPlayer) throws InterruptedException @@ -191,7 +167,6 @@ public class spawn_base extends script.base_script { return null; } - int intIndex = params.getInt("intIndex"); int intPlayerDifficulty = params.getInt("intPlayerDifficulty"); int intNumToSpawn = params.getInt("intNumToSpawn"); String strTemplateToSpawn = params.getString("strTemplateToSpawn"); @@ -239,7 +214,7 @@ public class spawn_base extends script.base_script if (strTemplate.indexOf("lair") > 0) { setObjVar(objCreatedTemplate, "numToSpawn", intNumToSpawn); - if (!strTemplateToSpawn.equals("") && strTemplateToSpawn != null) + if (!strTemplateToSpawn.equals("")) { setObjVar(objCreatedTemplate, "creatureTemplate", strTemplateToSpawn); } @@ -247,7 +222,7 @@ public class spawn_base extends script.base_script if (strTemplate.indexOf("herd") > 0) { setObjVar(objCreatedTemplate, "numToSpawn", intNumToSpawn); - if ((!strTemplateToSpawn.equals("")) && (strTemplateToSpawn != null)) + if ((!strTemplateToSpawn.equals(""))) { setObjVar(objCreatedTemplate, "creatureTemplate", strTemplateToSpawn); } @@ -270,22 +245,19 @@ public class spawn_base extends script.base_script public dictionary chooseWeightedSpawnTemplate(int[] intDataIndex, String strRegionName, String strPlanetName, region rgnRegion) throws InterruptedException { String strFileName; - if (strRegionName.equals("fictional")) - { - String strRegionFullName = rgnRegion.getName(); - strFileName = getFictionalRegionFileName(strPlanetName, strRegionFullName); + switch (strRegionName) { + case "fictional": + String strRegionFullName = rgnRegion.getName(); + strFileName = getFictionalRegionFileName(strPlanetName, strRegionFullName); + break; + case "overload": + strFileName = getOverLoadRegionFileName(strRegionName); + break; + default: + strFileName = "datatables/spawning/spawn_lists/" + strPlanetName + "/" + strPlanetName + "_" + strRegionName + ".iff"; + break; } - else if (strRegionName.equals("overload")) - { - strFileName = getOverLoadRegionFileName(strRegionName); - } - else - { - strFileName = "datatables/spawning/spawn_lists/" + strPlanetName + "/" + strPlanetName + "_" + strRegionName + ".iff"; - } - dictionary dctRegion = new dictionary(); String[] strTemplates = dataTableGetStringColumn(strFileName, "strTemplate"); - int[] intSpawnLimits = dataTableGetIntColumn(strFileName, "intSpawnLimit"); int[] intMinDifficulties = dataTableGetIntColumn(strFileName, "intMinDifficulty"); int[] intMaxDifficulties = dataTableGetIntColumn(strFileName, "intMaxDifficulty"); int[] intWeightings = dataTableGetIntColumn(strFileName, "intWeighting"); @@ -298,9 +270,8 @@ public class spawn_base extends script.base_script if (intDataIndex.length != 1) { int weightingGrandTotal = 0; - for (int i = 0; i < intDataIndex.length; ++i) - { - weightingGrandTotal += intWeightings[intDataIndex[i]]; + for (int anIntDataIndex : intDataIndex) { + weightingGrandTotal += intWeightings[anIntDataIndex]; } int randomValue = rand(0, weightingGrandTotal - 1); int previousChance = 0; @@ -330,9 +301,6 @@ public class spawn_base extends script.base_script } public void sendSpawnSpam(obj_id objPlayer, boolean boolLogFailures, boolean boolVerboseMode, String strSpam) throws InterruptedException { - if (boolLogFailures) - { - } if (boolVerboseMode && isIdValid(objPlayer)) { deltadictionary dctScriptVars = objPlayer.getScriptVars(); @@ -345,30 +313,17 @@ public class spawn_base extends script.base_script sendSystemMessageTestingOnly(objPlayer, strSpam); } } - return; } public boolean getVerboseMode(obj_id objPlayer) throws InterruptedException { - if (hasObjVar(objPlayer, "spawning.verboseMode")) - { - return true; - } - return false; + return hasObjVar(objPlayer, "spawning.verboseMode"); } public boolean checkTemplatesInRange(obj_id objPlayer, location locHome, boolean boolCheckForTheaters, String strObjectType) throws InterruptedException { - boolean boolLogFailures = checkSpawnLogFailures(); - boolean boolVerboseMode = getVerboseMode(objPlayer); - final int SPAWN_TEMPLATE_CHECK_DISTANCE = 128; - final int SPAWN_CHECK_TEMPLATE_LIMIT = 140; - final int SPAWN_THEATER_CHECK_DISTANCE = 200; - final int SPAWN_CHECK_THEATER_LIMIT = 1; return true; } public boolean canSpawn(obj_id objPlayer, location locSpawnLocation, boolean boolCheckForTheaters, String strObjectType) throws InterruptedException { - boolean boolLogFailures = checkSpawnLogFailures(); - boolean boolVerboseMode = getVerboseMode(objPlayer); if (!isSpawningAllowed(locSpawnLocation)) { return false; @@ -394,7 +349,7 @@ public class spawn_base extends script.base_script } } location locCurrentLocation = getLocation(objPlayer); - if (locCurrentLocation.area == "tutorial") + if (Objects.equals(locCurrentLocation.area, "tutorial")) { return false; } @@ -422,9 +377,9 @@ public class spawn_base extends script.base_script { boolean boolSpawnerIsOn; boolSpawnerIsOn = getBooleanObjVar(objMasterSpawner, "boolSpawnerIsOn"); - if (boolSpawnerIsOn == false) + if (!boolSpawnerIsOn) { - return boolSpawnerIsOn; + return false; } } if (locCurrentLocation.cell != obj_id.NULL_ID) @@ -475,7 +430,6 @@ public class spawn_base extends script.base_script public region getSpawnRegion(obj_id objPlayer) throws InterruptedException { location locTest = getLocation(objPlayer); - String strPlanet = locTest.area; region[] rgnRegionList = getRegionsWithSpawnableAtPoint(locTest, regions.SPAWN_TRUE); if (rgnRegionList == null) { @@ -486,10 +440,6 @@ public class spawn_base extends script.base_script return null; } region rgnSpawnRegion = locations.getSmallestRegion(rgnRegionList); - String strTestPlanet = rgnSpawnRegion.getPlanetName(); - if (!strTestPlanet.equals(strPlanet)) - { - } if (rgnSpawnRegion == null) { return null; @@ -511,20 +461,10 @@ public class spawn_base extends script.base_script } public void preLoadSpawnDataTables(obj_id objMasterSpawner) throws InterruptedException { - return; } - public boolean checkSpawnLogFailures() throws InterruptedException - { + public boolean checkSpawnLogFailures() throws InterruptedException { String strConfigSetting = getConfigSetting("GameServer", "fastSpawn"); - if (strConfigSetting == null) - { - return false; - } - if (strConfigSetting.equals("true")) - { - return true; - } - return false; + return strConfigSetting != null && strConfigSetting.equals("true"); } public boolean isSpawningAllowed(location locTest) throws InterruptedException { @@ -532,10 +472,8 @@ public class spawn_base extends script.base_script { return false; } - for (int i = 0; i < INVALID_SPAWNING_AREAS.length; ++i) - { - if (locTest.area == INVALID_SPAWNING_AREAS[i]) - { + for (String INVALID_SPAWNING_AREA : INVALID_SPAWNING_AREAS) { + if (locTest.area.equals(INVALID_SPAWNING_AREA)) { return false; } } @@ -543,10 +481,8 @@ public class spawn_base extends script.base_script } public String getFictionalRegionFileName(String strPlanet, String strFullName) throws InterruptedException { - string_id strId = utils.unpackString(strFullName); - String strRegionName = strId.getAsciiId(); - String strTableName = "datatables/spawning/spawn_lists/" + strPlanet + "/" + strRegionName + ".iff"; - return strTableName; + String strRegionName = utils.unpackString(strFullName).getAsciiId(); + return "datatables/spawning/spawn_lists/" + strPlanet + "/" + strRegionName + ".iff"; } public String getOverLoadRegionFileName(String strRegionName) throws InterruptedException { @@ -556,8 +492,7 @@ public class spawn_base extends script.base_script return ""; } String strFileName = strRegionName.substring(0, intIndex); - String strTableName = "datatables/spawning/spawn_lists/spawn_overloads/" + strFileName + ".iff"; - return strTableName; + return "datatables/spawning/spawn_lists/spawn_overloads/" + strFileName + ".iff"; } public void doSpawnEvent(dictionary params) throws InterruptedException { @@ -570,13 +505,12 @@ public class spawn_base extends script.base_script { return; } - int intPlayerDifficulty = params.getInt("intDifficulty"); String strRegionName = params.getString("strRegionName"); - String strPlanet = params.getString("strPlanet"); if (strRegionName == null || strRegionName.length() < 1) { return; } + String strPlanet = params.getString("strPlanet"); if (strPlanet == null || strPlanet.length() < 1) { return; @@ -599,51 +533,38 @@ public class spawn_base extends script.base_script { return; } - dictionary dctSpawnInformation = new dictionary(); - dctSpawnInformation = chooseWeightedSpawnTemplate(validSpawnIndices, strRegionType, strPlanet, rgnSpawnRegion); + dictionary dctSpawnInformation = chooseWeightedSpawnTemplate(validSpawnIndices, strRegionType, strPlanet, rgnSpawnRegion); if (dctSpawnInformation == null) { return; } - dctSpawnInformation.put("intPlayerDifficulty", intPlayerDifficulty); + dctSpawnInformation.put("intPlayerDifficulty", params.getInt("intDifficulty")); dctSpawnInformation.put("strRegionName", strRegionName); dctSpawnInformation.put("strPlanet", strPlanet); doSpawnTemplate(objPlayer, dctSpawnInformation); } public void doSpawnTemplate(obj_id self, dictionary params) throws InterruptedException { - String strTemplate = params.getString("strTemplate"); - int intIndex = params.getInt("intIndex"); - int intMinDifficulty = params.getInt("intMinDifficulty"); - int intMaxDifficulty = params.getInt("intMaxDifficulty"); - int intSize = params.getInt("intSize"); - int intNumToSpawn = params.getInt("intNumToSpawn"); String strLairType = params.getString("strLairType"); - String strBuildingType = params.getString("strBuildingType"); - String strTemplateToSpawn = params.getString("strBuildingType"); - String strRegionName = params.getString("strRegionName"); - String strPlanet = params.getString("strPlanet"); - int intPlayerDifficulty = params.getInt("intPlayerDifficulty"); dictionary dctParams = new dictionary(); location locSpawnLocation = getLocation(self); if (canSpawn(self, locSpawnLocation, true, strLairType)) { - dctParams.put("intMinDifficulty", intMinDifficulty); - dctParams.put("intMaxDifficulty", intMaxDifficulty); + dctParams.put("intMinDifficulty", params.getInt("intMinDifficulty")); + dctParams.put("intMaxDifficulty", params.getInt("intMaxDifficulty")); dctParams.put("strLairType", strLairType); - dctParams.put("strBuildingType", strBuildingType); - dctParams.put("strRegionName", strRegionName); - dctParams.put("strPlanet", strPlanet); - dctParams.put("intIndex", intIndex); - dctParams.put("intPlayerDifficulty", intPlayerDifficulty); - dctParams.put("intNumToSpawn", intNumToSpawn); - dctParams.put("strTemplateToSpawn", strTemplateToSpawn); - dctParams.put("strTemplate", strTemplate); - float fltSize = getLocationSize((float)intSize); + dctParams.put("strBuildingType", params.getString("strBuildingType")); + dctParams.put("strRegionName", params.getString("strRegionName")); + dctParams.put("strPlanet", params.getString("strPlanet")); + dctParams.put("intIndex", params.getInt("intIndex")); + dctParams.put("intPlayerDifficulty", params.getInt("intPlayerDifficulty")); + dctParams.put("intNumToSpawn", params.getInt("intNumToSpawn")); + dctParams.put("strTemplateToSpawn", params.getString("strBuildingType")); + dctParams.put("strTemplate", params.getString("strTemplate")); + float fltSize = getLocationSize((float)params.getInt("intSize")); utils.setScriptVar(self, "dctSpawnInfo", dctParams); requestLocation(self, "spawnLocation", locSpawnLocation, 100.0f, fltSize, true, false); } - return; } public int OnLocationReceived(obj_id self, String strId, obj_id objObject, location locSpawnLocation, float fltRadius) throws InterruptedException { @@ -713,17 +634,14 @@ public class spawn_base extends script.base_script region[] allRegions = getRegionsAtPoint(loc); if (allRegions != null && allRegions.length > 0) { - for (int iter = 0; iter < allRegions.length; ++iter) - { - region gcwRegion = allRegions[iter]; - if ((gcwRegion.getName()).startsWith("gcw")) - { + for (region gcwRegion : allRegions) { + if ((gcwRegion.getName()).startsWith("gcw")) { ImperialScore = getGcwImperialScorePercentile(toLower(gcwRegion.getName())); break; } } } - else + else { return false; } @@ -739,7 +657,7 @@ public class spawn_base extends script.base_script int ImperialScore = getGcwImperialScorePercentile(toLower(gcwSpecificRegion)); return isGalaticCivilWarWinner(gcwFaction, gcwThreshold, ImperialScore); } - else + else { return false; } diff --git a/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_egg_manager.java b/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_egg_manager.java old mode 100644 new mode 100755 index cc0bc81a6..5a88df994 --- a/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_egg_manager.java +++ b/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_egg_manager.java @@ -1,17 +1,7 @@ package script.systems.spawning; -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.library.space_create; -import script.library.ship_ai; import script.library.locations; -import script.library.utils; +import script.*; public class spawn_egg_manager extends script.base_script { @@ -34,7 +24,6 @@ public class spawn_egg_manager extends script.base_script LOG("spawn", "Spawning stuff"); setObjVar(self, "intNoDump", 1); location locTest = getLocation(self); - String strArea = locTest.area; String strDataTable = ""; String strName = locations.getCityName(locTest); if (strName != null) @@ -72,7 +61,7 @@ public class spawn_egg_manager extends script.base_script vector vctI = vctJ.cross(vctK); vctJ = vctK.cross(vctI); vector vctP = new vector(fltPX[intI], fltPY[intI], fltPZ[intI]); - transform tranCreation = new transform(); + transform tranCreation; try { tranCreation = new transform(vctI, vctJ, vctK, vctP); @@ -88,11 +77,7 @@ public class spawn_egg_manager extends script.base_script if (!strObject[intI].equals("")) { obj_id objTest = createObject(strObject[intI], tranCreation, null); - if ((!isIdValid(objTest)) || (!objTest.isLoaded())) - { - } - else - { + if ((isIdValid(objTest)) && (objTest.isLoaded())) { if (!strObjVars[intI].equals("")) { if ((isIdValid(objTest)) && (objTest.isLoaded())) @@ -103,19 +88,15 @@ public class spawn_egg_manager extends script.base_script if (!strScripts[intI].equals("")) { String[] strScriptArray = split(strScripts[intI], ','); - for (int intJ = 0; intJ < strScriptArray.length; intJ++) - { - if ((isIdValid(objTest)) && (objTest.isLoaded())) - { - String script = strScriptArray[intJ]; - if (script.indexOf("script.") > -1) - { + String script; + for (String aStrScriptArray : strScriptArray) { + if ((isIdValid(objTest)) && (objTest.isLoaded())) { + script = aStrScriptArray; + if (script.contains("script.")) { script = script.substring(7); } - if (!script.equals("")) - { - if (!hasScript(objTest, script)) - { + if (!script.equals("")) { + if (!hasScript(objTest, script)) { attachScript(objTest, script); } } diff --git a/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_master.java b/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_master.java old mode 100644 new mode 100755 index bb6894eaa..a50b79e6c --- a/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_master.java +++ b/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_master.java @@ -1,17 +1,6 @@ package script.systems.spawning; -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.library.regions; -import java.util.Set; -import java.util.Iterator; -import java.lang.Integer; +import script.obj_id; public class spawn_master extends script.systems.spawning.spawn_base { @@ -20,7 +9,6 @@ public class spawn_master extends script.systems.spawning.spawn_base } public int OnUniverseComplete(obj_id self) throws InterruptedException { - String strPlanet = getNameForPlanetObject(self); if (!hasObjVar(self, "boolSpawnerIsOn")) { setObjVar(self, "boolSpawnerIsOn", true); @@ -57,7 +45,6 @@ public class spawn_master extends script.systems.spawning.spawn_base } public int OnAttach(obj_id self) throws InterruptedException { - String strPlanet = getNameForPlanetObject(self); if (!hasObjVar(self, "boolSpawnerIsOn")) { setObjVar(self, "boolSpawnerIsOn", true); diff --git a/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_npc_lair_tracker.java b/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_npc_lair_tracker.java old mode 100644 new mode 100755 index d9aadfbee..e7c1505bb --- a/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_npc_lair_tracker.java +++ b/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_npc_lair_tracker.java @@ -1,12 +1,7 @@ package script.systems.spawning; -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.dictionary; +import script.obj_id; public class spawn_npc_lair_tracker extends script.base_script { diff --git a/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_player.java b/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_player.java old mode 100644 new mode 100755 index d7e8f244a..c5da3665a --- a/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_player.java +++ b/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_player.java @@ -1,25 +1,9 @@ package script.systems.spawning; 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.library.*; -import script.library.buff; -import script.library.craftinglib; -import script.library.create; -import script.library.datatable; -import script.library.group; -import script.library.locations; -import script.library.regions; -import script.library.skill; -import script.library.space_utils; -import script.library.spawning; -import script.library.sui; -import script.library.utils; +import java.util.Vector; public class spawn_player extends script.systems.spawning.spawn_base { @@ -103,8 +87,7 @@ public class spawn_player extends script.systems.spawning.spawn_base sendSystemMessageTestingOnly(self, strTable + " is not a valid dataTable"); return SCRIPT_CONTINUE; } - Integer ServerSpawnLimit = new Integer(0); - Integer intTestIndex = new Integer(0); + Integer intTestIndex; try { intTestIndex = new Integer(strNumber); @@ -114,17 +97,16 @@ public class spawn_player extends script.systems.spawning.spawn_base sendSystemMessageTestingOnly(self, strNumber + " is not a valid index"); return SCRIPT_CONTINUE; } - intIndex = intTestIndex.intValue(); + intIndex = intTestIndex; dictionary dctRow = dataTableGetRow(strTable, intIndex); if (dctRow == null) { sendSystemMessageTestingOnly(self, "Not a valid combination of data"); + return SCRIPT_CONTINUE; } int intMinDifficulty = dctRow.getInt("intMinDifficulty"); int intMaxDifficulty = dctRow.getInt("intMaxDifficulty"); int intPlayerDifficulty = rand(intMinDifficulty, intMaxDifficulty); - int intNumToSpawn = dctRow.getInt("intNumToSpawn"); - String strTemplateToSpawn = dctRow.getString("strTemplateToSpawn"); String strTemplate = dctRow.getString("strTemplate"); String strLairType = dctRow.getString("strLairType"); String strBuildingType = dctRow.getString("strBuildingType"); @@ -176,8 +158,7 @@ public class spawn_player extends script.systems.spawning.spawn_base sendSystemMessageTestingOnly(self, strTable + " is not a valid dataTable"); return SCRIPT_CONTINUE; } - Integer ServerSpawnLimit = new Integer(0); - Integer intTestIndex = new Integer(0); + Integer intTestIndex; try { intTestIndex = new Integer(strNumber); @@ -187,8 +168,7 @@ public class spawn_player extends script.systems.spawning.spawn_base sendSystemMessageTestingOnly(self, strNumber + " is not a valid index"); return SCRIPT_CONTINUE; } - intIndex = intTestIndex.intValue(); - Integer intTestDifficulty = new Integer(0); + intIndex = intTestIndex; try { intTestIndex = new Integer(strDifficultyInt); @@ -198,17 +178,15 @@ public class spawn_player extends script.systems.spawning.spawn_base sendSystemMessageTestingOnly(self, strDifficultyInt + " is not a valid index"); return SCRIPT_CONTINUE; } - int intLevel = intTestIndex.intValue(); + int intLevel = intTestIndex; dictionary dctRow = dataTableGetRow(strTable, intIndex); if (dctRow == null) { sendSystemMessageTestingOnly(self, "Not a valid combination of data"); + return SCRIPT_CONTINUE; } int intMinDifficulty = dctRow.getInt("intMinDifficulty"); int intMaxDifficulty = dctRow.getInt("intMaxDifficulty"); - int intPlayerDifficulty = rand(intMinDifficulty, intMaxDifficulty); - int intNumToSpawn = dctRow.getInt("intNumToSpawn"); - String strTemplateToSpawn = dctRow.getString("strTemplateToSpawn"); String strTemplate = dctRow.getString("strTemplate"); String strLairType = dctRow.getString("strLairType"); String strBuildingType = dctRow.getString("strBuildingType"); @@ -243,8 +221,7 @@ public class spawn_player extends script.systems.spawning.spawn_base } public int startSpawner(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException { - location locCurrentLocation = getLocation(self); - obj_id objMasterSpawner = getPlanetByName(locCurrentLocation.area); + obj_id objMasterSpawner = getPlanetByName(getLocation(self).area); if (objMasterSpawner == null) { return SCRIPT_CONTINUE; @@ -261,9 +238,7 @@ public class spawn_player extends script.systems.spawning.spawn_base } else { - boolean boolSpawnerIsOn; - boolSpawnerIsOn = getBooleanObjVar(objMasterSpawner, "boolSpawnerIsOn"); - if (boolSpawnerIsOn == false) + if (!getBooleanObjVar(objMasterSpawner, "boolSpawnerIsOn")) { setObjVar(objMasterSpawner, "boolSpawnerIsOn", true); sendSystemMessageTestingOnly(self, "The master spawner is now on!"); @@ -294,7 +269,6 @@ public class spawn_player extends script.systems.spawning.spawn_base spawning.activateSpawnerHack(self); return SCRIPT_CONTINUE; } - dictionary dctParams = new dictionary(); location locCurrentLocation = getLocation(self); if (locCurrentLocation == null) { @@ -302,12 +276,6 @@ public class spawn_player extends script.systems.spawning.spawn_base } if (canSpawn(self, locCurrentLocation, false, null)) { - dictionary dctSpawnParams = new dictionary(); - int intLevel = 0; - intLevel = skill.getGroupLevel(self); - intLevel = locations.normalizeDifficultyForRegion(intLevel, locCurrentLocation); - dctSpawnParams.put("intDifficulty", intLevel); - dctSpawnParams.put("objPlayer", self); region rgnSpawnRegion = getSpawnRegion(self); if (rgnSpawnRegion == null) { @@ -321,14 +289,15 @@ public class spawn_player extends script.systems.spawning.spawn_base LOG("DESIGNER_FATAL", "For region " + strRegionName + " planet is " + strPlanet); LOG("DESIGNER_FATAL", "But planet name for player is " + strTestPlanet); } + int intLevel = locations.normalizeDifficultyForRegion(skill.getGroupLevel(self), locCurrentLocation); + dictionary dctSpawnParams = new dictionary(); + dctSpawnParams.put("intDifficulty", intLevel); + dctSpawnParams.put("objPlayer", self); if (strRegionName != null) { dctSpawnParams.put("strRegionName", strRegionName); } - if (strPlanet != null) - { - dctSpawnParams.put("strPlanet", strPlanet); - } + dctSpawnParams.put("strPlanet", strPlanet); boolean boolTheatersAllowed = false; int intNumRules = getNumRunTimeRules(); if (intNumRules > 0) @@ -366,7 +335,7 @@ public class spawn_player extends script.systems.spawning.spawn_base } if (strCommands[0].equals("dumpBuildout")) { - String strDataTable = ""; + String strDataTable; if (strCommands.length > 1) { strDataTable = "datatables/spawning/ground_spawning/buildouts/" + strCommands[1] + ".tab"; @@ -378,19 +347,11 @@ public class spawn_player extends script.systems.spawning.spawn_base } location locTest = getLocation(self); obj_id objCell = locTest.cell; - boolean boolInBuilding = true; - if (!isIdValid(objCell)) - { - boolInBuilding = false; - } + boolean boolInBuilding = isIdValid(objCell); obj_id objBuilding = null; if (boolInBuilding) { objBuilding = getContainedBy(objCell); - if (!isIdValid(objBuilding)) - { - boolean boolInbuilding = false; - } } String[] strHeaderTypes = { @@ -424,13 +385,12 @@ public class spawn_player extends script.systems.spawning.spawn_base "strScripts", "strCellName" }; - boolean boolTest = datatable.createDataTable(strDataTable, strHeaders, strHeaderTypes); - if (!boolTest) + if (!datatable.createDataTable(strDataTable, strHeaders, strHeaderTypes)) { - sendSystemMessageTestingOnly(self, "No dattable made"); + sendSystemMessageTestingOnly(self, "No datatable made"); return SCRIPT_CONTINUE; } - obj_id[] objObjects = null; + obj_id[] objObjects; if (boolInBuilding) { objObjects = spawning.getAllContents(objBuilding); @@ -440,26 +400,13 @@ public class spawn_player extends script.systems.spawning.spawn_base objObjects = getAllObjectsWithObjVar(getLocation(self), 15000, "intSpawnLocation"); } sendSystemMessageTestingOnly(self, "dumping contents of " + objBuilding); - for (int intI = 0; intI < objObjects.length; intI++) - { - if (hasObjVar(objObjects[intI], "intSpawnLocation")) - { - dictionary dctRow = new dictionary(); - locTest = getLocation(objObjects[intI]); - String strTemplate = getTemplateName(objObjects[intI]); - float fltX = locTest.x; - float fltY = locTest.y; - float fltZ = locTest.z; - if (boolInBuilding) - { - String strCellName = space_utils.getCellName(objBuilding, locTest.cell); - dctRow.put("strCellName", strCellName); - } - else - { - dctRow.put("strCellName", ""); - } - transform vctTest = getTransform_o2p(objObjects[intI]); + dictionary dctRow; + for (obj_id objObject : objObjects) { + if (hasObjVar(objObject, "intSpawnLocation")) { + dctRow = new dictionary(); + locTest = getLocation(objObject); + dctRow.put("strCellName",(boolInBuilding ? space_utils.getCellName(objBuilding, locTest.cell) : "")); + transform vctTest = getTransform_o2p(objObject); vector vctJ = vctTest.getLocalFrameJ_p(); vector vctK = vctTest.getLocalFrameK_p(); vector vctP = vctTest.getPosition_p(); @@ -472,10 +419,10 @@ public class spawn_player extends script.systems.spawning.spawn_base dctRow.put("fltPX", vctP.x); dctRow.put("fltPY", vctP.y); dctRow.put("fltPZ", vctP.z); - dctRow.put("strTemplate", strTemplate); - String strObjVars = getPackedObjvars(objObjects[intI]); + dctRow.put("strTemplate", getTemplateName(objObject)); + String strObjVars = getPackedObjvars(objObject); dctRow.put("strObjVars", strObjVars); - String strScripts = utils.getPackedScripts(objObjects[intI]); + String strScripts = utils.getPackedScripts(objObject); dctRow.put("strScripts", strScripts); datatable.serverDataTableAddRow(strDataTable, dctRow); } @@ -484,9 +431,7 @@ public class spawn_player extends script.systems.spawning.spawn_base } if (strCommands[0].equals("addSpawnLocation")) { - transform trTest = getTransform_o2p(self); - location locTest = getLocation(self); - obj_id objSpawner = createObject("object/tangible/space/content_infrastructure/generic_egg_small.iff", trTest, locTest.cell); + obj_id objSpawner = createObject("object/tangible/space/content_infrastructure/generic_egg_small.iff", getTransform_o2p(self), getLocation(self).cell); setObjVar(objSpawner, "intSpawnLocation", 1); setName(objSpawner, "SPAWN LOCATION!"); sendSystemMessageTestingOnly(self, "Made spawn location"); @@ -527,7 +472,6 @@ public class spawn_player extends script.systems.spawning.spawn_base float fltSpawnerMinTime = utils.getFloatScriptVar(self, "fltMinSpawnTime"); float fltSpawnerMaxTime = utils.getFloatScriptVar(self, "fltMaxSpawnTime"); int intSpawnerBehavior = utils.getIntScriptVar(self, "intDefaultBehavior"); - int intSpawnerGoodLoc = utils.getIntScriptVar(self, "intGoodLocationSpawner"); String[] behaviors = { "wander", @@ -993,14 +937,12 @@ public class spawn_player extends script.systems.spawning.spawn_base Vector objPatrolPoints = utils.getResizeableObjIdArrayScriptVar(self, "objPatrolPoints"); if (objPatrolPoints != null) { - for (int intI = 0; intI < objPatrolPoints.size(); intI++) - { - destroyObject(((obj_id)objPatrolPoints.get(intI))); + for (Object objPatrolPoint : objPatrolPoints) { + destroyObject(((obj_id) objPatrolPoint)); } } } utils.removeScriptVar(self, "objPatrolPoints"); - return; } public void writeSpawner(obj_id self) throws InterruptedException { @@ -1008,8 +950,7 @@ public class spawn_player extends script.systems.spawning.spawn_base String strSpawnerType = utils.getStringScriptVar(self, "strType"); Vector patrolPoints = new Vector(); patrolPoints.setSize(0); - obj_id objSpawner = null; - String patrolPathType = null; + obj_id objSpawner; if (strSpawnerType.equals("area") || strSpawnerType.equals("location")) { transform trTest = getTransform_o2p(self); @@ -1076,11 +1017,7 @@ public class spawn_player extends script.systems.spawning.spawn_base } public boolean isValidSpawnerType(String strText) throws InterruptedException { - if (strText.equals("area") || strText.equals("patrol")) - { - return true; - } - return false; + return strText.equals("area") || strText.equals("patrol"); } public void handleMineFieldCreation() throws InterruptedException { @@ -1097,7 +1034,7 @@ public class spawn_player extends script.systems.spawning.spawn_base { packedMineStrings[i] = validMineTypes[i] + " DR[" + detonateRange[i] + "] BR[" + blastRadius[i] + "] MinD[" + minDamage[i] + "] MaxD[" + maxDamage[i] + "] DT [" + damageType[i] + "]"; } - if (validMineTypes != null && validMineTypes.length > 0) + if (validMineTypes.length > 0) { int pid = sui.listbox(user, user, "Select Mine Type", packedMineStrings, "handleSelectMineType"); if (pid > -1) @@ -1209,19 +1146,17 @@ public class spawn_player extends script.systems.spawning.spawn_base { return SCRIPT_CONTINUE; } - for (int i = 0; i < stations.length; ++i) - { - if (!isIdValid(stations[i])) - { + String buffName; + for (obj_id station : stations) { + if (!isIdValid(station)) { continue; } - int craftingType = getIntObjVar(stations[i], craftinglib.OBJVAR_CRAFTING_TYPE); - String buffName = craftinglib.getCraftingStationBuffName(craftingType); - if (buffName == null || buffName.equals("")) - { + int craftingType = getIntObjVar(station, craftinglib.OBJVAR_CRAFTING_TYPE); + buffName = craftinglib.getCraftingStationBuffName(craftingType); + if (buffName == null || buffName.equals("")) { continue; } - buff.applyBuff(self, stations[i], buffName); + buff.applyBuff(self, station, buffName); } } return SCRIPT_CONTINUE; diff --git a/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_tangible.java b/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_tangible.java old mode 100644 new mode 100755 index 6b0fd2fd1..0858666a1 --- a/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_tangible.java +++ b/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_tangible.java @@ -1,12 +1,8 @@ package script.systems.spawning; -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.dictionary; +import script.location; +import script.obj_id; public class spawn_tangible extends script.base_script { diff --git a/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_template.java b/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_template.java old mode 100644 new mode 100755 index f1805bfbe..46491ae54 --- a/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_template.java +++ b/sku.0/sys.server/compiled/game/script/systems/spawning/spawn_template.java @@ -1,12 +1,7 @@ package script.systems.spawning; -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.dictionary; +import script.obj_id; public class spawn_template extends script.systems.spawning.spawn_base { @@ -85,9 +80,7 @@ public class spawn_template extends script.systems.spawning.spawn_base int intNumberOfMobiles = getIntObjVar(objLair, "npc_lair.numberOfMobiles"); for (int intI = 0; intI < intNumberOfMobiles; intI++) { - obj_id objCreature = getObjIdObjVar(objLair, "npc_lair.mobile." + intNumberOfMobiles); - int intState = getState(objCreature, STATE_COMBAT); - if (intState > 0) + if (getState(getObjIdObjVar(objLair, "npc_lair.mobile." + intNumberOfMobiles), STATE_COMBAT) > 0) { return true; } diff --git a/sku.0/sys.server/compiled/game/script/systems/spawning/spawned_tracker.java b/sku.0/sys.server/compiled/game/script/systems/spawning/spawned_tracker.java old mode 100644 new mode 100755 index 7ceeef3ed..c89ddb704 --- a/sku.0/sys.server/compiled/game/script/systems/spawning/spawned_tracker.java +++ b/sku.0/sys.server/compiled/game/script/systems/spawning/spawned_tracker.java @@ -1,14 +1,9 @@ package script.systems.spawning; -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.dictionary; import script.library.utils; +import script.location; +import script.obj_id; public class spawned_tracker extends script.base_script { diff --git a/sku.0/sys.server/compiled/game/script/systems/spawning/spawner_area.java b/sku.0/sys.server/compiled/game/script/systems/spawning/spawner_area.java index 97fa0fecf..df276e5d0 100755 --- a/sku.0/sys.server/compiled/game/script/systems/spawning/spawner_area.java +++ b/sku.0/sys.server/compiled/game/script/systems/spawning/spawner_area.java @@ -1,18 +1,12 @@ package script.systems.spawning; -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.library.utils; +import script.dictionary; import script.library.ai_lib; -import script.library.space_utils; -import script.library.spawning; import script.library.create; +import script.library.spawning; +import script.library.utils; +import script.location; +import script.obj_id; public class spawner_area extends script.base_script { @@ -159,9 +153,7 @@ public class spawner_area extends script.base_script { return; } - float spawnerYaw = getYaw(self); int intIndex = strId.indexOf(".iff"); - float fltRespawnTime = getRespawnTime(self); if (isIdValid(objLocationObject)) { @@ -188,19 +180,19 @@ public class spawner_area extends script.base_script int intBehavior = getIntObjVar(self, "intDefaultBehavior"); ai_lib.setDefaultCalmBehavior(objTemplate, intBehavior); } + float fltRespawnTime = getRespawnTime(self); spawning.incrementSpawnCount(self); spawning.addToSpawnDebugList(self, objTemplate); setObjVar(objTemplate, "objParent", self); setObjVar(objTemplate, "fltRespawnTime", fltRespawnTime); attachScript(objTemplate, "systems.spawning.spawned_tracker"); - setYaw(objTemplate, spawnerYaw); + setYaw(objTemplate, getYaw(self)); if (!spawning.checkSpawnCount(self)) { return; } messageTo(self, "doSpawnEvent", null, fltRespawnTime, false); - return; } public int OnLocationReceived(obj_id self, String strId, obj_id objLocationObject, location locLocation, float fltRadius) throws InterruptedException { @@ -217,8 +209,8 @@ public class spawner_area extends script.base_script public int spawnDestroyed(obj_id self, dictionary params) throws InterruptedException { int intCurrentSpawnCount = utils.getIntScriptVar(self, "intCurrentSpawnCount"); - intCurrentSpawnCount = intCurrentSpawnCount - 1; - if (intCurrentSpawnCount > -1) + intCurrentSpawnCount--; + if (intCurrentSpawnCount >= 0) { utils.setScriptVar(self, "intCurrentSpawnCount", intCurrentSpawnCount); } @@ -251,11 +243,9 @@ public class spawner_area extends script.base_script { return SCRIPT_CONTINUE; } - for (int i = 0; i < spawns.length; ++i) - { - if (isIdValid(spawns[i]) && exists(spawns[i])) - { - messageTo(spawns[i], "selfDestruct", null, 5, false); + for (obj_id spawn : spawns) { + if (isIdValid(spawn) && exists(spawn)) { + messageTo(spawn, "selfDestruct", null, 5, false); } } } diff --git a/sku.0/sys.server/compiled/game/script/systems/spawning/spawner_find_node.java b/sku.0/sys.server/compiled/game/script/systems/spawning/spawner_find_node.java old mode 100644 new mode 100755 index 0dfe28f81..4d232431f --- a/sku.0/sys.server/compiled/game/script/systems/spawning/spawner_find_node.java +++ b/sku.0/sys.server/compiled/game/script/systems/spawning/spawner_find_node.java @@ -1,25 +1,7 @@ package script.systems.spawning; -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.library.buff; -import script.library.craftinglib; -import script.library.create; -import script.library.datatable; -import script.library.group; -import script.library.locations; -import script.library.regions; -import script.library.skill; -import script.library.space_utils; -import script.library.spawning; -import script.library.sui; -import script.library.utils; +import script.dictionary; +import script.obj_id; public class spawner_find_node extends script.base_script { diff --git a/sku.0/sys.server/compiled/game/script/systems/spawning/spawner_patrol.java b/sku.0/sys.server/compiled/game/script/systems/spawning/spawner_patrol.java old mode 100644 new mode 100755 index 6b1184dd1..7b52ec155 --- a/sku.0/sys.server/compiled/game/script/systems/spawning/spawner_patrol.java +++ b/sku.0/sys.server/compiled/game/script/systems/spawning/spawner_patrol.java @@ -1,18 +1,13 @@ package script.systems.spawning; -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.library.utils; +import script.dictionary; import script.library.ai_lib; -import script.library.space_utils; -import script.library.spawning; import script.library.create; +import script.library.spawning; +import script.library.utils; +import script.location; +import script.obj_id; + import java.util.Vector; public class spawner_patrol extends script.base_script @@ -51,7 +46,6 @@ public class spawner_patrol extends script.base_script { return SCRIPT_CONTINUE; } - int intGoodLocationSpawner = getIntObjVar(self, "intGoodLocationSpawner"); String strSpawnType = getStringObjVar(self, "strSpawns"); String[] strSpawns = { @@ -90,7 +84,6 @@ public class spawner_patrol extends script.base_script LOG("spawning", "ERROR: patrolArray script var not defined."); return SCRIPT_CONTINUE; } - int spawnNum = params.getInt("spawnNum"); int maxSpawns = getIntObjVar(self, "intSpawnCount"); if (maxSpawns >= patrolPoints.length) { @@ -100,16 +93,14 @@ public class spawner_patrol extends script.base_script Vector goodSpawns = new Vector(); for (int i = 0; i < fltSizes.length; ++i) { - goodSpawns.addElement(new Integer(i)); + goodSpawns.addElement(i); } int spawnCount = 0; while (spawnCount < maxSpawns) { int roll = rand(0, goodSpawns.size() - 1); - int rowIndex = ((Integer)goodSpawns.get(roll)).intValue(); - float size = fltSizes[rowIndex]; + int rowIndex = (Integer) goodSpawns.get(roll); String spawn = strSpawns[rowIndex]; - size = getClosestSize(size); location locTest = patrolPoints[spawnCount]; if (createMob(spawn, null, locTest, 0.0f, self, false, spawnCount)) { @@ -148,7 +139,7 @@ public class spawner_patrol extends script.base_script float[] fltSizes = dataTableGetFloatColumn(strFileName, "fltSize"); if ((strSpawns == null) || (strSpawns.length == 0)) { - setName(self, "Mangled spawner. strFileName is " + strFileName + " I couldnt find any spawns in that file."); + setName(self, "Mangled spawner. strFileName is " + strFileName + " I couldn't find any spawns in that file."); } int intRoll = rand(0, strSpawns.length - 1); if (fltSizes.length == 0) @@ -309,30 +300,21 @@ public class spawner_patrol extends script.base_script dungeonController = getObjIdObjVar(self, "dungeonController"); } setName(self, getStringObjVar(self, "strName")); - for (int i = 0; i < patrolPointString.length; i++) - { - for (int k = 0; k < objects.length; k++) - { - if (!isIdValid(objects[k])) - { + for (String aPatrolPointString : patrolPointString) { + for (obj_id object : objects) { + if (!isIdValid(object)) { continue; } - if (hasObjVar(objects[k], "pointName")) - { - if ((getStringObjVar(objects[k], "pointName")).equals(patrolPointString[i])) - { - if (isInInstance) - { - if (getObjIdObjVar(objects[k], "dungeonController") == dungeonController) - { - setName(objects[k], getStringObjVar(objects[k], "pointName")); - patrolPointLocation = utils.addElement(patrolPointLocation, getLocation(objects[k])); + if (hasObjVar(object, "pointName")) { + if ((getStringObjVar(object, "pointName")).equals(aPatrolPointString)) { + if (isInInstance) { + if (getObjIdObjVar(object, "dungeonController") == dungeonController) { + setName(object, getStringObjVar(object, "pointName")); + patrolPointLocation = utils.addElement(patrolPointLocation, getLocation(object)); } - } - else - { - setName(objects[k], getStringObjVar(objects[k], "pointName")); - patrolPointLocation = utils.addElement(patrolPointLocation, getLocation(objects[k])); + } else { + setName(object, getStringObjVar(object, "pointName")); + patrolPointLocation = utils.addElement(patrolPointLocation, getLocation(object)); } } } @@ -377,18 +359,9 @@ public class spawner_patrol extends script.base_script messageTo(self, "doSpawnEvent", null, 2, false); return SCRIPT_CONTINUE; } - public boolean canSpawnByConfigSetting() throws InterruptedException - { + public boolean canSpawnByConfigSetting() throws InterruptedException { String disableSpawners = getConfigSetting("GameServer", "disablePatrolSpawners"); - if (disableSpawners == null) - { - return true; - } - if (disableSpawners.equals("true") || disableSpawners.equals("1")) - { - return false; - } - return true; + return disableSpawners == null || !(disableSpawners.equals("true") || disableSpawners.equals("1")); } public int OnDestroy(obj_id self) throws InterruptedException { @@ -399,11 +372,9 @@ public class spawner_patrol extends script.base_script { return SCRIPT_CONTINUE; } - for (int i = 0; i < spawns.length; ++i) - { - if (isIdValid(spawns[i]) && exists(spawns[i])) - { - messageTo(spawns[i], "selfDestruct", null, 5, false); + for (obj_id spawn : spawns) { + if (isIdValid(spawn) && exists(spawn)) { + messageTo(spawn, "selfDestruct", null, 5, false); } } } diff --git a/sku.0/sys.server/compiled/game/script/systems/spawning/spawner_random.java b/sku.0/sys.server/compiled/game/script/systems/spawning/spawner_random.java old mode 100644 new mode 100755 index 5e2a3f27a..b5bc08b41 --- a/sku.0/sys.server/compiled/game/script/systems/spawning/spawner_random.java +++ b/sku.0/sys.server/compiled/game/script/systems/spawning/spawner_random.java @@ -1,18 +1,12 @@ package script.systems.spawning; -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.library.utils; +import script.dictionary; import script.library.ai_lib; -import script.library.space_utils; -import script.library.spawning; import script.library.create; +import script.library.spawning; +import script.library.utils; +import script.location; +import script.obj_id; public class spawner_random extends script.base_script { @@ -130,7 +124,7 @@ public class spawner_random extends script.base_script } CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: strSpawns: " + strSpawnType); String strSpawn = strSpawnType; - if (strSpawnType.indexOf(".iff") < 0) + if (!strSpawnType.contains(".iff")) { String strFileName = "datatables/spawning/ground_spawning/types/" + strSpawnType + ".iff"; if (dataTableOpen(strFileName)) @@ -268,7 +262,6 @@ public class spawner_random extends script.base_script return; } messageTo(self, "doSpawnEvent", null, fltRespawnTime, false); - return; } public int spawnDestroyed(obj_id self, dictionary params) throws InterruptedException { @@ -290,18 +283,9 @@ public class spawner_random extends script.base_script messageTo(self, "doSpawnEvent", null, 2, false); return SCRIPT_CONTINUE; } - public boolean canSpawnByConfigSetting() throws InterruptedException - { + public boolean canSpawnByConfigSetting() throws InterruptedException { String disableSpawners = getConfigSetting("GameServer", "disableAreaSpawners"); - if (disableSpawners == null) - { - return true; - } - if (disableSpawners.equals("true") || disableSpawners.equals("1")) - { - return false; - } - return true; + return disableSpawners == null || !(disableSpawners.equals("true") || disableSpawners.equals("1")); } public int OnDestroy(obj_id self) throws InterruptedException { @@ -312,11 +296,9 @@ public class spawner_random extends script.base_script { return SCRIPT_CONTINUE; } - for (int i = 0; i < spawns.length; ++i) - { - if (isIdValid(spawns[i]) && exists(spawns[i])) - { - messageTo(spawns[i], "selfDestruct", null, 5, false); + for (obj_id spawn : spawns) { + if (isIdValid(spawn) && exists(spawn)) { + messageTo(spawn, "selfDestruct", null, 5, false); } } } diff --git a/sku.0/sys.server/compiled/game/script/systems/spawning/spawner_random_proxy.java b/sku.0/sys.server/compiled/game/script/systems/spawning/spawner_random_proxy.java old mode 100644 new mode 100755 index 6aa7bcb52..503bf0af7 --- a/sku.0/sys.server/compiled/game/script/systems/spawning/spawner_random_proxy.java +++ b/sku.0/sys.server/compiled/game/script/systems/spawning/spawner_random_proxy.java @@ -1,18 +1,12 @@ package script.systems.spawning; -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.library.utils; +import script.dictionary; import script.library.ai_lib; -import script.library.space_utils; -import script.library.spawning; import script.library.create; +import script.library.spawning; +import script.library.utils; +import script.location; +import script.obj_id; public class spawner_random_proxy extends script.base_script { @@ -130,7 +124,7 @@ public class spawner_random_proxy extends script.base_script } CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: strSpawns: " + strSpawnType); String strSpawn = strSpawnType; - if (strSpawnType.indexOf(".iff") < 0) + if (!strSpawnType.contains(".iff")) { String strFileName = "datatables/spawning/ground_spawning/types/" + strSpawnType + ".iff"; if (dataTableOpen(strFileName)) @@ -341,7 +335,6 @@ public class spawner_random_proxy extends script.base_script return; } messageTo(self, "doSpawnEvent", null, fltRespawnTime, false); - return; } public int spawnDestroyed(obj_id self, dictionary params) throws InterruptedException { @@ -363,18 +356,9 @@ public class spawner_random_proxy extends script.base_script messageTo(self, "doSpawnEvent", null, 2, false); return SCRIPT_CONTINUE; } - public boolean canSpawnByConfigSetting() throws InterruptedException - { + public boolean canSpawnByConfigSetting() throws InterruptedException { String disableSpawners = getConfigSetting("GameServer", "disableAreaSpawners"); - if (disableSpawners == null) - { - return true; - } - if (disableSpawners.equals("true") || disableSpawners.equals("1")) - { - return false; - } - return true; + return disableSpawners == null || !(disableSpawners.equals("true") || disableSpawners.equals("1")); } public int OnDestroy(obj_id self) throws InterruptedException { @@ -385,11 +369,9 @@ public class spawner_random_proxy extends script.base_script { return SCRIPT_CONTINUE; } - for (int i = 0; i < spawns.length; ++i) - { - if (isIdValid(spawns[i]) && exists(spawns[i])) - { - messageTo(spawns[i], "selfDestruct", null, 5, false); + for (obj_id spawn : spawns) { + if (isIdValid(spawn) && exists(spawn)) { + messageTo(spawn, "selfDestruct", null, 5, false); } } } diff --git a/sku.0/sys.server/compiled/game/script/systems/spawning/theater_spawnegg.java b/sku.0/sys.server/compiled/game/script/systems/spawning/theater_spawnegg.java old mode 100644 new mode 100755 index ed19fc004..f5871201e --- a/sku.0/sys.server/compiled/game/script/systems/spawning/theater_spawnegg.java +++ b/sku.0/sys.server/compiled/game/script/systems/spawning/theater_spawnegg.java @@ -1,16 +1,11 @@ package script.systems.spawning; -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.dictionary; import script.library.ai_lib; import script.library.create; import script.library.utils; +import script.location; +import script.obj_id; public class theater_spawnegg extends script.base_script { @@ -29,11 +24,9 @@ public class theater_spawnegg extends script.base_script { return SCRIPT_CONTINUE; } - for (int i = 0; i < spawnList.length; i++) - { - if (isIdValid(spawnList[i])) - { - destroyObject(spawnList[i]); + for (obj_id aSpawnList : spawnList) { + if (isIdValid(aSpawnList)) { + destroyObject(aSpawnList); } } return SCRIPT_CONTINUE;