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 393eaabca..98b4a6def 100755 --- a/sku.0/sys.server/compiled/game/script/ai/ai.java +++ b/sku.0/sys.server/compiled/game/script/ai/ai.java @@ -1036,56 +1036,55 @@ public class ai extends script.base_script { hasLoot |= loot.addChronicleLoot(self); } - int corpseLevel = getLevel(self); - boolean doNotDropCard = false; - int difficultyClass = getIntObjVar(self, "difficultyClass"); - int sourceSystem = scheduled_drop.SYSTEM_COMBAT_NORMAL; - switch (difficultyClass) - { - case 0: - sourceSystem = scheduled_drop.SYSTEM_COMBAT_NORMAL; - break; - case 1: - sourceSystem = scheduled_drop.SYSTEM_COMBAT_ELITE; - break; - case 2: - sourceSystem = scheduled_drop.SYSTEM_COMBAT_BOSS; - break; - } - int delayCount = 0; - for (obj_id pk1 : pks) { - if (isIdValid(pk1) && (corpseLevel + 5 < getLevel(pk1) || utils.isFreeTrial(pk1))) { + + if(scheduled_drop.isSystemEnabled()) { + int corpseLevel = getLevel(self); + boolean doNotDropCard = false; + int difficultyClass = getIntObjVar(self, "difficultyClass"); + int sourceSystem = scheduled_drop.SYSTEM_COMBAT_NORMAL; + switch (difficultyClass) { + case 0: + sourceSystem = scheduled_drop.SYSTEM_COMBAT_NORMAL; + break; + case 1: + sourceSystem = scheduled_drop.SYSTEM_COMBAT_ELITE; + break; + case 2: + sourceSystem = scheduled_drop.SYSTEM_COMBAT_BOSS; + break; + } + int delayCount = 0; + for (obj_id pk1 : pks) { + if (isIdValid(pk1) && (corpseLevel + 5 < getLevel(pk1) || utils.isFreeTrial(pk1))) { + doNotDropCard = true; + } + if (isIdValid(pk1) && scheduled_drop.hasCardDelay(pk1, sourceSystem)) { + delayCount++; + } + } + if (delayCount > pks.length / 2) { doNotDropCard = true; } - if (isIdValid(pk1) && scheduled_drop.hasCardDelay(pk1, sourceSystem)) { - delayCount++; - } - } - if (delayCount > pks.length / 2) - { - doNotDropCard = true; - } - boolean canDrop = scheduled_drop.canDropCard(sourceSystem); - for (obj_id pk : pks) { - if (isIdValid(pk)) { - utils.setScriptVar(pk, scheduled_drop.PLAYER_SCRIPTVAR_DROP_TIME, getGameTime()); - if (isGod(pk) && hasObjVar(pk, "qa_tcg_always_drop")) { - if (!doNotDropCard) { - canDrop = true; + boolean canDrop = scheduled_drop.canDropCard(sourceSystem); + for (obj_id pk : pks) { + if (isIdValid(pk)) { + utils.setScriptVar(pk, scheduled_drop.PLAYER_SCRIPTVAR_DROP_TIME, getGameTime()); + if (isGod(pk) && hasObjVar(pk, "qa_tcg_always_drop")) { + if (!doNotDropCard) { + canDrop = true; + } + } + if (isGod(pk) && hasObjVar(pk, "qa_tcg")) { + sendSystemMessageTestingOnly(pk, "QA TCG COMBAT. Do not drop card? " + doNotDropCard + " hasCardDelay? " + scheduled_drop.hasCardDelay(pk, sourceSystem) + " isTrial? " + utils.isFreeTrial(pk) + " bad level? " + (corpseLevel + 5 < getLevel(pk))); } } - if (isGod(pk) && hasObjVar(pk, "qa_tcg")) { - sendSystemMessageTestingOnly(pk, "QA TCG COMBAT. Do not drop card? " + doNotDropCard + " hasCardDelay? " + scheduled_drop.hasCardDelay(pk, sourceSystem) + " isTrial? " + utils.isFreeTrial(pk) + " bad level? " + (corpseLevel + 5 < getLevel(pk))); - } } - } - if (!doNotDropCard) - { - obj_id inv = utils.getInventoryContainer(self); - if (isIdValid(inv) && canDrop) - { - scheduled_drop.dropCard(sourceSystem, inv); - hasLoot = true; + if (!doNotDropCard) { + obj_id inv = utils.getInventoryContainer(self); + if (isIdValid(inv) && canDrop) { + scheduled_drop.dropCard(sourceSystem, inv); + hasLoot = true; + } } } if (hasLoot) diff --git a/sku.0/sys.server/compiled/game/script/library/scheduled_drop.java b/sku.0/sys.server/compiled/game/script/library/scheduled_drop.java index f19edc23f..d638c8974 100755 --- a/sku.0/sys.server/compiled/game/script/library/scheduled_drop.java +++ b/sku.0/sys.server/compiled/game/script/library/scheduled_drop.java @@ -10,6 +10,18 @@ public class scheduled_drop extends script.base_script public scheduled_drop() { } + + /** + * ******************************************************************************************* + * NOTE: The scheduled drop system is disabled by default because it only contains deprecated values. + * The existing datatables from SOE end all drops in 2009, so they will need to be changed for future usage. + * This system runs a chance to drop on each kill of an NPC, crafted item, or buffed player, so it should + * not be enabled unless it will actually be used, due to the sheer amount of times it will run the checks. + * + * To enable this system, first update the tables in sys.server datatables/scheduled_drop for whatever you want to drop + * Then set enableScheduledDropSystem=true in localOptions.cfg. + * ******************************************************************************************* + */ public static final String DATATABLE_SCHEDULE = "datatables/scheduled_drop/schedule.iff"; public static final String DATATABLE_PROMOTIONS = "datatables/scheduled_drop/promotions.iff"; public static final String DATATABLE_SERVER_PERCENTAGES = "datatables/scheduled_drop/server_percentages.iff"; @@ -307,6 +319,9 @@ public class scheduled_drop extends script.base_script } public static void instantiatePromotionsOnCluster() throws InterruptedException { + if(!isSystemEnabled()) { + return; + } int lastUpdate = getLastClusterUpdateTime(); int currentDate = getCalendarTime(); if (currentDate - lastUpdate < 1800) @@ -392,6 +407,9 @@ public class scheduled_drop extends script.base_script } public static boolean canDropCard(int systemToDrop) throws InterruptedException { + if(!isSystemEnabled()) { + return false; + } switch (systemToDrop) { case SYSTEM_COMBAT_NORMAL: @@ -414,6 +432,9 @@ public class scheduled_drop extends script.base_script } public static obj_id dropCard(int systemToDrop, obj_id container) throws InterruptedException { + if(!isSystemEnabled()) { + return null; + } obj_id self = getSelf(); String typeName = "card"; instantiatePromotionsOnCluster(); @@ -474,4 +495,7 @@ public class scheduled_drop extends script.base_script messageTo(planet, "reducePromotion", params, 1.0f, true); return card; } + public static boolean isSystemEnabled() throws InterruptedException { + return utils.checkConfigFlag("Custom", "enableScheduledDropSystem"); + } } diff --git a/sku.0/sys.server/compiled/game/script/library/space_combat.java b/sku.0/sys.server/compiled/game/script/library/space_combat.java index b7fdc454a..12bd9c52e 100755 --- a/sku.0/sys.server/compiled/game/script/library/space_combat.java +++ b/sku.0/sys.server/compiled/game/script/library/space_combat.java @@ -888,7 +888,6 @@ public class space_combat extends script.base_script { final String LOOT_TABLE = "datatables/space_loot/loot_items.iff"; final String LOOKUP_TABLE = "datatables/space_loot/loot_lookup.iff"; - String strContainer = "object/tangible/container/drum/warren_drum_loot.iff"; obj_id objContainer; obj_id objPilot = getPilotId(objAttacker); if (space_utils.isShipWithInterior(objAttacker)) @@ -907,8 +906,7 @@ public class space_combat extends script.base_script { return; } - if (isIdValid(objPilot)) - { + if (scheduled_drop.isSystemEnabled()) { obj_id pilotInv = utils.getInventoryContainer(objPilot); boolean canDrop = scheduled_drop.canDropCard(scheduled_drop.SYSTEM_COMBAT_SPACE); boolean hasDelay = scheduled_drop.hasCardDelay(objPilot, scheduled_drop.SYSTEM_COMBAT_SPACE); diff --git a/sku.0/sys.server/compiled/game/script/planet/planet_base.java b/sku.0/sys.server/compiled/game/script/planet/planet_base.java index 8ae755ffe..19747d406 100755 --- a/sku.0/sys.server/compiled/game/script/planet/planet_base.java +++ b/sku.0/sys.server/compiled/game/script/planet/planet_base.java @@ -54,7 +54,9 @@ public class planet_base extends script.base_script CustomerServiceLog("holidayEvent", "planet_base.doSpawnSetup: Tatooine Planet detected. Script Not Attached. Attaching event.planet_event_handler"); attachScript(tatooinePlanet, "event.planet_event_handler"); } - scheduled_drop.instantiatePromotionsOnCluster(); + if(scheduled_drop.isSystemEnabled()) { + scheduled_drop.instantiatePromotionsOnCluster(); + } } else { diff --git a/sku.0/sys.server/compiled/game/script/systems/buff_builder/buff_builder_response.java b/sku.0/sys.server/compiled/game/script/systems/buff_builder/buff_builder_response.java index 59c94f3d8..d6d9d241c 100755 --- a/sku.0/sys.server/compiled/game/script/systems/buff_builder/buff_builder_response.java +++ b/sku.0/sys.server/compiled/game/script/systems/buff_builder/buff_builder_response.java @@ -57,6 +57,9 @@ public class buff_builder_response extends script.base_script } public int OnBuffBuilderCompleted(obj_id self, obj_id bufferId, obj_id recipientId, int startingTime, int bufferRequiredCredits, int recipientPaidCredits, boolean accepted, String[] buffComponentKeys, int[] buffComponentValues) throws InterruptedException { + if(!isIdValid(bufferId) || !isIdValid(recipientId)) { + return SCRIPT_CONTINUE; + } if (bufferRequiredCredits > 0 && !money.pay(recipientId, bufferId, bufferRequiredCredits, "", null)) { sendSystemMessage(recipientId, new string_id("spam", "buildabuff_nsf_buffee")); @@ -86,7 +89,7 @@ public class buff_builder_response extends script.base_script { utils.removeScriptVar(recipientId, "performance.inspireMaxReached"); } - if (isIdValid(bufferId)) + if (scheduled_drop.isSystemEnabled()) { obj_id inv = utils.getInventoryContainer(bufferId); boolean canDrop = scheduled_drop.canDropCard(scheduled_drop.SYSTEM_ENTERTAINER); diff --git a/sku.0/sys.server/compiled/game/script/systems/crafting/base_tool.java b/sku.0/sys.server/compiled/game/script/systems/crafting/base_tool.java index c843e1cb9..681beca7f 100755 --- a/sku.0/sys.server/compiled/game/script/systems/crafting/base_tool.java +++ b/sku.0/sys.server/compiled/game/script/systems/crafting/base_tool.java @@ -398,45 +398,38 @@ public class base_tool extends script.base_script } obj_id relic = loot.chroniclesCraftingLootDrop(crafter); obj_id inv = utils.getInventoryContainer(crafter); - boolean canDrop = scheduled_drop.canDropCard(scheduled_drop.SYSTEM_CRAFTER); - boolean hasDelay = scheduled_drop.hasCardDelay(crafter, scheduled_drop.SYSTEM_CRAFTER); - if (isGod(crafter) && hasObjVar(crafter, "qa_tcg_always_drop")) - { - canDrop = true; - hasDelay = false; - } - if (isIdValid(inv) && canDrop && !hasDelay && isPlayerActive(crafter)) - { - obj_id card = scheduled_drop.dropCard(scheduled_drop.SYSTEM_CRAFTER, inv); - if (isIdValid(card)) - { - String[] cardNameList = split(getName(card), ':'); - if (cardNameList != null && cardNameList.length > 1) - { - string_id cardName = new string_id(cardNameList[0], cardNameList[1]); - String name = getString(cardName); - prose_package pp = new prose_package(); - pp = prose.setStringId(pp, new string_id("spam", "tcg_space_loot")); - pp = prose.setTU(pp, name); - sendSystemMessageProse(crafter, pp); - } - } - else - { - if (isGod(crafter) && hasObjVar(crafter, "qa_tcg")) - { - sendSystemMessageTestingOnly(crafter, "QA TCG CRAFTING NOT DROPPED. Card is null. Random chance passed? " + canDrop + " Has Card Delay? " + hasDelay); + + if(scheduled_drop.isSystemEnabled()) { + boolean canDrop = scheduled_drop.canDropCard(scheduled_drop.SYSTEM_CRAFTER); + boolean hasDelay = scheduled_drop.hasCardDelay(crafter, scheduled_drop.SYSTEM_CRAFTER); + if (isGod(crafter) && hasObjVar(crafter, "qa_tcg_always_drop")) { + canDrop = true; + hasDelay = false; + } + if (isIdValid(inv) && canDrop && !hasDelay && isPlayerActive(crafter)) { + obj_id card = scheduled_drop.dropCard(scheduled_drop.SYSTEM_CRAFTER, inv); + if (isIdValid(card)) { + String[] cardNameList = split(getName(card), ':'); + if (cardNameList != null && cardNameList.length > 1) { + string_id cardName = new string_id(cardNameList[0], cardNameList[1]); + String name = getString(cardName); + prose_package pp = new prose_package(); + pp = prose.setStringId(pp, new string_id("spam", "tcg_space_loot")); + pp = prose.setTU(pp, name); + sendSystemMessageProse(crafter, pp); + } + } else { + if (isGod(crafter) && hasObjVar(crafter, "qa_tcg")) { + sendSystemMessageTestingOnly(crafter, "QA TCG CRAFTING NOT DROPPED. Card is null. Random chance passed? " + canDrop + " Has Card Delay? " + hasDelay); + } + } + } else { + if (isGod(crafter) && hasObjVar(crafter, "qa_tcg")) { + sendSystemMessageTestingOnly(crafter, "QA TCG CRAFTING NOT DROPPED. Random chance passed? " + canDrop + " Has Card Delay? " + hasDelay); } } + utils.setScriptVar(crafter, scheduled_drop.PLAYER_SCRIPTVAR_DROP_TIME, getGameTime()); } - else - { - if (isGod(crafter) && hasObjVar(crafter, "qa_tcg")) - { - sendSystemMessageTestingOnly(crafter, "QA TCG CRAFTING NOT DROPPED. Random chance passed? " + canDrop + " Has Card Delay? " + hasDelay); - } - } - utils.setScriptVar(crafter, scheduled_drop.PLAYER_SCRIPTVAR_DROP_TIME, getGameTime()); return SCRIPT_CONTINUE; } public obj_id getFirstParentInWorldOrPlayer(obj_id obj) throws InterruptedException