From 4202903a6f37b2e6db88dc9473c61b85c57bb9e1 Mon Sep 17 00:00:00 2001 From: AconiteGodOfSWG Date: Mon, 8 Mar 2021 19:09:53 -0500 Subject: [PATCH] more script clean up --- .../game/script/library/advanced_turret.java | 2 +- .../compiled/game/script/library/ai_lib.java | 41 ++++++++++--------- .../compiled/game/script/library/arena.java | 34 ++------------- .../compiled/game/script/library/armor.java | 23 +++-------- 4 files changed, 32 insertions(+), 68 deletions(-) diff --git a/sku.0/sys.server/compiled/game/script/library/advanced_turret.java b/sku.0/sys.server/compiled/game/script/library/advanced_turret.java index 6bb24ab8b..79c9dcb71 100755 --- a/sku.0/sys.server/compiled/game/script/library/advanced_turret.java +++ b/sku.0/sys.server/compiled/game/script/library/advanced_turret.java @@ -232,7 +232,7 @@ public class advanced_turret extends script.base_script return; } setObjVar(turret, MY_WEAPON, objWeapon); - setWeaponAttackSpeed(objWeapon, attackSpeed < 1.0f ? 1.0f : attackSpeed); + setWeaponAttackSpeed(objWeapon, Math.max(attackSpeed, 1.0f)); int primaryType = DAMAGE_ENERGY; int secondaryType = DAMAGE_ELEMENTAL_HEAT; int primaryMinDamage = 0; 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 index 68aea7dc3..92f52f8e7 100755 --- a/sku.0/sys.server/compiled/game/script/library/ai_lib.java +++ b/sku.0/sys.server/compiled/game/script/library/ai_lib.java @@ -466,7 +466,7 @@ public class ai_lib extends script.base_script for (int i = 0; i < waypoints.length; i++) { coords = parseWaypoints(waypoints[i]); - if (coords != null && coords.length == 2) + if (coords.length == 2) { patrolLoc.x = baseLoc.x + coords[0]; patrolLoc.z = baseLoc.z + coords[1]; @@ -1019,7 +1019,7 @@ public class ai_lib extends script.base_script { String mySocialGroup = getSocialGroup(npc); String yourSocialGroup = getSocialGroup(target); - if ((mySocialGroup != null) && (yourSocialGroup != null) && mySocialGroup.equals(yourSocialGroup)) + if ((mySocialGroup != null) && mySocialGroup.equals(yourSocialGroup)) { result = true; } @@ -1028,7 +1028,7 @@ public class ai_lib extends script.base_script { String mySocialGroup = factions.getFaction(npc); String yourSocialGroup = factions.getFaction(target); - if ((mySocialGroup != null) && (yourSocialGroup != null) && mySocialGroup.equals(yourSocialGroup)) + if ((mySocialGroup != null) && mySocialGroup.equals(yourSocialGroup)) { result = true; } @@ -1044,10 +1044,11 @@ public class ai_lib extends script.base_script 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))) - if (!hasScript(ai, "ai.pet_advance")) - if (aiIsStalker(ai)) - return true; + if (!(isPlayer(ai) || aiGetNiche(ai) == NICHE_NPC || isAndroid(ai))) { + if (!hasScript(ai, "ai.pet_advance")) { + return aiIsStalker(ai); + } + } return false; } public static boolean isAggroToward(obj_id npc, obj_id threat) throws InterruptedException @@ -1073,10 +1074,7 @@ public class ai_lib extends script.base_script { if (ai_lib.isAggro(npc)) { - if (reaction <= factions.REACTION_NEUTRAL) - { - return true; - } + return reaction <= factions.REACTION_NEUTRAL; } return false; } @@ -1084,10 +1082,7 @@ public class ai_lib extends script.base_script { return true; } - if (ai_lib.aiGetNiche(npc) == NICHE_CARNIVORE && ai_lib.aiGetNiche(threat) == NICHE_HERBIVORE) { - return true; - } - return false; + return ai_lib.aiGetNiche(npc) == NICHE_CARNIVORE && ai_lib.aiGetNiche(threat) == NICHE_HERBIVORE; } public static boolean isAggro(obj_id ai) throws InterruptedException { @@ -1116,13 +1111,15 @@ public class ai_lib extends script.base_script String creatureName = getCreatureName(npc); return creatureName != null && (dataTableGetInt(CREATURE_TABLE, creatureName, "healer") != 0); } - public static boolean incapacitateMob(obj_id target) throws InterruptedException + public static void incapacitateMob(obj_id target) throws InterruptedException { if (target == null || !isMob(target)) { - return false; + return; } - return setHealth(target, -50) && setAction(target, -50) && setMind(target, -50); + setHealth(target, -50); + setAction(target, -50); + setMind(target, -50); } public static boolean isHumanSkeleton(obj_id npc) throws InterruptedException { if (isPlayer(npc)) { @@ -1546,7 +1543,13 @@ public class ai_lib extends script.base_script String creatureName = getCreatureName(creature); if (creatureName.indexOf("elite_") < 1 && creatureName.indexOf("boss_") < 1) { - create.initializeCreature(creature, creatureName, utils.dataTableGetRow(CREATURE_TABLE, creatureName), getLevel(creature) + 1); + dictionary d = utils.dataTableGetRow(CREATURE_TABLE, creatureName); + if (d != null) { + create.initializeCreature(creature, creatureName, d, getLevel(creature) + 1); + } else + { + debugConsoleMsg(creature, "ai_lib.creatureLevelUp() Could not get data table dictionary for row requested for creature "+creatureName); + } } } public static boolean mindTrick(obj_id player, obj_id target) throws InterruptedException diff --git a/sku.0/sys.server/compiled/game/script/library/arena.java b/sku.0/sys.server/compiled/game/script/library/arena.java index cc3ee6e16..6e2e1ea4b 100755 --- a/sku.0/sys.server/compiled/game/script/library/arena.java +++ b/sku.0/sys.server/compiled/game/script/library/arena.java @@ -198,7 +198,6 @@ public class arena extends script.base_script trace.log("force_rank", "Rank #" + rank + " now has a new challenge score of " + score[idx], null, trace.TL_CS_LOG); setObjVar(terminal, VAR_ALL_RANKS, ranks); setObjVar(terminal, VAR_RANK_CHALLENGE_SCORES, score); - return; } public static String[] getChallengeScoreStrings(obj_id terminal) throws InterruptedException { @@ -249,7 +248,6 @@ public class arena extends script.base_script setObjVar(terminal, VAR_RANK_CHALLENGE_SCORES, scores); setObjVar(terminal, VAR_ALL_RANKS, ranks); } - return; } public static void initializeArena(obj_id terminal) throws InterruptedException { @@ -286,7 +284,6 @@ public class arena extends script.base_script attachScript(arenaCell, "systems.gcw.dark_jedi_arena"); } } - return; } public static void cleanupChallengeData(obj_id terminal) throws InterruptedException { @@ -397,11 +394,7 @@ public class arena extends script.base_script { dishOutChallengeAnswerPointsToRanks(terminal); } - else - { - } } - return; } public static void dishOutChallengeAnswerPointsToRanks(obj_id terminal) throws InterruptedException { @@ -439,20 +432,17 @@ public class arena extends script.base_script } removeObjVar(terminal, VAR_CH_RANKS_GOT_CHALLENGED); removeObjVar(terminal, VAR_CH_RANKS_WHO_ANSWERED); - return; } public static void openArenaForChallenges(obj_id terminal) throws InterruptedException { trace.log("force_rank", "Opening arena for challenges (GameTime: " + getGameTime() + ").", null, trace.TL_CS_LOG | trace.TL_DEBUG); setObjVar(terminal, VAR_ARENA_OPEN_FOR_CHALLENGES, true); setObjVar(terminal, VAR_ARENA_LAST_OPEN_TIME, getGameTime()); - return; } public static void closeArenaForChallenges(obj_id terminal) throws InterruptedException { trace.log("force_rank", "Closing arena for challenges (GameTime: " + getGameTime() + ").", null, trace.TL_CS_LOG | trace.TL_DEBUG); setObjVar(terminal, VAR_ARENA_OPEN_FOR_CHALLENGES, false); - return; } public static boolean isArenaOpenForChallenges(obj_id terminal) throws InterruptedException { @@ -490,7 +480,6 @@ public class arena extends script.base_script sendSystemMessageProse(rankMember, ppRank); utils.sendMail(msgSubject, ppRank, utils.getRealPlayerFirstName(rankMember), MAIL_FROM_ENCLAVE); } - return; } public static void notifyChallengeAccepted(obj_id terminal, obj_id challenger, obj_id defender, int rankFightingFor) throws InterruptedException { @@ -512,7 +501,6 @@ public class arena extends script.base_script sendSystemMessageProse(rankMember, ppAll); utils.sendMail(msgSubject, ppAll, utils.getRealPlayerFirstName(rankMember), MAIL_FROM_ENCLAVE); } - return; } public static void notifyChallengeConcluded(obj_id terminal, obj_id challenger, obj_id defender, boolean challengerWon, int rankFightingFor) throws InterruptedException { @@ -540,7 +528,6 @@ public class arena extends script.base_script sendSystemMessageProse(rankMember, ppAll); utils.sendMail(msgSubject, ppAll, utils.getRealPlayerFirstName(rankMember), MAIL_FROM_ENCLAVE); } - return; } public static void notifyChallengeTimedOut(obj_id terminal, obj_id challenger, int rankChallenged) throws InterruptedException { @@ -561,7 +548,6 @@ public class arena extends script.base_script sendSystemMessageProse(rankMember, ppAll); utils.sendMail(msgSubject, ppAll, utils.getRealPlayerFirstName(rankMember), MAIL_FROM_ENCLAVE); } - return; } public static Vector getChallengerIdsForRank(obj_id challengeTerminal, int rank) throws InterruptedException { @@ -645,8 +631,7 @@ public class arena extends script.base_script utils.addElement(players, utils.getRealPlayerFirstName(challengers[i]) + timeLeft); } } - String[] arrayNames = utils.toStaticStringArray(players); - return arrayNames; + return utils.toStaticStringArray(players); } public static boolean addChallengeIssueData(obj_id challengeTerminal, obj_id challenger, int rank) throws InterruptedException { @@ -806,11 +791,7 @@ public class arena extends script.base_script return false; } location theloc = getLocation(player); - if (theloc.cell == arenaCell && theloc.x > ARENA_X_MIN && theloc.x < ARENA_X_MAX && theloc.z > ARENA_Z_MIN && theloc.z < ARENA_Z_MAX) - { - return true; - } - return false; + return theloc.cell == arenaCell && theloc.x > ARENA_X_MIN && theloc.x < ARENA_X_MAX && theloc.z > ARENA_Z_MIN && theloc.z < ARENA_Z_MAX; } public static boolean acceptChallenge(obj_id challengeTerminal, obj_id defender, obj_id challenger) throws InterruptedException { @@ -847,7 +828,6 @@ public class arena extends script.base_script int defenderRank = force_rank.getForceRank(enclave, getRealPlayerFirstNameAuth(defender)); force_rank.demoteForceRank(enclave, getRealPlayerFirstNameAuth(defender), defenderRank - 1); force_rank.promoteForceRank(challenger); - return; } public static void doChallengerLostPenalties(obj_id defender, obj_id challenger, obj_id enclave, boolean forfeit) throws InterruptedException { @@ -857,7 +837,6 @@ public class arena extends script.base_script force_rank.adjustForceRankXP(challenger, pvp.getAdjustedForceRankXPDelta(challenger, defender, 1.0f, true)); force_rank.adjustForceRankXP(defender, pvp.getAdjustedForceRankXPDelta(challenger, defender, 1.0f, false)); } - return; } public static void duelistDied(obj_id player, obj_id opponent, obj_id enclave, boolean forfeit) throws InterruptedException { @@ -970,7 +949,6 @@ public class arena extends script.base_script doDefenderLostPenalties(player, opponent, enclave, forfeit); notifyChallengeConcluded(challengeTerminal, opponent, player, true, rankChallenged); } - return; } public static void leftArenaDuringDuel(obj_id player) throws InterruptedException { @@ -982,7 +960,6 @@ public class arena extends script.base_script obj_id enclave = force_rank.getEnclave(player); trace.log("force_rank", "Player %TU has somehow left the arena during a duel. Counting abandonment as death.", player, trace.TL_CS_LOG | trace.TL_DEBUG); duelistDied(player, utils.getObjIdScriptVar(player, arena.VAR_I_AM_DUELING), enclave, true); - return; } public static obj_id isEitherDuelistInADuel(obj_id challengeTerminal, obj_id duelist1, obj_id duelist2) throws InterruptedException { @@ -1111,7 +1088,6 @@ public class arena extends script.base_script utils.setScriptVar(defender, "noBeneficialJediHelp", 1); force_rank.makePlayersPermaEnemies(challenger, defender); sendDirtyObjectMenuNotification(terminal); - return; } public static void teleportPlayerToRandomArenaLoc(obj_id player, obj_id arenaCell) throws InterruptedException { @@ -1135,11 +1111,7 @@ public class arena extends script.base_script return false; } obj_id container = getTopMostContainer(player); - if (!isIdValid(container) || !hasScript(container, force_rank.SCRIPT_ENCLAVE_CONTROLLER)) - { - return false; - } - return true; + return isIdValid(container) && hasScript(container, force_rank.SCRIPT_ENCLAVE_CONTROLLER); } public static String[] getPlayerNamesForIssuedChallenges(obj_id challengeTerminal, int rank) throws InterruptedException { 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 3fe988d10..42a3c65ad 100755 --- a/sku.0/sys.server/compiled/game/script/library/armor.java +++ b/sku.0/sys.server/compiled/game/script/library/armor.java @@ -424,7 +424,7 @@ public class armor extends script.base_script return null; } Object o = ARMOR_PENALTY_TYPE_MAP.get(armorCategory * 10 + armorLevel); - if (o == null || !(o instanceof Integer)) + if (!(o instanceof Integer)) { return null; } @@ -437,7 +437,7 @@ public class armor extends script.base_script for (int i = 0; i < penalties.length; ++i) { o = ARMOR_PENALTY_COLUMN_MAP.get(ARMOR_PENALTY_INDEXES[i]); - if (o == null || !(o instanceof String)) + if (!(o instanceof String)) { return null; } @@ -881,19 +881,12 @@ public class armor extends script.base_script { return false; } - if (!hasObjVar(target, baseObjvar + "." + OBJVAR_ARMOR_CATEGORY)) - { - return false; - } + return hasObjVar(target, baseObjvar + "." + OBJVAR_ARMOR_CATEGORY); } else { - if (!hasScript(target, SCRIPT_ARMOR_EXAMINE)) - { - return false; - } + return hasScript(target, SCRIPT_ARMOR_EXAMINE); } - return true; } public static int getArmorLevel(obj_id armor) throws InterruptedException { @@ -1376,7 +1369,7 @@ public class armor extends script.base_script } trial.bumpSession(objPlayer, "displayDefensiveMods"); messageTo(objPlayer, "setDisplayOnlyDefensiveMods", trial.getSessionDict(objPlayer, "displayDefensiveMods"), 5, false); - final String strArmor[] = + final String[] strArmor = { "chest2", "bicep_r", @@ -1631,11 +1624,7 @@ public class armor extends script.base_script { return false; } - else if (utils.getIntScriptVar(wearer, "armor.armor_set_worn") > -1) - { - return true; - } - return false; + else return utils.getIntScriptVar(wearer, "armor.armor_set_worn") > -1; } public static int getExpertiseArmorSetId(obj_id wearer) throws InterruptedException {