From b262d6e15f57b2dc550128262deba44f7d7746d8 Mon Sep 17 00:00:00 2001 From: Cekis Date: Wed, 16 Mar 2016 06:21:15 +0000 Subject: [PATCH] Java code enhancements for most of the java library and other areas (lots more to come). --- .../compiled/game/script/ai/ai.java | 45 +- .../compiled/game/script/base_class.java | 112 +- .../compiled/game/script/base_script.java | 13 +- .../game/script/e3demo/e3_bridge_vader.java | 15 +- .../compiled/game/script/library/ai_lib.java | 688 ++---- .../compiled/game/script/library/armor.java | 349 ++- .../compiled/game/script/library/combat.java | 19 +- .../game/script/library/movement.java | 255 +- .../compiled/game/script/library/npc.java | 5 - .../compiled/game/script/library/npe.java | 523 ++-- .../game/script/library/objvar_mangle.java | 86 +- .../compiled/game/script/library/pclib.java | 261 +- .../game/script/library/planetary_map.java | 135 +- .../game/script/library/player_stomach.java | 47 +- .../game/script/library/player_structure.java | 2117 ++++++----------- .../game/script/library/player_version.java | 75 +- .../compiled/game/script/library/poi.java | 237 +- .../compiled/game/script/library/posture.java | 8 +- .../compiled/game/script/library/powerup.java | 270 +-- .../compiled/game/script/library/utils.java | 1476 +++++------- .../script/quest/util/theater_spawner.java | 54 +- .../theme_park/dungeon/generic_spawner.java | 165 +- .../jabbaspawner/behavior/conversing.java | 7 +- .../tatooine/jabbaspawner/masterspawner.java | 750 ++---- .../tatooine/jabbaspawner/oola.java | 9 +- .../tatooine/mos_eisley/masterspawner.java | 317 +-- 26 files changed, 2695 insertions(+), 5343 deletions(-) mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/base_class.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/base_script.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/e3demo/e3_bridge_vader.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/ai_lib.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/combat.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/movement.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/npc.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/npe.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/objvar_mangle.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/pclib.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/planetary_map.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/player_stomach.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/player_structure.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/player_version.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/poi.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/posture.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/library/powerup.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/quest/util/theater_spawner.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/theme_park/tatooine/jabbaspawner/behavior/conversing.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/theme_park/tatooine/jabbaspawner/masterspawner.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/theme_park/tatooine/jabbaspawner/oola.java diff --git a/sku.0/sys.server/compiled/game/script/ai/ai.java b/sku.0/sys.server/compiled/game/script/ai/ai.java index cc3b5c045..71a37554d 100755 --- a/sku.0/sys.server/compiled/game/script/ai/ai.java +++ b/sku.0/sys.server/compiled/game/script/ai/ai.java @@ -1,50 +1,7 @@ package script.ai; 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.ai.ai_aggro; -import script.ai.ai_combat; -import script.ai.ai_combat_assist; -import java.lang.Math; -import script.library.ai_lib; -import script.library.attrib; -import script.library.beast_lib; -import script.library.buff; -import script.library.callable; -import script.library.camping; -import script.library.chat; -import script.library.collection; -import script.library.colors; -import script.library.corpse; -import script.library.create; -import script.library.factions; -import script.library.gcw; -import script.library.group; -import script.library.groundquests; -import script.library.instance; -import script.library.locations; -import script.library.loot; -import script.library.performance; -import script.library.permissions; -import script.library.pet_lib; -import script.library.posture; -import script.library.prose; -import script.library.resource; -import script.library.scheduled_drop; -import script.library.scenario; -import script.library.scout; -import script.library.static_item; -import script.library.stealth; -import script.library.storyteller; -import script.library.sui; -import script.library.utils; -import script.library.xp; +import script.library.*; public class ai extends script.base_script { diff --git a/sku.0/sys.server/compiled/game/script/base_class.java b/sku.0/sys.server/compiled/game/script/base_class.java old mode 100644 new mode 100755 index efd95b5ce..23a74bffb --- a/sku.0/sys.server/compiled/game/script/base_class.java +++ b/sku.0/sys.server/compiled/game/script/base_class.java @@ -5,23 +5,10 @@ package script; -import java.io.FileNotFoundException; import java.io.File; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ArrayList; import java.util.Arrays; -import java.util.Calendar; -import java.util.Enumeration; -import java.util.HashSet; import java.util.Hashtable; -import java.util.Iterator; import java.util.Vector; -import script.obj_id; -import script.region; -import java.io.ByteArrayOutputStream; -import java.io.ObjectOutputStream; -import java.io.IOException; public class base_class @@ -1552,7 +1539,7 @@ public class base_class if ( id == 0 ) return null; - return obj_id.getObjId(new Long(id)); + return obj_id.getObjId(id); } // getObjId /** @@ -1819,10 +1806,13 @@ public class base_class int[] array = getIntArrayObjVar(object, name); if (array != null) { + /* Integer[] newArray = new Integer[array.length]; for ( int i = 0; i < array.length; ++i ) newArray[i] = new Integer(array[i]); return new Vector(Arrays.asList(newArray)); + */ + return new Vector(Arrays.asList(array)); } return null; } @@ -1859,10 +1849,13 @@ public class base_class float[] array = getFloatArrayObjVar(object, name); if (array != null) { + /* Float[] newArray = new Float[array.length]; for ( int i = 0; i < array.length; ++i ) newArray[i] = new Float(array[i]); return new Vector(Arrays.asList(newArray)); + */ + return new Vector(Arrays.asList(array)); } return null; } @@ -2054,10 +2047,7 @@ public class base_class */ public static boolean getBooleanObjVar(obj_id object, String name) { - int value = getIntObjVar(object, name); - if ( value == 0 ) - return false; - return true; + return getIntObjVar(object, name) != 0; } /** * Finds an attrib_mod obj_var with a given name on an object. @@ -2505,7 +2495,7 @@ public class base_class int[] x = new int[data.size()]; for ( int i = 0; i < x.length; ++i ) { - x[i] = ((Integer)data.get(i)).intValue(); + x[i] = (int) data.get(i); } return setObjVar(object, name, x); } @@ -2514,7 +2504,7 @@ public class base_class float[] x = new float[data.size()]; for ( int i = 0; i < x.length; ++i ) { - x[i] = ((Float)data.get(i)).floatValue(); + x[i] = (float) data.get(i); } return setObjVar(object, name, x); } @@ -2523,7 +2513,7 @@ public class base_class boolean[] x = new boolean[data.size()]; for ( int i = 0; i < x.length; ++i ) { - x[i] = ((Boolean)data.get(i)).booleanValue(); + x[i] = (boolean) data.get(i); } return setObjVar(object, name, x); } @@ -2796,9 +2786,9 @@ public class base_class */ public static void testAbortScript() throws InterruptedException { - long startTime = script_entry.getScriptStartTime(); if (script_entry.getScriptStartTime() > 0) { + long startTime = script_entry.getScriptStartTime(); long currentTime = System.currentTimeMillis(); if (currentTime > startTime + script_entry.getScriptInterruptMs()) { @@ -3527,8 +3517,7 @@ public class base_class } public static void setModValue(String modName, int value) { - obj_id self = getSelf(); - _setModValue(self, modName, value); + _setModValue(getSelf(), modName, value); } @@ -3655,7 +3644,7 @@ public class base_class */ public static void chatSendToRoom(String roomName, String localizedMessageText, String outOfBand) { - obj_id self = getSelf(); + //obj_id self = getSelf(); //String avatarName = getName(self); _chatSendToRoom("SYSTEM", roomName, localizedMessageText, outOfBand); } @@ -3675,9 +3664,7 @@ public class base_class */ public static void chatEnterRoom(String roomName) { - obj_id self = getSelf(); - String avatarName = getName(self); - _chatEnterRoom(avatarName, roomName); + _chatEnterRoom(getName(getSelf()), roomName); } private static native void _chatEnterRoom(String who, String roomName); @@ -3695,9 +3682,7 @@ public class base_class */ public static void chatExitRoom(String roomName) { - obj_id self = getSelf(); - String avatarName = getName(self); - _chatExitRoom(avatarName, roomName); + _chatExitRoom(getName(getSelf()), roomName); } private static native void _chatExitRoom(String who, String roomName); @@ -3707,9 +3692,7 @@ public class base_class public static native void chatRemoveModeratorFromRoom(String roomName, String moderatorName); public static void chatSendInstantMessage(String to, String localizedMessageText, String outOfBand) { - obj_id self = getSelf(); - String avatarName = getName (self); - _chatSendInstantMessage(avatarName, to, localizedMessageText, outOfBand); + _chatSendInstantMessage(getName (getSelf()), to, localizedMessageText, outOfBand); } private static native void _chatSendInstantMessage(String from, String to, String localizedMessageText, String outOfBand); @@ -3825,8 +3808,7 @@ public class base_class */ public static void sendQuestSystemMessage(obj_id to, prose_package pp) { - String oob = packOutOfBandProsePackage(null, pp); - sendQuestSystemMessage(to, null, oob); + sendQuestSystemMessage(to, null, packOutOfBandProsePackage(null, pp)); } /** @@ -3870,8 +3852,7 @@ public class base_class */ public static void sendSystemMessageProse (String to, prose_package pp) { - String oob = packOutOfBandProsePackage (null, pp); - sendSystemMessage (to, null, oob); + sendSystemMessage (to, null, packOutOfBandProsePackage (null, pp)); } /** @@ -3907,8 +3888,7 @@ public class base_class */ public static void sendSystemMessageProse (obj_id to, prose_package pp) { - String oob = packOutOfBandProsePackage (null, pp); - sendSystemMessage (to, null, oob); + sendSystemMessage (to, null, packOutOfBandProsePackage (null, pp)); //sendSystemMessageProse (getChatName (to), pp); } @@ -3937,8 +3917,7 @@ public class base_class public static void sendFactionalSystemMessagePlanet(prose_package pp, location loc, float radius, boolean notifyImperial, boolean notifyRebel) { - String oob = packOutOfBandProsePackage(null, pp); - sendFactionalSystemMessagePlanet(oob, loc, radius, notifyImperial, notifyRebel); + sendFactionalSystemMessagePlanet(packOutOfBandProsePackage(null, pp), loc, radius, notifyImperial, notifyRebel); } public static void sendFactionalSystemMessagePlanet(string_id messageId, location loc, float radius, boolean notifyImperial, boolean notifyRebel) @@ -3956,8 +3935,7 @@ public class base_class */ public static void sendSystemMessagePlanetTestingOnly (String localizedMessageText) { - String room = getGameChatCode () + "." + getGalaxyName () + "." + getCurrentSceneName () + ".system"; - chatSendToRoom (room, localizedMessageText, null); + chatSendToRoom (getGameChatCode () + "." + getGalaxyName () + "." + getCurrentSceneName () + ".system", localizedMessageText, null); } /** @@ -3965,8 +3943,7 @@ public class base_class */ public static void sendSystemMessagePlanetOob (String oob) { - String room = getGameChatCode () + "." + getGalaxyName () + "." + getCurrentSceneName () + ".system"; - chatSendToRoom (room, null, oob); + chatSendToRoom (getGameChatCode () + "." + getGalaxyName () + "." + getCurrentSceneName () + ".system", null, oob); } /** @@ -3984,8 +3961,7 @@ public class base_class */ public static void sendSystemMessagePlanetProse (prose_package pp) { - String oob = packOutOfBandProsePackage (null, pp); - sendSystemMessagePlanetOob (oob); + sendSystemMessagePlanetOob (packOutOfBandProsePackage (null, pp)); } //-------------------------------------------------------------- @@ -3996,8 +3972,7 @@ public class base_class */ public static void sendSystemMessageGalaxyTestingOnly (String localizedMessageText) { - String room = getGameChatCode () + "." + getGalaxyName () + ".system"; - chatSendToRoom (room, localizedMessageText, null); + chatSendToRoom (getGameChatCode () + "." + getGalaxyName () + ".system", localizedMessageText, null); } /** @@ -4005,8 +3980,7 @@ public class base_class */ public static void sendSystemMessageGalaxyOob (String oob) { - String room = getGameChatCode () + "." + getGalaxyName () + ".system"; - chatSendToRoom (room, null, oob); + chatSendToRoom (getGameChatCode () + "." + getGalaxyName () + ".system", null, oob); } /** @@ -4024,8 +3998,7 @@ public class base_class */ public static void sendSystemMessageGalaxyProse (prose_package pp) { - String oob = packOutOfBandProsePackage (null, pp); - sendSystemMessageGalaxyOob (oob); + sendSystemMessageGalaxyOob (packOutOfBandProsePackage (null, pp)); } //-------------------------------------------------------------- @@ -4080,8 +4053,7 @@ public class base_class */ public static void sendCombatSpamMessageProse(obj_id player, prose_package pp, int spamType) { - String oob = packOutOfBandProsePackage(null, pp); - sendCombatSpamMessageOob(player, null, oob, true, false, false, spamType); + sendCombatSpamMessageOob(player, null, packOutOfBandProsePackage(null, pp), true, false, false, spamType); } /** @@ -4090,8 +4062,7 @@ public class base_class public static void sendCombatSpamMessageProse(obj_id attacker, obj_id defender, prose_package pp, boolean sendToAttacker, boolean sendToDefender, boolean sendToBystanders, int spamType) { //@todo: send to other players - String oob = packOutOfBandProsePackage(null, pp); - sendCombatSpamMessageOob(attacker, defender, oob, sendToAttacker, sendToDefender, sendToBystanders, spamType); + sendCombatSpamMessageOob(attacker, defender, packOutOfBandProsePackage(null, pp), sendToAttacker, sendToDefender, sendToBystanders, spamType); } /** @@ -4233,8 +4204,7 @@ public class base_class public static boolean isGameObjectTypeOf (obj_id obj, int typeToTestAgainst) { - final int type = getGameObjectType (obj); - return isGameObjectTypeOf (type, typeToTestAgainst); + return isGameObjectTypeOf (getGameObjectType (obj), typeToTestAgainst); } /**************************************************************** @@ -5257,14 +5227,8 @@ public class base_class Acceptable colors are: red, blue, yellow, white, green, and orange */ - public static boolean setWaypointColor(obj_id waypoint, String color) - { - if(waypoint != null) - { - return _setWaypointColorNative(waypoint, color); - } - else - return false; + public static boolean setWaypointColor(obj_id waypoint, String color) { + return waypoint != null && _setWaypointColorNative(waypoint, color); } /** @brief set the visibility of a waypoint in a player's datapad */ @@ -5302,12 +5266,6 @@ public class base_class /** @brief set the region for a waypoint */ public static void setWaypointRegion(obj_id w, region r) { - if(w != null) - { - if(r != null) - { - } - } } private static native void _setWaypointName(long waypoint, String name); @@ -6124,7 +6082,7 @@ public class base_class * * @return the combined string */ - static public String join(String s1, String s2) + public static String join(String s1, String s2) { if (s1 != null && s2 != null) return s1 + s2; @@ -8693,8 +8651,8 @@ public class base_class * @param state The index of the mental state to get * @param value The amount to add to the mental state. * @param duration The time to hold the mental state. This does not include attack and decay time. - * @param attackTime The time before the modifier is fully active. - * @param decayTime The time for the modifier to decay to zero. + * @param attackRate The time before the modifier is fully active. + * @param decayRate The time for the modifier to decay to zero. * @return a success code */ private static native boolean _addMentalStateModifierToward(long creature, long target, int state, float value, float duration, float attackRate, float decayRate); diff --git a/sku.0/sys.server/compiled/game/script/base_script.java b/sku.0/sys.server/compiled/game/script/base_script.java old mode 100644 new mode 100755 index 729e18f4d..186cd8cf2 --- a/sku.0/sys.server/compiled/game/script/base_script.java +++ b/sku.0/sys.server/compiled/game/script/base_script.java @@ -21,14 +21,13 @@ public class base_script extends script.base_class public int OnLocateObject(obj_id self, dictionary params) throws InterruptedException { - location l = getLocation(self); obj_id requestor = params.getObjId("requestor"); if (requestor != null) { String callbackMethod = params.getString("callback"); if (callbackMethod != null) { - params.put("location", l); + params.put("location", getLocation(self)); messageTo(requestor, callbackMethod, params, 0, false); } } @@ -39,8 +38,7 @@ public class base_script extends script.base_class obj_id waypoint = params.getObjId("waypoint"); if (waypoint != null) { - boolean isActive = params.getBoolean("isActive"); - _setWaypointActiveNative(waypoint, isActive); + _setWaypointActiveNative(waypoint, params.getBoolean("isActive")); } return SCRIPT_CONTINUE; } @@ -77,9 +75,8 @@ public class base_script extends script.base_class { return; } - int count = objvars.getNumItems(); int elem = getFirstFreeIndex(names); - for (int i = 0; i < count && elem >= 0 && elem < names.length; ++i) + for (int i = 0; i < objvars.getNumItems() && elem >= 0 && elem < names.length; ++i) { obj_var o = objvars.getObjVar(i); if (o != null) @@ -126,9 +123,7 @@ public class base_script extends script.base_class String oldname = "\"" + k.toString(); String name = oldname.replace('.', '+'); debugServerConsoleMsg(self, "scriptvar name: " + name); - Object v = scriptvars.getObject(k); - String attrib = v.toString(); - sortedValues.put(name, attrib); + sortedValues.put(name, scriptvars.getObject(k)); } Iterator keysSet = (sortedValues.keySet()).iterator(); while (keysSet.hasNext() && i < names.length) diff --git a/sku.0/sys.server/compiled/game/script/e3demo/e3_bridge_vader.java b/sku.0/sys.server/compiled/game/script/e3demo/e3_bridge_vader.java old mode 100644 new mode 100755 index 01c7c2649..972e10797 --- a/sku.0/sys.server/compiled/game/script/e3demo/e3_bridge_vader.java +++ b/sku.0/sys.server/compiled/game/script/e3demo/e3_bridge_vader.java @@ -1,17 +1,10 @@ package script.e3demo; -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.anims; -import script.library.utils; -import script.library.space_utils; +import script.dictionary; import script.library.factions; +import script.library.utils; +import script.location; +import script.obj_id; public class e3_bridge_vader extends script.base_script { diff --git a/sku.0/sys.server/compiled/game/script/library/ai_lib.java b/sku.0/sys.server/compiled/game/script/library/ai_lib.java old mode 100644 new mode 100755 index 8e7513b91..27b1a0128 --- a/sku.0/sys.server/compiled/game/script/library/ai_lib.java +++ b/sku.0/sys.server/compiled/game/script/library/ai_lib.java @@ -1,25 +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.badge; -import script.library.beast_lib; -import script.library.buff; -import script.library.chat; -import script.library.combat_consts; -import script.library.dot; -import script.library.factions; -import script.library.locations; -import script.library.movement; -import script.library.pet_lib; -import script.library.skill; -import script.library.utils; +import java.util.Vector; public class ai_lib extends script.base_script { @@ -37,11 +23,11 @@ public class ai_lib extends script.base_script public static final int BEHAVIOR_SENTINEL = 1; public static final int BEHAVIOR_LOITER = 2; public static final int BEHAVIOR_STOP = 3; - public static final String DIF_VERY_EASY = "veryEasy"; - public static final String DIF_EASY = "easy"; - public static final String DIF_MEDIUM = "medium"; - public static final String DIF_HARD = "hard"; - public static final String DIF_VERY_HARD = "veryHard"; + //public static final String DIF_VERY_EASY = "veryEasy"; + //public static final String DIF_EASY = "easy"; + //public static final String DIF_MEDIUM = "medium"; + //public static final String DIF_HARD = "hard"; + //public static final String DIF_VERY_HARD = "veryHard"; public static final String ALLY_LIST = "allyList"; public static final String CREATURE_TABLE = "datatables/mob/creatures.iff"; public static final String CREATURE_NAME_FILE = "mob/creature_names"; @@ -62,8 +48,8 @@ public class ai_lib extends script.base_script public static final int FORMATION_WEDGE = 1; public static final int FORMATION_LINE = 2; public static final int FORMATION_BOX = 3; - public static final int DIFFICULTY_NORMAL = 0; - public static final int DIFFICULTY_ELITE = 1; + //public static final int DIFFICULTY_NORMAL = 0; + //public static final int DIFFICULTY_ELITE = 1; public static final int DIFFICULTY_BOSS = 2; public static final String SHARED_HEALTH_LIST = "shared_health_list"; public static boolean isWithinLeash(obj_id ai) throws InterruptedException @@ -105,18 +91,10 @@ public class ai_lib extends script.base_script } if (needsCombatTriggerVolumes) { - - { - final boolean promiscuous = true; - final float alertRadius = 64.0f; - createTriggerVolume(ai_lib.ALERT_VOLUME_NAME, alertRadius, promiscuous); - } - - { - final boolean promiscuous = false; - final float aggroRadius = aiGetAggroRadius(self); - createTriggerVolume(ai_lib.AGGRO_VOLUME_NAME, aggroRadius, promiscuous); - } + // Create ALERT trigger volume + createTriggerVolume(ai_lib.ALERT_VOLUME_NAME, 64.0f, true); + // Create AGGRO trigger volume, AI needs an aggro trigger volume because they could be factionally aggressive towards something + createTriggerVolume(ai_lib.AGGRO_VOLUME_NAME, aiGetAggroRadius(self), false); } } public static void clearCombatData() throws InterruptedException @@ -152,8 +130,7 @@ public class ai_lib extends script.base_script } public static void setMood(obj_id npc, String mood) throws InterruptedException { - obj_id thisNpc = getSelf(); - if (thisNpc != npc) + if (getSelf() != npc) { dictionary parms = new dictionary(); parms.put("animMood", mood); @@ -186,15 +163,11 @@ public class ai_lib extends script.base_script { mood = getStringObjVar(npc, "ai.defaultCalmMood"); } - else - { - } setAnimationMood(npc, mood); } public static void doAction(obj_id npc, String anim) throws InterruptedException { - obj_id thisNpc = getSelf(); - if (thisNpc != npc) + if (getSelf() != npc) { dictionary parms = new dictionary(); parms.put("anim", anim); @@ -307,8 +280,8 @@ public class ai_lib extends script.base_script } public static void setPatrolPath(obj_id npc, location[] patrolLoc, int startPoint) throws InterruptedException { - LOGC(aiLoggingEnabled(npc), "debug_ai", ("ai_lib::setPatrolPath() self(" + npc + ") getName(" + getName(npc) + ") patrolLength(" + patrolLoc + ")")); - if (isIdValid(npc) && patrolLoc != null) + LOGC(aiLoggingEnabled(npc), "debug_ai", ("ai_lib::setPatrolPath() self(" + npc + ") getName(" + getName(npc) + ") patrolLength(" + patrolLoc.length + ")")); + if (isIdValid(npc)) { utils.setScriptVar(npc, SCRIPTVAR_CACHED_PATROL_PATH, patrolLoc); utils.setScriptVar(npc, SCRIPTVAR_CACHED_PATROL_TYPE, PATROL_FLAG_REPEAT); @@ -468,17 +441,12 @@ public class ai_lib extends script.base_script resumeMovement(npc); } } - public static boolean canPatrol(obj_id npc) throws InterruptedException - { - if (isIdValid(npc)) - { - return utils.hasScriptVar(npc, SCRIPTVAR_CACHED_PATROL_TYPE); - } - return false; + public static boolean canPatrol(obj_id npc) throws InterruptedException { + return isIdValid(npc) && utils.hasScriptVar(npc, SCRIPTVAR_CACHED_PATROL_TYPE); } public static location[] parseWaypoints(obj_id npc, String[] waypoints) throws InterruptedException { - if (!isIdValid(npc) || waypoints != null) + if (!isIdValid(npc) || waypoints == null) { return null; } @@ -494,9 +462,10 @@ public class ai_lib extends script.base_script } location[] patrolLocs = new location[waypoints.length]; location patrolLoc = new location(baseLoc); + float[] coords; for (int i = 0; i < waypoints.length; i++) { - float[] coords = parseWaypoints(waypoints[i]); + coords = parseWaypoints(waypoints[i]); if (coords != null && coords.length == 2) { patrolLoc.x = baseLoc.x + coords[0]; @@ -512,33 +481,9 @@ public class ai_lib extends script.base_script } public static float[] parseWaypoints(String text) throws InterruptedException { - int intIndex = 0; - int intI = 0; - intIndex = text.indexOf(","); - String strText1 = ""; - String strText2 = ""; - if (intIndex < 0) - { - return null; - } - else - { - while (intI < text.length()) - { - if (intI < intIndex) - { - strText1 = strText1 + text.charAt(intI); - } - else if (intI > intIndex) - { - strText2 = strText2 + text.charAt(intI); - } - intI = intI + 1; - } - } float[] returnCoords = new float[2]; - returnCoords[0] = Float.parseFloat(strText1); - returnCoords[1] = Float.parseFloat(strText2); + returnCoords[0] = Float.parseFloat(text.split(",")[0]); + returnCoords[1] = Float.parseFloat(text.split(",")[1]); return returnCoords; } public static void setIgnoreCombat(obj_id npc) throws InterruptedException @@ -576,8 +521,7 @@ public class ai_lib extends script.base_script return; } utils.setScriptVar(npc, "ai.recentlyBarked", getGameTime() + rand(20, 45)); - location loc = getLocation(npc); - if (locations.isInCity(loc)) + if (locations.isInCity(getLocation(npc))) { if (rand(1, 100) != 1) { @@ -591,10 +535,7 @@ public class ai_lib extends script.base_script return; } } - String diction = getStringObjVar(npc, "ai.diction"); - String stringFile = "npc_reaction/" + diction; - String textString = text + "_" + rand(1, 16); - string_id speakString = new string_id(stringFile, textString); + string_id speakString = new string_id("npc_reaction/" + getStringObjVar(npc, "ai.diction"), text + "_" + rand(1, 16)); if (getString(speakString) == null) { debugServerConsoleMsg(npc, "WARNING: Npc_reaction " + speakString + " - does it exist?"); @@ -609,119 +550,44 @@ public class ai_lib extends script.base_script public static boolean isMonster(obj_id npc) throws InterruptedException { int myNiche = aiGetNiche(npc); - if (myNiche == NICHE_MONSTER || myNiche == NICHE_HERBIVORE || myNiche == NICHE_CARNIVORE || myNiche == NICHE_PREDATOR) - { - return true; - } - else - { - return false; - } + return myNiche == NICHE_MONSTER || myNiche == NICHE_HERBIVORE || myNiche == NICHE_CARNIVORE || myNiche == NICHE_PREDATOR; } public static boolean isDroid(obj_id npc) throws InterruptedException { - int niche = aiGetNiche(npc); - if (niche == NICHE_DROID) - { - return true; - } - else - { - return false; - } + return aiGetNiche(npc) == NICHE_DROID; } public static boolean isPredator(obj_id npc) throws InterruptedException { - int niche = aiGetNiche(npc); - if (niche == NICHE_PREDATOR) - { - return true; - } - else - { - return false; - } + return aiGetNiche(npc) == NICHE_PREDATOR; } public static boolean isCarnivore(obj_id npc) throws InterruptedException { - int niche = aiGetNiche(npc); - if (niche == NICHE_CARNIVORE) - { - return true; - } - else - { - return false; - } + return aiGetNiche(npc) == NICHE_CARNIVORE; } public static boolean isHerbivore(obj_id npc) throws InterruptedException { - int niche = aiGetNiche(npc); - if (niche == NICHE_HERBIVORE) - { - return true; - } - else - { - return false; - } + return aiGetNiche(npc) == NICHE_HERBIVORE; } public static boolean isVehicle(obj_id npc) throws InterruptedException { - int niche = aiGetNiche(npc); - if (niche == NICHE_VEHICLE) - { - return true; - } - else - { - return false; - } + return aiGetNiche(npc) == NICHE_VEHICLE; } public static boolean isAndroid(obj_id npc) throws InterruptedException { - int niche = aiGetNiche(npc); - if (niche == NICHE_ANDROID) - { - return true; - } - else - { - return false; - } + return aiGetNiche(npc) == NICHE_ANDROID; } public static boolean isHumanoid(obj_id target) throws InterruptedException { - if (isPlayer(target)) - { - return true; - } - else - { - int niche = aiGetNiche(target); - if (niche == NICHE_NPC || niche == NICHE_ANDROID) - { - return true; - } - } - return false; + int niche = aiGetNiche(target); + return isPlayer(target) || niche == NICHE_NPC || niche == NICHE_ANDROID; } public static boolean isNpc(obj_id npc) throws InterruptedException { - int myNiche = aiGetNiche(npc); - return (myNiche == NICHE_NPC); + return (aiGetNiche(npc) == NICHE_NPC); } public static boolean isTurret(obj_id npc) throws InterruptedException { - int got = getGameObjectType(npc); - if (isGameObjectTypeOf(got, GOT_installation_turret)) - { - return true; - } - else - { - return false; - } + return isGameObjectTypeOf(getGameObjectType(npc), GOT_installation_turret); } public static void setIgnoreCombat(obj_id npc, boolean b) throws InterruptedException { @@ -793,21 +659,11 @@ public class ai_lib extends script.base_script { return isAiDead(npc); } - public static boolean isAiDead(obj_id npc) throws InterruptedException - { - if (!isMob(npc)) - { + public static boolean isAiDead(obj_id npc) throws InterruptedException { + if (!isMob(npc)) { return (isDisabled(npc)); } - if (isIncapacitated(npc)) - { - return true; - } - if (isDead(npc)) - { - return true; - } - return false; + return isIncapacitated(npc) || isDead(npc); } public static void aiFollow(obj_id npc, obj_id target) throws InterruptedException { @@ -841,13 +697,8 @@ public class ai_lib extends script.base_script setObjVar(npc, "ai.persistantFollowing.max_dist", max_dist); follow(npc, target, min_dist, max_dist); } - public static boolean isFollowing(obj_id npc) throws InterruptedException - { - if (!isIdValid(npc)) - { - return false; - } - return hasObjVar(npc, "ai.persistantFollowing"); + public static boolean isFollowing(obj_id npc) throws InterruptedException { + return isIdValid(npc) && hasObjVar(npc, "ai.persistantFollowing"); } public static obj_id getFollowTarget(obj_id npc) throws InterruptedException { @@ -950,9 +801,8 @@ public class ai_lib extends script.base_script removeObjVar(npc, "ai.inFormation"); return; } - int formationType = getIntObjVar(npc, "ai.formationType"); int position = getIntObjVar(npc, "ai.formationPosition"); - switch (formationType) + switch (getIntObjVar(npc, "ai.formationType")) { case FORMATION_WEDGE: followInWedgeFormation(npc, leader, position); @@ -1050,11 +900,7 @@ public class ai_lib extends script.base_script } public static void pathAwayFrom(obj_id npc, obj_id target) throws InterruptedException { - if (!isIdValid(npc) || !isIdValid(target)) - { - return; - } - if (npc == target) + if (npc == target || !isIdValid(npc) || !isIdValid(target)) { return; } @@ -1161,8 +1007,7 @@ public class ai_lib extends script.base_script String creatureName = getCreatureName(npc); if (creatureName != null || !beast_lib.isBeast(npc)) { - String socialGroup = dataTableGetString(CREATURE_TABLE, creatureName, "socialGroup"); - return socialGroup; + return dataTableGetString(CREATURE_TABLE, creatureName, "socialGroup"); } return null; } @@ -1171,9 +1016,7 @@ public class ai_lib extends script.base_script boolean result = false; if (!pet_lib.isPet(npc) && !pet_lib.isPet(target) && !beast_lib.isBeast(npc) && !beast_lib.isBeast(target)) { - final String npcCreatureName = getCreatureName(npc); - final String targetCreatureName = getCreatureName(target); - if (npcCreatureName != null && targetCreatureName != null) + if (getCreatureName(npc) != null && getCreatureName(target) != null) { String mySocialGroup = getSocialGroup(npc); String yourSocialGroup = getSocialGroup(target); @@ -1194,31 +1037,19 @@ public class ai_lib extends script.base_script } return result; } - public static boolean isHerdingCreature(obj_id npc) throws InterruptedException - { - if (isNpc(npc) || isPlayer(npc) || isAndroid(npc)) - { + public static boolean isHerdingCreature(obj_id npc) throws InterruptedException { + if (isNpc(npc) || isPlayer(npc) || isAndroid(npc)) { return false; } String creatureName = getCreatureName(npc); - if (creatureName != null) - { - boolean isHerding = (dataTableGetInt(CREATURE_TABLE, creatureName, "herd") == 1); - return isHerding; - } - return false; + return creatureName != null && (dataTableGetInt(CREATURE_TABLE, creatureName, "herd") == 1); } - public static boolean isStalkingCreature(obj_id ai) throws InterruptedException - { - if (isPlayer(ai) || (aiGetNiche(ai) == NICHE_NPC) || isAndroid(ai)) - { - return false; - } - if (hasScript(ai, "ai.pet_advance")) - { - return false; - } - return aiIsStalker(ai); + public static boolean isStalkingCreature(obj_id ai) throws InterruptedException { + if (!(isPlayer(ai) || aiGetNiche(ai) == NICHE_NPC || isAndroid(ai))) + if (!hasScript(ai, "ai.pet_advance")) + if (aiIsStalker(ai)) + return true; + return false; } public static boolean isAggroToward(obj_id npc, obj_id threat) throws InterruptedException { @@ -1254,14 +1085,8 @@ public class ai_lib extends script.base_script { return true; } - int npcNiche = ai_lib.aiGetNiche(npc); - int threatNiche = ai_lib.aiGetNiche(threat); - if (npcNiche == NICHE_CARNIVORE) - { - if (threatNiche == NICHE_HERBIVORE) - { - return true; - } + if (ai_lib.aiGetNiche(npc) == NICHE_CARNIVORE && ai_lib.aiGetNiche(threat) == NICHE_HERBIVORE) { + return true; } return false; } @@ -1281,24 +1106,16 @@ public class ai_lib extends script.base_script } return aiIsAggressive(ai); } - public static boolean isHealingNpc(obj_id npc) throws InterruptedException - { - if (isPlayer(npc)) - { + public static boolean isHealingNpc(obj_id npc) throws InterruptedException { + if (isPlayer(npc)) { return false; } int niche = aiGetNiche(npc); - if (niche != NICHE_NPC || niche != NICHE_ANDROID) - { + if (niche != NICHE_NPC && niche != NICHE_ANDROID) { return false; } String creatureName = getCreatureName(npc); - if (creatureName != null) - { - boolean isHealer = (dataTableGetInt(CREATURE_TABLE, creatureName, "healer") != 0); - return isHealer; - } - return false; + return creatureName != null && (dataTableGetInt(CREATURE_TABLE, creatureName, "healer") != 0); } public static boolean incapacitateMob(obj_id target) throws InterruptedException { @@ -1306,29 +1123,14 @@ public class ai_lib extends script.base_script { return false; } - boolean result = true; - result &= setHealth(target, -50); - result &= setAction(target, -50); - result &= setMind(target, -50); - return result; + return setHealth(target, -50) && setAction(target, -50) && setMind(target, -50); } - public static boolean isHumanSkeleton(obj_id npc) throws InterruptedException - { - if (isPlayer(npc)) - { + public static boolean isHumanSkeleton(obj_id npc) throws InterruptedException { + if (isPlayer(npc)) { return true; } int speciesNum = ai_lib.aiGetSpecies(npc); - if (speciesNum == -1) - { - return false; - } - String skeleton = dataTableGetString("datatables/ai/species.iff", speciesNum, "Skeleton"); - if (skeleton.equals("human")) - { - return true; - } - return false; + return speciesNum != -1 && dataTableGetString("datatables/ai/species.iff", speciesNum, "Skeleton").equals("human"); } public static String getSkeleton(int speciesNum) throws InterruptedException { @@ -1336,8 +1138,7 @@ public class ai_lib extends script.base_script { return null; } - String skeleton = dataTableGetString("datatables/ai/species.iff", speciesNum, "Skeleton"); - return skeleton; + return dataTableGetString("datatables/ai/species.iff", speciesNum, "Skeleton"); } public static String getSkeleton(obj_id npc) throws InterruptedException { @@ -1362,47 +1163,46 @@ public class ai_lib extends script.base_script switch (rand(0, 13)) { case 0: - anim = ai_lib.ACTION_THREATEN; - break; + break; case 1: - anim = "alert"; - break; + anim = "alert"; + break; case 2: - anim = "angry"; - break; + anim = "angry"; + break; case 3: - anim = "gesticulate_wildly"; - break; + anim = "gesticulate_wildly"; + break; case 4: - anim = "greet"; - break; + anim = "greet"; + break; case 5: - anim = "look_casual"; - break; + anim = "look_casual"; + break; case 6: - anim = "look_left"; - break; + anim = "look_left"; + break; case 7: - anim = "look_right"; - break; + anim = "look_right"; + break; case 8: - anim = "point_accusingly"; - break; + anim = "point_accusingly"; + break; case 9: - anim = "pound_fist_chest"; - break; + anim = "pound_fist_chest"; + break; case 10: - anim = "pound_fist_palm"; - break; + anim = "pound_fist_palm"; + break; case 11: - anim = "taunt1"; - break; + anim = "taunt1"; + break; case 12: - anim = "taunt2"; - break; + anim = "taunt2"; + break; case 13: - anim = "taunt3"; - break; + anim = "taunt3"; + break; } ai_lib.doAction(npc, anim); } @@ -1428,83 +1228,82 @@ public class ai_lib extends script.base_script return; } String anim = "celebrate"; - switch (rand(0, 23)) + switch (rand(0, 24)) { case 0: - anim = "celebrate"; - break; + break; case 1: - anim = "applause_excited"; - break; + anim = "applause_excited"; + break; case 2: - anim = "belly_laugh"; - break; + anim = "belly_laugh"; + break; case 3: - anim = "celebrate1"; - break; + anim = "celebrate1"; + break; case 4: - anim = "coup_de_grace"; - break; + anim = "coup_de_grace"; + break; case 5: - anim = "dismiss"; - break; + anim = "dismiss"; + break; case 6: - anim = "flex_biceps"; - break; + anim = "flex_biceps"; + break; case 7: - anim = "laugh_pointing"; - break; + anim = "laugh_pointing"; + break; case 8: - anim = "point_accusingly"; - break; + anim = "point_accusingly"; + break; case 9: - anim = "pound_fist_chest"; - break; + anim = "pound_fist_chest"; + break; case 10: - anim = "pound_fist_palm"; - break; + anim = "pound_fist_palm"; + break; case 11: - anim = "salute1"; - break; + anim = "salute1"; + break; case 12: - anim = "salute2"; - break; + anim = "salute2"; + break; case 13: - anim = "shrug_hands"; - break; + anim = "shrug_hands"; + break; case 14: - anim = "shrug_shoulders"; - break; + anim = "shrug_shoulders"; + break; case 15: - anim = "smack_self"; - break; + anim = "smack_self"; + break; case 16: - anim = "shake_head_disgust"; - break; + anim = "shake_head_disgust"; + break; case 17: - anim = "snap_finger1"; - break; + anim = "snap_finger1"; + break; case 18: - anim = "snap_finger2"; - break; + anim = "snap_finger2"; + break; case 19: - anim = "tap_head"; - break; + anim = "tap_head"; + break; case 20: - anim = "taunt1"; - break; + anim = "taunt1"; + break; case 21: - anim = "taunt2"; - break; + anim = "taunt2"; + break; case 22: - anim = "taunt3"; - break; + anim = "taunt3"; + break; case 23: - anim = "yawn"; - break; + anim = "yawn"; + break; case 24: - anim = "check_wrist_device"; - break; + anim = "check_wrist_device"; + break; } doAction(npc, anim); } @@ -1539,7 +1338,7 @@ public class ai_lib extends script.base_script } public static void aiSetPosture(obj_id npc, int newPosture) throws InterruptedException { - if ((getState(npc, STATE_COMBAT) != 1)) + if (getState(npc, STATE_COMBAT) != 1) { setPostureClientImmediate(npc, newPosture); } @@ -1551,71 +1350,42 @@ public class ai_lib extends script.base_script doCombatResults("change_posture", cbtAnimationResults, null); } } - public static boolean canSit(obj_id npc) throws InterruptedException - { + public static boolean canSit(obj_id npc) throws InterruptedException { int speciesNum = ai_lib.aiGetSpecies(npc); - if (speciesNum == -1) - { - return false; - } - boolean hasSitAnims = (dataTableGetInt("datatables/ai/species.iff", speciesNum, "CanSit") == 1); - return hasSitAnims; + return speciesNum != -1 && dataTableGetInt("datatables/ai/species.iff", speciesNum, "CanSit") == 1; } - public static boolean canLieDown(obj_id npc) throws InterruptedException - { + public static boolean canLieDown(obj_id npc) throws InterruptedException { int speciesNum = ai_lib.aiGetSpecies(npc); - if (speciesNum == -1) - { - return false; - } - boolean hasLayAnims = (dataTableGetInt("datatables/ai/species.iff", speciesNum, "CanLieDown") == 1); - return hasLayAnims; + return speciesNum != -1 && dataTableGetInt("datatables/ai/species.iff", speciesNum, "CanLieDown") == 1; } - public static boolean isInSameBuilding(obj_id npc, obj_id target) throws InterruptedException - { - if (!isIdValid(npc)) - { - return false; - } - if (!isIdValid(target)) - { + public static boolean isInSameBuilding(obj_id npc, obj_id target) throws InterruptedException { + if (!isIdValid(npc) || !isIdValid(target)) { return false; } obj_id npcCell = getLocation(npc).cell; obj_id targetCell = getLocation(target).cell; - if (isIdValid(npcCell) == false && isIdValid(targetCell) == false) - { - return true; + if (!isIdValid(npcCell) && !isIdValid(targetCell)) { + return true; //we're both outside } - else if (isIdValid(npcCell) == false || isIdValid(targetCell) == false) - { + else if (!isIdValid(npcCell) || !isIdValid(targetCell)) { return false; } obj_id npcBldg = getTopMostContainer(npc); obj_id targetBldg = getTopMostContainer(target); - if (npcBldg == targetBldg) - { - return (canSee(npc, target)); - } - else - { - return false; - } + return npcBldg == targetBldg && (canSee(npc, target));//we're in the same building (and can see each other) } public static String getAttackString(int hash) throws InterruptedException { - String outstring = "@combat_effects:"; if (hash == 0) { return "@combat_effects:none"; } int[] attacks = dataTableGetIntColumn("datatables/ai/special_attack.iff", "ATTACK_HASH"); - String[] attackstrings = dataTableGetStringColumn("datatables/ai/special_attack.iff", "ATTACK_STRING"); for (int i = 0; i < attacks.length; i++) { if (hash == attacks[i]) { - return "@combat_effects:" + attackstrings[i]; + return "@combat_effects:" + dataTableGetStringColumn("datatables/ai/special_attack.iff", "ATTACK_STRING")[i]; } } return "@combat_effects:unknown_attack"; @@ -1627,10 +1397,7 @@ public class ai_lib extends script.base_script { return null; } - else - { - return dataTableGetString(CREATURE_TABLE, creatureName, "milkType"); - } + return dataTableGetString(CREATURE_TABLE, creatureName, "milkType"); } public static boolean checkForSmuggler(obj_id player) throws InterruptedException { @@ -1638,39 +1405,35 @@ public class ai_lib extends script.base_script { return false; } - else + int evadeScan = 0; + if (hasSkill(player, "class_smuggler_phase1_novice")) { - int evadeScan = 0; - if (hasSkill(player, "class_smuggler_phase1_novice")) - { - evadeScan = evadeScan + 15; - } - if (hasSkill(player, "class_smuggler_phase2_03")) - { - evadeScan = evadeScan + 15; - } - if (hasSkill(player, "class_smuggler_phase2_novice")) - { - evadeScan = evadeScan + 15; - } - if (hasSkill(player, "class_smuggler_phase3_novice")) - { - evadeScan = evadeScan + 15; - } - if (hasSkill(player, "class_smuggler_phase4_novice")) - { - evadeScan = evadeScan + 15; - } - if (hasSkill(player, "class_smuggler_phase4_master")) - { - evadeScan = evadeScan + 20; - } - int roll = rand(1, 100); - if (roll > evadeScan) - { - sendSystemMessage(player, SMUGGLER_SCAN_FAIL); - return false; - } + evadeScan += 15; + } + if (hasSkill(player, "class_smuggler_phase2_03")) + { + evadeScan += 15; + } + if (hasSkill(player, "class_smuggler_phase2_novice")) + { + evadeScan += 15; + } + if (hasSkill(player, "class_smuggler_phase3_novice")) + { + evadeScan += 15; + } + if (hasSkill(player, "class_smuggler_phase4_novice")) + { + evadeScan += 15; + } + if (hasSkill(player, "class_smuggler_phase4_master")) + { + evadeScan += 20; + } + if (rand(1, 100) > evadeScan) + { + sendSystemMessage(player, SMUGGLER_SCAN_FAIL); + return false; } sendSystemMessage(player, SMUGGLER_SCAN_SUCCESS); return true; @@ -1684,7 +1447,7 @@ public class ai_lib extends script.base_script int mindTrick = 0; if (isGod(player)) { - mindTrick += 101; + return true; } else if (badge.hasBadge(player, "bdg_jedi_elder") || getState(player, STATE_GLOWING_JEDI) != 0) { @@ -1698,12 +1461,7 @@ public class ai_lib extends script.base_script { mindTrick += 10; } - int roll = rand(1, 100); - if (roll > mindTrick) - { - return false; - } - return true; + return rand(1, 100) <= mindTrick; } public static boolean setupNpc(obj_id npc, boolean conversable, boolean invulnerable) throws InterruptedException { @@ -1732,11 +1490,11 @@ public class ai_lib extends script.base_script } Vector linkedCreatures = new Vector(); linkedCreatures.setSize(0); - for (int i = 0; i < creatures.length; i++) - { - if ((getSocialGroup(creatures[i])).equals(socialGroup)) - { - utils.addElement(linkedCreatures, creatures[i]); + String creatureSocialGroup; + for (obj_id creature : creatures) { + creatureSocialGroup = getSocialGroup(creature); + if (creatureSocialGroup != null && creatureSocialGroup.equals(socialGroup)) { + utils.addElement(linkedCreatures, creature); } } if (linkedCreatures.size() == 0) @@ -1744,20 +1502,14 @@ public class ai_lib extends script.base_script return; } obj_id[] creatureList = new obj_id[0]; - if (linkedCreatures != null) - { - creatureList = new obj_id[linkedCreatures.size()]; - linkedCreatures.toArray(creatureList); - } - if (creatureList == null || creatureList.length == 0) + creatureList = new obj_id[linkedCreatures.size()]; + linkedCreatures.toArray(creatureList); + + if (creatureList.length == 0) { return; } utils.setScriptVar(subject, ALLY_LIST, creatureList); - for (int k = 0; k < creatureList.length; k++) - { - utils.setScriptVar(subject, ALLY_LIST, creatureList); - } } public static void establishAgroLink(obj_id subject, obj_id[] allies) throws InterruptedException { @@ -1766,10 +1518,6 @@ public class ai_lib extends script.base_script return; } utils.setScriptVar(subject, ALLY_LIST, allies); - for (int i = 0; i < allies.length; i++) - { - utils.setScriptVar(allies[i], ALLY_LIST, allies); - } } public static void triggerAgroLinks(obj_id subject, obj_id attacker) throws InterruptedException { @@ -1782,17 +1530,12 @@ public class ai_lib extends script.base_script { return; } - for (int i = 0; i < allyList.length; i++) - { - if (isIdValid(allyList[i]) && exists(allyList[i]) && !isDead(allyList[i])) - { - if (!isInCombat(allyList[i])) - { - startCombat(allyList[i], attacker); - } - else - { - addHate(allyList[i], attacker, 1); + for (obj_id ally : allyList) { + if (isIdValid(ally) && exists(ally) && !isDead(ally)) { + if (!isInCombat(ally)) { + startCombat(ally, attacker); + } else { + addHate(ally, attacker, 1); } } } @@ -1804,10 +1547,8 @@ public class ai_lib extends script.base_script String creatureName = getCreatureName(creature); if (creatureName.indexOf("elite_") < 1 && creatureName.indexOf("boss_") < 1) { - dictionary creatureDict = utils.dataTableGetRow(CREATURE_TABLE, creatureName); - create.initializeCreature(creature, creatureName, creatureDict, getLevel(creature) + 1); + create.initializeCreature(creature, creatureName, utils.dataTableGetRow(CREATURE_TABLE, creatureName), getLevel(creature) + 1); } - return; } public static boolean mindTrick(obj_id player, obj_id target) throws InterruptedException { @@ -1861,28 +1602,23 @@ public class ai_lib extends script.base_script { return totalDamage; } - for (int q = 0; q < allies.size(); q++) - { - if (!isIdValid(((obj_id)allies.get(q))) || !exists(((obj_id)allies.get(q))) || isDead(((obj_id)allies.get(q))) || aiIsTethered(((obj_id)allies.get(q)))) - { + for (Object ally : allies) { + if (!isIdValid(((obj_id) ally)) || !exists(((obj_id) ally)) || isDead(((obj_id) ally)) || aiIsTethered(((obj_id) ally))) { continue; } - validList.add(((obj_id)allies.get(q))); + validList.add(((obj_id) ally)); } utils.setScriptVar(self, ai_lib.SHARED_HEALTH_LIST, validList); if (validList.size() < 2) { return totalDamage; } - int divisor = validList.size(); - int split = Math.round((float)totalDamage / (float)divisor); - for (int k = 0; k < validList.size(); k++) - { - if (((obj_id)validList.get(k)) == self) - { + int split = Math.round((float) totalDamage / (float) validList.size()); + for (Object aValidList : validList) { + if (aValidList == self) { continue; } - damage(((obj_id)validList.get(k)), DAMAGE_ELEMENTAL_HEAT, HIT_LOCATION_BODY, split); + damage(((obj_id) aValidList), DAMAGE_ELEMENTAL_HEAT, HIT_LOCATION_BODY, split); } return split; } diff --git a/sku.0/sys.server/compiled/game/script/library/armor.java b/sku.0/sys.server/compiled/game/script/library/armor.java index 5bfa3d4aa..43a1f1ddf 100755 --- a/sku.0/sys.server/compiled/game/script/library/armor.java +++ b/sku.0/sys.server/compiled/game/script/library/armor.java @@ -1,17 +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.util.Enumeration; import java.util.Map; -import script.library.skill; -import script.library.trial; public class armor extends script.base_script { @@ -103,9 +95,9 @@ public class armor extends script.base_script public static final String SID_ARMOR_CATEGORY = "armor_category"; public static final Integer[] ARMOR_CATEGORY_INDEXES = { - new Integer(AC_reconnaissance), - new Integer(AC_battle), - new Integer(AC_assault) + AC_reconnaissance, + AC_battle, + AC_assault }; public static final String[] SID_ARMOR_CATEGORIES = { @@ -116,27 +108,27 @@ public class armor extends script.base_script public static final Map ARMOR_CATEGORY_MAP = collections.newMap(ARMOR_CATEGORY_INDEXES, SID_ARMOR_CATEGORIES); public static final Integer[] ARMOR_PENALTY_DATATABLE_TYPES = { - new Integer(getStringCrc("basic_recon")), - new Integer(getStringCrc("std_recon")), - new Integer(getStringCrc("adv_recon")), - new Integer(getStringCrc("basic_battle")), - new Integer(getStringCrc("std_battle")), - new Integer(getStringCrc("adv_battle")), - new Integer(getStringCrc("basic_assault")), - new Integer(getStringCrc("std_assault")), - new Integer(getStringCrc("adv_assault")) + getStringCrc("basic_recon"), + getStringCrc("std_recon"), + getStringCrc("adv_recon"), + getStringCrc("basic_battle"), + getStringCrc("std_battle"), + getStringCrc("adv_battle"), + getStringCrc("basic_assault"), + getStringCrc("std_assault"), + getStringCrc("adv_assault") }; public static final Integer[] ARMOR_PENALTY_OBJECT_TYPES = { - new Integer(AC_reconnaissance * 10 + AL_basic), - new Integer(AC_reconnaissance * 10 + AL_standard), - new Integer(AC_reconnaissance * 10 + AL_advanced), - new Integer(AC_battle * 10 + AL_basic), - new Integer(AC_battle * 10 + AL_standard), - new Integer(AC_battle * 10 + AL_advanced), - new Integer(AC_assault * 10 + AL_basic), - new Integer(AC_assault * 10 + AL_standard), - new Integer(AC_assault * 10 + AL_advanced) + AL_basic, + AL_standard, + AL_advanced, + AC_battle * 10 + AL_basic, + AC_battle * 10 + AL_standard, + AC_battle * 10 + AL_advanced, + AC_assault * 10 + AL_basic, + AC_assault * 10 + AL_standard, + AC_assault * 10 + AL_advanced }; public static final Map ARMOR_PENALTY_TYPE_MAP = collections.newMap(ARMOR_PENALTY_OBJECT_TYPES, ARMOR_PENALTY_DATATABLE_TYPES); public static final int ARMOR_MOVE_PENALTY = 0; @@ -145,10 +137,10 @@ public class armor extends script.base_script public static final int ARMOR_DEFENSE_PENALTY = 3; public static final Integer[] ARMOR_PENALTY_INDEXES = { - new Integer(ARMOR_MOVE_PENALTY), - new Integer(ARMOR_ACCURACY_PENALTY), - new Integer(ARMOR_ATTACK_PENALTY), - new Integer(ARMOR_DEFENSE_PENALTY) + ARMOR_MOVE_PENALTY, + ARMOR_ACCURACY_PENALTY, + ARMOR_ATTACK_PENALTY, + ARMOR_DEFENSE_PENALTY }; public static final String[] ARMOR_PENALTY_DATATABLE_COLUMNS = { @@ -408,23 +400,19 @@ public class armor extends script.base_script { return null; } - String attrib_inc = dataTableGetString(DATATABLE_ARMOR, layerRow, DATATABLE_ATTRIB_INC_COL); - String attrib_dec = dataTableGetString(DATATABLE_ARMOR, layerRow, DATATABLE_ATTRIB_DEC_COL); - String[] attrib_incs = split(attrib_inc, ','); - String[] attrib_decs = split(attrib_dec, ','); + String[] attrib_incs = split(dataTableGetString(DATATABLE_ARMOR, layerRow, DATATABLE_ATTRIB_INC_COL), ','); + String[] attrib_decs = split(dataTableGetString(DATATABLE_ARMOR, layerRow, DATATABLE_ATTRIB_DEC_COL), ','); dictionary protections = new dictionary(); if (attrib_incs != null) { - for (int i = 0; i < attrib_incs.length; ++i) - { - protections.addFloat(attrib_incs[i], newValue); + for (String attrib_inc : attrib_incs) { + protections.addFloat(attrib_inc, newValue); } } if (attrib_decs != null) { - for (int i = 0; i < attrib_decs.length; ++i) - { - protections.addFloat(attrib_decs[i], -newValue); + for (String attrib_dec : attrib_decs) { + protections.addFloat(attrib_dec, -newValue); } } return protections; @@ -435,12 +423,12 @@ public class armor extends script.base_script { return null; } - Object o = ARMOR_PENALTY_TYPE_MAP.get(new Integer(armorCategory * 10 + armorLevel)); + Object o = ARMOR_PENALTY_TYPE_MAP.get(armorCategory * 10 + armorLevel); if (o == null || !(o instanceof Integer)) { return null; } - int row = dataTableSearchColumnForInt((((Integer)o)).intValue(), DATATABLE_TYPE_PENALTY_COL, DATATABLE_ARMOR_PENALTY); + int row = dataTableSearchColumnForInt((Integer) o, DATATABLE_TYPE_PENALTY_COL, DATATABLE_ARMOR_PENALTY); if (row < 0) { return null; @@ -459,7 +447,7 @@ public class armor extends script.base_script } public static float[] getScaledArmorPenalties(obj_id armor, float generalProtection, int armorRow, int armorLevel, int armorCategory) throws InterruptedException { - float[] penalties = null; + float[] penalties; if (isIdValid(armor)) { penalties = utils.getFloatArrayScriptVar(armor, SCRIPTVAR_CACHED_PENALTIES); @@ -508,9 +496,10 @@ public class armor extends script.base_script "firerate" }; float[] certPenalties = new float[penalties.length]; + String certName; for (int i = 0; i < ARMOR_DEFENSE_PENALTY; i++) { - String certName = armorCatNames[armorCategory] + "_" + armorPenaltyNames[i] + "_mitigate_"; + certName = armorCatNames[armorCategory] + "_" + armorPenaltyNames[i] + "_mitigate_"; certPenalties[i] = penalties[i]; for (int j = 3; j > 0; j--) { @@ -536,27 +525,22 @@ public class armor extends script.base_script obj_id[] wornItems = metrics.getWornItems(player); if (wornItems != null) { - for (int i = 0; i < wornItems.length; i++) - { - int got = getGameObjectType(wornItems[i]); - if (isGameObjectTypeOf(got, GOT_armor) && (!isGameObjectTypeOf(got, GOT_armor_foot) && !isGameObjectTypeOf(got, GOT_armor_hand))) - { + int got; + for (obj_id wornItem : wornItems) { + got = getGameObjectType(wornItem); + if (isGameObjectTypeOf(got, GOT_armor) && (!isGameObjectTypeOf(got, GOT_armor_foot) && !isGameObjectTypeOf(got, GOT_armor_hand))) { float[] penalties; - penalties = getFinalArmorPenalties(player, wornItems[i]); - if (penalties == null) - { + penalties = getFinalArmorPenalties(player, wornItem); + if (penalties == null) { continue; } - if (penalties[0] > movePenalty) - { + if (penalties[0] > movePenalty) { movePenalty = penalties[0]; } - if (penalties[1] > toHitPenalty) - { + if (penalties[1] > toHitPenalty) { toHitPenalty = penalties[1]; } - if (penalties[2] > fireRatePenalty) - { + if (penalties[2] > fireRatePenalty) { fireRatePenalty = penalties[2]; } } @@ -588,7 +572,6 @@ public class armor extends script.base_script { buff.removeBuff(player, (1005058320)); } - return; } public static void calculateWornArmor(obj_id player) throws InterruptedException { @@ -596,11 +579,10 @@ public class armor extends script.base_script int armorCount = 0; if (wornItems != null) { - for (int i = 0; i < wornItems.length; i++) - { - int got = getGameObjectType(wornItems[i]); - if (isGameObjectTypeOf(got, GOT_armor) && !isGameObjectTypeOf(got, GOT_armor_psg)) - { + int got; + for (obj_id wornItem : wornItems) { + got = getGameObjectType(wornItem); + if (isGameObjectTypeOf(got, GOT_armor) && !isGameObjectTypeOf(got, GOT_armor_psg)) { armorCount++; break; } @@ -614,7 +596,6 @@ public class armor extends script.base_script { utils.removeScriptVar(player, SCRIPTVAR_ARMOR_COUNT); } - return; } public static float[] getFinalArmorPenalties(obj_id player, obj_id armorPiece) throws InterruptedException { @@ -631,8 +612,7 @@ public class armor extends script.base_script CustomerServiceLog("armor", "WARNING: could not find armor datatable row for armor " + armorPiece); return null; } - String armorBaseObjVar = armor.getArmorBaseObjvar(armorType); - obj_var_list armorData = getObjVarList(armorPiece, armorBaseObjVar); + obj_var_list armorData = getObjVarList(armorPiece, armor.getArmorBaseObjvar(armorType)); if (armorData == null) { CustomerServiceLog("armor", "WARNING: unable to get armor data for armor/component " + armorPiece); @@ -672,7 +652,6 @@ public class armor extends script.base_script return true; } int armorType = getGameObjectType(armorPiece); - int armorCategory = -1; if (isGameObjectTypeOf(armorType, GOT_cybernetic)) { return true; @@ -685,8 +664,7 @@ public class armor extends script.base_script { armorType = GOT_armor; } - int armorRow = armor.getArmorDatatableRow(armorPiece); - if (armorRow < 0) + if (armor.getArmorDatatableRow(armorPiece) < 0) { if (hasScript(armorPiece, "item.armor.new_armor")) { @@ -709,8 +687,8 @@ public class armor extends script.base_script return false; } } - String armorBaseObjVar = armor.getArmorBaseObjvar(armorType); - obj_var_list armorData = getObjVarList(armorPiece, armorBaseObjVar); + obj_var_list armorData = getObjVarList(armorPiece, armor.getArmorBaseObjvar(armorType)); + int armorCategory; if (armorData != null) { if (!armorData.hasObjVar(armor.OBJVAR_ARMOR_CATEGORY)) @@ -733,11 +711,7 @@ public class armor extends script.base_script CustomerServiceLog("armor", "WARNING: could not determine armor type for armor " + armorPiece); return false; } - if (hasCommand(player, "wear_all_armor")) - { - return true; - } - return false; + return hasCommand(player, "wear_all_armor"); } public static float convertArmorData(float value, int fromRow, int toRow, String column) throws InterruptedException { @@ -767,13 +741,15 @@ public class armor extends script.base_script if (!hasObjVar(schematic, craftinglib.COMPONENT_ATTRIBUTE_INTERNAL_OBJVAR_NAME + ".isScaled")) { Enumeration keys = componentData.keys(); + float value; + float newValue; + String key; while (keys.hasMoreElements()) { - String key = (String)(keys.nextElement()); - // scaling ignored the fact that not all objvars were floats. Instead of letting it throw a warning, just scale objvars that are floats and ints + key = (String)(keys.nextElement()); if(componentData.isFloatObjVar(key) || componentData.isIntObjVar(key)) { - float value = (componentData.isFloatObjVar(key) ? componentData.getFloatObjVar(key) : componentData.getIntObjVar(key)); - float newValue = (float) rescaleArmorData(key, fromRow, toRow, value); + value = (componentData.isFloatObjVar(key) ? componentData.getFloatObjVar(key) : componentData.getIntObjVar(key)); + newValue = rescaleArmorData(key, fromRow, toRow, value); if (newValue != Float.MIN_VALUE) { debugServerConsoleMsg(null, "Armor scaling component data " + key + " from " + value + " to " + newValue + "(fromRow = " + fromRow + ", toRow = " + toRow + ")"); @@ -804,57 +780,53 @@ public class armor extends script.base_script } public static void updateItemAttributes(obj_id schematic, draft_schematic.attribute[] itemAttributes, int armorRow) throws InterruptedException { - for (int i = 0; i < itemAttributes.length; ++i) - { - if (itemAttributes[i] == null) - { + float resourceScale; + float value; + String componentName; + float componentValue; + int minProtection; + int maxProtection; + int minCondition; + int maxCondition; + + for (draft_schematic.attribute itemAttribute : itemAttributes) { + if (itemAttribute == null) { continue; } - if ((itemAttributes[i].name).equals(OBJVAR_GENERAL_PROTECTION)) - { - float resourceScale = dataTableGetFloat(DATATABLE_ARMOR, armorRow, DATATABLE_RES_GEN_PROT_COL) / 100.0f; - float value = itemAttributes[i].currentValue * resourceScale; - String componentName = craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + ".scaled." + OBJVAR_GENERAL_PROTECTION; - if (hasObjVar(schematic, componentName)) - { - float componentValue = getFloatObjVar(schematic, componentName); + if ((itemAttribute.name).equals(OBJVAR_GENERAL_PROTECTION)) { + resourceScale = dataTableGetFloat(DATATABLE_ARMOR, armorRow, DATATABLE_RES_GEN_PROT_COL) / 100.0f; + value = itemAttribute.currentValue * resourceScale; + componentName = craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + ".scaled." + OBJVAR_GENERAL_PROTECTION; + if (hasObjVar(schematic, componentName)) { + componentValue = getFloatObjVar(schematic, componentName); value += componentValue; - int minProtection = dataTableGetInt(DATATABLE_ARMOR, armorRow, DATATABLE_MIN_GEN_PROT_COL); - int maxProtection = dataTableGetInt(DATATABLE_ARMOR, armorRow, DATATABLE_MAX_GEN_PROT_COL); - if (maxProtection != minProtection && minProtection != 0) - { - value += ((float)minProtection) / ((float)(maxProtection - minProtection)); + minProtection = dataTableGetInt(DATATABLE_ARMOR, armorRow, DATATABLE_MIN_GEN_PROT_COL); + maxProtection = dataTableGetInt(DATATABLE_ARMOR, armorRow, DATATABLE_MAX_GEN_PROT_COL); + if (maxProtection != minProtection && minProtection != 0) { + value += ((float) minProtection) / ((float) (maxProtection - minProtection)); } - debugServerConsoleMsg(null, "Armor scaling general protection from resource value " + itemAttributes[i].currentValue + ", component value " + componentValue + " to " + value); + debugServerConsoleMsg(null, "Armor scaling general protection from resource value " + itemAttribute.currentValue + ", component value " + componentValue + " to " + value); + } else { + debugServerConsoleMsg(null, "Armor scaling general protection from resource value " + itemAttribute.currentValue + " to " + value); } - else - { - debugServerConsoleMsg(null, "Armor scaling general protection from resource value " + itemAttributes[i].currentValue + " to " + value); - } - itemAttributes[i].currentValue = value; - } - else if ((itemAttributes[i].name).equals(OBJVAR_CONDITION)) - { - float resourceScale = dataTableGetFloat(DATATABLE_ARMOR, armorRow, DATATABLE_RES_CONDITION_COL) / 100.0f; - float value = itemAttributes[i].currentValue * resourceScale; - String componentName = craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + ".scaled." + OBJVAR_CONDITION; - if (hasObjVar(schematic, componentName)) - { - float componentValue = getFloatObjVar(schematic, componentName); + itemAttribute.currentValue = value; + } else if ((itemAttribute.name).equals(OBJVAR_CONDITION)) { + resourceScale = dataTableGetFloat(DATATABLE_ARMOR, armorRow, DATATABLE_RES_CONDITION_COL) / 100.0f; + value = itemAttribute.currentValue * resourceScale; + componentName = craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME + ".scaled." + OBJVAR_CONDITION; + if (hasObjVar(schematic, componentName)) { + componentValue = getFloatObjVar(schematic, componentName); value += componentValue; - int minCondition = dataTableGetInt(DATATABLE_ARMOR, armorRow, DATATABLE_MIN_CONDITION_COL); - int maxCondition = dataTableGetInt(DATATABLE_ARMOR, armorRow, DATATABLE_MAX_CONDITION_COL); - if (maxCondition != minCondition && minCondition != 0) - { - value += ((float)minCondition) / ((float)(maxCondition - minCondition)); + minCondition = dataTableGetInt(DATATABLE_ARMOR, armorRow, DATATABLE_MIN_CONDITION_COL); + maxCondition = dataTableGetInt(DATATABLE_ARMOR, armorRow, DATATABLE_MAX_CONDITION_COL); + if (maxCondition != minCondition && minCondition != 0) { + value += ((float) minCondition) / ((float) (maxCondition - minCondition)); } - debugServerConsoleMsg(null, "Armor scaling condition from resource value " + itemAttributes[i].currentValue + ", component value " + componentValue + " to " + value); + debugServerConsoleMsg(null, "Armor scaling condition from resource value " + itemAttribute.currentValue + ", component value " + componentValue + " to " + value); + } else { + debugServerConsoleMsg(null, "Armor scaling condition from resource value " + itemAttribute.currentValue + " to " + value); } - else - { - debugServerConsoleMsg(null, "Armor scaling condition from resource value " + itemAttributes[i].currentValue + " to " + value); - } - itemAttributes[i].currentValue = value; + itemAttribute.currentValue = value; } } } @@ -865,10 +837,14 @@ public class armor extends script.base_script if (componentData != null) { Enumeration keys = componentData.keys(); + String key; + float value; + boolean haveAttribute; + while (keys.hasMoreElements()) { - String key = (String)(keys.nextElement()); - float value = componentData.getFloatObjVar(key); + key = (String)(keys.nextElement()); + value = componentData.getFloatObjVar(key); if (value < 0) { value = 0; @@ -877,11 +853,9 @@ public class armor extends script.base_script { value = 1.0f; } - boolean haveAttribute = false; - for (int i = 0; i < itemAttributes.length; ++i) - { - if ((itemAttributes[i].name).equals(key)) - { + haveAttribute = false; + for (draft_schematic.attribute itemAttribute : itemAttributes) { + if ((itemAttribute.name).equals(key)) { haveAttribute = true; break; } @@ -1070,8 +1044,7 @@ public class armor extends script.base_script { return -1; } - int row = dataTableSearchColumnForString(template, "crafted_object_template", DATATABLE_MASTER_ARMOR); - return row; + return dataTableSearchColumnForString(template, "crafted_object_template", DATATABLE_MASTER_ARMOR); } public static int getArmorCategoryByTemplate(String template) throws InterruptedException { @@ -1080,28 +1053,17 @@ public class armor extends script.base_script { return -1; } - int cat = dataTableGetInt(DATATABLE_MASTER_ARMOR, row, "category"); - return cat; + return dataTableGetInt(DATATABLE_MASTER_ARMOR, row, "category"); } - public static boolean setArmorDataPercent(obj_id target, int armorLevel, int armorCategory, float generalProtection, float condition) throws InterruptedException - { - if (!initializeArmor(target, armorLevel, armorCategory)) - { - return false; - } - return _setArmorDataPercent(target, generalProtection, condition, false); + public static boolean setArmorDataPercent(obj_id target, int armorLevel, int armorCategory, float generalProtection, float condition) throws InterruptedException { + return initializeArmor(target, armorLevel, armorCategory) && _setArmorDataPercent(target, generalProtection, condition, false); } public static boolean setArmorDataPercent(obj_id target, float generalProtection, float condition) throws InterruptedException { return _setArmorDataPercent(target, generalProtection, condition, true); } - public static boolean setAbsoluteArmorData(obj_id target, int armorLevel, int armorCategory, int generalProtection, int condition) throws InterruptedException - { - if (!initializeArmor(target, armorLevel, armorCategory)) - { - return false; - } - return setAbsoluteArmorData(target, generalProtection, condition); + public static boolean setAbsoluteArmorData(obj_id target, int armorLevel, int armorCategory, int generalProtection, int condition) throws InterruptedException { + return initializeArmor(target, armorLevel, armorCategory) && setAbsoluteArmorData(target, generalProtection, condition); } public static boolean setAbsoluteArmorData(obj_id target, int generalProtection, int condition) throws InterruptedException { @@ -1247,8 +1209,7 @@ public class armor extends script.base_script CustomerServiceLog("armor", "WARNING: armor object (" + armor + ") missing objvar " + genProtectionObjVar); return -1; } - float value = getFloatObjVar(armor, genProtectionObjVar); - float genProtection = getAbsoluteArmorAttribute(value, row, DATATABLE_MIN_GEN_PROT_COL); + float genProtection = getAbsoluteArmorAttribute(getFloatObjVar(armor, genProtectionObjVar), row, DATATABLE_MIN_GEN_PROT_COL); utils.setScriptVar(armor, SCRIPTVAR_CACHED_GENERAL_PROTECTION, (int)genProtection); return (int)genProtection; } @@ -1268,30 +1229,35 @@ public class armor extends script.base_script { return protections; } - String baseObjvar = getArmorBaseObjvar(armor); boolean isLayer = isArmorLayer(armor); float generalProtection = 0; if (!isLayer) { generalProtection = getArmorGeneralProtection(armor); } + obj_var layer; + dictionary layerProtections; + Enumeration keys; + Object key; + float protection; + for (int i = 0; i < NUM_DATATABLE_ARMOR_LAYERS; i++) { - obj_var layer = getObjVar(armor, baseObjvar + "." + OBJVAR_LAYER_PREFIX + i); + layer = getObjVar(armor, getArmorBaseObjvar(armor) + "." + OBJVAR_LAYER_PREFIX + i); if (layer != null) { - dictionary layerProtections = getAbsoluteArmorSpecialProtection(armor, DATATABLE_LAYER_ROW + i, layer.getFloatData(), row); + layerProtections = getAbsoluteArmorSpecialProtection(armor, DATATABLE_LAYER_ROW + i, layer.getFloatData(), row); if (layerProtections != null) { if (protections == null) { protections = new dictionary(); } - Enumeration keys = layerProtections.keys(); + keys = layerProtections.keys(); while (keys.hasMoreElements()) { - Object key = keys.nextElement(); - float protection = layerProtections.getFloat(key); + key = keys.nextElement(); + protection = layerProtections.getFloat(key); if (!isLayer && protection + generalProtection < 0) { protection = -generalProtection; @@ -1330,10 +1296,13 @@ public class armor extends script.base_script efficiency = 0; } Enumeration keys = protections.keys(); + String key; + float value; + while (keys.hasMoreElements()) { - String key = (String)(keys.nextElement()); - float value = protections.getFloat(key) * efficiency; + key = (String) (keys.nextElement()); + value = protections.getFloat(key) * efficiency; if (value + generalProtection < 0) { value = -generalProtection; @@ -1392,9 +1361,11 @@ public class armor extends script.base_script } public static void recalculateArmorForMob(obj_id mob) throws InterruptedException { - int mobGeneralArmor = (int)getFloatObjVar(mob, OBJVAR_ARMOR_BASE + "." + OBJVAR_GENERAL_PROTECTION); - int innateProtectionAll = (int)getSkillStatisticModifier(mob, "expertise_innate_protection_all"); - utils.setScriptVar(mob, SCRIPTVAR_CACHED_GENERAL_PROTECTION, (mobGeneralArmor + innateProtectionAll)); + utils.setScriptVar( + mob, + SCRIPTVAR_CACHED_GENERAL_PROTECTION, + ((int) getFloatObjVar(mob, OBJVAR_ARMOR_BASE + "." + OBJVAR_GENERAL_PROTECTION) + (int) getSkillStatisticModifier(mob, "expertise_innate_protection_all")) + ); } public static void recalculateArmorForPlayer(obj_id objPlayer) throws InterruptedException { @@ -1431,17 +1402,23 @@ public class armor extends script.base_script int lastArmorType = -1; int numLikePieces = 0; int armorSetWorn = -1; - int numClothingPieces = 0; int[] armorTallyType = { 0, 0, 0 }; + obj_id objArmor; + float fltWeight; + float fltSpecialProt; + int thisArmorType; + float fltArmorGeneralProtection; + float fltReduction; + for (int intI = 0; intI < strArmor.length; intI++) { - obj_id objArmor = getObjectInSlot(objPlayer, strArmor[intI]); - float fltWeight = fltWeightings[intI]; + objArmor = getObjectInSlot(objPlayer, strArmor[intI]); + fltWeight = fltWeightings[intI]; if (strArmor[intI].equals("chest2") && isIdNull(objArmor)) { objArmor = getObjectInSlot(objPlayer, "chest1"); @@ -1458,7 +1435,7 @@ public class armor extends script.base_script { if (hasObjVar(objArmor, "armor.fake_armor." + DATATABLE_SPECIAL_PROTECTIONS[i])) { - float fltSpecialProt = (float)getIntObjVar(objArmor, "armor.fake_armor." + DATATABLE_SPECIAL_PROTECTIONS[i]); + fltSpecialProt = (float) getIntObjVar(objArmor, "armor.fake_armor." + DATATABLE_SPECIAL_PROTECTIONS[i]); if (fltSpecialProt != 0) { fltSpecialProts[i] += fltWeight * fltSpecialProt; @@ -1477,7 +1454,7 @@ public class armor extends script.base_script } if (hasObjVar(objArmor, "armor.armorCategory")) { - int thisArmorType = getIntObjVar(objArmor, "armor.armorCategory"); + thisArmorType = getIntObjVar(objArmor, "armor.armorCategory"); if (intI == 0) { lastArmorType = getIntObjVar(objArmor, "armor.armorCategory"); @@ -1500,8 +1477,8 @@ public class armor extends script.base_script { LOG("armor.recalculateArmorForPlayer ", "checking is armor of obj_id: " + objArmor); dictionary dctSpecialProtections = getArmorSpecialProtections(objArmor); - float fltArmorGeneralProtection = (float)utils.getIntScriptVar(objArmor, armor.SCRIPTVAR_CACHED_GENERAL_PROTECTION); - float fltReduction = combat.getArmorDecayPercentage(objArmor); + fltArmorGeneralProtection = (float) utils.getIntScriptVar(objArmor, armor.SCRIPTVAR_CACHED_GENERAL_PROTECTION); + fltReduction = combat.getArmorDecayPercentage(objArmor); fltArmorGeneralProtection = fltArmorGeneralProtection * fltReduction; if (dctSpecialProtections != null) { @@ -1509,7 +1486,7 @@ public class armor extends script.base_script { if (armor.DATATABLE_SPECIAL_PROTECTIONS[intJ] != null) { - float fltSpecialProt = dctSpecialProtections.getFloat(armor.DATATABLE_SPECIAL_PROTECTIONS[intJ]); + fltSpecialProt = dctSpecialProtections.getFloat(armor.DATATABLE_SPECIAL_PROTECTIONS[intJ]); if (fltSpecialProt != 0) { fltSpecialProts[intJ] += fltWeight * fltSpecialProt; @@ -1526,10 +1503,10 @@ public class armor extends script.base_script float fltInnateProtectionAll = getSkillStatisticModifier(objPlayer, "expertise_innate_protection_all"); fltGeneralProtection = fltGeneralProtection / fltTotal; dictionary dctProtections = new dictionary(); + int intMod; for (int intI = 0; intI < fltSpecialProts.length; intI++) { fltSpecialProts[intI] = fltSpecialProts[intI] / fltTotal; - fltTempProtection = 0; fltSpecialProts[intI] += fltInnateProtectionAll; fltSpecialProts[intI] += getSkillStatisticModifier(objPlayer, "expertise_innate_protection_" + DATATABLE_SPECIAL_PROTECTIONS[intI]); fltSpecialProts[intI] += getSkillStatisticModifier(objPlayer, "expertise_armorset_protection_" + armorSetWorn + "_" + DATATABLE_SPECIAL_PROTECTIONS[intI]); @@ -1545,17 +1522,15 @@ public class armor extends script.base_script { fltSpecialProts[intI] += fltTempProtection = getSkillStatisticModifier(objPlayer, "expertise_overridable_protection_" + DATATABLE_SPECIAL_PROTECTIONS[intI]) + fltGenericProtection; } - int intMod = (int)(fltSpecialProts[intI] + fltGeneralProtection + 0.5f); + intMod = (int) (fltSpecialProts[intI] + fltGeneralProtection + 0.5f); applySkillStatisticModifier(objPlayer, DATATABLE_SPECIAL_PROTECTIONS[intI], -1 * getSkillStatisticModifier(objPlayer, DATATABLE_SPECIAL_PROTECTIONS[intI])); applySkillStatisticModifier(objPlayer, DATATABLE_SPECIAL_PROTECTIONS[intI], intMod); dctProtections.put(armor.DATATABLE_SPECIAL_PROTECTIONS[intI], fltSpecialProts[intI]); } utils.setScriptVar(objPlayer, armor.SCRIPTVAR_CACHED_SPECIAL_PROTECTIONS, dctProtections); - int intProtection = (int)fltGeneralProtection; - utils.setScriptVar(objPlayer, armor.SCRIPTVAR_CACHED_GENERAL_PROTECTION, intProtection); + utils.setScriptVar(objPlayer, armor.SCRIPTVAR_CACHED_GENERAL_PROTECTION, (int)fltGeneralProtection); utils.setScriptVar(objPlayer, "armor.armor_set_worn", armorSetWorn); utils.setScriptVar(objPlayer, "armor.armor_type_tally", armorTallyType); - return; } public static void recalculatePseudoArmorForPlayer(obj_id objPlayer, obj_id item, boolean applyArmor) throws InterruptedException { @@ -1568,16 +1543,19 @@ public class armor extends script.base_script if (intProtection > 0) { dictionary dctProtections = new dictionary(); + int armorValue; + int intMod; + for (int intI = 0; intI < fltSpecialProts.length; intI++) { - int armorValue = 0; + armorValue = 0; if (applyArmor) { armorValue = intProtection; fltSpecialProts[intI] += fltInnateProtectionAll; fltSpecialProts[intI] += getSkillStatisticModifier(objPlayer, "expertise_innate_protection_" + DATATABLE_SPECIAL_PROTECTIONS[intI]); fltSpecialProts[intI] += getSkillStatisticModifier(objPlayer, "expertise_armorset_protection_" + "_" + DATATABLE_SPECIAL_PROTECTIONS[intI]); - int intMod = (int)(fltSpecialProts[intI] + armorValue + 0.5f); + intMod = (int) (fltSpecialProts[intI] + armorValue + 0.5f); applySkillStatisticModifier(objPlayer, DATATABLE_SPECIAL_PROTECTIONS[intI], -1 * getSkillStatisticModifier(objPlayer, DATATABLE_SPECIAL_PROTECTIONS[intI])); applySkillStatisticModifier(objPlayer, DATATABLE_SPECIAL_PROTECTIONS[intI], intMod); dctProtections.put(armor.DATATABLE_SPECIAL_PROTECTIONS[intI], fltSpecialProts[intI]); @@ -1601,7 +1579,6 @@ public class armor extends script.base_script { recalculateArmorForPlayer(objPlayer); } - return; } public static String getPseudoArmorLevel(int pseudoLevel) throws InterruptedException { @@ -1652,12 +1629,11 @@ public class armor extends script.base_script } public static int getExpertiseArmorSetId(obj_id wearer) throws InterruptedException { - int armorSetId = -1; if (utils.hasScriptVar(wearer, "armor.armor_set_worn")) { return utils.getIntScriptVar(wearer, "armor.armor_set_worn"); } - return armorSetId; + return -1; } public static boolean turnArmorIntoSchem(obj_id player, obj_id armor) throws InterruptedException { @@ -1680,9 +1656,7 @@ public class armor extends script.base_script { return false; } - String limitedUseTemplate = "object/tangible/loot/loot_schematic/deconstructed_armor_schematic.iff"; - obj_id pInv = utils.getInventoryContainer(player); - obj_id newSchem = createObjectOverloaded(limitedUseTemplate, pInv); + obj_id newSchem = createObjectOverloaded("object/tangible/loot/loot_schematic/deconstructed_armor_schematic.iff", utils.getInventoryContainer(player)); CustomerServiceLog("new_armor_conversion", "New schematic(" + schemName + ") converted from armor(" + armor + ") for player " + getFirstName(player) + "(" + player + ")"); if (!isIdValid(newSchem) || !exists(newSchem)) { @@ -1691,8 +1665,7 @@ public class armor extends script.base_script setName(newSchem, utils.packStringId(getNameFromTemplate(template))); setObjVar(newSchem, "loot_schematic.schematic", "object/draft_schematic/armor/" + schemName + ".iff"); setObjVar(newSchem, "loot_schematic.uses", 1); - int gotType = getGameObjectType(armor); - if (gotType == GOT_cybernetic_forearm) + if (getGameObjectType(armor) == GOT_cybernetic_forearm) { setObjVar(newSchem, "loot_schematic.skill_req", "class_engineering_phase1_master"); } diff --git a/sku.0/sys.server/compiled/game/script/library/combat.java b/sku.0/sys.server/compiled/game/script/library/combat.java old mode 100644 new mode 100755 index 5e92ebf0a..33e5887b6 --- a/sku.0/sys.server/compiled/game/script/library/combat.java +++ b/sku.0/sys.server/compiled/game/script/library/combat.java @@ -1,26 +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.colors; -import script.library.weapons; -import script.library.utils; -import script.library.jedi; -import script.library.armor; -import script.library.heavyweapons; -import script.library.movement; -import script.library.buff; -import script.library.space_utils; -import script.library.group; -import script.library.static_item; -import script.library.prose; +import java.util.Vector; public class combat extends script.base_script { diff --git a/sku.0/sys.server/compiled/game/script/library/movement.java b/sku.0/sys.server/compiled/game/script/library/movement.java old mode 100644 new mode 100755 index f42046148..309da3b30 --- a/sku.0/sys.server/compiled/game/script/library/movement.java +++ b/sku.0/sys.server/compiled/game/script/library/movement.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 movement extends script.base_script { @@ -104,8 +100,7 @@ public class movement extends script.base_script { utils.setScriptVar(target, MOVEMENT_OBJVAR + "." + name + ".strength", strength); } - final boolean result = refresh(target); - return result; + return refresh(target); } public static boolean removeMovementModifier(obj_id target, String name) throws InterruptedException { @@ -145,44 +140,32 @@ public class movement extends script.base_script { return false; } - for (int i = 0; i < mods.length; i++) - { - removeMovementModifier(target, mods[i], false); + for (String mod : mods) { + removeMovementModifier(target, mod, false); } return refresh(target); } - public static boolean removeAllModifiersOfType(obj_id target, int type) throws InterruptedException - { + public static boolean removeAllModifiersOfType(obj_id target, int type) throws InterruptedException { String[] mods = getAllModifiers(target); - if (mods == null || mods.length == 0) - { + if (mods == null || mods.length == 0) { return false; } boolean removed = false; - for (int i = 0; i < mods.length; i++) - { - if (getType(mods[i]) == type && buff.canBeDispelled(mods[i])) - { - removeMovementModifier(target, mods[i], false); + for (String mod : mods) { + if (getType(mod) == type && buff.canBeDispelled(mod)) { + removeMovementModifier(target, mod, false); removed = true; } } - if (removed) - { - return refresh(target); - } - else - { - return false; - } + return removed && refresh(target); } public static boolean hasMovementModifier(obj_id target) throws InterruptedException { - deltadictionary dd = target.getScriptVars(); - java.util.Enumeration keys = dd.keys(); + java.util.Enumeration keys = target.getScriptVars().keys(); + String key; while (keys.hasMoreElements()) { - String key = (String)(keys.nextElement()); + key = (String)(keys.nextElement()); if (key.startsWith(MOVEMENT_OBJVAR + ".")) { return true; @@ -192,11 +175,7 @@ public class movement extends script.base_script } public static boolean hasMovementModifier(obj_id target, String name) throws InterruptedException { - if (utils.hasScriptVar(target, MOVEMENT_OBJVAR + "." + name + ".time")) - { - return true; - } - return false; + return utils.hasScriptVar(target, MOVEMENT_OBJVAR + "." + name + ".time"); } public static int getType(String name) throws InterruptedException { @@ -242,21 +221,15 @@ public class movement extends script.base_script } public static boolean isValidModifier(int nameCrc) throws InterruptedException { - int row = dataTableSearchColumnForInt(nameCrc, "name", MOVEMENT_TABLE); - return (row >= 0); + return (dataTableSearchColumnForInt(nameCrc, "name", MOVEMENT_TABLE) >= 0); } public static boolean isRoot(String name) throws InterruptedException { return (isRoot(getStringCrc(name.toLowerCase())) || isStunEffect(name)); } - public static boolean isRoot(int nameCrc) throws InterruptedException - { + public static boolean isRoot(int nameCrc) throws InterruptedException { int row = dataTableSearchColumnForInt(nameCrc, "name", MOVEMENT_TABLE); - if (row >= 0) - { - return (dataTableGetInt(MOVEMENT_TABLE, row, "type") == MT_ROOT); - } - return false; + return row >= 0 && (dataTableGetInt(MOVEMENT_TABLE, row, "type") == MT_ROOT); } public static boolean isSnare(String name) throws InterruptedException { @@ -279,53 +252,33 @@ public class movement extends script.base_script { return isPersisted(getStringCrc(name.toLowerCase())); } - public static boolean isPersisted(int nameCrc) throws InterruptedException - { + public static boolean isPersisted(int nameCrc) throws InterruptedException { int row = dataTableSearchColumnForInt(nameCrc, "name", MOVEMENT_TABLE); - if (row >= 0) - { - return (dataTableGetInt(MOVEMENT_TABLE, row, "persistence") == 1); - } - return false; + return row >= 0 && (dataTableGetInt(MOVEMENT_TABLE, row, "persistence") == 1); } public static boolean canAffectOnFoot(String name) throws InterruptedException { return canAffectOnFoot(getStringCrc(name.toLowerCase())); } - public static boolean canAffectOnFoot(int nameCrc) throws InterruptedException - { + public static boolean canAffectOnFoot(int nameCrc) throws InterruptedException { int row = dataTableSearchColumnForInt(nameCrc, "name", MOVEMENT_TABLE); - if (row >= 0) - { - return (dataTableGetInt(MOVEMENT_TABLE, row, "affects_onfoot") == 1); - } - return false; + return row >= 0 && (dataTableGetInt(MOVEMENT_TABLE, row, "affects_onfoot") == 1); } public static boolean canAffectVehicles(String name) throws InterruptedException { return canAffectVehicles(getStringCrc(name.toLowerCase())); } - public static boolean canAffectVehicles(int nameCrc) throws InterruptedException - { + public static boolean canAffectVehicles(int nameCrc) throws InterruptedException { int row = dataTableSearchColumnForInt(nameCrc, "name", MOVEMENT_TABLE); - if (row >= 0) - { - return (dataTableGetInt(MOVEMENT_TABLE, row, "affects_vehicle") == 1); - } - return false; + return row >= 0 && (dataTableGetInt(MOVEMENT_TABLE, row, "affects_vehicle") == 1); } public static boolean canAffectMounts(String name) throws InterruptedException { return canAffectMounts(getStringCrc(name.toLowerCase())); } - public static boolean canAffectMounts(int nameCrc) throws InterruptedException - { + public static boolean canAffectMounts(int nameCrc) throws InterruptedException { int row = dataTableSearchColumnForInt(nameCrc, "name", MOVEMENT_TABLE); - if (row >= 0) - { - return (dataTableGetInt(MOVEMENT_TABLE, row, "affects_mount") == 1); - } - return false; + return row >= 0 && (dataTableGetInt(MOVEMENT_TABLE, row, "affects_mount") == 1); } public static boolean isStunEffect(String name) throws InterruptedException { @@ -338,10 +291,8 @@ public class movement extends script.base_script { return false; } - for (int i = 0; i < movementMods.length; i++) - { - if (isStunEffect(movementMods[i])) - { + for (String movementMod : movementMods) { + if (isStunEffect(movementMod)) { return true; } } @@ -356,11 +307,9 @@ public class movement extends script.base_script } Vector effectList = new Vector(); effectList.setSize(0); - for (int i = 0; i < movementMods.length; i++) - { - if (isStunEffect(movementMods[i])) - { - effectList.add(movementMods[i]); + for (String movementMod : movementMods) { + if (isStunEffect(movementMod)) { + effectList.add(movementMod); } } return utils.toStaticStringArray(effectList); @@ -368,15 +317,15 @@ public class movement extends script.base_script public static String[] getAllModifiers(obj_id target) throws InterruptedException { Vector mods = new Vector(); - deltadictionary dd = target.getScriptVars(); - java.util.Enumeration keys = dd.keys(); + java.util.Enumeration keys = target.getScriptVars().keys(); + String key; + while (keys.hasMoreElements()) { - String key = (String)(keys.nextElement()); + key = (String)(keys.nextElement()); if (key.startsWith(MOVEMENT_OBJVAR + ".") && key.endsWith(".time")) { - String[] vars = split(key, '.'); - mods.add(vars[1]); + mods.add(split(key, '.')[1]); } } return utils.toStaticStringArray(mods); @@ -394,73 +343,58 @@ public class movement extends script.base_script } public static float _recalculateMovementModifiers(obj_id target) throws InterruptedException { - float boostMod = 0.0f; - float snareMod = 0.0f; - float permaBoost = 0.0f; - float permaSnare = 1.0f; String[] mods = getAllModifiers(target); testStunEffects(target); if (mods == null || mods.length == 0) { return 1.0f; } + float boostMod = 0.0f; + float snareMod = 0.0f; + float permaBoost = 0.0f; + float permaSnare = 1.0f; + float adj; obj_id mount = getMountId(target); - for (int i = 0; i < mods.length; i++) - { - if (isPlayer(target) && isIdValid(mount)) - { - if (hasScript(mount, "systems.vehicle_system.vehicle_base")) - { - if (!canAffectVehicles(mods[i])) - { + for (String mod : mods) { + if (isPlayer(target) && isIdValid(mount)) { + if (hasScript(mount, "systems.vehicle_system.vehicle_base")) { + if (!canAffectVehicles(mod)) { + continue; + } + } else { + if (!canAffectMounts(mod)) { continue; } } - else - { - if (!canAffectMounts(mods[i])) - { - continue; - } - } - } - else - { - if (!canAffectOnFoot(mods[i])) - { + } else { + if (!canAffectOnFoot(mod)) { continue; } } - if (isRoot(mods[i])) - { + if (isRoot(mod)) { return 0.0f; } - float adj = _getMovementPercentageAdjustment(target, mods[i]); - if (adj == Float.NEGATIVE_INFINITY) - { + adj = _getMovementPercentageAdjustment(target, mod); + if (adj == Float.NEGATIVE_INFINITY) { continue; } - int type = getType(mods[i]); - switch (type) - { + switch (getType(mod)) { case MT_BOOST: - if (adj > boostMod) - { - boostMod = adj; - } - break; + if (adj > boostMod) { + boostMod = adj; + } + break; case MT_SNARE: - if (adj < snareMod) - { - snareMod = adj; - } - break; + if (adj < snareMod) { + snareMod = adj; + } + break; case MT_PERMABOOST: - permaBoost += adj; - break; + permaBoost += adj; + break; case MT_PERMASNARE: - permaSnare *= (1.0f + adj); - break; + permaSnare *= (1.0f + adj); + break; } } if (snareMod < 0.0) @@ -477,35 +411,28 @@ public class movement extends script.base_script } public static boolean checkForMovementImmunity(obj_id target, String name) throws InterruptedException { - int modifierType = getType(name); if (isPlayer(target) && !buff.canBeDispelled(name)) { return false; } boolean resisted = false; - int stunResist = getEnhancedSkillStatisticModifierUncapped(target, "movement_resist_stun"); - int snareResist = getEnhancedSkillStatisticModifierUncapped(target, "movement_resist_snare"); - int rootResist = getEnhancedSkillStatisticModifierUncapped(target, "movement_resist_root"); - if (modifierType == MT_STUN) - { - if (rand(1, 99) < stunResist) - { - resisted = true; - } - } - else if (modifierType == MT_SNARE) - { - if (rand(1, 99) < snareResist) - { - resisted = true; - } - } - else if (modifierType == MT_ROOT) - { - if (rand(1, 99) < rootResist) - { - resisted = true; - } + int roll = rand(1,99); + switch (getType(name)) { + case MT_STUN: + if (roll < getEnhancedSkillStatisticModifierUncapped(target, "movement_resist_stun")) { + resisted = true; + } + break; + case MT_SNARE: + if (roll < getEnhancedSkillStatisticModifierUncapped(target, "movement_resist_snare")) { + resisted = true; + } + break; + case MT_ROOT: + if (roll < getEnhancedSkillStatisticModifierUncapped(target, "movement_resist_root")) { + resisted = true; + } + break; } return resisted; } @@ -513,17 +440,13 @@ public class movement extends script.base_script { boolean isStunned = hasStunEffect(target); setState(target, STATE_STUNNED, isStunned); - float turnRate = isStunned ? 0.0f : 360.0f; return isStunned; } public static void updateMovementImmunity(obj_id target) throws InterruptedException { - int stunResist = getEnhancedSkillStatisticModifierUncapped(target, "movement_resist_stun"); - int snareResist = getEnhancedSkillStatisticModifierUncapped(target, "movement_resist_snare"); - int rootResist = getEnhancedSkillStatisticModifierUncapped(target, "movement_resist_root"); dictionary dict = new dictionary(); dict.put("self", target); - if (stunResist >= 100) + if (getEnhancedSkillStatisticModifierUncapped(target, "movement_resist_stun") >= 100) { if (removeAllModifiersOfType(target, movement.MT_STUN)) { @@ -533,7 +456,7 @@ public class movement extends script.base_script messageTo(target, "messageDetrimentalRemoved", dict, 0.0f, false); } } - if (snareResist >= 100) + if (getEnhancedSkillStatisticModifierUncapped(target, "movement_resist_snare") >= 100) { if (removeAllModifiersOfType(target, movement.MT_SNARE)) { @@ -543,7 +466,7 @@ public class movement extends script.base_script messageTo(target, "messageDetrimentalRemoved", dict, 0.0f, false); } } - if (rootResist >= 100) + if (getEnhancedSkillStatisticModifierUncapped(target, "movement_resist_root") >= 100) { if (removeAllModifiersOfType(target, movement.MT_ROOT)) { diff --git a/sku.0/sys.server/compiled/game/script/library/npc.java b/sku.0/sys.server/compiled/game/script/library/npc.java old mode 100644 new mode 100755 index 770dbea62..93aa48a25 --- a/sku.0/sys.server/compiled/game/script/library/npc.java +++ b/sku.0/sys.server/compiled/game/script/library/npc.java @@ -68,7 +68,6 @@ public class npc extends script.base_script public static void hueClothes(obj_id newClothes, String clothes) throws InterruptedException { debugServerConsoleMsg(getSelf(), "WARNING: SOMETHING IS STILL USING NPC.SCRIPTLIB hueClothes( obj_id newClothes, string clothes )"); - return; } public static String chooseSpecies(String type, int number, String gender) throws InterruptedException { @@ -88,12 +87,10 @@ public class npc extends script.base_script public static void dressUp(obj_id npc, String type, String gender) throws InterruptedException { debugServerConsoleMsg(getSelf(), "WARNING: SOMETHING IS STILL USING NPC.SCRIPTLIB dressUp (obj_id npc, string type, string gender)"); - return; } public static void dressHair(obj_id npc, String name, String gender) throws InterruptedException { debugServerConsoleMsg(getSelf(), "WARNING: SOMETHING IS STILL USING NPC.SCRIPTLIB dressHair (obj_id npc, string name, string gender)"); - return; } public static obj_id makeStormtrooperInside(obj_id bldg, String cellName) throws InterruptedException { @@ -103,7 +100,6 @@ public class npc extends script.base_script public static void scriptAttach(obj_id npc, String type) throws InterruptedException { debugServerConsoleMsg(getSelf(), "WARNING: SOMETHING IS STILL USING NPC.SCRIPTLIB scriptAttach (obj_id npc, string type)"); - return; } public static obj_id makeDroid(location loc) throws InterruptedException { @@ -168,7 +164,6 @@ public class npc extends script.base_script public static void spamErrorMsg(String text) throws InterruptedException { debugServerConsoleMsg(getSelf(), "WARNING: SOMETHING IS STILL USING NPC.SCRIPTLIB spamErrorMsg( string text )"); - return; } public static String getClothingTemplateName(String tableName, int column) throws InterruptedException { diff --git a/sku.0/sys.server/compiled/game/script/library/npe.java b/sku.0/sys.server/compiled/game/script/library/npe.java old mode 100644 new mode 100755 index ae432eaf9..7aefdb2f8 --- a/sku.0/sys.server/compiled/game/script/library/npe.java +++ b/sku.0/sys.server/compiled/game/script/library/npe.java @@ -76,102 +76,88 @@ public class npe extends script.base_script } public static boolean performTransitionFromClusterWideData(obj_id player, dictionary[] stations, String station) throws InterruptedException { - if (station.equals(DUNGEON_SPACE_STATION + "*")) - { - dictionary info = getNpeInstanceInfo(DUNGEON_SPACE_STATION); - int instance_index = getBestStationInstanceIndex(player, stations); - if (instance_index == -1 || instance_index >= stations.length) - { - return false; - } - dictionary station_info = stations[instance_index]; - if (station_info == null) - { - return false; - } - if (utils.hasScriptVar(player, SCRIPT_VAR_FROM_ORD_SPACE)) - { - removeObjVar(player, SCRIPT_VAR_FROM_ORD_SPACE); - utils.removeScriptVar(player, SCRIPT_VAR_FROM_ORD_SPACE); - info.put("cell", FROM_ORD_SPACE_TO_STATION_CELL); - location cell_loc = new location(FROM_ORD_SPACE_TO_STATION_X, FROM_ORD_SPACE_TO_STATION_Y, FROM_ORD_SPACE_TO_STATION_Z); - info.put("cell_loc", cell_loc); - } - obj_id station_id = station_info.getObjId("building_id"); - String planet = info.getString("planet"); - location world_loc = new location(station_info.getFloat("world_location.x"), station_info.getFloat("world_location.y"), station_info.getFloat("world_location.z")); - String cell = info.getString("cell"); - location cell_loc = info.getLocation("cell_loc"); - randomizeLocation(cell_loc); - LIVE_LOG("npe", "Found " + stations.length + " buildings, moving " + player + " to " + station_id + " s:" + planet + " c:" + cell + " w:" + world_loc.x + " " + world_loc.y + " " + world_loc.z + " l:" + cell_loc.x + " " + cell_loc.y + " " + cell_loc.z); - if (utils.hasScriptVar(player, SCRIPT_VAR_DO_HYPERSPACE)) - { - utils.removeScriptVar(player, SCRIPT_VAR_DO_HYPERSPACE); - hyperspacePlayerToLocation(player, planet, world_loc.x, world_loc.y, world_loc.z, station_id, cell, cell_loc.x, cell_loc.y, cell_loc.z, "msgNpeInstanceTravelComplete", false); - } - else - { - warpPlayer(player, planet, world_loc.x, world_loc.y, world_loc.z, station_id, cell, cell_loc.x, cell_loc.y, cell_loc.z, "msgNpeInstanceTravelComplete", false); - } - return true; - } - else if (station.equals(DUNGEON_ORD_SPACE_STATION + "*")) - { - if (utils.hasScriptVar(player, SCRIPT_VAR_ORD_SPACE_DESTINATION)) - { - location new_loc = utils.getLocationScriptVar(player, SCRIPT_VAR_ORD_SPACE_DESTINATION); - utils.removeScriptVar(player, SCRIPT_VAR_ORD_SPACE_DESTINATION); - int index = getBestDungeonInstanceIndex(player, stations); - String scene = SCENE_SPACE_ORD_MANTELL; - if (!isIdValid(getPlanetByName(scene))) - { + dictionary info; + dictionary station_info; + obj_id station_id; + String planet; + location world_loc; + String cell; + location cell_loc; + switch (station) { + case DUNGEON_SPACE_STATION + "*": + int instance_index = getBestStationInstanceIndex(player, stations); + if (instance_index == -1 || instance_index >= stations.length) { return false; } - obj_id ship = setupLaunchToSpace(player); - if (!isIdValid(ship)) - { + station_info = stations[instance_index]; + if (station_info == null) { return false; } - new_loc.area = scene; - location ground_loc = getWorldLocation(player); - obj_id[] members = new obj_id[0]; - randomizeSpaceLocation(new_loc); - space_transition.launch(player, ship, members, new_loc, ground_loc); - return true; - } - else - { - String ord_scene = getCurrentSceneName(); - dictionary info = getNpeInstanceInfo(DUNGEON_ORD_SPACE_STATION); - dictionary station_info = getBestOrdSpaceStation(player, stations, ord_scene); - if (station_info == null) - { - return false; + info = getNpeInstanceInfo(DUNGEON_SPACE_STATION); + if (utils.hasScriptVar(player, SCRIPT_VAR_FROM_ORD_SPACE)) { + removeObjVar(player, SCRIPT_VAR_FROM_ORD_SPACE); + utils.removeScriptVar(player, SCRIPT_VAR_FROM_ORD_SPACE); + cell_loc = new location(FROM_ORD_SPACE_TO_STATION_X, FROM_ORD_SPACE_TO_STATION_Y, FROM_ORD_SPACE_TO_STATION_Z); + info.put("cell", FROM_ORD_SPACE_TO_STATION_CELL); + info.put("cell_loc", cell_loc); } - setObjVar(player, npe.VAR_ORD_SCENE_NAME, ord_scene); - obj_id station_id = station_info.getObjId("building_id"); - String planet = info.getString("planet"); - location world_loc = new location(station_info.getFloat("world_location.x"), station_info.getFloat("world_location.y"), station_info.getFloat("world_location.z")); - String cell = info.getString("cell"); - location cell_loc = info.getLocation("cell_loc"); + world_loc = new location(station_info.getFloat("world_location.x"), station_info.getFloat("world_location.y"), station_info.getFloat("world_location.z")); + station_id = station_info.getObjId("building_id"); + planet = info.getString("planet"); + cell = info.getString("cell"); + cell_loc = info.getLocation("cell_loc"); randomizeLocation(cell_loc); LIVE_LOG("npe", "Found " + stations.length + " buildings, moving " + player + " to " + station_id + " s:" + planet + " c:" + cell + " w:" + world_loc.x + " " + world_loc.y + " " + world_loc.z + " l:" + cell_loc.x + " " + cell_loc.y + " " + cell_loc.z); - if (utils.hasScriptVar(player, SCRIPT_VAR_DO_HYPERSPACE)) - { + if (utils.hasScriptVar(player, SCRIPT_VAR_DO_HYPERSPACE)) { utils.removeScriptVar(player, SCRIPT_VAR_DO_HYPERSPACE); hyperspacePlayerToLocation(player, planet, world_loc.x, world_loc.y, world_loc.z, station_id, cell, cell_loc.x, cell_loc.y, cell_loc.z, "msgNpeInstanceTravelComplete", false); - } - else - { + } else { warpPlayer(player, planet, world_loc.x, world_loc.y, world_loc.z, station_id, cell, cell_loc.x, cell_loc.y, cell_loc.z, "msgNpeInstanceTravelComplete", false); } return true; - } - } - else - { - LIVE_LOG("npe", "Player is trying to perform a cluster wide transition, but is going to an unsupported station " + station + " should be " + DUNGEON_SPACE_STATION + "*, " + DUNGEON_ORD_SPACE_STATION + "*"); - return false; + case DUNGEON_ORD_SPACE_STATION + "*": + if (utils.hasScriptVar(player, SCRIPT_VAR_ORD_SPACE_DESTINATION)) { + if (!isIdValid(getPlanetByName(SCENE_SPACE_ORD_MANTELL))) { + return false; + } + utils.removeScriptVar(player, SCRIPT_VAR_ORD_SPACE_DESTINATION); + obj_id ship = setupLaunchToSpace(player); + if (!isIdValid(ship)) { + return false; + } + location new_loc = utils.getLocationScriptVar(player, SCRIPT_VAR_ORD_SPACE_DESTINATION); + new_loc.area = SCENE_SPACE_ORD_MANTELL; + location ground_loc = getWorldLocation(player); + obj_id[] members = new obj_id[0]; + randomizeSpaceLocation(new_loc); + space_transition.launch(player, ship, members, new_loc, ground_loc); + return true; + } else { + String ord_scene = getCurrentSceneName(); + station_info = getBestOrdSpaceStation(player, stations, ord_scene); + if (station_info == null) { + return false; + } + info = getNpeInstanceInfo(DUNGEON_ORD_SPACE_STATION); + setObjVar(player, npe.VAR_ORD_SCENE_NAME, ord_scene); + station_id = station_info.getObjId("building_id"); + planet = info.getString("planet"); + world_loc = new location(station_info.getFloat("world_location.x"), station_info.getFloat("world_location.y"), station_info.getFloat("world_location.z")); + cell = info.getString("cell"); + cell_loc = info.getLocation("cell_loc"); + randomizeLocation(cell_loc); + LIVE_LOG("npe", "Found " + stations.length + " buildings, moving " + player + " to " + station_id + " s:" + planet + " c:" + cell + " w:" + world_loc.x + " " + world_loc.y + " " + world_loc.z + " l:" + cell_loc.x + " " + cell_loc.y + " " + cell_loc.z); + if (utils.hasScriptVar(player, SCRIPT_VAR_DO_HYPERSPACE)) { + utils.removeScriptVar(player, SCRIPT_VAR_DO_HYPERSPACE); + hyperspacePlayerToLocation(player, planet, world_loc.x, world_loc.y, world_loc.z, station_id, cell, cell_loc.x, cell_loc.y, cell_loc.z, "msgNpeInstanceTravelComplete", false); + } else { + warpPlayer(player, planet, world_loc.x, world_loc.y, world_loc.z, station_id, cell, cell_loc.x, cell_loc.y, cell_loc.z, "msgNpeInstanceTravelComplete", false); + } + return true; + } + default: + LIVE_LOG("npe", "Player is trying to perform a cluster wide transition, but is going to an unsupported station " + station + " should be " + DUNGEON_SPACE_STATION + "*, " + DUNGEON_ORD_SPACE_STATION + "*"); + return false; } } public static dictionary getNpeInstanceInfo(String row) throws InterruptedException @@ -229,9 +215,8 @@ public class npe extends script.base_script LOG("npe", "getBestStationInstanceIndex: Got a null entry in stations array"); continue; } - obj_id new_station = stations[i].getObjId("building_id"); int new_pop = stations[i].getInt("population_num"); - if (!isIdValid(new_station)) + if (!isIdValid(stations[i].getObjId("building_id"))) { LOG("npe", "getBestStationInstanceIndex: stations array passed into getBestStationInstanceIndex contained a null or invalid station id"); continue; @@ -273,10 +258,9 @@ public class npe extends script.base_script } sendSystemMessageTestingOnly(player, "The station Gamma index override you specified is null! Defaulting to normal behavior"); } - int numOrdSpace = getNumberOfOrdSpaceScenes(); int return_index = -1; int population = -1; - for (int i = 0; i < dungeons.length && i < numOrdSpace; ++i) + for (int i = 0; i < dungeons.length && i < getNumberOfOrdSpaceScenes(); ++i) { if (dungeons[i] == null) { @@ -322,11 +306,7 @@ public class npe extends script.base_script { return true; } - if (new_pop < pop) - { - return true; - } - return false; + return new_pop < pop; } public static dictionary getBestOrdSpaceStation(obj_id player, dictionary[] stations, String ord_scene) throws InterruptedException { @@ -353,18 +333,15 @@ public class npe extends script.base_script } sendSystemMessageTestingOnly(player, "The station Gamma index override you specified is null! Defaulting to normal behavior"); } - String ord_num_str = ord_scene.substring(ord_scene.length() - 1); - int ord_num_ind = utils.stringToInt(ord_num_str); + int ord_num_ind = utils.stringToInt(ord_scene.substring(ord_scene.length() - 1)); --ord_num_ind; if (ord_num_ind > 0 && ord_num_ind < stations.length && stations[ord_num_ind] != null && isIdValid(stations[ord_num_ind].getObjId("building_id"))) { return stations[ord_num_ind]; } - for (int i = 0; i < stations.length; ++i) - { - if (stations[i] != null && isIdValid(stations[i].getObjId("building_id"))) - { - return stations[i]; + for (dictionary station : stations) { + if (station != null && isIdValid(station.getObjId("building_id"))) { + return station; } } return null; @@ -388,8 +365,7 @@ public class npe extends script.base_script } public static String getOpenOrdMantellSpaceZone() throws InterruptedException { - int maxIndex = getNumberOfOrdSpaceScenes(); - int returnIndex = rand(1, maxIndex); + int returnIndex = rand(1, getNumberOfOrdSpaceScenes()); if (returnIndex == 1) { return SCENE_SPACE_ORD_MANTELL; @@ -602,7 +578,6 @@ public class npe extends script.base_script { obj_id pInv = utils.getInventoryContainer(player); int pSpecies = getSpecies(player); - String playerTemplate = getSkillTemplate(player); int pGender = getGender(player); HashSet theSet = new HashSet(); if (utils.isProfession(player, utils.FORCE_SENSITIVE)) @@ -765,8 +740,6 @@ public class npe extends script.base_script } public static obj_id grantNpeResourceStack(obj_id player, String strResourceType, int intAmount) throws InterruptedException { - int maxResource = 1000000; - obj_id objContainer = utils.getInventoryContainer(player); obj_id[] objResourceIds = getResourceTypes(strResourceType); obj_id objResourceId = null; if ((objResourceIds != null) && (objResourceIds.length > 0)) @@ -777,22 +750,19 @@ public class npe extends script.base_script { return null; } + obj_id objContainer = utils.getInventoryContainer(player); obj_id objStack = getResourceStack(objContainer, objResourceId); if (isIdValid(objStack)) { int intCount = getResourceContainerQuantity(objStack); + int maxResource = 1000000; intCount += intAmount; if (intCount > maxResource) { - intCount = intCount - maxResource; - intAmount = intAmount - intCount; - addResourceToContainer(objStack, objResourceId, intAmount, null); - objStack = null; - } - else - { - addResourceToContainer(objStack, objResourceId, intAmount, null); + intCount -= maxResource; + intAmount -= intCount; } + addResourceToContainer(objStack, objResourceId, intAmount, null); } else { @@ -806,8 +776,6 @@ public class npe extends script.base_script } public static int harvestNpeResourceStack(obj_id player, String strResourceType, int intAmount) throws InterruptedException { - int maxResource = 1000000; - obj_id objContainer = utils.getInventoryContainer(player); obj_id[] objResourceIds = getResourceTypes(strResourceType); obj_id objResourceId = null; if ((objResourceIds != null) && (objResourceIds.length > 0)) @@ -818,26 +786,21 @@ public class npe extends script.base_script { return 0; } + obj_id objContainer = utils.getInventoryContainer(player); obj_id objStack = getResourceStack(objContainer, objResourceId); if (isIdValid(objStack)) { + int maxResource = 1000000; int intCount = getResourceContainerQuantity(objStack); intCount += intAmount; if (intCount > maxResource) { - intCount = intCount - maxResource; - intAmount = intAmount - intCount; - addResourceToContainer(objStack, objResourceId, intAmount, null); - objStack = null; - utils.setScriptVar(player, "resource.lastAmt", intAmount); - return intAmount; - } - else - { - addResourceToContainer(objStack, objResourceId, intAmount, null); - utils.setScriptVar(player, "resource.lastAmt", intAmount); - return intAmount; + intCount -= maxResource; + intAmount -= intCount; } + addResourceToContainer(objStack, objResourceId, intAmount, null); + utils.setScriptVar(player, "resource.lastAmt", intAmount); + return intAmount; } else { @@ -852,7 +815,6 @@ public class npe extends script.base_script } public static obj_id getResourceStack(obj_id objContainer, obj_id objResource) throws InterruptedException { - int maxResource = 1000000; if (!isIdValid(objContainer)) { return null; @@ -862,15 +824,11 @@ public class npe extends script.base_script { return null; } - for (int intI = 0; intI < objContents.length; intI++) - { - obj_id objType = getResourceContainerResourceType(objContents[intI]); - if (objType == objResource) - { - int intCount = getResourceContainerQuantity(objContents[intI]); - if (intCount < maxResource) - { - return objContents[intI]; + int maxResource = 1000000; + for (obj_id objContent : objContents) { + if (getResourceContainerResourceType(objContent) == objResource) { + if (getResourceContainerQuantity(objContent) < maxResource) { + return objContent; } } } @@ -878,14 +836,9 @@ public class npe extends script.base_script } public static boolean giveCreditPopUp(obj_id player, obj_id npc) throws InterruptedException { - string_id credits = new string_id("npe", "pop_credits"); - String stfCredits = utils.packStringId(credits); - int hadNotif = utils.getIntScriptVar(player, "npe.credits"); - if (hadNotif == 0) + if (utils.getIntScriptVar(player, "npe.credits") == 0) { - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); - commTutorialPlayer(droid, player, 10, credits, "sound/c3po_29.snd", "object/mobile/c_3po.iff"); + commTutorialPlayer(utils.getObjIdScriptVar(getTopMostContainer(player), "objDroidInvis"), player, 10, new string_id("npe", "pop_credits"), "sound/c3po_29.snd", "object/mobile/c_3po.iff"); utils.setScriptVar(player, "npe.credits", 1); return true; } @@ -893,25 +846,13 @@ public class npe extends script.base_script } public static boolean giveAutoPopUp(obj_id player, obj_id npc) throws InterruptedException { - string_id autoAttack = new string_id("npe", "pop_auto_attack"); - String stfAuto = utils.packStringId(autoAttack); - int hadNotif = utils.getIntScriptVar(player, "npe.pop_auto"); - if (hadNotif == 0) - { - return true; - } - return false; + return utils.getIntScriptVar(player, "npe.pop_auto") == 0; } public static boolean giveEquipPopUp(obj_id player, obj_id npc) throws InterruptedException { - string_id equip = new string_id("npe", "pop_equip"); - String stfEquip = utils.packStringId(equip); - int hadNotif = utils.getIntScriptVar(player, "npe.pop_equip"); - if (hadNotif == 0) + if (utils.getIntScriptVar(player, "npe.pop_equip") == 0) { - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); - commTutorialPlayer(droid, player, 3, equip, "sound/c3po_31.snd", "object/mobile/c_3po.iff"); + commTutorialPlayer(utils.getObjIdScriptVar(getTopMostContainer(player), "objDroidInvis"), player, 3, new string_id("npe", "pop_equip"), "sound/c3po_31.snd", "object/mobile/c_3po.iff"); utils.setScriptVar(player, "npe.pop_equip", 1); return true; } @@ -919,14 +860,9 @@ public class npe extends script.base_script } public static boolean giveInvPopUp(obj_id player, obj_id npc) throws InterruptedException { - string_id inventory = new string_id("npe", "pop_inventory"); - String stfInv = utils.packStringId(inventory); - int hadNotif = utils.getIntScriptVar(player, "npe.pop_inv"); - if (hadNotif == 0) + if (utils.getIntScriptVar(player, "npe.pop_inv") == 0) { - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); - commTutorialPlayer(droid, player, 3, inventory, "sound/c3po_43.snd", "object/mobile/c_3po.iff"); + commTutorialPlayer(utils.getObjIdScriptVar(getTopMostContainer(player), "objDroidInvis"), player, 3, new string_id("npe", "pop_inventory"), "sound/c3po_43.snd", "object/mobile/c_3po.iff"); utils.setScriptVar(player, "npe.pop_inv", 1); return true; } @@ -934,14 +870,9 @@ public class npe extends script.base_script } public static boolean giveAttackPopUp(obj_id player, obj_id npc) throws InterruptedException { - string_id attack = new string_id("npe", "pop_attack"); - String stfAttack = utils.packStringId(attack); - int hadNotif = utils.getIntScriptVar(player, "npe.pop_attack"); - if (hadNotif == 0) + if (utils.getIntScriptVar(player, "npe.pop_attack") == 0) { - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); - commTutorialPlayer(droid, player, 4, attack, "sound/c3po_21.snd", "object/mobile/c_3po.iff"); + commTutorialPlayer(utils.getObjIdScriptVar(getTopMostContainer(player), "objDroidInvis"), player, 4, new string_id("npe", "pop_attack"), "sound/c3po_21.snd", "object/mobile/c_3po.iff"); utils.setScriptVar(player, "npe.pop_attack", 1); return true; } @@ -949,14 +880,9 @@ public class npe extends script.base_script } public static boolean giveTargetPopUp(obj_id player, obj_id npc) throws InterruptedException { - string_id target = new string_id("npe", "pop_target"); - String stfTarget = utils.packStringId(target); - int hadNotif = utils.getIntScriptVar(player, "npe.pop_target"); - if (hadNotif == 0) + if (utils.getIntScriptVar(player, "npe.pop_target") == 0) { - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); - commTutorialPlayer(droid, player, 8, target, "sound/c3po_51.snd", "object/mobile/c_3po.iff"); + commTutorialPlayer(utils.getObjIdScriptVar(getTopMostContainer(player), "objDroidInvis"), player, 8, new string_id("npe", "pop_target"), "sound/c3po_51.snd", "object/mobile/c_3po.iff"); utils.setScriptVar(player, "npe.pop_target", 1); return true; } @@ -964,14 +890,9 @@ public class npe extends script.base_script } public static boolean giveMapPopUp(obj_id player, obj_id npc) throws InterruptedException { - string_id map = new string_id("npe", "pop_map"); - String stfMap = utils.packStringId(map); - int hadNotif = utils.getIntScriptVar(player, "npe.map"); - if (hadNotif == 0) + if (utils.getIntScriptVar(player, "npe.map") == 0) { - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); - commTutorialPlayer(droid, player, 8, map, "sound/c3po_46.snd", "object/mobile/c_3po.iff"); + commTutorialPlayer(utils.getObjIdScriptVar(getTopMostContainer(player), "objDroidInvis"), player, 8, new string_id("npe", "pop_map"), "sound/c3po_46.snd", "object/mobile/c_3po.iff"); utils.setScriptVar(player, "npe.map", 1); return true; } @@ -979,49 +900,29 @@ public class npe extends script.base_script } public static boolean giveJournPopUp(obj_id player) throws InterruptedException { - string_id journal = new string_id("npe", "pop_journal"); - String stfJournal = utils.packStringId(journal); - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); - commTutorialPlayer(droid, player, 12, journal, "sound/c3po_44.snd", "object/mobile/c_3po.iff"); + commTutorialPlayer(utils.getObjIdScriptVar(getTopMostContainer(player), "objDroidInvis"), player, 12, new string_id("npe", "pop_journal"), "sound/c3po_44.snd", "object/mobile/c_3po.iff"); utils.setScriptVar(player, "npe.journal", 1); return true; } public static boolean giveQuestHelperPopUp(obj_id player) throws InterruptedException { - string_id helper = new string_id("npe", "pop_quest_helper"); - String stfHelper = utils.packStringId(helper); - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); - commTutorialPlayer(droid, player, 7, helper, "sound/c3po_50b.snd", "object/mobile/c_3po.iff"); + commTutorialPlayer(utils.getObjIdScriptVar(getTopMostContainer(player), "objDroidInvis"), player, 7, new string_id("npe", "pop_quest_helper"), "sound/c3po_50b.snd", "object/mobile/c_3po.iff"); utils.setScriptVar(player, "npe.quest_helper", 1); return true; } public static boolean giveQuestHelperPopUp2(obj_id player) throws InterruptedException { - string_id helper = new string_id("npe", "pop_quest_helper2"); - String stfHelper = utils.packStringId(helper); - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); utils.setScriptVar(player, "npe.quest_helper", 1); return true; } public static boolean giveCraftPopUp(obj_id player, obj_id npc) throws InterruptedException { - string_id craft = new string_id("npe", "pop_craft"); - string_id craft2 = new string_id("npe", "pop_craft2"); - string_id craft3 = new string_id("npe", "pop_craft3"); - String stfCraft = utils.packStringId(craft); - String stfCraft2 = utils.packStringId(craft2); - String stfCraft3 = utils.packStringId(craft3); - int hadNotif = utils.getIntScriptVar(player, "npe.craft"); - if (hadNotif == 0) + if (utils.getIntScriptVar(player, "npe.craft") == 0) { - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); - commTutorialPlayer(droid, player, 15, craft, "sound/c3po_26.snd", "object/mobile/c_3po.iff"); - commTutorialPlayer(droid, player, 12, craft2, "sound/c3po_27.snd", "object/mobile/c_3po.iff"); - commTutorialPlayer(droid, player, 14, craft3, "sound/c3po_28.snd", "object/mobile/c_3po.iff"); + obj_id droid = utils.getObjIdScriptVar(getTopMostContainer(player), "objDroidInvis"); + commTutorialPlayer(droid, player, 15, new string_id("npe", "pop_craft"), "sound/c3po_26.snd", "object/mobile/c_3po.iff"); + commTutorialPlayer(droid, player, 12, new string_id("npe", "pop_craft2"), "sound/c3po_27.snd", "object/mobile/c_3po.iff"); + commTutorialPlayer(droid, player, 14, new string_id("npe", "pop_craft3"), "sound/c3po_28.snd", "object/mobile/c_3po.iff"); utils.setScriptVar(player, "npe.craft", 1); return true; } @@ -1029,14 +930,9 @@ public class npe extends script.base_script } public static boolean givePistolPopUp(obj_id player, obj_id npc) throws InterruptedException { - string_id equip_pistol = new string_id("npe", "pop_equip_pistol"); - String stfEquipPistol = utils.packStringId(equip_pistol); - int hadNotif = utils.getIntScriptVar(player, "npe.equip_pistol"); - if (hadNotif == 0) + if (utils.getIntScriptVar(player, "npe.equip_pistol") == 0) { - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); - commTutorialPlayer(droid, player, 8, equip_pistol, "sound/c3po_83.snd", "object/mobile/c_3po.iff"); + commTutorialPlayer(utils.getObjIdScriptVar(getTopMostContainer(player), "objDroidInvis"), player, 8, new string_id("npe", "pop_equip_pistol"), "sound/c3po_83.snd", "object/mobile/c_3po.iff"); utils.setScriptVar(player, "npe.equip_pistol", 1); return true; } @@ -1044,14 +940,9 @@ public class npe extends script.base_script } public static boolean giveCarbinePopUp(obj_id player, obj_id npc) throws InterruptedException { - string_id equip_carbine = new string_id("npe", "pop_equip_carbine"); - String stfEquipCarbine = utils.packStringId(equip_carbine); - int hadNotif = utils.getIntScriptVar(player, "npe.equip_carbine"); - if (hadNotif == 0) + if (utils.getIntScriptVar(player, "npe.equip_carbine") == 0) { - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); - commTutorialPlayer(droid, player, 8, equip_carbine, "sound/c3po_82.snd", "object/mobile/c_3po.iff"); + commTutorialPlayer(utils.getObjIdScriptVar(getTopMostContainer(player), "objDroidInvis"), player, 8, new string_id("npe", "pop_equip_carbine"), "sound/c3po_82.snd", "object/mobile/c_3po.iff"); utils.setScriptVar(player, "npe.equip_carbine", 1); return true; } @@ -1059,14 +950,9 @@ public class npe extends script.base_script } public static boolean giveRiflePopUp(obj_id player, obj_id npc) throws InterruptedException { - string_id equip_rifle = new string_id("npe", "pop_equip_rifle"); - String stfEquipRifle = utils.packStringId(equip_rifle); - int hadNotif = utils.getIntScriptVar(player, "npe.equip_rifle"); - if (hadNotif == 0) + if (utils.getIntScriptVar(player, "npe.equip_rifle") == 0) { - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); - commTutorialPlayer(droid, player, 8, equip_rifle, "sound/c3po_84.snd", "object/mobile/c_3po.iff"); + commTutorialPlayer(utils.getObjIdScriptVar(getTopMostContainer(player), "objDroidInvis"), player, 8, new string_id("npe", "pop_equip_rifle"), "sound/c3po_84.snd", "object/mobile/c_3po.iff"); utils.setScriptVar(player, "npe.equip_rifle", 1); return true; } @@ -1074,14 +960,9 @@ public class npe extends script.base_script } public static boolean give1hPopUp(obj_id player, obj_id npc) throws InterruptedException { - string_id equip_sword = new string_id("npe", "pop_equip_sword"); - String stfEquipSword = utils.packStringId(equip_sword); - int hadNotif = utils.getIntScriptVar(player, "npe.equip_sword"); - if (hadNotif == 0) + if (utils.getIntScriptVar(player, "npe.equip_sword") == 0) { - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); - commTutorialPlayer(droid, player, 8, equip_sword, "sound/c3po_86.snd", "object/mobile/c_3po.iff"); + commTutorialPlayer(utils.getObjIdScriptVar(getTopMostContainer(player), "objDroidInvis"), player, 8, new string_id("npe", "pop_equip_sword"), "sound/c3po_86.snd", "object/mobile/c_3po.iff"); utils.setScriptVar(player, "npe.equip_sword", 1); return true; } @@ -1089,14 +970,9 @@ public class npe extends script.base_script } public static boolean give2hPopUp(obj_id player, obj_id npc) throws InterruptedException { - string_id equip_axe = new string_id("npe", "pop_equip_axe"); - String stfEquipAxe = utils.packStringId(equip_axe); - int hadNotif = utils.getIntScriptVar(player, "npe.equip_axe"); - if (hadNotif == 0) + if (utils.getIntScriptVar(player, "npe.equip_axe") == 0) { - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); - commTutorialPlayer(droid, player, 8, equip_axe, "sound/c3po_81.snd", "object/mobile/c_3po.iff"); + commTutorialPlayer(utils.getObjIdScriptVar(getTopMostContainer(player), "objDroidInvis"), player, 8, new string_id("npe", "pop_equip_axe"), "sound/c3po_81.snd", "object/mobile/c_3po.iff"); utils.setScriptVar(player, "npe.equip_axe", 1); return true; } @@ -1104,14 +980,9 @@ public class npe extends script.base_script } public static boolean givePolePopUp(obj_id player, obj_id npc) throws InterruptedException { - string_id equip_staff = new string_id("npe", "pop_equip_staff"); - String stfEquipStaff = utils.packStringId(equip_staff); - int hadNotif = utils.getIntScriptVar(player, "npe.equip_staff"); - if (hadNotif == 0) + if (utils.getIntScriptVar(player, "npe.equip_staff") == 0) { - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); - commTutorialPlayer(droid, player, 9, equip_staff, "sound/c3po_85.snd", "object/mobile/c_3po.iff"); + commTutorialPlayer(utils.getObjIdScriptVar(getTopMostContainer(player), "objDroidInvis"), player, 9, new string_id("npe", "pop_equip_staff"), "sound/c3po_85.snd", "object/mobile/c_3po.iff"); utils.setScriptVar(player, "npe.equip_staff", 1); return true; } @@ -1119,14 +990,9 @@ public class npe extends script.base_script } public static boolean giveUnarmPopUp(obj_id player, obj_id npc) throws InterruptedException { - string_id equip_unarmed = new string_id("npe", "pop_equip_unarmed"); - String stfEquipUnarmed = utils.packStringId(equip_unarmed); - int hadNotif = utils.getIntScriptVar(player, "npe.equip_unarmed"); - if (hadNotif == 0) + if (utils.getIntScriptVar(player, "npe.equip_unarmed") == 0) { - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); - commTutorialPlayer(droid, player, 11, equip_unarmed, "sound/c3po_87.snd", "object/mobile/c_3po.iff"); + commTutorialPlayer(utils.getObjIdScriptVar(getTopMostContainer(player), "objDroidInvis"), player, 11, new string_id("npe", "pop_equip_unarmed"), "sound/c3po_87.snd", "object/mobile/c_3po.iff"); utils.setScriptVar(player, "npe.equip_unarmed", 1); return true; } @@ -1134,14 +1000,9 @@ public class npe extends script.base_script } public static boolean giveHealPopUp(obj_id player, obj_id npc) throws InterruptedException { - string_id heal = new string_id("npe", "pop_heal"); - String stfHeal = utils.packStringId(heal); - int hadNotif = utils.getIntScriptVar(player, "npe.heal"); - if (hadNotif == 0) + if (utils.getIntScriptVar(player, "npe.heal") == 0) { - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); - commTutorialPlayer(droid, player, 7, heal, "sound/c3po_90.snd", "object/mobile/c_3po.iff"); + commTutorialPlayer(utils.getObjIdScriptVar(getTopMostContainer(player), "objDroidInvis"), player, 7, new string_id("npe", "pop_heal"), "sound/c3po_90.snd", "object/mobile/c_3po.iff"); utils.setScriptVar(player, "npe.heal", 1); return true; } @@ -1149,17 +1010,11 @@ public class npe extends script.base_script } public static boolean givePerformPopUp(obj_id player, obj_id npc) throws InterruptedException { - string_id perform = new string_id("npe", "pop_perform"); - string_id flourish = new string_id("npe", "pop_flourish"); - String stfPerform = utils.packStringId(perform); - String stfFlourish = utils.packStringId(flourish); - int hadNotif = utils.getIntScriptVar(player, "npe.perform"); - if (hadNotif == 0) + if (utils.getIntScriptVar(player, "npe.perform") == 0) { - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); - commTutorialPlayer(droid, player, 16, perform, "sound/c3po_93.snd", "object/mobile/c_3po.iff"); - commTutorialPlayer(droid, player, 13, flourish, "sound/c3po_88.snd", "object/mobile/c_3po.iff"); + obj_id droid = utils.getObjIdScriptVar(getTopMostContainer(player), "objDroidInvis"); + commTutorialPlayer(droid, player, 16, new string_id("npe", "pop_perform"), "sound/c3po_93.snd", "object/mobile/c_3po.iff"); + commTutorialPlayer(droid, player, 13, new string_id("npe", "pop_flourish"), "sound/c3po_88.snd", "object/mobile/c_3po.iff"); utils.setScriptVar(player, "npe.perform", 1); return true; } @@ -1167,76 +1022,53 @@ public class npe extends script.base_script } public static boolean giveGrenadePopUp(obj_id player, obj_id npc) throws InterruptedException { - string_id grenade = new string_id("npe", "pop_grenade"); - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); - commTutorialPlayer(droid, player, 10, grenade, "", "object/mobile/dressed_npe_commando.iff"); + commTutorialPlayer(utils.getObjIdScriptVar(getTopMostContainer(player), "objDroidInvis"), player, 10, new string_id("npe", "pop_grenade"), "", "object/mobile/dressed_npe_commando.iff"); return true; } public static boolean giveChatPopUp(obj_id player) throws InterruptedException { - string_id chat = new string_id("npe", "pop_chat"); - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); - commTutorialPlayer(droid, player, 10, chat, "sound/dro_r2_3_danger.snd", "object/mobile/r2.iff"); + commTutorialPlayer(utils.getObjIdScriptVar(getTopMostContainer(player), "objDroidInvis"), player, 10, new string_id("npe", "pop_chat"), "sound/dro_r2_3_danger.snd", "object/mobile/r2.iff"); return true; } public static boolean giveGroupPopUp1(obj_id player) throws InterruptedException { - string_id chat = new string_id("npe", "pop_group"); - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); - commTutorialPlayer(droid, player, 10, chat, "sound/dro_r2_3_danger.snd", "object/mobile/r2.iff"); + commTutorialPlayer(utils.getObjIdScriptVar(getTopMostContainer(player), "objDroidInvis"), player, 10, new string_id("npe", "pop_group"), "sound/dro_r2_3_danger.snd", "object/mobile/r2.iff"); return true; } public static boolean giveGroupPopUp2(obj_id player) throws InterruptedException { - string_id chat = new string_id("npe", "pop_group2"); - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); - commTutorialPlayer(droid, player, 20, chat, "sound/dro_r2_3_danger.snd", "object/mobile/r2.iff"); + commTutorialPlayer(utils.getObjIdScriptVar(getTopMostContainer(player), "objDroidInvis"), player, 20, new string_id("npe", "pop_group2"), "sound/dro_r2_3_danger.snd", "object/mobile/r2.iff"); return true; } public static boolean giveEscPopUp(obj_id player) throws InterruptedException { - string_id chat = new string_id("npe", "pop_escape"); - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); - commTutorialPlayer(droid, player, 10, chat, "sound/vo_c3po_xtra2.snd", "object/mobile/c_3po.iff"); + commTutorialPlayer(utils.getObjIdScriptVar(getTopMostContainer(player), "objDroidInvis"), player, 10, new string_id("npe", "pop_escape"), "sound/vo_c3po_xtra2.snd", "object/mobile/c_3po.iff"); return true; } public static boolean giveEntXpPopUp(obj_id player) throws InterruptedException { - string_id chat = new string_id("npe", "pop_entxp"); - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); - commTutorialPlayer(droid, player, 10, chat, "sound/dro_r2_3_danger.snd", "object/mobile/r2.iff"); + commTutorialPlayer(utils.getObjIdScriptVar(getTopMostContainer(player), "objDroidInvis"), player, 10, new string_id("npe", "pop_entxp"), "sound/dro_r2_3_danger.snd", "object/mobile/r2.iff"); return true; } public static boolean giveTraderXpPopUp(obj_id player) throws InterruptedException { - string_id chat = new string_id("npe", "pop_tradexp"); - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); - commTutorialPlayer(droid, player, 10, chat, "sound/dro_r2_3_danger.snd", "object/mobile/r2.iff"); + commTutorialPlayer(utils.getObjIdScriptVar(getTopMostContainer(player), "objDroidInvis"), player, 10, new string_id("npe", "pop_tradexp"), "sound/dro_r2_3_danger.snd", "object/mobile/r2.iff"); return true; } public static boolean giveStationWaypoint(obj_id player) throws InterruptedException { - obj_id[] waypoints = getWaypointsInDatapad(player); boolean theyHave = false; - for (int i = 0; i < waypoints.length; i++) - { - String myName = getWaypointName(waypoints[i]); - if (myName.equals("Station Gamma")) - { + String myName; + for (obj_id waypoint1 : getWaypointsInDatapad(player)) { + myName = getWaypointName(waypoint1); + if (myName.equals("Station Gamma")) { theyHave = true; + break; } } - if (theyHave == false) + if (!theyHave) { - location gamma = new location(663, -1002, 2039, "space_ord_mantell", null); - obj_id waypoint = createWaypointInDatapad(player, gamma); + obj_id waypoint = createWaypointInDatapad(player, new location(663, -1002, 2039, "space_ord_mantell", null)); setWaypointName(waypoint, "Station Gamma"); setWaypointColor(waypoint, "space"); setWaypointVisible(waypoint, true); @@ -1247,13 +1079,9 @@ public class npe extends script.base_script } public static boolean giveHarvestPopUp(obj_id player, obj_id npc) throws InterruptedException { - string_id harvest = new string_id("npe", "pop_harvest"); - int hadNotif = utils.getIntScriptVar(player, "npe.harvest"); - if (hadNotif == 0) + if (utils.getIntScriptVar(player, "npe.harvest") == 0) { - obj_id building = getTopMostContainer(player); - obj_id droid = utils.getObjIdScriptVar(building, "objDroidInvis"); - commTutorialPlayer(droid, player, 6, harvest, "sound/c3po_89.snd", "object/mobile/c_3po.iff"); + commTutorialPlayer(utils.getObjIdScriptVar(getTopMostContainer(player), "objDroidInvis"), player, 6, new string_id("npe", "pop_harvest"), "sound/c3po_89.snd", "object/mobile/c_3po.iff"); utils.setScriptVar(player, "npe.harvest", 1); return true; } @@ -1261,10 +1089,6 @@ public class npe extends script.base_script } public static void npeNpcVendor(obj_id player, obj_id npc) throws InterruptedException { - string_id stfPrompt = new string_id("npe", "store_prompt"); - string_id stfTitle = new string_id("npe", "store_title"); - String prompt = utils.packStringId(stfPrompt); - String title = utils.packStringId(stfTitle); String[] options = new String[2]; string_id[] items = new string_id[2]; items[0] = new string_id("npe", "store_item3"); @@ -1273,12 +1097,20 @@ public class npe extends script.base_script { options[i] = utils.packStringId(items[i]); } - int pid = sui.listbox(npc, player, prompt, sui.OK_CANCEL, title, options, "npeHandleBuy", false, false); - sui.showSUIPage(pid); + sui.showSUIPage(sui.listbox( + npc, + player, + utils.packStringId(new string_id("npe", "store_prompt")), + sui.OK_CANCEL, + utils.packStringId(new string_id("npe", "store_title")), + options, + "npeHandleBuy", + false, + false + )); } public static void giveTemplatePointer(obj_id player) throws InterruptedException { - String playerTemplate = getSkillTemplate(player); if (utils.isProfession(player, utils.BOUNTY_HUNTER)) { groundquests.sendSignal(player, "npe_solo_profession_2_end"); @@ -1327,9 +1159,7 @@ public class npe extends script.base_script } public static void commTutorialPlayer(obj_id owner, obj_id player, float duration, string_id text, String sfx, String appearance) throws InterruptedException { - prose_package pp = prose.getPackage(text); - commPlayers(owner, appearance, sfx, duration, player, pp); - return; + commPlayers(owner, appearance, sfx, duration, player, prose.getPackage(text)); } public static void sendDelayed3poPopup(obj_id player, int timeDelay, int duration, String soundFile, String strFile, String strMessage, String scriptVarName) throws InterruptedException { @@ -1344,16 +1174,13 @@ public class npe extends script.base_script } public static void removeAllQuests(obj_id player) throws InterruptedException { - int[] allQuests = questGetAllActiveQuestIds(player); - for (int y = 0; y < allQuests.length; y++) - { - questClearQuest(allQuests[y], player); + for (int quest : questGetAllActiveQuestIds(player)) { + questClearQuest(quest, player); } } public static obj_id[] giveProfessionWeapon(obj_id player) throws InterruptedException { obj_id pInv = utils.getInventoryContainer(player); - String playerTemplate = getSkillTemplate(player); HashSet theSet = new HashSet(); if (utils.isProfession(player, utils.SMUGGLER)) { @@ -1398,21 +1225,15 @@ public class npe extends script.base_script } public static void reGrantReWorkedQuests(obj_id player) throws InterruptedException { - String[] questList = dataTableGetStringColumn(QUEST_REWORK_TABLE, GROUND_QUESTS); - int listLength = questList.length; - for (int i = 0; i < listLength; i++) - { - if (groundquests.isQuestActive(player, questList[i])) - { - groundquests.clearQuest(player, questList[i]); - if (!questList[i].equals("npe_scout_1a") && !questList[i].equals("npe_brawler_2a")) - { - groundquests.grantQuestNoAcceptUI(player, questList[i], false); + for (String quest : dataTableGetStringColumn(QUEST_REWORK_TABLE, GROUND_QUESTS)) { + if (groundquests.isQuestActive(player, quest)) { + groundquests.clearQuest(player, quest); + if (!quest.equals("npe_scout_1a") && !quest.equals("npe_brawler_2a")) { + groundquests.grantQuestNoAcceptUI(player, quest, false); } } } setObjVar(player, QUEST_REWORK_VAR, QUEST_ENUMERATION); - return; } public static void clearActiveSpaceQuests(obj_id player) throws InterruptedException { @@ -1432,14 +1253,12 @@ public class npe extends script.base_script } } setObjVar(player, QUEST_REWORK_VAR, QUEST_ENUMERATION); - return; } public static boolean hasReachedMaxTutorialLevel(obj_id player) throws InterruptedException { - int playerLevel = getLevel(player); if (hasObjVar(player, "npe")) { - if (playerLevel >= LEVEL_CAP) + if (getLevel(player) >= LEVEL_CAP) { return true; } diff --git a/sku.0/sys.server/compiled/game/script/library/objvar_mangle.java b/sku.0/sys.server/compiled/game/script/library/objvar_mangle.java old mode 100644 new mode 100755 index c95a1b365..d89dc5532 --- a/sku.0/sys.server/compiled/game/script/library/objvar_mangle.java +++ b/sku.0/sys.server/compiled/game/script/library/objvar_mangle.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; +import script.obj_id; public class objvar_mangle extends script.base_script { @@ -56,18 +50,18 @@ public class objvar_mangle extends script.base_script removeObjVar(self, varName + "_mangled.segment"); setObjVar(self, varName + "_mangled.count", values.length); int pos, segment; + int segmentLength; + int[] segmentValues; for (pos = 0, segment = 0; pos < values.length; pos += INTS_PER_SEGMENT, ++segment) { - int segmentLength = values.length - pos; + segmentLength = values.length - pos; if (segmentLength > INTS_PER_SEGMENT) { segmentLength = INTS_PER_SEGMENT; } - int[] segmentValues = new int[segmentLength]; - for (int i = 0; i < segmentLength; ++i) - { - segmentValues[i] = values[pos + i]; - } + segmentValues = new int[segmentLength]; + System.arraycopy(values, pos, segmentValues, 0, segmentLength); + if (segmentValues.length > 0) { setObjVar(self, varName + "_mangled.segment." + segment, segmentValues); @@ -88,9 +82,10 @@ public class objvar_mangle extends script.base_script float[] values = new float[count]; int segment = 0; int valuePos = 0; + float[] segmentValues; while (valuePos < count) { - float[] segmentValues = getFloatArrayObjVar(self, varName + "_mangled.segment." + segment); + segmentValues = getFloatArrayObjVar(self, varName + "_mangled.segment." + segment); if (segmentValues == null) { break; @@ -112,19 +107,20 @@ public class objvar_mangle extends script.base_script removeObjVar(self, varName); removeObjVar(self, varName + "_mangled.segment"); setObjVar(self, varName + "_mangled.count", values.length); - int pos, segment; + int pos; + int segment; + int segmentLength; + float[] segmentValues; + for (pos = 0, segment = 0; pos < values.length; pos += FLOATS_PER_SEGMENT, ++segment) { - int segmentLength = values.length - pos; + segmentLength = values.length - pos; if (segmentLength > FLOATS_PER_SEGMENT) { segmentLength = FLOATS_PER_SEGMENT; } - float[] segmentValues = new float[segmentLength]; - for (int i = 0; i < segmentLength; ++i) - { - segmentValues[i] = values[pos + i]; - } + segmentValues = new float[segmentLength]; + System.arraycopy(values, pos, segmentValues, 0, segmentLength); if (segmentValues.length > 0) { setObjVar(self, varName + "_mangled.segment." + segment, segmentValues); @@ -145,9 +141,10 @@ public class objvar_mangle extends script.base_script String[] values = new String[count]; int segment = 0; int valuePos = 0; + String[] segmentValues; while (valuePos < count) { - String[] segmentValues = getStringArrayObjVar(self, varName + "_mangled.segment." + segment); + segmentValues = getStringArrayObjVar(self, varName + "_mangled.segment." + segment); if (segmentValues == null) { break; @@ -178,9 +175,11 @@ public class objvar_mangle extends script.base_script String[] values = new String[count]; int segment = 0; int valuePos = 0; + String[] segmentValues; + while (valuePos < count) { - String[] segmentValues = getStringArrayObjVar(self, varName + "_mangled.segment." + segment); + segmentValues = getStringArrayObjVar(self, varName + "_mangled.segment." + segment); if (segmentValues == null) { break; @@ -191,13 +190,11 @@ public class objvar_mangle extends script.base_script values[valuePos++] = segmentValues[i]; } } + if (valuePos != count) { String[] strNewStrings = new String[valuePos]; - for (int intI = 0; intI < valuePos; intI++) - { - strNewStrings[intI] = values[intI]; - } + System.arraycopy(values, 0, strNewStrings, 0, valuePos); return strNewStrings; } return values; @@ -207,19 +204,20 @@ public class objvar_mangle extends script.base_script removeObjVar(self, varName); removeObjVar(self, varName + "_mangled.segment"); setObjVar(self, varName + "_mangled.count", values.length); - int pos, segment; + int pos; + int segment; + int segmentLength; + String[] segmentValues; + for (pos = 0, segment = 0; pos < values.length; pos += STRINGS_PER_SEGMENT, ++segment) { - int segmentLength = values.length - pos; + segmentLength = values.length - pos; if (segmentLength > STRINGS_PER_SEGMENT) { segmentLength = STRINGS_PER_SEGMENT; } - String[] segmentValues = new String[segmentLength]; - for (int i = 0; i < segmentLength; ++i) - { - segmentValues[i] = values[pos + i]; - } + segmentValues = new String[segmentLength]; + System.arraycopy(values, pos, segmentValues, 0, segmentLength); if (segmentValues.length > 0) { setObjVar(self, varName + "_mangled.segment." + segment, segmentValues); @@ -240,9 +238,11 @@ public class objvar_mangle extends script.base_script obj_id[] values = new obj_id[count]; int segment = 0; int valuePos = 0; + obj_id[] segmentValues; + while (valuePos < count) { - obj_id[] segmentValues = getObjIdArrayObjVar(self, varName + "_mangled.segment." + segment); + segmentValues = getObjIdArrayObjVar(self, varName + "_mangled.segment." + segment); if (segmentValues == null) { break; @@ -264,19 +264,21 @@ public class objvar_mangle extends script.base_script removeObjVar(self, varName); removeObjVar(self, varName + "_mangled.segment"); setObjVar(self, varName + "_mangled.count", values.length); - int pos, segment; + int pos; + int segment; + int segmentLength; + obj_id[] segmentValues; + for (pos = 0, segment = 0; pos < values.length; pos += OBJIDS_PER_SEGMENT, ++segment) { - int segmentLength = values.length - pos; + segmentLength = values.length - pos; if (segmentLength > OBJIDS_PER_SEGMENT) { segmentLength = OBJIDS_PER_SEGMENT; } - obj_id[] segmentValues = new obj_id[segmentLength]; - for (int i = 0; i < segmentLength; ++i) - { - segmentValues[i] = values[pos + i]; - } + segmentValues = new obj_id[segmentLength]; + System.arraycopy(values, pos, segmentValues, 0, segmentLength); + if (segmentValues.length > 0) { setObjVar(self, varName + "_mangled.segment." + segment, segmentValues); diff --git a/sku.0/sys.server/compiled/game/script/library/pclib.java b/sku.0/sys.server/compiled/game/script/library/pclib.java old mode 100644 new mode 100755 index f591ca9bc..b8928de69 --- a/sku.0/sys.server/compiled/game/script/library/pclib.java +++ b/sku.0/sys.server/compiled/game/script/library/pclib.java @@ -1,43 +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.structure; -import script.library.sui; -import script.library.corpse; -import script.library.jedi; -import script.library.utils; -import script.library.prose; -import script.library.healing; -import script.library.battlefield; -import script.library.combat; -import script.library.factions; -import script.library.dot; -import script.library.group; -import script.library.pvp; -import script.library.ai_lib; -import script.library.innate; -import script.library.player_stomach; -import script.library.slots; -import script.library.money; -import script.library.player_structure; -import script.library.meditation; -import script.library.city; -import script.library.force_rank; -import script.library.missions; -import script.library.bounty_hunter; -import script.library.smuggler; -import script.library.buff; -import script.ai.ai_combat; -import java.util.Arrays; import java.util.Vector; -import java.util.Enumeration; public class pclib extends script.base_script { @@ -203,20 +168,11 @@ public class pclib extends script.base_script minCost = MIN_CLONING_SICKNESS_COST / 2; maxCost = MAX_CLONING_SICKNESS_COST / 2; } - float level = getLevel(player); - float costRatio = level / 90f; - float cost = minCost + ((maxCost - minCost) * costRatio); - return (int)cost; + return (int) (minCost + ((maxCost - minCost) * (getLevel(player) / 90f))); } public static boolean canAffordCloningSicknessCure(obj_id player) throws InterruptedException { - int cost = getCloningSicknessCureCost(player); - int balance = getTotalMoney(player); - if (cost > balance) - { - return false; - } - return true; + return getCloningSicknessCureCost(player) <= getTotalMoney(player); } public static void cureCloningSickness(obj_id player) throws InterruptedException { @@ -263,10 +219,6 @@ public class pclib extends script.base_script CustomerServiceLog("Trade", " Processing Tip, Player: " + player + " " + getName(player) + " Target: " + target + " " + getName(target) + " Amount: " + amt + " Cash: " + useCash); if (target.isLoaded() && !isPlayer(target)) { - if (targetName == null || targetName.equals("")) - { - targetName = utils.getStringName(target); - } CustomerServiceLog("Trade", " Tip -- Player: " + player + " " + getName(player) + " -- Tip aborted: Target isn't a player."); prose_package ppNoTipTarget = prose.getPackage(SID_MAY_NOT_TIP_TARGET); prose.setTT(ppNoTipTarget, target); @@ -314,8 +266,7 @@ public class pclib extends script.base_script if (amt > cash) { CustomerServiceLog("Trade", " Tip -- Player: " + player + " " + getName(player) + " Target: " + target + " -- Tip aborted: Insufficient cash. Amt: " + amt + " Cash: " + cash); - prose_package nsfCash = prose.getPackage(PROSE_TIP_NSF_CASH, target, amt); - sendSystemMessageProse(player, nsfCash); + sendSystemMessageProse(player, prose.getPackage(PROSE_TIP_NSF_CASH, target, amt)); return false; } CustomerServiceLog("Trade", " Tip -- Player: " + player + " " + getName(player) + " Target: " + target + " -- Transferring Cash! Amt: " + amt); @@ -337,8 +288,7 @@ public class pclib extends script.base_script if (amt > bank) { CustomerServiceLog("Trade", " Tip -- Player: " + player + " " + getName(player) + " Target: " + target + " -- Tip aborted: Insufficient bank balance. Amt: " + amt + " Bank: " + bank); - prose_package nsfBank = prose.getPackage(PROSE_TIP_NSF_BANK, target, amt); - sendSystemMessageProse(player, nsfBank); + sendSystemMessageProse(player, prose.getPackage(PROSE_TIP_NSF_BANK, target, amt)); return false; } int pid = showTipSui(player, target, targetName, amt); @@ -358,9 +308,7 @@ public class pclib extends script.base_script return -1; } CustomerServiceLog("Trade", " Tip -- Player: " + player + " " + getName(player) + " Target: " + target + " -- Showing bank tip wire UI."); - String title = utils.packStringId(SID_TIP_WIRE_TITLE); - String prompt = utils.packStringId(SID_TIP_WIRE_PROMPT); - int cBox = sui.msgbox(player, player, prompt, sui.YES_NO, title, "handleWireConfirm"); + int cBox = sui.msgbox(player, player, utils.packStringId(SID_TIP_WIRE_PROMPT), sui.YES_NO, utils.packStringId(SID_TIP_WIRE_TITLE), "handleWireConfirm"); if (cBox > -1) { utils.setScriptVar(player, VAR_TIP_SUI, cBox); @@ -455,14 +403,12 @@ public class pclib extends script.base_script } if (utils.getElementPositionInArray(consentTo, target) > -1) { - prose_package pp = prose.getPackage(PROSE_CONSENT_ALREADY_CONSENTING, getPlayerFullName(target)); - sendSystemMessageProse(player, pp); + sendSystemMessageProse(player, prose.getPackage(PROSE_CONSENT_ALREADY_CONSENTING, getPlayerFullName(target))); return false; } else if (consentTo.size() >= LIMIT_CONSENT_TO) { - prose_package pp = prose.getPackage(PROSE_CONSENT_LIST_FULL, LIMIT_CONSENT_TO); - sendSystemMessageProse(player, pp); + sendSystemMessageProse(player, prose.getPackage(PROSE_CONSENT_LIST_FULL, LIMIT_CONSENT_TO)); return false; } else @@ -520,8 +466,7 @@ public class pclib extends script.base_script { setObjVar(player, VAR_CONSENT_TO_ID, consentTo); } - prose_package pp = prose.getPackage(PROSE_UNCONSENT, getPlayerFullName(target)); - sendSystemMessageProse(player, pp); + sendSystemMessageProse(player, prose.getPackage(PROSE_UNCONSENT, getPlayerFullName(target))); dictionary d = new dictionary(); d.put(DICT_CONSENTER_ID, player); messageTo(target, HANDLER_RECEIVED_UNCONSENT, d, 0, true); @@ -549,11 +494,7 @@ public class pclib extends script.base_script } boolean isConsented = false; obj_id[] consentFrom = getObjIdArrayObjVar(player, VAR_CONSENT_FROM_ID); - if ((consentFrom == null) || (consentFrom.length == 0)) - { - } - else - { + if ((consentFrom != null) && (consentFrom.length != 0)) { if (utils.getElementPositionInArray(consentFrom, target) > -1) { isConsented = true; @@ -596,9 +537,8 @@ public class pclib extends script.base_script dictionary d = new dictionary(); d.put(corpse.DICT_PLAYER_ID, player); boolean litmus = true; - for (int i = 0; i < consentFromList.length; i++) - { - litmus &= messageTo(consentFromList[i], HANDLER_CONSENT_TO_LOGOUT, d, 0, true); + for (obj_id consentFromItem : consentFromList) { + litmus &= messageTo(consentFromItem, HANDLER_CONSENT_TO_LOGOUT, d, 0, true); } removeObjVar(player, VAR_CONSENT_FROM_BASE); return litmus; @@ -629,8 +569,7 @@ public class pclib extends script.base_script { return; } - int dam = -(getAttrib(player, HEALTH) + 50); - addAttribModifier(player, HEALTH, dam, 0f, 0f, MOD_POOL); + addAttribModifier(player, HEALTH, -(getAttrib(player, HEALTH) + 50), 0f, 0f, MOD_POOL); coupDeGrace(player, killer, false, usePVPRules); } public static void coupDeGrace(obj_id victim, obj_id killer, boolean playAnim) throws InterruptedException @@ -659,11 +598,9 @@ public class pclib extends script.base_script if (!victim.isAuthoritative() || !killer.isAuthoritative()) { requestSameServer(victim, killer); - int expireTime = getGameTime() + 60; - utils.setScriptVar(victim, "death.beingCoupDeGraced", expireTime); - int numberOfTries = 1; + utils.setScriptVar(victim, "death.beingCoupDeGraced", getGameTime() + 60); dictionary dict = new dictionary(); - dict.put("numberOfTries", numberOfTries); + dict.put("numberOfTries", 1); dict.put("victim", victim); dict.put("killer", killer); dict.put("playAnim", playAnim); @@ -673,8 +610,7 @@ public class pclib extends script.base_script } if (isDead(victim)) { - prose_package pp = prose.getPackage(PROSE_TARGET_ALREADY_DEAD, victim); - sendSystemMessageProse(killer, pp); + sendSystemMessageProse(killer, prose.getPackage(PROSE_TARGET_ALREADY_DEAD, victim)); return; } if (!isIncapacitated(victim)) @@ -689,7 +625,7 @@ public class pclib extends script.base_script setObjVar(victim, VAR_DEATHBLOW_STAMP, getGameTime()); } gcw.releaseGcwPointCredit(victim); - obj_id master = null; + obj_id master; obj_id pvpKiller = killer; if (!isPlayer(killer)) { @@ -736,12 +672,6 @@ public class pclib extends script.base_script playDeathBlowAnimation(victim, killer); } boolean dueling = pvpIsDueling(victim, pvpKiller); - if (getPosture(victim) != POSTURE_DEAD) - { - if (!setPosture(victim, POSTURE_DEAD)) - { - } - } if (killer != victim) { prose_package ppToKiller = prose.getPackage(PROSE_TARGET_DEAD, victim); @@ -760,9 +690,6 @@ public class pclib extends script.base_script return; } } - else - { - } playerDeath(victim, killer, dueling); } public static void playDeathBlowAnimation(obj_id victim, obj_id killer) throws InterruptedException @@ -775,11 +702,7 @@ public class pclib extends script.base_script if (dataTableOpen(DATATABLE_AI_SPECIES)) { int species = getSpecies(killer); - if (species == -1) - { - } - else - { + if (species != -1) { skeleton = dataTableGetString(DATATABLE_AI_SPECIES, species, DATATABLE_COL_SKELETON); } } @@ -840,8 +763,7 @@ public class pclib extends script.base_script } else { - prose_package ppToVictim = prose.getPackage(PROSE_VICTIM_DEAD, killer); - sendSystemMessageProse(player, ppToVictim); + sendSystemMessageProse(player, prose.getPackage(PROSE_VICTIM_DEAD, killer)); } float factionMod = 1.0f; if (!isPlayer(killer) && isMob(killer) && isIdValid(getMaster(killer))) @@ -894,10 +816,9 @@ public class pclib extends script.base_script { return; } - for (int i = 0; i < myHateList.length; i++) - { - removeHateTarget(self, myHateList[i]); - removeHateTarget(myHateList[i], self); + for (obj_id hateItem : myHateList) { + removeHateTarget(self, hateItem); + removeHateTarget(hateItem, self); } } public static boolean playerRevive(obj_id player) throws InterruptedException @@ -920,8 +841,7 @@ public class pclib extends script.base_script return false; } setObjVar(player, "fullHealClone", true); - boolean warped = sendToCloneSpawn(player, HANDLER_CLONE_RESPAWN, reviveLoc, spawnLoc); - if (!warped) + if (!sendToCloneSpawn(player, HANDLER_CLONE_RESPAWN, reviveLoc, spawnLoc)) { sendSystemMessage(player, cloninglib.SID_RESPAWN_CURRENT_LOCATION); messageTo(player, HANDLER_CLONE_RESPAWN, null, 2, true); @@ -942,24 +862,18 @@ public class pclib extends script.base_script obj_id[] items = utils.getFilteredPlayerContents(player); if ((items != null) && (items.length > 0)) { - for (int i = 0; i < items.length; i++) - { - int got = getGameObjectType(items[i]); - if (isGameObjectTypeOf(got, GOT_clothing) || isGameObjectTypeOf(got, GOT_armor)) - { - equip(items[i], player); + int got; + for (obj_id item : items) { + got = getGameObjectType(item); + if (isGameObjectTypeOf(got, GOT_clothing) || isGameObjectTypeOf(got, GOT_armor)) { + equip(item, player); } } } return true; } - public static boolean autoInsureItem(obj_id item) throws InterruptedException - { - if (!isIdValid(item)) - { - return false; - } - return setAutoInsured(item); + public static boolean autoInsureItem(obj_id item) throws InterruptedException { + return isIdValid(item) && setAutoInsured(item); } public static boolean resurrectPlayer(obj_id target) throws InterruptedException { @@ -971,8 +885,7 @@ public class pclib extends script.base_script { return false; } - int posture = getPosture(target); - if (posture == POSTURE_DEAD) + if (getPosture(target) == POSTURE_DEAD) { clearEffectsForDeath(target); if (utils.hasScriptVar(target, VAR_SUI_CLONE)) @@ -1006,22 +919,16 @@ public class pclib extends script.base_script setCombatTarget(target, null); stopCombat(target); obj_id[] objEnemies = getHateList(target); - for (int i = 0; i < objEnemies.length; i++) - { - if (!isIdValid(objEnemies[i]) || !exists(objEnemies[i])) - { + for (obj_id objEnemy : objEnemies) { + if (!isIdValid(objEnemy) || !exists(objEnemy)) { continue; } - if (!isPlayer(objEnemies[i])) - { - if (isIdValid(objEnemies[i]) && exists(objEnemies[i]) && isIdValid(target) && exists(target)) - { - removeHateTarget(objEnemies[i], target); + if (!isPlayer(objEnemy)) { + if (isIdValid(objEnemy) && exists(objEnemy) && isIdValid(target) && exists(target)) { + removeHateTarget(objEnemy, target); } - } - else - { - setCombatTarget(objEnemies[i], null); + } else { + setCombatTarget(objEnemy, null); } } removeObjVar(target, "intBurstRunning"); @@ -1116,13 +1023,15 @@ public class pclib extends script.base_script return; } boolean isTrandoshan = isSpecies(player, SPECIES_TRANDOSHAN); + obj_id object; + for (int i = 0; i < slots.EQ_SLOTS.length; ++i) { - if (isTrandoshan && slots.EQ_SLOTS[i] == slots.SHOES) + if (isTrandoshan && slots.EQ_SLOTS[i].equals(slots.SHOES)) { continue; } - obj_id object = getObjectInSlot(player, slots.EQ_SLOTS[i]); + object = getObjectInSlot(player, slots.EQ_SLOTS[i]); if (isIdValid(object)) { destroyObject(object); @@ -1145,11 +1054,9 @@ public class pclib extends script.base_script { return; } - for (int i = 0; i < contents.length; ++i) - { - if (isIdValid(contents[i])) - { - destroyObject(contents[i]); + for (obj_id content : contents) { + if (isIdValid(content)) { + destroyObject(content); } } } @@ -1169,11 +1076,9 @@ public class pclib extends script.base_script { return; } - for (int i = 0; i < contents.length; ++i) - { - if (isIdValid(contents[i])) - { - destroyObject(contents[i]); + for (obj_id content : contents) { + if (isIdValid(content)) { + destroyObject(content); } } } @@ -1277,9 +1182,10 @@ public class pclib extends script.base_script } dot.removeAllDots(player); removeAllAttribModifiers(player); + String objvarName; for (int i = 0; i < NUM_ATTRIBUTES; i++) { - String objvarName = "healing." + (healing.attributeToString(i)).toLowerCase() + "_enhance"; + objvarName = "healing." + ((healing.attributeToString(i)) != null ? (healing.attributeToString(i)).toLowerCase() : "") + "_enhance"; if (hasObjVar(player, objvarName)) { removeObjVar(player, objvarName); @@ -1317,11 +1223,7 @@ public class pclib extends script.base_script containers = utils.addElement(containers, c); c = getContainedBy(c); } - if (utils.getElementPositionInArray(containers, player) > -1) - { - return true; - } - return false; + return utils.getElementPositionInArray(containers, player) > -1; } public static boolean msgAttachScript(obj_id player, String scriptName) throws InterruptedException { @@ -1415,43 +1317,38 @@ public class pclib extends script.base_script { Vector resourceList = new Vector(); resourceList.setSize(0); - for (int i = 0; i < resources.length; i++) - { - if (!isResourceDerivedFrom(resources[i], resourceClass)) - { + String parent; + String child; + + for (obj_id resource : resources) { + if (!isResourceDerivedFrom(resource, resourceClass)) { continue; } - String parent = getResourceClass(resources[i]); - String child = null; - if (parent == null) - { + parent = getResourceClass(resource); + child = null; + if (parent == null) { continue; } - while (!parent.equals(resourceClass)) - { + while (!parent.equals(resourceClass)) { child = parent; parent = getResourceParentClass(child); } - if (child == null) - { - child = "\\#pcontrast1 " + getResourceName(resources[i]) + "\\#."; + if (child == null) { + child = "\\#pcontrast1 " + getResourceName(resource) + "\\#."; } - for (int j = 0; j < branchLevel; j++) - { + for (int j = 0; j < branchLevel; j++) { child = " " + child; } - if (resourceList.indexOf(child) == -1) - { + if (resourceList.indexOf(child) == -1) { resourceList.add(child); } } for (int i = 0; i < resourceList.size(); i++) { - String parent = ((String)resourceList.get(i)).trim(); - String[] childBranch = buildSortedResourceList(resources, parent, branchLevel + 1); - for (int j = 0; j < childBranch.length; j++) - { - resourceList.add(++i, childBranch[j]); + parent = ((String) resourceList.get(i)).trim(); + String[] childBranchs = buildSortedResourceList(resources, parent, branchLevel + 1); + for (String childBranch : childBranchs) { + resourceList.add(++i, childBranch); } } String[] _resourceList = new String[0]; @@ -1465,21 +1362,19 @@ public class pclib extends script.base_script public static String createResourcePlanetReport(String[] resourceList, String planet, String resourceClass) throws InterruptedException { String report = "Incoming planetary survey report...\n\n" + "\\#pcontrast3 Planet: \\#pcontrast1 " + toUpper(planet, 0) + "\n" + "\\#pcontrast3 Resource Class: \\#pcontrast1 " + getClassString(resourceClass) + "\n\n" + "\\#pcontrast3 Resources located...\\#.\n\n"; - for (int i = 0; i < resourceList.length; i++) - { - String resourceName = resourceList[i].trim(); - if (resourceName.startsWith("\\#")) - { + String resourceName; + obj_id resourceId; + + for (String resource : resourceList) { + resourceName = resource.trim(); + if (resourceName.startsWith("\\#")) { resourceName = resourceName.substring(13, resourceName.length() - 3); } - obj_id resourceId = getResourceTypeByName(resourceName); - if (resourceId == null) - { - report += " " + getTab(resourceList[i]) + getClassString(resourceName) + "\n"; - } - else - { - report += " " + resourceList[i] + "\n"; + resourceId = getResourceTypeByName(resourceName); + if (resourceId == null) { + report += " " + getTab(resource) + getClassString(resourceName) + "\n"; + } else { + report += " " + resource + "\n"; } } report += "\n\n"; diff --git a/sku.0/sys.server/compiled/game/script/library/planetary_map.java b/sku.0/sys.server/compiled/game/script/library/planetary_map.java old mode 100644 new mode 100755 index 811960902..05e4d2258 --- a/sku.0/sys.server/compiled/game/script/library/planetary_map.java +++ b/sku.0/sys.server/compiled/game/script/library/planetary_map.java @@ -1,24 +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.locations; -import script.library.city; -import script.library.player_structure; -import script.library.structure; -import script.library.factions; -import script.library.regions; -import script.library.hq; -import script.library.instance; -import script.library.utils; -import script.library.sui; -import java.util.Arrays; import java.util.Vector; public class planetary_map extends script.base_script @@ -76,7 +59,6 @@ public class planetary_map extends script.base_script { return addTerminalLocation(self); } - String locType = "map"; String planet = getCurrentSceneName(); if ((planet == null) || (planet.equals(""))) { @@ -110,16 +92,13 @@ public class planetary_map extends script.base_script { category = CITY; locationName = getCityRegionName(here); - locType = "CITY"; } else { - dictionary row = new dictionary(); - row = dataTableGetRow(TBL, template); + dictionary row = dataTableGetRow(TBL, template); if ((row == null) || (row.isEmpty())) { - String msg = "WARNING: map_location -> obj_id " + self + " unable to locate template (" + template + ") in datatable!"; - debugServerConsoleMsg(self, msg); + debugServerConsoleMsg(self, "WARNING: map_location -> obj_id " + self + " unable to locate template (" + template + ") in datatable!"); } else { @@ -155,8 +134,7 @@ public class planetary_map extends script.base_script } if (player_structure.isCivic(self)) { - int city_id = getCityAtLocation(getLocation(self), 0); - locationName = cityGetName(city_id); + locationName = cityGetName(getCityAtLocation(getLocation(self), 0)); flags = MLF_INACTIVE; } else if (player_structure.isCommercial(self)) @@ -220,14 +198,7 @@ public class planetary_map extends script.base_script { return null; } - if (r.length > 1) - { - for (int i = 0; i < r.length; i++) - { - } - } - region city = r[0]; - return city.getName(); + return r[0].getName(); } public static void removeMapLocation(obj_id self) throws InterruptedException { @@ -235,15 +206,6 @@ public class planetary_map extends script.base_script { return; } - String template = getTemplateName(self); - if (template != null) - { - } - location here = getLocation(self); - if (here != null) - { - } - String planet = getCurrentSceneName(); removePlanetaryMapLocation(self); } public static boolean addCreatureLocation(obj_id self) throws InterruptedException @@ -252,7 +214,6 @@ public class planetary_map extends script.base_script { return false; } - String locType = "map"; String planet = getCurrentSceneName(); if ((planet == null) || (planet.equals(""))) { @@ -275,14 +236,11 @@ public class planetary_map extends script.base_script } if (cType.equals("junk_dealer")) { - String myName = getEncodedName(self); - return addPlanetaryMapLocation(self, myName, (int)here.x, (int)here.z, CAT_VENDOR, SUB_VENDOR_JUNK, MLT_STATIC, NO_FLAG); + return addPlanetaryMapLocation(self, getEncodedName(self), (int)here.x, (int)here.z, CAT_VENDOR, SUB_VENDOR_JUNK, MLT_STATIC, NO_FLAG); } else if (cType.startsWith("trainer_")) { - String myName = getEncodedName(self); - String subCat = cType; - return addPlanetaryMapLocation(self, myName, (int)here.x, (int)here.z, CAT_TRAINER, subCat, MLT_STATIC, NO_FLAG); + return addPlanetaryMapLocation(self, getEncodedName(self), (int)here.x, (int)here.z, CAT_TRAINER, cType, MLT_STATIC, NO_FLAG); } } } @@ -335,20 +293,13 @@ public class planetary_map extends script.base_script map_location[] mapLocs = getPlanetaryMapLocations(CITY, null); if (mapLocs != null && mapLocs.length > 0) { - for (int i = 0; i < mapLocs.length; i++) - { - if ((mapLocs[i].getLocationName()).equals(cityName)) - { - string_id sid_cityName = utils.unpackString(cityName); - location cityLoc = new location(mapLocs[i].getX(), 0, mapLocs[i].getY()); - String cardinalString = utils.getStringCardinalDirection(cityLoc, here, true); - if (cardinalString != null && !cardinalString.equals("")) - { - String locName = getString(sid_cityName) + " (" + cardinalString + ")"; - return addPlanetaryMapLocation(self, locName, (int)here.x, (int)here.z, CAT_TERMINAL, subCat, MLT_STATIC, NO_FLAG); - } - else - { + String cardinalString; + for (map_location mapLoc : mapLocs) { + if ((mapLoc.getLocationName()).equals(cityName)) { + cardinalString = utils.getStringCardinalDirection(new location(mapLoc.getX(), 0, mapLoc.getY()), here, true); + if (cardinalString != null && !cardinalString.equals("")) { + return addPlanetaryMapLocation(self, getString(utils.unpackString(cityName)) + " (" + cardinalString + ")", (int) here.x, (int) here.z, CAT_TERMINAL, subCat, MLT_STATIC, NO_FLAG); + } else { break; } } @@ -377,15 +328,17 @@ public class planetary_map extends script.base_script } float min = Float.POSITIVE_INFINITY; int locIdx = -1; - float x = 0f; - float z = 0f; - location there = new location(); + float x; + float z; + location there; + float dist; + for (int n = 0; n < map_locs.length; n++) { x = (float)(map_locs[n].getX()); z = (float)(map_locs[n].getY()); there = new location(x, 0, z); - float dist = utils.getDistance2D(here, there); + dist = utils.getDistance2D(here, there); if (dist < min) { min = dist; @@ -441,32 +394,25 @@ public class planetary_map extends script.base_script entries.setSize(0); Vector params = new Vector(); params.setSize(0); - for (int i = 0; i < cats.length; i++) - { - String cat = cats[i]; - String[] subs = getUniquePlanetaryMapCategories(cat); - if ((subs != null) && (subs.length > 0)) - { + + String[] subs; + + for (String cat : cats) { + subs = getUniquePlanetaryMapCategories(cat); + if ((subs != null) && (subs.length > 0)) { LOG("find", "showFindSui: cat = " + cat + " sub count = " + subs.length); - string_id sid_cat = new string_id("map_loc_cat_n", cat); - for (int n = 0; n < subs.length; n++) - { - string_id sid_sub = new string_id("map_loc_cat_n", subs[n]); - entries = utils.addElement(entries, getString(sid_cat) + ": " + getString(sid_sub)); - params = utils.addElement(params, subs[n]); + for (String sub : subs) { + entries = utils.addElement(entries, getString(new string_id("map_loc_cat_n", cat)) + ": " + getString(new string_id("map_loc_cat_n", sub))); + params = utils.addElement(params, sub); } - } - else - { + } else { entries = utils.addElement(entries, "@map_loc_cat_n:" + cat); params = utils.addElement(params, cat); } } if ((entries != null) && (entries.size() > 0)) { - String title = utils.packStringId(SID_FIND_TITLE); - String prompt = utils.packStringId(SID_FIND_PROMPT); - int pid = sui.listbox(self, self, prompt, sui.OK_CANCEL, title, entries, "handleFindSui"); + int pid = sui.listbox(self, self, utils.packStringId(SID_FIND_PROMPT), sui.OK_CANCEL, utils.packStringId(SID_FIND_TITLE), entries, "handleFindSui"); if (pid > -1) { utils.setScriptVar(self, SCRIPTVAR_FIND_SUI, pid); @@ -481,8 +427,7 @@ public class planetary_map extends script.base_script obj_id self = getSelf(); if (utils.hasScriptVar(self, SCRIPTVAR_FIND_SUI)) { - int pid = utils.getIntScriptVar(self, SCRIPTVAR_FIND_SUI); - forceCloseSUIPage(pid); + forceCloseSUIPage(utils.getIntScriptVar(self, SCRIPTVAR_FIND_SUI)); cleanupFindSui(); } } @@ -501,23 +446,17 @@ public class planetary_map extends script.base_script } Vector unique = new Vector(); unique.setSize(0); - for (int i = 0; i < cats.length; i++) - { - if (utils.getElementPositionInArray(unique, cats[i]) == -1) - { - unique = utils.addElement(unique, cats[i]); + for (String cat : cats) { + if (utils.getElementPositionInArray(unique, cat) == -1) { + unique = utils.addElement(unique, cat); } } if ((unique == null) || (unique.size() == 0)) { return null; } - String[] _unique = new String[0]; - if (unique != null) - { - _unique = new String[unique.size()]; - unique.toArray(_unique); - } + String[] _unique = new String[unique.size()]; + unique.toArray(_unique); return _unique; } public static boolean updateFacilityActive(obj_id facility, boolean isActive) throws InterruptedException @@ -539,7 +478,7 @@ public class planetary_map extends script.base_script { return false; } - byte flags = maploc.getFlags(); + byte flags; if (isActive) { flags = MLF_ACTIVE; diff --git a/sku.0/sys.server/compiled/game/script/library/player_stomach.java b/sku.0/sys.server/compiled/game/script/library/player_stomach.java old mode 100644 new mode 100755 index be470198e..29ca35e7f --- a/sku.0/sys.server/compiled/game/script/library/player_stomach.java +++ b/sku.0/sys.server/compiled/game/script/library/player_stomach.java @@ -1,12 +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.obj_id; +import script.string_id; public class player_stomach extends script.base_script { @@ -42,11 +37,7 @@ public class player_stomach extends script.base_script } public static boolean isValidStomach(int idx) throws InterruptedException { - if ((idx >= STOMACH_FOOD) && (idx < STOMACH_MAX)) - { - return true; - } - return false; + return (idx >= STOMACH_FOOD) && (idx < STOMACH_MAX); } public static String getStomachVar(int stomach) throws InterruptedException { @@ -58,13 +49,11 @@ public class player_stomach extends script.base_script } public static string_id getStomachFullMsg(int stomach) throws InterruptedException { - String lookup = dataTableGetString(DATATABLE_STOMACH, stomach, COL_MSG_FULL); - return new string_id("error_message", lookup); + return new string_id("error_message", dataTableGetString(DATATABLE_STOMACH, stomach, COL_MSG_FULL)); } public static string_id getTargetFullMsg(int stomach) throws InterruptedException { - String lookup = dataTableGetString(DATATABLE_STOMACH, stomach, COL_TARGET_FULL); - return new string_id("error_message", lookup); + return new string_id("error_message", dataTableGetString(DATATABLE_STOMACH, stomach, COL_TARGET_FULL)); } public static int setStomach(obj_id player, int stomach, int vol, int stamp) throws InterruptedException { @@ -80,13 +69,12 @@ public class player_stomach extends script.base_script { return -1; } - boolean litmus = true; int maxSize = getStomachMaxSize(stomach); if (vol > maxSize) { vol = maxSize; } - litmus &= setObjVar(player, getStomachVar(stomach), vol); + boolean litmus = setObjVar(player, getStomachVar(stomach), vol); litmus &= setObjVar(player, getStampVar(stomach), stamp); if (litmus) { @@ -103,8 +91,7 @@ public class player_stomach extends script.base_script } public static boolean canAddToStomach(obj_id player, int[] vol) throws InterruptedException { - boolean result = true; - return result; + return true; } public static boolean addToStomach(obj_id player, int stomach, int vol) throws InterruptedException { @@ -116,8 +103,7 @@ public class player_stomach extends script.base_script } public static boolean addToStomach(obj_id player, obj_id target, int[] vol) throws InterruptedException { - boolean litmus = true; - return litmus; + return true; } public static boolean addToStomach(obj_id player, int[] vol) throws InterruptedException { @@ -133,19 +119,12 @@ public class player_stomach extends script.base_script { return -1; } - int curVol = 0; - int stamp = 0; - int curTime = getGameTime(); - int deltaTime = 0; int digestRate = getStomachDigestRate(stomach); - int digestCycles = 0; - int digested = 0; - curVol = getIntObjVar(player, getStomachVar(stomach)); - stamp = getIntObjVar(player, getStampVar(stomach)); - deltaTime = curTime - stamp; - digestCycles = deltaTime / digestRate; - digested = digestCycles * getStomachDigestValue(stomach); - curVol -= digested; + int curVol = getIntObjVar(player, getStomachVar(stomach)); + int stamp = getIntObjVar(player, getStampVar(stomach)); + int digestCycles = (getGameTime() - stamp) / digestRate; + + curVol -= (digestCycles * getStomachDigestValue(stomach)); if (curVol < 0) { curVol = 0; diff --git a/sku.0/sys.server/compiled/game/script/library/player_structure.java b/sku.0/sys.server/compiled/game/script/library/player_structure.java old mode 100644 new mode 100755 index b3b267052..7fe619b2e --- a/sku.0/sys.server/compiled/game/script/library/player_structure.java +++ b/sku.0/sys.server/compiled/game/script/library/player_structure.java @@ -1,24 +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 script.library.city; -import script.library.prose; -import script.library.regions; -import script.library.static_item; -import script.library.sui; -import script.library.target_dummy; -import script.library.trace; -import script.library.trial; -import script.library.utils; -import script.library.vendor_lib; +import java.util.StringTokenizer; +import java.util.Vector; public class player_structure extends script.base_script { @@ -264,8 +249,7 @@ public class player_structure extends script.base_script { return null; } - float rot_float = (float)(90 * rotation); - setYaw(structure, rot_float); + setYaw(structure, (float)(90 * rotation)); persistObject(structure); initializeStructure(structure, owner, deed_info); dictionary outparams = new dictionary(); @@ -305,13 +289,6 @@ public class player_structure extends script.base_script { return null; } - String cityName = getStringObjVar(deed, "cityName"); - String template = getDeedTemplate(deed); - String deed_template = getTemplateName(deed); - int build_time = getDeedBuildTime(deed); - int time_stamp = getGameTime(); - String owner_name = getPlayerName(owner); - String scene = getDeedScene(deed); int max_extraction = -1; int current_extraction = -1; int max_hopper = -1; @@ -338,10 +315,12 @@ public class player_structure extends script.base_script { CustomerServiceLog("playerStructure", "Deed " + deed + " with suplus maintenance used. Amount: " + maintPool + ". Owner is %TU.", owner, null); } + String template = getDeedTemplate(deed); if (template == null) { return null; } + int build_time = getDeedBuildTime(deed); if (build_time == -1) { return null; @@ -355,9 +334,8 @@ public class player_structure extends script.base_script { return null; } - String temp_template = dataTableGetString(PLAYER_STRUCTURE_DATATABLE, idx, DATATABLE_COL_TEMP_STRUCTURE); loc.y = getHeightAtLocation(loc.x, loc.z); - obj_id structure = createObject(temp_template, loc); + obj_id structure = createObject(dataTableGetString(PLAYER_STRUCTURE_DATATABLE, idx, DATATABLE_COL_TEMP_STRUCTURE), loc); if (!isIdValid(structure)) { structure = createObject("object/building/player/construction_structure.iff", loc); @@ -367,14 +345,15 @@ public class player_structure extends script.base_script } } persistObject(structure); - float rot_fl = (float)(rot * 90); - setYaw(structure, rot_fl); + setYaw(structure, (float)(rot * 90)); + int time_stamp = getGameTime(); setObjVar(structure, VAR_DEED_BUILDTIME, build_time); setObjVar(structure, VAR_DEED_TIMESTAMP, time_stamp); - String structure_name = localize(getNameStringId(structure)); - addStructure(structure, template, structure_name, loc, owner, owner_name, true, true); + String owner_name = getPlayerName(owner); + addStructure(structure, template, localize(getNameStringId(structure)), loc, owner, owner_name, true, true); int maintenance_mod = getSkillStatMod(owner, "structure_maintenance_mod"); int factory_mod = getSkillStatMod(owner, "factory_efficiency"); + String deed_template = getTemplateName(deed); dictionary deed_info = new dictionary(); deed_info.put("template", deed_template); deed_info.put("build_time", build_time); @@ -398,7 +377,9 @@ public class player_structure extends script.base_script setObjVar(structure, VAR_TEMP_PLACEMENT_HEIGHT, placementHeight); setDeedTemplate(structure, deed_template); setObjVar(structure, VAR_DEED_BUILDTIME, build_time); + String scene = getDeedScene(deed); setObjVar(structure, VAR_DEED_SCENE, scene); + String cityName = getStringObjVar(deed, "cityName"); if (cityName != null && !cityName.equals("")) { setObjVar(structure, "cityName", cityName); @@ -459,8 +440,7 @@ public class player_structure extends script.base_script return false; } String sceneName = getCurrentSceneName(); - String structureTemplate = getTemplateName(structure); - int numItems = 0; + int numItems; if (dataTableOpen(PLAYER_STRUCTURE_DATATABLE)) { numItems = dataTableGetNumRows(PLAYER_STRUCTURE_DATATABLE); @@ -475,13 +455,27 @@ public class player_structure extends script.base_script } boolean object_set = false; boolean object_mode = false; - obj_id object = obj_id.NULL_ID; + obj_id object; Vector base_object_list = new Vector(); base_object_list.setSize(0); + + String buildingTemplate; + dictionary item; + String TEMPLATE; + float X; + float Y; + float Z; + float HEADING; + String CELL_NAME; + obj_id CELL_ID; + location s_loc; + float[] delta_trans; + location spot; + for (int i = 0; i < numItems; i++) { - String buildingTemplate = dataTableGetString(PLAYER_STRUCTURE_DATATABLE, i, DATATABLE_COL_STRUCTURE); - if (buildingTemplate.equals(structureTemplate)) + buildingTemplate = dataTableGetString(PLAYER_STRUCTURE_DATATABLE, i, DATATABLE_COL_STRUCTURE); + if (buildingTemplate.equals(getTemplateName(structure))) { object_mode = true; continue; @@ -492,20 +486,19 @@ public class player_structure extends script.base_script { break; } - dictionary item = dataTableGetRow(PLAYER_STRUCTURE_DATATABLE, i); - String TEMPLATE = item.getString(DATATABLE_COL_OBJECT); - float X = item.getFloat(DATATABLE_COL_X); - float Y = item.getFloat(DATATABLE_COL_Y); - float Z = item.getFloat(DATATABLE_COL_Z); - float HEADING = item.getFloat(DATATABLE_COL_HEADING); - String CELL_NAME = item.getString(DATATABLE_COL_CELL); - obj_id CELL_ID = obj_id.NULL_ID; - location s_loc = getLocation(structure); + item = dataTableGetRow(PLAYER_STRUCTURE_DATATABLE, i); + TEMPLATE = item.getString(DATATABLE_COL_OBJECT); + X = item.getFloat(DATATABLE_COL_X); + Y = item.getFloat(DATATABLE_COL_Y); + Z = item.getFloat(DATATABLE_COL_Z); + HEADING = item.getFloat(DATATABLE_COL_HEADING); + CELL_NAME = item.getString(DATATABLE_COL_CELL); + s_loc = getLocation(structure); if (CELL_NAME.equals(WORLD_DELTA)) { if (rotation != 0) { - float[] delta_trans = transformDeltaWorldCoord(X, Z, rotation); + delta_trans = transformDeltaWorldCoord(X, Z, rotation); X = delta_trans[0]; Z = delta_trans[1]; HEADING = HEADING + (float)(rotation * 90); @@ -514,8 +507,7 @@ public class player_structure extends script.base_script HEADING = HEADING - 360; } } - location obj_loc = new location(s_loc.x - X, s_loc.y - Y, s_loc.z - Z, sceneName, obj_id.NULL_ID); - object = createObject(TEMPLATE, obj_loc); + object = createObject(TEMPLATE, new location(s_loc.x - X, s_loc.y - Y, s_loc.z - Z, sceneName, obj_id.NULL_ID)); if (isCivic(structure)) { setOwner(object, structure); @@ -530,7 +522,7 @@ public class player_structure extends script.base_script } else { - location spot = new location(X, Y, Z, sceneName, CELL_ID); + spot = new location(X, Y, Z, sceneName, CELL_ID); object = createObjectInCell(TEMPLATE, structure, CELL_NAME, spot); } } @@ -539,7 +531,6 @@ public class player_structure extends script.base_script setYaw(object, HEADING); base_object_list = utils.addElement(base_object_list, object); object_set = true; - object = obj_id.NULL_ID; } } } @@ -584,23 +575,15 @@ public class player_structure extends script.base_script int civic = 0; int city_rank = 0; int city_cost = 0; - float power_value = 0f; float power_rate = getBasePowerRate(structure); - int items_stored = 0; int idx = getStructureTableIndex(template); - if (idx == -1) - { - } - else - { + if (idx != -1) { decay_rate = dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, idx, DATATABLE_COL_DECAY_RATE); condition = dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, idx, DATATABLE_COL_CONDITION); civic = dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, idx, DATATABLE_COL_CIVIC); city_rank = dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, idx, DATATABLE_COL_CITY_RANK); city_cost = dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, idx, DATATABLE_COL_CITY_COST); } - int version = dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, idx, DATATABLE_COL_VERSION); - int got = getGameObjectType(structure); setOwner(structure, owner); setObjVar(structure, VAR_OWNER, owner_name); String owner_faction = deed_info.getString("owner_faction"); @@ -630,13 +613,14 @@ public class player_structure extends script.base_script setMaxHitpoints(structure, condition); setInvulnerableHitpoints(structure, condition); } - setObjVar(structure, VAR_VERSION, version); + setObjVar(structure, VAR_VERSION, dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, idx, DATATABLE_COL_VERSION)); if (isBuilding(structure)) { setObjVar(structure, "healing.canhealwound", 1); setObjVar(structure, "healing.canhealshock", 1); setObjVar(structure, "safeLogout", 1); } + int got = getGameObjectType(structure); if (isInstallation(structure) && got != GOT_installation_turret) { String[] hopperList = new String[1]; @@ -665,15 +649,15 @@ public class player_structure extends script.base_script setObjVar(structure, VAR_DEED_SCENE, deed_info.getString("scene")); if (deed_info.containsKey("current_extraction") && (isHarvester(structure) || isGenerator(structure))) { - int expertiseExtractionIncrease = (int)getSkillStatisticModifier(owner, "expertise_harvester_collection_increase"); + int expertiseExtractionIncrease = getSkillStatisticModifier(owner, "expertise_harvester_collection_increase"); int currentExtraction = deed_info.getInt("current_extraction"); int maxExtraction = deed_info.getInt("max_extraction"); setObjVar(structure, "current_extraction", currentExtraction); setObjVar(structure, "max_extraction", maxExtraction); if (expertiseExtractionIncrease > 0) { - currentExtraction += (int)(currentExtraction * (float)(expertiseExtractionIncrease / 100.0f)); - maxExtraction += (int)(maxExtraction * (float)(expertiseExtractionIncrease / 100.0f)); + currentExtraction += (int)(currentExtraction * expertiseExtractionIncrease / 100.0f); + maxExtraction += (int)(maxExtraction * expertiseExtractionIncrease / 100.0f); } if (currentExtraction > HARVESTER_MAX_EXTRACTION_RATE) { @@ -692,10 +676,10 @@ public class player_structure extends script.base_script setObjVar(structure, VAR_DEED_MAX_HOPPER, max_hopper); if (isHarvester(structure) || isGenerator(structure)) { - int expertiseHopperIncrease = (int)getSkillStatisticModifier(owner, "expertise_havester_storage_increase"); + int expertiseHopperIncrease = getSkillStatisticModifier(owner, "expertise_havester_storage_increase"); if (expertiseHopperIncrease > 0) { - max_hopper += (int)(max_hopper * (float)(expertiseHopperIncrease / 100.0f)); + max_hopper += (int)(max_hopper * expertiseHopperIncrease / 100.0f); } } if (max_hopper > HARVESTER_MAX_HOPPER_SIZE) @@ -746,8 +730,7 @@ public class player_structure extends script.base_script } public static float getBasePowerRate(obj_id structure) throws InterruptedException { - String template = getTemplateName(structure); - int idx = getStructureTableIndex(template); + int idx = getStructureTableIndex(getTemplateName(structure)); float power_rate = dataTableGetFloat(PLAYER_STRUCTURE_DATATABLE, idx, DATATABLE_COL_POWER_RATE); if (power_rate < 0f) { @@ -786,18 +769,18 @@ public class player_structure extends script.base_script { if (got == GOT_installation_factory) { - expertisePowerReduction = (int)getSkillStatisticModifier(owner, "expertise_factory_energy_decrease"); + expertisePowerReduction = getSkillStatisticModifier(owner, "expertise_factory_energy_decrease"); setObjVar(structure, VAR_POWER_MOD_FACTORY, expertisePowerReduction); } if (got == GOT_installation_harvester) { - expertisePowerReduction = (int)getSkillStatisticModifier(owner, "expertise_harvester_energy_decrease"); + expertisePowerReduction = getSkillStatisticModifier(owner, "expertise_harvester_energy_decrease"); setObjVar(structure, VAR_POWER_MOD_HARVESTER, expertisePowerReduction); } } if (expertisePowerReduction > 0) { - power_rate -= (int)(power_rate * (float)(expertisePowerReduction / 100.0f)); + power_rate -= (int)(power_rate * expertisePowerReduction / 100.0f); } return power_rate; } @@ -865,19 +848,21 @@ public class player_structure extends script.base_script modifyList(structure, getPlayerName(player), null, VAR_ADMIN_LIST, false); } } - if (player_loaded && struct_loaded) - { - } city.addStructureToCity(structure); return true; } public static boolean addStructure(obj_id structure, obj_id player) throws InterruptedException { - String template = getTemplateName(structure); - String structure_name = localize(getNameStringId(structure)); - location structure_location = getWorldLocation(structure); - String player_name = getPlayerName(player); - return addStructure(structure, template, structure_name, structure_location, player, player_name, true, true); + return addStructure( + structure, + getTemplateName(structure), + localize(getNameStringId(structure)), + getWorldLocation(structure), + player, + getPlayerName(player), + true, + true + ); } public static boolean removeStructure(obj_id structure, String template, obj_id player, String player_name, boolean struct_loaded, boolean player_loaded) throws InterruptedException { @@ -901,8 +886,7 @@ public class player_structure extends script.base_script { return false; } - int ignore_lots = dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, idx, DATATABLE_COL_NO_LOT_REQ); - if (ignore_lots != 1) + if (dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, idx, DATATABLE_COL_NO_LOT_REQ) != 1) { int struct_lots = (getNumberOfLots(fp_template) / 4) - dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, idx, DATATABLE_COL_LOT_REDUCTION); if (struct_lots < 1) @@ -936,9 +920,7 @@ public class player_structure extends script.base_script } public static boolean removeStructure(obj_id structure, obj_id player) throws InterruptedException { - String template = getTemplateName(structure); - String player_name = getPlayerName(player); - return removeStructure(structure, template, player, player_name, true, true); + return removeStructure(structure, getTemplateName(structure), player, getPlayerName(player), true, true); } public static boolean updateStructureVersion(obj_id structure) throws InterruptedException { @@ -951,8 +933,7 @@ public class player_structure extends script.base_script { return false; } - int idx = getStructureTableIndex(template); - if (idx == -1) + if (getStructureTableIndex(template) == -1) { return false; } @@ -961,9 +942,8 @@ public class player_structure extends script.base_script { yaw = yaw + 360.0f; } - int rotation = (int)(yaw + 1) / 90; updateStructureData(structure); - createStructureObjects(structure, rotation); + createStructureObjects(structure, (int)(yaw + 1) / 90); createStructureSign(structure); return true; } @@ -984,9 +964,8 @@ public class player_structure extends script.base_script return false; } dictionary row = dataTableGetRow(PLAYER_STRUCTURE_DATATABLE, idx); - int decay_rate = row.getInt(DATATABLE_COL_DECAY_RATE); int condition = row.getInt(DATATABLE_COL_CONDITION); - setObjVar(structure, VAR_DECAY_RATE, decay_rate); + setObjVar(structure, VAR_DECAY_RATE, row.getInt(DATATABLE_COL_DECAY_RATE)); float power_rate = 0.0f; if (!hasObjVar(structure, "selfpowered")) { @@ -996,10 +975,8 @@ public class player_structure extends script.base_script setPowerRate(structure, power_rate); if (condition > 0) { - int current_hp = getHitpoints(structure); - int max_hp = getMaxHitpoints(structure); setMaxHitpoints(structure, condition); - if (current_hp == max_hp) + if (getHitpoints(structure) == getMaxHitpoints(structure)) { setInvulnerableHitpoints(structure, condition); } @@ -1027,8 +1004,7 @@ public class player_structure extends script.base_script } if ((strPlanet.equals("yavin4")) || (strPlanet.equals("dathomir")) || (strPlanet.equals("endor"))) { - int intIndex = template.indexOf("installation"); - if (intIndex < 0) + if (!template.contains("installation")) { sendSystemMessage(player, new string_id(STF_FILE, "cannot_use_deed_here")); return false; @@ -1040,11 +1016,12 @@ public class player_structure extends script.base_script { String scene = getCurrentSceneName(); String deed_scene = getDeedScene(deed); + String curScene; boolean match = false; java.util.StringTokenizer st = new java.util.StringTokenizer(deed_scene, ","); while (st.hasMoreTokens()) { - String curScene = st.nextToken(); + curScene = st.nextToken(); if (scene.equals(curScene)) { match = true; @@ -1080,8 +1057,7 @@ public class player_structure extends script.base_script sendSystemMessage(player, new string_id(STF_FILE, "not_inside")); return false; } - region[] rgnTest = getRegionsWithBuildableAtPoint(loc, regions.BUILD_FALSE); - if (rgnTest != null) + if (getRegionsWithBuildableAtPoint(loc, regions.BUILD_FALSE) != null) { sendSystemMessage(player, new string_id(STF_FILE, "not_permitted")); return false; @@ -1093,16 +1069,15 @@ public class player_structure extends script.base_script return false; } } - if (template.indexOf("cityhall") != -1) + if (template.contains("cityhall")) { int cities_on_planet = 0; String planet_name = getCurrentSceneName(); int[] city_ids = getAllCityIds(); - for (int i = 0; i < city_ids.length; i++) - { - location city_loc = cityGetLocation(city_ids[i]); - if (city_loc.area.equals(planet_name)) - { + location city_loc; + for (int city_id : city_ids) { + city_loc = cityGetLocation(city_id); + if (city_loc.area.equals(planet_name)) { cities_on_planet++; } } @@ -1128,14 +1103,11 @@ public class player_structure extends script.base_script int blocking_city = city.canBuildCityHere(player, loc); if (blocking_city > -1) { - String block_name = cityGetName(blocking_city); - location block_loc = cityGetLocation(blocking_city); - sendSystemMessageProse(player, prose.getPackage(new string_id(STF_FILE, "city_too_close"), block_name)); + sendSystemMessageProse(player, prose.getPackage(new string_id(STF_FILE, "city_too_close"), cityGetName(blocking_city))); return false; } } int city_rank_req = dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, template_idx, DATATABLE_COL_CITY_RANK); - int civic = dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, template_idx, DATATABLE_COL_CIVIC); if (city_rank_req > 0) { int city_id = getCityAtLocation(loc, 0); @@ -1153,7 +1125,6 @@ public class player_structure extends script.base_script } } int city_id = getCityAtLocation(loc, 0); - obj_id mayor = cityGetLeader(city_id); if (cityExists(city_id) && city.isCityZoned(city_id) && isIdValid(player)) { if (!city.hasZoningRights(player, city_id)) @@ -1162,14 +1133,12 @@ public class player_structure extends script.base_script return false; } } - if (civic == 1) + if (dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, template_idx, DATATABLE_COL_CIVIC) == 1) { - int civic_count = city.getCivicCount(city_id); int max_civic = city.getMaxCivicCount(city_id); - if (civic_count >= max_civic) + if (city.getCivicCount(city_id) >= max_civic) { - prose_package pp = prose.getPackage(SID_CIVIC_COUNT, max_civic); - sendSystemMessageProse(player, pp); + sendSystemMessageProse(player, prose.getPackage(SID_CIVIC_COUNT, max_civic)); return false; } } @@ -1177,8 +1146,7 @@ public class player_structure extends script.base_script } public static boolean canPlaceStructure(obj_id player, String template) throws InterruptedException { - location loc = getLocation(player); - return canPlaceStructure(player, template, loc, null); + return canPlaceStructure(player, template, getLocation(player), null); } public static boolean canOwnStructure(String template, obj_id player, boolean allowOverLotLimitIfPlayerHouse) throws InterruptedException { @@ -1191,8 +1159,7 @@ public class player_structure extends script.base_script { return false; } - int ignore_lots = dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, idx, DATATABLE_COL_NO_LOT_REQ); - if (ignore_lots != 1) + if (dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, idx, DATATABLE_COL_NO_LOT_REQ) != 1) { int lots = getAccountNumLots(getPlayerObject(player)); int lots_needed = (getNumberOfLots(template) / 4) - dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, idx, DATATABLE_COL_LOT_REDUCTION); @@ -1207,11 +1174,7 @@ public class player_structure extends script.base_script } if ((lots + lots_needed) > MAX_LOTS) { - if (allowOverLotLimitIfPlayerHouse && (template.indexOf("object/building/player/player_house_") == 0)) - { - } - else - { + if (!allowOverLotLimitIfPlayerHouse || (template.indexOf("object/building/player/player_house_") != 0)) { sendSystemMessageProse(player, prose.getPackage(new string_id(STF_FILE, "not_enough_lots"), lots_needed)); return false; } @@ -1221,11 +1184,9 @@ public class player_structure extends script.base_script { if (hasObjVar(player, "factionBaseCount")) { - int factionBaseCount = getIntObjVar(player, "factionBaseCount"); - if (factionBaseCount > MAX_BASE_COUNT - 1) + if (getIntObjVar(player, "factionBaseCount") > MAX_BASE_COUNT - 1) { - string_id strSpam = new string_id("faction_perk", "not_enough_base_units"); - sendSystemMessage(player, strSpam); + sendSystemMessage(player, new string_id("faction_perk", "not_enough_base_units")); getClusterWideData("gcw_player_base", "base_cwdata_manager*", true, player); return false; } @@ -1234,9 +1195,7 @@ public class player_structure extends script.base_script String skill_mod = dataTableGetString(PLAYER_STRUCTURE_DATATABLE, idx, DATATABLE_COL_SKILL_MOD); if (skill_mod.length() > 0) { - int skill_mod_value = dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, idx, DATATABLE_COL_SKILL_MOD_VALUE); - int player_skill = getSkillStatMod(player, skill_mod); - if (player_skill < skill_mod_value) + if (getSkillStatMod(player, skill_mod) < dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, idx, DATATABLE_COL_SKILL_MOD_VALUE)) { String msg = dataTableGetString(PLAYER_STRUCTURE_DATATABLE, idx, DATATABLE_COL_SKILL_MOD_MESSAGE); if ((msg == null) || (msg.equals(""))) @@ -1245,8 +1204,7 @@ public class player_structure extends script.base_script } else { - string_id msgsid = new string_id(STF_FILE, msg); - sendSystemMessage(player, msgsid); + sendSystemMessage(player, new string_id(STF_FILE, msg)); } return false; } @@ -1259,8 +1217,7 @@ public class player_structure extends script.base_script { return false; } - String template = getTemplateName(structure); - return canOwnStructure(template, player, false); + return canOwnStructure(getTemplateName(structure), player, false); } public static String getFootprintTemplate(String template) throws InterruptedException { @@ -1307,15 +1264,12 @@ public class player_structure extends script.base_script { return true; } - location loc_structure = getLocation(structure); location loc_player = getLocation(player); - obj_id building = getTopMostContainer(loc_player.cell); - if (building == structure) + if (getTopMostContainer(loc_player.cell) == structure) { return true; } - float distance = loc_structure.distance(loc_player); - if (distance < getInstallationRange(structure)) + if (getLocation(structure).distance(loc_player) < getInstallationRange(structure)) { return true; } @@ -1411,46 +1365,40 @@ public class player_structure extends script.base_script } public static int getMaintenanceRate(obj_id structure) throws InterruptedException { - int civic = getIntObjVar(structure, VAR_CIVIC); - if (civic == 1) + if (getIntObjVar(structure, VAR_CIVIC) == 1) { return 0; } - else + int maint = getBaseMaintenanceRate(structure); + float merchant_mod = getMaintenanceMerchantMod(structure); + if (merchant_mod != 0f) { - int maint = getBaseMaintenanceRate(structure); - float merchant_mod = getMaintenanceMerchantMod(structure); - if (merchant_mod != 0f) - { - maint = Math.round(maint * (1f + merchant_mod)); - } - float factory_mod = getMaintenanceFactoryMod(structure); - if (factory_mod != 0f) - { - maint -= Math.round(maint * (factory_mod / 100.0f)); - } - float harvester_mod = getMaintenanceHarvesterMod(structure); - if (harvester_mod != 0f) - { - maint -= Math.round(maint * (harvester_mod / 100.0f)); - } - int tax = getMaintenancePropertyTax(structure); - if (tax > 0) - { - maint += tax; - } - return maint; + maint = Math.round(maint * (1f + merchant_mod)); } + float factory_mod = getMaintenanceFactoryMod(structure); + if (factory_mod != 0f) + { + maint -= Math.round(maint * (factory_mod / 100.0f)); + } + float harvester_mod = getMaintenanceHarvesterMod(structure); + if (harvester_mod != 0f) + { + maint -= Math.round(maint * (harvester_mod / 100.0f)); + } + int tax = getMaintenancePropertyTax(structure); + if (tax > 0) + { + maint += tax; + } + return maint; } public static int getBaseMaintenanceRate(obj_id structure) throws InterruptedException { - int idx = getStructureTableIndex(getTemplateName(structure)); - return dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, idx, DATATABLE_COL_MAINT_RATE); + return dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, getStructureTableIndex(getTemplateName(structure)), DATATABLE_COL_MAINT_RATE); } public static int getRedeedCost(obj_id structure) throws InterruptedException { - int idx = getStructureTableIndex(getTemplateName(structure)); - return dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, idx, DATATABLE_COL_REDEED_COST); + return dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, getStructureTableIndex(getTemplateName(structure)), DATATABLE_COL_REDEED_COST); } public static float getMaintenanceMerchantMod(obj_id structure) throws InterruptedException { @@ -1566,38 +1514,21 @@ public class player_structure extends script.base_script String[] fullEntryList = permissionsGetAllowed(structure); Vector filteredEntryList = new Vector(); filteredEntryList.setSize(0); - for (int i = 0; i < fullEntryList.length; i++) - { - String entryItemString = fullEntryList[i]; - obj_id entryItemId = utils.stringToObjId(entryItemString); - if (isIdValid(entryItemId)) - { - } - else - { - if ((entryItemString.toLowerCase()).indexOf("guild:") > -1) - { - int guild_id = findGuild(((entryItemString.substring(6)).toLowerCase()).trim()); - if (guild_id > 0) - { + + for (String entryItemString : fullEntryList) { + if (!isIdValid(utils.stringToObjId(entryItemString))) { + if ((entryItemString.toLowerCase()).contains("guild:")) { + if (findGuild(((entryItemString.substring(6)).toLowerCase()).trim()) > 0) { utils.addElement(filteredEntryList, entryItemString); } - else - { - } - } - else - { + } else { utils.addElement(filteredEntryList, entryItemString); } } } String[] returnList = new String[0]; - if (filteredEntryList != null) - { - returnList = new String[filteredEntryList.size()]; - filteredEntryList.toArray(returnList); - } + returnList = new String[filteredEntryList.size()]; + filteredEntryList.toArray(returnList); return returnList; } public static String[] getCompleteEntryList(obj_id structure) throws InterruptedException @@ -1710,8 +1641,7 @@ public class player_structure extends script.base_script { return null; } - String[] vendor_list = new String[0]; - return vendor_list; + return new String[0]; } public static String[] getHopperListRaw(obj_id structure) throws InterruptedException { @@ -1800,26 +1730,21 @@ public class player_structure extends script.base_script { return null; } - for (int i = 0; i < items.length; i++) - { - if (isInstallation(items[i])) - { - if (isAdmin(items[i], object)) - { - obj_id[] base_objects = getObjIdArrayObjVar(items[i], "player_structure.base_objects"); - if (base_objects != null && base_objects.length > 0) - { - for (int j = 0; j < base_objects.length; j++) - { - if (base_objects[j] == target) - { - return items[i]; + obj_id[] base_objects; + + for (obj_id item : items) { + if (isInstallation(item)) { + if (isAdmin(item, object)) { + base_objects = getObjIdArrayObjVar(item, "player_structure.base_objects"); + if (base_objects != null && base_objects.length > 0) { + for (obj_id base_object : base_objects) { + if (base_object == target) { + return item; } } } - if ((!isIdValid(structure)) || ((getLocation(items[i])).distance(loc) < (getLocation(structure)).distance(loc))) - { - structure = items[i]; + if ((!isIdValid(structure)) || ((getLocation(item)).distance(loc) < (getLocation(structure)).distance(loc))) { + structure = item; } } } @@ -1844,13 +1769,11 @@ public class player_structure extends script.base_script objects.setSize(0); if (cells != null) { - for (int i = 0; i < cells.length; i++) - { - if (isIdValid(cells[i])) - { - obj_id[] cell_contents = getContents(cells[i]); - if (cell_contents.length > 0) - { + obj_id[] cell_contents; + for (obj_id cell : cells) { + if (isIdValid(cell)) { + cell_contents = getContents(cell); + if (cell_contents.length > 0) { objects = utils.concatArrays(objects, cell_contents); } } @@ -1879,11 +1802,9 @@ public class player_structure extends script.base_script obj_id[] objects = getObjectsInBuilding(structure); if (objects != null && objects.length > 0) { - for (int i = 0; i < objects.length; i++) - { - if (isIdValid(objects[i]) && isPlayer(objects[i])) - { - players = utils.addElement(players, objects[i]); + for (obj_id object : objects) { + if (isIdValid(object) && isPlayer(object)) { + players = utils.addElement(players, object); } } } @@ -1901,50 +1822,42 @@ public class player_structure extends script.base_script { return null; } - location loc = getLocation(structure); Vector players = new Vector(); players.setSize(0); - obj_id[] items = getObjectsInRange(loc, getInstallationRange(structure)); - if (items == null) - { - obj_id[] _players = new obj_id[0]; - if (players != null) - { - _players = new obj_id[players.size()]; - players.toArray(_players); - } - return _players; - } - for (int i = 0; i < items.length; i++) - { - if (isPlayer(items[i])) - { - players = utils.addElement(players, items[i]); - } - } + obj_id[] items = getObjectsInRange(getLocation(structure), getInstallationRange(structure)); obj_id[] _players = new obj_id[0]; - if (players != null) + + if (items != null) { - _players = new obj_id[players.size()]; - players.toArray(_players); + for (obj_id item : items) { + if (isPlayer(item)) { + players = utils.addElement(players, item); + } + } + if (players != null) { + _players = new obj_id[players.size()]; + } + else{ + players = new Vector(); + players.setSize(0); + } } + + players.toArray(_players); return _players; } public static void confirmNoReclaimPlacement(obj_id deedOrScd, obj_id player, String template) throws InterruptedException { if (utils.hasScriptVar(deedOrScd, "noreclaim.pid")) { - int oldpid = utils.getIntScriptVar(deedOrScd, "noreclaim.pid"); obj_id oldplayer = utils.getObjIdScriptVar(deedOrScd, "noreclaim.player"); utils.removeScriptVarTree(deedOrScd, "noreclaim"); if (isIdValid(oldplayer)) { - sui.closeSUI(oldplayer, oldpid); + sui.closeSUI(oldplayer, utils.getIntScriptVar(deedOrScd, "noreclaim.pid")); } } - String title = utils.packStringId(SID_SUI_CONFIRM_PLACEMENT_TITLE); - String prompt = utils.packStringId(SID_SUI_CONFIRM_PLACEMENT_PROMPT); - int pid = sui.msgbox(deedOrScd, player, prompt, sui.YES_NO, title, "handleNoReclaimConfirm"); + int pid = sui.msgbox(deedOrScd, player, utils.packStringId(SID_SUI_CONFIRM_PLACEMENT_PROMPT), sui.YES_NO, utils.packStringId(SID_SUI_CONFIRM_PLACEMENT_TITLE), "handleNoReclaimConfirm"); if (pid > -1) { utils.setScriptVar(deedOrScd, "noreclaim.pid", pid); @@ -1963,9 +1876,7 @@ public class player_structure extends script.base_script return false; } } - location loc = getLocation(player); - float range = 200f; - if (!player_structure.canPlaceGarage(loc, range, template)) + if (!player_structure.canPlaceGarage(getLocation(player), 200f, template)) { sendSystemMessage(player, SID_CANNOT_BUILD_GARAGE_TOO_CLOSE); return false; @@ -1979,23 +1890,22 @@ public class player_structure extends script.base_script } public static boolean tryEnterPlacementMode(obj_id deedOrScd, obj_id player) throws InterruptedException { - obj_id target = deedOrScd; - if (!isIdValid(target)) + if (!isIdValid(deedOrScd)) { return false; } - if (!isGameObjectTypeOf(getGameObjectType(target), GOT_deed) && !isGameObjectTypeOf(getGameObjectType(target), GOT_data_house_control_device)) + if (!isGameObjectTypeOf(getGameObjectType(deedOrScd), GOT_deed) && !isGameObjectTypeOf(getGameObjectType(deedOrScd), GOT_data_house_control_device)) { sendSystemMessage(player, new string_id("player_structure", "not_a_deed")); return false; } - String template = player_structure.getDeedTemplate(target); + String template = player_structure.getDeedTemplate(deedOrScd); if (template == null) { return false; } location here = getLocation(player); - if (!player_structure.canPlaceStructure(player, template, here, target)) + if (!player_structure.canPlaceStructure(player, template, here, deedOrScd)) { return false; } @@ -2007,7 +1917,7 @@ public class player_structure extends script.base_script return false; } } - enterClientStructurePlacementMode(player, target, fp_template); + enterClientStructurePlacementMode(player, deedOrScd, fp_template); return true; } public static boolean canPackBuilding(obj_id player, obj_id structure) throws InterruptedException @@ -2031,7 +1941,6 @@ public class player_structure extends script.base_script stringId += "_abandoned"; } utils.setScriptVar(player, "packup.suiconfirm", sui.msgbox(player, player, utils.packStringId(new string_id("sui", stringId)), sui.YES_NO, "msgConfirmHousePackup")); - return; } public static void finalizePackUp(obj_id player, obj_id structure) throws InterruptedException { @@ -2083,34 +1992,28 @@ public class player_structure extends script.base_script if (players != null) { blog("player_structure.finalizePackUp Players are in the building that is about to be packed."); - for (int i = 0; i < players.length; i++) - { - expelFromBuilding(players[i]); + for (obj_id player1 : players) { + expelFromBuilding(player1); } } String[] cells = getCellNames(structure); if (cells != null) { - for (int i = 0; i < cells.length; i++) - { - obj_id cellid = getCellId(structure, cells[i]); - obj_id contents[] = getContents(cellid); - if (contents != null) - { - for (int j = 0; j < contents.length; j++) - { - if (hasCondition(contents[j], CONDITION_VENDOR)) - { - obj_id owner = getObjIdObjVar(contents[j], "vendor_owner"); - if (!isIdValid(owner)) - { - owner = getOwner(contents[j]); + obj_id owner; + obj_id contents[]; + for (String cell : cells) { + contents = getContents(getCellId(structure, cell)); + if (contents != null) { + for (obj_id content : contents) { + if (hasCondition(content, CONDITION_VENDOR)) { + owner = getObjIdObjVar(content, "vendor_owner"); + if (!isIdValid(owner)) { + owner = getOwner(content); } - vendor_lib.finalizePackUp(owner, contents[j], player, isAbandoned); + vendor_lib.finalizePackUp(owner, content, player, isAbandoned); } - if (isIdValid(contents[j])) - { - messageTo(contents[j], "OnPack", null, 1.0f, false); + if (isIdValid(content)) { + messageTo(content, "OnPack", null, 1.0f, false); } } } @@ -2144,8 +2047,7 @@ public class player_structure extends script.base_script } } city.removeStructureFromCity(structure); - String template = getTemplateName(structure); - setDeedTemplate(scd, template); + setDeedTemplate(scd, getTemplateName(structure)); if (hasObjVar(structure, VAR_DEED_SCENE)) { setObjVar(scd, VAR_DEED_SCENE, getDeedScene(structure)); @@ -2167,7 +2069,6 @@ public class player_structure extends script.base_script fixLoadWith(structure, structure_owner, maxDepth); } CustomerServiceLog("housepackup", "Player/Owner " + getPlayerName(player) + " (" + player + ") packed structure (" + structure + ",abandoned=" + isAbandoned + "," + where.toString() + " into device (" + scd + ")"); - return; } public static void finalizeAbandonedStructurePackUp(obj_id player, obj_id structure) throws InterruptedException { @@ -2178,7 +2079,7 @@ public class player_structure extends script.base_script return; } obj_id structure_owner = getOwner(structure); - CustomerServiceLog("housepackup", "Player " + getPlayerName(player) + " (" + player + ") is attempting to pack structure (" + structure + ",abandoned=" + isAbandoned + ") owned by player " + getPlayerName(structure_owner) + " (" + structure_owner + ")"); + CustomerServiceLog("housepackup", "Player " + getPlayerName(player) + " (" + player + ") is attempting to pack structure (" + structure + ",abandoned=true) owned by player " + getPlayerName(structure_owner) + " (" + structure_owner + ")"); if (!structure.isLoaded() || !structure.isAuthoritative()) { blog("player_structure.finalizeAbandonedStructurePackUp structure NOT LOADED or NOT AUTHORITATIVE."); @@ -2195,11 +2096,6 @@ public class player_structure extends script.base_script if (structure_owner.isLoaded() && structure_owner.isAuthoritative()) { blog("player_structure.finalizeAbandonedStructurePackUp The owner is loaded in game."); - obj_id owner_datapad = utils.getPlayerDatapad(structure_owner); - if (isIdValid(owner_datapad)) - { - datapad = owner_datapad; - } } else if (!player.isLoaded() || !player.isAuthoritative()) { @@ -2213,8 +2109,7 @@ public class player_structure extends script.base_script params.put("structure_owner", structure_owner); blog("player_structure.finalizePackUp STRUCTURE WAS ABANDONED. Sending message back to player to send animation, tally success."); messageTo(player, "callAirStrikePackAbandonedStructure", params, 0, false); - CustomerServiceLog("housepackup", "Player " + getPlayerName(player) + " (" + player + ") is ABOUT to pack abandoned structure (" + structure + ",abandoned=" + isAbandoned + "," + where.toString() + ") owned by player " + getPlayerName(structure_owner) + " (" + structure_owner + ")"); - return; + CustomerServiceLog("housepackup", "Player " + getPlayerName(player) + " (" + player + ") is ABOUT to pack abandoned structure (" + structure + ",abandoned=" + true + "," + where.toString() + ") owned by player " + getPlayerName(structure_owner) + " (" + structure_owner + ")"); } public static void confirmCityAbandonedAndPack(obj_id structure, obj_id player) throws InterruptedException { @@ -2262,9 +2157,7 @@ public class player_structure extends script.base_script sendSystemMessage(player, SID_GENERIC_CITY_PACKUP_ERROR); return; } - int loginTime = getPlayerLastLoginTime(owner); - int curTime = getCalendarTime(); - if ((curTime - loginTime) < cityGetInactivePackupInactiveTimeSeconds()) + if ((getCalendarTime() - getPlayerLastLoginTime(owner)) < cityGetInactivePackupInactiveTimeSeconds()) { if (hasObjVar(player, "qa.city_packup")) { @@ -2415,7 +2308,6 @@ public class player_structure extends script.base_script params.put("structure_owner", structure_owner); messageTo(structure, "cityMoveStructureToSCD", params, 1.0f, false); LOG("sissynoid", "Calling cityMoveStructureToSCD - Finally starting the packup procedure."); - return; } public static int getPlayerPackUpMeritPoints(obj_id player) throws InterruptedException { @@ -2569,8 +2461,7 @@ public class player_structure extends script.base_script { return null; } - obj_id resident = getObjIdObjVar(structure, VAR_RESIDENCE_BUILDING); - return resident; + return getObjIdObjVar(structure, VAR_RESIDENCE_BUILDING); } public static boolean replacePackedStructure(obj_id scd, obj_id owner, location loc, int rot, float placementHeight) throws InterruptedException { @@ -2610,8 +2501,7 @@ public class player_structure extends script.base_script removeObjVar(house, "player_structure.abandoned"); if (hasObjVar(house, "player_structure.name.original")) { - obj_var originalName = getObjVar(house, "player_structure.name.original"); - setName(house, originalName.getStringData()); + setName(house, getObjVar(house, "player_structure.name.original").getStringData()); } } if (player_structure.isCityAbandoned(house)) @@ -2619,8 +2509,7 @@ public class player_structure extends script.base_script removeObjVar(house, "player_structure.city_abandoned"); if (hasObjVar(house, "player_structure.name.original")) { - obj_var originalName = getObjVar(house, "player_structure.name.original"); - setName(house, originalName.getStringData()); + setName(house, getObjVar(house, "player_structure.name.original").getStringData()); } } float rot_float = (float)(90 * rot); @@ -2631,9 +2520,8 @@ public class player_structure extends script.base_script city.addStructureToCity(house); trace.log("housepackup", "%TU unpacked their house (" + house + ") from structure control device ( " + scd + ") to new location " + loc.toString(), owner, trace.TL_CS_LOG); obj_id[] houseContents = trial.getAllObjectsInDungeon(house); - for (int i = 0, j = houseContents.length; i < j; i++) - { - messageTo(houseContents[i], "OnUnpack", null, 1.0f, false); + for (obj_id houseContent : houseContents) { + messageTo(houseContent, "OnUnpack", null, 1.0f, false); } return true; } @@ -2642,16 +2530,13 @@ public class player_structure extends script.base_script String[] cells = getCellNames(structure); if (cells != null) { - for (int i = 0; i < cells.length; i++) - { - obj_id cellid = getCellId(structure, cells[i]); - obj_id contents[] = getContents(cellid); - if (contents != null) - { - for (int j = 0; j < contents.length; j++) - { - if (hasCondition(contents[j], CONDITION_VENDOR)) - { + obj_id contents[]; + + for (String cell : cells) { + contents = getContents(getCellId(structure, cell)); + if (contents != null) { + for (obj_id content : contents) { + if (hasCondition(content, CONDITION_VENDOR)) { return true; } } @@ -2662,29 +2547,14 @@ public class player_structure extends script.base_script } public static boolean isBuilding(obj_id object) throws InterruptedException { - int got = getGameObjectType(object); - if (isGameObjectTypeOf(got, GOT_building)) - { - return true; - } - return false; + return isGameObjectTypeOf(getGameObjectType(object), GOT_building); } public static boolean isBuildingName(String objectTemplateName) throws InterruptedException { - return objectTemplateName.indexOf("building") != -1; + return objectTemplateName.contains("building"); } - public static boolean isInstallation(obj_id object) throws InterruptedException - { - if (object == null || object == obj_id.NULL_ID) - { - return false; - } - int got = getGameObjectType(object); - if (isGameObjectTypeOf(got, GOT_installation)) - { - return true; - } - return false; + public static boolean isInstallation(obj_id object) throws InterruptedException { + return !(object == null || object == obj_id.NULL_ID) && isGameObjectTypeOf(getGameObjectType(object), GOT_installation); } public static boolean isGuildHall(obj_id object) throws InterruptedException { @@ -2700,53 +2570,21 @@ public class player_structure extends script.base_script { return true; } - else - { - String templateName = getTemplateName(object); - if (templateName.indexOf("guildhall") > 0 || templateName.indexOf("player_mustafar_house_lg") > 0 || templateName.indexOf("player_house_mustafar_lg") > 0) - { - return true; - } - else - { - return false; - } - } + String templateName = getTemplateName(object); + return templateName.indexOf("guildhall") > 0 || templateName.indexOf("player_mustafar_house_lg") > 0 || templateName.indexOf("player_house_mustafar_lg") > 0; } - public static boolean isCivic(obj_id object) throws InterruptedException - { - if (!isIdValid(object)) - { - return false; - } - if (exists(object) && getIntObjVar(object, VAR_CIVIC) == 1) - { - return true; - } - else - { - return false; - } + public static boolean isCivic(obj_id object) throws InterruptedException { + return isIdValid(object) && exists(object) && getIntObjVar(object, VAR_CIVIC) == 1; } - public static boolean isAbandoned(obj_id object) throws InterruptedException - { - if (!isIdValid(object)) - { - return false; - } - return (getIntObjVar(object, VAR_ABANDONED) == PLAYER_STRUCTURE_ABANDONED); + public static boolean isAbandoned(obj_id object) throws InterruptedException { + return isIdValid(object) && (getIntObjVar(object, VAR_ABANDONED) == PLAYER_STRUCTURE_ABANDONED); } public static void setAbandoned(obj_id object) throws InterruptedException { setObjVar(object, VAR_ABANDONED, PLAYER_STRUCTURE_ABANDONED); } - public static boolean isPreAbandoned(obj_id object) throws InterruptedException - { - if (!isIdValid(object)) - { - return false; - } - return (getIntObjVar(object, VAR_ABANDONED) == PLAYER_STRUCTURE_PRE_ABANDONED); + public static boolean isPreAbandoned(obj_id object) throws InterruptedException { + return isIdValid(object) && (getIntObjVar(object, VAR_ABANDONED) == PLAYER_STRUCTURE_PRE_ABANDONED); } public static void setPreAbandoned(obj_id object) throws InterruptedException { @@ -2756,17 +2594,8 @@ public class player_structure extends script.base_script { removeObjVar(object, VAR_ABANDONED); } - public static boolean isCityAbandoned(obj_id object) throws InterruptedException - { - if (!isIdValid(object)) - { - return false; - } - if (hasObjVar(object, VAR_CITY_ABANDONED)) - { - return true; - } - return false; + public static boolean isCityAbandoned(obj_id object) throws InterruptedException { + return isIdValid(object) && hasObjVar(object, VAR_CITY_ABANDONED); } public static void setCityAbandoned(obj_id object) throws InterruptedException { @@ -2788,17 +2617,8 @@ public class player_structure extends script.base_script removeObjVar(object, VAR_CITY_ABANDONED); } } - public static boolean isCityPackupAuthoritative(obj_id player, obj_id structure) throws InterruptedException - { - if (!player.isLoaded() || !player.isAuthoritative()) - { - return false; - } - if (!structure.isLoaded() || !structure.isAuthoritative()) - { - return false; - } - return true; + public static boolean isCityPackupAuthoritative(obj_id player, obj_id structure) throws InterruptedException { + return !(!player.isLoaded() || !player.isAuthoritative()) && !(!structure.isLoaded() || !structure.isAuthoritative()); } public static void removeCityAbandonedTagFromHouse(obj_id structure) throws InterruptedException { @@ -2816,22 +2636,19 @@ public class player_structure extends script.base_script } return; } - else + if (!hasObjVar(structure, "player_structure.sign.id")) { - if (!hasObjVar(structure, "player_structure.sign.id")) - { - LOG("sissynoid", "Structure(" + structure + ") does not have a House Sign ObjVar"); - return; - } - obj_id signId = getObjIdObjVar(structure, "player_structure.sign.id"); - String signText = getName(signId); - int indexOfAbandonedText = signText.indexOf(player_structure.CITY_ABANDONED_TEXT); - if (indexOfAbandonedText > -1) - { - signText = signText.substring(0, indexOfAbandonedText); - setName(signId, signText); - LOG("sissynoid", "Removed Zoning Violation - New Text: " + signText); - } + LOG("sissynoid", "Structure(" + structure + ") does not have a House Sign ObjVar"); + return; + } + obj_id signId = getObjIdObjVar(structure, "player_structure.sign.id"); + String signText = getName(signId); + int indexOfAbandonedText = signText.indexOf(player_structure.CITY_ABANDONED_TEXT); + if (indexOfAbandonedText > -1) + { + signText = signText.substring(0, indexOfAbandonedText); + setName(signId, signText); + LOG("sissynoid", "Removed Zoning Violation - New Text: " + signText); } } public static void updateCityAbandonedFactoryName(obj_id factory) throws InterruptedException @@ -2846,7 +2663,7 @@ public class player_structure extends script.base_script } else { - if (assignedName != null && assignedName.indexOf(player_structure.CITY_ABANDONED_TEXT) != -1) + if (assignedName != null && assignedName.contains(player_structure.CITY_ABANDONED_TEXT)) { assignedName = getStringObjVar(factory, "player_structure.name.original"); } @@ -2857,42 +2674,29 @@ public class player_structure extends script.base_script } if (assignedName == null || assignedName.length() == 0) { - String templateName = getTemplateName(factory); - if (templateName.equals("object/installation/manufacture/food_factory.iff")) - { - assignedName = "Food and Chemical Factory"; - } - else if (templateName.equals("object/installation/manufacture/clothing_factory.iff")) - { - assignedName = "Wearables Factory"; - } - else if (templateName.equals("object/installation/manufacture/weapon_factory.iff")) - { - assignedName = "Equipment Factory"; - } - else if (templateName.equals("object/installation/manufacture/structure_factory.iff")) - { - assignedName = "Structure Factory"; - } - else - { - assignedName = "Factory"; + switch (getTemplateName(factory)) { + case "object/installation/manufacture/food_factory.iff": + assignedName = "Food and Chemical Factory"; + break; + case "object/installation/manufacture/clothing_factory.iff": + assignedName = "Wearables Factory"; + break; + case "object/installation/manufacture/weapon_factory.iff": + assignedName = "Equipment Factory"; + break; + case "object/installation/manufacture/structure_factory.iff": + assignedName = "Structure Factory"; + break; + default: + assignedName = "Factory"; + break; } } setName(factory, assignedName + player_structure.CITY_ABANDONED_TEXT); } } - public static boolean isCommercial(obj_id object) throws InterruptedException - { - if (!isIdValid(object)) - { - return false; - } - if (!isCivic(object) && getStructureCityRank(object) > 0) - { - return true; - } - return false; + public static boolean isCommercial(obj_id object) throws InterruptedException { + return isIdValid(object) && !isCivic(object) && getStructureCityRank(object) > 0; } public static int getStructureCityRank(obj_id object) throws InterruptedException { @@ -2917,15 +2721,7 @@ public class player_structure extends script.base_script { if (structures[i].equals(template)) { - int civic = dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, i, "CIVIC"); - if (civic == 1) - { - return true; - } - else - { - return false; - } + return dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, i, "CIVIC") == 1; } } return false; @@ -2937,15 +2733,7 @@ public class player_structure extends script.base_script { if (structures[i].equals(template)) { - int shuttleport = dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, i, "SHUTTLEPORT"); - if (shuttleport == 1) - { - return true; - } - else - { - return false; - } + return dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, i, "SHUTTLEPORT") == 1; } } return false; @@ -2957,15 +2745,7 @@ public class player_structure extends script.base_script { if (structures[i].equals(template)) { - int clone = dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, i, "CLONE_FACILITY"); - if (clone == 1) - { - return true; - } - else - { - return false; - } + return dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, i, "CLONE_FACILITY") == 1; } } return false; @@ -2977,63 +2757,19 @@ public class player_structure extends script.base_script { if (structures[i].equals(template)) { - int garage = dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, i, "GARAGE"); - if (garage == 1) - { - return true; - } - else - { - return false; - } + return dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, i, "GARAGE") == 1; } } return false; } - public static boolean isFactory(obj_id object) throws InterruptedException - { - if (object == null || object == obj_id.NULL_ID) - { - return false; - } - if (getGameObjectType(object) == GOT_installation_factory) - { - return true; - } - else - { - return false; - } + public static boolean isFactory(obj_id object) throws InterruptedException { + return !(object == null || object == obj_id.NULL_ID) && getGameObjectType(object) == GOT_installation_factory; } - public static boolean isHarvester(obj_id object) throws InterruptedException - { - if (object == null || object == obj_id.NULL_ID) - { - return false; - } - if (getGameObjectType(object) == GOT_installation_harvester) - { - return true; - } - else - { - return false; - } + public static boolean isHarvester(obj_id object) throws InterruptedException { + return !(object == null || object == obj_id.NULL_ID) && getGameObjectType(object) == GOT_installation_harvester; } - public static boolean isGenerator(obj_id object) throws InterruptedException - { - if (object == null || object == obj_id.NULL_ID) - { - return false; - } - if (getGameObjectType(object) == GOT_installation_generator) - { - return true; - } - else - { - return false; - } + public static boolean isGenerator(obj_id object) throws InterruptedException { + return !(object == null || object == obj_id.NULL_ID) && getGameObjectType(object) == GOT_installation_generator; } public static boolean isAdmin(obj_id structure, String player_or_guild_name) throws InterruptedException { @@ -3048,9 +2784,6 @@ public class player_structure extends script.base_script { return true; } - else - { - } } return false; } @@ -3090,27 +2823,16 @@ public class player_structure extends script.base_script String[] vendor_list = getVendorList(structure); if (vendor_list != null) { - String playerNameUpperCase = player_name.toUpperCase(); - for (int i = 0; i < vendor_list.length; i++) - { - if (playerNameUpperCase.equals(vendor_list[i].toUpperCase())) - { + for (String vendor : vendor_list) { + if (player_name.toUpperCase().equals(vendor.toUpperCase())) { return true; } } } return false; } - public static boolean isVendor(obj_id structure, obj_id player) throws InterruptedException - { - if (isIdValid(player)) - { - return isVendor(structure, getPlayerName(player)); - } - else - { - return false; - } + public static boolean isVendor(obj_id structure, obj_id player) throws InterruptedException { + return isIdValid(player) && isVendor(structure, getPlayerName(player)); } public static boolean canEnter(obj_id structure, String player_or_guild_name) throws InterruptedException { @@ -3125,22 +2847,11 @@ public class player_structure extends script.base_script { return true; } - else - { - } } return false; } - public static boolean canEnter(obj_id structure, obj_id player) throws InterruptedException - { - if (isIdValid(player)) - { - return canEnter(structure, getPlayerName(player)); - } - else - { - return false; - } + public static boolean canEnter(obj_id structure, obj_id player) throws InterruptedException { + return isIdValid(player) && canEnter(structure, getPlayerName(player)); } public static boolean canHopper(obj_id structure, String player_or_guild_name) throws InterruptedException { @@ -3155,22 +2866,11 @@ public class player_structure extends script.base_script { return true; } - else - { - } } return false; } - public static boolean canHopper(obj_id structure, obj_id player) throws InterruptedException - { - if (isIdValid(player)) - { - return canHopper(structure, getPlayerName(player)); - } - else - { - return false; - } + public static boolean canHopper(obj_id structure, obj_id player) throws InterruptedException { + return isIdValid(player) && canHopper(structure, getPlayerName(player)); } public static boolean isBanned(obj_id structure, String player_or_guild_name) throws InterruptedException { @@ -3185,78 +2885,20 @@ public class player_structure extends script.base_script { return true; } - else - { - } } return false; } - public static boolean isBanned(obj_id structure, obj_id player) throws InterruptedException - { - if (isIdValid(player)) - { - return isBanned(structure, getPlayerName(player)); - } - else - { - return false; - } + public static boolean isBanned(obj_id structure, obj_id player) throws InterruptedException { + return isIdValid(player) && isBanned(structure, getPlayerName(player)); } - public static boolean isOwner(obj_id structure, String player_name) throws InterruptedException - { - if (structure == null || structure == obj_id.NULL_ID) - { - return false; - } - String owner_name = getStructureOwner(structure); - if ((owner_name.toUpperCase()).equals(player_name.toUpperCase())) - { - return true; - } - else - { - return false; - } + public static boolean isOwner(obj_id structure, String player_name) throws InterruptedException { + return !(structure == null || structure == obj_id.NULL_ID) && (getStructureOwner(structure).toUpperCase()).equals(player_name.toUpperCase()); } - public static boolean isOwner(obj_id structure, obj_id player) throws InterruptedException - { - if (player == null || player == obj_id.NULL_ID) - { - return false; - } - if (isGod(player)) - { - return true; - } - obj_id owner = getOwner(structure); - if (owner == player) - { - return true; - } - else - { - return false; - } + public static boolean isOwner(obj_id structure, obj_id player) throws InterruptedException { + return !(player == null || player == obj_id.NULL_ID) && (isGod(player) || getOwner(structure) == player); } - public static boolean isResidence(obj_id structure, obj_id player) throws InterruptedException - { - if (structure == null || structure == obj_id.NULL_ID) - { - return false; - } - if (player == null || player == obj_id.NULL_ID) - { - return false; - } - obj_id residence = getResidence(player); - if (residence == structure) - { - return true; - } - else - { - return false; - } + public static boolean isResidence(obj_id structure, obj_id player) throws InterruptedException { + return !(structure == null || structure == obj_id.NULL_ID) && !(player == null || player == obj_id.NULL_ID) && getResidence(player) == structure; } public static boolean applyManagementMods(obj_id structure, dictionary mods) throws InterruptedException { @@ -3276,10 +2918,6 @@ public class player_structure extends script.base_script mm = mm + mods.getInt("factory_mod"); } } - String template = getTemplateName(structure); - int idx = getStructureTableIndex(template); - int maint_rate = dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, idx, DATATABLE_COL_MAINT_RATE); - maint_rate = maint_rate * 100 / (100 + mm); if (mm > 0) { setObjVar(structure, VAR_MAINTENANCE_MOD, mm); @@ -3298,16 +2936,15 @@ public class player_structure extends script.base_script { mods.put("maintenance_mod", maintenance_mod); } - int factory_mod = getSkillStatMod(player, "factory_efficiency"); if (isFactory(structure)) { - maintenance_mod += (int)getSkillStatisticModifier(player, "expertise_factory_maintenance_decrease"); + maintenance_mod += getSkillStatisticModifier(player, "expertise_factory_maintenance_decrease"); } if (isHarvester(structure)) { - maintenance_mod += (int)getSkillStatisticModifier(player, "expertise_harvester_maintenance_decrease"); + maintenance_mod += getSkillStatisticModifier(player, "expertise_harvester_maintenance_decrease"); } - if (factory_mod > 0) + if (getSkillStatMod(player, "factory_efficiency") > 0) { mods.put("factory_mod", maintenance_mod); } @@ -3331,45 +2968,23 @@ public class player_structure extends script.base_script { return true; } - public static boolean isGuildIdOnRawList(String[] nameList, int guildId) throws InterruptedException - { - if ((nameList != null) && (guildId != 0)) - { - String guildIdAsString = "guild:" + guildId; - return (utils.getElementPositionInArray(nameList, guildIdAsString) != -1); - } - return false; + public static boolean isGuildIdOnRawList(String[] nameList, int guildId) throws InterruptedException { + return (nameList != null) && (guildId != 0) && (utils.getElementPositionInArray(nameList, "guild:" + guildId) != -1); } - public static boolean isGuildNameOnRawList(String[] nameList, String guildNameToFind) throws InterruptedException - { - if (guildNameToFind != null) - { - return isGuildIdOnRawList(nameList, findGuild((guildNameToFind.trim()).toLowerCase())); - } - return false; + public static boolean isGuildNameOnRawList(String[] nameList, String guildNameToFind) throws InterruptedException { + return guildNameToFind != null && isGuildIdOnRawList(nameList, findGuild((guildNameToFind.trim()).toLowerCase())); } - public static boolean isPlayerObjIdOnRawList(String[] nameList, obj_id playerObjId) throws InterruptedException - { - if ((nameList != null) && isIdValid(playerObjId)) - { - String playerObjIdAsString = playerObjId.toString(); - return (utils.getElementPositionInArray(nameList, playerObjIdAsString) != -1); - } - return false; + public static boolean isPlayerObjIdOnRawList(String[] nameList, obj_id playerObjId) throws InterruptedException { + return (nameList != null) && isIdValid(playerObjId) && (utils.getElementPositionInArray(nameList, playerObjId.toString()) != -1); } - public static boolean isPlayerNameOnRawList(String[] nameList, String playerNameToFind) throws InterruptedException - { - if (playerNameToFind != null) - { - return isPlayerObjIdOnRawList(nameList, getPlayerIdFromFirstName((playerNameToFind.trim()).toLowerCase())); - } - return false; + public static boolean isPlayerNameOnRawList(String[] nameList, String playerNameToFind) throws InterruptedException { + return playerNameToFind != null && isPlayerObjIdOnRawList(nameList, getPlayerIdFromFirstName((playerNameToFind.trim()).toLowerCase())); } public static boolean isNameOnRawList(String[] nameList, String nameToFind) throws InterruptedException { if (nameToFind != null) { - if ((nameToFind.toLowerCase()).indexOf("guild:") > -1) + if ((nameToFind.toLowerCase()).contains("guild:")) { return isGuildNameOnRawList(nameList, ((nameToFind.substring(6)).toLowerCase()).trim()); } @@ -3384,27 +2999,20 @@ public class player_structure extends script.base_script { if ((permissionList != null) && (nameToFind != null)) { - if ((nameToFind.toLowerCase()).indexOf("guild:") > -1) + if ((nameToFind.toLowerCase()).contains("guild:")) { String guildName = ((nameToFind.substring(6)).toLowerCase()).trim(); int guildId = findGuild(guildName); - for (int i = 0; i < permissionList.length; i++) - { - if ((permissionList[i].toLowerCase()).indexOf("guild:") > -1) - { - String permissionListGuildName = ((permissionList[i].substring(6)).toLowerCase()).trim(); - if (guildId == 0) - { - if (guildName.equals(permissionListGuildName)) - { + String permissionListGuildName; + for (String aPermissionList : permissionList) { + if ((aPermissionList.toLowerCase()).contains("guild:")) { + permissionListGuildName = ((aPermissionList.substring(6)).toLowerCase()).trim(); + if (guildId == 0) { + if (guildName.equals(permissionListGuildName)) { return true; } - } - else - { - int permissionListGuildId = findGuild(permissionListGuildName); - if (guildId == permissionListGuildId) - { + } else { + if (guildId == findGuild(permissionListGuildName)) { return true; } } @@ -3414,10 +3022,8 @@ public class player_structure extends script.base_script else { String playerName = (nameToFind.toLowerCase()).trim(); - for (int i = 0; i < permissionList.length; i++) - { - if (((permissionList[i].toLowerCase()).trim()).equals(playerName)) - { + for (String aPermissionList : permissionList) { + if (((aPermissionList.toLowerCase()).trim()).equals(playerName)) { return true; } } @@ -3443,13 +3049,8 @@ public class player_structure extends script.base_script } return false; } - public static boolean addGuildNameToRawList(Vector nameList, String guildNameToAdd) throws InterruptedException - { - if (guildNameToAdd != null) - { - return addGuildIdToRawList(nameList, findGuild((guildNameToAdd.trim()).toLowerCase())); - } - return false; + public static boolean addGuildNameToRawList(Vector nameList, String guildNameToAdd) throws InterruptedException { + return guildNameToAdd != null && addGuildIdToRawList(nameList, findGuild((guildNameToAdd.trim()).toLowerCase())); } public static boolean addPlayerObjIdToRawList(Vector nameList, obj_id playerObjId) throws InterruptedException { @@ -3468,19 +3069,14 @@ public class player_structure extends script.base_script } return false; } - public static boolean addPlayerNameToRawList(Vector nameList, String playerNameToAdd) throws InterruptedException - { - if (playerNameToAdd != null) - { - return addPlayerObjIdToRawList(nameList, getPlayerIdFromFirstName((playerNameToAdd.trim()).toLowerCase())); - } - return false; + public static boolean addPlayerNameToRawList(Vector nameList, String playerNameToAdd) throws InterruptedException { + return playerNameToAdd != null && addPlayerObjIdToRawList(nameList, getPlayerIdFromFirstName((playerNameToAdd.trim()).toLowerCase())); } public static boolean addNameToRawList(Vector nameList, String nameToAdd) throws InterruptedException { if (nameToAdd != null) { - if ((nameToAdd.toLowerCase()).indexOf("guild:") > -1) + if ((nameToAdd.toLowerCase()).contains("guild:")) { return addGuildNameToRawList(nameList, ((nameToAdd.substring(6)).toLowerCase()).trim()); } @@ -3495,8 +3091,7 @@ public class player_structure extends script.base_script { if ((nameList != null) && (guildId != 0)) { - String guildIdAsString = "guild:" + guildId; - int deleteIndex = utils.getElementPositionInArray(nameList, guildIdAsString); + int deleteIndex = utils.getElementPositionInArray(nameList, "guild:" + guildId); if (deleteIndex != -1) { nameList.remove(deleteIndex); @@ -3505,20 +3100,14 @@ public class player_structure extends script.base_script } return false; } - public static boolean removeGuildNameFromRawList(Vector nameList, String guildNameToRemove) throws InterruptedException - { - if (guildNameToRemove != null) - { - return removeGuildIdFromRawList(nameList, findGuild((guildNameToRemove.trim()).toLowerCase())); - } - return false; + public static boolean removeGuildNameFromRawList(Vector nameList, String guildNameToRemove) throws InterruptedException { + return guildNameToRemove != null && removeGuildIdFromRawList(nameList, findGuild((guildNameToRemove.trim()).toLowerCase())); } public static boolean removePlayerObjIdFromRawList(Vector nameList, obj_id playerObjId) throws InterruptedException { if ((nameList != null) && isIdValid(playerObjId)) { - String playerObjIdAsString = playerObjId.toString(); - int deleteIndex = utils.getElementPositionInArray(nameList, playerObjIdAsString); + int deleteIndex = utils.getElementPositionInArray(nameList, playerObjId.toString()); if (deleteIndex != -1) { nameList.remove(deleteIndex); @@ -3527,19 +3116,14 @@ public class player_structure extends script.base_script } return false; } - public static boolean removePlayerNameFromRawList(Vector nameList, String playerNameToRemove) throws InterruptedException - { - if (playerNameToRemove != null) - { - return removePlayerObjIdFromRawList(nameList, getPlayerIdFromFirstName((playerNameToRemove.trim()).toLowerCase())); - } - return false; + public static boolean removePlayerNameFromRawList(Vector nameList, String playerNameToRemove) throws InterruptedException { + return playerNameToRemove != null && removePlayerObjIdFromRawList(nameList, getPlayerIdFromFirstName((playerNameToRemove.trim()).toLowerCase())); } public static boolean removeNameFromRawList(Vector nameList, String nameToRemove) throws InterruptedException { if (nameToRemove != null) { - if ((nameToRemove.toLowerCase()).indexOf("guild:") > -1) + if ((nameToRemove.toLowerCase()).contains("guild:")) { return removeGuildNameFromRawList(nameList, ((nameToRemove.substring(6)).toLowerCase()).trim()); } @@ -3556,46 +3140,36 @@ public class player_structure extends script.base_script converted_list.setSize(0); if (nameListToConvert != null) { - for (int i = 0; i < nameListToConvert.length; i++) - { - if ((nameListToConvert[i].toLowerCase()).indexOf("guild:") > -1) - { - String guildIdString = ((nameListToConvert[i].substring(6)).toLowerCase()).trim(); - int guildId = utils.stringToInt(guildIdString); - if (guildId > 0) - { + int guildId; + obj_id player; + String player_full_name; + StringTokenizer st; + + for (String aNameListToConvert : nameListToConvert) { + if ((aNameListToConvert.toLowerCase()).contains("guild:")) { + guildId = utils.stringToInt(((aNameListToConvert.substring(6)).toLowerCase()).trim()); + if (guildId > 0) { String guildAbbrev = guildGetAbbrev(guildId); - if ((guildAbbrev != null) && (!guildAbbrev.equals(""))) - { + if ((guildAbbrev != null) && (!guildAbbrev.equals(""))) { converted_list.add("Guild:" + guildAbbrev); } } - } - else - { - obj_id player = utils.stringToObjId(nameListToConvert[i]); - if (isIdValid(player)) - { - String player_full_name = getPlayerFullName(player); - if (player_full_name != null) - { - java.util.StringTokenizer st = new java.util.StringTokenizer(player_full_name); - if (st.hasMoreTokens()) - { - String player_first_name = st.nextToken(); - converted_list.add(player_first_name); + } else { + player = utils.stringToObjId(aNameListToConvert); + if (isIdValid(player)) { + player_full_name = getPlayerFullName(player); + if (player_full_name != null) { + st = new StringTokenizer(player_full_name); + if (st.hasMoreTokens()) { + converted_list.add(st.nextToken()); } } } } } } - String[] _converted_list = new String[0]; - if (converted_list != null) - { - _converted_list = new String[converted_list.size()]; - converted_list.toArray(_converted_list); - } + String[] _converted_list = new String[converted_list.size()]; + converted_list.toArray(_converted_list); return _converted_list; } public static boolean modifyList(obj_id structure, String player_or_guild_name, obj_id admin, String objvar, boolean verbose) throws InterruptedException @@ -3624,46 +3198,39 @@ public class player_structure extends script.base_script return false; } boolean is_name_on_list = false; - if (objvar.equals(VAR_ENTER_LIST)) - { - is_name_on_list = isNameOnEntryList(structure, player_or_guild_name); - } - else if (objvar.equals(VAR_BAN_LIST)) - { - is_name_on_list = isNameOnBanList(structure, player_or_guild_name); - } - else if (objvar.equals(VAR_ADMIN_LIST)) - { - is_name_on_list = isNameOnAdminList(structure, player_or_guild_name); - } - else if (objvar.equals(VAR_HOPPER_LIST)) - { - is_name_on_list = isNameOnHopperList(structure, player_or_guild_name); - } - else - { - return false; + switch (objvar) { + case VAR_ENTER_LIST: + is_name_on_list = isNameOnEntryList(structure, player_or_guild_name); + break; + case VAR_BAN_LIST: + is_name_on_list = isNameOnBanList(structure, player_or_guild_name); + break; + case VAR_ADMIN_LIST: + is_name_on_list = isNameOnAdminList(structure, player_or_guild_name); + break; + case VAR_HOPPER_LIST: + is_name_on_list = isNameOnHopperList(structure, player_or_guild_name); + break; + default: + return false; } if (!is_name_on_list) { - { String[] listOfNames = new String[0]; - if (objvar.equals(VAR_ENTER_LIST)) - { - listOfNames = getEntryList(structure); - } - else if (objvar.equals(VAR_BAN_LIST)) - { - listOfNames = getBanList(structure); - } - else if (objvar.equals(VAR_ADMIN_LIST)) - { - listOfNames = getAdminListRaw(structure); - } - else if (objvar.equals(VAR_HOPPER_LIST)) - { - listOfNames = getHopperListRaw(structure); + switch (objvar) { + case VAR_ENTER_LIST: + listOfNames = getEntryList(structure); + break; + case VAR_BAN_LIST: + listOfNames = getBanList(structure); + break; + case VAR_ADMIN_LIST: + listOfNames = getAdminListRaw(structure); + break; + case VAR_HOPPER_LIST: + listOfNames = getHopperListRaw(structure); + break; } if (listOfNames != null) { @@ -3677,7 +3244,7 @@ public class player_structure extends script.base_script } } } - if ((player_or_guild_name.toLowerCase()).indexOf("guild:") > -1) + if ((player_or_guild_name.toLowerCase()).contains("guild:")) { if (objvar.equals(VAR_ADMIN_LIST) || objvar.equals(VAR_HOPPER_LIST)) { @@ -3687,8 +3254,7 @@ public class player_structure extends script.base_script } return false; } - int guild_id = findGuild(((player_or_guild_name.substring(6)).toLowerCase()).trim()); - if (guild_id == 0) + if (findGuild(((player_or_guild_name.substring(6)).toLowerCase()).trim()) == 0) { if (verbose && isIdValid(admin)) { @@ -3712,21 +3278,19 @@ public class player_structure extends script.base_script } } } - if (objvar.equals(VAR_ENTER_LIST)) - { - permissionsAddAllowed(structure, player_or_guild_name); - } - else if (objvar.equals(VAR_BAN_LIST)) - { - permissionsAddBanned(structure, player_or_guild_name); - } - else if (objvar.equals(VAR_ADMIN_LIST)) - { - adminListAddName(structure, player_or_guild_name); - } - else if (objvar.equals(VAR_HOPPER_LIST)) - { - hopperListAddName(structure, player_or_guild_name); + switch (objvar) { + case VAR_ENTER_LIST: + permissionsAddAllowed(structure, player_or_guild_name); + break; + case VAR_BAN_LIST: + permissionsAddBanned(structure, player_or_guild_name); + break; + case VAR_ADMIN_LIST: + adminListAddName(structure, player_or_guild_name); + break; + case VAR_HOPPER_LIST: + hopperListAddName(structure, player_or_guild_name); + break; } if (verbose && isIdValid(admin)) { @@ -3769,21 +3333,19 @@ public class player_structure extends script.base_script } else { - if (objvar.equals(VAR_ENTER_LIST)) - { - permissionsRemoveAllowed(structure, player_or_guild_name); - } - else if (objvar.equals(VAR_BAN_LIST)) - { - permissionsRemoveBanned(structure, player_or_guild_name); - } - else if (objvar.equals(VAR_ADMIN_LIST)) - { - adminListRemoveName(structure, player_or_guild_name); - } - else if (objvar.equals(VAR_HOPPER_LIST)) - { - hopperListRemoveName(structure, player_or_guild_name); + switch (objvar) { + case VAR_ENTER_LIST: + permissionsRemoveAllowed(structure, player_or_guild_name); + break; + case VAR_BAN_LIST: + permissionsRemoveBanned(structure, player_or_guild_name); + break; + case VAR_ADMIN_LIST: + adminListRemoveName(structure, player_or_guild_name); + break; + case VAR_HOPPER_LIST: + hopperListRemoveName(structure, player_or_guild_name); + break; } if (verbose && isIdValid(admin)) { @@ -3792,16 +3354,8 @@ public class player_structure extends script.base_script } return true; } - public static boolean modifyEntryList(obj_id structure, obj_id player, obj_id admin) throws InterruptedException - { - if (isIdValid(player)) - { - return modifyEntryList(structure, getPlayerName(player), admin); - } - else - { - return false; - } + public static boolean modifyEntryList(obj_id structure, obj_id player, obj_id admin) throws InterruptedException { + return isIdValid(player) && modifyEntryList(structure, getPlayerName(player), admin); } public static boolean modifyEntryList(obj_id structure, String player_or_guild_name, obj_id admin) throws InterruptedException { @@ -3899,8 +3453,7 @@ public class player_structure extends script.base_script } public static boolean modifyVendorList(obj_id structure, obj_id player, obj_id admin) throws InterruptedException { - String player_name = getPlayerName(player); - return modifyVendorList(structure, player_name, admin); + return modifyVendorList(structure, getPlayerName(player), admin); } public static boolean modifyHopperList(obj_id structure, obj_id player, obj_id admin) throws InterruptedException { @@ -4033,11 +3586,10 @@ public class player_structure extends script.base_script } int property_tax = city.getPropertyTax(structure); int pretax_amt = 0, tax_amt = 0; - int base_amt = amt; if (property_tax > 0) { pretax_amt = Math.round(amt / (1 + (property_tax / 100.f))); - tax_amt = base_amt - pretax_amt; + tax_amt = amt - pretax_amt; if (money.bankTo(structure, money.ACCT_STRUCTURE_MAINTENANCE, pretax_amt)) { pool -= pretax_amt; @@ -4113,9 +3665,8 @@ public class player_structure extends script.base_script LOG("building", "Returning 12"); return -1; } - int condition = getStructureCondition(structure); + int condition = getStructureCondition(structure) + amt; int max_condition = getMaxCondition(structure); - condition = condition + amt; LOG("building", "new condition is " + condition); if (condition > max_condition) { @@ -4186,24 +3737,16 @@ public class player_structure extends script.base_script } if (last_message <= getGameTime() && !isStructureCondemned(structure)) { - int condition = player_structure.getStructureCondition(structure); - int max_condition = player_structure.getMaxCondition(structure); - int perc_condition = (condition * 100) / max_condition; + int perc_condition = (player_structure.getStructureCondition(structure) * 100) / player_structure.getMaxCondition(structure); if (perc_condition <= 90) { obj_id owner = getStructureOwnerObjId(structure); if (isIdValid(owner)) { location loc = getLocation(structure); - String area = loc.area; - if (area != null) - { - area = (area.substring(0, 1)).toUpperCase() + area.substring(1); - } String loc_str = "(" + loc.x + ", " + loc.z + " " + loc.area + ")"; string_id strSpam = player_structure.SID_MAIL_STRUCTURE_DAMAGE; - prose_package pp = prose.getPackage(strSpam, null, structure, loc_str, perc_condition); - utils.sendMail(player_structure.SID_MAIL_STRUCTURE_DAMAGE_SUB, pp, getPlayerName(owner), "@player_structure:management"); + utils.sendMail(player_structure.SID_MAIL_STRUCTURE_DAMAGE_SUB, prose.getPackage(strSpam, null, structure, loc_str, perc_condition), getPlayerName(owner), "@player_structure:management"); utils.setObjVar(structure, VAR_LAST_MESSAGE, getGameTime() + MAIL_WARNING_INTERVAL); return true; } @@ -4281,25 +3824,23 @@ public class player_structure extends script.base_script String deed_scene = getDeedScene(structure); if (deed_scene != null) { - if (deed_scene.equals("tatooine")) - { - deed_scene = "tatooine,lok,dantooine"; - } - else if (deed_scene.equals("naboo")) - { - deed_scene = "naboo,rori,dantooine"; - } - else if (deed_scene.equals("corellia")) - { - deed_scene = "corellia,talus"; + switch (deed_scene) { + case "tatooine": + deed_scene = "tatooine,lok,dantooine"; + break; + case "naboo": + deed_scene = "naboo,rori,dantooine"; + break; + case "corellia": + deed_scene = "corellia,talus"; + break; } } setObjVar(deed, VAR_DEED_SCENE, deed_scene); } if (hasObjVar(structure, "structureChange.storageIncrease")) { - int storageIncrease = getIntObjVar(structure, "structureChange.storageIncrease"); - setObjVar(deed, "structureChange.storageIncrease", storageIncrease); + setObjVar(deed, "structureChange.storageIncrease", getIntObjVar(structure, "structureChange.storageIncrease")); setObjVar(deed, "noTrade", 1); attachScript(deed, "item.special.nomove"); } @@ -4318,10 +3859,9 @@ public class player_structure extends script.base_script { setObjVar(deed, VAR_DEED_MAX_HOPPER, maxHopperAmount); } - int maintPool = getBankBalance(structure); int reclaimCost = getRedeedCost(structure); transferBankCreditsToNamedAccount(structure, money.ACCT_DEED_RECLAIM, reclaimCost, "noHandler", "noHandler", new dictionary()); - int surplus = maintPool - reclaimCost; + int surplus = getBankBalance(structure) - reclaimCost; if (surplus > 0) { setObjVar(deed, VAR_DEED_SURPLUS_MAINTENANCE, surplus); @@ -4368,9 +3908,8 @@ public class player_structure extends script.base_script obj_id[] players = getPlayersInBuilding(structure); if (players != null) { - for (int i = 0; i < players.length; i++) - { - expelFromBuilding(players[i]); + for (obj_id player : players) { + expelFromBuilding(player); } } } @@ -4390,22 +3929,18 @@ public class player_structure extends script.base_script String[] cells = getCellNames(structure); if (cells != null) { - for (int i = 0; i < cells.length; i++) - { - obj_id cellid = getCellId(structure, cells[i]); - obj_id contents[] = getContents(cellid); - if (contents != null) - { - for (int j = 0; j < contents.length; j++) - { - if (hasCondition(contents[j], CONDITION_VENDOR)) - { - obj_id vendorOwner = getObjIdObjVar(contents[j], "vendor_owner"); - if (!isIdValid(vendorOwner)) - { - vendorOwner = getOwner(contents[j]); + obj_id[] contents; + obj_id vendorOwner; + for (String cell : cells) { + contents = getContents(getCellId(structure, cell)); + if (contents != null) { + for (obj_id content : contents) { + if (hasCondition(content, CONDITION_VENDOR)) { + vendorOwner = getObjIdObjVar(content, "vendor_owner"); + if (!isIdValid(vendorOwner)) { + vendorOwner = getOwner(content); } - vendor_lib.finalizePackUp(vendorOwner, contents[j], self, false); + vendor_lib.finalizePackUp(vendorOwner, content, self, false); } } } @@ -4432,31 +3967,30 @@ public class player_structure extends script.base_script sendSystemMessage(self, new string_id(STF_FILE, "destroy_must_be_owner")); return false; } - obj_id inv = utils.getInventoryContainer(self); - int resultCode = destroyStructure(structure, inv, reclaim, false); + int resultCode = destroyStructure(structure, utils.getInventoryContainer(self), reclaim, false); switch (resultCode) { case DESTROY_RESULT_FAIL_COULD_NOT_CREATE_DEED: - sendSystemMessage(self, new string_id(STF_FILE, "repack_design_error")); - return false; + sendSystemMessage(self, new string_id(STF_FILE, "repack_design_error")); + return false; case DESTROY_RESULT_FAIL_COULD_NOT_DETERMINE_DEED_FOR_STRUCTURE: - sendSystemMessage(self, new string_id(STF_FILE, "contact_cs")); - return false; + sendSystemMessage(self, new string_id(STF_FILE, "contact_cs")); + return false; case DESTROY_RESULT_FAIL_TARGET_CONTAINER_FULL: - sendSystemMessage(self, new string_id(STF_FILE, "inventory_full")); - return false; + sendSystemMessage(self, new string_id(STF_FILE, "inventory_full")); + return false; case DESTROY_RESULT_FAIL_TARGET_CONTAINER_FULL_SELFPOWERED: - sendSystemMessage(self, new string_id(STF_FILE, "inventory_full_selfpowered")); - return false; + sendSystemMessage(self, new string_id(STF_FILE, "inventory_full_selfpowered")); + return false; case DESTROY_RESULT_SUCCESS_SELFPOWERED: - sendSystemMessage(self, new string_id(STF_FILE, "selfpowered")); - break; + sendSystemMessage(self, new string_id(STF_FILE, "selfpowered")); + break; case DESTROY_RESULT_INVALID_STATIC_ITEM: - sendSystemMessage(self, new string_id(STF_FILE, "invalid_static_item")); - return false; + sendSystemMessage(self, new string_id(STF_FILE, "invalid_static_item")); + return false; case DESTROY_RESULT_INVALID_CONTAINER: - sendSystemMessage(self, new string_id(STF_FILE, "inventory_invalid")); - return false; + sendSystemMessage(self, new string_id(STF_FILE, "inventory_invalid")); + return false; } return true; } @@ -4475,11 +4009,9 @@ public class player_structure extends script.base_script { return false; } - 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); } } return true; @@ -4494,17 +4026,13 @@ public class player_structure extends script.base_script obj_id[] base_objects = getStructureBaseObjects(structure); if (base_objects != null) { - for (int i = 0; i < base_objects.length; i++) - { - if (!isIdValid(base_objects[i]) || !base_objects[i].isLoaded()) - { + obj_id container; + for (obj_id base_object : base_objects) { + if (!isIdValid(base_object) || !base_object.isLoaded()) { create_objects = true; - } - else - { - obj_id container = getTopMostContainer(base_objects[i]); - if (container == null || structure != container) - { + } else { + container = getTopMostContainer(base_object); + if (container == null || structure != container) { create_objects = true; } } @@ -4518,8 +4046,7 @@ public class player_structure extends script.base_script { yaw = yaw + 360.0f; } - int rotation = (int)(yaw + 1) / 90; - createStructureObjects(structure, rotation); + createStructureObjects(structure, (int)(yaw + 1) / 90); } return true; } @@ -4531,11 +4058,9 @@ public class player_structure extends script.base_script } if (time == Integer.MAX_VALUE) { - int[] ret = - { + return new int[]{ Integer.MAX_VALUE }; - return ret; } int mod_day = time % 86400; int mod_hour = mod_day % 3600; @@ -4543,14 +4068,12 @@ public class player_structure extends script.base_script int hours = mod_day / 3600; int minutes = mod_hour / 60; int seconds = mod_hour % 60; - int[] converted_time = - { + return new int[]{ days, hours, minutes, seconds }; - return converted_time; } public static String assembleTimeRemaining(int[] time_values) throws InterruptedException { @@ -4570,10 +4093,8 @@ public class player_structure extends script.base_script "second" }; int num_times = 0; - for (int i = 0; i < time_values.length; i++) - { - if (time_values[i] != 0) - { + for (int time_value : time_values) { + if (time_value != 0) { num_times++; } } @@ -4583,7 +4104,7 @@ public class player_structure extends script.base_script { if (time_values[i] > 0) { - sb.append(time_values[i] + " " + time_strings[i]); + sb.append(time_values[i]).append(" ").append(time_strings[i]); if (time_values[i] > 1) { sb.append("s"); @@ -4693,9 +4214,6 @@ public class player_structure extends script.base_script } setObjVar(structure, VAR_PERMISSIONS_CONVERTED, 1); } - else - { - } return true; } public static String[] convertObjIdPermissionList(obj_id[] objId_list) throws InterruptedException @@ -4707,21 +4225,16 @@ public class player_structure extends script.base_script } Vector new_name_list = new Vector(); new_name_list.setSize(0); - for (int i = 0; i < objId_list.length; i++) - { - if (!addPlayerObjIdToRawList(new_name_list, objId_list[i])) - { - LOG("player_structure", "player_structure.convertObjIdPermissionList -- invalid object ID " + objId_list[i].toString()); + for (obj_id objId : objId_list) { + if (!addPlayerObjIdToRawList(new_name_list, objId)) { + LOG("player_structure", "player_structure.convertObjIdPermissionList -- invalid object ID " + objId.toString()); } } if (new_name_list.size() > 0) { String[] _new_name_list = new String[0]; - if (new_name_list != null) - { - _new_name_list = new String[new_name_list.size()]; - new_name_list.toArray(_new_name_list); - } + _new_name_list = new String[new_name_list.size()]; + new_name_list.toArray(_new_name_list); return _new_name_list; } else @@ -4738,21 +4251,15 @@ public class player_structure extends script.base_script } Vector new_name_list = new Vector(); new_name_list.setSize(0); - for (int i = 0; i < name_list.length; i++) - { - if (!addNameToRawList(new_name_list, name_list[i])) - { - LOG("player_structure", "player_structure.convertStringPermissionList -- couldn't convert the name " + name_list[i]); + for (String name : name_list) { + if (!addNameToRawList(new_name_list, name)) { + LOG("player_structure", "player_structure.convertStringPermissionList -- couldn't convert the name " + name); } } if (new_name_list.size() > 0) { - String[] _new_name_list = new String[0]; - if (new_name_list != null) - { - _new_name_list = new String[new_name_list.size()]; - new_name_list.toArray(_new_name_list); - } + String[] _new_name_list = new String[new_name_list.size()]; + new_name_list.toArray(_new_name_list); return _new_name_list; } else @@ -4767,26 +4274,24 @@ public class player_structure 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; + X = -z; + Z = x; break; } - float[] delta_world = - { + return new float[]{ X, Z }; - return delta_world; } public static location transformDeltaWorldCoord(location here, float dx, float dz, float yaw) throws InterruptedException { @@ -4797,7 +4302,7 @@ public class player_structure extends script.base_script } int rotation = java.lang.Math.round(yaw / 90f); float[] xz = transformDeltaWorldCoord(dx, dz, rotation); - if (xz != null & xz.length == 2) + if (xz != null && xz.length == 2) { location there = (location)here.clone(); there.x += xz[0]; @@ -4806,23 +4311,12 @@ public class player_structure extends script.base_script } return null; } - public static boolean hasSign(obj_id structure) throws InterruptedException - { - if (!isIdValid(structure)) - { - return false; - } - return hasObjVar(structure, VAR_SIGN_ID); + public static boolean hasSign(obj_id structure) throws InterruptedException { + return isIdValid(structure) && hasObjVar(structure, VAR_SIGN_ID); } - public static boolean isPackedUp(obj_id structure) throws InterruptedException - { + public static boolean isPackedUp(obj_id structure) throws InterruptedException { obj_id container = getContainedBy(structure); - if (!isIdValid(container)) - { - return false; - } - String template = getTemplateName(container); - return template.equals("object/intangible/house/generic_house_control_device.iff"); + return isIdValid(container) && getTemplateName(container).equals("object/intangible/house/generic_house_control_device.iff"); } public static obj_id createStructureSign(obj_id structure, float sYaw) throws InterruptedException { @@ -4840,17 +4334,14 @@ public class player_structure extends script.base_script { destroyStructureSign(structure); location here = getLocation(structure); - for (int x = 0; x < SIGN_TYPE.length; x++) - { - obj_id[] nc = getAllObjectsWithTemplate(here, 64f, SIGN_TYPE[x]); - if (nc != null && nc.length > 0) - { - for (int i = 0; i < nc.length; i++) - { - if (isObjectPersisted(nc[i]) && !utils.hasScriptVar(nc[i], "player_structure.parent")) - { - CustomerServiceLog("sign_destruction", "destroying sign " + nc[i] + " whose name is '" + getName(nc[i]) + "'"); - destroyObject(nc[i]); + obj_id[] nc; + for (String aSIGN_TYPE : SIGN_TYPE) { + nc = getAllObjectsWithTemplate(here, 64f, aSIGN_TYPE); + if (nc != null && nc.length > 0) { + for (obj_id aNc : nc) { + if (isObjectPersisted(aNc) && !utils.hasScriptVar(aNc, "player_structure.parent")) { + CustomerServiceLog("sign_destruction", "destroying sign " + aNc + " whose name is '" + getName(aNc) + "'"); + destroyObject(aNc); } } } @@ -4877,39 +4368,39 @@ public class player_structure extends script.base_script String admin_name = admins[0]; if (admin_name != null) { - if (structureTemplate.indexOf("guild") > -1) + if (structureTemplate.contains("guild")) { signName = admin_name + "'s Guildhall"; } - else if (structureTemplate.indexOf("barn") > -1) + else if (structureTemplate.contains("barn")) { signName = admin_name + "'s Barn"; } - else if (structureTemplate.indexOf("diner") > -1) + else if (structureTemplate.contains("diner")) { signName = admin_name + "'s Diner"; } - else if (structureTemplate.indexOf("cantina") > -1) + else if (structureTemplate.contains("cantina")) { signName = admin_name + "'s Cantina"; } - else if (structureTemplate.indexOf("hospital") > -1) + else if (structureTemplate.contains("hospital")) { signName = admin_name + "'s Medical Center"; } - else if (structureTemplate.indexOf("pgc_merchant_tent") > -1) + else if (structureTemplate.contains("pgc_merchant_tent")) { signName = admin_name + "'s Chronicles Tent"; } - else if (structureTemplate.indexOf("merchant_tent") > -1) + else if (structureTemplate.contains("merchant_tent")) { signName = admin_name + "'s Merchant Tent"; } - else if (structureTemplate.indexOf("theater") > -1) + else if (structureTemplate.contains("theater")) { signName = admin_name + "'s Theater"; } - else if (structureTemplate.indexOf("garage") > -1) + else if (structureTemplate.contains("garage")) { signName = admin_name + "'s Garage"; } @@ -4920,43 +4411,43 @@ public class player_structure extends script.base_script } else { - if (structureTemplate.indexOf("guild") > -1) + if (structureTemplate.contains("guild")) { signName = "Guildhall"; } - else if (structureTemplate.indexOf("barn") > -1) + else if (structureTemplate.contains("barn")) { - signName = admin_name + "Barn"; + signName = "Barn"; } - else if (structureTemplate.indexOf("diner") > -1) + else if (structureTemplate.contains("diner")) { - signName = admin_name + "Diner"; + signName = "Diner"; } - else if (structureTemplate.indexOf("cantina") > -1) + else if (structureTemplate.contains("cantina")) { - signName = admin_name + "Cantina"; + signName = "Cantina"; } - else if (structureTemplate.indexOf("hospital") > -1) + else if (structureTemplate.contains("hospital")) { - signName = admin_name + "Medical Center"; + signName = "Medical Center"; } - else if (structureTemplate.indexOf("pgc_merchant_tent") > -1) + else if (structureTemplate.contains("pgc_merchant_tent")) { - signName = admin_name + "'s Chronicles Tent"; + signName = "Chronicles Tent"; } - else if (structureTemplate.indexOf("merchant_tent") > -1) + else if (structureTemplate.contains("merchant_tent")) { - signName = admin_name + "Merchant Tent"; + signName = "Merchant Tent"; } - else if (structureTemplate.indexOf("theater") > -1) + else if (structureTemplate.contains("theater")) { signName = "Theater"; } - else if (structureTemplate.indexOf("garage") > -1) + else if (structureTemplate.contains("garage")) { signName = "Garage"; } - else + else { signName = "House"; } @@ -4999,7 +4490,7 @@ public class player_structure extends script.base_script there.z -= 0.4f; z -= 0.4f; } - if (structureTemplate.equals("object/building/player/player_house_generic_large_style_01.iff")) + else if (structureTemplate.equals("object/building/player/player_house_generic_large_style_01.iff")) { if (signTemplate.startsWith("object/tangible/sign/player/shop_sign_") && !signTemplate.startsWith("object/tangible/sign/player/shop_sign_s0")) { @@ -5007,12 +4498,12 @@ public class player_structure extends script.base_script z += 0.8f; } } - if (structureTemplate.startsWith("object/building/player/city/cantina_naboo") && signTemplate.startsWith("object/tangible/sign/player/house_address") && !signTemplate.startsWith("object/tangible/sign/municipal/municipal_sign_hanging_cantina")) + else if (structureTemplate.startsWith("object/building/player/city/cantina_naboo") && signTemplate.startsWith("object/tangible/sign/player/house_address") && !signTemplate.startsWith("object/tangible/sign/municipal/municipal_sign_hanging_cantina")) { there.z += 0.3f; z += 0.3f; } - if (structureTemplate.startsWith("object/building/player/city/cantina_corellia") && signTemplate.startsWith("object/tangible/sign/player/house_address") && !signTemplate.startsWith("object/tangible/sign/municipal/municipal_sign_hanging_cantina")) + else if (structureTemplate.startsWith("object/building/player/city/cantina_corellia") && signTemplate.startsWith("object/tangible/sign/player/house_address") && !signTemplate.startsWith("object/tangible/sign/municipal/municipal_sign_hanging_cantina")) { there.z += 0.1f; z += 0.1f; @@ -5026,12 +4517,12 @@ public class player_structure extends script.base_script there.y += 1.5f; y += 1.5f; } - if (signTemplate.startsWith("object/tangible/sign/player/pgc_sign_hanging.iff")) + else if (signTemplate.startsWith("object/tangible/sign/player/pgc_sign_hanging.iff")) { there.x -= 0.45f; x -= 0.45f; } - if (structureTemplate.startsWith("object/building/player/player_merchant_tent")) + else if (structureTemplate.startsWith("object/building/player/player_merchant_tent")) { if (!signTemplate.startsWith("object/tangible/tcg/series3/house_sign_tcg_s02") && signTemplate.startsWith("object/tangible/tcg/")) { @@ -5040,28 +4531,28 @@ public class player_structure extends script.base_script x -= 0.4f; z -= 0.4f; } - if (signTemplate.startsWith("object/tangible/tcg/series3/house_sign_tcg_s02")) + else if (signTemplate.startsWith("object/tangible/tcg/series3/house_sign_tcg_s02")) { there.x += 0.6f; there.z += 0.1f; x += 0.6f; z += 0.1f; } - if (signTemplate.startsWith("object/tangible/sign/player/house_address_halloween")) + else if (signTemplate.startsWith("object/tangible/sign/player/house_address_halloween")) { there.x -= 0.2f; there.z -= 0.2f; x -= 0.2f; z -= 0.2f; } - if (signTemplate.startsWith("object/tangible/sign/player/imperial_empire_day_2009_sign_hanging") || signTemplate.startsWith("object/tangible/sign/player/rebel_remembrance_day_2009_sign_hanging")) + else if (signTemplate.startsWith("object/tangible/sign/player/imperial_empire_day_2009_sign_hanging") || signTemplate.startsWith("object/tangible/sign/player/rebel_remembrance_day_2009_sign_hanging")) { there.x -= 0.37f; there.z -= 0.37f; x -= 0.37f; z -= 0.37f; } - if (signTemplate.startsWith("object/tangible/sign/player/imperial_empire_day_2009_sign_standing") || signTemplate.startsWith("object/tangible/sign/player/rebel_remembrance_day_2009_sign_standing")) + else if (signTemplate.startsWith("object/tangible/sign/player/imperial_empire_day_2009_sign_standing") || signTemplate.startsWith("object/tangible/sign/player/rebel_remembrance_day_2009_sign_standing")) { there.x += 0.6f; there.z += 0.1f; @@ -5069,19 +4560,19 @@ public class player_structure extends script.base_script z += 0.1f; } } - if (structureTemplate.startsWith("object/building/player/player_house_mustafar_lg")) + else if (structureTemplate.startsWith("object/building/player/player_house_mustafar_lg")) { if (signTemplate.startsWith("object/tangible/tcg/series3/house_sign_tcg_s01")) { there.z -= 0.4f; z -= 0.4f; } - if (signTemplate.startsWith("object/tangible/sign/player/imperial_empire_day_2009_sign_hanging") || signTemplate.startsWith("object/tangible/sign/player/rebel_remembrance_day_2009_sign_hanging")) + else if (signTemplate.startsWith("object/tangible/sign/player/imperial_empire_day_2009_sign_hanging") || signTemplate.startsWith("object/tangible/sign/player/rebel_remembrance_day_2009_sign_hanging")) { there.z -= 0.4f; z -= 0.4f; } - if (signTemplate.startsWith("object/tangible/tcg/series5/house_sign_tcg_hanging")) + else if (signTemplate.startsWith("object/tangible/tcg/series5/house_sign_tcg_hanging")) { there.z -= 0.4f; z -= 0.4f; @@ -5102,9 +4593,8 @@ public class player_structure extends script.base_script there.z -= 0.4f; there.y -= 0.1f; z -= 0.4f; - y -= 0.1f; } - if (signTemplate.startsWith("object/tangible/sign/player/rebel_remembrance_day_2009_sign_hanging") || signTemplate.startsWith("object/tangible/sign/player/imperial_empire_day_2009_sign_hanging")) + else if (signTemplate.startsWith("object/tangible/sign/player/rebel_remembrance_day_2009_sign_hanging") || signTemplate.startsWith("object/tangible/sign/player/imperial_empire_day_2009_sign_hanging")) { heading += 90f; there.z -= 0.4f; @@ -5118,7 +4608,7 @@ public class player_structure extends script.base_script there.x -= 0.4f; x -= 0.4f; } - if (signTemplate.startsWith("object/tangible/sign/player/rebel_remembrance_day_2009_sign_hanging")) + else if (signTemplate.startsWith("object/tangible/sign/player/rebel_remembrance_day_2009_sign_hanging")) { there.x -= 0.4f; x -= 0.4f; @@ -5139,12 +4629,12 @@ public class player_structure extends script.base_script there.z += 1.2f; z += 1.2f; } - if (signTemplate.startsWith("object/tangible/sign/player/rebel_remembrance_day_2009_sign_standing.iff") || signTemplate.startsWith("object/tangible/sign/player/imperial_empire_day_2009_sign_standing.iff")) + else if (signTemplate.startsWith("object/tangible/sign/player/rebel_remembrance_day_2009_sign_standing.iff") || signTemplate.startsWith("object/tangible/sign/player/imperial_empire_day_2009_sign_standing.iff")) { there.z += 0.6f; z += 0.6f; } - if (signTemplate.startsWith("object/tangible/sign/player/rebel_remembrance_day_2009_sign_hanging.iff") || signTemplate.startsWith("object/tangible/sign/player/imperial_empire_day_2009_sign_hanging.iff")) + else if (signTemplate.startsWith("object/tangible/sign/player/rebel_remembrance_day_2009_sign_hanging.iff") || signTemplate.startsWith("object/tangible/sign/player/imperial_empire_day_2009_sign_hanging.iff")) { there.z -= 0.3f; z -= 0.3f; @@ -5157,7 +4647,7 @@ public class player_structure extends script.base_script there.z -= 0.25f; z -= 0.25f; } - if (signTemplate.startsWith("object/tangible/sign/player/rebel_remembrance_day_2009_sign_hanging.iff") || signTemplate.startsWith("object/tangible/sign/player/imperial_empire_day_2009_sign_hanging.iff")) + else if (signTemplate.startsWith("object/tangible/sign/player/rebel_remembrance_day_2009_sign_hanging.iff") || signTemplate.startsWith("object/tangible/sign/player/imperial_empire_day_2009_sign_hanging.iff")) { there.z -= 0.25f; z -= 0.25f; @@ -5170,29 +4660,29 @@ public class player_structure extends script.base_script there.x += 0.5f; x += 0.5f; } - if (structureTemplate.startsWith("object/building/player/player_house_corellia_large_style_01.iff")) + else if (structureTemplate.startsWith("object/building/player/player_house_corellia_large_style_01.iff")) { heading += 90; there.z -= 0.5f; z -= 0.5f; } - if (structureTemplate.startsWith("object/building/player/player_house_corellia_large_style_02.iff") || structureTemplate.startsWith("object/building/player/player_house_corellia_small_style_02.iff") || structureTemplate.startsWith("object/building/player/player_house_corellia_small_style_02_floorplan_02.iff")) + else if (structureTemplate.startsWith("object/building/player/player_house_corellia_large_style_02.iff") || structureTemplate.startsWith("object/building/player/player_house_corellia_small_style_02.iff") || structureTemplate.startsWith("object/building/player/player_house_corellia_small_style_02_floorplan_02.iff")) { heading += 90; there.z -= 0.1f; z -= 0.1f; } - if (structureTemplate.startsWith("object/building/player/player_house_corellia_medium_style_01.iff")) + else if (structureTemplate.startsWith("object/building/player/player_house_corellia_medium_style_01.iff")) { heading += 90; } - if (structureTemplate.startsWith("object/building/player/player_house_corellia_small_style_01.iff") || structureTemplate.startsWith("object/building/player/player_house_corellia_small_style_01_floorplan_02.iff")) + else if (structureTemplate.startsWith("object/building/player/player_house_corellia_small_style_01.iff") || structureTemplate.startsWith("object/building/player/player_house_corellia_small_style_01_floorplan_02.iff")) { heading += 90; there.x += 0.5f; x += 0.5f; } - if (structureTemplate.startsWith("object/building/player/player_merchant_tent_style_01.iff") || structureTemplate.startsWith("object/building/player/player_merchant_tent_style_02.iff") || structureTemplate.startsWith("object/building/player/player_merchant_tent_style_03.iff")) + else if (structureTemplate.startsWith("object/building/player/player_merchant_tent_style_01.iff") || structureTemplate.startsWith("object/building/player/player_merchant_tent_style_02.iff") || structureTemplate.startsWith("object/building/player/player_merchant_tent_style_03.iff")) { heading += 10; there.x += 0.3f; @@ -5200,53 +4690,53 @@ public class player_structure extends script.base_script x += 0.3f; z -= 0.1f; } - if (structureTemplate.startsWith("object/building/player/player_house_tatooine_large_style_01.iff")) + else if (structureTemplate.startsWith("object/building/player/player_house_tatooine_large_style_01.iff")) { there.z -= 0.1f; z -= 0.1f; } - if (structureTemplate.startsWith("object/building/player/player_house_mustafar_lg.iff")) + else if (structureTemplate.startsWith("object/building/player/player_house_mustafar_lg.iff")) { heading += 180; there.x -= 0.3f; x -= 0.3f; } - if (structureTemplate.startsWith("object/building/player/player_house_generic_large_style_01.iff") || structureTemplate.startsWith("object/building/player/player_house_generic_large_style_02.iff") || structureTemplate.startsWith("object/building/player/player_house_generic_medium_style_02.iff") || structureTemplate.startsWith("object/building/player/player_house_generic_small_style_02.iff")) + else if (structureTemplate.startsWith("object/building/player/player_house_generic_large_style_01.iff") || structureTemplate.startsWith("object/building/player/player_house_generic_large_style_02.iff") || structureTemplate.startsWith("object/building/player/player_house_generic_medium_style_02.iff") || structureTemplate.startsWith("object/building/player/player_house_generic_small_style_02.iff")) { there.z += 0.2f; z += 0.2f; } - if (structureTemplate.startsWith("object/building/player/player_house_generic_medium_windowed_s02.iff")) + else if (structureTemplate.startsWith("object/building/player/player_house_generic_medium_windowed_s02.iff")) { there.z -= 0.2f; z -= 0.2f; } - if (structureTemplate.startsWith("object/building/player/player_house_generic_small_style_01.iff")) + else if (structureTemplate.startsWith("object/building/player/player_house_generic_small_style_01.iff")) { there.z += 0.2f; there.x += 0.7f; z += 0.2f; x += 0.7f; } - if (structureTemplate.startsWith("object/building/player/player_house_naboo_small_style_01.iff")) + else if (structureTemplate.startsWith("object/building/player/player_house_naboo_small_style_01.iff")) { heading -= 10; there.x += 0.4f; x += 0.4f; } - if (structureTemplate.startsWith("object/building/player/player_house_generic_small_windowed.iff")) + else if (structureTemplate.startsWith("object/building/player/player_house_generic_small_windowed.iff")) { there.x += 0.5f; x += 0.5f; } - if (structureTemplate.startsWith("object/building/player/player_house_generic_small_window_style_03.iff")) + else if (structureTemplate.startsWith("object/building/player/player_house_generic_small_window_style_03.iff")) { there.x += 1; there.z -= 0.2f; x += 1; z -= 0.2f; } - if (structureTemplate.startsWith("object/building/player/player_house_naboo_small_window_style_01.iff")) + else if (structureTemplate.startsWith("object/building/player/player_house_naboo_small_window_style_01.iff")) { heading -= 12; there.x += 0.6f; @@ -5372,11 +4862,9 @@ public class player_structure extends script.base_script { Vector thisStructure = new Vector(); thisStructure.setSize(0); - for (int i = 0; i < allStructures.length; i++) - { - if (structureTemplate.equals(allStructures[i])) - { - thisStructure = utils.addElement(thisStructure, allStructures[i]); + for (String allStructure : allStructures) { + if (structureTemplate.equals(allStructure)) { + thisStructure = utils.addElement(thisStructure, allStructure); } } } @@ -5384,16 +4872,7 @@ public class player_structure extends script.base_script return sign; } } - else - { - } } - else - { - } - } - else - { } return null; } @@ -5403,9 +4882,7 @@ public class player_structure extends script.base_script { return null; } - float sYaw = getYaw(structure); - sYaw = (float)(Math.round(sYaw)); - return createStructureSign(structure, sYaw); + return createStructureSign(structure, (float)(Math.round(getYaw(structure)))); } public static void destroyStructureSign(obj_id structure) throws InterruptedException { @@ -5426,13 +4903,11 @@ public class player_structure extends script.base_script { return -1f; } - int energonGOT = getGameObjectType(energon); - if (isGameObjectTypeOf(energonGOT, GOT_resource_container)) + if (isGameObjectTypeOf(getGameObjectType(energon), GOT_resource_container)) { return -1f; } - int bldgGOT = getGameObjectType(bldg); - if (!isGameObjectTypeOf(bldgGOT, GOT_installation)) + if (!isGameObjectTypeOf(getGameObjectType(bldg), GOT_installation)) { return -1f; } @@ -5482,20 +4957,27 @@ public class player_structure extends script.base_script if (ovl != null) { int numItems = ovl.getNumItems(); + obj_var ov; + String ovName; + obj_id rId; + float amt; + String mType; + obj_id newId; + for (int i = 0; i < numItems; i++) { - obj_var ov = ovl.getObjVar(i); + ov = ovl.getObjVar(i); if (ov != null) { - String ovName = ov.getName(); - obj_id rId = utils.stringToObjId(ovName); + ovName = ov.getName(); + rId = utils.stringToObjId(ovName); if (!isValidResourceId(rId)) { - float amt = ov.getFloatData(); - String mType = getHarvesterMasterResource(structure); + amt = ov.getFloatData(); + mType = getHarvesterMasterResource(structure); if (mType != null && !mType.equals("")) { - obj_id newId = pickRandomNonDepeletedResource(mType); + newId = pickRandomNonDepeletedResource(mType); if (isIdValid(newId)) { setObjVar(structure, "resource." + newId, amt); @@ -5536,25 +5018,25 @@ public class player_structure extends script.base_script } if (isHarvester(structure)) { - if (template.indexOf("mining_ore") > -1) + if (template.contains("mining_ore")) { return "mineral"; } - if (template.indexOf("mining_gas") > -1) + if (template.contains("mining_gas")) { return "gas"; } - if (template.indexOf("mining_liquid") > -1) + if (template.contains("mining_liquid")) { - if (template.indexOf("moisture") > -1) + if (template.contains("moisture")) { return "water"; } return "chemical"; } - if (template.indexOf("mining_organic") > -1) + if (template.contains("mining_organic")) { - if (template.indexOf("creature") > -1) + if (template.contains("creature")) { return "creature_resources"; } @@ -5563,37 +5045,26 @@ public class player_structure extends script.base_script } else if (isGenerator(structure)) { - if (template.indexOf("fusion") > -1) + if (template.contains("fusion")) { return "radioactive"; } - if (template.indexOf("solar") > -1) + if (template.contains("solar")) { return "energy_renewable_unlimited_solar"; } - if (template.indexOf("wind") > -1) + if (template.contains("wind")) { return "energy_renewable_unlimited_wind"; } } return null; } - public static boolean canReclaimDeed(obj_id structure) throws InterruptedException - { - if (!isIdValid(structure)) - { - return false; - } - String template = getTemplateName(structure); - return canReclaimDeed(template); + public static boolean canReclaimDeed(obj_id structure) throws InterruptedException { + return isIdValid(structure) && canReclaimDeed(getTemplateName(structure)); } - public static boolean canReclaimDeed(String structureTemplate) throws InterruptedException - { - if (structureTemplate == null || structureTemplate.equals("")) - { - return false; - } - return dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, structureTemplate, "CAN_RECLAIM") == 1; + public static boolean canReclaimDeed(String structureTemplate) throws InterruptedException { + return !(structureTemplate == null || structureTemplate.equals("")) && dataTableGetInt(PLAYER_STRUCTURE_DATATABLE, structureTemplate, "CAN_RECLAIM") == 1; } public static void showChangeSignSui(obj_id structure, obj_id player) throws InterruptedException { @@ -5621,9 +5092,7 @@ public class player_structure extends script.base_script } if (entries != null && entries.size() > 0) { - String prompt = "@player_structure:changesign_prompt"; - String title = "@player_structure:changesign_title"; - sui.listbox(structure, player, prompt, sui.OK_CANCEL, title, entries, "handleChangeSignSui"); + sui.listbox(structure, player, "@player_structure:changesign_prompt", sui.OK_CANCEL, "@player_structure:changesign_title", entries, "handleChangeSignSui"); } } public static String getStructureName(obj_id structure) throws InterruptedException @@ -5646,8 +5115,7 @@ public class player_structure extends script.base_script { if (1 == dataTableGetInt(player_structure.PLAYER_STRUCTURE_DATATABLE, template, "GARAGE")) { - obj_id check = getFirstObjectWithTemplate(loc, range, template); - if (check != null) + if (getFirstObjectWithTemplate(loc, range, template) != null) { return false; } @@ -5656,11 +5124,8 @@ public class player_structure extends script.base_script } public static boolean hasMaintenanceDroid(obj_id player) throws InterruptedException { - obj_id[] datapad = getContents(utils.getPlayerDatapad(player)); - for (int i = 0; i < datapad.length; i++) - { - if (hasObjVar(datapad[i], "module_data.struct_maint")) - { + for (obj_id datapad : getContents(utils.getPlayerDatapad(player))) { + if (hasObjVar(datapad, "module_data.struct_maint")) { return true; } } @@ -5670,12 +5135,10 @@ public class player_structure extends script.base_script { Vector droids = new Vector(); droids.setSize(0); - obj_id[] datapad = getContents(utils.getPlayerDatapad(player)); - for (int i = 0; i < datapad.length; i++) - { - if (hasObjVar(datapad[i], "module_data.struct_maint")) - { - droids = utils.addElement(droids, datapad[i]); + obj_id[] datapads = getContents(utils.getPlayerDatapad(player)); + for (obj_id datapad : datapads) { + if (hasObjVar(datapad, "module_data.struct_maint")) { + droids = utils.addElement(droids, datapad); } } obj_id[] _droids = new obj_id[0]; @@ -5688,19 +5151,19 @@ public class player_structure extends script.base_script } public static void flagConverted(String template, obj_id structure) throws InterruptedException { - if (template.indexOf("_guildhall_") != -1) + if (template.contains("_guildhall_")) { setObjVar(structure, "newBuilding", true); setObjVar(structure, "newBuildPartTwo", true); } - else if (template.indexOf("structure_factory") != -1) + else if (template.contains("structure_factory")) { setObjVar(structure, "newBuilding", true); setObjVar(structure, "newBuildPartTwo", true); } - else if (template.indexOf("player_house_") != -1) + else if (template.contains("player_house_")) { - if (template.indexOf("_large_style_") != -1) + if (template.contains("_large_style_")) { setObjVar(structure, "newBuilding", true); setObjVar(structure, "newBuildPartTwo", true); @@ -5711,9 +5174,9 @@ public class player_structure extends script.base_script { if (!hasObjVar(structure, "newBuilding") || !hasObjVar(structure, "newBuildPartTwo")) { - if (template.indexOf("_guildhall_") != -1) + if (template.contains("_guildhall_")) { - if (template.indexOf("_guildhall_tatooine_") == -1) + if (!template.contains("_guildhall_tatooine_")) { struct_lots = 9; } @@ -5722,13 +5185,13 @@ public class player_structure extends script.base_script struct_lots = 7; } } - else if (template.indexOf("structure_factory") != -1) + else if (template.contains("structure_factory")) { struct_lots = 2; } - else if (template.indexOf("player_house_") != -1) + else if (template.contains("player_house_")) { - if (template.indexOf("_large_style_") != -1) + if (template.contains("_large_style_")) { struct_lots = 6; } @@ -5745,9 +5208,9 @@ public class player_structure extends script.base_script if (!hasObjVar(structure, "newBuilding")) { String template = getTemplateName(structure); - if (template.indexOf("_guildhall_") != -1) + if (template.contains("_guildhall_")) { - if (template.indexOf("_guildhall_tatooine_") == -1) + if (!template.contains("_guildhall_tatooine_")) { adjustLotCount(getPlayerObject(player), -4); setObjVar(structure, "newBuilding", true); @@ -5760,14 +5223,14 @@ public class player_structure extends script.base_script setObjVar(structure, "newBuildPartTwo", true); } } - else if (template.indexOf("structure_factory") != -1) + else if (template.contains("structure_factory")) { adjustLotCount(getPlayerObject(player), -1); setObjVar(structure, "newBuilding", true); } - else if (template.indexOf("player_house_") != -1) + else if (template.contains("player_house_")) { - if (template.indexOf("_large_style_") != -1) + if (template.contains("_large_style_")) { adjustLotCount(getPlayerObject(player), -1); setObjVar(structure, "newBuilding", true); @@ -5778,14 +5241,14 @@ public class player_structure extends script.base_script else if (!hasObjVar(structure, "newBuildPartTwo")) { String template = getTemplateName(structure); - if (template.indexOf("_guildhall_") != -1) + if (template.contains("_guildhall_")) { adjustLotCount(getPlayerObject(player), -2); setObjVar(structure, "newBuildPartTwo", true); } - else if (template.indexOf("player_house_") != -1) + else if (template.contains("player_house_")) { - if (template.indexOf("_large_style_") != -1) + if (template.contains("_large_style_")) { adjustLotCount(getPlayerObject(player), -1); setObjVar(structure, "newBuildPartTwo", true); @@ -5799,9 +5262,9 @@ public class player_structure extends script.base_script if (!hasObjVar(structure, "newBuilding")) { String template = getTemplateName(structure); - if (template.indexOf("_guildhall_") != -1) + if (template.contains("_guildhall_")) { - if (template.indexOf("_guildhall_tatooine_") == -1) + if (!template.contains("_guildhall_tatooine_")) { params.put("lotAdjust", -4); setObjVar(structure, "newBuilding", true); @@ -5816,16 +5279,16 @@ public class player_structure extends script.base_script messageTo(owner, "handleAdjustLotCount", params, 0, true); } } - else if (template.indexOf("structure_factory") != -1) + else if (template.contains("structure_factory")) { params.put("lotAdjust", -1); setObjVar(structure, "newBuilding", true); setObjVar(structure, "newBuildPartTwo", true); messageTo(owner, "handleAdjustLotCount", params, 0, true); } - else if (template.indexOf("player_house_") != -1) + else if (template.contains("player_house_")) { - if (template.indexOf("_large_style_") != -1) + if (template.contains("_large_style_")) { params.put("lotAdjust", -1); setObjVar(structure, "newBuilding", true); @@ -5837,15 +5300,15 @@ public class player_structure extends script.base_script else if (!hasObjVar(structure, "newBuildPartTwo")) { String template = getTemplateName(structure); - if (template.indexOf("_guildhall_") != -1) + if (template.contains("_guildhall_")) { params.put("lotAdjust", -2); setObjVar(structure, "newBuildPartTwo", true); messageTo(owner, "handleAdjustLotCount", params, 0, true); } - else if (template.indexOf("player_house_") != -1) + else if (template.contains("player_house_")) { - if (template.indexOf("_large_style_") != -1) + if (template.contains("_large_style_")) { params.put("lotAdjust", -1); setObjVar(structure, "newBuildPartTwo", true); @@ -5868,7 +5331,6 @@ public class player_structure extends script.base_script { String strTitle = "@player_structure:fix_condemned_title"; string_id strPrompt = new string_id(STF_FILE, "structure_condemned_owner_has_credits"); - String strConfirm = "@player_structure:confirm_pay"; prose_package pp = new prose_package(); prose.setStringId(pp, strPrompt); prose.setDI(pp, intRepairCost); @@ -5877,7 +5339,6 @@ public class player_structure extends script.base_script { showSUIPage(pid); } - return; } else { @@ -5886,26 +5347,19 @@ public class player_structure extends script.base_script prose.setStringId(pp, strSpam); prose.setDI(pp, intRepairCost); sendSystemMessageProse(objItem, pp); - return; } } else { - string_id strSpam = new string_id(STF_FILE, "structure_condemned_not_owner"); - sendSystemMessage(objItem, strSpam); - return; + sendSystemMessage(objItem, new string_id(STF_FILE, "structure_condemned_not_owner")); } } } public static int getStructureRepairCost(obj_id structure) throws InterruptedException { - int condition = getStructureCondition(structure); - int max_condition = getMaxCondition(structure); - int damage = max_condition - condition; - int maint_pool = getBankBalance(structure); + int damage = getMaxCondition(structure) - getStructureCondition(structure); float per_point_cost = getBaseMaintenanceRate(structure) / 3.0f; - int repair_cost = (int)(damage * per_point_cost); - return repair_cost; + return (int)(damage * per_point_cost); } public static boolean isStructureCondemned(obj_id objStructure) throws InterruptedException { @@ -5913,25 +5367,16 @@ public class player_structure extends script.base_script } public static void sendCondemnedMail(obj_id objStructure) throws InterruptedException { - obj_id objOwner = getOwner(objStructure); - String strName = getPlayerName(objOwner); - string_id strSubject = new string_id(STF_FILE, "structure_condemned_subject"); - string_id strBody = new string_id(STF_FILE, "structure_condemned_body"); - int intRepairCost = getStructureRepairCost(objStructure); location loc = getLocation(objStructure); - String area = loc.area; - if (area != null) - { - area = (area.substring(0, 1)).toUpperCase() + area.substring(1); - } String loc_str = "(" + loc.x + ", " + loc.z + " " + loc.area + ")"; + prose_package pp = new prose_package(); - prose.setStringId(pp, strBody); + prose.setStringId(pp, new string_id(STF_FILE, "structure_condemned_body")); prose.setTO(pp, loc_str); prose.setTT(pp, objStructure); - prose.setDI(pp, intRepairCost); - utils.sendMail(strSubject, pp, strName, "@player_structure:management"); - return; + prose.setDI(pp, getStructureRepairCost(objStructure)); + + utils.sendMail(new string_id(STF_FILE, "structure_condemned_subject"), pp, getPlayerName(getOwner(objStructure)), "@player_structure:management"); } public static int getMaintenanceHeartbeat() throws InterruptedException { @@ -5949,29 +5394,19 @@ public class player_structure extends script.base_script } public static void sendOutOfMaintenanceMail(obj_id objStructure) throws InterruptedException { - obj_id objOwner = getOwner(objStructure); - String strName = getPlayerName(objOwner); - string_id strSubject = new string_id(STF_FILE, "structure_maintenance_empty_subject"); - string_id strBody = new string_id(STF_FILE, "structure_maintenance_empty_body"); location loc = getLocation(objStructure); - String area = loc.area; - if (area != null) - { - area = (area.substring(0, 1)).toUpperCase() + area.substring(1); - } String loc_str = "(" + loc.x + ", " + loc.z + " " + loc.area + ")"; + prose_package pp = new prose_package(); - prose.setStringId(pp, strBody); + prose.setStringId(pp, new string_id(STF_FILE, "structure_maintenance_empty_body")); prose.setTO(pp, loc_str); prose.setTT(pp, objStructure); - String strTest = getString(strSubject); - strTest = getString(strBody); - utils.sendMail(strSubject, pp, strName, "@player_structure:management"); - return; + + utils.sendMail(new string_id(STF_FILE, "structure_maintenance_empty_subject"), pp, getPlayerName(getOwner(objStructure)), "@player_structure:management"); } public static boolean isFactionPerkBase(String objectTemplateName) throws InterruptedException { - return objectTemplateName.indexOf("object/building/faction_perk/hq/") != -1; + return objectTemplateName.contains("object/building/faction_perk/hq/"); } public static boolean isFactionPerkBaseDeed(obj_id objDeed) throws InterruptedException { @@ -5979,7 +5414,7 @@ public class player_structure extends script.base_script } public static boolean isFactionPerkBaseDeed(String deedObjectTemplateName) throws InterruptedException { - return deedObjectTemplateName.indexOf("object/tangible/deed/faction_perk/hq/") != -1; + return deedObjectTemplateName.contains("object/tangible/deed/faction_perk/hq/"); } public static boolean canPlaceFactionPerkDeed(obj_id objDeed, obj_id objPlayer) throws InterruptedException { @@ -5987,12 +5422,10 @@ public class player_structure extends script.base_script final int BASES_ALLOWED = 3; if (player_structure.isFactionPerkBaseDeed(objDeed)) { - location locTest = getLocation(objPlayer); - obj_id[] objBases = getAllObjectsWithScript(locTest, CHECK_RANGE, "faction_perk.hq.loader"); + obj_id[] objBases = getAllObjectsWithScript(getLocation(objPlayer), CHECK_RANGE, "faction_perk.hq.loader"); if ((objBases != null) && (objBases.length >= BASES_ALLOWED)) { - string_id strSpam = new string_id("gcw", "too_many_bases"); - sendSystemMessage(objPlayer, strSpam); + sendSystemMessage(objPlayer, new string_id("gcw", "too_many_bases")); return false; } } @@ -6000,7 +5433,6 @@ public class player_structure extends script.base_script } public static int validateHopperSize(obj_id structureObject) throws InterruptedException { - int objvar_hopper = 0; if (!isIdValid(structureObject)) { return 0; @@ -6021,6 +5453,7 @@ public class player_structure extends script.base_script { return 0; } + int objvar_hopper; if (hasObjVar(structureObject, VAR_DEED_MAX_HOPPER)) { objvar_hopper = getIntObjVar(structureObject, VAR_DEED_MAX_HOPPER); @@ -6055,11 +5488,7 @@ public class player_structure extends script.base_script return false; } String templateName = getTemplateName(structure); - if (templateName == null || isFactionPerkBase(templateName)) - { - return false; - } - return true; + return !(templateName == null || isFactionPerkBase(templateName)); } public static boolean needsPreAbandonCheck(obj_id structure) throws InterruptedException { @@ -6075,11 +5504,7 @@ public class player_structure extends script.base_script { return true; } - if (!doesUnmarkedStructureQualifyForHousePackup(structure)) - { - return false; - } - return true; + return doesUnmarkedStructureQualifyForHousePackup(structure); } public static boolean needsAbandonCheck(obj_id structure) throws InterruptedException { @@ -6095,11 +5520,7 @@ public class player_structure extends script.base_script { return true; } - if (!doesUnmarkedStructureQualifyForHousePackup(structure)) - { - return false; - } - return true; + return doesUnmarkedStructureQualifyForHousePackup(structure); } public static boolean needsCityAbandonCheck(obj_id structure) throws InterruptedException { @@ -6118,9 +5539,7 @@ public class player_structure extends script.base_script LOG("sissynoid", "Failed 'needsCityAbandonedCheck - Structure is unpackable"); return false; } - location loc = getLocation(structure); - int city_id = getCityAtLocation(loc, 0); - if (!cityExists(city_id)) + if (!cityExists(getCityAtLocation(getLocation(structure), 0))) { LOG("sissynoid", "Failed 'needsCityAbandonedCheck - No City Exists at this Location"); return false; @@ -6203,11 +5622,7 @@ public class player_structure extends script.base_script { return false; } - if (!isCommoditiesServerAvailable()) - { - return false; - } - return true; + return isCommoditiesServerAvailable(); } public static boolean canPlayerPackAbandonedStructure(obj_id player, obj_id structure) throws InterruptedException { @@ -6223,11 +5638,7 @@ public class player_structure extends script.base_script { return false; } - if (!structure.isLoaded() || !structure.isAuthoritative()) - { - return false; - } - return true; + return !(!structure.isLoaded() || !structure.isAuthoritative()); } public static boolean canPackStructureWithVendors(obj_id player, obj_id structure) throws InterruptedException { @@ -6248,8 +5659,7 @@ public class player_structure extends script.base_script { if (hasObjVar(player, HOUSE_PACKUP_DAILY_TIMER_OBJVAR)) { - int resetTime = getIntObjVar(player, HOUSE_PACKUP_DAILY_TIMER_OBJVAR); - if (getGameTime() >= resetTime) + if (getGameTime() >= getIntObjVar(player, HOUSE_PACKUP_DAILY_TIMER_OBJVAR)) { removeObjVar(player, HOUSE_PACKUP_DAILY_TIMER_OBJVAR); removeObjVar(player, HOUSE_PACKUP_DAILY_TALLY_OBJVAR); @@ -6281,7 +5691,6 @@ public class player_structure extends script.base_script } params.put("structure", structure); messageTo(player, "msgFinalizePackup", params, 0, false); - return; } else if (!canPackMoreToday(player)) { @@ -6293,12 +5702,10 @@ public class player_structure extends script.base_script } int timeLeft = getIntObjVar(player, HOUSE_PACKUP_DAILY_TIMER_OBJVAR); timeLeft -= getGameTime(); - String displayTime = utils.assembleTimeRemainToUse(timeLeft, false); - string_id stringId = new string_id("spam", "wait_twenty_four"); prose_package p = new prose_package(); - prose.setStringId(p, stringId); + prose.setStringId(p, new string_id("spam", "wait_twenty_four")); prose.setDI(p, MAX_PACKUP_PER_DAY); - prose.setTT(p, displayTime); + prose.setTT(p, utils.assembleTimeRemainToUse(timeLeft, false)); commPlayers(player, "object/mobile/dressed_hiddendagger_pilot_m_01.iff", "sound/sys_comm_other.snd", 5f, player, p); messageTo(player, "handleFailedStructurePackup", null, 0, false); messageTo(player, "handlePlayerStructurePackupLockoutRemoval", null, 0, false); @@ -6389,14 +5796,12 @@ public class player_structure extends script.base_script messageTo(player, "handlePlayerStructurePackupLockoutRemoval", null, 0, false); return false; } - String timeMessage = utils.formatTimeVerbose(timeDiff); prose_package pp = new prose_package(); pp = prose.setStringId(pp, SID_LOCKOUT_MESSAGE); - pp = prose.setTO(pp, timeMessage); + pp = prose.setTO(pp, utils.formatTimeVerbose(timeDiff)); sendSystemMessageProse(player, pp); } - else if (!canPackMore) - { + else { blog("player_structure.isPlayerGatedFromHousePackUp - !canPackMoreToday(player)"); if (!hasObjVar(player, HOUSE_PACKUP_DAILY_TIMER_OBJVAR)) { @@ -6406,12 +5811,10 @@ public class player_structure extends script.base_script } int timeLeft = getIntObjVar(player, HOUSE_PACKUP_DAILY_TIMER_OBJVAR); timeLeft -= getGameTime(); - String displayTime = utils.assembleTimeRemainToUse(timeLeft, false); - string_id stringId = new string_id("spam", "wait_twenty_four"); prose_package p = new prose_package(); - prose.setStringId(p, stringId); + prose.setStringId(p, new string_id("spam", "wait_twenty_four")); prose.setDI(p, MAX_PACKUP_PER_DAY); - prose.setTT(p, displayTime); + prose.setTT(p, utils.assembleTimeRemainToUse(timeLeft, false)); commPlayers(player, "object/mobile/dressed_hiddendagger_pilot_m_01.iff", "sound/sys_comm_other.snd", 5f, player, p); messageTo(player, "handleFailedStructurePackup", null, 0, false); messageTo(player, "handlePlayerStructurePackupLockoutRemoval", null, 0, false); @@ -6445,15 +5848,9 @@ public class player_structure extends script.base_script } public static boolean validSafeStorageRemoval(obj_id structure, int decreaseAmount) throws InterruptedException { - int numItems = player_structure.getStructureNumItems(structure); int baseItemLimit = getPobBaseItemLimit(structure); - int storageIncreased = getTotalIncreasedStorageAmountStructure(structure); - int projectedAmount = baseItemLimit + (storageIncreased - decreaseAmount); - if ((numItems > projectedAmount) || (projectedAmount < baseItemLimit)) - { - return false; - } - return true; + int projectedAmount = baseItemLimit + (getTotalIncreasedStorageAmountStructure(structure) - decreaseAmount); + return !((player_structure.getStructureNumItems(structure) > projectedAmount) || (projectedAmount < baseItemLimit)); } public static boolean incrementStorageAmount(obj_id player, obj_id structure, obj_id deed, int increaseAmount) throws InterruptedException { @@ -6494,8 +5891,7 @@ public class player_structure extends script.base_script { decreaseAmount = getIntObjVar(structure, nonGenericStorageTypeObjVar); } - int baseStorageIncrease = getTotalIncreasedStorageAmountStructure(structure); - int newStrucStorage = baseStorageIncrease - decreaseAmount; + int newStrucStorage = getTotalIncreasedStorageAmountStructure(structure) - decreaseAmount; if (newStrucStorage >= 0 && validSafeStorageRemoval(structure, decreaseAmount)) { obj_id pInv = utils.getInventoryContainer(player); @@ -6527,16 +5923,11 @@ public class player_structure extends script.base_script } public static boolean alreadyHasNonGenericStorageIncreaseOfType(obj_id structure, obj_id deed) throws InterruptedException { - String deedType = getStaticItemName(deed); - String nonGenericStorageTypeObjVar = NON_GENERIC_STORAGE_ITEM_OBJVAR + "." + deedType; - return hasObjVar(structure, nonGenericStorageTypeObjVar); + return hasObjVar(structure, NON_GENERIC_STORAGE_ITEM_OBJVAR + "." + getStaticItemName(deed)); } public static void setNonGenericStorageIncreaseOfTypeObjVar(obj_id structure, obj_id deed, int increaseAmount) throws InterruptedException { - String deedType = getStaticItemName(deed); - String nonGenericStorageTypeObjVar = NON_GENERIC_STORAGE_ITEM_OBJVAR + "." + deedType; - setObjVar(structure, nonGenericStorageTypeObjVar, increaseAmount); - return; + setObjVar(structure, NON_GENERIC_STORAGE_ITEM_OBJVAR + "." + getStaticItemName(deed), increaseAmount); } public static void removeNonGenericStorageIncreaseOfTypeObjVar(obj_id structure, String type) throws InterruptedException { @@ -6545,14 +5936,12 @@ public class player_structure extends script.base_script { removeObjVar(structure, nonGenericStorageTypeObjVar); } - return; } public static void displayAvailableNonGenericStorageTypes(obj_id player, obj_id terminal, obj_id structure) throws InterruptedException { if (utils.hasScriptVar(player, "structureStorageRedeedPid")) { - int oldSui = utils.getIntScriptVar(player, "structureStorageRedeedPid"); - forceCloseSUIPage(oldSui); + forceCloseSUIPage(utils.getIntScriptVar(player, "structureStorageRedeedPid")); } String[] storageTypeNamesArrayRef = getStorageTypeNamesArray(structure); if (!hasObjVar(structure, NON_GENERIC_STORAGE_ITEM_OBJVAR)) @@ -6568,8 +5957,6 @@ public class player_structure extends script.base_script } else { - String title = utils.packStringId(new string_id("player_structure", "sui_storage_nongeneric_redeed_title")); - String prompt = utils.packStringId(new string_id("player_structure", "sui_storage_nongeneric_redeed_prompt")); String[] storageTypeNamesArrayStrings = new String[storageTypeNamesArrayRef.length]; for (int i = 0; i < storageTypeNamesArrayRef.length; i++) { @@ -6593,11 +5980,17 @@ public class player_structure extends script.base_script storageTypeNamesArrayStrings[i] = "\0" + packOutOfBandProsePackage(null, pp); } } - int newSui = sui.listbox(terminal, player, prompt, sui.OK_CANCEL, title, storageTypeNamesArrayStrings, "handleStorageRedeedChoice"); + int newSui = sui.listbox( + terminal, + player, + utils.packStringId(new string_id("player_structure", "sui_storage_nongeneric_redeed_prompt")), + sui.OK_CANCEL, + utils.packStringId(new string_id("player_structure", "sui_storage_nongeneric_redeed_title")), + storageTypeNamesArrayStrings, "handleStorageRedeedChoice" + ); utils.setScriptVar(player, "structureStorageRedeedPid", newSui); } utils.setBatchScriptVar(terminal, "storageTypeNamesRef", storageTypeNamesArrayRef); - return; } public static String[] getStorageTypeNamesArray(obj_id structure) throws InterruptedException { @@ -6610,10 +6003,12 @@ public class player_structure extends script.base_script if (nonGenericStorageObjvarList != null) { int numItem = nonGenericStorageObjvarList.getNumItems(); + obj_var nonGenericStorageObjvar; + String nonGenericStorageObjvarName; for (int i = 0; i < numItem; i++) { - obj_var nonGenericStorageObjvar = nonGenericStorageObjvarList.getObjVar(i); - String nonGenericStorageObjvarName = nonGenericStorageObjvar.getName(); + nonGenericStorageObjvar = nonGenericStorageObjvarList.getObjVar(i); + nonGenericStorageObjvarName = nonGenericStorageObjvar.getName(); totalNonGenericStorageIncrease = totalNonGenericStorageIncrease + nonGenericStorageObjvar.getIntData(); if (nonGenericStorageObjvarName != null && nonGenericStorageObjvarName.length() > 0) { @@ -6636,18 +6031,18 @@ public class player_structure extends script.base_script } public static boolean handleStorageReclaimConfirmation(obj_id player, obj_id terminal) throws InterruptedException { - String title = utils.packStringId(new string_id("player_structure", "sui_storage_redeed_title")); - String prompt = utils.packStringId(new string_id("player_structure", "sui_storage_redeed_prompt")); - sui.msgbox(terminal, player, prompt, sui.YES_NO, title, "handleStorageRedeedChoice"); + sui.msgbox( + terminal, + player, + utils.packStringId(new string_id("player_structure", "sui_storage_redeed_prompt")), + sui.YES_NO, + utils.packStringId(new string_id("player_structure", "sui_storage_redeed_title")), + "handleStorageRedeedChoice" + ); return false; } - public static boolean canRotateFurnitureInPitchRollAxes(obj_id player) throws InterruptedException - { - if (!isIdValid(player)) - { - return false; - } - return hasCompletedCollection(player, "force_shui_tier_02"); + public static boolean canRotateFurnitureInPitchRollAxes(obj_id player) throws InterruptedException { + return isIdValid(player) && hasCompletedCollection(player, "force_shui_tier_02"); } public static boolean isPlayerStructure(obj_id target) throws InterruptedException { @@ -6672,11 +6067,7 @@ public class player_structure extends script.base_script { return false; } - if (!isGameObjectTypeOf(target, GOT_building_player)) - { - return false; - } - return true; + return isGameObjectTypeOf(target, GOT_building_player); } public static boolean hasSpecialSignSkillMod(obj_id player, obj_id structure) throws InterruptedException { @@ -6685,14 +6076,13 @@ public class player_structure extends script.base_script { return false; } - boolean owner = isOwner(structure, player); blog("player_structure.hasSpecialSignSkillMod: initial validation passes"); String[] specialSignSkillMods = dataTableGetStringColumn(TBL_SPECIAL_SIGNS, "skillmod_name"); - int[] adminSpecialSign = dataTableGetIntColumn(TBL_SPECIAL_SIGNS, "admin_placement"); if (specialSignSkillMods == null || specialSignSkillMods.length <= 0) { return false; } + int[] adminSpecialSign = dataTableGetIntColumn(TBL_SPECIAL_SIGNS, "admin_placement"); blog("player_structure.hasSpecialSignSkillMod: about to test each of the special signs to see if I have the necessary skill mods."); for (int i = 0; i < specialSignSkillMods.length; i++) { @@ -6700,7 +6090,7 @@ public class player_structure extends script.base_script { continue; } - if (!owner && adminSpecialSign[i] == 0) + if (!isOwner(structure, player) && adminSpecialSign[i] == 0) { continue; } @@ -6719,18 +6109,17 @@ public class player_structure extends script.base_script boolean owner = isOwner(structure, player); blog("player_structure.getSpecialSignList: initial validation passes"); String[] specialSignSkillMods = dataTableGetStringColumn(TBL_SPECIAL_SIGNS, "skillmod_name"); - String[] specialSignTemplates = dataTableGetStringColumn(TBL_SPECIAL_SIGNS, "sign_template"); - String[] specialSignNames = dataTableGetStringColumn(TBL_SPECIAL_SIGNS, "string_mapping"); int[] adminSpecialSign = dataTableGetIntColumn(TBL_SPECIAL_SIGNS, "admin_placement"); if (specialSignSkillMods == null || specialSignSkillMods.length <= 0) { return false; } - else if (specialSignTemplates == null || specialSignTemplates.length <= 0) + String[] specialSignTemplates = dataTableGetStringColumn(TBL_SPECIAL_SIGNS, "sign_template"); + if (specialSignTemplates == null || specialSignTemplates.length <= 0) { return false; } - else if (specialSignSkillMods.length != specialSignTemplates.length) + if (specialSignSkillMods.length != specialSignTemplates.length) { return false; } @@ -6739,6 +6128,7 @@ public class player_structure extends script.base_script Vector allSignStrings = new Vector(); allSignStrings.setSize(0); blog("player_structure.getSpecialSignList: about to test each of the special signs to see if I have the necessary skill mods."); + String[] specialSignNames = dataTableGetStringColumn(TBL_SPECIAL_SIGNS, "string_mapping"); for (int i = 0; i < specialSignSkillMods.length; i++) { if (getSkillStatMod(player, specialSignSkillMods[i]) <= 0) @@ -6781,11 +6171,10 @@ public class player_structure extends script.base_script revertCustomSign(player, structure); return true; } - boolean owner = isOwner(structure, player); if (hasObjVar(structure, SPECIAL_SIGN_OWNER_ONLY)) { boolean needsOwnerToRemove = getBooleanObjVar(structure, SPECIAL_SIGN_OWNER_ONLY); - if (!owner && needsOwnerToRemove) + if (!isOwner(structure, player) && needsOwnerToRemove) { sendSystemMessage(player, SID_ONLY_OWNER_CAN_REMOVE); return false; @@ -6797,7 +6186,6 @@ public class player_structure extends script.base_script return false; } blog("player_structure.removeSpecialSign - validation completed"); - String skillmodRecovery = getStringObjVar(structure, SPECIAL_SIGN_SKILLMOD); boolean ownerOnlyRecovery = false; if (hasObjVar(structure, SPECIAL_SIGN_OWNER_ONLY) && getBooleanObjVar(structure, SPECIAL_SIGN_OWNER_ONLY)) { @@ -6826,7 +6214,7 @@ public class player_structure extends script.base_script setObjVar(structure, SPECIAL_SIGN, true); setObjVar(structure, SPECIAL_SIGN_TEMPLATE, signTemplateRecovery); setObjVar(structure, VAR_SIGN_TYPE, signTypeRecovery); - setObjVar(structure, VAR_SIGN_TYPE, skillmodRecovery); + setObjVar(structure, VAR_SIGN_TYPE, getStringObjVar(structure, SPECIAL_SIGN_SKILLMOD)); setObjVar(structure, SPECIAL_SIGN_OWNER_ONLY, ownerOnlyRecovery); blog("player_structure.removeSpecialSign - Default Sign Creation failed!!!!!!!!!!!!!!!!!"); sendSystemMessage(player, SID_SPECIAL_SIGN_FAILED); @@ -6878,7 +6266,7 @@ public class player_structure extends script.base_script blog("revertCustomSign - customSign: item_event_halloween_house_sign_standing " + customSign); newSign = "item_special_sign_halloween_standing_sign"; } - if (newSign == null || newSign.length() <= 0) + if (newSign.length() <= 0) { blog("revertCustomSign - customSign: FAIL!!!!!!!!!!!"); obj_id sign = static_item.createNewItemFunction(customSign, player); @@ -6915,19 +6303,24 @@ public class player_structure extends script.base_script cleanupFindItemScriptVars(player); cleanupFindItemScriptVars(self); showFindItemsListboxPage(self, player, 0); - return; } public static void initializeItemSearchInHouse(obj_id self, obj_id player) throws InterruptedException { - String title = utils.packStringId(new string_id("player_structure", "find_items_search_keyword_title")); - String prompt = getString(new string_id("player_structure", "find_items_search_keyword_prompt")); - int pid = sui.inputbox(self, player, prompt, sui.OK_CANCEL, title, sui.INPUT_NORMAL, null, "handlePlayerStructureSearchItemsGetKeyword"); + int pid = sui.inputbox( + self, + player, + getString(new string_id("player_structure", "find_items_search_keyword_prompt")), + sui.OK_CANCEL, + utils.packStringId(new string_id("player_structure","find_items_search_keyword_title")), + sui.INPUT_NORMAL, + null, + "handlePlayerStructureSearchItemsGetKeyword" + ); if (pid > -1) { sui.showSUIPage(pid); utils.setScriptVar(player, "findItems.pid", pid); } - return; } public static void showFindItemsListboxPage(obj_id self, obj_id player, int startingIndex) throws InterruptedException { @@ -6949,11 +6342,12 @@ public class player_structure extends script.base_script String[] itemsPageNamesList = new String[(endingIndex + 1) - startingIndex]; obj_id[] itemsPageList = new obj_id[(endingIndex + 1) - startingIndex]; int j = 0; + obj_id item; + for (int i = startingIndex; i <= endingIndex; i++) { - obj_id item = ((obj_id)myItemsInBuilding.get(i)); - String itemName = getEncodedName(item); - itemsPageNamesList[j] = itemName; + item = ((obj_id)myItemsInBuilding.get(i)); + itemsPageNamesList[j] = getEncodedName(item); itemsPageList[j] = item; ++j; } @@ -6965,7 +6359,6 @@ public class player_structure extends script.base_script cleanupFindItemScriptVars(player); cleanupFindItemScriptVars(self); } - return; } public static void repeatFindItemsListboxPage(obj_id self, obj_id player, int startingIndex, int totalNumItems, obj_id[] itemsPageList) throws InterruptedException { @@ -6974,19 +6367,14 @@ public class player_structure extends script.base_script String[] itemsPageNamesList = new String[itemsPageList.length]; for (int i = 0; i < itemsPageList.length; i++) { - obj_id item = itemsPageList[i]; - String itemName = getEncodedName(item); - itemsPageNamesList[i] = itemName; + itemsPageNamesList[i] = getEncodedName(itemsPageList[i]); } showFindItemsListboxSui(self, player, startingIndex, totalNumItems, itemsPageList, itemsPageNamesList); - return; } public static void showFindItemsListboxSui(obj_id self, obj_id player, int startingIndex, int totalNumItems, obj_id[] itemsPageList, String[] itemsPageNamesList) throws InterruptedException { - String title = utils.packStringId(new string_id("player_structure", "find_items_title")); String prompt = utils.packStringId(new string_id("player_structure", "find_items_prompt")); - prompt += target_dummy.addLineBreaks(2); - prompt += target_dummy.ORANGE + "Number of Items Found: " + target_dummy.WHITE + totalNumItems; + prompt += target_dummy.addLineBreaks(2) + target_dummy.ORANGE + "Number of Items Found: " + target_dummy.WHITE + totalNumItems; int endingIndex = startingIndex + 49; if (endingIndex >= totalNumItems) { @@ -6994,7 +6382,7 @@ public class player_structure extends script.base_script } prompt += target_dummy.addLineBreaks(1); prompt += target_dummy.ORANGE + "Displaying Items: " + target_dummy.WHITE + (startingIndex + 1) + " through " + (endingIndex + 1); - int pid = sui.listbox(self, player, prompt, sui.OK_CANCEL_REFRESH, title, itemsPageNamesList, "handlePlayerStructureFindItemsListResponse"); + int pid = sui.listbox(self, player, prompt, sui.OK_CANCEL_REFRESH, utils.packStringId(new string_id("player_structure", "find_items_title")), itemsPageNamesList, "handlePlayerStructureFindItemsListResponse"); if (pid > -1) { if (totalNumItems > 50) @@ -7012,7 +6400,6 @@ public class player_structure extends script.base_script utils.setScriptVar(player, "findItems.totalNumItems", totalNumItems); utils.setScriptVar(self, "findItems.itemsPageList", itemsPageList); } - return; } public static Vector getMyItemsInBuilding(obj_id player) throws InterruptedException { @@ -7031,11 +6418,8 @@ public class player_structure extends script.base_script obj_id[] cellList = getContents(building); if (cellList != null && cellList.length > 0) { - for (int i = 0; i < cellList.length; i++) - { - obj_id buildingCell = cellList[i]; - if ((getTemplateName(buildingCell)).equals(structure.TEMPLATE_CELL)) - { + for (obj_id buildingCell : cellList) { + if ((getTemplateName(buildingCell)).equals(structure.TEMPLATE_CELL)) { addPlayerItemsFromContainerToList(buildingCell, player, myItemsInBuilding); } } @@ -7066,50 +6450,37 @@ public class player_structure extends script.base_script obj_id[] contents = getContents(container); if (contents != null && contents.length > 0) { - for (int j = 0; j < contents.length; j++) - { - obj_id thing = contents[j]; - if (isIdValid(thing)) - { - boolean isValidPlayerOwnedObject = true; - obj_id thingOwner = getOwner(thing); - if (player != thingOwner && !isGod(player)) - { + boolean isValidPlayerOwnedObject; + obj_id ship; + obj_id lootBox; + + for (obj_id thing : contents) { + if (isIdValid(thing)) { + isValidPlayerOwnedObject = !(player != getOwner(thing) && !isGod(player)); + if (!isObjectPersisted(thing)) { isValidPlayerOwnedObject = false; } - if (!isObjectPersisted(thing)) - { + if (isPlayer(thing)) { isValidPlayerOwnedObject = false; } - if (isPlayer(thing)) - { + if (isMob(thing)) { isValidPlayerOwnedObject = false; } - if (isMob(thing)) - { - isValidPlayerOwnedObject = false; - } - obj_id ship = space_transition.getContainingShip(thing); - if (isIdValid(ship)) - { - obj_id lootBox = obj_id.NULL_ID; - if (hasObjVar(ship, "objLootBox")) - { + ship = space_transition.getContainingShip(thing); + if (isIdValid(ship)) { + lootBox = obj_id.NULL_ID; + if (hasObjVar(ship, "objLootBox")) { lootBox = getObjIdObjVar(ship, "objLootBox"); } - if (isIdValid(lootBox) && lootBox == thing) - { + if (isIdValid(lootBox) && lootBox == thing) { isValidPlayerOwnedObject = false; } } - if (hasCondition(thing, CONDITION_VENDOR)) - { + if (hasCondition(thing, CONDITION_VENDOR)) { isValidPlayerOwnedObject = false; } - if (isValidPlayerOwnedObject) - { - if (getContainerType(thing) != 0 && getGameObjectType(thing) != GOT_misc_factory_crate) - { + if (isValidPlayerOwnedObject) { + if (getContainerType(thing) != 0 && getGameObjectType(thing) != GOT_misc_factory_crate) { addPlayerItemsFromContainerToList(thing, player, myItemsInBuilding); } utils.addElement(myItemsInBuilding, thing); @@ -7134,21 +6505,17 @@ public class player_structure extends script.base_script { if (!utils.isNestedWithinAPlayer(selectedItem)) { - obj_id itemTopMost = getTopMostContainer(selectedItem); - obj_id myTopMost = getTopMostContainer(player); - if (itemTopMost == myTopMost) + if (getTopMostContainer(selectedItem) == getTopMostContainer(player)) { obj_id topNonCellContainer = getTopNonCellContainer(selectedItem); - String itemName = getEncodedName(selectedItem); - String containerName = getEncodedName(topNonCellContainer); string_id message = new string_id("player_structure", "find_items_item_moved"); if (topNonCellContainer != selectedItem) { message = new string_id("player_structure", "find_items_item_container_moved"); } prose_package pp = prose.getPackage(message); - prose.setTO(pp, itemName); - prose.setTT(pp, containerName); + prose.setTO(pp, getEncodedName(selectedItem)); + prose.setTT(pp, getEncodedName(topNonCellContainer)); sendQuestSystemMessage(player, pp); setLocation(topNonCellContainer, here); return true; @@ -7210,7 +6577,6 @@ public class player_structure extends script.base_script public static void cleanupFindItemScriptVars(obj_id target) throws InterruptedException { utils.removeScriptVarTree(target, "findItems"); - return; } public static void handleFindItemsListResponse(obj_id self, dictionary params) throws InterruptedException { @@ -7246,7 +6612,7 @@ public class player_structure extends script.base_script if (totalNumItems > 50) { String title = utils.packStringId(new string_id("player_structure", "find_items_page_title")); - String prompt = ""; + String prompt; int pid = sui.createSUIPage(sui.SUI_MSGBOX, self, player, "handlePlayerStructureFindItemsPageResponse"); if (startingIndex == 0) { @@ -7315,7 +6681,6 @@ public class player_structure extends script.base_script } cleanupFindItemScriptVars(player); cleanupFindItemScriptVars(self); - return; } public static void handleFindItemsChangePageResponse(obj_id self, dictionary params) throws InterruptedException { @@ -7357,7 +6722,6 @@ public class player_structure extends script.base_script cleanupFindItemScriptVars(player); cleanupFindItemScriptVars(self); showFindItemsListboxPage(self, player, startingIndex); - return; } public static void handleSearchItemsGetKeyword(obj_id self, dictionary params) throws InterruptedException { @@ -7389,50 +6753,43 @@ public class player_structure extends script.base_script keywordMatchedNames.setSize(0); int numMatches = 0; String prompt = utils.packStringId(new string_id("player_structure", "find_items_search_list_prompt")); - for (int i = 0; i < myItemsInBuilding.size(); i++) - { - obj_id thing = ((obj_id)myItemsInBuilding.get(i)); - String name = getAssignedName(thing); - if (name == null || name.length() < 1) - { - string_id sidName = getNameStringId(thing); - if (sidName != null && !sidName.isEmpty()) - { + obj_id thing; + String name; + string_id sidName; + + for (Object myItem : myItemsInBuilding) { + thing = ((obj_id) myItem); + name = getAssignedName(thing); + if (name == null || name.length() < 1) { + sidName = getNameStringId(thing); + if (sidName != null && !sidName.isEmpty()) { sidName = utils.unpackString("@" + sidName.toString()); name = getString(sidName); - if (name.startsWith("@")) - { + if (name.startsWith("@")) { CustomerServiceLog("findItemInStructure", "Server localization for this item failed: " + getTemplateName(thing) + " (" + thing + ")."); } } } - String lowerCaseName = toLower(name); - int stringCheck = lowerCaseName.indexOf(keyword); - if (stringCheck > -1) - { + if (toLower(name).contains(keyword)) { utils.addElement(keywordMatchedIds, thing); utils.addElement(keywordMatchedNames, name); ++numMatches; } - if (numMatches >= 50) - { + if (numMatches >= 50) { prompt = utils.packStringId(new string_id("player_structure", "find_items_search_list_too_long_prompt")); break; } } - if (keywordMatchedIds == null || keywordMatchedIds.size() < 1) + if (keywordMatchedIds.size() < 1) { sendSystemMessage(player, new string_id("player_structure", "find_items_search_not_found")); return; } - if (keywordMatchedNames == null || keywordMatchedNames.size() < 1 || keywordMatchedIds.size() != keywordMatchedNames.size()) + if (keywordMatchedNames.size() < 1 || keywordMatchedIds.size() != keywordMatchedNames.size()) { return; } - String[] matchingItemsNameList = utils.toStaticStringArray(keywordMatchedNames); - obj_id[] matchingItemsList = utils.toStaticObjIdArray(keywordMatchedIds); - showSearchItemsListboxSui(self, player, matchingItemsList, matchingItemsNameList, prompt); - return; + showSearchItemsListboxSui(self, player, utils.toStaticObjIdArray(keywordMatchedIds), utils.toStaticStringArray(keywordMatchedNames), prompt); } public static void repeatSearchItemsKeywordList(obj_id self, obj_id player, obj_id[] matchingItemsList) throws InterruptedException { @@ -7441,9 +6798,7 @@ public class player_structure extends script.base_script String[] matchingItemsNamesList = new String[matchingItemsList.length]; for (int i = 0; i < matchingItemsList.length; i++) { - obj_id item = matchingItemsList[i]; - String itemName = getEncodedName(item); - matchingItemsNamesList[i] = itemName; + matchingItemsNamesList[i] = getEncodedName(matchingItemsList[i]); } String prompt = utils.packStringId(new string_id("player_structure", "find_items_search_list_prompt")); if (matchingItemsList.length >= 50) @@ -7451,12 +6806,18 @@ public class player_structure extends script.base_script prompt = utils.packStringId(new string_id("player_structure", "find_items_search_list_too_long_prompt")); } showSearchItemsListboxSui(self, player, matchingItemsList, matchingItemsNamesList, prompt); - return; } public static void showSearchItemsListboxSui(obj_id self, obj_id player, obj_id[] matchingItemsList, String[] matchingItemsNamesList, String prompt) throws InterruptedException { - String title = utils.packStringId(new string_id("player_structure", "find_items_search_list_title")); - int pid = sui.listbox(self, player, prompt, sui.OK_CANCEL, title, matchingItemsNamesList, "handlePlayerStructureSearchItemsSelectedResponse"); + int pid = sui.listbox( + self, + player, + prompt, + sui.OK_CANCEL, + utils.packStringId(new string_id("player_structure", "find_items_search_list_title")), + matchingItemsNamesList, + "handlePlayerStructureSearchItemsSelectedResponse" + ); if (pid > -1) { sui.setSUIProperty(pid, sui.LISTBOX_BTN_OK, sui.PROP_TEXT, "Retrieve Object"); @@ -7464,7 +6825,6 @@ public class player_structure extends script.base_script utils.setScriptVar(player, "findItems.pid", pid); utils.setScriptVar(self, "findItems.searchList", matchingItemsList); } - return; } public static void handleSearchItemsSelectedResponse(obj_id self, dictionary params) throws InterruptedException { @@ -7477,8 +6837,7 @@ public class player_structure extends script.base_script { return; } - int button = sui.getIntButtonPressed(params); - if (button == sui.BP_CANCEL) + if (sui.getIntButtonPressed(params) == sui.BP_CANCEL) { sendSystemMessage(player, new string_id("player_structure", "find_items_search_cancelled")); cleanupFindItemScriptVars(player); @@ -7509,7 +6868,6 @@ public class player_structure extends script.base_script } cleanupFindItemScriptVars(player); cleanupFindItemScriptVars(self); - return; } public static void removeStructureFromMaintenance(obj_id droid, obj_id pcd, int indexOfStructure) throws InterruptedException { @@ -7527,7 +6885,6 @@ public class player_structure extends script.base_script return; } obj_id[] new_struct_list = new obj_id[struct_list.length - 1]; - int currentIndex = 0; for (int i = 0; i < struct_list.length; i++) { if (i == indexOfStructure) diff --git a/sku.0/sys.server/compiled/game/script/library/player_version.java b/sku.0/sys.server/compiled/game/script/library/player_version.java old mode 100644 new mode 100755 index e12a362ee..3ffda9135 --- a/sku.0/sys.server/compiled/game/script/library/player_version.java +++ b/sku.0/sys.server/compiled/game/script/library/player_version.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.obj_id; -import script.library.utils; -import java.util.Arrays; import java.util.Vector; public class player_version extends script.base_script @@ -19,11 +11,7 @@ public class player_version extends script.base_script } public static boolean updateSkills(obj_id player) throws InterruptedException { - if (!isIdValid(player) || (!isPlayer(player))) - { - return false; - } - return true; + return !(!isIdValid(player) || (!isPlayer(player))); } public static void zeroPlayerSkillData(obj_id player) throws InterruptedException { @@ -34,26 +22,22 @@ public class player_version extends script.base_script String[] mods = getSkillStatModListingForPlayer(player); if ((mods != null) && (mods.length > 0)) { - for (int i = 0; i < mods.length; i++) - { - int val = getSkillStatMod(player, mods[i]); - applySkillStatisticModifier(player, mods[i], -val); + for (String mod : mods) { + applySkillStatisticModifier(player, mod, -getSkillStatMod(player, mod)); } } String[] cmds = getCommandListingForPlayer(player); if ((cmds != null) && (cmds.length > 0)) { - for (int i = 0; i < cmds.length; i++) - { - revokeCommand(player, cmds[i]); + for (String cmd : cmds) { + revokeCommand(player, cmd); } } int[] schematics = getSchematicListingForPlayer(player); if ((schematics != null) && (schematics.length > 0)) { - for (int i = 0; i < schematics.length; i++) - { - revokeSchematic(player, schematics[i]); + for (int schematic : schematics) { + revokeSchematic(player, schematic); } } } @@ -64,37 +48,34 @@ public class player_version extends script.base_script return null; } Vector ret = new Vector(); - for (int i = 0; i < skillList.length; i++) - { - LOG("playerVersion", "ordering skill = " + skillList[i]); - String[] reqs = getSkillPrerequisiteSkills(skillList[i]); - if ((reqs == null) || (reqs.length == 0)) - { + String[] reqs; + int idx; + int pos; + + for (String skill : skillList) { + LOG("playerVersion", "ordering skill = " + skill); + reqs = getSkillPrerequisiteSkills(skill); + if ((reqs == null) || (reqs.length == 0)) { LOG("playerVersion", " reqs = null || length = 0... appending..."); - ret.add(skillList[i]); - } - else - { - int idx = ret.size(); - for (int n = 0; n < reqs.length; n++) - { - LOG("playerVersion", " testing ret for: " + reqs[n]); - int pos = ret.indexOf(reqs[n]); - if (pos > -1) - { - LOG("playerVersion", "** found req(" + reqs[n] + ") at ret idx = " + pos); - if (pos < idx) - { + ret.add(skill); + } else { + idx = ret.size(); + for (String req : reqs) { + LOG("playerVersion", " testing ret for: " + req); + pos = ret.indexOf(req); + if (pos > -1) { + LOG("playerVersion", "** found req(" + req + ") at ret idx = " + pos); + if (pos < idx) { LOG("playerVersion", "** updating insert idx to " + pos); idx = pos; } } } - LOG("playerVersion", " - inserting " + skillList[i] + " @ idx = " + idx); - ret.add(idx, skillList[i]); + LOG("playerVersion", " - inserting " + skill + " @ idx = " + idx); + ret.add(idx, skill); } } - if ((ret == null) || (ret.size() == 0)) + if (ret.size() == 0) { return null; } diff --git a/sku.0/sys.server/compiled/game/script/library/poi.java b/sku.0/sys.server/compiled/game/script/library/poi.java old mode 100644 new mode 100755 index 2edc44b86..152c6ccda --- a/sku.0/sys.server/compiled/game/script/library/poi.java +++ b/sku.0/sys.server/compiled/game/script/library/poi.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.create; -import script.library.structure; -import script.library.utils; -import script.library.factions; -import script.library.scenario; -import script.library.chat; public class poi extends script.base_script { @@ -91,8 +78,7 @@ public class poi extends script.base_script } public static obj_id createObject(String template, float x, float z, int level) throws InterruptedException { - obj_id poiObject = getSelf(); - return createObject(poiObject, template, x, z, level); + return createObject(getSelf(), template, x, z, level); } public static obj_id createObject(obj_id poiObject, String name, String template, float x, float y) throws InterruptedException { @@ -110,8 +96,7 @@ public class poi extends script.base_script } public static obj_id createObject(String name, String template, float x, float y, int level) throws InterruptedException { - obj_id poiObject = getSelf(); - return createObject(poiObject, name, template, x, y, level); + return createObject(getSelf(), name, template, x, y, level); } public static obj_id createObject(obj_id poiObject, String strName, location locCenter) throws InterruptedException { @@ -120,9 +105,7 @@ public class poi extends script.base_script public static obj_id createObject(obj_id poiObject, String strName, location locCenter, int level) throws InterruptedException { location locHome = getLocation(poiObject); - float fltX = locCenter.x - locHome.x; - float fltZ = locCenter.z - locHome.z; - return createObject(poiObject, strName, fltX, fltZ, level); + return createObject(poiObject, strName, locCenter.x - locHome.x, locCenter.z - locHome.z, level); } public static obj_id createNpc(obj_id poiObject, String type, float x, float z) throws InterruptedException { @@ -161,8 +144,7 @@ public class poi extends script.base_script } public static obj_id createNpc(String type, float x, float z, int level) throws InterruptedException { - obj_id poiObject = getSelf(); - return createNpc(poiObject, type, x, z, level); + return createNpc(getSelf(), type, x, z, level); } public static obj_id createNpc(obj_id poiObject, String ident, String type, float x, float z) throws InterruptedException { @@ -252,8 +234,7 @@ public class poi extends script.base_script } public static obj_id createNpc(String ident, String type, float x, float z, int level) throws InterruptedException { - obj_id poiObject = getSelf(); - return createNpc(poiObject, ident, type, x, z, level); + return createNpc(getSelf(), ident, type, x, z, level); } public static obj_id findObject(obj_id poiObject, String name) throws InterruptedException { @@ -266,8 +247,7 @@ public class poi extends script.base_script } public static obj_id findObject(String name) throws InterruptedException { - obj_id poiObject = getSelf(); - return findObject(poiObject, name); + return findObject(getSelf(), name); } public static String findObjectName(obj_id poiObject) throws InterruptedException { @@ -275,8 +255,7 @@ public class poi extends script.base_script } public static String findObjectName() throws InterruptedException { - obj_id poiObject = getSelf(); - return findObjectName(poiObject); + return findObjectName(getSelf()); } public static void setDestroyMessage(obj_id poiObject, String name, String messageHandlerName, int delay) throws InterruptedException { @@ -303,8 +282,7 @@ public class poi extends script.base_script } public static void setDestroyMessage(String name, String messageHandlerName) throws InterruptedException { - obj_id poiObject = getSelf(); - setDestroyMessage(poiObject, name, messageHandlerName, 0); + setDestroyMessage(getSelf(), name, messageHandlerName, 0); } public static void setDestroyMessage(obj_id poiObject, String messageHandlerName, int delay) throws InterruptedException { @@ -320,13 +298,11 @@ public class poi extends script.base_script } public static void setDestroyMessage(String messageHandlerName, int delay) throws InterruptedException { - obj_id poiObject = getSelf(); - setDestroyMessage(poiObject, messageHandlerName, delay); + setDestroyMessage(getSelf(), messageHandlerName, delay); } public static void setDestroyMessage(String messageHandlerName) throws InterruptedException { - obj_id poiObject = getSelf(); - setDestroyMessage(poiObject, messageHandlerName, 0); + setDestroyMessage(getSelf(), messageHandlerName, 0); } public static void grantCredit(obj_id poiObject, obj_id player) throws InterruptedException { @@ -348,8 +324,7 @@ public class poi extends script.base_script } public static void grantCredit(obj_id player) throws InterruptedException { - obj_id poiObject = getSelf(); - grantCredit(poiObject, player); + grantCredit(getSelf(), player); } public static void removeCredit(obj_id poiObject, obj_id player) throws InterruptedException { @@ -366,8 +341,7 @@ public class poi extends script.base_script } public static void removeCredit(obj_id player) throws InterruptedException { - obj_id poiObject = getSelf(); - removeCredit(poiObject, player); + removeCredit(getSelf(), player); } public static void denyCredit(obj_id poiObject, obj_id player) throws InterruptedException { @@ -386,54 +360,31 @@ public class poi extends script.base_script } public static void denyCredit(obj_id player) throws InterruptedException { - obj_id poiObject = getSelf(); - denyCredit(poiObject, player); + denyCredit(getSelf(), player); } - public static boolean isGrantedCredit(obj_id poiObject, obj_id player) throws InterruptedException - { + public static boolean isGrantedCredit(obj_id poiObject, obj_id player) throws InterruptedException { obj_id poiBaseObject = getBaseObject(poiObject); - if (poiBaseObject == null || poiBaseObject == obj_id.NULL_ID) - { - return false; - } - String objVarName = player.toString(); - return isGrantedCredit(poiBaseObject, objVarName); + return !(poiBaseObject == null || poiBaseObject == obj_id.NULL_ID) && isGrantedCredit(poiBaseObject, player.toString()); } public static boolean isGrantedCredit(obj_id player) throws InterruptedException { - obj_id poiObject = getSelf(); - return isGrantedCredit(poiObject, player); + return isGrantedCredit(getSelf(), player); } public static boolean isGrantedCredit(obj_id poiBaseObject, String objVarName) throws InterruptedException { - if (hasObjVar(poiBaseObject, POI_CREDIT_LIST + "." + objVarName)) - { - return true; - } - return false; + return hasObjVar(poiBaseObject, POI_CREDIT_LIST + "." + objVarName); } - public static boolean isDeniedCredit(obj_id poiObject, obj_id player) throws InterruptedException - { + public static boolean isDeniedCredit(obj_id poiObject, obj_id player) throws InterruptedException { obj_id poiBaseObject = getBaseObject(poiObject); - if (poiBaseObject == null || poiBaseObject == obj_id.NULL_ID) - { - return false; - } - String objVarName = player.toString(); - return isDeniedCredit(poiBaseObject, objVarName); + return !(poiBaseObject == null || poiBaseObject == obj_id.NULL_ID) && isDeniedCredit(poiBaseObject, player.toString()); } public static boolean isDeniedCredit(obj_id player) throws InterruptedException { - obj_id poiObject = getSelf(); - return isDeniedCredit(poiObject, player); + return isDeniedCredit(getSelf(), player); } public static boolean isDeniedCredit(obj_id poiBaseObject, String objVarName) throws InterruptedException { - if (hasObjVar(poiBaseObject, POI_DENY_LIST + "." + objVarName)) - { - return true; - } - return false; + return hasObjVar(poiBaseObject, POI_DENY_LIST + "." + objVarName); } public static void addToStringList(obj_id element, String name) throws InterruptedException { @@ -452,8 +403,7 @@ public class poi extends script.base_script } public static void addToStringList(String name) throws InterruptedException { - obj_id poiObject = getSelf(); - addToStringList(poiObject, name); + addToStringList(getSelf(), name); } public static void removeFromStringList(obj_id element) throws InterruptedException { @@ -468,8 +418,7 @@ public class poi extends script.base_script } public static void removeFromStringList() throws InterruptedException { - obj_id poiObject = getSelf(); - removeFromStringList(poiObject); + removeFromStringList(getSelf()); } public static void removeFromStringList(obj_id poiObject, String name) throws InterruptedException { @@ -489,16 +438,13 @@ public class poi extends script.base_script } public static void removeFromStringList(String name) throws InterruptedException { - obj_id poiObject = getSelf(); - removeFromStringList(poiObject, name); + removeFromStringList(getSelf(), name); } public static void addToMasterList(obj_id poiBaseObject, obj_id elementToAdd) throws InterruptedException { - return; } public static void removeFromMasterList(obj_id poiBaseObject, obj_id elementToRemove) throws InterruptedException { - return; } public static boolean isInMasterList(obj_id poiBaseObject, obj_id element) throws InterruptedException { @@ -519,8 +465,7 @@ public class poi extends script.base_script } public static obj_id getBaseObject() throws InterruptedException { - obj_id poiObject = getSelf(); - return getBaseObject(poiObject); + return getBaseObject(getSelf()); } public static void baseObjectDestroyed(obj_id poiBaseObject) throws InterruptedException { @@ -561,7 +506,7 @@ public class poi extends script.base_script return getStringObjVar(poiBaseObject, POI_DIFFICULTY); } int difficulty = getIntObjVar(poiBaseObject, "intDifficulty"); - String diff = "easy"; + String diff; if (difficulty <= 4) { diff = "veryEasy"; @@ -587,36 +532,23 @@ public class poi extends script.base_script } public static String getDifficulty() throws InterruptedException { - obj_id poiObject = getSelf(); - return getDifficulty(poiObject); + return getDifficulty(getSelf()); } public static int getIntDifficulty() throws InterruptedException { - obj_id poiObject = getSelf(); - String diff = getDifficulty(poiObject); - if (diff.equals("veryEasy")) - { - return DIFF_VEASY; - } - else if (diff.equals("easy")) - { - return DIFF_EASY; - } - else if (diff.equals("medium")) - { - return DIFF_MEDIUM; - } - else if (diff.equals("hard")) - { - return DIFF_HARD; - } - else if (diff.equals("veryHard")) - { - return DIFF_VHARD; - } - else - { - return DIFF_UNKNOWN; + switch (getDifficulty(getSelf())) { + case "veryEasy": + return DIFF_VEASY; + case "easy": + return DIFF_EASY; + case "medium": + return DIFF_MEDIUM; + case "hard": + return DIFF_HARD; + case "veryHard": + return DIFF_VHARD; + default: + return DIFF_UNKNOWN; } } public static String getFaction(obj_id poiObject) throws InterruptedException @@ -630,8 +562,7 @@ public class poi extends script.base_script } public static String getFaction() throws InterruptedException { - obj_id poiObject = getSelf(); - return getFaction(poiObject); + return getFaction(getSelf()); } public static float getFactionValue(obj_id poiObject) throws InterruptedException { @@ -644,8 +575,7 @@ public class poi extends script.base_script } public static float getFactionValue() throws InterruptedException { - obj_id poiObject = getSelf(); - return getFactionValue(poiObject); + return getFactionValue(getSelf()); } public static String getObjective(obj_id poiObject) throws InterruptedException { @@ -658,8 +588,7 @@ public class poi extends script.base_script } public static String getObjective() throws InterruptedException { - obj_id poiObject = getSelf(); - return getObjective(poiObject); + return getObjective(getSelf()); } public static void setFaction(obj_id poiObject, String faction) throws InterruptedException { @@ -672,8 +601,7 @@ public class poi extends script.base_script } public static void setFaction(String faction) throws InterruptedException { - obj_id poiObject = getSelf(); - setFaction(poiObject, faction); + setFaction(getSelf(), faction); } public static void setFactionValue(obj_id poiObject, float factionValue) throws InterruptedException { @@ -686,8 +614,7 @@ public class poi extends script.base_script } public static void setFactionValue(float factionValue) throws InterruptedException { - obj_id poiObject = getSelf(); - setFactionValue(poiObject, factionValue); + setFactionValue(getSelf(), factionValue); } public static void complete(obj_id poiObject, int status) throws InterruptedException { @@ -700,13 +627,8 @@ public class poi extends script.base_script { return; } - switch (status) - { - case POI_SUCCESS: + if (status == POI_SUCCESS) { awardFactionStanding(poiBaseObject); - break; - case POI_FAIL: - break; } sendMissionStatus(poiBaseObject, status); messageTo(poiBaseObject, "cleanUpRoutine", null, 60, false); @@ -714,8 +636,7 @@ public class poi extends script.base_script } public static void complete(int status) throws InterruptedException { - obj_id poiObject = getSelf(); - complete(poiObject, status); + complete(getSelf(), status); } public static void complete(obj_id poiObject) throws InterruptedException { @@ -734,13 +655,11 @@ public class poi extends script.base_script } public static void complete() throws InterruptedException { - obj_id poiObject = getSelf(); - complete(poiObject); + complete(getSelf()); } public static void awardFactionStanding(obj_id poiBaseObject) throws InterruptedException { String faction = getFaction(poiBaseObject); - float factionValue = getFactionValue(poiBaseObject); if (faction == null) { return; @@ -750,12 +669,10 @@ public class poi extends script.base_script { return; } - int count = playerList.getNumItems(); - for (int i = 0; i < count; ++i) + + for (int i = 0; i < playerList.getNumItems(); ++i) { - obj_var playerVar = playerList.getObjVar(i); - obj_id player = utils.stringToObjId(playerVar.getName()); - factions.addFactionStanding(player, faction, factionValue); + factions.addFactionStanding(utils.stringToObjId(playerList.getObjVar(i).getName()), faction, getFactionValue(poiBaseObject)); } } public static void sendMissionStatus(obj_id poiBaseObject, int status) throws InterruptedException @@ -768,17 +685,17 @@ public class poi extends script.base_script switch (status) { case POI_SUCCESS: - messageTo(objMission, "destructionSuccess", null, 0, true); - break; + messageTo(objMission, "destructionSuccess", null, 0, true); + break; case POI_INCOMPLETE: - messageTo(objMission, "destructionIncomplete", null, 0, true); - break; + messageTo(objMission, "destructionIncomplete", null, 0, true); + break; case POI_FAIL: - messageTo(objMission, "destructionFail", null, 0, true); - break; + messageTo(objMission, "destructionFail", null, 0, true); + break; default: - messageTo(objMission, "destructionIncomplete", null, 0, true); - break; + messageTo(objMission, "destructionIncomplete", null, 0, true); + break; } } public static void baseObjectRemovedFromWorld(obj_id poiBaseObject) throws InterruptedException @@ -807,8 +724,7 @@ public class poi extends script.base_script } if (hasObjVar(poiObject, "npc_lair.target")) { - obj_id target = getObjIdObjVar(poiObject, "npc_lair.target"); - if (!exists(target)) + if (!exists(getObjIdObjVar(poiObject, "npc_lair.target"))) { return true; } @@ -817,8 +733,7 @@ public class poi extends script.base_script } public static boolean isComplete() throws InterruptedException { - obj_id poiObject = getSelf(); - return isComplete(poiObject); + return isComplete(getSelf()); } public static boolean setTitle(obj_id npc, String title) throws InterruptedException { @@ -832,26 +747,12 @@ public class poi extends script.base_script { return false; } - string_id titleid = new string_id(convo, title); - String name = getName(npc); - setName(npc, getString(titleid) + " " + name); + setName(npc, getString(new string_id(convo, title)) + " " + getName(npc)); return true; } - public static boolean isNpcTagged(obj_id npc, String tag) throws InterruptedException - { + public static boolean isNpcTagged(obj_id npc, String tag) throws InterruptedException { obj_id found = findObject(tag); - if ((found == null) || (found == obj_id.NULL_ID)) - { - return false; - } - else if (found == npc) - { - return true; - } - else - { - return false; - } + return !((found == null) || (found == obj_id.NULL_ID)) && found == npc; } public static boolean quickSay(obj_id npc, String speech) throws InterruptedException { @@ -861,7 +762,7 @@ public class poi extends script.base_script return false; } String convo = getStringObjVar(poiBaseObject, scenario.VAR_SCENARIO_CONVO); - if (convo.equals(null) || convo.equals("")) + if (convo == null || convo.equals("")) { return false; } @@ -890,9 +791,7 @@ public class poi extends script.base_script { return null; } - int count = getIntObjVar(poiBaseObject, scenario.VAR_MEDIATOR_COUNT); - int index = rand(0, count - 1); - return poi.findObject(scenario.MEDIATOR + "_" + index); + return poi.findObject(scenario.MEDIATOR + "_" + rand(0, getIntObjVar(poiBaseObject, scenario.VAR_MEDIATOR_COUNT) - 1)); } public static obj_id getRandomAntagonist(obj_id poiobj) throws InterruptedException { @@ -901,8 +800,6 @@ public class poi extends script.base_script { return null; } - int count = getIntObjVar(poiBaseObject, scenario.VAR_ANTAGONIST_COUNT); - int index = rand(0, count - 1); - return poi.findObject(scenario.ANTAGONIST + "_" + index); + return poi.findObject(scenario.ANTAGONIST + "_" + rand(0, getIntObjVar(poiBaseObject, scenario.VAR_ANTAGONIST_COUNT) - 1)); } } diff --git a/sku.0/sys.server/compiled/game/script/library/posture.java b/sku.0/sys.server/compiled/game/script/library/posture.java old mode 100644 new mode 100755 index c0cf967d9..578a94694 --- a/sku.0/sys.server/compiled/game/script/library/posture.java +++ b/sku.0/sys.server/compiled/game/script/library/posture.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; +import script.obj_id; public class posture extends script.base_script { diff --git a/sku.0/sys.server/compiled/game/script/library/powerup.java b/sku.0/sys.server/compiled/game/script/library/powerup.java old mode 100644 new mode 100755 index f4331f5c4..c1afae8c7 --- a/sku.0/sys.server/compiled/game/script/library/powerup.java +++ b/sku.0/sys.server/compiled/game/script/library/powerup.java @@ -1,18 +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 java.util.Enumeration; -import java.lang.Integer; -import script.library.combat; -import script.library.jedi; public class powerup extends script.base_script { @@ -61,46 +49,39 @@ public class powerup extends script.base_script if (ovl != null) { int numItems = ovl.getNumItems(); + String name; for (int i = 0; i < numItems; i++) { - obj_var ov = ovl.getObjVar(i); - String name = ov.getName(); - String varpath = powerup.VAR_POWERUP_BASE + "." + name; - float mod = getFloatObjVar(weapon, varpath); - String log; - if (name.equals("damage")) - { - names[idx] = "cat_pup.pup_damage"; - attribs[idx] = formatter.format(mod); - } - else if (name.equals("speed")) - { - names[idx] = "cat_pup.pup_speed"; - attribs[idx] = formatter.format(mod); - } - else if (name.equals("accuracy")) - { - names[idx] = "cat_pup.pup_accuracy"; - attribs[idx] = intFormat.format(mod); - } - else if (name.equals("wound")) - { - names[idx] = "cat_pup.pup_wound"; - attribs[idx] = formatter.format(mod); - } - else if (name.equals("elementalDamage")) - { - names[idx] = "cat_pup.pup_elemental"; - attribs[idx] = formatter.format(mod); - } - else if (name.equals("actionCost")) - { - names[idx] = "cat_pup.pup_action"; - attribs[idx] = formatter.format(mod); - } - else - { - idx--; + name = ovl.getObjVar(i).getName(); + float mod = getFloatObjVar(weapon, powerup.VAR_POWERUP_BASE + "." + name); + switch (name) { + case "damage": + names[idx] = "cat_pup.pup_damage"; + attribs[idx] = formatter.format(mod); + break; + case "speed": + names[idx] = "cat_pup.pup_speed"; + attribs[idx] = formatter.format(mod); + break; + case "accuracy": + names[idx] = "cat_pup.pup_accuracy"; + attribs[idx] = intFormat.format(mod); + break; + case "wound": + names[idx] = "cat_pup.pup_wound"; + attribs[idx] = formatter.format(mod); + break; + case "elementalDamage": + names[idx] = "cat_pup.pup_elemental"; + attribs[idx] = formatter.format(mod); + break; + case "actionCost": + names[idx] = "cat_pup.pup_action"; + attribs[idx] = formatter.format(mod); + break; + default: + idx--; + break; } idx++; } @@ -130,8 +111,7 @@ public class powerup extends script.base_script } if (hasPowerUpInstalled(target)) { - prose_package ppAlreadyPowered = prose.getPackage(PROSE_ALREADY_POWERED, target); - sendSystemMessageProse(player, ppAlreadyPowered); + sendSystemMessageProse(player, prose.getPackage(PROSE_ALREADY_POWERED, target)); return false; } int iGot = getGameObjectType(powerup); @@ -162,40 +142,38 @@ public class powerup extends script.base_script switch (powerupType) { case TYPE_MELEE: - if (!combat.isMeleeWeapon(target)) - { - sendSystemMessage(player, new string_id("powerup_d", "apply_fail_not_melee")); - LOG("powerup", "Melee weapon failure"); - return false; - } - break; + if (!combat.isMeleeWeapon(target)) + { + sendSystemMessage(player, new string_id("powerup_d", "apply_fail_not_melee")); + LOG("powerup", "Melee weapon failure"); + return false; + } + break; case TYPE_RANGED: - if (!combat.isRangedWeapon(target)) - { - sendSystemMessage(player, new string_id("powerup_d", "apply_fail_not_ranged")); - LOG("powerup", "Ranged weapon failure"); - return false; - } - break; + if (!combat.isRangedWeapon(target)) + { + sendSystemMessage(player, new string_id("powerup_d", "apply_fail_not_ranged")); + LOG("powerup", "Ranged weapon failure"); + return false; + } + break; case TYPE_GRENADE: - int weaponType = getWeaponType(target); - if (weaponType != WEAPON_TYPE_THROWN) - { - sendSystemMessage(player, new string_id("powerup_d", "apply_fail_not_grenade")); - LOG("powerup", "Grenade weapon failure"); - return false; - } - break; + if (getWeaponType(target) != WEAPON_TYPE_THROWN) + { + sendSystemMessage(player, new string_id("powerup_d", "apply_fail_not_grenade")); + LOG("powerup", "Grenade weapon failure"); + return false; + } + break; default: - sendSystemMessage(player, new string_id("powerup_d", "apply_failed_type_unknown")); - LOG("powerup", "Default faulure"); - return false; + sendSystemMessage(player, new string_id("powerup_d", "apply_failed_type_unknown")); + LOG("powerup", "Default faulure"); + return false; } String template = getTemplateName(powerup); if (template.equals("object/tangible/powerup/weapon/ranged_power.iff") || template.equals("object/tangible/powerup/weapon/melee_element_dispursal_tuner.iff")) { - int elementalDamage = getWeaponElementalValue(target); - if (elementalDamage < 1) + if (getWeaponElementalValue(target) < 1) { sendSystemMessage(player, new string_id("powerup_d", "apply_fail_no_elemental")); LOG("powerup", "Elemental failure"); @@ -212,34 +190,31 @@ public class powerup extends script.base_script if (ovl != null) { int numItems = ovl.getNumItems(); + obj_var ov; + String name; for (int i = 0; i < numItems; i++) { - obj_var ov = ovl.getObjVar(i); - String name = ov.getName(); - String varpath = VAR_POWERUP_BASE + "." + name; - if (name.equals("speed")) - { - speedMod = ov.getFloatData(); - } - else if (name.equals("damage")) - { - damageMod = ov.getFloatData(); - } - else if (name.equals("accuracy")) - { - accuracyMod = ov.getFloatData(); - } - else if (name.equals("wound")) - { - woundMod = ov.getFloatData(); - } - else if (name.equals("elementalDamage")) - { - elementalMod = ov.getFloatData(); - } - else if (name.equals("actionCost")) - { - actionMod = ov.getFloatData(); + ov = ovl.getObjVar(i); + name = ov.getName(); + switch (name) { + case "speed": + speedMod = ov.getFloatData(); + break; + case "damage": + damageMod = ov.getFloatData(); + break; + case "accuracy": + accuracyMod = ov.getFloatData(); + break; + case "wound": + woundMod = ov.getFloatData(); + break; + case "elementalDamage": + elementalMod = ov.getFloatData(); + break; + case "actionCost": + actionMod = ov.getFloatData(); + break; } } } @@ -306,8 +281,7 @@ public class powerup extends script.base_script LOG("powerup", "----------- Done Applying powerup ----------"); destroyObject(powerup); attachScript(target, SCRIPT_WEAPON); - prose_package ppApply = prose.getPackage(PROSE_POWERUP_APPLY, powerup, target); - sendSystemMessageProse(player, ppApply); + sendSystemMessageProse(player, prose.getPackage(PROSE_POWERUP_APPLY, powerup, target)); return true; } public static boolean cleanupWeaponPowerup(obj_id weapon) throws InterruptedException @@ -317,49 +291,46 @@ public class powerup extends script.base_script if (ovl != null) { int numItems = ovl.getNumItems(); + String name; + String varpath; for (int i = 0; i < numItems; i++) { - obj_var ov = ovl.getObjVar(i); - String name = ov.getName(); - String varpath = VAR_POWERUP_BASE + "." + name; - if (name.equals("speed")) - { - float curSpeed = getWeaponAttackSpeed(weapon); - float speedDiff = getFloatObjVar(weapon, varpath); - setWeaponAttackSpeed(weapon, curSpeed + speedDiff); - } - else if (name.equals("damage")) - { - int curMinDmg = getWeaponMinDamage(weapon); - float dmgDiff = getFloatObjVar(weapon, varpath); - setWeaponMinDamage(weapon, curMinDmg - (int)dmgDiff); - int curMaxDmg = getWeaponMaxDamage(weapon); - setWeaponMaxDamage(weapon, curMaxDmg - (int)dmgDiff); - } - else if (name.equals("accuracy")) - { - int curAcc = getWeaponAccuracy(weapon); - float accDiff = getFloatObjVar(weapon, varpath); - setWeaponAccuracy(weapon, curAcc - (int)accDiff); - } - else if (name.equals("wound")) - { - float curWound = getWeaponWoundChance(weapon); - float woundDiff = getFloatObjVar(weapon, varpath); - LOG("powerup", "Reverting wound: curWound=" + curWound + ", woundDiff=" + woundDiff + ", newWound=" + (curWound - woundDiff)); - setWeaponWoundChance(weapon, curWound - woundDiff); - } - else if (name.equals("elementalDamage")) - { - int curEDmg = getWeaponElementalValue(weapon); - float eDmgDiff = getFloatObjVar(weapon, varpath); - setWeaponElementalValue(weapon, curEDmg - (int)eDmgDiff); - } - else if (name.equals("actionCost")) - { - float curAction = getWeaponAttackCost(weapon); - float actionDiff = getFloatObjVar(weapon, varpath); - setWeaponAttackCost(weapon, (int)curAction - (int)actionDiff); + name = ovl.getObjVar(i).getName(); + varpath = VAR_POWERUP_BASE + "." + name; + switch (name) { + case "speed": + float curSpeed = getWeaponAttackSpeed(weapon); + float speedDiff = getFloatObjVar(weapon, varpath); + setWeaponAttackSpeed(weapon, curSpeed + speedDiff); + break; + case "damage": + int curMinDmg = getWeaponMinDamage(weapon); + float dmgDiff = getFloatObjVar(weapon, varpath); + setWeaponMinDamage(weapon, curMinDmg - (int) dmgDiff); + int curMaxDmg = getWeaponMaxDamage(weapon); + setWeaponMaxDamage(weapon, curMaxDmg - (int) dmgDiff); + break; + case "accuracy": + int curAcc = getWeaponAccuracy(weapon); + float accDiff = getFloatObjVar(weapon, varpath); + setWeaponAccuracy(weapon, curAcc - (int) accDiff); + break; + case "wound": + float curWound = getWeaponWoundChance(weapon); + float woundDiff = getFloatObjVar(weapon, varpath); + LOG("powerup", "Reverting wound: curWound=" + curWound + ", woundDiff=" + woundDiff + ", newWound=" + (curWound - woundDiff)); + setWeaponWoundChance(weapon, curWound - woundDiff); + break; + case "elementalDamage": + int curEDmg = getWeaponElementalValue(weapon); + float eDmgDiff = getFloatObjVar(weapon, varpath); + setWeaponElementalValue(weapon, curEDmg - (int) eDmgDiff); + break; + case "actionCost": + float curAction = getWeaponAttackCost(weapon); + float actionDiff = getFloatObjVar(weapon, varpath); + setWeaponAttackCost(weapon, (int) curAction - (int) actionDiff); + break; } } } @@ -385,8 +356,7 @@ public class powerup extends script.base_script { return; } - prose_package ppExpire = prose.getPackage(PROSE_POWERUP_EXPIRE, target); - sendSystemMessageProse(owner, ppExpire); + sendSystemMessageProse(owner, prose.getPackage(PROSE_POWERUP_EXPIRE, target)); return; } setObjVar(target, VAR_POWERUP_USES_LEFT, cnt); 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 28419bac8..4ef39e954 100755 --- a/sku.0/sys.server/compiled/game/script/library/utils.java +++ b/sku.0/sys.server/compiled/game/script/library/utils.java @@ -122,9 +122,8 @@ public class utils extends script.base_script if (fArray.length > 1) { float fSum = 0.0f; - for (int i = 0; i < fArray.length; i++) - { - fSum += fArray[i]; + for (float aFArray : fArray) { + fSum += aFArray; } float fRandom = rand() * fSum; fSum = 0.0f; @@ -184,30 +183,26 @@ public class utils extends script.base_script "pants1", "utility_belt" }; - obj_id curArmor = null; + obj_id curArmor; obj_id inv = utils.getInventoryContainer(player); String classTemplate = getSkillTemplate(player); - for (int i = 0; i < armorSlots.length; i++) - { - curArmor = getObjectInSlot(player, armorSlots[i]); - if ((isIdValid(curArmor) && !armor.isArmorCertified(player, curArmor)) || (isMando(curArmor) && !hasSpecialSkills(player))) - { + prose_package pp; + + for (String armorSlot : armorSlots) { + curArmor = getObjectInSlot(player, armorSlot); + if ((isIdValid(curArmor) && !armor.isArmorCertified(player, curArmor)) || (isMando(curArmor) && !hasSpecialSkills(player))) { totalUnequipped++; - prose_package pp = new prose_package(); + pp = new prose_package(); pp = prose.setStringId(pp, new string_id("spam", "armor_lost_cert")); pp = prose.setTT(pp, curArmor); sendSystemMessageProse(player, pp); putInOverloaded(curArmor, inv); } - if (!isIdNull(curArmor) && hasObjVar(curArmor, "armor.fake_armor") && hasObjVar(curArmor, "dynamic_item.required_skill")) - { - String requiredSkill = getStringObjVar(curArmor, "dynamic_item.required_skill"); - if (classTemplate != null && !classTemplate.equals("")) - { - if (!classTemplate.startsWith(requiredSkill)) - { + if (!isIdNull(curArmor) && hasObjVar(curArmor, "armor.fake_armor") && hasObjVar(curArmor, "dynamic_item.required_skill")) { + if (classTemplate != null && !classTemplate.equals("")) { + if (!classTemplate.startsWith(getStringObjVar(curArmor, "dynamic_item.required_skill"))) { totalUnequipped++; - prose_package pp = new prose_package(); + pp = new prose_package(); pp = prose.setStringId(pp, new string_id("spam", "armor_lost_cert")); pp = prose.setTT(pp, curArmor); sendSystemMessageProse(player, pp); @@ -219,23 +214,19 @@ public class utils extends script.base_script obj_id[] equipSlots = metrics.getWornItems(player); if (equipSlots != null && equipSlots.length > 0) { - for (int i = 0; i < equipSlots.length; i++) - { - if (!static_item.validateLevelRequired(player, (equipSlots[i]))) - { + for (obj_id equipSlot : equipSlots) { + if (!static_item.validateLevelRequired(player, (equipSlot))) { totalUnequipped++; - prose_package pp = new prose_package(); + pp = new prose_package(); pp = prose.setStringId(pp, new string_id("spam", "item_lost_cert")); - pp = prose.setTT(pp, equipSlots[i]); + pp = prose.setTT(pp, equipSlot); sendSystemMessageProse(player, pp); - putInOverloaded(equipSlots[i], inv); - } - else if (!static_item.validateLevelRequiredForWornEffect(player, (equipSlots[i]))) - { - static_item.removeWornBuffs(equipSlots[i], player); - prose_package pp = new prose_package(); + putInOverloaded(equipSlot, inv); + } else if (!static_item.validateLevelRequiredForWornEffect(player, (equipSlot))) { + static_item.removeWornBuffs(equipSlot, player); + pp = new prose_package(); pp = prose.setStringId(pp, new string_id("spam", "item_lost_cert_effect")); - pp = prose.setTT(pp, equipSlots[i]); + pp = prose.setTT(pp, equipSlot); sendSystemMessageProse(player, pp); } } @@ -244,7 +235,7 @@ public class utils extends script.base_script if (isIdValid(weapon) && !combat.hasCertification(player, weapon)) { totalUnequipped++; - prose_package pp = new prose_package(); + pp = new prose_package(); pp = prose.setStringId(pp, new string_id("spam", "weapon_lost_cert")); pp = prose.setTT(pp, weapon); sendSystemMessageProse(player, pp); @@ -255,7 +246,7 @@ public class utils extends script.base_script if (isIdValid(hold_l) && !performance.isDancePropCertified(player, hold_l)) { totalUnequipped++; - prose_package pp = new prose_package(); + pp = new prose_package(); pp = prose.setStringId(pp, new string_id("spam", "prop_lost_cert")); pp = prose.setTT(pp, hold_l); sendSystemMessageProse(player, pp); @@ -265,7 +256,7 @@ public class utils extends script.base_script if (isIdValid(hold_r) && !performance.isDancePropCertified(player, hold_r)) { totalUnequipped++; - prose_package pp = new prose_package(); + pp = new prose_package(); pp = prose.setStringId(pp, new string_id("spam", "prop_lost_cert")); pp = prose.setTT(pp, hold_r); sendSystemMessageProse(player, pp); @@ -275,7 +266,7 @@ public class utils extends script.base_script if (performance.isValidDanceProp(hold_l) && performance.isValidDanceProp(hold_r) && !hasCommand(player, "prop_dual_wield")) { totalUnequipped++; - prose_package pp = new prose_package(); + pp = new prose_package(); pp = prose.setStringId(pp, new string_id("spam", "dual_prop_lost_cert")); pp = prose.setTT(pp, hold_l); sendSystemMessageProse(player, pp); @@ -285,27 +276,21 @@ public class utils extends script.base_script obj_id[] appearanceItems = getAllItemsFromAppearanceInventory(player); if (appearanceItems != null && appearanceItems.length > 0) { - for (int i = 0; i < appearanceItems.length; ++i) - { - curArmor = appearanceItems[i]; - if ((isIdValid(curArmor) && !armor.isArmorCertified(player, curArmor)) || (isMando(curArmor) && !hasSpecialSkills(player))) - { + for (obj_id appearanceItem : appearanceItems) { + curArmor = appearanceItem; + if ((isIdValid(curArmor) && !armor.isArmorCertified(player, curArmor)) || (isMando(curArmor) && !hasSpecialSkills(player))) { totalUnequipped++; - prose_package pp = new prose_package(); + pp = new prose_package(); pp = prose.setStringId(pp, new string_id("spam", "armor_lost_cert")); pp = prose.setTT(pp, curArmor); sendSystemMessageProse(player, pp); putInOverloaded(curArmor, inv); } - if (!isIdNull(curArmor) && hasObjVar(curArmor, "armor.fake_armor") && hasObjVar(curArmor, "dynamic_item.required_skill")) - { - String requiredSkill = getStringObjVar(curArmor, "dynamic_item.required_skill"); - if (classTemplate != null && !classTemplate.equals("")) - { - if (!classTemplate.startsWith(requiredSkill)) - { + if (!isIdNull(curArmor) && hasObjVar(curArmor, "armor.fake_armor") && hasObjVar(curArmor, "dynamic_item.required_skill")) { + if (classTemplate != null && !classTemplate.equals("")) { + if (!classTemplate.startsWith(getStringObjVar(curArmor, "dynamic_item.required_skill"))) { totalUnequipped++; - prose_package pp = new prose_package(); + pp = new prose_package(); pp = prose.setStringId(pp, new string_id("spam", "armor_lost_cert")); pp = prose.setTT(pp, curArmor); sendSystemMessageProse(player, pp); @@ -313,19 +298,16 @@ public class utils extends script.base_script } } } - if (!static_item.validateLevelRequired(player, curArmor)) - { + if (!static_item.validateLevelRequired(player, curArmor)) { totalUnequipped++; - prose_package pp = new prose_package(); + pp = new prose_package(); pp = prose.setStringId(pp, new string_id("spam", "item_lost_cert")); pp = prose.setTT(pp, curArmor); sendSystemMessageProse(player, pp); putInOverloaded(curArmor, inv); - } - else if (!static_item.validateLevelRequiredForWornEffect(player, curArmor)) - { + } else if (!static_item.validateLevelRequiredForWornEffect(player, curArmor)) { static_item.removeWornBuffs(curArmor, player); - prose_package pp = new prose_package(); + pp = new prose_package(); pp = prose.setStringId(pp, new string_id("spam", "item_lost_cert_effect")); pp = prose.setTT(pp, curArmor); sendSystemMessageProse(player, pp); @@ -428,22 +410,15 @@ public class utils extends script.base_script { return false; } - for (int i = 0; i < objIdArray.length; i++) - { - if (objIdArray[i] == objTarget) - { + for (obj_id anObjIdArray : objIdArray) { + if (anObjIdArray == objTarget) { return true; } } return false; } - public static boolean isElementInArray(Vector objIdArray, Object objTarget) throws InterruptedException - { - if (objIdArray == null || objIdArray.isEmpty()) - { - return false; - } - return objIdArray.contains(objTarget); + public static boolean isElementInArray(Vector objIdArray, Object objTarget) throws InterruptedException { + return !(objIdArray == null || objIdArray.isEmpty()) && objIdArray.contains(objTarget); } public static int getElementPositionInArray(Vector array, Object element) throws InterruptedException { @@ -594,10 +569,7 @@ public class utils extends script.base_script { return null; } - for (int i = 0; i < objSourceArray.length; i++) - { - objDestinationArray[i] = objSourceArray[i]; - } + System.arraycopy(objSourceArray, 0, objDestinationArray, 0, objSourceArray.length); return objDestinationArray; } public static obj_id[] copyArray(obj_id[] oldArray, obj_id[] newArray) throws InterruptedException @@ -606,10 +578,7 @@ public class utils extends script.base_script { return null; } - for (int i = 0; i < oldArray.length; i++) - { - newArray[i] = oldArray[i]; - } + System.arraycopy(oldArray, 0, newArray, 0, oldArray.length); return newArray; } public static int[] copyArray(int[] oldArray, int[] newArray) throws InterruptedException @@ -618,10 +587,7 @@ public class utils extends script.base_script { return null; } - for (int i = 0; i < oldArray.length; i++) - { - newArray[i] = oldArray[i]; - } + System.arraycopy(oldArray, 0, newArray, 0, oldArray.length); return newArray; } public static float[] copyArray(float[] oldArray, float[] newArray) throws InterruptedException @@ -630,10 +596,7 @@ public class utils extends script.base_script { return null; } - for (int i = 0; i < oldArray.length; i++) - { - newArray[i] = oldArray[i]; - } + System.arraycopy(oldArray, 0, newArray, 0, oldArray.length); return newArray; } public static boolean[] copyArray(boolean[] oldArray, boolean[] newArray) throws InterruptedException @@ -642,10 +605,7 @@ public class utils extends script.base_script { return null; } - for (int i = 0; i < oldArray.length; i++) - { - newArray[i] = oldArray[i]; - } + System.arraycopy(oldArray, 0, newArray, 0, oldArray.length); return newArray; } public static String[] copyArray(String[] oldArray, String[] newArray) throws InterruptedException @@ -654,10 +614,7 @@ public class utils extends script.base_script { return null; } - for (int i = 0; i < oldArray.length; i++) - { - newArray[i] = oldArray[i]; - } + System.arraycopy(oldArray, 0, newArray, 0, oldArray.length); return newArray; } public static region[] copyArray(region[] oldArray, region[] newArray) throws InterruptedException @@ -666,10 +623,7 @@ public class utils extends script.base_script { return null; } - for (int i = 0; i < oldArray.length; i++) - { - newArray[i] = oldArray[i]; - } + System.arraycopy(oldArray, 0, newArray, 0, oldArray.length); return newArray; } public static location[] copyArray(location[] oldArray, location[] newArray) throws InterruptedException @@ -678,10 +632,7 @@ public class utils extends script.base_script { return null; } - for (int i = 0; i < oldArray.length; i++) - { - newArray[i] = oldArray[i]; - } + System.arraycopy(oldArray, 0, newArray, 0, oldArray.length); return newArray; } public static string_id[] copyArray(string_id[] oldArray, string_id[] newArray) throws InterruptedException @@ -690,10 +641,7 @@ public class utils extends script.base_script { return null; } - for (int i = 0; i < oldArray.length; i++) - { - newArray[i] = oldArray[i]; - } + System.arraycopy(oldArray, 0, newArray, 0, oldArray.length); return newArray; } public static attrib_mod[] copyArray(attrib_mod[] oldArray, attrib_mod[] newArray) throws InterruptedException @@ -702,10 +650,7 @@ public class utils extends script.base_script { return null; } - for (int i = 0; i < oldArray.length; i++) - { - newArray[i] = oldArray[i]; - } + System.arraycopy(oldArray, 0, newArray, 0, oldArray.length); return newArray; } public static String[] copyArrayOfRange(String[] oldArray, String[] newArray, int startIndex, int stopIndex) throws InterruptedException @@ -760,8 +705,7 @@ public class utils extends script.base_script { return null; } - obj_id objObject = obj_id.getObjId(lngId.longValue()); - return objObject; + return obj_id.getObjId(lngId.longValue()); } public static obj_id[] stringToObjId(String[] text) throws InterruptedException { @@ -892,10 +836,6 @@ public class utils extends script.base_script return null; } Vector ret = new Vector(Arrays.asList(array)); - if (ret == null) - { - return null; - } if (elements == null || elements.length == 0) { return ret; @@ -991,10 +931,8 @@ public class utils extends script.base_script { return false; } - for (int i = 0; i < items.length; i++) - { - if (getDistance2D(loc, getLocation(items[i])) < dist) - { + for (obj_id item : items) { + if (getDistance2D(loc, getLocation(item)) < dist) { return false; } } @@ -1011,14 +949,8 @@ public class utils extends script.base_script return array1; } obj_id[] toPass = new obj_id[array1.length + array2.length]; - for (int i = 0; i < array1.length; i++) - { - toPass[i] = array1[i]; - } - for (int i = 0; i < array2.length; i++) - { - toPass[i + array1.length] = array2[i]; - } + System.arraycopy(array1, 0, toPass, 0, array1.length); + System.arraycopy(array2, 0, toPass, array1.length, array2.length); return toPass; } public static Vector concatArrays(Vector array1, Vector array2) throws InterruptedException @@ -1056,7 +988,7 @@ public class utils extends script.base_script Object[] toPass = new Object[array2.length]; for (int i = 0; i < array2.length; i++) { - toPass[i] = new Integer(array2[i]); + toPass[i] = array2[i]; } return concatArrays(array1, toPass); } @@ -1069,7 +1001,7 @@ public class utils extends script.base_script Object[] toPass = new Object[array2.length]; for (int i = 0; i < array2.length; i++) { - toPass[i] = new Float(array2[i]); + toPass[i] = array2[i]; } return concatArrays(array1, toPass); } @@ -1082,7 +1014,7 @@ public class utils extends script.base_script Object[] toPass = new Object[array2.length]; for (int i = 0; i < array2.length; i++) { - toPass[i] = new Boolean(array2[i]); + toPass[i] = array2[i]; } return concatArrays(array1, toPass); } @@ -1097,14 +1029,8 @@ public class utils extends script.base_script return array1; } String[] toPass = new String[array1.length + array2.length]; - for (int i = 0; i < array1.length; i++) - { - toPass[i] = array1[i]; - } - for (int i = 0; i < array2.length; i++) - { - toPass[i + array1.length] = array2[i]; - } + System.arraycopy(array1, 0, toPass, 0, array1.length); + System.arraycopy(array2, 0, toPass, array1.length, array2.length); return toPass; } public static boolean isSubset(obj_id[] array1, obj_id[] array2) throws InterruptedException @@ -1175,21 +1101,15 @@ public class utils extends script.base_script } Vector nameList = new Vector(); nameList.setSize(0); - for (int i = 0; i < players.length; i++) - { - if (isPlayer(players[i])) - { - nameList = addElement(nameList, getName(players[i])); + for (obj_id player : players) { + if (isPlayer(player)) { + nameList = addElement(nameList, getName(player)); } } if (nameList.size() == players.length) { - String[] _nameList = new String[0]; - if (nameList != null) - { - _nameList = new String[nameList.size()]; - nameList.toArray(_nameList); - } + String[] _nameList = new String[nameList.size()]; + nameList.toArray(_nameList); return _nameList; } else @@ -1205,26 +1125,20 @@ public class utils extends script.base_script } Vector nameList = new Vector(); nameList.setSize(0); - obj_id self = getSelf(); - for (int i = 0; i < targets.length; i++) - { - if (isIdValid(targets[i])) - { - String itemName = getEncodedName(targets[i]); - if (itemName != null) - { + String itemName; + + for (obj_id target : targets) { + if (isIdValid(target)) { + itemName = getEncodedName(target); + if (itemName != null) { nameList = addElement(nameList, itemName); } } } if (nameList.size() == targets.length) { - String[] _nameList = new String[0]; - if (nameList != null) - { - _nameList = new String[nameList.size()]; - nameList.toArray(_nameList); - } + String[] _nameList = new String[nameList.size()]; + nameList.toArray(_nameList); return _nameList; } else @@ -1252,11 +1166,7 @@ public class utils extends script.base_script { return true; } - if (getObjIdObjVar(target, VAR_OWNER) == player) - { - return true; - } - return false; + return getObjIdObjVar(target, VAR_OWNER) == player; } public static boolean isCoOwner(obj_id target, obj_id player) throws InterruptedException { @@ -1269,11 +1179,7 @@ public class utils extends script.base_script { return false; } - if (getElementPositionInArray(coowners, player) > -1) - { - return true; - } - return false; + return getElementPositionInArray(coowners, player) > -1; } public static obj_id[] getContents(obj_id container, boolean recurse, Vector excludedNodes) throws InterruptedException { @@ -1319,15 +1225,22 @@ public class utils extends script.base_script { exclude = false; } + obj_id item; + boolean keepItem; + int idx; + int itemGameObjectType; + int containerType; + obj_id[] newContents; + for (int i = 0; i < contents.size(); i++) { - obj_id item = ((obj_id)contents.get(i)); + item = ((obj_id)contents.get(i)); if (isIdValid(item)) { - boolean keepItem = true; + keepItem = true; if (exclude) { - int idx = excludedNodes.indexOf(item); + idx = excludedNodes.indexOf(item); if (idx > -1) { contents = removeElementAt(contents, i); @@ -1337,13 +1250,13 @@ public class utils extends script.base_script } if (keepItem) { - int itemGameObjectType = getGameObjectType(item); + itemGameObjectType = getGameObjectType(item); if (itemGameObjectType != GOT_misc_factory_crate && itemGameObjectType != GOT_chronicles_quest_holocron) { - int containerType = getContainerType(item); + containerType = getContainerType(item); if (containerType != 0) { - obj_id[] newContents = getContents(item); + newContents = getContents(item); if (newContents != null) { contents = concatArrays(contents, newContents); @@ -1385,8 +1298,7 @@ public class utils extends script.base_script return null; } Vector toExclude = addElement(null, bank); - obj_id[] contents = getContents(player, true, toExclude); - return contents; + return getContents(player, true, toExclude); } public static obj_id[] getFilteredPlayerContents(obj_id player) throws InterruptedException { @@ -1398,7 +1310,7 @@ public class utils extends script.base_script obj_id bank = getPlayerBank(player); if (isIdValid(bank)) { - toExclude = addElement(toExclude, bank); + toExclude = addElement(null, bank); } obj_id missionBag = getMissionBag(player); if (isIdValid(missionBag)) @@ -1425,21 +1337,15 @@ public class utils extends script.base_script { return null; } - for (int i = 0; i < allObjects.length; i++) - { - if (getObjIdObjVar(allObjects[i], VAR_OWNER) == player) - { - ownedObjects = addElement(ownedObjects, allObjects[i]); + for (obj_id allObject : allObjects) { + if (getObjIdObjVar(allObject, VAR_OWNER) == player) { + ownedObjects = addElement(ownedObjects, allObject); } } if (ownedObjects.size() > 0) { - obj_id[] _ownedObjects = new obj_id[0]; - if (ownedObjects != null) - { - _ownedObjects = new obj_id[ownedObjects.size()]; - ownedObjects.toArray(_ownedObjects); - } + obj_id[] _ownedObjects = new obj_id[ownedObjects.size()]; + ownedObjects.toArray(_ownedObjects); return _ownedObjects; } return null; @@ -1479,19 +1385,11 @@ public class utils extends script.base_script } else { - obj_id player = getContainingPlayer(item); - obj_id bank = getPlayerBank(player); + obj_id bank = getPlayerBank(getContainingPlayer(item)); if (isIdValid(bank)) { obj_id containedBy = getContainedBy(item); - if (containedBy == bank) - { - return false; - } - else - { - return true; - } + return containedBy != bank; } else { @@ -1520,11 +1418,7 @@ public class utils extends script.base_script { return false; } - if (isIdValid(getContainingNpcCreature(item))) - { - return true; - } - return false; + return isIdValid(getContainingNpcCreature(item)); } public static obj_id getContainingNpcCreature(obj_id item) throws InterruptedException { @@ -1560,11 +1454,8 @@ public class utils extends script.base_script obj_id[] objContents = getContents(objInventory, true); if (objContents != null) { - for (int intI = 0; intI < objContents.length; intI++) - { - String strItemTemplate = getTemplateName(objContents[intI]); - if (strItemTemplate.equals(strTemplate)) - { + for (obj_id objContent : objContents) { + if (getTemplateName(objContent).equals(strTemplate)) { return true; } } @@ -1580,17 +1471,13 @@ public class utils extends script.base_script LOG("utils", "playerHasItemByTemplateInDataPad::pDataPad " + pDataPad); obj_id[] objContents = getContents(pDataPad, true); LOG("utils", "playerHasItemByTemplateInDataPad::objContents.length " + objContents.length); - if (objContents != null) - { - for (int intI = 0; intI < objContents.length; intI++) - { - String strItemTemplate = getTemplateName(objContents[intI]); - LOG("utils", "playerHasItemByTemplateInDataPad::strItemTemplate " + strItemTemplate); - LOG("utils", "playerHasItemByTemplateInDataPad::strTemplate " + strTemplate); - if (strItemTemplate.equals(strTemplate)) - { - return true; - } + String strItemTemplate; + for (obj_id objContent : objContents) { + strItemTemplate = getTemplateName(objContent); + LOG("utils", "playerHasItemByTemplateInDataPad::strItemTemplate " + strItemTemplate); + LOG("utils", "playerHasItemByTemplateInDataPad::strTemplate " + strTemplate); + if (strItemTemplate.equals(strTemplate)) { + return true; } } } @@ -1609,11 +1496,11 @@ public class utils extends script.base_script obj_id[] objContents = getContents(pDataPad, recurse); if (objContents != null) { - for (int intI = 0; intI < objContents.length; intI++) - { - String strItemTemplate = getTemplateName(objContents[intI]); - if (strItemTemplate.equals(strTemplate)) - { + String strItemTemplate; + + for (obj_id objContent : objContents) { + strItemTemplate = getTemplateName(objContent); + if (strItemTemplate.equals(strTemplate)) { ++count; } } @@ -1626,11 +1513,8 @@ public class utils extends script.base_script obj_id[] contents = getInventoryAndEquipment(player); if (contents != null) { - for (int i = 0; i < contents.length; i++) - { - String inventoryObject = getTemplateName(contents[i]); - if (inventoryObject.equals(desiredTemplate)) - { + for (obj_id content : contents) { + if (getTemplateName(content).equals(desiredTemplate)) { return true; } } @@ -1642,12 +1526,9 @@ public class utils extends script.base_script obj_id[] contents = getInventoryAndEquipment(player); if (contents != null) { - for (int i = 0; i < contents.length; i++) - { - String inventoryObject = getTemplateName(contents[i]); - if (inventoryObject.equals(desiredTemplate)) - { - return contents[i]; + for (obj_id content : contents) { + if (getTemplateName(content).equals(desiredTemplate)) { + return content; } } } @@ -1658,10 +1539,8 @@ public class utils extends script.base_script obj_id[] contents = getInventoryAndEquipment(player); if (contents != null) { - for (int i = 0; i < contents.length; i++) - { - if (hasObjVar(contents[i], desiredObjVar)) - { + for (obj_id content : contents) { + if (hasObjVar(content, desiredObjVar)) { return true; } } @@ -1673,13 +1552,9 @@ public class utils extends script.base_script obj_id[] contents = getInventoryAndEquipment(player); if (contents != null) { - for (int i = 0; i < contents.length; i++) - { - String inventoryObject = getTemplateName(contents[i]); - if (inventoryObject.equals(desiredTemplate)) - { - if (hasObjVar(contents[i], desiredObjVar)) - { + for (obj_id content : contents) { + if (getTemplateName(content).equals(desiredTemplate)) { + if (hasObjVar(content, desiredObjVar)) { return true; } } @@ -1695,11 +1570,8 @@ public class utils extends script.base_script obj_id[] objContents = getContents(objBank, true); if (objContents != null) { - for (int i = 0; i < objContents.length; i++) - { - String strItemTemplate = getTemplateName(objContents[i]); - if (strItemTemplate.equals(strTemplate)) - { + for (obj_id objContent : objContents) { + if (getTemplateName(objContent).equals(strTemplate)) { return true; } } @@ -1726,14 +1598,13 @@ public class utils extends script.base_script public static obj_id getStaticItemInBankOrInventory(obj_id player, String staticItem) throws InterruptedException { obj_id[] contents = getInventoryAndEquipment(player); + String itemName; if (contents != null && contents.length > 0) { - for (int i = 0; i < contents.length; i++) - { - String itemName = getStaticItemName(contents[i]); - if (itemName != null && staticItem != null && staticItem.equals(itemName)) - { - return contents[i]; + for (obj_id content : contents) { + itemName = getStaticItemName(content); + if (itemName != null && staticItem != null && staticItem.equals(itemName)) { + return content; } } } @@ -1743,12 +1614,10 @@ public class utils extends script.base_script contents = getContents(bank, true); if (contents != null && contents.length > 0) { - for (int i = 0; i < contents.length; i++) - { - String itemName = static_item.getStaticItemName(contents[i]); - if (itemName != null && staticItem != null && staticItem.equals(itemName)) - { - return contents[i]; + for (obj_id content : contents) { + itemName = static_item.getStaticItemName(content); + if (itemName != null && staticItem != null && staticItem.equals(itemName)) { + return content; } } } @@ -1766,12 +1635,12 @@ public class utils extends script.base_script { if (contents != null && contents.length > 0) { - for (int i = 0; i < contents.length; i++) - { - String itemName = getStaticItemName(contents[i]); - if (itemName != null && staticItem != null && staticItem.equals(itemName)) - { - return contents[i]; + String itemName; + + for (obj_id content : contents) { + itemName = getStaticItemName(content); + if (itemName != null && staticItem != null && staticItem.equals(itemName)) { + return content; } } } @@ -1787,16 +1656,11 @@ public class utils extends script.base_script obj_id[] contents = getInventoryAndEquipment(player); if (contents != null && contents.length > 0) { - for (int i = 0; i < contents.length; i++) - { - if (contents[i] != null) - { - if (static_item.isStaticItem(contents[i])) - { - String itemName = getStaticItemName(contents[i]); - if (itemName.equals(staticItem)) - { - objectList = addElement(objectList, contents[i]); + for (obj_id content : contents) { + if (content != null) { + if (static_item.isStaticItem(content)) { + if (getStaticItemName(content).equals(staticItem)) { + objectList = addElement(objectList, content); } } } @@ -1816,12 +1680,11 @@ public class utils extends script.base_script obj_id[] contents = getInventoryAndEquipment(player); if (contents != null && contents.length > 0) { - for (int i = 0; i < contents.length; i++) - { - String itemName = getStaticItemName(contents[i]); - if (itemName != null && staticItem != null && staticItem.equals(itemName)) - { - return contents[i]; + String itemName; + for (obj_id content : contents) { + itemName = getStaticItemName(content); + if (itemName != null && staticItem != null && staticItem.equals(itemName)) { + return content; } } } @@ -1829,13 +1692,7 @@ public class utils extends script.base_script } public static int countOfStackedItemsInArray(obj_id[] items) throws InterruptedException { - int totalCount = 0; - for (int i = 0; i < items.length; i++) - { - int itemCount = getCount(items[i]); - totalCount = itemCount + totalCount; - } - return totalCount; + return items.length; } public static obj_id getItemPlayerHasByTemplate(obj_id objPlayer, String strTemplate) throws InterruptedException { @@ -1845,12 +1702,9 @@ public class utils extends script.base_script obj_id[] objContents = getContents(objInventory, true); if (objContents != null) { - for (int i = 0; i < objContents.length; i++) - { - String strItemTemplate = getTemplateName(objContents[i]); - if (strItemTemplate.equals(strTemplate)) - { - return objContents[i]; + for (obj_id objContent : objContents) { + if (getTemplateName(objContent).equals(strTemplate)) { + return objContent; } } } @@ -1865,12 +1719,9 @@ public class utils extends script.base_script obj_id[] objContents = getContents(pDataPad, true); if (objContents != null) { - for (int i = 0; i < objContents.length; i++) - { - String strItemTemplate = getTemplateName(objContents[i]); - if (strItemTemplate.equals(strTemplate)) - { - return objContents[i]; + for (obj_id objContent : objContents) { + if (getTemplateName(objContent).equals(strTemplate)) { + return objContent; } } } @@ -1885,12 +1736,9 @@ public class utils extends script.base_script obj_id[] objContents = getContents(objBank, true); if (objContents != null) { - for (int i = 0; i < objContents.length; i++) - { - String strItemTemplate = getTemplateName(objContents[i]); - if (strItemTemplate.equals(strTemplate)) - { - return objContents[i]; + for (obj_id objContent : objContents) { + if (getTemplateName(objContent).equals(strTemplate)) { + return objContent; } } } @@ -1950,19 +1798,14 @@ public class utils extends script.base_script obj_id[] objContents = getContents(container, recurse); if (objContents != null) { - for (int intI = 0; intI < objContents.length; intI++) - { - String itemTemplate = getTemplateName(objContents[intI]); - if (itemTemplate.equals(template)) - { - if (!allowEquipped) - { - if (isEquipped(objContents[intI])) - { + for (obj_id objContent : objContents) { + if (getTemplateName(objContent).equals(template)) { + if (!allowEquipped) { + if (isEquipped(objContent)) { continue; } } - objectList = addElement(objectList, objContents[intI]); + objectList = addElement(objectList, objContent); } } } @@ -2010,12 +1853,9 @@ public class utils extends script.base_script obj_id[] objContents = getContents(container, recurse); if (objContents != null) { - for (int intI = 0; intI < objContents.length; intI++) - { - String itemTemplate = getTemplateName(objContents[intI]); - if (itemTemplate.startsWith(template)) - { - objectList = addElement(objectList, objContents[intI]); + for (obj_id objContent : objContents) { + if (getTemplateName(objContent).startsWith(template)) { + objectList = addElement(objectList, objContent); } } } @@ -2040,12 +1880,9 @@ public class utils extends script.base_script obj_id[] objContents = getContents(objInventory, true); if (objContents != null) { - for (int i = 0; i < objContents.length; i++) - { - String strItemTemplate = getTemplateName(objContents[i]); - if (strItemTemplate.equals(strTemplate)) - { - objectList = addElement(objectList, objContents[i]); + for (obj_id objContent : objContents) { + if (getTemplateName(objContent).equals(strTemplate)) { + objectList = addElement(objectList, objContent); } } } @@ -2056,12 +1893,9 @@ public class utils extends script.base_script obj_id[] objContents = getContents(objBank, true); if (objContents != null) { - for (int j = 0; j < objContents.length; j++) - { - String strItemTemplate = getTemplateName(objContents[j]); - if (strItemTemplate.equals(strTemplate)) - { - objectList = addElement(objectList, objContents[j]); + for (obj_id objContent : objContents) { + if (getTemplateName(objContent).equals(strTemplate)) { + objectList = addElement(objectList, objContent); } } } @@ -2080,9 +1914,8 @@ public class utils extends script.base_script obj_id[] objContents = getInventoryAndEquipment(objPlayer); if (objContents != null) { - for (int i = 0; i < objContents.length; i++) - { - objectList = addElement(objectList, objContents[i]); + for (obj_id objContent : objContents) { + objectList = addElement(objectList, objContent); } } obj_id objBank = getPlayerBank(objPlayer); @@ -2091,9 +1924,8 @@ public class utils extends script.base_script objContents = getContents(objBank, true); if (objContents != null) { - for (int j = 0; j < objContents.length; j++) - { - objectList = addElement(objectList, objContents[j]); + for (obj_id objContent : objContents) { + objectList = addElement(objectList, objContent); } } } @@ -2107,13 +1939,9 @@ public class utils extends script.base_script } public static location getRandomLocationInRing(location locOrigin, float fltMinDistance, float fltMaxDistance) throws InterruptedException { - float fltRand = rand(); - float fltDistance = (fltMaxDistance - fltMinDistance) * fltRand + fltMinDistance; - obj_id objTest = null; - debugServerConsoleMsg(objTest, "fltDistance is " + fltDistance); - float fltAngle = rand(0, 360); - locOrigin = rotatePointXZ(locOrigin, fltDistance, fltAngle); - return locOrigin; + float fltDistance = (fltMaxDistance - fltMinDistance) * rand() + fltMinDistance; + debugServerConsoleMsg(null, "fltDistance is " + fltDistance); + return rotatePointXZ(locOrigin, fltDistance, rand(0, 360)); } public static location rotatePointXZ(location locOrigin, float fltDistance, float fltAngle) throws InterruptedException { @@ -2168,9 +1996,7 @@ public class utils extends script.base_script { return null; } - float yaw = getYaw(target); - location newLoc = rotatePointXZ(origin, distance, yaw); - return newLoc; + return rotatePointXZ(origin, distance, getYaw(target)); } public static attrib_mod createAttribMod(int attrib, int value, float duration, float attack, float decay) throws InterruptedException { @@ -2243,31 +2069,30 @@ public class utils extends script.base_script float duration = am.getDuration(); int amt = am.getValue(); int attack = (int)(am.getAttack()); - int decay = (int)(am.getDecay()); if (attack < 0) { switch (attack) { case (int)healing.AM_HEAL_WOUND: - if (amt < 0) - { - amt = 0; - } - break; + if (amt < 0) + { + amt = 0; + } + break; case (int)healing.AM_HEAL_SHOCK: - if (amt < 0) - { - amt = 0; - } - litmus &= healShockWound(target, amt); - break; + if (amt < 0) + { + amt = 0; + } + litmus = healShockWound(target, amt); + break; case (int)healing.AM_ADD_SHOCK: - if (amt < 0) - { - amt = 0; - } - litmus &= addShockWound(target, amt); - break; + if (amt < 0) + { + amt = 0; + } + litmus = addShockWound(target, amt); + break; } } else @@ -2286,19 +2111,13 @@ public class utils extends script.base_script return false; } boolean ret = true; - for (int i = 0; i < am.length; i++) - { - ret &= addAttribMod(target, am[i]); + for (attrib_mod anAm : am) { + ret &= addAttribMod(target, anAm); } return ret; } - public static boolean setHeading(obj_id target, float heading) throws InterruptedException - { - if (target == null) - { - return false; - } - return setYaw(target, heading); + public static boolean setHeading(obj_id target, float heading) throws InterruptedException { + return target != null && setYaw(target, heading); } public static dictionary parseKeyPairList(String keyPairList, char delim) throws InterruptedException { @@ -2312,14 +2131,14 @@ public class utils extends script.base_script { return null; } - for (int i = 0; i < pairs.length; i++) - { - String[] tmp = split(pairs[i], '='); - if ((tmp != null) && (tmp.length == 2)) - { - int val = stringToInt(tmp[1]); - if (val != -1) - { + String[] tmp; + int val; + + for (String pair : pairs) { + tmp = split(pair, '='); + if ((tmp != null) && (tmp.length == 2)) { + val = stringToInt(tmp[1]); + if (val != -1) { d.put(tmp[0], val); } } @@ -2330,31 +2149,19 @@ public class utils extends script.base_script { return parseKeyPairList(keyPairList, ','); } - public static boolean putInPlayerInventory(obj_id player, obj_id item) throws InterruptedException - { - if ((!isIdValid(player)) || (!isPlayer(player)) || (item == null)) - { + public static boolean putInPlayerInventory(obj_id player, obj_id item) throws InterruptedException { + if ((!isIdValid(player)) || (!isPlayer(player)) || (item == null)) { return false; } obj_id inventory = getObjectInSlot(player, SLOT_INVENTORY); - if (inventory == null) - { - return false; - } - return putIn(item, inventory); + return inventory != null && putIn(item, inventory); } - public static boolean putInPlayerDatapad(obj_id player, obj_id item) throws InterruptedException - { - if ((!isIdValid(player)) || (!isPlayer(player)) || (item == null)) - { + public static boolean putInPlayerDatapad(obj_id player, obj_id item) throws InterruptedException { + if ((!isIdValid(player)) || (!isPlayer(player)) || (item == null)) { return false; } obj_id datapad = getObjectInSlot(player, SLOT_DATAPAD); - if (datapad == null) - { - return false; - } - return putIn(item, datapad); + return datapad != null && putIn(item, datapad); } public static obj_id getInventoryContainer(obj_id target) throws InterruptedException { @@ -2447,8 +2254,7 @@ public class utils extends script.base_script { return null; } - String strPackedId = "@" + strId.getTable() + ":" + strId.getAsciiId(); - return strPackedId; + return "@" + strId.getTable() + ":" + strId.getAsciiId(); } public static string_id unpackString(String strId) throws InterruptedException { @@ -2476,13 +2282,14 @@ public class utils extends script.base_script obj_id[] players = getPlayerCreaturesInRange(actor, 128.0f); if (players != null) { - for (int i = 0; i < players.length; ++i) - { - java.util.StringTokenizer st2 = new java.util.StringTokenizer(getName(players[i])); - String playerName = toLower(st2.nextToken()); - if (compareName.equals(playerName)) - { - return players[i]; + StringTokenizer st2; + String playerName; + + for (obj_id player : players) { + st2 = new StringTokenizer(getName(player)); + playerName = toLower(st2.nextToken()); + if (compareName.equals(playerName)) { + return player; } } } @@ -2498,7 +2305,6 @@ public class utils extends script.base_script cbtAttackerResults.endPosture = intPosture; cbtAttackerResults.weapon = null; doCombatResults(strPlayback, cbtAttackerResults, null); - return; } public static obj_id[] getBuildingsInObjIdList(obj_id[] items) throws InterruptedException { @@ -2508,14 +2314,9 @@ public class utils extends script.base_script } Vector buildings = new Vector(); buildings.setSize(0); - for (int i = 0; i < items.length; i++) - { - if (getCellNames(items[i]) == null) - { - } - else - { - buildings = addElement(buildings, items[i]); + for (obj_id item : items) { + if (getCellNames(item) != null) { + buildings = addElement(buildings, item); } } if ((buildings == null) || (buildings.size() == 0)) @@ -2525,11 +2326,8 @@ public class utils extends script.base_script else { obj_id[] _buildings = new obj_id[0]; - if (buildings != null) - { - _buildings = new obj_id[buildings.size()]; - buildings.toArray(_buildings); - } + _buildings = new obj_id[buildings.size()]; + buildings.toArray(_buildings); return _buildings; } } @@ -2550,21 +2348,15 @@ public class utils extends script.base_script } Vector ret = new Vector(); ret.setSize(0); - for (int i = 0; i < contents.length; i++) - { - int myType = getGameObjectType(contents[i]); - if (!allowDerived) - { - if (myType == got) - { - ret = addElement(ret, contents[i]); + for (obj_id content : contents) { + int myType = getGameObjectType(content); + if (!allowDerived) { + if (myType == got) { + ret = addElement(ret, content); } - } - else - { - if (isGameObjectTypeOf(myType, got)) - { - ret = addElement(ret, contents[i]); + } else { + if (isGameObjectTypeOf(myType, got)) { + ret = addElement(ret, content); } } } @@ -2573,11 +2365,8 @@ public class utils 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); - } + _ret = new obj_id[ret.size()]; + ret.toArray(_ret); return _ret; } public static obj_id[] getContainedGOTObjects(obj_id container, int got, boolean recurse) throws InterruptedException @@ -2609,11 +2398,9 @@ public class utils extends script.base_script } Vector ret = new Vector(); ret.setSize(0); - for (int i = 0; i < contents.length; i++) - { - if (hasObjVar(contents[i], var)) - { - ret = addElement(ret, contents[i]); + for (obj_id content : contents) { + if (hasObjVar(content, var)) { + ret = addElement(ret, content); } } if ((ret == null) || (ret.size() == 0)) @@ -2621,11 +2408,8 @@ public class utils 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); - } + _ret = new obj_id[ret.size()]; + ret.toArray(_ret); return _ret; } public static obj_id[] getContainedObjectsWithObjVar(obj_id container, String var) throws InterruptedException @@ -2653,11 +2437,9 @@ public class utils extends script.base_script } Vector ret = new Vector(); ret.setSize(0); - for (int i = 0; i < contents.length; i++) - { - if (hasScript(contents[i], script)) - { - ret = addElement(ret, contents[i]); + for (obj_id content : contents) { + if (hasScript(content, script)) { + ret = addElement(ret, content); } } if ((ret == null) || (ret.size() == 0)) @@ -2665,11 +2447,8 @@ public class utils 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); - } + _ret = new obj_id[ret.size()]; + ret.toArray(_ret); return _ret; } public static obj_id[] getContainedObjectsWithScript(obj_id container, String script) throws InterruptedException @@ -2678,39 +2457,23 @@ public class utils extends script.base_script } public static void sendMail(string_id subject, string_id body, String to, String from) throws InterruptedException { - String body_oob = chatMakePersistentMessageOutOfBandBody(null, body); - String subject_str = "@" + subject.toString(); - chatSendPersistentMessage(from, to, subject_str, null, body_oob); - return; + chatSendPersistentMessage(from, to, "@" + subject.toString(), null, chatMakePersistentMessageOutOfBandBody(null, body)); } public static void sendMail(string_id subject, string_id body, obj_id to, String from) throws InterruptedException { - String body_oob = chatMakePersistentMessageOutOfBandBody(null, body); - String subject_str = "@" + subject.toString(); - chatSendPersistentMessage(from, to, subject_str, null, body_oob); + chatSendPersistentMessage(from, to, "@" + subject.toString(), null, chatMakePersistentMessageOutOfBandBody(null, body)); } public static void sendMail(string_id subject, prose_package body, obj_id to, String from) throws InterruptedException { - String body_oob = chatMakePersistentMessageOutOfBandBody(null, body); - String subject_str = "@" + subject.toString(); - chatSendPersistentMessage(from, to, subject_str, null, body_oob); + chatSendPersistentMessage(from, to, "@" + subject.toString(), null, chatMakePersistentMessageOutOfBandBody(null, body)); } public static void sendMail(string_id subject, prose_package body, String to, String from) throws InterruptedException { - String body_oob = chatMakePersistentMessageOutOfBandBody(null, body); - String subject_str = "@" + subject.toString(); - chatSendPersistentMessage(from, to, subject_str, null, body_oob); + chatSendPersistentMessage(from, to, "@" + subject.toString(), null, chatMakePersistentMessageOutOfBandBody(null, body)); } public static boolean isNightTime() throws InterruptedException { - if (getLocalTime() < getLocalDayLength()) - { - return false; - } - else - { - return true; - } + return getLocalTime() >= getLocalDayLength(); } public static void sendSystemMessageTestingOnly(obj_id[] players, String message) throws InterruptedException { @@ -2718,11 +2481,9 @@ public class utils extends script.base_script { return; } - for (int i = 0; i < players.length; i++) - { - if (isIdValid(players[i]) && exists(players[i])) - { - sendSystemMessageTestingOnly(players[i], message); + for (obj_id player : players) { + if (isIdValid(player) && exists(player)) { + sendSystemMessageTestingOnly(player, message); } } } @@ -2732,11 +2493,9 @@ public class utils extends script.base_script { return; } - for (int i = 0; i < players.length; i++) - { - if (isIdValid(players[i]) && exists(players[i])) - { - sendSystemMessage(players[i], message); + for (obj_id player : players) { + if (isIdValid(player) && exists(player)) { + sendSystemMessage(player, message); } } } @@ -2746,11 +2505,9 @@ public class utils extends script.base_script { return; } - for (int i = 0; i < players.length; i++) - { - if (isIdValid(players[i]) && exists(players[i])) - { - sendSystemMessageProse(players[i], message); + for (obj_id player : players) { + if (isIdValid(player) && exists(player)) { + sendSystemMessageProse(player, message); } } } @@ -2914,8 +2671,7 @@ public class utils extends script.base_script { return false; } - dictionary dd = target.getScriptDictionary(); - dd.put(path, val); + target.getScriptDictionary().put(path, val); return true; } public static boolean setLocalVar(obj_id target, String path, location[] val) throws InterruptedException @@ -2928,8 +2684,7 @@ public class utils extends script.base_script { return false; } - dictionary dd = target.getScriptDictionary(); - dd.put(path, val); + target.getScriptDictionary().put(path, val); return true; } public static boolean setLocalVar(obj_id target, String path, String val) throws InterruptedException @@ -2942,8 +2697,7 @@ public class utils extends script.base_script { return false; } - dictionary dd = target.getScriptDictionary(); - dd.put(path, val); + target.getScriptDictionary().put(path, val); return true; } public static boolean setLocalVar(obj_id target, String path, String[] val) throws InterruptedException @@ -2956,8 +2710,7 @@ public class utils extends script.base_script { return false; } - dictionary dd = target.getScriptDictionary(); - dd.put(path, val); + target.getScriptDictionary().put(path, val); return true; } public static boolean setLocalVar(obj_id target, String path, obj_id val) throws InterruptedException @@ -2970,8 +2723,7 @@ public class utils extends script.base_script { return false; } - dictionary dd = target.getScriptDictionary(); - dd.put(path, val); + target.getScriptDictionary().put(path, val); return true; } public static boolean setLocalVar(obj_id target, String path, obj_id[] val) throws InterruptedException @@ -2984,8 +2736,7 @@ public class utils extends script.base_script { return false; } - dictionary dd = target.getScriptDictionary(); - dd.put(path, val); + target.getScriptDictionary().put(path, val); return true; } public static boolean setLocalVar(obj_id target, String path, int val) throws InterruptedException @@ -2998,8 +2749,7 @@ public class utils extends script.base_script { return false; } - dictionary dd = target.getScriptDictionary(); - dd.put(path, val); + target.getScriptDictionary().put(path, val); return true; } public static boolean setLocalVar(obj_id target, String path, int[] val) throws InterruptedException @@ -3012,8 +2762,7 @@ public class utils extends script.base_script { return false; } - dictionary dd = target.getScriptDictionary(); - dd.put(path, val); + target.getScriptDictionary().put(path, val); return true; } public static boolean setLocalVar(obj_id target, String path, float val) throws InterruptedException @@ -3026,8 +2775,7 @@ public class utils extends script.base_script { return false; } - dictionary dd = target.getScriptDictionary(); - dd.put(path, val); + target.getScriptDictionary().put(path, val); return true; } public static boolean setLocalVar(obj_id target, String path, float[] val) throws InterruptedException @@ -3040,8 +2788,7 @@ public class utils extends script.base_script { return false; } - dictionary dd = target.getScriptDictionary(); - dd.put(path, val); + target.getScriptDictionary().put(path, val); return true; } public static boolean setLocalVar(obj_id target, String path, boolean val) throws InterruptedException @@ -3054,8 +2801,7 @@ public class utils extends script.base_script { return false; } - dictionary dd = target.getScriptDictionary(); - dd.put(path, val); + target.getScriptDictionary().put(path, val); return true; } public static boolean setLocalVar(obj_id target, String path, transform val) throws InterruptedException @@ -3068,8 +2814,7 @@ public class utils extends script.base_script { return false; } - dictionary dd = target.getScriptDictionary(); - dd.put(path, val); + target.getScriptDictionary().put(path, val); return true; } public static boolean setLocalVar(obj_id target, String path, transform[] val) throws InterruptedException @@ -3082,8 +2827,7 @@ public class utils extends script.base_script { return false; } - dictionary dd = target.getScriptDictionary(); - dd.put(path, val); + target.getScriptDictionary().put(path, val); return true; } public static boolean setLocalVar(obj_id target, String path, vector val) throws InterruptedException @@ -3096,8 +2840,7 @@ public class utils extends script.base_script { return false; } - dictionary dd = target.getScriptDictionary(); - dd.put(path, val); + target.getScriptDictionary().put(path, val); return true; } public static boolean setLocalVar(obj_id target, String path, vector[] val) throws InterruptedException @@ -3110,8 +2853,7 @@ public class utils extends script.base_script { return false; } - dictionary dd = target.getScriptDictionary(); - dd.put(path, val); + target.getScriptDictionary().put(path, val); return true; } public static boolean setLocalVar(obj_id target, String path, boolean[] val) throws InterruptedException @@ -3124,8 +2866,7 @@ public class utils extends script.base_script { return false; } - dictionary dd = target.getScriptDictionary(); - dd.put(path, val); + target.getScriptDictionary().put(path, val); return true; } public static boolean setLocalVar(obj_id target, String path, dictionary val) throws InterruptedException @@ -3138,14 +2879,12 @@ public class utils extends script.base_script { return false; } - dictionary dd = target.getScriptDictionary(); - dd.put(path, val); + target.getScriptDictionary().put(path, val); return true; } public static boolean hasLocalVar(obj_id target, String path) throws InterruptedException { - dictionary dd = target.getScriptDictionary(); - return dd.containsKey(path); + return target.getScriptDictionary().containsKey(path); } public static boolean removeLocalVar(obj_id target, String path) throws InterruptedException { @@ -3157,74 +2896,60 @@ public class utils extends script.base_script { return false; } - dictionary dd = target.getScriptDictionary(); - dd.remove(path); + target.getScriptDictionary().remove(path); return true; } public static int getIntLocalVar(obj_id target, String path) throws InterruptedException { - dictionary dd = target.getScriptDictionary(); - return dd.getInt(path); + return target.getScriptDictionary().getInt(path); } public static int[] getIntArrayLocalVar(obj_id target, String path) throws InterruptedException { - dictionary dd = target.getScriptDictionary(); - return dd.getIntArray(path); + return target.getScriptDictionary().getIntArray(path); } public static float getFloatLocalVar(obj_id target, String path) throws InterruptedException { - dictionary dd = target.getScriptDictionary(); - return dd.getFloat(path); + return target.getScriptDictionary().getFloat(path); } public static float[] getFloatArrayLocalVar(obj_id target, String path) throws InterruptedException { - dictionary dd = target.getScriptDictionary(); - return dd.getFloatArray(path); + return target.getScriptDictionary().getFloatArray(path); } public static String getStringLocalVar(obj_id target, String path) throws InterruptedException { - dictionary dd = target.getScriptDictionary(); - return dd.getString(path); + return target.getScriptDictionary().getString(path); } public static String[] getStringArrayLocalVar(obj_id target, String path) throws InterruptedException { - dictionary dd = target.getScriptDictionary(); - return dd.getStringArray(path); + return target.getScriptDictionary().getStringArray(path); } public static transform[] getTransformArrayLocalVar(obj_id target, String path) throws InterruptedException { - dictionary dd = target.getScriptDictionary(); - return dd.getTransformArray(path); + return target.getScriptDictionary().getTransformArray(path); } public static boolean getBooleanLocalVar(obj_id target, String path) throws InterruptedException { - dictionary dd = target.getScriptDictionary(); - return dd.getBoolean(path); + return target.getScriptDictionary().getBoolean(path); } public static boolean[] getBooleanArrayLocalVar(obj_id target, String path) throws InterruptedException { - dictionary dd = target.getScriptDictionary(); - return dd.getBooleanArray(path); + return target.getScriptDictionary().getBooleanArray(path); } public static location getLocationLocalVar(obj_id target, String path) throws InterruptedException { - dictionary dd = target.getScriptDictionary(); - return dd.getLocation(path); + return target.getScriptDictionary().getLocation(path); } public static location[] getLocationArrayLocalVar(obj_id target, String path) throws InterruptedException { - dictionary dd = target.getScriptDictionary(); - return dd.getLocationArray(path); + return target.getScriptDictionary().getLocationArray(path); } public static obj_id getObjIdLocalVar(obj_id target, String path) throws InterruptedException { - dictionary dd = target.getScriptDictionary(); - return dd.getObjId(path); + return target.getScriptDictionary().getObjId(path); } public static obj_id[] getObjIdArrayLocalVar(obj_id target, String path) throws InterruptedException { - dictionary dd = target.getScriptDictionary(); - return dd.getObjIdArray(path); + return target.getScriptDictionary().getObjIdArray(path); } public static Vector getResizeableObjIdArrayLocalVar(obj_id target, String path) throws InterruptedException { @@ -3243,9 +2968,8 @@ public class utils extends script.base_script dictionary dd = target.getScriptDictionary(); int[] intArray = dd.getIntArray(path); Vector rszArray = new Vector(intArray.length + 1); - for (int i = 0; i < intArray.length; ++i) - { - rszArray.add(new Integer(intArray[i])); + for (int anIntArray : intArray) { + rszArray.add(anIntArray); } return rszArray; } @@ -3254,9 +2978,8 @@ public class utils extends script.base_script dictionary dd = target.getScriptDictionary(); float[] fltArray = dd.getFloatArray(path); Vector rszArray = new Vector(fltArray.length + 10); - for (int i = 0; i < fltArray.length; ++i) - { - rszArray.add(new Float(fltArray[i])); + for (float aFltArray : fltArray) { + rszArray.add(aFltArray); } return rszArray; } @@ -3270,30 +2993,25 @@ public class utils extends script.base_script { dictionary dd = target.getScriptDictionary(); transform[] trArray = dd.getTransformArray(path); - Vector v1 = new Vector(Arrays.asList(trArray)); - return v1; + return new Vector(Arrays.asList(trArray)); } public static Vector getResizeableVectorArrayLocalVar(obj_id target, String path) throws InterruptedException { dictionary dd = target.getScriptDictionary(); vector[] vctArray = dd.getVectorArray(path); - Vector v1 = new Vector(Arrays.asList(vctArray)); - return v1; + return new Vector(Arrays.asList(vctArray)); } public static string_id getStringIdLocalVar(obj_id target, String path) throws InterruptedException { - dictionary dd = target.getScriptDictionary(); - return dd.getStringId(path); + return target.getScriptDictionary().getStringId(path); } public static string_id[] getStringIdArrayLocalVar(obj_id target, String path) throws InterruptedException { - dictionary dd = target.getScriptDictionary(); - return dd.getStringIdArray(path); + return target.getScriptDictionary().getStringIdArray(path); } public static dictionary getDictionaryLocalVar(obj_id target, String path) throws InterruptedException { - dictionary dd = target.getScriptDictionary(); - return dd.getDictionary(path); + return target.getScriptDictionary().getDictionary(path); } public static boolean setScriptVar(obj_id target, String path, location val) throws InterruptedException { @@ -3305,8 +3023,7 @@ public class utils extends script.base_script { return false; } - deltadictionary dd = target.getScriptVars(); - dd.put(path, val); + target.getScriptVars().put(path, val); return true; } public static boolean setScriptVar(obj_id target, String path, location[] val) throws InterruptedException @@ -3319,8 +3036,7 @@ public class utils extends script.base_script { return false; } - deltadictionary dd = target.getScriptVars(); - dd.put(path, val); + target.getScriptVars().put(path, val); return true; } public static boolean setScriptVar(obj_id target, String path, String val) throws InterruptedException @@ -3333,8 +3049,7 @@ public class utils extends script.base_script { return false; } - deltadictionary dd = target.getScriptVars(); - dd.put(path, val); + target.getScriptVars().put(path, val); return true; } public static boolean setScriptVar(obj_id target, String path, String[] val) throws InterruptedException @@ -3347,8 +3062,7 @@ public class utils extends script.base_script { return false; } - deltadictionary dd = target.getScriptVars(); - dd.put(path, val); + target.getScriptVars().put(path, val); return true; } public static boolean setScriptVar(obj_id target, String path, String[][] val) throws InterruptedException @@ -3361,8 +3075,7 @@ public class utils extends script.base_script { return false; } - deltadictionary dd = target.getScriptVars(); - dd.put(path, val); + target.getScriptVars().put(path, val); return true; } public static boolean setScriptVar(obj_id target, String path, obj_id val) throws InterruptedException @@ -3375,8 +3088,7 @@ public class utils extends script.base_script { return false; } - deltadictionary dd = target.getScriptVars(); - dd.put(path, val); + target.getScriptVars().put(path, val); return true; } public static boolean setScriptVar(obj_id target, String path, obj_id[] val) throws InterruptedException @@ -3389,8 +3101,7 @@ public class utils extends script.base_script { return false; } - deltadictionary dd = target.getScriptVars(); - dd.put(path, val); + target.getScriptVars().put(path, val); return true; } public static boolean setScriptVar(obj_id target, String path, int val) throws InterruptedException @@ -3403,8 +3114,7 @@ public class utils extends script.base_script { return false; } - deltadictionary dd = target.getScriptVars(); - dd.put(path, val); + target.getScriptVars().put(path, val); return true; } public static boolean setScriptVar(obj_id target, String path, int[] val) throws InterruptedException @@ -3417,8 +3127,7 @@ public class utils extends script.base_script { return false; } - deltadictionary dd = target.getScriptVars(); - dd.put(path, val); + target.getScriptVars().put(path, val); return true; } public static boolean setScriptVar(obj_id target, String path, long val) throws InterruptedException @@ -3431,8 +3140,7 @@ public class utils extends script.base_script { return false; } - deltadictionary dd = target.getScriptVars(); - dd.put(path, val); + target.getScriptVars().put(path, val); return true; } public static boolean setScriptVar(obj_id target, String path, long[] val) throws InterruptedException @@ -3445,8 +3153,7 @@ public class utils extends script.base_script { return false; } - deltadictionary dd = target.getScriptVars(); - dd.put(path, val); + target.getScriptVars().put(path, val); return true; } public static boolean setScriptVar(obj_id target, String path, double val) throws InterruptedException @@ -3459,8 +3166,7 @@ public class utils extends script.base_script { return false; } - deltadictionary dd = target.getScriptVars(); - dd.put(path, val); + target.getScriptVars().put(path, val); return true; } public static boolean setScriptVar(obj_id target, String path, double[] val) throws InterruptedException @@ -3473,8 +3179,7 @@ public class utils extends script.base_script { return false; } - deltadictionary dd = target.getScriptVars(); - dd.put(path, val); + target.getScriptVars().put(path, val); return true; } public static boolean setScriptVar(obj_id target, String path, float val) throws InterruptedException @@ -3487,8 +3192,7 @@ public class utils extends script.base_script { return false; } - deltadictionary dd = target.getScriptVars(); - dd.put(path, val); + target.getScriptVars().put(path, val); return true; } public static boolean setScriptVar(obj_id target, String path, float[] val) throws InterruptedException @@ -3501,8 +3205,7 @@ public class utils extends script.base_script { return false; } - deltadictionary dd = target.getScriptVars(); - dd.put(path, val); + target.getScriptVars().put(path, val); return true; } public static boolean setScriptVar(obj_id target, String path, boolean val) throws InterruptedException @@ -3515,8 +3218,7 @@ public class utils extends script.base_script { return false; } - deltadictionary dd = target.getScriptVars(); - dd.put(path, val); + target.getScriptVars().put(path, val); return true; } public static boolean setScriptVar(obj_id target, String path, transform val) throws InterruptedException @@ -3529,8 +3231,7 @@ public class utils extends script.base_script { return false; } - deltadictionary dd = target.getScriptVars(); - dd.put(path, val); + target.getScriptVars().put(path, val); return true; } public static boolean setScriptVar(obj_id target, String path, transform[] val) throws InterruptedException @@ -3543,8 +3244,7 @@ public class utils extends script.base_script { return false; } - deltadictionary dd = target.getScriptVars(); - dd.put(path, val); + target.getScriptVars().put(path, val); return true; } public static boolean setScriptVar(obj_id target, String path, vector val) throws InterruptedException @@ -3557,8 +3257,7 @@ public class utils extends script.base_script { return false; } - deltadictionary dd = target.getScriptVars(); - dd.put(path, val); + target.getScriptVars().put(path, val); return true; } public static boolean setScriptVar(obj_id target, String path, vector[] val) throws InterruptedException @@ -3571,8 +3270,7 @@ public class utils extends script.base_script { return false; } - deltadictionary dd = target.getScriptVars(); - dd.put(path, val); + target.getScriptVars().put(path, val); return true; } public static boolean setScriptVar(obj_id target, String path, boolean[] val) throws InterruptedException @@ -3585,8 +3283,7 @@ public class utils extends script.base_script { return false; } - deltadictionary dd = target.getScriptVars(); - dd.put(path, val); + target.getScriptVars().put(path, val); return true; } public static boolean setScriptVar(obj_id target, String path, Vector val) throws InterruptedException @@ -3686,11 +3383,11 @@ public class utils extends script.base_script { return false; } - deltadictionary dd = target.getScriptVars(); - Enumeration keys = dd.keys(); + Enumeration keys = target.getScriptVars().keys(); + String key; while (keys.hasMoreElements()) { - String key = (String)(keys.nextElement()); + key = (String) (keys.nextElement()); if (key.equals(path) || key.startsWith(path + ".")) { return true; @@ -3714,9 +3411,10 @@ public class utils extends script.base_script return false; } Enumeration keys = target.getScriptVars().keys(); + String key; while (keys.hasMoreElements()) { - String key = (String)(keys.nextElement()); + key = (String) (keys.nextElement()); if (key.equals(path) || key.startsWith(path + ".")) { target.getScriptVars().remove(key); @@ -3917,8 +3615,9 @@ public class utils extends script.base_script return 0; } int intCount = 0; + String strString; for (obj_id objObject : objObjects) { - String strString = getStringObjVar(objObject, strObjVar); + strString = getStringObjVar(objObject, strObjVar); if (strString != null && strString.contains(strSubString)) intCount++; } @@ -4011,13 +3710,12 @@ public class utils extends script.base_script { basePath = ""; } - String name = ovl.getName(); - String path = basePath + name; - boolean litmus = true; + String path = basePath + ovl.getName(); int numItems = ovl.getNumItems(); + obj_var ov; for (int i = 0; i < numItems; i++) { - obj_var ov = ovl.getObjVar(i); + ov = ovl.getObjVar(i); if (ov != null) { if (ov instanceof obj_var_list) @@ -4064,9 +3762,10 @@ public class utils extends script.base_script return; } int numItems = ovl.getNumItems(); + obj_var ov; for (int x = 0; x < numItems; x++) { - obj_var ov = ovl.getObjVar(x); + ov = ovl.getObjVar(x); if (ov != null) { copyObjVar(template, clone, ov.getName()); @@ -4166,7 +3865,7 @@ public class utils extends script.base_script result[i] = true; } } - if (result == null || result.length == 0) + if (result.length == 0) { result[0] = false; } @@ -4194,6 +3893,7 @@ public class utils extends script.base_script } } Enumeration keys = dict.keys(); + Object data; while (keys.hasMoreElements()) { String key; @@ -4205,7 +3905,7 @@ public class utils extends script.base_script { return false; } - Object data = dict.get(key); + data = dict.get(key); if (data instanceof Integer) { setObjVar(object, rootName + key, ((Integer)data).intValue()); @@ -4258,11 +3958,9 @@ public class utils extends script.base_script boolean litmus = true; int n = 0; Vector toSet = new Vector(); - for (int i = 0; i < array.length; i++) - { - toSet.add(array[i]); - if (toSet.size() >= BatchSize) - { + for (Object anArray : array) { + toSet.add(anArray); + if (toSet.size() >= BatchSize) { litmus &= setObjectArrayObjVar(target, base_path + "." + n, toSet); toSet.clear(); n++; @@ -4285,9 +3983,8 @@ public class utils extends script.base_script { return; } - int listLength = list.getNumItems(); int intQ = 0; - for (int i = 0; i < listLength; i++) + for (int i = 0; i < list.getNumItems(); i++) { if (hasObjVar(target, base_path + "." + intQ)) { @@ -4309,11 +4006,9 @@ public class utils extends script.base_script boolean litmus = true; int n = 0; Vector toSet = new Vector(); - for (int i = 0; i < array.length; i++) - { - toSet.add(new Integer(array[i])); - if (toSet.size() >= BatchSize) - { + for (int anArray : array) { + toSet.add(anArray); + if (toSet.size() >= BatchSize) { litmus &= setObjectArrayObjVar(target, base_path + "." + n, toSet); toSet.clear(); n++; @@ -4335,11 +4030,9 @@ public class utils extends script.base_script boolean litmus = true; int n = 0; Vector toSet = new Vector(); - for (int i = 0; i < vector.size(); i++) - { - toSet.add(vector.get(i)); - if (toSet.size() >= BatchSize) - { + for (Object aVector : vector) { + toSet.add(aVector); + if (toSet.size() >= BatchSize) { litmus &= setObjectArrayObjVar(target, base_path + "." + n, toSet); toSet.clear(); n++; @@ -4412,11 +4105,8 @@ public class utils extends script.base_script if ((ret != null) && (ret.size() > 0)) { 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; } return null; @@ -4482,11 +4172,8 @@ public class utils extends script.base_script if ((ret != null) && (ret.size() > 0)) { string_id[] _ret = new string_id[0]; - if (ret != null) - { - _ret = new string_id[ret.size()]; - ret.toArray(_ret); - } + _ret = new string_id[ret.size()]; + ret.toArray(_ret); return _ret; } return null; @@ -4524,11 +4211,8 @@ public class utils extends script.base_script if ((ret != null) && (ret.size() > 0)) { obj_id[] _ret = new obj_id[0]; - if (ret != null) - { - _ret = new obj_id[ret.size()]; - ret.toArray(_ret); - } + _ret = new obj_id[ret.size()]; + ret.toArray(_ret); return _ret; } return null; @@ -4555,9 +4239,10 @@ public class utils extends script.base_script return null; } int numItems = ovl.getNumItems(); + obj_id[] tmp; for (int i = 0; i < numItems; i++) { - obj_id[] tmp = getObjIdArrayObjVar(target, base_path + "." + i); + tmp = getObjIdArrayObjVar(target, base_path + "." + i); if ((tmp != null) && (tmp.length > 0)) { ret = concatArrays(ret, tmp); @@ -4602,14 +4287,11 @@ public class utils extends script.base_script if ((ret != null) && (ret.size() > 0)) { int[] _ret = new int[0]; - if (ret != null) - { - _ret = new int[ret.size()]; - for (int _i = 0; _i < ret.size(); ++_i) - { - _ret[_i] = (Integer) ret.get(_i); - } - } + _ret = new int[ret.size()]; + for (int _i = 0; _i < ret.size(); ++_i) + { + _ret[_i] = (Integer) ret.get(_i); + } return _ret; } return null; @@ -4672,9 +4354,10 @@ public class utils extends script.base_script Vector ret = new Vector(); ret.setSize(0); int numItems = ovl.getNumItems(); + attrib_mod[] tmp; for (int i = 0; i < numItems; i++) { - attrib_mod[] tmp = getAttribModArrayObjVar(target, base_path + "." + i); + tmp = getAttribModArrayObjVar(target, base_path + "." + i); if ((tmp != null) && (tmp.length > 0)) { ret = concatArrays(ret, tmp); @@ -4683,11 +4366,8 @@ public class utils extends script.base_script if ((ret != null) && (ret.size() > 0)) { attrib_mod[] _ret = new attrib_mod[0]; - if (ret != null) - { - _ret = new attrib_mod[ret.size()]; - ret.toArray(_ret); - } + _ret = new attrib_mod[ret.size()]; + ret.toArray(_ret); return _ret; } return null; @@ -4714,9 +4394,10 @@ public class utils extends script.base_script return null; } int numItems = ovl.getNumItems(); + location[] tmp; for (int i = 0; i < numItems; i++) { - location[] tmp = getLocationArrayObjVar(target, base_path + "." + i); + tmp = getLocationArrayObjVar(target, base_path + "." + i); if ((tmp != null) && (tmp.length > 0)) { ret = concatArrays(ret, tmp); @@ -4725,11 +4406,8 @@ public class utils extends script.base_script if ((ret != null) && (ret.size() > 0)) { location[] _ret = new location[0]; - if (ret != null) - { - _ret = new location[ret.size()]; - ret.toArray(_ret); - } + _ret = new location[ret.size()]; + ret.toArray(_ret); return _ret; } return null; @@ -4858,9 +4536,10 @@ public class utils extends script.base_script } int cnt = getIntScriptVar(target, base_path); Vector ret = new Vector(); + Vector tmp; for (int i = 0; i < cnt; i++) { - Vector tmp = target.getScriptVars().getResizeableObjIdArray(base_path + "." + i); + tmp = target.getScriptVars().getResizeableObjIdArray(base_path + "." + i); if ((tmp != null) && (tmp.size() > 0)) { ret.addAll(tmp); @@ -4905,7 +4584,7 @@ public class utils extends script.base_script ret.addAll(tmp); } } - if ((ret != null) && (ret.size() > 0)) + if ((ret.size() > 0)) { return ret; } @@ -4936,15 +4615,16 @@ public class utils extends script.base_script } int cnt = getIntScriptVar(target, base_path); Vector ret = new Vector(); + Vector tmp; for (int i = 0; i < cnt; i++) { - Vector tmp = target.getScriptVars().getResizeableLocationArray(base_path + "." + i); + tmp = target.getScriptVars().getResizeableLocationArray(base_path + "." + i); if ((tmp != null) && (tmp.size() > 0)) { ret.addAll(tmp); } } - if ((ret != null) && (ret.size() > 0)) + if ((ret.size() > 0)) { return ret; } @@ -4966,15 +4646,16 @@ public class utils extends script.base_script } int cnt = getIntScriptVar(target, base_path); Vector ret = new Vector(); + Vector tmp; for (int i = 0; i < cnt; i++) { - Vector tmp = target.getScriptVars().getResizeableIntArray(base_path + "." + i); + tmp = target.getScriptVars().getResizeableIntArray(base_path + "." + i); if ((tmp != null) && (tmp.size() > 0)) { ret.addAll(tmp); } } - if ((ret != null) && (ret.size() > 0)) + if ((ret.size() > 0)) { return ret; } @@ -5068,7 +4749,7 @@ public class utils extends script.base_script { return Integer.parseInt(setting); } - catch(NumberFormatException err) + catch(NumberFormatException ignored) { } return 0; @@ -5084,7 +4765,7 @@ public class utils extends script.base_script { return Float.parseFloat(setting); } - catch(NumberFormatException err) + catch(NumberFormatException ignored) { } return 0; @@ -5165,7 +4846,7 @@ public class utils extends script.base_script time_str += ", "; } } - if (time_str != null && !time_str.equals("")) + if (!time_str.equals("")) { return time_str; } @@ -5360,21 +5041,17 @@ public class utils extends script.base_script } Vector tmp = new Vector(); java.text.Collator myCol = java.text.Collator.getInstance(); - for (int i = 0; i < array.length; i++) - { + for (String anArray : array) { boolean inserted = false; - for (int n = 0; n < tmp.size(); n++) - { - if (myCol.compare(array[i], tmp.elementAt(n)) < 0) - { - tmp.add(n, array[i]); + for (int n = 0; n < tmp.size(); n++) { + if (myCol.compare(anArray, tmp.elementAt(n)) < 0) { + tmp.add(n, anArray); inserted = true; break; } } - if (!inserted) - { - tmp.add(array[i]); + if (!inserted) { + tmp.add(anArray); } } if (tmp.size() == 0) @@ -5401,27 +5078,27 @@ public class utils extends script.base_script switch (species) { case SPECIES_HUMAN: - return "human"; + return "human"; case SPECIES_BOTHAN: - return "bothan"; + return "bothan"; case SPECIES_RODIAN: - return "rodian"; + return "rodian"; case SPECIES_TWILEK: - return "twilek"; + return "twilek"; case SPECIES_TRANDOSHAN: - return "trandoshan"; + return "trandoshan"; case SPECIES_MON_CALAMARI: - return "moncalamari"; + return "moncalamari"; case SPECIES_WOOKIEE: - return "wookiee"; + return "wookiee"; case SPECIES_ZABRAK: - return "zabrak"; + return "zabrak"; case SPECIES_ITHORIAN: - return "ithorian"; + return "ithorian"; case SPECIES_SULLUSTAN: - return "sullustan"; + return "sullustan"; default: - return "unknown"; + return "unknown"; } } public static void addListener(String strObjVar, obj_id objListener, obj_id objTarget) throws InterruptedException @@ -5445,7 +5122,6 @@ public class utils extends script.base_script dctParams.put("objListener", objListener); dctParams.put("strObjVar", strObjVar); messageTo(objTarget, "addListener", dctParams, 0, true); - return; } public static void removeListener(String strObjVar, obj_id objListener, obj_id objTarget) throws InterruptedException { @@ -5468,7 +5144,6 @@ public class utils extends script.base_script dctParams.put("objListener", objListener); dctParams.put("strObjVar", strObjVar); messageTo(objTarget, "removeListener", dctParams, 0, true); - return; } public static void messageListeners(String strObjVar, obj_id objOwner, String strMessageName, dictionary dctParams) throws InterruptedException { @@ -5497,7 +5172,6 @@ public class utils extends script.base_script intI = intI + 1; } } - return; } public static int getTheaterSize(String strLairType) throws InterruptedException { @@ -5551,29 +5225,17 @@ public class utils extends script.base_script } return setName(target, name); } - public static boolean setNonReservedName(obj_id target, String name) throws InterruptedException - { - if (!isIdValid(target) || name == null || name.equals("")) - { + public static boolean setNonReservedName(obj_id target, String name) throws InterruptedException { + if (!isIdValid(target) || name == null || name.equals("")) { return false; } - if (!isNameReserved(name)) - { - return setName(target, name); - } - return false; + return !isNameReserved(name) && setName(target, name); } - public static boolean setFilteredName(obj_id target, String name) throws InterruptedException - { - if (!isIdValid(target) || name == null || name.equals("")) - { + public static boolean setFilteredName(obj_id target, String name) throws InterruptedException { + if (!isIdValid(target) || name == null || name.equals("")) { return false; } - if (!isNameReserved(name)) - { - return setNonProfaneName(target, name); - } - return false; + return !isNameReserved(name) && setNonProfaneName(target, name); } public static void destroyObjects(obj_id[] objects) throws InterruptedException { @@ -5894,9 +5556,10 @@ public class utils extends script.base_script { debugSpeakMsg(objObject, "list length is " + strScripts.length); String[] strCorrectArray = new String[strScripts.length]; + String script; for (int intI = 0; intI < strScripts.length; intI++) { - String script = strScripts[intI]; + script = strScripts[intI]; if (script.contains("script.")) { script = script.substring(7); @@ -5953,43 +5616,31 @@ public class utils extends script.base_script obj_id[] objects = getObjectsInRange(loc, radius); Vector attackable_targets = new Vector(); attackable_targets.setSize(0); - for (int i = 0; i < objects.length; i++) - { - if (isMob(objects[i])) - { - if (pvpCanAttack(attacker, objects[i])) - { - if (!isIncapacitated(objects[i]) && !isDead(objects[i])) - { - if (isPlayer(objects[i])) - { - if (!player_targets) - { + for (obj_id object : objects) { + if (isMob(object)) { + if (pvpCanAttack(attacker, object)) { + if (!isIncapacitated(object) && !isDead(object)) { + if (isPlayer(object)) { + if (!player_targets) { continue; } } - if (canSee(attacker, objects[i])) - { - attackable_targets = utils.addElement(attackable_targets, objects[i]); + if (canSee(attacker, object)) { + attackable_targets = utils.addElement(attackable_targets, object); } } } - } - else if (ai_lib.isTurret(objects[i])) - { - if (pvpCanAttack(attacker, objects[i])) - { - if (canSee(attacker, objects[i])) - { - attackable_targets = utils.addElement(attackable_targets, objects[i]); + } else if (ai_lib.isTurret(object)) { + if (pvpCanAttack(attacker, object)) { + if (canSee(attacker, object)) { + attackable_targets = utils.addElement(attackable_targets, object); } } } } if (attackable_targets.size() >= 1) { - obj_id[] _attackable_targets = new obj_id[0]; - _attackable_targets = new obj_id[attackable_targets.size()]; + obj_id[] _attackable_targets = new obj_id[attackable_targets.size()]; attackable_targets.toArray(_attackable_targets); return _attackable_targets; } @@ -6071,8 +5722,7 @@ public class utils extends script.base_script public static String getCellName(obj_id building, obj_id cell) throws InterruptedException { for (String cellName : getCellNames(building)) { - obj_id thisCell = getCellId(building, cellName); - if (thisCell == cell) { + if (getCellId(building, cellName) == cell) { return cellName; } } @@ -6135,10 +5785,13 @@ public class utils extends script.base_script java.util.StringTokenizer st = new java.util.StringTokenizer(getStringObjVar(item, prefix + "classRequired"), ","); String requiredText = ""; boolean qualifies = false; + String classId; + String tmp; + while (st.hasMoreTokens()) { - String classId = st.nextToken(); - String tmp = "@skl_n:class_" + classId + "\0"; + classId = st.nextToken(); + tmp = "@skl_n:class_" + classId + "\0"; if (st.hasMoreTokens()) { tmp += "\n\\>117\0"; @@ -6258,23 +5911,17 @@ public class utils extends script.base_script { if (items != null) { - for (int i = 0; i < items.length; ++i) - { - if (isIdValid(items[i]) && (testPlayers || !isPlayer(items[i]))) - { - if (novendor && hasScript(items[i], "terminal.vendor")) - { + obj_id result; + for (obj_id item : items) { + if (isIdValid(item) && (testPlayers || !isPlayer(item))) { + if (novendor && hasScript(item, "terminal.vendor")) { continue; } - if (!canTrade(items[i])) - { - return items[i]; - } - else if (utils.isContainer(items[i])) - { - obj_id result = findNoTradeItem(getContents(items[i]), testPlayers); - if (isIdValid(result)) - { + if (!canTrade(item)) { + return item; + } else if (utils.isContainer(item)) { + result = findNoTradeItem(getContents(item), testPlayers); + if (isIdValid(result)) { return result; } } @@ -6298,14 +5945,12 @@ public class utils extends script.base_script { return null; } - for (int i = 0; i < waypoints.length; ++i) - { - if (isIdValid(waypoints[i])) - { - String waypointName = getWaypointName(waypoints[i]); - if (waypointName != null && waypointName.equals(name)) - { - return waypoints[i]; + String waypointName; + for (obj_id waypoint : waypoints) { + if (isIdValid(waypoint)) { + waypointName = getWaypointName(waypoint); + if (waypointName != null && waypointName.equals(name)) { + return waypoint; } } } @@ -6322,12 +5967,9 @@ public class utils extends script.base_script { return false; } - for (int i = 0; i < waypoints.length; ++i) - { - if (isIdValid(waypoints[i])) - { - if (waypoints[i] == waypoint) - { + for (obj_id waypoint1 : waypoints) { + if (isIdValid(waypoint1)) { + if (waypoint1 == waypoint) { return true; } } @@ -6396,11 +6038,9 @@ public class utils extends script.base_script return null; } Vector localMemberIdsVector = new Vector(); - for (int i = 0; i < groupMemberIds.length; ++i) - { - if (isIdValid(groupMemberIds[i]) && exists(groupMemberIds[i]) && isPlayer(groupMemberIds[i])) - { - localMemberIdsVector.addElement(groupMemberIds[i]); + for (obj_id groupMemberId : groupMemberIds) { + if (isIdValid(groupMemberId) && exists(groupMemberId) && isPlayer(groupMemberId)) { + localMemberIdsVector.addElement(groupMemberId); } } if (localMemberIdsVector == null || localMemberIdsVector.size() < 1) @@ -6428,13 +6068,17 @@ public class utils extends script.base_script { return; } + String[] objVarToSet; + String objVarValue; + String[] objVarNameAndType; + String objVarName; + for (String pair : split(objVarList, ',')) { - String[] objVarToSet = split(pair, '='); - String objVarValue = objVarToSet[1]; - String[] objVarNameAndType = split(objVarToSet[0], ':'); - String objVarType = objVarNameAndType[0]; - String objVarName = objVarNameAndType[1]; - switch (objVarType) { + objVarToSet = split(pair, '='); + objVarValue = objVarToSet[1]; + objVarNameAndType = split(objVarToSet[0], ':'); + objVarName = objVarNameAndType[1]; + switch (objVarNameAndType[0]) { case "string": setObjVar(object, objVarName, objVarValue); break; @@ -6460,13 +6104,17 @@ public class utils extends script.base_script { return; } + String[] objVarToSet; + String objVarValue; + String[] objVarNameAndType; + String objVarName; + for (String pair : split(objVarList, ',')) { - String[] objVarToSet = split(pair, '='); - String objVarValue = objVarToSet[1]; - String[] objVarNameAndType = split(objVarToSet[0], ';'); - String objVarType = objVarNameAndType[0]; - String objVarName = objVarNameAndType[1]; - switch (objVarType) { + objVarToSet = split(pair, '='); + objVarValue = objVarToSet[1]; + objVarNameAndType = split(objVarToSet[0], ';'); + objVarName = objVarNameAndType[1]; + switch (objVarNameAndType[0]) { case "string": setObjVar(object, objVarName, objVarValue); break; @@ -6490,8 +6138,7 @@ public class utils extends script.base_script { if (!hasObjVar(subject, "recordLoc")) { - location recordLoc = getLocation(subject); - setObjVar(subject, "recordLoc", recordLoc); + setObjVar(subject, "recordLoc", getLocation(subject)); return true; } float distanceDifference = getDistance(getLocationObjVar(subject, "recordLoc"), getLocation(getTopMostContainer(subject))); @@ -6598,34 +6245,34 @@ public class utils extends script.base_script switch (profession) { case COMMANDO: - professionName = "commando"; - break; + professionName = "commando"; + break; case SMUGGLER: - professionName = "smuggler"; - break; + professionName = "smuggler"; + break; case MEDIC: - professionName = "medic"; - break; + professionName = "medic"; + break; case OFFICER: - professionName = "officer"; - break; + professionName = "officer"; + break; case SPY: - professionName = "spy"; - break; + professionName = "spy"; + break; case BOUNTY_HUNTER: - professionName = "bounty"; - break; + professionName = "bounty"; + break; case FORCE_SENSITIVE: - professionName = "force"; - break; + professionName = "force"; + break; case TRADER: - professionName = "trader"; - break; + professionName = "trader"; + break; case ENTERTAINER: - professionName = "entertainer"; - break; + professionName = "entertainer"; + break; default: - break; + break; } String classTemplate = getSkillTemplate(player); return classTemplate != null && classTemplate.startsWith(professionName); @@ -6768,17 +6415,13 @@ public class utils extends script.base_script obj_id[] objContents = getContents(objInventory, true); if (objContents != null) { - for (int i = 0; i < objContents.length; i++) - { - for (int j = 0; j < oldTemplates.length; j++) - { - String strItemTemplate = getTemplateName(objContents[i]); - if (strItemTemplate.equals(oldTemplates[j])) - { - String newTemplate = dataTableGetString("datatables/item/snowflake_item_swaps.iff", j, "NEW_TEMPLATE"); - if (newTemplate != null && !newTemplate.equals("")) - { - replaceSnowflakeItem(objContents[i], newTemplate); + String newTemplate; + for (obj_id objContent : objContents) { + for (int j = 0; j < oldTemplates.length; j++) { + if (getTemplateName(objContent).equals(oldTemplates[j])) { + newTemplate = dataTableGetString("datatables/item/snowflake_item_swaps.iff", j, "NEW_TEMPLATE"); + if (newTemplate != null && !newTemplate.equals("")) { + replaceSnowflakeItem(objContent, newTemplate); } } } @@ -6908,11 +6551,7 @@ public class utils extends script.base_script { return false; } - if (!hasObjVar(house, "player_structure.admin.adminList")) - { - return false; - } - return true; + return hasObjVar(house, "player_structure.admin.adminList"); } return false; } @@ -6931,11 +6570,12 @@ public class utils extends script.base_script { return false; } + obj_id resourceId; for (obj_id content : contents) { int got = getGameObjectType(content); if (isGameObjectTypeOf(got, GOT_resource_container)) { if (isIdValid(content)) { - obj_id resourceId = getResourceContainerResourceType(content); + resourceId = getResourceContainerResourceType(content); if (isIdValid(resourceId)) { if (isResourceDerivedFrom(resourceId, resource)) { return true; @@ -6978,26 +6618,22 @@ public class utils extends script.base_script { return null; } - for (int i = 0; i < allPlayers.length; i++) - { - location loc = getLocation(trial.getTop(allPlayers[i])); - if (loc.x < x1 || loc.x > x2 || loc.z < z1 || loc.z > z2) - { + location loc; + for (obj_id allPlayer : allPlayers) { + loc = getLocation(trial.getTop(allPlayer)); + if (loc.x < x1 || loc.x > x2 || loc.z < z1 || loc.z > z2) { LOG("doLogging", "" + loc.x + " vs: " + x1 + ", " + x2 + " and " + loc.z + " vs: " + z1 + ", " + z2); continue; } - utils.addElement(playersInArea, allPlayers[i]); + utils.addElement(playersInArea, allPlayer); } if (playersInArea.size() == 0) { return null; } obj_id[] _playersInArea = new obj_id[0]; - if (playersInArea != null) - { - _playersInArea = new obj_id[playersInArea.size()]; - playersInArea.toArray(_playersInArea); - } + _playersInArea = new obj_id[playersInArea.size()]; + playersInArea.toArray(_playersInArea); return _playersInArea; } public static dictionary getCoordinatesInBuildoutRow(String scene, int buildout_row) throws InterruptedException @@ -7041,14 +6677,13 @@ public class utils extends script.base_script { return null; } - for (int i = 0; i < allObjects.length; i++) - { - location testLoc = getLocation(trial.getTop(allObjects[i])); - if (testLoc.x < x1 || testLoc.x > x2 || testLoc.z < z1 || testLoc.z > z2) - { + location testLoc; + for (obj_id allObject : allObjects) { + testLoc = getLocation(trial.getTop(allObject)); + if (testLoc.x < x1 || testLoc.x > x2 || testLoc.z < z1 || testLoc.z > z2) { continue; } - objectsInArea.add(allObjects[i]); + objectsInArea.add(allObject); } if (objectsInArea.size() == 0) { @@ -7152,9 +6787,10 @@ public class utils extends script.base_script } Vector resizeList = new Vector(); resizeList.setSize(0); + obj_id tempRider; for (int i = 1; i <= 25; ++i) { - obj_id tempRider = getObjectInSlot(vehicle, "rider" + i); + tempRider = getObjectInSlot(vehicle, "rider" + i); if (!isIdValid(tempRider) || !exists(tempRider)) { continue; @@ -7234,23 +6870,17 @@ public class utils extends script.base_script -1, -1 }; - for (int i = 0; i < ctsOjbvars.length; ++i) - { - if ((ctsOjbvars[i] != null) && ctsOjbvars[i].containsKey(respec.PROF_LEVEL_ARRAY) && ctsOjbvars[i].isIntArray(respec.PROF_LEVEL_ARRAY)) - { - int[] levelArray = ctsOjbvars[i].getIntArray(respec.PROF_LEVEL_ARRAY); - if ((levelArray != null) && (levelArray.length == 3)) - { - if (levelArray[0] > recpecLevelsFromTransfer[0]) - { + for (dictionary ctsOjbvar : ctsOjbvars) { + if ((ctsOjbvar != null) && ctsOjbvar.containsKey(respec.PROF_LEVEL_ARRAY) && ctsOjbvar.isIntArray(respec.PROF_LEVEL_ARRAY)) { + int[] levelArray = ctsOjbvar.getIntArray(respec.PROF_LEVEL_ARRAY); + if ((levelArray != null) && (levelArray.length == 3)) { + if (levelArray[0] > recpecLevelsFromTransfer[0]) { recpecLevelsFromTransfer[0] = levelArray[0]; } - if (levelArray[1] > recpecLevelsFromTransfer[1]) - { + if (levelArray[1] > recpecLevelsFromTransfer[1]) { recpecLevelsFromTransfer[1] = levelArray[1]; } - if (levelArray[2] > recpecLevelsFromTransfer[2]) - { + if (levelArray[2] > recpecLevelsFromTransfer[2]) { recpecLevelsFromTransfer[2] = levelArray[2]; } } @@ -7331,28 +6961,21 @@ public class utils extends script.base_script return; } HashSet abilities = new HashSet(); - for (int i = 0; i < ctsOjbvars.length; ++i) - { - if (ctsOjbvars[i] != null) - { + String objVarName; + for (dictionary ctsOjbvar : ctsOjbvars) { + if (ctsOjbvar != null) { int j = 0; - while (true) - { - final String objVarName = beast_lib.PLAYER_KNOWN_SKILLS_LIST + "." + j; - if (ctsOjbvars[i].containsKey(objVarName) && ctsOjbvars[i].isIntArray(objVarName)) - { - final int[] objVarValue = ctsOjbvars[i].getIntArray(objVarName); - if ((objVarValue != null) && (objVarValue.length > 0)) - { - for (int k = 0; k < objVarValue.length; ++k) - { - abilities.add(new Integer(objVarValue[k])); + while (true) { + objVarName = beast_lib.PLAYER_KNOWN_SKILLS_LIST + "." + j; + if (ctsOjbvar.containsKey(objVarName) && ctsOjbvar.isIntArray(objVarName)) { + final int[] objVarValue = ctsOjbvar.getIntArray(objVarName); + if ((objVarValue != null) && (objVarValue.length > 0)) { + for (int anObjVarValue : objVarValue) { + abilities.add(anObjVarValue); } } ++j; - } - else - { + } else { break; } } @@ -7369,12 +6992,12 @@ public class utils extends script.base_script else { HashSet abilitiesCurrentNoDupes = new HashSet(); - for (int i = 0; i < abilitiesCurrent.size(); ++i) - { - abilitiesCurrentNoDupes.add(new Integer((Integer) abilitiesCurrent.get(i))); + for (Object anAbilitiesCurrent : abilitiesCurrent) { + abilitiesCurrentNoDupes.add(new Integer((Integer) anAbilitiesCurrent)); } + Integer ability; for (Object abilitiesCurrentNoDupe : abilitiesCurrentNoDupes) { - Integer ability = (Integer) abilitiesCurrentNoDupe; + ability = (Integer) abilitiesCurrentNoDupe; abilities.add(ability); } if (abilities.size() != abilitiesCurrentNoDupes.size()) @@ -7388,9 +7011,10 @@ public class utils extends script.base_script Iterator abilitiesIterator = abilities.iterator(); String strAbilitiesNew = ""; int i = 0; + Integer ability; while (abilitiesIterator.hasNext() && (i < abilitiesNew.length)) { - Integer ability = (Integer)abilitiesIterator.next(); + ability = (Integer) abilitiesIterator.next(); abilitiesNew[i] = ability; strAbilitiesNew += "" + abilitiesNew[i] + ", "; ++i; @@ -7398,9 +7022,8 @@ public class utils extends script.base_script String strAbilitiesCurrent = ""; if ((abilitiesCurrent != null) && (abilitiesCurrent.size() > 0)) { - for (int j = 0; j < abilitiesCurrent.size(); ++j) - { - strAbilitiesCurrent += "" + (Integer) abilitiesCurrent.get(j) + ", "; + for (Object anAbilitiesCurrent : abilitiesCurrent) { + strAbilitiesCurrent += "" + (Integer) anAbilitiesCurrent + ", "; } } CustomerServiceLog("CharacterTransferRetroactiveHistory", "changing " + beast_lib.PLAYER_KNOWN_SKILLS_LIST + " objvar for " + player + " from (" + strAbilitiesCurrent + ") to (" + strAbilitiesNew + ")"); @@ -7423,19 +7046,14 @@ public class utils extends script.base_script 0, 0 }; - for (int i = 0; i < ctsOjbvars.length; ++i) - { - if ((ctsOjbvars[i] != null) && ctsOjbvars[i].containsKey(player_structure.HOUSE_PACKUP_ARRAY_OBJVAR) && ctsOjbvars[i].isIntArray(player_structure.HOUSE_PACKUP_ARRAY_OBJVAR)) - { - int[] housePackupCTSValues = ctsOjbvars[i].getIntArray(player_structure.HOUSE_PACKUP_ARRAY_OBJVAR); - if ((housePackupCTSValues != null) && (housePackupCTSValues.length == 2)) - { - if (housePackupCTSValues[0] > 0) - { + for (dictionary ctsOjbvar : ctsOjbvars) { + if ((ctsOjbvar != null) && ctsOjbvar.containsKey(player_structure.HOUSE_PACKUP_ARRAY_OBJVAR) && ctsOjbvar.isIntArray(player_structure.HOUSE_PACKUP_ARRAY_OBJVAR)) { + int[] housePackupCTSValues = ctsOjbvar.getIntArray(player_structure.HOUSE_PACKUP_ARRAY_OBJVAR); + if ((housePackupCTSValues != null) && (housePackupCTSValues.length == 2)) { + if (housePackupCTSValues[0] > 0) { housePackupNewValues[0] += housePackupCTSValues[0]; } - if (housePackupCTSValues[1] > 0) - { + if (housePackupCTSValues[1] > 0) { housePackupNewValues[1] += housePackupCTSValues[1]; } } diff --git a/sku.0/sys.server/compiled/game/script/quest/util/theater_spawner.java b/sku.0/sys.server/compiled/game/script/quest/util/theater_spawner.java old mode 100644 new mode 100755 index 6717d92f2..affbbbb66 --- a/sku.0/sys.server/compiled/game/script/quest/util/theater_spawner.java +++ b/sku.0/sys.server/compiled/game/script/quest/util/theater_spawner.java @@ -1,14 +1,8 @@ package script.quest.util; -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.quests; +import script.base_class; +import script.dictionary; +import script.obj_id; public class theater_spawner extends script.base_script { @@ -19,48 +13,48 @@ public class theater_spawner extends script.base_script public static final String VAR_SPAWNED_BY = "quest_spawner.spawned_by"; public int OnInitialize(obj_id self) throws InterruptedException { - String spawner = getStringObjVar(self, "quest_spawner.type"); + String spawner = base_class.getStringObjVar(self, "quest_spawner.type"); if (spawner == null || spawner.length() < 1) { - LOG("quest", "theater_spawner.OnInitialize -- spawner is null or empty"); - return SCRIPT_CONTINUE; + base_class.LOG("quest", "theater_spawner.OnInitialize -- spawner is null or empty"); + return base_class.SCRIPT_CONTINUE; } - String datatable = getStringObjVar(self, "quest_spawner.datatable"); + String datatable = base_class.getStringObjVar(self, "quest_spawner.datatable"); if (datatable == null || datatable.length() < 1) { - LOG("quest", "theater_spawner.OnInitialize -- datatable is null or empty"); - return SCRIPT_CONTINUE; + base_class.LOG("quest", "theater_spawner.OnInitialize -- datatable is null or empty"); + return base_class.SCRIPT_CONTINUE; } - int index = dataTableSearchColumnForString(spawner, "type", datatable); + int index = base_class.dataTableSearchColumnForString(spawner, "type", datatable); if (index == -1) { - LOG("quest", "theater_spawner.OnInitialize -- can't find spawner " + spawner + " within datatable " + datatable); - return SCRIPT_CONTINUE; + base_class.LOG("quest", "theater_spawner.OnInitialize -- can't find spawner " + spawner + " within datatable " + datatable); + return base_class.SCRIPT_CONTINUE; } - dictionary row = dataTableGetRow(datatable, index); + dictionary row = base_class.dataTableGetRow(datatable, index); if (row == null) { - LOG("quest", "theater_spawner.OnInitialize -- can't find data in row " + index + " for datatable " + datatable); - return SCRIPT_CONTINUE; + base_class.LOG("quest", "theater_spawner.OnInitialize -- can't find data in row " + index + " for datatable " + datatable); + return base_class.SCRIPT_CONTINUE; } int pulse = row.getInt("pulse"); int max_spawn = row.getInt("max_spawn"); int max_population = row.getInt("max_population"); int expire = row.getInt("expire"); - setObjVar(self, "quest_spawner.pulse", pulse); - setObjVar(self, "quest_spawner.max_spawn", max_spawn); - setObjVar(self, "quest_spawner.max_pop", max_population); + base_class.setObjVar(self, "quest_spawner.pulse", pulse); + base_class.setObjVar(self, "quest_spawner.max_spawn", max_spawn); + base_class.setObjVar(self, "quest_spawner.max_pop", max_population); if (expire > 1) { - setObjVar(self, "quest_spawner.time_expired", expire + getGameTime()); + base_class.setObjVar(self, "quest_spawner.time_expired", expire + base_class.getGameTime()); } else { - setObjVar(self, "quest_spawner.time_expired", 0); + base_class.setObjVar(self, "quest_spawner.time_expired", 0); } - detachScript(self, "quest.util.theater_spawner"); - attachScript(self, "quest.util.quest_spawner"); - messageTo(self, "msgQuestSpawnerPulse", null, 5.0f, false); - return SCRIPT_CONTINUE; + base_class.detachScript(self, "quest.util.theater_spawner"); + base_class.attachScript(self, "quest.util.quest_spawner"); + base_class.messageTo(self, "msgQuestSpawnerPulse", null, 5.0f, false); + return base_class.SCRIPT_CONTINUE; } } diff --git a/sku.0/sys.server/compiled/game/script/theme_park/dungeon/generic_spawner.java b/sku.0/sys.server/compiled/game/script/theme_park/dungeon/generic_spawner.java index 33799d9a6..1f7fb9c27 100755 --- a/sku.0/sys.server/compiled/game/script/theme_park/dungeon/generic_spawner.java +++ b/sku.0/sys.server/compiled/game/script/theme_park/dungeon/generic_spawner.java @@ -28,8 +28,7 @@ public class generic_spawner extends script.base_script public static final String GENERIC_SPAWNER_ACTIVE = "genericSpawner.isActive"; public int OnAttach(obj_id self) throws InterruptedException { - String name = getTemplateName(self); - if (name.equals("object/building/general/bunker_allum_mine.iff")) + if (getTemplateName(self).equals("object/building/general/bunker_allum_mine.iff")) { String setting = getConfigSetting("Dungeon", "Death_Watch"); if (setting == null || setting.equals("false") || setting.equals("0")) @@ -49,8 +48,7 @@ public class generic_spawner extends script.base_script } public int OnInitialize(obj_id self) throws InterruptedException { - String name = getTemplateName(self); - if (name.equals("object/building/general/bunker_allum_mine.iff")) + if (getTemplateName(self).equals("object/building/general/bunker_allum_mine.iff")) { String setting = getConfigSetting("Dungeon", "Death_Watch"); if (setting == null || setting.equals("false") || setting.equals("0")) @@ -75,15 +73,13 @@ public class generic_spawner extends script.base_script { return SCRIPT_OVERRIDE; } - int numberOfCreaturesToSpawn = dataTableGetNumRows(datatable); int x = utils.getIntScriptVar(self, "spawnCounter"); setDungeonActive(self, true); - while (x < numberOfCreaturesToSpawn) + while (x < dataTableGetNumRows(datatable)) { if (hasObjVar(self, SPAWNED + x)) { - obj_id check = getObjIdObjVar(self, SPAWNED + x); - if (!check.isLoaded()) + if (!getObjIdObjVar(self, SPAWNED + x).isLoaded()) { spawnCreatures(x, datatable, self); } @@ -126,30 +122,18 @@ public class generic_spawner extends script.base_script { return SCRIPT_CONTINUE; } - for (int i = 0; i < objects.length; i++) - { - if (isPlayer(objects[i])) - { - if (instance.isInInstanceArea(objects[i])) - { - instance.requestExitPlayer(self, objects[i], 1); + for (obj_id object : objects) { + if (isPlayer(object)) { + if (instance.isInInstanceArea(object)) { + instance.requestExitPlayer(self, object, 1); continue; - } - else - { - space_dungeon.verifyPlayerSession(objects[i]); + } else { + space_dungeon.verifyPlayerSession(object); continue; } } - if (isMob(objects[i])) - { - trial.cleanupNpc(objects[i]); - continue; - } - if (trial.isTempObject(objects[i])) - { - trial.cleanupNpc(objects[i]); - continue; + if (isMob(object) || trial.isTempObject(object)) { + trial.cleanupNpc(object); } } return SCRIPT_CONTINUE; @@ -161,24 +145,14 @@ public class generic_spawner extends script.base_script return SCRIPT_CONTINUE; } int spawn_num = params.getInt("spawnNumber"); - obj_id spawn_mob = params.getObjId("spawnMob"); - if (hasObjVar(self, SPAWNED + spawn_num) && (spawn_mob == getObjIdObjVar(self, SPAWNED + spawn_num))) + if (hasObjVar(self, SPAWNED + spawn_num) && (params.getObjId("spawnMob") == getObjIdObjVar(self, SPAWNED + spawn_num))) { - String datatable = getStringObjVar(self, "spawn_table"); - spawnCreatures(spawn_num, datatable, self); + spawnCreatures(spawn_num, getStringObjVar(self, "spawn_table"), self); } return SCRIPT_CONTINUE; } - public boolean isDungeonActive(obj_id dungeon) throws InterruptedException - { - if (utils.hasScriptVar(dungeon, GENERIC_SPAWNER_ACTIVE)) - { - return utils.getBooleanScriptVar(dungeon, GENERIC_SPAWNER_ACTIVE); - } - else - { - return true; - } + public boolean isDungeonActive(obj_id dungeon) throws InterruptedException { + return !utils.hasScriptVar(dungeon, GENERIC_SPAWNER_ACTIVE) || utils.getBooleanScriptVar(dungeon, GENERIC_SPAWNER_ACTIVE); } public void setDungeonActive(obj_id dungeon, boolean state) throws InterruptedException { @@ -186,42 +160,30 @@ public class generic_spawner extends script.base_script } public void attachRoomScripts(obj_id self, String datatable) throws InterruptedException { - String[] roomsToLock = dataTableGetStringColumnNoDefaults(datatable, "special_room"); - int numRooms = roomsToLock.length; int passThrough = 0; - while (passThrough < numRooms) + while (passThrough < dataTableGetStringColumnNoDefaults(datatable, "special_room").length) { String roomName = dataTableGetString(datatable, passThrough, "special_room"); String roomScript = dataTableGetString(datatable, passThrough, "special_room_script"); - if (roomName == null && roomName.equals("")) + if (roomName == null || roomName.equals("")) { - setObjVar(self, "problem", "No room name"); + setObjVar(self, "problem", "No Special Room Name found."); return; } - if (roomScript == null && roomScript.equals("")) + if (roomScript == null || roomScript.equals("")) { - setObjVar(self, "problem", "No Script"); + setObjVar(self, "problem", "No Special Room Script found."); return; } - obj_id roomObj = self; - if (roomName.equals("self")) - { - roomObj = self; - } - else - { - roomObj = getCellId(self, roomName); - } + obj_id roomObj = roomName.equals("self") ? self : getCellId(self, roomName); attachScript(roomObj, roomScript); setObjVar(self, "set_room", passThrough); - passThrough = passThrough + 1; + passThrough++; } - return; } public void setRoomObjVars(obj_id self, String datatable) throws InterruptedException { - String[] roomsToSet = dataTableGetStringColumnNoDefaults(datatable, "room_objvar"); - int numRooms = roomsToSet.length; + int numRooms = dataTableGetStringColumnNoDefaults(datatable, "room_objvar").length; if (numRooms == 0) { return; @@ -230,28 +192,24 @@ public class generic_spawner extends script.base_script while (passThrough < numRooms) { String roomName = dataTableGetString(datatable, passThrough, "room_objvar"); - String roomObjVar = dataTableGetString(datatable, passThrough, "room_objvar_name"); - String roomObjVarValue = dataTableGetString(datatable, passThrough, "room_objvar_value"); if (roomName == null || roomName.equals("")) { setObjVar(self, "problem", "No room name"); return; } + String roomObjVar = dataTableGetString(datatable, passThrough, "room_objvar_name"); if (roomObjVar == null || roomObjVar.equals("")) { setObjVar(self, "problem", "No ObjVar Name"); return; } - obj_id roomObj = getCellId(self, roomName); - setObjVar(roomObj, roomObjVar, roomObjVarValue); - passThrough = passThrough + 1; + setObjVar(getCellId(self, roomName), roomObjVar, dataTableGetString(datatable, passThrough, "room_objvar_value")); + passThrough++; } - return; } public void spawnCreatures(int x, String datatable, obj_id self) throws InterruptedException { String spawn = dataTableGetString(datatable, x, "spawns"); - String creatureName = dataTableGetString(datatable, x, "name"); float xCoord = dataTableGetFloat(datatable, x, "loc_x"); float yCoord = dataTableGetFloat(datatable, x, "loc_y"); float zCoord = dataTableGetFloat(datatable, x, "loc_z"); @@ -265,7 +223,7 @@ public class generic_spawner extends script.base_script removeObjVar(self, SPAWNED + x); return; } - location spawnPoint = new location(xCoord, yCoord, zCoord, planet, room); + String creatureName = dataTableGetString(datatable, x, "name"); if (dataTableHasColumn(datatable, "boss") && dataTableHasColumn(datatable, "boss_chance") && dataTableHasColumn(datatable, "boss_name")) { String boss = dataTableGetString(datatable, x, "boss"); @@ -291,7 +249,7 @@ public class generic_spawner extends script.base_script } } } - location locTest = spawnPoint; + location locTest = new location(xCoord, yCoord, zCoord, planet, room); if (dataTableHasColumn(datatable, "radius")) { float fltRadius = dataTableGetFloat(datatable, x, "radius"); @@ -303,8 +261,7 @@ public class generic_spawner extends script.base_script int level = -1; if (dataTableHasColumn(datatable, "planet_level")) { - int useLevel = dataTableGetInt(datatable, x, "planet_level"); - if (useLevel != 0) + if (dataTableGetInt(datatable, x, "planet_level") != 0) { level = getRandomPlanetCreatureLevel(self, spawn, locTest); } @@ -400,17 +357,13 @@ public class generic_spawner extends script.base_script ai_lib.setDefaultCalmMood(spawnedCreature, creatureMood); } } - return; } public int animationMood(obj_id self, dictionary params) throws InterruptedException { - int x = params.getInt("x"); - String datatable = params.getString("datatable"); - obj_id spawnedCreature = params.getObjId("spawnedCreature"); - String creatureAnimationMood = dataTableGetString(datatable, x, "animation_mood"); + String creatureAnimationMood = dataTableGetString(params.getString("datatable"), params.getInt("x"), "animation_mood"); if (creatureAnimationMood != null && !creatureAnimationMood.equals("")) { - ai_lib.setAnimationMood(spawnedCreature, creatureAnimationMood); + ai_lib.setAnimationMood(params.getObjId("spawnedCreature"), creatureAnimationMood); } return SCRIPT_CONTINUE; } @@ -421,47 +374,35 @@ public class generic_spawner extends script.base_script return; } String[] pairs = split(objVarList, ','); - for (int i = 0; i < pairs.length; i++) - { - String[] objVarToSet = split(pairs[i], '='); + for (String pair : pairs) { + String[] objVarToSet = split(pair, '='); String objVarValue = objVarToSet[1]; String[] objVarNameAndType = split(objVarToSet[0], ':'); String objVarType = objVarNameAndType[0]; String objVarName = objVarNameAndType[1]; - if (objVarType.equals("string")) - { - setObjVar(creature, objVarName, objVarValue); - } - else if (objVarType.equals("int")) - { - setObjVar(creature, objVarName, utils.stringToInt(objVarValue)); - } - else if (objVarType.equals("float")) - { - setObjVar(creature, objVarName, utils.stringToFloat(objVarValue)); - } - else if (objVarType.equals("boolean") || objVarType.equals("bool")) - { - setObjVar(creature, objVarName, utils.stringToInt(objVarValue)); - } - else - { - setObjVar(creature, objVarName, objVarValue); + switch (objVarType) { + case "string": + setObjVar(creature, objVarName, objVarValue); + break; + case "int": + setObjVar(creature, objVarName, utils.stringToInt(objVarValue)); + break; + case "float": + setObjVar(creature, objVarName, utils.stringToFloat(objVarValue)); + break; + case "boolean": + case "bool": + setObjVar(creature, objVarName, utils.stringToInt(objVarValue)); + break; + default: + setObjVar(creature, objVarName, objVarValue); + break; } } } - public boolean canSpawnByConfigSetting() throws InterruptedException - { + public boolean canSpawnByConfigSetting() throws InterruptedException { String disableSpawners = getConfigSetting("GameServer", "disableGenericSpawner"); - 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 getRandomPlanetCreatureLevel(obj_id spawner, String npcType, location here) throws InterruptedException { diff --git a/sku.0/sys.server/compiled/game/script/theme_park/tatooine/jabbaspawner/behavior/conversing.java b/sku.0/sys.server/compiled/game/script/theme_park/tatooine/jabbaspawner/behavior/conversing.java old mode 100644 new mode 100755 index 999109007..7540e74bf --- a/sku.0/sys.server/compiled/game/script/theme_park/tatooine/jabbaspawner/behavior/conversing.java +++ b/sku.0/sys.server/compiled/game/script/theme_park/tatooine/jabbaspawner/behavior/conversing.java @@ -34,10 +34,8 @@ public class conversing extends script.base_script { if (!ai_lib.isInCombat(self)) { - int anims = getIntObjVar(self, "animsLeft"); String action = "wave_hail"; - int move = rand(1, 10); - switch (move) + switch (rand(1, 10)) { case 1: action = "check_wrist_device"; @@ -71,8 +69,7 @@ public class conversing extends script.base_script break; } doAnimationAction(self, action); - int speed = rand(15, 25); - messageTo(self, "playAnimation", null, speed, false); + messageTo(self, "playAnimation", null, rand(15, 25), false); } return SCRIPT_CONTINUE; } diff --git a/sku.0/sys.server/compiled/game/script/theme_park/tatooine/jabbaspawner/masterspawner.java b/sku.0/sys.server/compiled/game/script/theme_park/tatooine/jabbaspawner/masterspawner.java old mode 100644 new mode 100755 index c9681261c..b6aa80cff --- a/sku.0/sys.server/compiled/game/script/theme_park/tatooine/jabbaspawner/masterspawner.java +++ b/sku.0/sys.server/compiled/game/script/theme_park/tatooine/jabbaspawner/masterspawner.java @@ -1,23 +1,17 @@ package script.theme_park.tatooine.jabbaspawner; -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.ai.ai; +import script.dictionary; import script.library.ai_lib; import script.library.create; +import script.location; +import script.obj_id; public class masterspawner extends script.base_script { public masterspawner() { } - public static final String VERSION = "v1.00.00"; + // public static final String VERSION = "v1.00.00"; public int OnInitialize(obj_id self) throws InterruptedException { debugServerConsoleMsg(self, "Attached Jabba's Palace Spawn Script"); @@ -91,7 +85,6 @@ public class masterspawner extends script.base_script { spawnCelebs(self); messageTo(self, "throneRoom", null, 10, true); - return; } public int throneRoom(obj_id self, dictionary params) throws InterruptedException { @@ -139,18 +132,16 @@ public class masterspawner extends script.base_script spawnBarada(self); spawnKlaatu(self); spawnPorcellus(self); - obj_id malakili = spawnMalakili(self); - spawnRancor(self, malakili); + spawnRancor(self, spawnMalakili(self)); spawnOrgan(self); - obj_id reelo = spawnReelo(self); - spawnReeYees(self, reelo); + spawnReeYees(self, spawnReelo(self)); spawnJawl(self); } public void spawnThrone(obj_id self) throws InterruptedException { obj_id oola = spawnOola(self); spawnMax(self, oola); - obj_id sy = spawnSy(self, oola); + spawnSy(self, oola); spawnDroopy(self, oola); spawnJabba(self, oola); spawnPDroid(self, oola); @@ -170,7 +161,7 @@ public class masterspawner extends script.base_script spawnGamGuard8(self, gamGuard6); spawnGamGuard9(self); spawnGamGuard10(self); - obj_id gamGuard11 = spawnGamGuard11(self); + spawnGamGuard11(self); spawnGamGuard12(self); spawnGamGuard13(self); } @@ -181,40 +172,29 @@ public class masterspawner extends script.base_script spawnBomarrMonk3(self); spawnBomarrMonk4(self); spawnBomarrMonk5(self); - obj_id bomarrMonk6 = spawnBomarrMonk6(self); + spawnBomarrMonk6(self); } public void spawnJawas(obj_id self) throws InterruptedException { - obj_id jawa1 = spawnJawa1(self); spawnJawa2(self); - obj_id jawa3 = spawnJawa3(self); - obj_id jawa4 = spawnJawa4(self); spawnJawa5(self); - spawnJawa6(self, jawa1); - obj_id jawa7 = spawnJawa7(self); - spawnJawa8(self, jawa7); - obj_id jawa9 = spawnJawa9(self); - spawnJawa10(self, jawa9); - spawnRandom13(self, jawa3); - spawnRandom14(self, jawa4); + // note: the following lines each spawn two diff Jawa's in a single line of code. + spawnJawa6(self, spawnJawa1(self)); + spawnJawa8(self, spawnJawa7(self)); + spawnJawa10(self, spawnJawa9(self)); + spawnRandom13(self, spawnJawa3(self)); + spawnRandom14(self, spawnJawa4(self)); } public void spawnRandom(obj_id self) throws InterruptedException { - obj_id gamGuard5 = spawnGamGuard5(self); - spawnRandom1(self, gamGuard5); + spawnRandom1(self, spawnGamGuard5(self)); spawnRandom2(self); - obj_id random3 = spawnRandom3(self); - spawnRandom4(self, random3); - obj_id random5 = spawnRandom5(self); - obj_id random6 = spawnRandom6(self); - obj_id random7 = spawnRandom7(self); - spawnRandom8(self, random7); - obj_id random9 = spawnRandom9(self); - spawnRandom10(self, random9); - obj_id random11 = spawnRandom11(self); - spawnRandom12(self, random11); - spawnRandom15(self, random5); - spawnRandom16(self, random6); + spawnRandom4(self, spawnRandom3(self)); + spawnRandom8(self, spawnRandom7(self)); + spawnRandom10(self, spawnRandom9(self)); + spawnRandom12(self, spawnRandom11(self)); + spawnRandom15(self, spawnRandom5(self)); + spawnRandom16(self, spawnRandom6(self)); } public void spawnDroids(obj_id self) throws InterruptedException { @@ -239,9 +219,7 @@ public class masterspawner extends script.base_script } public obj_id spawnBib(obj_id self, obj_id oola) throws InterruptedException { - obj_id throne = getCellId(self, "throneroom"); - location bibLocation = new location(-12.09f, 2f, 49.41f, "tatooine", throne); - obj_id bib = create.staticObject("bib_fortuna", bibLocation); + obj_id bib = create.staticObject("bib_fortuna", new location(-12.09f, 2f, 49.41f, "tatooine", getCellId(self, "throneroom"))); faceTo(bib, oola); attachScript(bib, "theme_park.tatooine.jabbaspawner.bib"); setObjVar(self, "PalaceInhabitants.bib", bib); @@ -250,9 +228,7 @@ public class masterspawner extends script.base_script } public obj_id spawnReelo(obj_id self) throws InterruptedException { - obj_id foyer = getCellId(self, "foyer"); - location reeloLocation = new location(-2, 2, 113, "tatooine", foyer); - obj_id reelo = create.staticObject("reelo_baruk", reeloLocation); + obj_id reelo = create.staticObject("reelo_baruk", new location(-2, 2, 113, "tatooine", getCellId(self, "foyer"))); attachScript(reelo, "theme_park.tatooine.jabbaspawner.reelo"); setObjVar(self, "PalaceInhabitants.reelo", reelo); setObjVar(reelo, "palace", self); @@ -260,20 +236,15 @@ public class masterspawner extends script.base_script } public void spawnReeYees(obj_id self, obj_id reelo) throws InterruptedException { - obj_id foyer = getCellId(self, "foyer"); - location ReeYeesLocation = new location(5.97f, .3f, 116.1f, "tatooine", foyer); - obj_id ReeYees = create.staticObject("ree_yees", ReeYeesLocation); + obj_id ReeYees = create.staticObject("ree_yees", new location(5.97f, .3f, 116.1f, "tatooine", getCellId(self, "foyer"))); faceTo(ReeYees, reelo); attachScript(ReeYees, "theme_park.tatooine.jabbaspawner.reeyees"); setObjVar(self, "PalaceInhabitants.reeyees", ReeYees); setObjVar(ReeYees, "palace", self); - return; } public obj_id spawnEphant(obj_id self) throws InterruptedException { - obj_id office = getCellId(self, "office"); - location ephantLocation = new location(-6, 8, 84, "tatooine", office); - obj_id ephant = create.staticObject("ephant_mon", ephantLocation); + obj_id ephant = create.staticObject("ephant_mon", new location(-6, 8, 84, "tatooine", getCellId(self, "office"))); attachScript(ephant, "theme_park.tatooine.jabbaspawner.ephant"); setObjVar(self, "PalaceInhabitants.ephant", ephant); setObjVar(ephant, "palace", self); @@ -281,9 +252,7 @@ public class masterspawner extends script.base_script } public obj_id spawnOola(obj_id self) throws InterruptedException { - obj_id throneroom = getCellId(self, "throneroom"); - location oolaLocation = new location(-10, 4, 43, "tatooine", throneroom); - obj_id oola = create.staticObject("oola", oolaLocation); + obj_id oola = create.staticObject("oola", new location(-10, 4, 43, "tatooine", getCellId(self, "throneroom"))); attachScript(oola, "theme_park.tatooine.jabbaspawner.oola"); setObjVar(self, "PalaceInhabitants.oola", oola); setObjVar(oola, "palace", self); @@ -291,102 +260,76 @@ public class masterspawner extends script.base_script } public void spawnMax(obj_id self, obj_id oola) throws InterruptedException { - obj_id throneroom = getCellId(self, "throneroom"); - location maxLocation = new location(-11, 2, 36, "tatooine", throneroom); - obj_id max = create.staticObject("max_rebo", maxLocation); + obj_id max = create.staticObject("max_rebo", new location(-11, 2, 36, "tatooine", getCellId(self, "throneroom"))); faceTo(max, oola); attachScript(max, "theme_park.tatooine.jabbaspawner.max"); setObjVar(self, "PalaceInhabitants.max", max); setObjVar(max, "palace", self); setObjVar(max, "oola", oola); setObjVar(oola, "max", max); - return; } public void spawnOrgan(obj_id self) throws InterruptedException { - obj_id throneroom = getCellId(self, "throneroom"); - location organLoc = new location(-11, 2, 36, "tatooine", throneroom); - obj_id organ = createObject("object/tangible/instrument/organ_max_rebo.iff", organLoc); - return; + createObject("object/tangible/instrument/organ_max_rebo.iff", new location(-11, 2, 36, "tatooine", getCellId(self, "throneroom"))); } - public obj_id spawnSy(obj_id self, obj_id oola) throws InterruptedException + public void spawnSy(obj_id self, obj_id oola) throws InterruptedException { - obj_id throneroom = getCellId(self, "throneroom"); - location syLocation = new location(-9, 4, 37, "tatooine", throneroom); - obj_id sy = create.staticObject("sy_snootles", syLocation); + obj_id sy = create.staticObject("sy_snootles", new location(-8, 4, 37, "tatooine", getCellId(self, "throneroom"))); faceTo(sy, oola); attachScript(sy, "theme_park.tatooine.jabbaspawner.sy"); setObjVar(self, "PalaceInhabitants.sy", sy); setObjVar(sy, "palace", self); setObjVar(oola, "sy", sy); - syLocation.x = syLocation.x + 1; - return sy; } public void spawnDroopy(obj_id self, obj_id oola) throws InterruptedException { - obj_id throneroom = getCellId(self, "throneroom"); - location droopyLocation = new location(-13, 4, 37, "tatooine", throneroom); - obj_id droopy = create.staticObject("droopy_mccool", droopyLocation); + obj_id droopy = create.staticObject("droopy_mccool", new location(-13, 4, 37, "tatooine", getCellId(self, "throneroom"))); faceTo(droopy, oola); - obj_id horn = createObject("object/tangible/instrument/kloo_horn.iff", droopy, ""); - equip(horn, droopy); + equip(createObject("object/tangible/instrument/kloo_horn.iff", droopy, ""), droopy); attachScript(droopy, "theme_park.tatooine.jabbaspawner.droopy"); setObjVar(self, "PalaceInhabitants.droopy", droopy); setObjVar(droopy, "palace", self); setObjVar(oola, "droopy", droopy); - return; } public void spawnJabba(obj_id self, obj_id oola) throws InterruptedException { - obj_id throneroom = getCellId(self, "throneroom"); - location jabbaLocation = new location(-16.65f, 7, 45, "tatooine", throneroom); - obj_id jabba = create.staticObject("jabba_the_hutt", jabbaLocation); + obj_id jabba = create.staticObject("jabba_the_hutt", new location(-16.65f, 7, 45, "tatooine", getCellId(self, "throneroom"))); faceTo(jabba, oola); attachScript(jabba, "theme_park.tatooine.jabbaspawner.jabba"); attachScript(jabba, "conversation.ep3_clone_relics_clone_trooper_jabba"); setObjVar(self, "PalaceInhabitants.jabba", jabba); setObjVar(jabba, "palace", self); - return; } public void spawnCrumb(obj_id self, obj_id oola) throws InterruptedException { - obj_id throneroom = getCellId(self, "throneroom"); - location crumbLocation = new location(-16.29f, 7.0f, 42.54f, "tatooine", throneroom); - obj_id crumb = create.staticObject("salacious_crumb", crumbLocation); + obj_id crumb = create.staticObject("salacious_crumb", new location(-16.29f, 7.0f, 42.54f, "tatooine", getCellId(self, "throneroom"))); faceTo(crumb, oola); setObjVar(self, "PalaceInhabitants.crumb", crumb); attachScript(crumb, "theme_park.tatooine.jabbaspawner.crumb"); setObjVar(crumb, "palace", self); setObjVar(crumb, "ai.defaultCalmBehavior", 1); - return; } public void spawnPDroid(obj_id self, obj_id oola) throws InterruptedException { - obj_id throneroom = getCellId(self, "throneroom"); - location pDroidLocation = new location(-15.07f, 2, 45.9f, "tatooine", throneroom); - obj_id pDroid = create.staticObject("g_5po", pDroidLocation); + obj_id pDroid = create.staticObject("g_5po", new location(-15.07f, 2, 45.9f, "tatooine", getCellId(self, "throneroom"))); faceTo(pDroid, oola); attachScript(pDroid, "theme_park.tatooine.jabbaspawner.pdroid"); setObjVar(self, "PalaceInhabitants.pDroid", pDroid); setObjVar(pDroid, "palace", self); - return; } public void spawnBarada(obj_id self) throws InterruptedException { obj_id garage1 = getCellId(self, "garage1"); - location baradaLocation = new location(30.57f, .2f, -1.05f, "tatooine", garage1); - location toolBox = new location(28, .2f, -1.05f, "tatooine", garage1); - obj_id barada = create.staticObject("barada", baradaLocation); + obj_id barada = create.staticObject("barada", new location(30.57f, .2f, -1.05f, "tatooine", garage1)); attachScript(barada, "theme_park.tatooine.jabbaspawner.barada"); setObjVar(self, "PalaceInhabitants.barada", barada); setObjVar(barada, "palace", self); - faceTo(barada, toolBox); - return; + // Barada is meant to face the toolbox. + faceTo(barada, new location(28, .2f, -1.05f, "tatooine", garage1)); } public void spawnKlaatu(obj_id self) throws InterruptedException { - location klaatuLocation = new location(-6178.97f, 90.0f, -6381.74f, "tatooine", null); - obj_id klaatu = create.staticObject("klaatu", klaatuLocation); + obj_id klaatu = create.staticObject("klaatu", new location(-6178.97f, 90.0f, -6381.74f, "tatooine", null)); attachScript(klaatu, "theme_park.tatooine.jabbaspawner.klaatu"); attachScript(klaatu, "conversation.corvette_neutral_pilot"); setObjVar(klaatu, "space_dungeon.ticket.point", "corvette_neutral_pilot"); @@ -394,23 +337,18 @@ public class masterspawner extends script.base_script attachScript(klaatu, "item.travel_ticket.travel_space_dungeon"); setObjVar(self, "PalaceInhabitants.klaatu", klaatu); setObjVar(klaatu, "palace", self); - return; } public void spawnPorcellus(obj_id self) throws InterruptedException { - obj_id kitchen = getCellId(self, "kitchen"); - location porcellusLocation = new location(-43, 5, 64, "tatooine", kitchen); + location porcellusLocation = new location(-43, 5, 64, "tatooine", getCellId(self, "kitchen")); obj_id porcellus = create.staticObject("porcellus", porcellusLocation); attachScript(porcellus, "theme_park.tatooine.jabbaspawner.porcellus"); setObjVar(self, "PalaceInhabitants.porcellus", porcellus); setObjVar(porcellus, "palace", self); - return; } public obj_id spawnMalakili(obj_id self) throws InterruptedException { - obj_id rancortrainer = getCellId(self, "rancortrainer"); - location malakiliLocation = new location(19, -9, 42, "tatooine", rancortrainer); - obj_id malakili = create.staticObject("malakili", malakiliLocation); + obj_id malakili = create.staticObject("malakili", new location(19, -9, 42, "tatooine", getCellId(self, "rancortrainer"))); attachScript(malakili, "theme_park.tatooine.jabbaspawner.malakili"); setObjVar(self, "PalaceInhabitants.malakili", malakili); setObjVar(malakili, "palace", self); @@ -418,34 +356,26 @@ public class masterspawner extends script.base_script } public void spawnRancor(obj_id self, obj_id malakili) throws InterruptedException { - obj_id rancorpit = getCellId(self, "rancorpit"); - location rancorLocation = new location(4, -10, 45, "tatooine", rancorpit); - obj_id rancor = create.staticObject("jabbas_palace_rancor", rancorLocation); + obj_id rancor = create.staticObject("jabbas_palace_rancor", new location(4, -10, 45, "tatooine", getCellId(self, "rancorpit"))); faceTo(rancor, malakili); attachScript(rancor, "theme_park.tatooine.jabbaspawner.rancor"); setObjVar(self, "PalaceInhabitants.rancor", rancor); setObjVar(rancor, "palace", self); setObjVar(rancor, "gm", 1); - return; } public void spawnBoba(obj_id self, obj_id oola) throws InterruptedException { - obj_id throneroom = getCellId(self, "throneroom"); - location bobaLocation = new location(-1, 5, 31, "tatooine", throneroom); - obj_id boba = create.staticObject("boba_fett", bobaLocation); + obj_id boba = create.staticObject("boba_fett", new location(-1, 5, 31, "tatooine", getCellId(self, "throneroom"))); faceTo(boba, oola); attachScript(boba, "theme_park.tatooine.jabbaspawner.boba"); attachScript(boba, "conversation.boba_fett"); setObjVar(self, "PalaceInhabitants.boba", boba); setObjVar(boba, "palace", self); - return; } - public obj_id spawnGamGuard1(obj_id self, obj_id bib) throws InterruptedException + public obj_id spawnGamGuard1(obj_id self, obj_id whoToFace) throws InterruptedException { - obj_id office = getCellId(self, "office"); - location gamGuard1Location = new location(1, 7, 88, "tatooine", office); - obj_id gamGuard1 = create.object("gamorrean_guard", gamGuard1Location); - faceTo(gamGuard1, bib); + obj_id gamGuard1 = create.object("gamorrean_guard", new location(1, 7, 88, "tatooine", getCellId(self, "office"))); + faceTo(gamGuard1, whoToFace); attachScript(gamGuard1, "theme_park.tatooine.jabbaspawner.gamguard1"); attachScript(gamGuard1, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.gamGuard1", gamGuard1); @@ -455,48 +385,37 @@ public class masterspawner extends script.base_script } public void spawnGamGuard2(obj_id self, obj_id gamGuard1) throws InterruptedException { - obj_id office = getCellId(self, "office"); - location gamGuard2Location = new location(1, 7, 80, "tatooine", office); - obj_id gamGuard2 = create.object("gamorrean_guard", gamGuard2Location); + obj_id gamGuard2 = create.object("gamorrean_guard", new location(1, 7, 80, "tatooine", getCellId(self, "office"))); faceTo(gamGuard2, gamGuard1); attachScript(gamGuard2, "theme_park.tatooine.jabbaspawner.gamguard2"); attachScript(gamGuard2, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.gamGuard2", gamGuard2); setObjVar(gamGuard2, "palace", self); setName(gamGuard2, "Rogua"); - return; } public void spawnGamGuard3(obj_id self, obj_id gamGuard1) throws InterruptedException { - obj_id office = getCellId(self, "office"); - location gamGuard3Location = new location(-11, 7, 88, "tatooine", office); - obj_id gamGuard3 = create.object("gamorrean_guard", gamGuard3Location); + obj_id gamGuard3 = create.object("gamorrean_guard", new location(-11, 7, 88, "tatooine", getCellId(self, "office"))); faceTo(gamGuard3, gamGuard1); attachScript(gamGuard3, "theme_park.tatooine.jabbaspawner.gamguard3"); attachScript(gamGuard3, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.gamGuard3", gamGuard3); setObjVar(gamGuard3, "palace", self); setName(gamGuard3, "Gartogg"); - return; } - public void spawnGamGuard4(obj_id self, obj_id bib) throws InterruptedException + public void spawnGamGuard4(obj_id self, obj_id whoToFace) throws InterruptedException { - obj_id office = getCellId(self, "office"); - location gamGuard4Location = new location(-1, 7, 98, "tatooine", office); - obj_id gamGuard4 = create.object("gamorrean_guard", gamGuard4Location); - faceTo(gamGuard4, bib); + obj_id gamGuard4 = create.object("gamorrean_guard", new location(-1, 7, 98, "tatooine", getCellId(self, "office"))); + faceTo(gamGuard4, whoToFace); attachScript(gamGuard4, "theme_park.tatooine.jabbaspawner.gamguard4"); attachScript(gamGuard4, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.gamGuard4", gamGuard4); setObjVar(gamGuard4, "palace", self); setName(gamGuard4, "Torrug"); - return; } public obj_id spawnGamGuard5(obj_id self) throws InterruptedException { - obj_id hall2 = getCellId(self, "hall2"); - location gamGuard5Location = new location(10, 7, 71, "tatooine", hall2); - obj_id gamGuard5 = create.object("gamorrean_guard", gamGuard5Location); + obj_id gamGuard5 = create.object("gamorrean_guard", new location(10, 7, 71, "tatooine", getCellId(self, "hall2"))); attachScript(gamGuard5, "theme_park.tatooine.jabbaspawner.gamguard5"); attachScript(gamGuard5, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.gamGuard5", gamGuard5); @@ -506,9 +425,7 @@ public class masterspawner extends script.base_script } public obj_id spawnGamGuard6(obj_id self) throws InterruptedException { - obj_id hall5 = getCellId(self, "hall5"); - location gamGuard6Location = new location(-30.78f, .2f, 82.64f, "tatooine", hall5); - obj_id gamGuard6 = create.object("gamorrean_guard", gamGuard6Location); + obj_id gamGuard6 = create.object("gamorrean_guard", new location(-30.78f, .2f, 82.64f, "tatooine", getCellId(self, "hall5"))); attachScript(gamGuard6, "theme_park.tatooine.jabbaspawner.gamguard6"); setObjVar(self, "PalaceInhabitants.gamGuard6", gamGuard6); attachScript(gamGuard6, "theme_park.tatooine.jabbaspawner.palace_path"); @@ -518,172 +435,131 @@ public class masterspawner extends script.base_script } public void spawnGamGuard7(obj_id self, obj_id gamGuard6) throws InterruptedException { - obj_id hall7 = getCellId(self, "hall7"); - location gamGuard7Location = new location(-2.04f, .2f, 82.61f, "tatooine", hall7); - obj_id gamGuard7 = create.object("gamorrean_guard", gamGuard7Location); + obj_id gamGuard7 = create.object("gamorrean_guard", new location(-2.04f, .2f, 82.61f, "tatooine", getCellId(self, "hall7"))); faceTo(gamGuard7, gamGuard6); attachScript(gamGuard7, "theme_park.tatooine.jabbaspawner.gamguard7"); attachScript(gamGuard7, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.gamGuard7", gamGuard7); setObjVar(gamGuard7, "palace", self); setName(gamGuard7, "Artogg"); - return; } public void spawnGamGuard8(obj_id self, obj_id gamGuard6) throws InterruptedException { - obj_id hall4 = getCellId(self, "hall4"); - location gamGuard8Location = new location(-13, 5, 59, "tatooine", hall4); - obj_id gamGuard8 = create.object("gamorrean_guard", gamGuard8Location); + obj_id gamGuard8 = create.object("gamorrean_guard", new location(-13, 5, 59, "tatooine", getCellId(self, "hall4"))); faceTo(gamGuard8, gamGuard6); attachScript(gamGuard8, "theme_park.tatooine.jabbaspawner.gamguard8"); attachScript(gamGuard8, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.gamGuard8", gamGuard8); setObjVar(gamGuard8, "palace", self); setName(gamGuard8, "Ogtur"); - return; } public void spawnGamGuard9(obj_id self) throws InterruptedException { - obj_id jabbaPrivate = getCellId(self, "jabbaprivate"); - location gamGuard9Location = new location(-37, 5, 46, "tatooine", jabbaPrivate); - obj_id gamGuard9 = create.object("gamorrean_guard", gamGuard9Location); + obj_id gamGuard9 = create.object("gamorrean_guard", new location(-37, 5, 46, "tatooine", getCellId(self, "jabbaprivate"))); attachScript(gamGuard9, "theme_park.tatooine.jabbaspawner.gamguard9"); attachScript(gamGuard9, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.gamGuard9", gamGuard9); setObjVar(gamGuard9, "palace", self); setName(gamGuard9, "Rautog"); - return; } public void spawnGamGuard10(obj_id self) throws InterruptedException { - obj_id throneRoom = getCellId(self, "throneroom"); - location gamGuard10Location = new location(-25, 5, 34, "tatooine", throneRoom); - obj_id gamGuard10 = create.object("gamorrean_guard", gamGuard10Location); + obj_id gamGuard10 = create.object("gamorrean_guard", new location(-25, 5, 34, "tatooine", getCellId(self, "throneroom"))); attachScript(gamGuard10, "theme_park.tatooine.jabbaspawner.gamguard10"); attachScript(gamGuard10, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.gamGuard10", gamGuard10); setObjVar(gamGuard10, "palace", self); setName(gamGuard10, "Agtor"); - return; } - public obj_id spawnGamGuard11(obj_id self) throws InterruptedException + public void spawnGamGuard11(obj_id self) throws InterruptedException { - obj_id throneRoom = getCellId(self, "throneroom"); - location gamGuard11Location = new location(6, 4, 26, "tatooine", throneRoom); - obj_id gamGuard11 = create.object("gamorrean_guard", gamGuard11Location); + obj_id gamGuard11 = create.object("gamorrean_guard", new location(6, 4, 26, "tatooine", getCellId(self, "throneroom"))); attachScript(gamGuard11, "theme_park.tatooine.jabbaspawner.gamguard11"); attachScript(gamGuard11, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.gamGuard11", gamGuard11); setObjVar(gamGuard11, "palace", self); setName(gamGuard11, "Torgau"); - return gamGuard11; } public void spawnGamGuard12(obj_id self) throws InterruptedException { - obj_id rancorTrainer = getCellId(self, "rancortrainer"); - location gamGuard12Location = new location(22, -9, 48, "tatooine", rancorTrainer); - obj_id gamGuard12 = create.object("gamorrean_guard", gamGuard12Location); + obj_id gamGuard12 = create.object("gamorrean_guard", new location(22, -9, 48, "tatooine", getCellId(self, "rancortrainer"))); attachScript(gamGuard12, "theme_park.tatooine.jabbaspawner.gamguard12"); attachScript(gamGuard12, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.gamGuard12", gamGuard12); setObjVar(gamGuard12, "palace", self); setName(gamGuard12, "Ugtaur"); - return; } public void spawnGamGuard13(obj_id self) throws InterruptedException { - obj_id throneRoom = getCellId(self, "throneroom"); - location gamGuard13Location = new location(.14f, 2f, 53.1f, "tatooine", throneRoom); - obj_id gamGuard13 = create.object("gamorrean_guard", gamGuard13Location); + obj_id gamGuard13 = create.object("gamorrean_guard", new location(.14f, 2f, 53.1f, "tatooine", getCellId(self, "throneroom"))); attachScript(gamGuard13, "theme_park.tatooine.jabbaspawner.gamguard13"); attachScript(gamGuard13, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.gamGuard13", gamGuard13); setName(gamGuard13, "Gurgot"); setObjVar(gamGuard13, "palace", self); - return; } public void spawnBomarrMonk1(obj_id self) throws InterruptedException { - obj_id bibspawn = getCellId(self, "bibspawn"); - location bomarrMonk1Location = new location(-24, 10, 86, "tatooine", bibspawn); - obj_id bomarrMonk1 = create.object("bomarr_monk", bomarrMonk1Location); + obj_id bomarrMonk1 = create.object("bomarr_monk", new location(-24, 10, 86, "tatooine", getCellId(self, "bibspawn"))); setObjVar(bomarrMonk1, "ai.defaultCalmBehavior", 1); attachScript(bomarrMonk1, "theme_park.tatooine.jabbaspawner.bomarrmonk1"); attachScript(bomarrMonk1, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.bomarrMonk1", bomarrMonk1); setObjVar(bomarrMonk1, "palace", self); setInvulnerable(bomarrMonk1, true); - return; } public void spawnBomarrMonk2(obj_id self) throws InterruptedException { - obj_id hall1 = getCellId(self, "hall1"); - location bomarrMonk2Location = new location(-2, 4, 104, "tatooine", hall1); - obj_id bomarrMonk2 = create.object("bomarr_monk", bomarrMonk2Location); + obj_id bomarrMonk2 = create.object("bomarr_monk", new location(-2, 4, 104, "tatooine", getCellId(self, "hall1"))); setObjVar(bomarrMonk2, "ai.defaultCalmBehavior", 1); attachScript(bomarrMonk2, "theme_park.tatooine.jabbaspawner.bomarrmonk2"); attachScript(bomarrMonk2, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.bomarrMonk2", bomarrMonk2); setObjVar(bomarrMonk2, "palace", self); setInvulnerable(bomarrMonk2, true); - return; } public void spawnBomarrMonk3(obj_id self) throws InterruptedException { - obj_id spawn1 = getCellId(self, "spawn1"); - location bomarrMonk3Location = new location(-18, 9, 73, "tatooine", spawn1); - obj_id bomarrMonk3 = create.object("bomarr_monk", bomarrMonk3Location); + obj_id bomarrMonk3 = create.object("bomarr_monk", new location(-18, 9, 73, "tatooine", getCellId(self, "spawn1"))); setObjVar(bomarrMonk3, "ai.defaultCalmBehavior", 1); attachScript(bomarrMonk3, "theme_park.tatooine.jabbaspawner.bomarrmonk3"); attachScript(bomarrMonk3, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.bomarrMonk3", bomarrMonk3); setObjVar(bomarrMonk3, "palace", self); setInvulnerable(bomarrMonk3, true); - return; } public void spawnBomarrMonk4(obj_id self) throws InterruptedException { - obj_id throneroom = getCellId(self, "throneroom"); - location bomarrMonk4Location = new location(7, 6, 50, "tatooine", throneroom); - obj_id bomarrMonk4 = create.object("bomarr_monk", bomarrMonk4Location); + obj_id bomarrMonk4 = create.object("bomarr_monk", new location(7, 6, 50, "tatooine", getCellId(self, "throneroom"))); setObjVar(bomarrMonk4, "ai.defaultCalmBehavior", 1); attachScript(bomarrMonk4, "theme_park.tatooine.jabbaspawner.bomarrmonk4"); attachScript(bomarrMonk4, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.bomarrMonk4", bomarrMonk4); setObjVar(bomarrMonk4, "palace", self); setInvulnerable(bomarrMonk4, true); - return; } public void spawnBomarrMonk5(obj_id self) throws InterruptedException { - obj_id garage2 = getCellId(self, "garage2"); - location bomarrMonk5Location = new location(24, 4, -9, "tatooine", garage2); - obj_id bomarrMonk5 = create.object("bomarr_monk", bomarrMonk5Location); + obj_id bomarrMonk5 = create.object("bomarr_monk", new location(24, 4, -9, "tatooine", getCellId(self, "garage2"))); setObjVar(bomarrMonk5, "ai.defaultCalmBehavior", 1); attachScript(bomarrMonk5, "theme_park.tatooine.jabbaspawner.bomarrmonk5"); attachScript(bomarrMonk5, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.bomarrMonk5", bomarrMonk5); setObjVar(bomarrMonk5, "palace", self); setInvulnerable(bomarrMonk5, true); - return; } - public obj_id spawnBomarrMonk6(obj_id self) throws InterruptedException + public void spawnBomarrMonk6(obj_id self) throws InterruptedException { - obj_id display = getCellId(self, "display"); - location bomarrMonk6Location = new location(-18, 7, 9, "tatooine", display); - obj_id bomarrMonk6 = create.object("bomarr_monk", bomarrMonk6Location); + obj_id bomarrMonk6 = create.object("bomarr_monk", new location(-18, 7, 9, "tatooine", getCellId(self, "display"))); setObjVar(bomarrMonk6, "ai.defaultCalmBehavior", 1); attachScript(bomarrMonk6, "theme_park.tatooine.jabbaspawner.bomarrmonk6"); setObjVar(self, "PalaceInhabitants.bomarrMonk6", bomarrMonk6); setObjVar(bomarrMonk6, "palace", self); setInvulnerable(bomarrMonk6, true); - return bomarrMonk6; } public obj_id spawnJawa1(obj_id self) throws InterruptedException { - obj_id hall4 = getCellId(self, "hall4"); - location jawa1Location = new location(-23, 5, 59, "tatooine", hall4); - obj_id jawa1 = create.staticObject("jawa", jawa1Location); + obj_id jawa1 = create.staticObject("jawa", new location(-23, 5, 59, "tatooine", getCellId(self, "hall4"))); setObjVar(jawa1, "ai.defaultCalmBehavior", 1); attachScript(jawa1, "theme_park.tatooine.jabbaspawner.jawa1"); setObjVar(self, "PalaceInhabitants.jawa1", jawa1); @@ -693,21 +569,16 @@ public class masterspawner extends script.base_script } public void spawnJawa2(obj_id self) throws InterruptedException { - obj_id hall8 = getCellId(self, "hall8"); - location jawa2Location = new location(-38, 5, 53, "tatooine", hall8); - obj_id jawa2 = create.staticObject("jawa", jawa2Location); + obj_id jawa2 = create.staticObject("jawa", new location(-38, 5, 53, "tatooine", getCellId(self, "hall8"))); setObjVar(jawa2, "ai.defaultCalmBehavior", 1); attachScript(jawa2, "theme_park.tatooine.jabbaspawner.jawa2"); setObjVar(self, "PalaceInhabitants.jawa2", jawa2); setObjVar(jawa2, "palace", self); setInvulnerable(jawa2, true); - return; } public obj_id spawnJawa3(obj_id self) throws InterruptedException { - obj_id throneroom = getCellId(self, "throneroom"); - location jawa3Location = new location(-1, 5, 25, "tatooine", throneroom); - obj_id jawa3 = create.staticObject("jawa", jawa3Location); + obj_id jawa3 = create.staticObject("jawa", new location(-1, 5, 25, "tatooine", getCellId(self, "throneroom"))); setObjVar(jawa3, "ai.defaultCalmBehavior", 1); attachScript(jawa3, "theme_park.tatooine.jabbaspawner.jawa3"); setObjVar(self, "PalaceInhabitants.jawa3", jawa3); @@ -717,9 +588,7 @@ public class masterspawner extends script.base_script } public obj_id spawnJawa4(obj_id self) throws InterruptedException { - obj_id display = getCellId(self, "display"); - location jawa4Location = new location(-8, 5, 20, "tatooine", display); - obj_id jawa4 = create.staticObject("jawa", jawa4Location); + obj_id jawa4 = create.staticObject("jawa", new location(-8, 5, 20, "tatooine", getCellId(self, "display"))); setObjVar(jawa4, "ai.defaultCalmBehavior", 1); attachScript(jawa4, "theme_park.tatooine.jabbaspawner.jawa4"); setObjVar(self, "PalaceInhabitants.jawa4", jawa4); @@ -729,34 +598,26 @@ public class masterspawner extends script.base_script } public void spawnJawa5(obj_id self) throws InterruptedException { - obj_id display = getCellId(self, "display"); - location jawa5Location = new location(-18, 5, 13, "tatooine", display); - obj_id jawa5 = create.staticObject("jawa", jawa5Location); + obj_id jawa5 = create.staticObject("jawa", new location(-18, 5, 13, "tatooine", getCellId(self, "display"))); setObjVar(jawa5, "ai.defaultCalmBehavior", 1); attachScript(jawa5, "theme_park.tatooine.jabbaspawner.jawa5"); setObjVar(self, "PalaceInhabitants.jawa5", jawa5); setObjVar(jawa5, "palace", self); setInvulnerable(jawa5, true); - return; } public void spawnJawa6(obj_id self, obj_id jawa1) throws InterruptedException { - obj_id hall4 = getCellId(self, "hall4"); - location jawa6Location = new location(-23, 5, 61, "tatooine", hall4); - obj_id jawa6 = create.staticObject("jawa", jawa6Location); + obj_id jawa6 = create.staticObject("jawa", new location(-23, 5, 61, "tatooine", getCellId(self, "hall4"))); setObjVar(jawa6, "ai.defaultCalmBehavior", 1); faceTo(jawa6, jawa1); attachScript(jawa6, "theme_park.tatooine.jabbaspawner.jawa6"); setObjVar(self, "PalaceInhabitants.jawa6", jawa6); setObjVar(jawa6, "palace", self); setInvulnerable(jawa6, true); - return; } public obj_id spawnJawa7(obj_id self) throws InterruptedException { - obj_id throne = getCellId(self, "throneroom"); - location jawa7Location = new location(8.73f, 2f, 23.58f, "tatooine", throne); - obj_id jawa7 = create.staticObject("jawa", jawa7Location); + obj_id jawa7 = create.staticObject("jawa", new location(8.73f, 2f, 23.58f, "tatooine", getCellId(self, "throneroom"))); setObjVar(jawa7, "ai.defaultCalmBehavior", 1); attachScript(jawa7, "theme_park.tatooine.jabbaspawner.jawa7"); setObjVar(self, "PalaceInhabitants.jawa7", jawa7); @@ -766,9 +627,7 @@ public class masterspawner extends script.base_script } public void spawnJawa8(obj_id self, obj_id jawa7) throws InterruptedException { - obj_id throne = getCellId(self, "throneroom"); - location jawa8Location = new location(9.22f, 2f, 25.22f, "tatooine", throne); - obj_id jawa8 = create.staticObject("jawa", jawa8Location); + obj_id jawa8 = create.staticObject("jawa", new location(9.22f, 2f, 25.22f, "tatooine", getCellId(self, "throneroom"))); setObjVar(jawa8, "ai.defaultCalmBehavior", 1); setObjVar(jawa8, "facer", jawa7); setObjVar(jawa7, "facer", jawa8); @@ -778,13 +637,10 @@ public class masterspawner extends script.base_script setObjVar(self, "PalaceInhabitants.jawa8", jawa8); setObjVar(jawa8, "palace", self); setInvulnerable(jawa8, true); - return; } public obj_id spawnJawa9(obj_id self) throws InterruptedException { - obj_id hall3 = getCellId(self, "hall3"); - location jawa9Location = new location(29.42f, .2f, 46.58f, "tatooine", hall3); - obj_id jawa9 = create.staticObject("jawa", jawa9Location); + obj_id jawa9 = create.staticObject("jawa", new location(29.42f, .2f, 46.58f, "tatooine", getCellId(self, "hall3"))); setObjVar(jawa9, "ai.defaultCalmBehavior", 1); attachScript(jawa9, "theme_park.tatooine.jabbaspawner.jawa9"); setObjVar(self, "PalaceInhabitants.jawa9", jawa9); @@ -794,9 +650,7 @@ public class masterspawner extends script.base_script } public void spawnJawa10(obj_id self, obj_id jawa9) throws InterruptedException { - obj_id hall3 = getCellId(self, "hall3"); - location jawa10Location = new location(29.44f, .2f, 45.39f, "tatooine", hall3); - obj_id jawa10 = create.staticObject("jawa", jawa10Location); + obj_id jawa10 = create.staticObject("jawa", new location(29.44f, .2f, 45.39f, "tatooine", getCellId(self, "hall3"))); setObjVar(jawa10, "ai.defaultCalmBehavior", 1); setObjVar(jawa9, "facer", jawa10); setObjVar(jawa10, "facer", jawa9); @@ -806,13 +660,10 @@ public class masterspawner extends script.base_script setObjVar(self, "PalaceInhabitants.jawa10", jawa10); setObjVar(jawa10, "palace", self); setInvulnerable(jawa10, true); - return; } public void spawnRandom1(obj_id self, obj_id gamGuard5) throws InterruptedException { - obj_id hall2 = getCellId(self, "hall2"); - location random1Location = new location(9, 7, 73, "tatooine", hall2); - obj_id random1 = create.staticObject("outlaw", random1Location); + obj_id random1 = create.staticObject("outlaw", new location(9, 7, 73, "tatooine", getCellId(self, "hall2"))); setObjVar(random1, "ai.defaultCalmBehavior", 1); attachScript(random1, "theme_park.tatooine.jabbaspawner.random1"); setObjVar(random1, "facer", gamGuard5); @@ -824,13 +675,10 @@ public class masterspawner extends script.base_script ai_lib.setCustomIdleAnimation(random1, "conversation"); attachScript(random1, "theme_park.tatooine.jabbaspawner.behavior.conversing"); setInvulnerable(random1, true); - return; } public void spawnRandom2(obj_id self) throws InterruptedException { - obj_id hall4 = getCellId(self, "hall4"); - location random2Location = new location(-25, 5, 61, "tatooine", hall4); - obj_id random2 = create.object("roughneck", random2Location); + obj_id random2 = create.object("roughneck", new location(-25, 5, 61, "tatooine", getCellId(self, "hall4"))); setObjVar(random2, "ai.defaultCalmBehavior", 1); attachScript(random2, "theme_park.tatooine.jabbaspawner.random2"); attachScript(random2, "theme_park.tatooine.jabbaspawner.palace_path"); @@ -838,13 +686,10 @@ public class masterspawner extends script.base_script setObjVar(random2, "palace", self); ai_lib.setCustomIdleAnimation(random2, "conversation"); setInvulnerable(random2, true); - return; } public obj_id spawnRandom3(obj_id self) throws InterruptedException { - obj_id throneroom = getCellId(self, "throneroom"); - location random3Location = new location(5, 4, 44, "tatooine", throneroom); - obj_id random3 = create.staticObject("scoundrel", random3Location); + obj_id random3 = create.staticObject("scoundrel", new location(5, 4, 44, "tatooine", getCellId(self, "throneroom"))); setObjVar(random3, "ai.defaultCalmBehavior", 1); attachScript(random3, "theme_park.tatooine.jabbaspawner.random3"); setObjVar(self, "PalaceInhabitants.random3", random3); @@ -856,9 +701,7 @@ public class masterspawner extends script.base_script } public void spawnRandom4(obj_id self, obj_id random3) throws InterruptedException { - obj_id throneroom = getCellId(self, "throneroom"); - location random4Location = new location(5, 4, 45.5f, "tatooine", throneroom); - obj_id random4 = create.staticObject("wastrel", random4Location); + obj_id random4 = create.staticObject("wastrel", new location(5, 4, 45.5f, "tatooine", getCellId(self, "throneroom"))); setObjVar(random4, "ai.defaultCalmBehavior", 1); setObjVar(random4, "facer", random3); setObjVar(random3, "facer", random4); @@ -870,13 +713,10 @@ public class masterspawner extends script.base_script ai_lib.setCustomIdleAnimation(random4, "conversation"); attachScript(random4, "theme_park.tatooine.jabbaspawner.behavior.conversing"); setInvulnerable(random4, true); - return; } public obj_id spawnRandom5(obj_id self) throws InterruptedException { - obj_id throneroom = getCellId(self, "throneroom"); - location random5Location = new location(-9, 5, 25, "tatooine", throneroom); - obj_id random5 = create.object("spacer", random5Location); + obj_id random5 = create.object("spacer", new location(-9, 5, 25, "tatooine", getCellId(self, "throneroom"))); setObjVar(random5, "ai.defaultCalmBehavior", 1); attachScript(random5, "theme_park.tatooine.jabbaspawner.random5"); setObjVar(self, "PalaceInhabitants.random5", random5); @@ -888,9 +728,7 @@ public class masterspawner extends script.base_script } public obj_id spawnRandom6(obj_id self) throws InterruptedException { - obj_id throneroom = getCellId(self, "throneroom"); - location random6Location = new location(1.08f, 2f, 36.7f, "tatooine", throneroom); - obj_id random6 = create.staticObject("thug", random6Location); + obj_id random6 = create.staticObject("thug", new location(1.08f, 2f, 36.7f, "tatooine", getCellId(self, "throneroom"))); setObjVar(random6, "ai.defaultCalmBehavior", 1); attachScript(random6, "theme_park.tatooine.jabbaspawner.random6"); setObjVar(self, "PalaceInhabitants.random6", random6); @@ -902,9 +740,7 @@ public class masterspawner extends script.base_script } public obj_id spawnRandom7(obj_id self) throws InterruptedException { - obj_id throneroom = getCellId(self, "throneroom"); - location random7Location = new location(-9, 4, 51, "tatooine", throneroom); - obj_id random7 = create.staticObject("slicer", random7Location); + obj_id random7 = create.staticObject("slicer", new location(-9, 4, 51, "tatooine", getCellId(self, "throneroom"))); setObjVar(random7, "ai.defaultCalmBehavior", 1); attachScript(random7, "theme_park.tatooine.jabbaspawner.random7"); setObjVar(self, "PalaceInhabitants.random7", random7); @@ -916,9 +752,7 @@ public class masterspawner extends script.base_script } public void spawnRandom8(obj_id self, obj_id random7) throws InterruptedException { - obj_id throneroom = getCellId(self, "throneroom"); - location random8Location = new location(-8.69f, 4f, 49.57f, "tatooine", throneroom); - obj_id random8 = create.staticObject("fringer", random8Location); + obj_id random8 = create.staticObject("fringer", new location(-8.69f, 4f, 49.57f, "tatooine", getCellId(self, "throneroom"))); setObjVar(random8, "ai.defaultCalmBehavior", 1); attachScript(random8, "theme_park.tatooine.jabbaspawner.random8"); setObjVar(self, "PalaceInhabitants.random8", random8); @@ -930,13 +764,10 @@ public class masterspawner extends script.base_script attachScript(random8, "theme_park.tatooine.jabbaspawner.behavior.conversing"); ai_lib.setCustomIdleAnimation(random8, "conversation"); setInvulnerable(random8, true); - return; } public obj_id spawnRandom9(obj_id self) throws InterruptedException { - obj_id throne = getCellId(self, "throneroom"); - location random9Location = new location(-5.88f, 2.0f, 43.07f, "tatooine", throne); - obj_id random9 = create.staticObject("roughneck", random9Location); + obj_id random9 = create.staticObject("roughneck", new location(-5.88f, 2.0f, 43.07f, "tatooine", getCellId(self, "throneroom"))); setObjVar(random9, "ai.defaultCalmBehavior", 1); attachScript(random9, "theme_park.tatooine.jabbaspawner.random9"); setObjVar(self, "PalaceInhabitants.random9", random9); @@ -947,9 +778,7 @@ public class masterspawner extends script.base_script } public void spawnRandom10(obj_id self, obj_id random9) throws InterruptedException { - obj_id throne = getCellId(self, "throneroom"); - location random10Location = new location(-5.72f, 2.0f, 44.11f, "tatooine", throne); - obj_id random10 = create.staticObject("roughneck", random10Location); + obj_id random10 = create.staticObject("roughneck", new location(-5.72f, 2.0f, 44.11f, "tatooine", getCellId(self, "throneroom"))); setObjVar(random10, "ai.defaultCalmBehavior", 1); attachScript(random10, "theme_park.tatooine.jabbaspawner.random10"); setObjVar(random9, "facer", random10); @@ -961,13 +790,10 @@ public class masterspawner extends script.base_script ai_lib.setMood(random10, "conversation"); ai_lib.setCustomIdleAnimation(random10, "conversation"); setInvulnerable(random10, true); - return; } public obj_id spawnRandom11(obj_id self) throws InterruptedException { - obj_id throne = getCellId(self, "throneroom"); - location random11Location = new location(-14.32f, 2f, 52.08f, "tatooine", throne); - obj_id random11 = create.staticObject("scoundrel", random11Location); + obj_id random11 = create.staticObject("scoundrel", new location(-14.32f, 2f, 52.08f, "tatooine", getCellId(self, "throneroom"))); setObjVar(random11, "ai.defaultCalmBehavior", 1); attachScript(random11, "theme_park.tatooine.jabbaspawner.random11"); setObjVar(self, "PalaceInhabitants.random11", random11); @@ -978,9 +804,7 @@ public class masterspawner extends script.base_script } public void spawnRandom12(obj_id self, obj_id random11) throws InterruptedException { - obj_id throne = getCellId(self, "throneroom"); - location random12Location = new location(-15.83f, 2f, 51.94f, "tatooine", throne); - obj_id random12 = create.staticObject("thug", random12Location); + obj_id random12 = create.staticObject("thug", new location(-15.83f, 2f, 51.94f, "tatooine", getCellId(self, "throneroom"))); setObjVar(random12, "ai.defaultCalmBehavior", 1); attachScript(random12, "theme_park.tatooine.jabbaspawner.random12"); setObjVar(self, "PalaceInhabitants.random12", random12); @@ -991,13 +815,10 @@ public class masterspawner extends script.base_script messageTo(random11, "doFacing", null, 10, true); ai_lib.setCustomIdleAnimation(random12, "conversation"); setInvulnerable(random12, true); - return; } public void spawnRandom13(obj_id self, obj_id jawa3) throws InterruptedException { - obj_id throne = getCellId(self, "throneroom"); - location random13Location = new location(-1.64f, 3f, 26.17f, "tatooine", throne); - obj_id random13 = create.staticObject("thug", random13Location); + obj_id random13 = create.staticObject("thug", new location(-1.64f, 3f, 26.17f, "tatooine", getCellId(self, "throneroom"))); setObjVar(random13, "ai.defaultCalmBehavior", 1); attachScript(random13, "theme_park.tatooine.jabbaspawner.random13"); setObjVar(self, "PalaceInhabitants.random13", random13); @@ -1008,13 +829,10 @@ public class masterspawner extends script.base_script messageTo(jawa3, "doFacing", null, 10, true); ai_lib.setCustomIdleAnimation(random13, "conversation"); setInvulnerable(random13, true); - return; } public void spawnRandom14(obj_id self, obj_id jawa4) throws InterruptedException { - obj_id throne = getCellId(self, "throneroom"); - location random14Location = new location(-8.44f, 3f, 21.23f, "tatooine", throne); - obj_id random14 = create.staticObject("thug", random14Location); + obj_id random14 = create.staticObject("thug", new location(-8.44f, 3f, 21.23f, "tatooine", getCellId(self, "throneroom"))); setObjVar(random14, "ai.defaultCalmBehavior", 1); attachScript(random14, "theme_park.tatooine.jabbaspawner.random14"); setObjVar(self, "PalaceInhabitants.random14", random14); @@ -1025,13 +843,10 @@ public class masterspawner extends script.base_script messageTo(jawa4, "doFacing", null, 10, true); ai_lib.setCustomIdleAnimation(random14, "conversation"); setInvulnerable(random14, true); - return; } public void spawnRandom15(obj_id self, obj_id random5) throws InterruptedException { - obj_id throne = getCellId(self, "throneroom"); - location random15Location = new location(-9.9f, 3f, 25.6f, "tatooine", throne); - obj_id random15 = create.staticObject("thug", random15Location); + obj_id random15 = create.staticObject("thug", new location(-9.9f, 3f, 25.6f, "tatooine", getCellId(self, "throneroom"))); setObjVar(random15, "ai.defaultCalmBehavior", 1); attachScript(random15, "theme_park.tatooine.jabbaspawner.random15"); setObjVar(self, "PalaceInhabitants.random15", random15); @@ -1042,13 +857,10 @@ public class masterspawner extends script.base_script messageTo(random5, "doFacing", null, 10, true); ai_lib.setCustomIdleAnimation(random15, "conversation"); setInvulnerable(random15, true); - return; } public void spawnRandom16(obj_id self, obj_id random6) throws InterruptedException { - obj_id throne = getCellId(self, "throneroom"); - location random16Location = new location(1.08f, 2f, 35.07f, "tatooine", throne); - obj_id random16 = create.staticObject("thug", random16Location); + obj_id random16 = create.staticObject("thug", new location(1.08f, 2f, 35.07f, "tatooine", getCellId(self, "throneroom"))); setObjVar(random16, "ai.defaultCalmBehavior", 1); attachScript(random16, "theme_park.tatooine.jabbaspawner.random16"); setObjVar(self, "PalaceInhabitants.random16", random16); @@ -1059,214 +871,163 @@ public class masterspawner extends script.base_script messageTo(random6, "doFacing", null, 10, true); ai_lib.setCustomIdleAnimation(random16, "conversation"); setInvulnerable(random16, true); - return; } public void spawnEv9d9(obj_id self) throws InterruptedException { - obj_id droidtorture = getCellId(self, "droidtorture"); - location ev9d9Loc = new location(24.47f, 0.2f, 87.86f, "tatooine", droidtorture); - obj_id ev9d9 = create.staticObject("ev_9d9", ev9d9Loc); + obj_id ev9d9 = create.staticObject("ev_9d9", new location(24.47f, 0.2f, 87.86f, "tatooine", getCellId(self, "droidtorture"))); setObjVar(ev9d9, "ai.defaultCalmBehavior", 1); attachScript(ev9d9, "theme_park.tatooine.jabbaspawner.ev9d9"); setObjVar(self, "PalaceInhabitants.ev9d9", ev9d9); setObjVar(ev9d9, "palace", self); - return; } public void spawnDroid1(obj_id self) throws InterruptedException { - obj_id droidtorture = getCellId(self, "droidtorture"); - location droid1Location = new location(19.73f, 0.2f, 90.51f, "tatooine", droidtorture); - obj_id droid1 = create.object("r2", droid1Location); + obj_id droid1 = create.object("r2", new location(19.73f, 0.2f, 90.51f, "tatooine", getCellId(self, "droidtorture"))); setObjVar(droid1, "ai.defaultCalmBehavior", 1); attachScript(droid1, "theme_park.tatooine.jabbaspawner.droid1"); attachScript(droid1, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.droid1", droid1); setObjVar(droid1, "palace", self); setInvulnerable(droid1, true); - return; } public void spawnDroid2(obj_id self) throws InterruptedException { - obj_id droidtorture = getCellId(self, "droidtorture"); - location droid2Location = new location(13.33f, 0.2f, 88.72f, "tatooine", droidtorture); - obj_id droid2 = create.object("ra7_bug_droid", droid2Location); + obj_id droid2 = create.object("ra7_bug_droid", new location(13.33f, 0.2f, 88.72f, "tatooine", getCellId(self, "droidtorture"))); setObjVar(droid2, "ai.defaultCalmBehavior", 1); attachScript(droid2, "theme_park.tatooine.jabbaspawner.droid2"); setObjVar(self, "PalaceInhabitants.droid2", droid2); setObjVar(droid2, "palace", self); setInvulnerable(droid2, true); - return; } public void spawnDroid3(obj_id self) throws InterruptedException { - obj_id droidtorture = getCellId(self, "droidtorture"); - location droid3Location = new location(10.71f, 0.2f, 84.27f, "tatooine", droidtorture); - obj_id droid3 = create.object("protocol_droid_3po_red", droid3Location); + obj_id droid3 = create.object("protocol_droid_3po_red", new location(10.71f, 0.2f, 84.27f, "tatooine", getCellId(self, "droidtorture"))); setObjVar(droid3, "ai.defaultCalmBehavior", 1); attachScript(droid3, "theme_park.tatooine.jabbaspawner.droid3"); setObjVar(self, "PalaceInhabitants.droid3", droid3); setObjVar(droid3, "palace", self); setInvulnerable(droid3, true); - return; } public void spawnDroid4(obj_id self) throws InterruptedException { - obj_id droidtorture = getCellId(self, "droidtorture"); - location droid4Location = new location(17.42f, 0.2f, 81.22f, "tatooine", droidtorture); - obj_id droid4 = create.object("eg6_power_droid", droid4Location); + obj_id droid4 = create.object("eg6_power_droid", new location(17.42f, 0.2f, 81.22f, "tatooine", getCellId(self, "droidtorture"))); setObjVar(droid4, "ai.defaultCalmBehavior", 1); attachScript(droid4, "theme_park.tatooine.jabbaspawner.droid4"); attachScript(droid4, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.droid4", droid4); setObjVar(droid4, "palace", self); setInvulnerable(droid4, true); - return; } public void spawnDroid5(obj_id self) throws InterruptedException { - obj_id droidtorture = getCellId(self, "droidtorture"); - location droid5Location = new location(23.67f, 0.2f, 76.43f, "tatooine", droidtorture); - obj_id droid5 = create.object("le_repair_droid", droid5Location); + obj_id droid5 = create.object("le_repair_droid", new location(23.67f, 0.2f, 76.43f, "tatooine", getCellId(self, "droidtorture"))); setObjVar(droid5, "ai.defaultCalmBehavior", 1); attachScript(droid5, "theme_park.tatooine.jabbaspawner.droid5"); setObjVar(self, "PalaceInhabitants.droid5", droid5); setObjVar(droid5, "palace", self); setInvulnerable(droid5, true); - return; } public void spawnDroid6(obj_id self) throws InterruptedException { - obj_id garage = getCellId(self, "garage1"); - location droid6Location = new location(43.29f, .2f, 7.14f, "tatooine", garage); - obj_id droid6 = create.object("eg6_power_droid", droid6Location); + obj_id droid6 = create.object("eg6_power_droid", new location(43.29f, .2f, 7.14f, "tatooine", getCellId(self, "garage1"))); setObjVar(droid6, "ai.defaultCalmBehavior", 1); attachScript(droid6, "theme_park.tatooine.jabbaspawner.droid6"); attachScript(droid6, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.droid6", droid6); setObjVar(droid6, "palace", self); setInvulnerable(droid6, true); - return; } public void spawnPrisoner1(obj_id self) throws InterruptedException { - obj_id jail1 = getCellId(self, "jail1"); - location jailCell1 = new location(-33.83f, .2f, 76.58f, "tatooine", jail1); - obj_id prisoner1 = create.staticObject("commoner", jailCell1); + obj_id prisoner1 = create.staticObject("commoner", new location(-33.83f, .2f, 76.58f, "tatooine", getCellId(self, "jail1"))); setObjVar(prisoner1, "ai.defaultCalmBehavior", 1); attachScript(prisoner1, "theme_park.tatooine.jabbaspawner.prisoner1"); attachScript(prisoner1, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.prisoner1", prisoner1); setObjVar(prisoner1, "palace", self); setInvulnerable(prisoner1, true); - return; } public void spawnPrisoner2(obj_id self) throws InterruptedException { - obj_id jail2 = getCellId(self, "jail2"); - location jailCell2 = new location(-37.43f, .2f, 76.85f, "tatooine", jail2); - obj_id prisoner2 = create.staticObject("commoner", jailCell2); + obj_id prisoner2 = create.staticObject("commoner", new location(-37.43f, .2f, 76.85f, "tatooine", getCellId(self, "jail2"))); setObjVar(prisoner2, "ai.defaultCalmBehavior", 1); attachScript(prisoner2, "theme_park.tatooine.jabbaspawner.prisoner2"); attachScript(prisoner2, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.prisoner2", prisoner2); setObjVar(prisoner2, "palace", self); setInvulnerable(prisoner2, true); - return; } public void spawnPrisoner3(obj_id self) throws InterruptedException { - obj_id jail3 = getCellId(self, "jail3"); - location jailCell3 = new location(-34.48f, .2f, 88.22f, "tatooine", jail3); - obj_id prisoner3 = create.staticObject("commoner", jailCell3); + obj_id prisoner3 = create.staticObject("commoner", new location(-34.48f, .2f, 88.22f, "tatooine", getCellId(self, "jail3"))); setObjVar(prisoner3, "ai.defaultCalmBehavior", 1); attachScript(prisoner3, "theme_park.tatooine.jabbaspawner.prisoner3"); attachScript(prisoner3, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.prisoner3", prisoner3); setObjVar(prisoner3, "palace", self); setInvulnerable(prisoner3, true); - return; } public void spawnPrisoner4(obj_id self) throws InterruptedException { - obj_id jail4 = getCellId(self, "jail4"); - location jailCell4 = new location(-38.7f, .2f, 88.24f, "tatooine", jail4); - obj_id prisoner4 = create.staticObject("commoner", jailCell4); + obj_id prisoner4 = create.staticObject("commoner", new location(-38.7f, .2f, 88.24f, "tatooine", getCellId(self, "jail4"))); setObjVar(prisoner4, "ai.defaultCalmBehavior", 1); attachScript(prisoner4, "theme_park.tatooine.jabbaspawner.prisoner4"); attachScript(prisoner4, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.prisoner4", prisoner4); setObjVar(prisoner4, "palace", self); setInvulnerable(prisoner4, true); - return; } public void spawnPrisoner5(obj_id self) throws InterruptedException { - obj_id jail5 = getCellId(self, "jail5"); - location jailCell5 = new location(-10.07f, .2f, 77.54f, "tatooine", jail5); - obj_id prisoner5 = create.staticObject("commoner", jailCell5); + obj_id prisoner5 = create.staticObject("commoner", new location(-10.07f, .2f, 77.54f, "tatooine", getCellId(self, "jail5"))); setObjVar(prisoner5, "ai.defaultCalmBehavior", 1); attachScript(prisoner5, "theme_park.tatooine.jabbaspawner.prisoner5"); attachScript(prisoner5, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.prisoner5", prisoner5); setObjVar(prisoner5, "palace", self); setInvulnerable(prisoner5, true); - return; } public void spawnPrisoner6(obj_id self) throws InterruptedException { - obj_id jail6 = getCellId(self, "jail6"); - location jailCell6 = new location(-13.62f, .2f, 77.52f, "tatooine", jail6); - obj_id prisoner6 = create.staticObject("commoner", jailCell6); + obj_id prisoner6 = create.staticObject("commoner", new location(-13.62f, .2f, 77.52f, "tatooine", getCellId(self, "jail6"))); setObjVar(prisoner6, "ai.defaultCalmBehavior", 1); attachScript(prisoner6, "theme_park.tatooine.jabbaspawner.prisoner6"); attachScript(prisoner6, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.prisoner6", prisoner6); setObjVar(prisoner6, "palace", self); setInvulnerable(prisoner6, true); - return; } public void spawnPrisoner7(obj_id self) throws InterruptedException { - obj_id jail7 = getCellId(self, "jail7"); - location jailCell7 = new location(-10.88f, .2f, 87.49f, "tatooine", jail7); - obj_id prisoner7 = create.staticObject("commoner", jailCell7); + obj_id prisoner7 = create.staticObject("commoner", new location(-10.88f, .2f, 87.49f, "tatooine", getCellId(self, "jail7"))); setObjVar(prisoner7, "ai.defaultCalmBehavior", 1); attachScript(prisoner7, "theme_park.tatooine.jabbaspawner.prisoner7"); attachScript(prisoner7, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.prisoner7", prisoner7); setObjVar(prisoner7, "palace", self); setInvulnerable(prisoner7, true); - return; } public void spawnPrisoner8(obj_id self) throws InterruptedException { - obj_id jail8 = getCellId(self, "jail8"); - location jailCell8 = new location(-15.43f, .2f, 87.68f, "tatooine", jail8); - obj_id prisoner8 = create.staticObject("commoner", jailCell8); + obj_id prisoner8 = create.staticObject("commoner", new location(-15.43f, .2f, 87.68f, "tatooine", getCellId(self, "jail8"))); setObjVar(prisoner8, "ai.defaultCalmBehavior", 1); attachScript(prisoner8, "theme_park.tatooine.jabbaspawner.prisoner8"); attachScript(prisoner8, "theme_park.tatooine.jabbaspawner.palace_path"); setObjVar(self, "PalaceInhabitants.prisoner8", prisoner8); setObjVar(prisoner8, "palace", self); setInvulnerable(prisoner8, true); - return; } public void spawnJawl(obj_id self) throws InterruptedException { - obj_id foyer = getCellId(self, "foyer"); - location jawlsloc = new location(-5.5f, 0.2f, 114.2f, "tatooine", foyer); - int yaw = -150; - obj_id jawl = create.object("clone_relics_jawl", jawlsloc); - setYaw(jawl, yaw); + obj_id jawl = create.object("clone_relics_jawl", new location(-5.5f, 0.2f, 114.2f, "tatooine", getCellId(self, "foyer"))); + setYaw(jawl, -150); ai_lib.setDefaultCalmMood(jawl, "confused"); setObjVar(self, "PalaceInhabitants.jawl", jawl); setObjVar(jawl, "palace", self); - return; } public int bibDied(obj_id self, dictionary params) throws InterruptedException { - obj_id oola = getObjIdObjVar(self, "PalaceInhabitants.oola"); - spawnBib(self, oola); + spawnBib(self, getObjIdObjVar(self, "PalaceInhabitants.oola")); return SCRIPT_CONTINUE; } public int reeloDied(obj_id self, dictionary params) throws InterruptedException @@ -1281,13 +1042,11 @@ public class masterspawner extends script.base_script } public int reeyeesDied(obj_id self, dictionary params) throws InterruptedException { - obj_id oola = getObjIdObjVar(self, "PalaceInhabitants.oola"); - spawnReeYees(self, oola); + spawnReeYees(self, getObjIdObjVar(self, "PalaceInhabitants.oola")); return SCRIPT_CONTINUE; } public int jawlDied(obj_id self, dictionary params) throws InterruptedException { - obj_id jawl = getObjIdObjVar(self, "PalaceInhabitants.jawl"); spawnJawl(self); return SCRIPT_CONTINUE; } @@ -1298,38 +1057,32 @@ public class masterspawner extends script.base_script } public int maxDied(obj_id self, dictionary params) throws InterruptedException { - obj_id oola = getObjIdObjVar(self, "PalaceInhabitants.oola"); - spawnMax(self, oola); + spawnMax(self, getObjIdObjVar(self, "PalaceInhabitants.oola")); return SCRIPT_CONTINUE; } public int syDied(obj_id self, dictionary params) throws InterruptedException { - obj_id oola = getObjIdObjVar(self, "PalaceInhabitants.oola"); - spawnSy(self, oola); + spawnSy(self, getObjIdObjVar(self, "PalaceInhabitants.oola")); return SCRIPT_CONTINUE; } public int droopyDied(obj_id self, dictionary params) throws InterruptedException { - obj_id oola = getObjIdObjVar(self, "PalaceInhabitants.oola"); - spawnDroopy(self, oola); + spawnDroopy(self, getObjIdObjVar(self, "PalaceInhabitants.oola")); return SCRIPT_CONTINUE; } public int jabbaDied(obj_id self, dictionary params) throws InterruptedException { - obj_id oola = getObjIdObjVar(self, "PalaceInhabitants.oola"); - spawnJabba(self, oola); + spawnJabba(self, getObjIdObjVar(self, "PalaceInhabitants.oola")); return SCRIPT_CONTINUE; } public int crumbDied(obj_id self, dictionary params) throws InterruptedException { - obj_id oola = getObjIdObjVar(self, "PalaceInhabitants.crumb"); - spawnCrumb(self, oola); + spawnCrumb(self, getObjIdObjVar(self, "PalaceInhabitants.oola")); return SCRIPT_CONTINUE; } public int pDroidDied(obj_id self, dictionary params) throws InterruptedException { - obj_id oola = getObjIdObjVar(self, "PalaceInhabitants.oola"); - spawnPDroid(self, oola); + spawnPDroid(self, getObjIdObjVar(self, "PalaceInhabitants.oola")); return SCRIPT_CONTINUE; } public int baradaDied(obj_id self, dictionary params) throws InterruptedException @@ -1354,38 +1107,32 @@ public class masterspawner extends script.base_script } public int rancorDied(obj_id self, dictionary params) throws InterruptedException { - obj_id malakili = getObjIdObjVar(self, "PalaceInhabitants.malakili"); - spawnRancor(self, malakili); + spawnRancor(self, getObjIdObjVar(self, "PalaceInhabitants.malakili")); return SCRIPT_CONTINUE; } public int bobaDied(obj_id self, dictionary params) throws InterruptedException { - obj_id oola = getObjIdObjVar(self, "PalaceInhabitants.oola"); - spawnBoba(self, oola); + spawnBoba(self, getObjIdObjVar(self, "PalaceInhabitants.oola")); return SCRIPT_CONTINUE; } public int gamGuard1Died(obj_id self, dictionary params) throws InterruptedException { - obj_id ephant = getObjIdObjVar(self, "PalaceInhabitants.ephant"); - spawnGamGuard1(self, ephant); + spawnGamGuard1(self, getObjIdObjVar(self, "PalaceInhabitants.ephant")); return SCRIPT_CONTINUE; } public int gamGuard2Died(obj_id self, dictionary params) throws InterruptedException { - obj_id gamGuard1 = getObjIdObjVar(self, "PalaceInhabitants.gamGuard1"); - spawnGamGuard2(self, gamGuard1); + spawnGamGuard2(self, getObjIdObjVar(self, "PalaceInhabitants.gamGuard1")); return SCRIPT_CONTINUE; } public int gamGuard3Died(obj_id self, dictionary params) throws InterruptedException { - obj_id gamGuard1 = getObjIdObjVar(self, "PalaceInhabitants.gamGuard1"); - spawnGamGuard3(self, gamGuard1); + spawnGamGuard3(self, getObjIdObjVar(self, "PalaceInhabitants.gamGuard1")); return SCRIPT_CONTINUE; } public int gamGuard4Died(obj_id self, dictionary params) throws InterruptedException { - obj_id ephant = getObjIdObjVar(self, "PalaceInhabitants.ephant"); - spawnGamGuard4(self, ephant); + spawnGamGuard4(self, getObjIdObjVar(self, "PalaceInhabitants.ephant")); return SCRIPT_CONTINUE; } public int gamGuard5Died(obj_id self, dictionary params) throws InterruptedException @@ -1400,20 +1147,17 @@ public class masterspawner extends script.base_script } public int gamGuard7Died(obj_id self, dictionary params) throws InterruptedException { - obj_id gamGuard6 = getObjIdObjVar(self, "PalaceInhabitants.gamGuard6"); - spawnGamGuard7(self, gamGuard6); + spawnGamGuard7(self, getObjIdObjVar(self, "PalaceInhabitants.gamGuard6")); return SCRIPT_CONTINUE; } public int gamGuard8Died(obj_id self, dictionary params) throws InterruptedException { - obj_id gamGuard6 = getObjIdObjVar(self, "PalaceInhabitants.gamGuard6"); - spawnGamGuard8(self, gamGuard6); + spawnGamGuard8(self, getObjIdObjVar(self, "PalaceInhabitants.gamGuard6")); return SCRIPT_CONTINUE; } public int gamGuard9Died(obj_id self, dictionary params) throws InterruptedException { - obj_id jabba2 = getObjIdObjVar(self, "PalaceInhabitants.jabba2"); - spawnGamGuard9(self); + spawnGamGuard9(getObjIdObjVar(self, "PalaceInhabitants.jabba2")); return SCRIPT_CONTINUE; } public int gamGuard10Died(obj_id self, dictionary params) throws InterruptedException @@ -1428,13 +1172,11 @@ public class masterspawner extends script.base_script } public int gamGuard12Died(obj_id self, dictionary params) throws InterruptedException { - obj_id malakili = getObjIdObjVar(self, "PalaceInhabitants.malakili"); spawnGamGuard12(self); return SCRIPT_CONTINUE; } public int gamGuard13Died(obj_id self, dictionary params) throws InterruptedException { - obj_id oola = getObjIdObjVar(self, "PalaceInhabitants.oola"); spawnGamGuard13(self); return SCRIPT_CONTINUE; } @@ -1455,7 +1197,6 @@ public class masterspawner extends script.base_script } public int bomarrMonk4Died(obj_id self, dictionary params) throws InterruptedException { - obj_id gamGuard11 = getObjIdObjVar(self, "PalaceInhabitants.gamGuard11"); spawnBomarrMonk4(self); return SCRIPT_CONTINUE; } @@ -1491,14 +1232,12 @@ public class masterspawner extends script.base_script } public int jawa5Died(obj_id self, dictionary params) throws InterruptedException { - obj_id bomarrMonk6 = getObjIdObjVar(self, "PalaceInhabitants.bomarrMonk6"); spawnJawa5(self); return SCRIPT_CONTINUE; } public int jawa6Died(obj_id self, dictionary params) throws InterruptedException { - obj_id jawa1 = getObjIdObjVar(self, "PalaceInhabitants.jawa1"); - spawnJawa6(self, jawa1); + spawnJawa6(self, getObjIdObjVar(self, "PalaceInhabitants.jawa1")); return SCRIPT_CONTINUE; } public int jawa7Died(obj_id self, dictionary params) throws InterruptedException @@ -1508,8 +1247,7 @@ public class masterspawner extends script.base_script } public int jawa8Died(obj_id self, dictionary params) throws InterruptedException { - obj_id jawa7 = getObjIdObjVar(self, "PalaceInhabitants.jawa7"); - spawnJawa8(self, jawa7); + spawnJawa8(self, getObjIdObjVar(self, "PalaceInhabitants.jawa7")); return SCRIPT_CONTINUE; } public int jawa9Died(obj_id self, dictionary params) throws InterruptedException @@ -1519,19 +1257,16 @@ public class masterspawner extends script.base_script } public int jawa10Died(obj_id self, dictionary params) throws InterruptedException { - obj_id jawa9 = getObjIdObjVar(self, "PalaceInhabitants.jawa9"); - spawnJawa10(self, jawa9); + spawnJawa10(self, getObjIdObjVar(self, "PalaceInhabitants.jawa9")); return SCRIPT_CONTINUE; } public int random1Died(obj_id self, dictionary params) throws InterruptedException { - obj_id gamGuard5 = getObjIdObjVar(self, "PalaceInhabitants.gamGuard5"); - spawnRandom1(self, gamGuard5); + spawnRandom1(self, getObjIdObjVar(self, "PalaceInhabitants.gamGuard5")); return SCRIPT_CONTINUE; } public int random2Died(obj_id self, dictionary params) throws InterruptedException { - obj_id jawa1 = getObjIdObjVar(self, "PalaceInhabitants.jawa1"); spawnRandom2(self); return SCRIPT_CONTINUE; } @@ -1542,19 +1277,16 @@ public class masterspawner extends script.base_script } public int random4Died(obj_id self, dictionary params) throws InterruptedException { - obj_id random3 = getObjIdObjVar(self, "PalaceInhabitants.random3"); - spawnRandom4(self, random3); + spawnRandom4(self, getObjIdObjVar(self, "PalaceInhabitants.random3")); return SCRIPT_CONTINUE; } public int random5Died(obj_id self, dictionary params) throws InterruptedException { - obj_id random3 = getObjIdObjVar(self, "PalaceInhabitants.random3"); spawnRandom5(self); return SCRIPT_CONTINUE; } public int random6Died(obj_id self, dictionary params) throws InterruptedException { - obj_id sy = getObjIdObjVar(self, "PalaceInhabitants.sy"); spawnRandom6(self); return SCRIPT_CONTINUE; } @@ -1565,8 +1297,7 @@ public class masterspawner extends script.base_script } public int random8Died(obj_id self, dictionary params) throws InterruptedException { - obj_id random7 = getObjIdObjVar(self, "PalaceInhabitants.random7"); - spawnRandom8(self, random7); + spawnRandom8(self, getObjIdObjVar(self, "PalaceInhabitants.random7")); return SCRIPT_CONTINUE; } public int random9Died(obj_id self, dictionary params) throws InterruptedException @@ -1576,8 +1307,7 @@ public class masterspawner extends script.base_script } public int random10Died(obj_id self, dictionary params) throws InterruptedException { - obj_id random9 = getObjIdObjVar(self, "PalaceInhabitants.random9"); - spawnRandom10(self, random9); + spawnRandom10(self, getObjIdObjVar(self, "PalaceInhabitants.random9")); return SCRIPT_CONTINUE; } public int random11Died(obj_id self, dictionary params) throws InterruptedException @@ -1587,32 +1317,27 @@ public class masterspawner extends script.base_script } public int random12Died(obj_id self, dictionary params) throws InterruptedException { - obj_id random11 = getObjIdObjVar(self, "PalaceInhabitants.random11"); - spawnRandom12(self, random11); + spawnRandom12(self, getObjIdObjVar(self, "PalaceInhabitants.random11")); return SCRIPT_CONTINUE; } public int random13Died(obj_id self, dictionary params) throws InterruptedException { - obj_id jawa3 = getObjIdObjVar(self, "PalaceInhabitants.jawa3"); - spawnRandom13(self, jawa3); + spawnRandom13(self, getObjIdObjVar(self, "PalaceInhabitants.jawa3")); return SCRIPT_CONTINUE; } public int random14Died(obj_id self, dictionary params) throws InterruptedException { - obj_id jawa4 = getObjIdObjVar(self, "PalaceInhabitants.jawa4"); - spawnRandom14(self, jawa4); + spawnRandom14(self, getObjIdObjVar(self, "PalaceInhabitants.jawa4")); return SCRIPT_CONTINUE; } public int random15Died(obj_id self, dictionary params) throws InterruptedException { - obj_id random5 = getObjIdObjVar(self, "PalaceInhabitants.random5"); - spawnRandom15(self, random5); + spawnRandom15(self, getObjIdObjVar(self, "PalaceInhabitants.random5")); return SCRIPT_CONTINUE; } public int random16Died(obj_id self, dictionary params) throws InterruptedException { - obj_id random6 = getObjIdObjVar(self, "PalaceInhabitants.random6"); - spawnRandom16(self, random6); + spawnRandom16(self, getObjIdObjVar(self, "PalaceInhabitants.random6")); return SCRIPT_CONTINUE; } public int ev9d9Died(obj_id self, dictionary params) throws InterruptedException @@ -1702,42 +1427,26 @@ public class masterspawner extends script.base_script } public int doGuards(obj_id self, dictionary params) throws InterruptedException { - obj_id guard1 = getObjIdObjVar(self, "PalaceInhabitants.gamGuard1"); - attachScript(guard1, "theme_park.tatooine.jabbaspawner.palace_path"); - obj_id guard2 = getObjIdObjVar(self, "PalaceInhabitants.gamGuard2"); - attachScript(guard2, "theme_park.tatooine.jabbaspawner.palace_path"); - obj_id guard3 = getObjIdObjVar(self, "PalaceInhabitants.gamGuard3"); - attachScript(guard3, "theme_park.tatooine.jabbaspawner.palace_path"); - obj_id guard4 = getObjIdObjVar(self, "PalaceInhabitants.gamGuard4"); - attachScript(guard4, "theme_park.tatooine.jabbaspawner.palace_path"); - obj_id guard6 = getObjIdObjVar(self, "PalaceInhabitants.gamGuard6"); - attachScript(guard6, "theme_park.tatooine.jabbaspawner.palace_path"); - obj_id guard7 = getObjIdObjVar(self, "PalaceInhabitants.gamGuard7"); - attachScript(guard7, "theme_park.tatooine.jabbaspawner.palace_path"); - obj_id guard8 = getObjIdObjVar(self, "PalaceInhabitants.gamGuard8"); - attachScript(guard8, "theme_park.tatooine.jabbaspawner.palace_path"); - obj_id guard9 = getObjIdObjVar(self, "PalaceInhabitants.gamGuard9"); - attachScript(guard9, "theme_park.tatooine.jabbaspawner.palace_path"); - obj_id guard10 = getObjIdObjVar(self, "PalaceInhabitants.gamGuard10"); - attachScript(guard10, "theme_park.tatooine.jabbaspawner.palace_path"); - obj_id guard11 = getObjIdObjVar(self, "PalaceInhabitants.gamGuard11"); - attachScript(guard11, "theme_park.tatooine.jabbaspawner.palace_path"); - obj_id guard12 = getObjIdObjVar(self, "PalaceInhabitants.gamGuard12"); - attachScript(guard12, "theme_park.tatooine.jabbaspawner.palace_path"); + attachScript(getObjIdObjVar(self, "PalaceInhabitants.gamGuard1"), "theme_park.tatooine.jabbaspawner.palace_path"); + attachScript(getObjIdObjVar(self, "PalaceInhabitants.gamGuard2"), "theme_park.tatooine.jabbaspawner.palace_path"); + attachScript(getObjIdObjVar(self, "PalaceInhabitants.gamGuard3"), "theme_park.tatooine.jabbaspawner.palace_path"); + attachScript(getObjIdObjVar(self, "PalaceInhabitants.gamGuard4"), "theme_park.tatooine.jabbaspawner.palace_path"); + attachScript(getObjIdObjVar(self, "PalaceInhabitants.gamGuard6"), "theme_park.tatooine.jabbaspawner.palace_path"); + attachScript(getObjIdObjVar(self, "PalaceInhabitants.gamGuard7"), "theme_park.tatooine.jabbaspawner.palace_path"); + attachScript(getObjIdObjVar(self, "PalaceInhabitants.gamGuard8"), "theme_park.tatooine.jabbaspawner.palace_path"); + attachScript(getObjIdObjVar(self, "PalaceInhabitants.gamGuard9"), "theme_park.tatooine.jabbaspawner.palace_path"); + attachScript(getObjIdObjVar(self, "PalaceInhabitants.gamGuard10"), "theme_park.tatooine.jabbaspawner.palace_path"); + attachScript(getObjIdObjVar(self, "PalaceInhabitants.gamGuard11"), "theme_park.tatooine.jabbaspawner.palace_path"); + attachScript(getObjIdObjVar(self, "PalaceInhabitants.gamGuard11"), "theme_park.tatooine.jabbaspawner.palace_path"); return SCRIPT_CONTINUE; } public int doMonks(obj_id self, dictionary params) throws InterruptedException { - obj_id monk1 = getObjIdObjVar(self, "PalaceInhabitants.bomarrMonk1"); - attachScript(monk1, "theme_park.tatooine.jabbaspawner.palace_path"); - obj_id monk2 = getObjIdObjVar(self, "PalaceInhabitants.bomarrMonk2"); - attachScript(monk2, "theme_park.tatooine.jabbaspawner.palace_path"); - obj_id monk3 = getObjIdObjVar(self, "PalaceInhabitants.bomarrMonk3"); - attachScript(monk3, "theme_park.tatooine.jabbaspawner.palace_path"); - obj_id monk4 = getObjIdObjVar(self, "PalaceInhabitants.bomarrMonk4"); - attachScript(monk4, "theme_park.tatooine.jabbaspawner.palace_path"); - obj_id monk5 = getObjIdObjVar(self, "PalaceInhabitants.bomarrMonk5"); - attachScript(monk5, "theme_park.tatooine.jabbaspawner.palace_path"); + attachScript(getObjIdObjVar(self, "PalaceInhabitants.bomarrMonk1"), "theme_park.tatooine.jabbaspawner.palace_path"); + attachScript(getObjIdObjVar(self, "PalaceInhabitants.bomarrMonk2"), "theme_park.tatooine.jabbaspawner.palace_path"); + attachScript(getObjIdObjVar(self, "PalaceInhabitants.bomarrMonk3"), "theme_park.tatooine.jabbaspawner.palace_path"); + attachScript(getObjIdObjVar(self, "PalaceInhabitants.bomarrMonk4"), "theme_park.tatooine.jabbaspawner.palace_path"); + attachScript(getObjIdObjVar(self, "PalaceInhabitants.bomarrMonk5"), "theme_park.tatooine.jabbaspawner.palace_path"); return SCRIPT_CONTINUE; } public void destroyCelebs(obj_id self) throws InterruptedException @@ -1894,142 +1603,21 @@ public class masterspawner extends script.base_script } public int doGating(obj_id self, dictionary params) throws InterruptedException { - obj_id hall1 = getCellId(self, "hall1"); - obj_id display = getCellId(self, "display"); - obj_id throne = getCellId(self, "throneroom"); - obj_id garage = getCellId(self, "garage1"); - obj_id garage2 = getCellId(self, "garage2"); - obj_id hall8 = getCellId(self, "hall8"); - attachScript(hall1, "theme_park.gating.jabba.stairs_block"); - attachScript(garage2, "theme_park.gating.jabba.garage_block"); - attachScript(garage, "theme_park.gating.jabba.garage_block"); - attachScript(throne, "theme_park.gating.jabba.throne_block"); - attachScript(display, "theme_park.gating.jabba.throne_block"); - attachScript(hall8, "theme_park.gating.jabba.master_block"); + attachScript(getCellId(self, "hall1"), "theme_park.gating.jabba.stairs_block"); + attachScript(getCellId(self, "garage2"), "theme_park.gating.jabba.garage_block"); + attachScript(getCellId(self, "garage1"), "theme_park.gating.jabba.garage_block"); + attachScript(getCellId(self, "throneroom"), "theme_park.gating.jabba.throne_block"); + attachScript(getCellId(self, "display"), "theme_park.gating.jabba.throne_block"); + attachScript(getCellId(self, "hall8"), "theme_park.gating.jabba.master_block"); return SCRIPT_CONTINUE; } public void despawnEveryone(obj_id self) throws InterruptedException { - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.bib")); - removeObjVar(self, "PalaceInhabitants.bib"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.ephant")); - removeObjVar(self, "PalaceInhabitants.ephant"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.reelo")); - removeObjVar(self, "PalaceInhabitants.reelo"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.crumb")); - removeObjVar(self, "PalaceInhabitants.crumb"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.oola")); - removeObjVar(self, "PalaceInhabitants.oola"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.max")); - removeObjVar(self, "PalaceInhabitants.max"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.sy")); - removeObjVar(self, "PalaceInhabitants.sy"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.droopy")); - removeObjVar(self, "PalaceInhabitants.droopy"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.jabba")); - removeObjVar(self, "PalaceInhabitants.jabba"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.pDroid")); - removeObjVar(self, "PalaceInhabitants.pDroid"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.barada")); - removeObjVar(self, "PalaceInhabitants.barada"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.klaatu")); - removeObjVar(self, "PalaceInhabitants.klaatu"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.porcellus")); - removeObjVar(self, "PalaceInhabitants.porcellus"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.malakili")); - removeObjVar(self, "PalaceInhabitants.malakili"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.rancor")); - removeObjVar(self, "PalaceInhabitants.rancor"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.jabba2")); - removeObjVar(self, "PalaceInhabitants.jabba2"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.boba")); - removeObjVar(self, "PalaceInhabitants.boba"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.gamGuard1")); - removeObjVar(self, "PalaceInhabitants.gamGuard1"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.gamGuard2")); - removeObjVar(self, "PalaceInhabitants.gamGuard2"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.gamGuard3")); - removeObjVar(self, "PalaceInhabitants.gamGuard3"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.gamGuard4")); - removeObjVar(self, "PalaceInhabitants.gamGuard4"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.gamGuard5")); - removeObjVar(self, "PalaceInhabitants.gamGuard5"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.gamGuard6")); - removeObjVar(self, "PalaceInhabitants.gamGuard6"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.gamGuard7")); - removeObjVar(self, "PalaceInhabitants.gamGuard7"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.gamGuard8")); - removeObjVar(self, "PalaceInhabitants.gamGuard8"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.gamGuard9")); - removeObjVar(self, "PalaceInhabitants.gamGuard9"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.gamGuard10")); - removeObjVar(self, "PalaceInhabitants.gamGuard10"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.gamGuard11")); - removeObjVar(self, "PalaceInhabitants.gamGuard11"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.gamGuard12")); - removeObjVar(self, "PalaceInhabitants.gamGuard12"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.gamGuard13")); - removeObjVar(self, "PalaceInhabitants.gamGuard13"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.bomarrMonk1")); - removeObjVar(self, "PalaceInhabitants.bomarrMonk1"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.bomarrMonk2")); - removeObjVar(self, "PalaceInhabitants.bomarrMonk2"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.bomarrMonk3")); - removeObjVar(self, "PalaceInhabitants.bomarrMonk3"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.bomarrMonk4")); - removeObjVar(self, "PalaceInhabitants.bomarrMonk4"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.bomarrMonk5")); - removeObjVar(self, "PalaceInhabitants.bomarrMonk5"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.bomarrMonk6")); - removeObjVar(self, "PalaceInhabitants.bomarrMonk6"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.jawa1")); - removeObjVar(self, "PalaceInhabitants.jawa1"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.jawa2")); - removeObjVar(self, "PalaceInhabitants.jawa2"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.jawa3")); - removeObjVar(self, "PalaceInhabitants.jawa3"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.jawa4")); - removeObjVar(self, "PalaceInhabitants.jawa4"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.jawa5")); - removeObjVar(self, "PalaceInhabitants.jawa5"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.jawa6")); - removeObjVar(self, "PalaceInhabitants.jawa6"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.random1")); - removeObjVar(self, "PalaceInhabitants.random1"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.random2")); - removeObjVar(self, "PalaceInhabitants.random2"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.random3")); - removeObjVar(self, "PalaceInhabitants.random3"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.random4")); - removeObjVar(self, "PalaceInhabitants.random4"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.random5")); - removeObjVar(self, "PalaceInhabitants.random5"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.random6")); - removeObjVar(self, "PalaceInhabitants.random6"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.random7")); - removeObjVar(self, "PalaceInhabitants.random7"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.random8")); - removeObjVar(self, "PalaceInhabitants.random8"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.random9")); - removeObjVar(self, "PalaceInhabitants.random9"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.random10")); - removeObjVar(self, "PalaceInhabitants.random10"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.random11")); - removeObjVar(self, "PalaceInhabitants.random11"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.random12")); - removeObjVar(self, "PalaceInhabitants.random12"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.random13")); - removeObjVar(self, "PalaceInhabitants.random13"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.random14")); - removeObjVar(self, "PalaceInhabitants.random14"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.random15")); - removeObjVar(self, "PalaceInhabitants.random15"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.random16")); - removeObjVar(self, "PalaceInhabitants.random16"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.reeyees")); - removeObjVar(self, "PalaceInhabitants.reeyees"); - destroyObject(getObjIdObjVar(self, "PalaceInhabitants.jawl")); - removeObjVar(self, "PalaceInhabitants.jawl"); - return; + destroyCelebs(self); + destroyDroids(self); + destroyGuards(self); + destroyJawas(self); + destroyMonks(self); + destroyRandom(self); } } diff --git a/sku.0/sys.server/compiled/game/script/theme_park/tatooine/jabbaspawner/oola.java b/sku.0/sys.server/compiled/game/script/theme_park/tatooine/jabbaspawner/oola.java old mode 100644 new mode 100755 index 24a69b3aa..95633b72a --- a/sku.0/sys.server/compiled/game/script/theme_park/tatooine/jabbaspawner/oola.java +++ b/sku.0/sys.server/compiled/game/script/theme_park/tatooine/jabbaspawner/oola.java @@ -17,24 +17,17 @@ public class oola extends script.base_script } public int OnDestroy(obj_id self) throws InterruptedException { - obj_id palace = getObjIdObjVar(self, "palace"); - messageTo(palace, "oolaDied", null, 20, true); + messageTo(getObjIdObjVar(self, "palace"), "oolaDied", null, 20, true); return SCRIPT_CONTINUE; } public int OnAttach(obj_id self) throws InterruptedException { grantSkill(self, "social_dancer_novice"); - obj_id max = getObjIdObjVar(self, "max"); - obj_id sy = getObjIdObjVar(self, "sy"); - obj_id droopy = getObjIdObjVar(self, "droopy"); messageTo(self, "startDancing", null, 10, true); return SCRIPT_CONTINUE; } public int startDancing(obj_id self, dictionary params) throws InterruptedException { - obj_id max = getObjIdObjVar(self, "max"); - obj_id sy = getObjIdObjVar(self, "sy"); - obj_id droopy = getObjIdObjVar(self, "droopy"); ai_lib.setMood(self, "themepark_oola"); return SCRIPT_CONTINUE; } diff --git a/sku.0/sys.server/compiled/game/script/theme_park/tatooine/mos_eisley/masterspawner.java b/sku.0/sys.server/compiled/game/script/theme_park/tatooine/mos_eisley/masterspawner.java index d37271df4..7a74edcc9 100755 --- a/sku.0/sys.server/compiled/game/script/theme_park/tatooine/mos_eisley/masterspawner.java +++ b/sku.0/sys.server/compiled/game/script/theme_park/tatooine/mos_eisley/masterspawner.java @@ -20,7 +20,6 @@ public class masterspawner extends script.base_script public int OnInitialize(obj_id self) throws InterruptedException { debugServerConsoleMsg(self, "Initialized Mos Eisley Cantina spawner script"); - dictionary params = new dictionary(); messageTo(self, "spawnThings", null, 2, true); return SCRIPT_CONTINUE; } @@ -39,88 +38,60 @@ public class masterspawner extends script.base_script spawnCheatedGambler(self); spawnEntAlcove(self); spawnJunkDealer(self); - return; } public void spawnHanandChewie(obj_id self) throws InterruptedException { obj_id room = getCellId(self, "cantina"); - location han_loc = new location(10.50f, 1.0f, 11.98f, "tatooine", room); - int han_yaw = -177; - location chewie_loc = new location(10.22f, 1.0f, 9.78f, "tatooine", room); - int chewie_yaw = 0; - obj_id han = create.object("han_solo", han_loc); - obj_id chewie = create.object("chewbacca", chewie_loc); - setYaw(han, han_yaw); - setYaw(chewie, chewie_yaw); + obj_id han = create.object("han_solo", new location(10.50f, 1.0f, 11.98f, "tatooine", room)); + obj_id chewie = create.object("chewbacca", new location(10.22f, 1.0f, 9.78f, "tatooine", room)); + setYaw(han, -177); + setYaw(chewie, 0); setInvulnerable(han, true); setInvulnerable(chewie, true); setCreatureStatic(han, true); setCreatureStatic(chewie, true); - return; } public void spawnPadawanTrialsNpc(obj_id self) throws InterruptedException { - obj_id room = getCellId(self, "cantina"); - location npc_loc = new location(-9.34f, 1.0f, 5.66f, "tatooine", room); - int npc_yaw = 105; - obj_id npc = create.object("patron_human_male_01", npc_loc); - setYaw(npc, npc_yaw); + obj_id npc = create.object("patron_human_male_01", new location(-9.34f, 1.0f, 5.66f, "tatooine", getCellId(self, "cantina"))); + setYaw(npc, 105); setInvulnerable(npc, true); setCreatureStatic(npc, true); ai_lib.setDefaultCalmMood(npc, "npc_standing_drinking"); - obj_id cup = createObject("object/tangible/item/con_drinking_glass_01.iff", npc, ""); - equip(cup, npc); + equip(createObject("object/tangible/item/con_drinking_glass_01.iff", npc, ""), npc); setName(npc, "Marco Vahn (a booking agent)"); attachScript(npc, "conversation.padawan_old_musician_02"); setObjVar(self, "cantinaInhabitants.padawanTrialsNpc", npc); - return; } public void spawnChadraFans(obj_id self) throws InterruptedException { obj_id room = getCellId(self, "cantina"); - location c1_loc = new location(10.70f, 1.0f, -0.23f, "tatooine", room); - int c1_yaw = -158; - location c2_loc = new location(10.43f, 1.0f, -1.47f, "tatooine", room); - int c2_yaw = 25; - obj_id c1 = create.object("chadra_fan_male", c1_loc); - obj_id c2 = create.object("chadra_fan_female", c2_loc); - setYaw(c1, c1_yaw); - setYaw(c2, c2_yaw); + obj_id c1 = create.object("chadra_fan_male", new location(10.70f, 1.0f, -0.23f, "tatooine", room)); + obj_id c2 = create.object("chadra_fan_female", new location(10.43f, 1.0f, -1.47f, "tatooine", room)); + setYaw(c1, -158); + setYaw(c2, 25); setCreatureStatic(c1, true); setCreatureStatic(c2, true); setInvulnerable(c1, true); setInvulnerable(c2, true); ai_lib.setDefaultCalmMood(c1, "conversation"); ai_lib.setDefaultCalmMood(c2, "conversation"); - return; } public void spawnFoyer(obj_id self) throws InterruptedException { obj_id room = getCellId(self, "foyer2"); - location f1_loc = new location(29.51f, 1.0f, -7.38f, "tatooine", room); - int f1_yaw = 47; - location f2_loc = new location(31.01f, 1.0f, -8.83f, "tatooine", room); - int f2_yaw = -12; - location f3_loc = new location(29.54f, 1.0f, -6.18f, "tatooine", room); - int f3_yaw = 171; - location f4_loc = new location(35.96f, 1.0f, 0.74f, "tatooine", room); - int f4_yaw = 1; - location f5_loc = new location(35.72f, 1.0f, 3.19f, "tatooine", room); - int f5_yaw = 158; - location f6_loc = new location(31.6f, 0.1f, 0.3f, "tatooine", room); - int f6_yaw = -90; - obj_id f1 = create.object("commoner", f1_loc); - obj_id f2 = create.object("commoner", f2_loc); - obj_id f3 = create.object("commoner", f3_loc); - obj_id f4 = create.object("commoner", f4_loc); - obj_id f5 = create.object("commoner", f5_loc); - obj_id f6 = create.object("newbie_tutorial_entertainer", f6_loc); - setYaw(f1, f1_yaw); - setYaw(f2, f2_yaw); - setYaw(f3, f3_yaw); - setYaw(f4, f4_yaw); - setYaw(f5, f5_yaw); - setYaw(f6, f6_yaw); + obj_id f1 = create.object("commoner", new location(29.51f, 1.0f, -7.38f, "tatooine", room)); + obj_id f2 = create.object("commoner", new location(31.01f, 1.0f, -8.83f, "tatooine", room)); + obj_id f3 = create.object("commoner", new location(29.54f, 1.0f, -6.18f, "tatooine", room)); + obj_id f4 = create.object("commoner", new location(35.96f, 1.0f, 0.74f, "tatooine", room)); + obj_id f5 = create.object("commoner", new location(35.72f, 1.0f, 3.19f, "tatooine", room)); + obj_id f6 = create.object("newbie_tutorial_entertainer", new location(31.6f, 0.1f, 0.3f, "tatooine", room)); + setYaw(f1, 47); + setYaw(f2, -12); + setYaw(f3, 171); + setYaw(f4, 1); + setYaw(f5, 158); + setYaw(f6, -90); setCreatureStatic(f1, true); setInvulnerable(f1, true); setCreatureStatic(f2, true); @@ -140,35 +111,22 @@ public class masterspawner extends script.base_script ai_lib.setDefaultCalmMood(f5, "npc_sitting_chair"); ai_lib.setDefaultCalmMood(f6, "npc_imperial"); attachScript(f6, "conversation.c_newbie_entertainer"); - return; } public void spawnClosePatrons(obj_id self) throws InterruptedException { obj_id room = getCellId(self, "cantina"); - location s1_loc = new location(22.31f, 1.0f, 3.00f, "tatooine", room); - int s1_yaw = -19; - location s2_loc = new location(20.52f, 1.0f, 4.10f, "tatooine", room); - int s2_yaw = 73; - location s3_loc = new location(21.19f, 1.0f, 5.65f, "tatooine", room); - int s3_yaw = 157; - location s4_loc = new location(23.37f, 1.0f, 4.88f, "tatooine", room); - int s4_yaw = -103; - location s5_loc = new location(16.96f, 1.0f, 6.62f, "tatooine", room); - int s5_yaw = -114; - location s6_loc = new location(14.97f, 1.0f, 6.77f, "tatooine", room); - int s6_yaw = 88; - obj_id s1 = create.object("patron_ishitib_male", s1_loc); - obj_id s2 = create.object("muftak", s2_loc); - obj_id s3 = create.object("patron_devaronian_male", s3_loc); - obj_id s4 = create.object("patron_nikto", s4_loc); - obj_id s5 = create.object("patron_quarren", s5_loc); - obj_id s6 = create.object("patron_klaatu", s6_loc); - setYaw(s1, s1_yaw); - setYaw(s2, s2_yaw); - setYaw(s3, s3_yaw); - setYaw(s4, s4_yaw); - setYaw(s5, s5_yaw); - setYaw(s6, s6_yaw); + obj_id s1 = create.object("patron_ishitib_male", new location(22.31f, 1.0f, 3.00f, "tatooine", room)); + obj_id s2 = create.object("muftak", new location(20.52f, 1.0f, 4.10f, "tatooine", room)); + obj_id s3 = create.object("patron_devaronian_male", new location(21.19f, 1.0f, 5.65f, "tatooine", room)); + obj_id s4 = create.object("patron_nikto", new location(23.37f, 1.0f, 4.88f, "tatooine", room)); + obj_id s5 = create.object("patron_quarren", new location(16.96f, 1.0f, 6.62f, "tatooine", room)); + obj_id s6 = create.object("patron_klaatu", new location(14.97f, 1.0f, 6.77f, "tatooine", room)); + setYaw(s1, -19); + setYaw(s2, 73); + setYaw(s3, 157); + setYaw(s4, -103); + setYaw(s5, -114); + setYaw(s6, 88); setCreatureStatic(s1, true); setCreatureStatic(s2, true); setCreatureStatic(s3, true); @@ -187,62 +145,40 @@ public class masterspawner extends script.base_script ai_lib.setDefaultCalmMood(s4, "npc_sitting_chair"); ai_lib.setDefaultCalmMood(s5, "npc_sitting_chair"); ai_lib.setDefaultCalmMood(s6, "npc_sitting_chair"); - return; } public void spawnStandingConvoGroup(obj_id self) throws InterruptedException { obj_id room = getCellId(self, "cantina"); - location itho_loc = new location(15.89f, 1.0f, 2.48f, "tatooine", room); - int itho_yaw = 36; - location greeata_loc = new location(16.46f, 1.0f, 2.98f, "tatooine", room); - int greeata_yaw = -129; - obj_id itho = create.object("patron_ithorian_male", itho_loc); - obj_id greeata = create.object("commoner", greeata_loc); - setYaw(itho, itho_yaw); - setYaw(greeata, greeata_yaw); + obj_id itho = create.object("patron_ithorian_male", new location(15.89f, 1.0f, 2.48f, "tatooine", room)); + obj_id greeata = create.object("commoner", new location(16.46f, 1.0f, 2.98f, "tatooine", room)); + setYaw(itho, 36); + setYaw(greeata, -129); setCreatureStatic(itho, true); setCreatureStatic(greeata, true); setInvulnerable(itho, true); setInvulnerable(greeata, true); ai_lib.setDefaultCalmMood(itho, "nervous"); ai_lib.setDefaultCalmMood(greeata, "conversation"); - return; } public void spawnAudience(obj_id self) throws InterruptedException { obj_id room = getCellId(self, "cantina"); - location a1_loc = new location(8.68f, 1.0f, -6.08f, "tatooine", room); - int a1_yaw = -148; - location a2_loc = new location(6.76f, 1.0f, -6.48f, "tatooine", room); - int a2_yaw = 177; - location a3_loc = new location(1.99f, 1.0f, -8.44f, "tatooine", room); - int a3_yaw = -35; - location a4_loc = new location(1.19f, 1.0f, -7.63f, "tatooine", room); - int a4_yaw = 152; - location a5_loc = new location(3.62f, 1.0f, -6.78f, "tatooine", room); - int a5_yaw = 0; - location a6_loc = new location(2.84f, 1.0f, -6.30f, "tatooine", room); - int a6_yaw = 16; - location a7_loc = new location(3.62f, 1.0f, -4.77f, "tatooine", room); - int a7_yaw = -176; - location a8_loc = new location(1.74f, 1.0f, -4.91f, "tatooine", room); - int a8_yaw = 95; - obj_id a1 = create.object("patron_human_female_01", a1_loc); - obj_id a2 = create.object("patron_human_male_01", a2_loc); - obj_id a3 = create.object("commoner", a3_loc); - obj_id a4 = create.object("commoner", a4_loc); - obj_id a5 = create.object("stormtrooper_squad_leader", a5_loc); - obj_id a6 = create.object("stormtrooper", a6_loc); - obj_id a7 = create.object("patron_chiss_female", a7_loc); - obj_id a8 = create.object("patron_chiss_male", a8_loc); - setYaw(a1, a1_yaw); - setYaw(a2, a2_yaw); - setYaw(a3, a3_yaw); - setYaw(a4, a4_yaw); - setYaw(a5, a5_yaw); - setYaw(a6, a6_yaw); - setYaw(a7, a7_yaw); - setYaw(a8, a8_yaw); + obj_id a1 = create.object("patron_human_female_01", new location(8.68f, 1.0f, -6.08f, "tatooine", room)); + obj_id a2 = create.object("patron_human_male_01", new location(6.76f, 1.0f, -6.48f, "tatooine", room)); + obj_id a3 = create.object("commoner", new location(1.99f, 1.0f, -8.44f, "tatooine", room)); + obj_id a4 = create.object("commoner", new location(1.19f, 1.0f, -7.63f, "tatooine", room)); + obj_id a5 = create.object("stormtrooper_squad_leader", new location(3.62f, 1.0f, -6.78f, "tatooine", room)); + obj_id a6 = create.object("stormtrooper", new location(2.84f, 1.0f, -6.30f, "tatooine", room)); + obj_id a7 = create.object("patron_chiss_female", new location(3.62f, 1.0f, -4.77f, "tatooine", room)); + obj_id a8 = create.object("patron_chiss_male", new location(1.74f, 1.0f, -4.91f, "tatooine", room)); + setYaw(a1, -148); + setYaw(a2, 177); + setYaw(a3, -35); + setYaw(a4, 152); + setYaw(a5, 0); + setYaw(a6, 16); + setYaw(a7, -176); + setYaw(a8, 95); setCreatureStatic(a1, true); setCreatureStatic(a2, true); setCreatureStatic(a3, true); @@ -267,37 +203,20 @@ public class masterspawner extends script.base_script ai_lib.setDefaultCalmMood(a6, "npc_imperial"); ai_lib.setDefaultCalmMood(a7, "npc_sad"); ai_lib.setDefaultCalmMood(a8, "npc_consoling"); - return; } public void spawnBarPatronsRight(obj_id self) throws InterruptedException { obj_id room = getCellId(self, "cantina"); - location p1_loc = new location(10.65f, 1.0f, 1.91f, "tatooine", room); - location p2_loc = new location(10.17f, 1.0f, 2.74f, "tatooine", room); - location p3_loc = new location(9.08f, 1.0f, 4.15f, "tatooine", room); - location p4_loc = new location(8.49f, 1.0f, 4.64f, "tatooine", room); - location p5_loc = new location(6.11f, 1.0f, 5.40f, "tatooine", room); - location p6_loc = new location(5.11f, 1.0f, 5.40f, "tatooine", room); - location p7_loc = new location(4.11f, 1.0f, 5.40f, "tatooine", room); - location p8_loc = new location(3.11f, 1.0f, 5.40f, "tatooine", room); - location p9_loc = new location(2.11f, 1.0f, 5.40f, "tatooine", room); - location p10_loc = new location(1.11f, 1.0f, 5.40f, "tatooine", room); - location p11_loc = new location(-1.11f, 1.0f, 5.40f, "tatooine", room); - location p12_loc = new location(-2.11f, 1.0f, 6.40f, "tatooine", room); - location p13_loc = new location(-3.11f, 1.0f, 5.40f, "tatooine", room); - location p14_loc = new location(-4.11f, 1.0f, 5.40f, "tatooine", room); - location p15_loc = new location(-5.11f, 1.0f, 6.40f, "tatooine", room); - location p16_loc = new location(-6.11f, 1.0f, 5.40f, "tatooine", room); - obj_id p1 = create.object("businessman", p1_loc); - obj_id p2 = create.object("commoner", p2_loc); - obj_id p3 = create.object("entertainer", p3_loc); - obj_id p4 = create.object("noble", p4_loc); - obj_id p7 = create.object("commoner", p7_loc); - obj_id p8 = create.object("commoner", p8_loc); - obj_id p9 = create.object("commoner", p9_loc); - obj_id p10 = create.object("commoner", p10_loc); - obj_id p13 = create.object("commoner", p13_loc); - obj_id p14 = create.object("businessman", p14_loc); + obj_id p1 = create.object("businessman", new location(10.65f, 1.0f, 1.91f, "tatooine", room)); + obj_id p2 = create.object("commoner", new location(10.17f, 1.0f, 2.74f, "tatooine", room)); + obj_id p3 = create.object("entertainer", new location(9.08f, 1.0f, 4.15f, "tatooine", room)); + obj_id p4 = create.object("noble", new location(8.49f, 1.0f, 4.64f, "tatooine", room)); + obj_id p7 = create.object("commoner", new location(4.11f, 1.0f, 5.40f, "tatooine", room)); + obj_id p8 = create.object("commoner", new location(3.11f, 1.0f, 5.40f, "tatooine", room)); + obj_id p9 = create.object("commoner", new location(2.11f, 1.0f, 5.40f, "tatooine", room)); + obj_id p10 = create.object("commoner", new location(1.11f, 1.0f, 5.40f, "tatooine", room)); + obj_id p13 = create.object("commoner", new location(-3.11f, 1.0f, 5.40f, "tatooine", room)); + obj_id p14 = create.object("businessman", new location(-4.11f, 1.0f, 5.40f, "tatooine", room)); setCreatureStatic(p1, true); setCreatureStatic(p2, true); setCreatureStatic(p3, true); @@ -350,55 +269,39 @@ public class masterspawner extends script.base_script equip(cup13, p13); obj_id cup14 = createObject("object/tangible/item/con_drinking_glass_01.iff", p14, ""); equip(cup14, p14); - return; } public void spawnSittingPatrons(obj_id self) throws InterruptedException { obj_id room = getCellId(self, "cantina"); - location p1_loc = new location(16.37f, 1.0f, -3.23f, "tatooine", room); - int p1_yaw = -128; - location p2_loc = new location(14.57f, 1.0f, -2.85f, "tatooine", room); - int p2_yaw = 127; - location p3_loc = new location(14.21f, 1.0f, -4.89f, "tatooine", room); - int p3_yaw = 46; - location p4_loc = new location(16.49f, 1.0f, -4.86f, "tatooine", room); - int p4_yaw = -48; - obj_id p2 = create.object("patron_human_female_02", p2_loc); - obj_id p3 = create.object("patron_human_male_03", p3_loc); - obj_id p4 = create.object("patron_human_female_03", p4_loc); + obj_id p2 = create.object("patron_human_female_02", new location(14.57f, 1.0f, -2.85f, "tatooine", room)); + obj_id p3 = create.object("patron_human_male_03", new location(14.21f, 1.0f, -4.89f, "tatooine", room)); + obj_id p4 = create.object("patron_human_female_03", new location(16.49f, 1.0f, -4.86f, "tatooine", room)); setCreatureStatic(p2, true); setCreatureStatic(p3, true); setCreatureStatic(p4, true); setInvulnerable(p2, true); setInvulnerable(p3, true); setInvulnerable(p4, true); - setYaw(p2, p2_yaw); - setYaw(p3, p3_yaw); - setYaw(p4, p4_yaw); + setYaw(p2, 127); + setYaw(p3, 46); + setYaw(p4, -48); ai_lib.setDefaultCalmMood(p2, "npc_sitting_table"); ai_lib.setDefaultCalmMood(p3, "npc_sitting_table_eating"); ai_lib.setDefaultCalmMood(p4, "npc_sitting_chair"); - location p7_loc = new location(24.34f, 1.0f, -8.23f, "tatooine", room); - int p7_yaw = 49; - location p8_loc = new location(26.20f, 1.0f, -8.33f, "tatooine", room); - int p8_yaw = -43; - obj_id p7 = create.object("patron_human_female_04", p7_loc); - obj_id p8 = create.object("patron_human_male_04", p8_loc); + obj_id p7 = create.object("patron_human_female_04", new location(24.34f, 1.0f, -8.23f, "tatooine", room)); + obj_id p8 = create.object("patron_human_male_04", new location(26.20f, 1.0f, -8.33f, "tatooine", room)); setCreatureStatic(p7, true); setCreatureStatic(p8, true); setInvulnerable(p7, true); setInvulnerable(p8, true); - setYaw(p7, p7_yaw); - setYaw(p8, p8_yaw); + setYaw(p7, 49); + setYaw(p8, -43); ai_lib.setDefaultCalmMood(p7, "npc_sitting_table_eating"); ai_lib.setDefaultCalmMood(p8, "npc_sitting_chair"); - return; } public void spawnWuher(obj_id self) throws InterruptedException { - obj_id room = getCellId(self, "cantina"); - location wuherLoc = new location(8.46f, 1.0f, 0.35f, "tatooine", room); - obj_id wuher = create.object("wuher", wuherLoc); + obj_id wuher = create.object("wuher", new location(8.46f, 1.0f, 0.35f, "tatooine", getCellId(self, "cantina"))); create.addDestroyMessage(wuher, "wuherDied", 10f, self); // all bartenders should move around and do their job... nobody gets away with just standing around. // (removing setCreatureStatic to allow Wuher to move around.) @@ -408,26 +311,15 @@ public class masterspawner extends script.base_script ai_lib.setDefaultCalmMood(wuher, "npc_imperial"); attachScript(wuher, "npc.bartender.base"); attachScript(wuher, "npc.bartender.listen"); - return; } public void spawnBithBand(obj_id self) throws InterruptedException { obj_id room = getCellId(self, "alcove3"); - location figrinloc = new location(3.69f, 1.0f, -14.40f, "tatooine", room); - int figrinYaw = 50; - location boxloc = new location(4.11f, 1.0f, -17.07f, "tatooine", room); - int boxYaw = 45; - location hornloc = new location(1.29f, 1.0f, -15.18f, "tatooine", room); - int hornYaw = 70; - location fizzloc = new location(2.32f, 1.0f, -16.47f, "tatooine", room); - int fizzYaw = 44; - location bfloc = new location(0.54f, 1.0f, -17.13f, "tatooine", room); - int bfYaw = 38; - obj_id figrin = create.object("figrin_dan", figrinloc); - obj_id box = create.object("bith_musician", boxloc); - obj_id horn = create.object("bith_musician", hornloc); - obj_id fizz = create.object("bith_musician", fizzloc); - obj_id bandfill = create.object("bith_musician", bfloc); + obj_id figrin = create.object("figrin_dan", new location(3.69f, 1.0f, -14.40f, "tatooine", room)); + obj_id box = create.object("bith_musician", new location(4.11f, 1.0f, -17.07f, "tatooine", room)); + obj_id horn = create.object("bith_musician", new location(1.29f, 1.0f, -15.18f, "tatooine", room)); + obj_id fizz = create.object("bith_musician", new location(2.32f, 1.0f, -16.47f, "tatooine", room)); + obj_id bandfill = create.object("bith_musician", new location(0.54f, 1.0f, -17.13f, "tatooine", room)); setObjVar(figrin, performance.NPC_ENTERTAINMENT_NO_ENTERTAIN, 1); setObjVar(box, performance.NPC_ENTERTAINMENT_NO_ENTERTAIN, 1); setObjVar(horn, performance.NPC_ENTERTAINMENT_NO_ENTERTAIN, 1); @@ -438,11 +330,11 @@ public class masterspawner extends script.base_script ai_lib.setDefaultCalmMood(horn, "themepark_music_3"); ai_lib.setDefaultCalmMood(fizz, "themepark_music_3"); ai_lib.setDefaultCalmMood(bandfill, "themepark_music_3"); - setYaw(figrin, figrinYaw); - setYaw(box, boxYaw); - setYaw(horn, hornYaw); - setYaw(fizz, fizzYaw); - setYaw(bandfill, bfYaw); + setYaw(figrin, 50); + setYaw(box, 45); + setYaw(horn, 70); + setYaw(fizz, 44); + setYaw(bandfill, 38); setCreatureStatic(figrin, true); setInvulnerable(figrin, true); setCreatureStatic(box, true); @@ -458,15 +350,10 @@ public class masterspawner extends script.base_script setName(horn, "Tedn Dahai"); setName(fizz, "Doikk Na'ts"); setName(bandfill, "Nalan Cheel"); - obj_id kloo = createObject("object/tangible/instrument/kloo_horn.iff", figrin, ""); - equip(kloo, figrin); - obj_id kloo2 = createObject("object/tangible/instrument/kloo_horn.iff", horn, ""); - equip(kloo2, horn); - obj_id fizzHorn = createObject("object/tangible/instrument/fizz.iff", fizz, ""); - equip(fizzHorn, fizz); - obj_id bf = createObject("object/tangible/instrument/bandfill.iff", bandfill, ""); - equip(bf, bandfill); - return; + equip(createObject("object/tangible/instrument/kloo_horn.iff", figrin, ""), figrin); + equip(createObject("object/tangible/instrument/kloo_horn.iff", horn, ""), horn); + equip(createObject("object/tangible/instrument/fizz.iff", fizz, ""), fizz); + equip(createObject("object/tangible/instrument/bandfill.iff", bandfill, ""), bandfill); } public int spawnThings(obj_id self, dictionary params) throws InterruptedException { @@ -505,36 +392,24 @@ public class masterspawner extends script.base_script } public void spawnCheatedGambler(obj_id self) throws InterruptedException { - obj_id room = getCellId(self, "stage"); - location CG = new location(-6.5f, -.9f, -20.7f, "tatooine", room); - int yaw = 60; - obj_id gambler = create.object("ep3_cheated_gambler", CG); - setYaw(gambler, yaw); + obj_id gambler = create.object("ep3_cheated_gambler", new location(-6.5f, -.9f, -20.7f, "tatooine", getCellId(self, "stage"))); + setYaw(gambler, 60); ai_lib.setDefaultCalmMood(gambler, "npc_sad"); - return; } public void spawnEntAlcove(obj_id self) throws InterruptedException { - obj_id room = getCellId(self, "alcove1"); - location entLoc = new location(19.5f, -.9f, -19.8f, "tatooine", room); - int yaw = -1; - obj_id ent = create.object("prof_quest_entertainer", entLoc); - setYaw(ent, yaw); + obj_id ent = create.object("prof_quest_entertainer", new location(19.5f, -.9f, -19.8f, "tatooine", getCellId(self, "alcove1"))); + setYaw(ent, -1); setCreatureStatic(ent, true); setInvulnerable(ent, true); ai_lib.setDefaultCalmMood(ent, "npc_imperial"); attachScript(ent, "conversation.c_prof_ent_questgiver"); - return; } public void spawnJunkDealer(obj_id self) throws InterruptedException { - obj_id room = getCellId(self, "private_room2"); - location junkLoc = new location(-30.9152f, -0.52f, 6.8631f, "tatooine", room); - int yaw = 25; - obj_id junkDealer = create.object("junk_dealer", junkLoc); - setYaw(junkDealer, yaw); + obj_id junkDealer = create.object("junk_dealer", new location(-30.9152f, -0.52f, 6.8631f, "tatooine", getCellId(self, "private_room2"))); + setYaw(junkDealer, 25); setInvulnerable(junkDealer, true); ai_lib.setDefaultCalmMood(junkDealer, "npc_imperial"); - return; } }