diff --git a/sku.0/sys.server/compiled/game/script/base_class.java b/sku.0/sys.server/compiled/game/script/base_class.java index b1183dba5f..de63d0bedc 100755 --- a/sku.0/sys.server/compiled/game/script/base_class.java +++ b/sku.0/sys.server/compiled/game/script/base_class.java @@ -1870,19 +1870,16 @@ public static float[] getFloatArrayObjVar(obj_id object, String name) * @param name the objvar name to search for * @return the float array, or null if not found */ - public static Vector getResizeableFloatArrayObjVar(obj_id object, String name) - { + public static Vector getResizeableFloatArrayObjVar(obj_id object, String name) { float[] array = getFloatArrayObjVar(object, name); - if (array != null) - { - /* + if (array != null) { Float[] newArray = new Float[array.length]; - for ( int i = 0; i < array.length; ++i ) - newArray[i] = new Float(array[i]); + for (int i = 0; i < array.length; ++i) { + newArray[i] = Float.valueOf(array[i]); + } return new Vector(Arrays.asList(newArray)); - */ - return new Vector(Arrays.asList(array)); } + return null; } /** @@ -2609,6 +2606,8 @@ else if (data instanceof Float) return setObjVar(object, name, ((Float)data).floatValue()); else if (data instanceof float[]) return setObjVar(object, name, (float[])data); + else if (data instanceof Float[]) + return setObjVar(object, name, (Float[]) data); if (data instanceof Boolean) return setObjVar(object, name, ((Boolean)data).booleanValue()); else if (data instanceof boolean[]) @@ -26873,3 +26872,4 @@ public static boolean isInAdminTable(obj_id player) throws InterruptedException } } // class base_class + diff --git a/sku.0/sys.server/compiled/game/script/item/firework/show.java b/sku.0/sys.server/compiled/game/script/item/firework/show.java index 4325c514c1..41bbebe1c1 100755 --- a/sku.0/sys.server/compiled/game/script/item/firework/show.java +++ b/sku.0/sys.server/compiled/game/script/item/firework/show.java @@ -7,11 +7,8 @@ import java.util.Vector; -public class show extends script.base_script -{ - public show() - { - } +public class show extends script.base_script { + public static final string_id MNU_LAUNCH = new string_id(firework.STF, "mnu_launch"); public static final string_id MNU_SHOW_DATA = new string_id(firework.STF, "mnu_show_data"); public static final string_id MNU_ADD_EVENT = new string_id(firework.STF, "mnu_add_event"); @@ -19,111 +16,86 @@ public show() public static final string_id MNU_REMOVE_EVENT = new string_id(firework.STF, "mnu_remove_event"); public static final string_id MNU_REORDER_SHOW = new string_id(firework.STF, "mnu_reorder_show"); public static final string_id SID_NO_FIREWORKS_IN_SPACE = new string_id("space/space_interaction", "no_fireworks_in_space"); - public int OnInitialize(obj_id self) throws InterruptedException - { + + public int OnInitialize(obj_id self) throws InterruptedException { int eventCount = getCount(self); Vector show_fx = getResizeableStringArrayObjVar(self, firework.VAR_SHOW_FX); - if(show_fx == null || (eventCount > 0 && show_fx.size() != eventCount)) - { + if (show_fx == null || (eventCount > 0 && show_fx.size() != eventCount)) { setCount(self, 0); removeObjVar(self, firework.VAR_SHOW_FX); return SCRIPT_CONTINUE; } Vector show_delay = getResizeableFloatArrayObjVar(self, firework.VAR_SHOW_DELAY); - if (show_delay == null || show_delay.size() == 0) - { + if (show_delay == null || show_delay.size() == 0) { return SCRIPT_CONTINUE; } - if (show_fx.size() != show_delay.size()) - { + if (show_fx.size() != show_delay.size()) { setCount(self, 0); removeObjVar(self, firework.VAR_SHOW_FX); return SCRIPT_CONTINUE; } - for (int i = 0; i < show_delay.size(); i++) - { - if ((Float) show_delay.get(i) < firework.SHOW_DELAY_MIN) - { + for (int i = 0; i < show_delay.size(); i++) { + if ((Float) show_delay.get(i) < firework.SHOW_DELAY_MIN) { show_delay.set(i, firework.SHOW_DELAY_MIN); } } setObjVar(self, firework.VAR_SHOW_DELAY, show_delay); return SCRIPT_CONTINUE; } - public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info mi) throws InterruptedException - { + + public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info mi) throws InterruptedException { obj_id inv = utils.getInventoryContainer(player); - if (isIdValid(inv) && utils.isNestedWithin(self, inv)) - { + if (isIdValid(inv) && utils.isNestedWithin(self, inv)) { int eventCount = getCount(self); - if (eventCount > 0) - { + if (eventCount > 0) { int mnuLaunch = mi.addRootMenu(menu_info_types.ITEM_USE, MNU_LAUNCH); } int mnuShowData = -1; - if (!hasScript(self, "item.firework.premade_show")) - { + if (!hasScript(self, "item.firework.premade_show")) { mnuShowData = mi.addRootMenu(menu_info_types.SERVER_MENU2, MNU_SHOW_DATA); } - if (eventCount > 0 && mnuShowData > -1 && !hasScript(self, "item.firework.premade_show") || isGod(player)) - { + if (eventCount > 0 && mnuShowData > -1 && !hasScript(self, "item.firework.premade_show") || isGod(player)) { int mnuRemove = mi.addSubMenu(mnuShowData, menu_info_types.SERVER_MENU3, MNU_REMOVE_EVENT); int mnuModify = mi.addSubMenu(mnuShowData, menu_info_types.SERVER_MENU4, MNU_MODIFY_EVENT); int mnuReorder = mi.addSubMenu(mnuShowData, menu_info_types.SERVER_MENU6, MNU_REORDER_SHOW); } - if (eventCount < firework.SHOW_EVENT_MAX && !hasScript(self, "item.firework.premade_show")) - { + if (eventCount < firework.SHOW_EVENT_MAX && !hasScript(self, "item.firework.premade_show")) { int mnuAdd = mi.addSubMenu(mnuShowData, menu_info_types.SERVER_MENU5, MNU_ADD_EVENT); } } return SCRIPT_CONTINUE; } - public int OnObjectMenuSelect(obj_id self, obj_id player, int item) throws InterruptedException - { - if (isSpaceScene()) - { + + public int OnObjectMenuSelect(obj_id self, obj_id player, int item) throws InterruptedException { + if (isSpaceScene()) { sendSystemMessage(player, SID_NO_FIREWORKS_IN_SPACE); return SCRIPT_CONTINUE; } - if (item == menu_info_types.SERVER_MENU1 || item == menu_info_types.ITEM_USE) - { + if (item == menu_info_types.SERVER_MENU1 || item == menu_info_types.ITEM_USE) { obj_id inv = utils.getInventoryContainer(player); - if (isIdValid(inv) && utils.isNestedWithin(self, inv)) - { + if (isIdValid(inv) && utils.isNestedWithin(self, inv)) { queueCommand(player, (-309362530), self, "show", COMMAND_PRIORITY_DEFAULT); return SCRIPT_CONTINUE; } - } - else if (item == menu_info_types.SERVER_MENU2 && !hasScript(self, "item.firework.premade_show")) - { + } else if (item == menu_info_types.SERVER_MENU2 && !hasScript(self, "item.firework.premade_show")) { firework.showEventDataSUI(player, self); - } - else if (item == menu_info_types.SERVER_MENU3 && !hasScript(self, "item.firework.premade_show")) - { + } else if (item == menu_info_types.SERVER_MENU3 && !hasScript(self, "item.firework.premade_show")) { firework.showRemoveEventSUI(player, self); - } - else if (item == menu_info_types.SERVER_MENU4 && !hasScript(self, "item.firework.premade_show")) - { + } else if (item == menu_info_types.SERVER_MENU4 && !hasScript(self, "item.firework.premade_show")) { firework.showModifyEventIndexSUI(player, self); - } - else if (item == menu_info_types.SERVER_MENU5 && !hasScript(self, "item.firework.premade_show")) - { - if (utils.hasScriptVar(self, "addEvent.pid")) - { + } else if (item == menu_info_types.SERVER_MENU5 && !hasScript(self, "item.firework.premade_show")) { + if (utils.hasScriptVar(self, "addEvent.pid")) { int oldpid = utils.getIntScriptVar(self, "addEvent.pid"); obj_id oldplayer = utils.getObjIdScriptVar(self, "addEvent.player"); - if (isIdValid(oldplayer)) - { + if (isIdValid(oldplayer)) { sui.closeSUI(oldplayer, oldpid); } utils.removeScriptVarTree(self, "addEvent"); } obj_id inv = utils.getInventoryContainer(player); - if (isIdValid(inv)) - { + if (isIdValid(inv)) { obj_id[] tmpFireworks = utils.getContainedGOTObjects(inv, GOT_misc_firework, true, false); - if (tmpFireworks != null) - { + if (tmpFireworks != null && tmpFireworks.length > 0) { Vector fireworks = new Vector(); fireworks.setSize(0); Vector entries = new Vector(); @@ -134,151 +106,130 @@ else if (item == menu_info_types.SERVER_MENU5 && !hasScript(self, "item.firework entries = utils.addElement(entries, utils.getStringName(tmpFirework) + " (" + getCount(tmpFirework) + ")"); } } - if (entries != null && fireworks != null && entries.size() == fireworks.size()) - { + if (entries != null && fireworks != null && entries.size() == fireworks.size()) { String title = "Select Show Addition"; String prompt = "Select the firework to append to the end of the show package."; int pid = sui.listbox(self, player, prompt, sui.OK_CANCEL, title, entries, "handleAddEventSui"); - if (pid > -1) - { + if (pid > -1) { utils.setScriptVar(self, "addEvent.pid", pid); utils.setScriptVar(self, "addEvent.player", player); utils.setBatchScriptVar(self, "addEvent.fireworks", fireworks); return SCRIPT_CONTINUE; } } + } else { + sendSystemMessage(player, firework.SID_NO_SHOWS_TO_ADD); + return SCRIPT_CONTINUE; } } - } - else if (item == menu_info_types.SERVER_MENU6) - { + } else if (item == menu_info_types.SERVER_MENU6) { firework.showReorderEventsSUI(player, self); } return SCRIPT_CONTINUE; } - public int handleAddEventSui(obj_id self, dictionary params) throws InterruptedException - { + + public int handleAddEventSui(obj_id self, dictionary params) throws InterruptedException { obj_id[] fireworks = utils.getObjIdBatchScriptVar(self, "addEvent.fireworks"); utils.removeScriptVarTree(self, "addEvent"); - if (params == null || params.isEmpty()) - { + if (params == null || params.isEmpty()) { return SCRIPT_CONTINUE; } int bp = sui.getIntButtonPressed(params); - if (bp == sui.BP_CANCEL) - { + if (bp == sui.BP_CANCEL) { return SCRIPT_CONTINUE; } obj_id player = sui.getPlayerId(params); - if (!isIdValid(player)) - { + if (!isIdValid(player)) { return SCRIPT_CONTINUE; } int idx = sui.getListboxSelectedRow(params); - if (idx == -1) - { + if (idx == -1) { return SCRIPT_CONTINUE; } - if (fireworks == null || fireworks.length == 0) - { + if (fireworks == null || fireworks.length == 0) { return SCRIPT_CONTINUE; } firework.addShowEvent(player, self, fireworks[idx]); return SCRIPT_CONTINUE; } - public int handleEventDataSUI(obj_id self, dictionary params) throws InterruptedException - { + + public int handleEventDataSUI(obj_id self, dictionary params) throws InterruptedException { firework.removeSUIScriptVars(self); return SCRIPT_CONTINUE; } - public int handleRemoveEventSUI(obj_id self, dictionary params) throws InterruptedException - { + + public int handleRemoveEventSUI(obj_id self, dictionary params) throws InterruptedException { firework.removeSUIScriptVars(self); int bp = sui.getIntButtonPressed(params); - if (bp == sui.BP_CANCEL) - { + if (bp == sui.BP_CANCEL) { return SCRIPT_CONTINUE; } int idx = sui.getListboxSelectedRow(params); - if (idx < 0) - { + if (idx < 0) { return SCRIPT_CONTINUE; } obj_id player = sui.getPlayerId(params); - if (!isIdValid(player)) - { + if (!isIdValid(player)) { return SCRIPT_CONTINUE; } firework.removeShowEvent(player, self, idx); firework.showRemoveEventSUI(player, self); return SCRIPT_CONTINUE; } - public int handleReorderEventsSUI(obj_id self, dictionary params) throws InterruptedException - { + + public int handleReorderEventsSUI(obj_id self, dictionary params) throws InterruptedException { firework.removeSUIScriptVars(self); int bp = sui.getIntButtonPressed(params); - if (bp == sui.BP_CANCEL) - { + if (bp == sui.BP_CANCEL) { return SCRIPT_CONTINUE; } int idx = sui.getListboxSelectedRow(params); - if (idx < 0) - { + if (idx < 0) { return SCRIPT_CONTINUE; } obj_id player = sui.getPlayerId(params); - if (!isIdValid(player)) - { + if (!isIdValid(player)) { return SCRIPT_CONTINUE; } - if (bp == sui.BP_OK) - { + if (bp == sui.BP_OK) { firework.swapEvents(player, self, idx, idx - 1); - } - else if (bp == sui.BP_REVERT) - { + } else if (bp == sui.BP_REVERT) { firework.swapEvents(player, self, idx, idx + 1); } firework.showReorderEventsSUI(player, self); return SCRIPT_CONTINUE; } - public int handleModifyEventIndexSUI(obj_id self, dictionary params) throws InterruptedException - { + + public int handleModifyEventIndexSUI(obj_id self, dictionary params) throws InterruptedException { firework.removeSUIScriptVars(self); int bp = sui.getIntButtonPressed(params); - if (bp == sui.BP_CANCEL) - { + if (bp == sui.BP_CANCEL) { return SCRIPT_CONTINUE; } int idx = sui.getListboxSelectedRow(params); - if (idx < 0) - { + if (idx < 0) { return SCRIPT_CONTINUE; } obj_id player = sui.getPlayerId(params); - if (!isIdValid(player)) - { + if (!isIdValid(player)) { return SCRIPT_CONTINUE; } firework.showModifyEventTimeSUI(player, self, idx); return SCRIPT_CONTINUE; } - public int handleModifyEventTimeSUI(obj_id self, dictionary params) throws InterruptedException - { - if (!utils.hasScriptVar(self, "firework.idx")) - { + + public int handleModifyEventTimeSUI(obj_id self, dictionary params) throws InterruptedException { + if (!utils.hasScriptVar(self, "firework.idx")) { return SCRIPT_CONTINUE; } int idx = utils.getIntScriptVar(self, "firework.idx"); firework.removeSUIScriptVars(self); int bp = sui.getIntButtonPressed(params); - if (bp == sui.BP_CANCEL) - { + if (bp == sui.BP_CANCEL) { return SCRIPT_CONTINUE; } obj_id player = sui.getPlayerId(params); - if (!isIdValid(player)) - { + if (!isIdValid(player)) { return SCRIPT_CONTINUE; } float delay = sui.getTransferInputTo(params) / 10.0f; @@ -286,21 +237,18 @@ public int handleModifyEventTimeSUI(obj_id self, dictionary params) throws Inter firework.showModifyEventIndexSUI(player, self); return SCRIPT_CONTINUE; } - public void addDebugRandomEvent(obj_id show) throws InterruptedException - { + + public void addDebugRandomEvent(obj_id show) throws InterruptedException { String[] fxs = dataTableGetStringColumn(firework.TBL_FX, "name"); - if (fxs != null && fxs.length > 0) - { + if (fxs != null && fxs.length > 0) { Vector show_fx = getResizeableStringArrayObjVar(show, firework.VAR_SHOW_FX); Vector show_delay = getResizeableFloatArrayObjVar(show, firework.VAR_SHOW_DELAY); show_fx = utils.addElement(show_fx, fxs[rand(0, fxs.length - 1)]); - show_delay = utils.addElement(show_delay, 0.1f); - if (show_fx == null || show_fx.size() == 0 || show_delay == null || show_delay.size() == 0) - { + show_delay = utils.addElement(show_delay, (Float) 0.1f); + if (show_fx == null || show_fx.size() == 0 || show_delay == null || show_delay.size() == 0) { return; } - if (show_fx.size() != show_delay.size()) - { + if (show_fx.size() != show_delay.size()) { return; } setCount(show, show_fx.size()); @@ -309,3 +257,5 @@ public void addDebugRandomEvent(obj_id show) throws InterruptedException } } } + + diff --git a/sku.0/sys.server/compiled/game/script/library/firework.java b/sku.0/sys.server/compiled/game/script/library/firework.java index b4eb16c5e8..8405ef044c 100755 --- a/sku.0/sys.server/compiled/game/script/library/firework.java +++ b/sku.0/sys.server/compiled/game/script/library/firework.java @@ -4,14 +4,11 @@ import java.util.Vector; -public class firework extends script.base_script -{ - public firework() - { - } +public class firework extends script.base_script { + public static final int SHOW_EVENT_MAX = 20; - public static final float SHOW_DELAY_MIN = 1.0f; - public static final float SHOW_DELAY_MAX = 10.0f; + public static final Float SHOW_DELAY_MIN = 1.0f; + public static final Float SHOW_DELAY_MAX = 10.0f; public static final String SCRIPT_PLAYER = "item.firework.player"; public static final String SCRIPT_FIREWORK_CLEANUP = "item.firework.cleanup"; public static final String SCRIPT_LAUNCHER = "item.firework.launcher"; @@ -23,9 +20,7 @@ public firework() public static final String SCRIPTVAR_COUNT = VAR_FIREWORK_BASE + ".cnt"; public static final String TBL_FX = "datatables/firework/fx.iff"; public static final String HANDLER_FIREWORK_PREPARE = "handleFireworkPrepare"; - public static final String HANDLER_FIREWORK_IGNITE = "handleFireworkIgnite"; public static final String HANDLER_FIREWORK_LAUNCH = "handleFireworkLaunch"; - public static final String HANDLER_FIREWORK_EXPLOSION = "handleFireworkExplosion"; public static final String HANDLER_FIREWORK_CLEANUP = "handleFireworkCleanup"; public static final String STF = "firework"; public static final String TEMPLATE_SHOW_LAUNCHER = "object/static/firework/show_launcher.iff"; @@ -33,21 +28,19 @@ public firework() public static final string_id SID_NO_SHOWS_TO_REMOVE = new string_id(STF, "no_shows_to_remove"); public static final string_id SID_NO_SHOWS_TO_MODIFY = new string_id(STF, "no_shows_to_modify"); public static final string_id SID_NO_SHOWS_TO_DISPLAY = new string_id(STF, "no_shows_to_display"); + public static final string_id SID_NO_SHOWS_TO_ADD = new string_id(STF, "no_shows_to_add"); public static final string_id SID_NO_NEED_TO_REORDER = new string_id(STF, "no_need_to_reorder"); public static final string_id SID_DUD_FIREWORK = new string_id(STF, "dud_firework"); - public static boolean launch(obj_id target, obj_id firework) throws InterruptedException - { - if (!isIdValid(target) || !isIdValid(firework)) - { + + public static boolean launch(obj_id target, obj_id firework) throws InterruptedException { + if (!isIdValid(target) || !isIdValid(firework)) { return false; } - if (!hasObjVar(firework, VAR_FIREWORK_BASE)) - { + if (!hasObjVar(firework, VAR_FIREWORK_BASE)) { makeRandomEffect(firework); } String fx = getStringObjVar(firework, VAR_FIREWORK_FX); - if (fx == null || fx.equals("")) - { + if (fx == null || fx.isEmpty()) { fx = getRandomFireworkEffect(); } dictionary params = new dictionary(); @@ -56,37 +49,31 @@ public static boolean launch(obj_id target, obj_id firework) throws InterruptedE int cnt = utils.getIntScriptVar(target, SCRIPTVAR_COUNT); cnt++; utils.setScriptVar(target, SCRIPTVAR_COUNT, cnt); - if (!hasScript(target, SCRIPT_PLAYER)) - { + if (!hasScript(target, SCRIPT_PLAYER)) { attachScript(target, SCRIPT_PLAYER); } messageTo(target, HANDLER_FIREWORK_PREPARE, params, 0, false); return true; } - public static void launchShow(obj_id target, obj_id show) throws InterruptedException - { - if (!isIdValid(target) || !isIdValid(show)) - { + + public static void launchShow(obj_id target, obj_id show) throws InterruptedException { + if (!isIdValid(target) || !isIdValid(show)) { return; } Vector show_fx = getResizeableStringArrayObjVar(show, VAR_SHOW_FX); Vector show_delay = getResizeableFloatArrayObjVar(show, VAR_SHOW_DELAY); - if (show_fx == null || show_fx.size() == 0 || show_delay == null || show_delay.size() == 0) - { + if (show_fx == null || show_fx.size() == 0 || show_delay == null || show_delay.size() == 0) { return; } - if (show_fx.size() != show_delay.size()) - { + if (show_fx.size() != show_delay.size()) { return; } location there = utils.findLocInFrontOfTarget(target, 0.75f); - if (there == null) - { + if (there == null) { there = getLocation(target); } obj_id launcher = createObject(TEMPLATE_SHOW_LAUNCHER, there); - if (isIdValid(launcher)) - { + if (isIdValid(launcher)) { attachScript(launcher, SCRIPT_LAUNCHER); dictionary d = new dictionary(); d.put("fx", show_fx); @@ -97,14 +84,12 @@ public static void launchShow(obj_id target, obj_id show) throws InterruptedExce destroyObject(show); } } - public static boolean addShowEvent(obj_id target, obj_id show, obj_id firework) throws InterruptedException - { - if (!isIdValid(target) || !isIdValid(show) || !isIdValid(firework)) - { + + public static boolean addShowEvent(obj_id target, obj_id show, obj_id firework) throws InterruptedException { + if (!isIdValid(target) || !isIdValid(show) || !isIdValid(firework)) { return false; } - if (getCount(show) >= SHOW_EVENT_MAX) - { + if (getCount(show) >= SHOW_EVENT_MAX) { sendSystemMessage(target, SID_YOU_CANNOT_ADD); return false; } @@ -116,372 +101,332 @@ public static boolean addShowEvent(obj_id target, obj_id show, obj_id firework) boolean litmus = true; litmus &= setObjVar(show, VAR_SHOW_FX, show_fx); litmus &= setObjVar(show, VAR_SHOW_DELAY, show_delay); - if (litmus) - { + if (litmus) { useCharge(firework); incrementCount(show, 1); } return litmus; } - public static void removeShowEvent(obj_id target, obj_id show, int idx) throws InterruptedException - { - if (!isIdValid(target) || !isIdValid(show) || idx < 0) - { + + public static void removeShowEvent(obj_id target, obj_id show, int idx) throws InterruptedException { + if (!isIdValid(target) || !isIdValid(show) || idx < 0) { return; } - if (getCount(show) == 0) - { + if (getCount(show) == 0) { sendSystemMessage(target, SID_NO_SHOWS_TO_REMOVE); return; } Vector show_fx = getResizeableStringArrayObjVar(show, VAR_SHOW_FX); Vector show_delay = getResizeableFloatArrayObjVar(show, VAR_SHOW_DELAY); - if (show_fx == null || show_fx.size() == 0 || show_delay == null || show_delay.size() == 0) - { + if (show_fx == null || show_fx.size() == 0 || show_delay == null || show_delay.size() == 0) { return; } - if (show_fx.size() != show_delay.size()) - { + if (show_fx.size() != show_delay.size()) { return; } - if (idx >= show_fx.size()) - { + if (idx >= show_fx.size()) { return; } show_fx = utils.removeElementAt(show_fx, idx); show_delay = utils.removeElementAt(show_delay, idx); - if (show_fx.size() != show_delay.size()) - { + if (show_fx.size() != show_delay.size()) { return; } - setObjVar(show, VAR_SHOW_FX, show_fx); - setObjVar(show, VAR_SHOW_DELAY, show_delay); + if (show_fx.size() == 0) { + removeObjVar(show, VAR_SHOW_FX); + removeObjVar(show, VAR_SHOW_DELAY); + } else { + setObjVar(show, VAR_SHOW_FX, show_fx); + setObjVar(show, VAR_SHOW_DELAY, show_delay); + } incrementCount(show, -1); } - public static void setShowEventDelay(obj_id target, obj_id show, int idx, float delay) throws InterruptedException - { - if (!isIdValid(target) || !isIdValid(show) || idx < 0) - { + + public static void setShowEventDelay(obj_id target, obj_id show, int idx, float delay) throws InterruptedException { + if (!isIdValid(target) || !isIdValid(show) || idx < 0) { return; } - if (getCount(show) == 0) - { + if (getCount(show) == 0) { sendSystemMessage(target, SID_NO_SHOWS_TO_MODIFY); return; } Vector show_delay = getResizeableFloatArrayObjVar(show, VAR_SHOW_DELAY); - if (show_delay == null || show_delay.size() == 0) - { + if (show_delay == null || show_delay.size() == 0) { return; } - if (idx >= show_delay.size()) - { + if (idx >= show_delay.size()) { return; } - if (delay < 0.1f) - { + if (delay < 0.1f) { delay = 0.1f; } - if (delay > SHOW_DELAY_MAX) - { + if (delay > SHOW_DELAY_MAX) { delay = SHOW_DELAY_MAX; } - show_delay.set(idx, delay); + show_delay.set(idx, Float.valueOf(delay)); setObjVar(show, VAR_SHOW_DELAY, show_delay); } - public static void showEventDataSUI(obj_id player, obj_id show) throws InterruptedException - { - if (!isIdValid(player) || !isIdValid(show)) - { + + public static void showEventDataSUI(obj_id player, obj_id show) throws InterruptedException { + if (!isIdValid(player) || !isIdValid(show)) { return; } - if (getCount(show) == 0) - { + if (getCount(show) == 0) { sendSystemMessage(player, SID_NO_SHOWS_TO_DISPLAY); return; } cleanupSUIScriptVars(show); Vector entries = getShowListEntries(show); - if (entries == null || entries.size() == 0) - { + if (entries == null || entries.size() == 0) { sendSystemMessage(player, SID_NO_SHOWS_TO_DISPLAY); return; } String title = "@firework:data_title"; String prompt = "@firework:data_prompt"; int pid = sui.listbox(show, player, prompt, sui.OK_ONLY, title, entries, "handleEventDataSUI"); - if (pid > -1) - { + if (pid > -1) { setSUIScriptVars(show, pid, player); } } - public static void showRemoveEventSUI(obj_id player, obj_id show) throws InterruptedException - { - if (!isIdValid(player) || !isIdValid(show)) - { + + public static void showRemoveEventSUI(obj_id player, obj_id show) throws InterruptedException { + if (!isIdValid(player) || !isIdValid(show)) { return; } - if (getCount(show) == 0) - { + if (getCount(show) == 0) { sendSystemMessage(player, SID_NO_SHOWS_TO_REMOVE); return; } cleanupSUIScriptVars(show); Vector entries = getShowListEntries(show); - if (entries == null || entries.size() == 0) - { + if (entries == null || entries.size() == 0) { sendSystemMessage(player, SID_NO_SHOWS_TO_DISPLAY); return; } String title = "@firework:remove_title"; String prompt = "@firework:remove_prompt"; int pid = sui.listbox(show, player, prompt, sui.OK_CANCEL, title, entries, "handleRemoveEventSUI"); - if (pid > -1) - { + if (pid > -1) { setSUIScriptVars(show, pid, player); } } - public static void showReorderEventsSUI(obj_id player, obj_id show) throws InterruptedException - { - if (!isIdValid(player) || !isIdValid(show)) - { + + public static void showReorderEventsSUI(obj_id player, obj_id show) throws InterruptedException { + if (!isIdValid(player) || !isIdValid(show)) { return; } - if (getCount(show) == 0) - { + if (getCount(show) == 0) { sendSystemMessage(player, SID_NO_NEED_TO_REORDER); return; } cleanupSUIScriptVars(show); Vector entries = getShowListEntries(show); - if (entries == null || entries.size() < 0) - { + if (entries == null || entries.size() < 0) { sendSystemMessage(player, SID_NO_NEED_TO_REORDER); return; } String title = "@firework:reorder_title"; String prompt = "@firework:reorder_prompt"; int pid = sui.listbox(show, player, prompt, sui.MOVEUP_MOVEDOWN_DONE, title, entries, "handleReorderEventsSUI"); - if (pid > -1) - { + if (pid > -1) { setSUIScriptVars(show, pid, player); } } - public static void showModifyEventIndexSUI(obj_id player, obj_id show) throws InterruptedException - { - if (!isIdValid(player) || !isIdValid(show)) - { + + public static void showModifyEventIndexSUI(obj_id player, obj_id show) throws InterruptedException { + if (!isIdValid(player) || !isIdValid(show)) { return; } - if (getCount(show) == 0) - { + if (getCount(show) == 0) { sendSystemMessage(player, SID_NO_SHOWS_TO_MODIFY); return; } cleanupSUIScriptVars(show); Vector entries = getShowListEntries(show); - if (entries == null || entries.size() == 0) - { + if (entries == null || entries.size() == 0) { sendSystemMessage(player, SID_NO_SHOWS_TO_MODIFY); return; } String title = "@firework:modify_index_title"; String prompt = "@firework:modify_index_prompt"; int pid = sui.listbox(show, player, prompt, sui.OK_CANCEL, title, entries, "handleModifyEventIndexSUI"); - if (pid > -1) - { + if (pid > -1) { setSUIScriptVars(show, pid, player); } } - public static void showModifyEventTimeSUI(obj_id player, obj_id show, int idx) throws InterruptedException - { - if (!isIdValid(player) || !isIdValid(show) || idx < 0) - { + + public static void showModifyEventTimeSUI(obj_id player, obj_id show, int idx) throws InterruptedException { + if (!isIdValid(player) || !isIdValid(show) || idx < 0) { return; } - if (getCount(show) == 0) - { + if (getCount(show) == 0) { sendSystemMessage(player, SID_NO_SHOWS_TO_MODIFY); return; } cleanupSUIScriptVars(show); Vector delays = getResizeableFloatArrayObjVar(show, VAR_SHOW_DELAY); - if (delays == null || delays.size() == 0 || idx >= delays.size()) - { + if (delays == null || delays.size() == 0 || idx >= delays.size()) { return; } - int current = (int)((Float) delays.get(idx) * 10); - int available = (int)(SHOW_DELAY_MAX * 10) - current; + int current = (int) ((Float) delays.get(idx) * 10); + int available = (int) (SHOW_DELAY_MAX * 10) - current; String title = "@firework:modify_delay_title"; String prompt = "@firework:modify_delay_prompt"; int pid = sui.transfer(show, player, prompt, title, "Available", available, "Delay", current, "handleModifyEventTimeSUI"); - if (pid > -1) - { + if (pid > -1) { setSUIScriptVars(show, pid, player, idx); } } - public static void setSUIScriptVars(obj_id show, int pid, obj_id player) throws InterruptedException - { + + public static void setSUIScriptVars(obj_id show, int pid, obj_id player) throws InterruptedException { utils.setScriptVar(show, "firework.pid", pid); utils.setScriptVar(show, "firework.player", player); } - public static void setSUIScriptVars(obj_id show, int pid, obj_id player, int idx) throws InterruptedException - { + + public static void setSUIScriptVars(obj_id show, int pid, obj_id player, int idx) throws InterruptedException { utils.setScriptVar(show, "firework.pid", pid); utils.setScriptVar(show, "firework.player", player); utils.setScriptVar(show, "firework.idx", idx); } - public static void removeSUIScriptVars(obj_id show) throws InterruptedException - { + + public static void removeSUIScriptVars(obj_id show) throws InterruptedException { utils.removeScriptVar(show, "firework.pid"); utils.removeScriptVar(show, "firework.player"); utils.removeScriptVar(show, "firework.idx"); } - public static void cleanupSUIScriptVars(obj_id show) throws InterruptedException - { - if (utils.hasScriptVar(show, "firework.pid")) - { + + public static void cleanupSUIScriptVars(obj_id show) throws InterruptedException { + if (utils.hasScriptVar(show, "firework.pid")) { int oldpid = utils.getIntScriptVar(show, "firework.pid"); obj_id player = utils.getObjIdScriptVar(show, "firework.player"); - if (isIdValid(player)) - { + if (isIdValid(player)) { sui.closeSUI(player, oldpid); } removeSUIScriptVars(show); } } - public static Vector getShowListEntries(obj_id show) throws InterruptedException - { + + public static Vector getShowListEntries(obj_id show) throws InterruptedException { Vector show_fx = getResizeableStringArrayObjVar(show, VAR_SHOW_FX); Vector show_delay = getResizeableFloatArrayObjVar(show, VAR_SHOW_DELAY); - if (show_fx == null || show_fx.size() == 0 || show_delay == null || show_delay.size() == 0) - { + if (show_fx == null || show_fx.size() == 0 || show_delay == null || show_delay.size() == 0) { + LOG("firework", "ERROR - getShowListEntries: not valid show_fx or show_delay objVars for show [" + show + "]"); return null; } - if (show_fx.size() != show_delay.size()) - { + if (show_fx.size() != show_delay.size()) { + LOG("firework", "ERROR - getShowListEntries: show_fx.size() [" + show_fx.size() + "] != show_delay.size() [" + show_delay.size() + "]"); return null; } - float time = 0; + Float time = 0f; Vector entries = new Vector(); entries.setSize(0); - for (int i = 0; i < show_fx.size(); i++) - { + for (int i = 0; i < show_fx.size(); i++) { time += (Float) show_delay.get(i); String sTime = utils.formatTime(time); - entries = utils.addElement(entries, "(" + sTime + "s) " + getString(new string_id("firework_n", ((String)show_fx.get(i))))); + entries = utils.addElement(entries, "(" + sTime + "s) " + getString(new string_id("firework_n", ((String) show_fx.get(i))))); } - if (entries == null || entries.size() == 0) - { + if (entries == null || entries.size() == 0) { + LOG("firework", "ERROR - getShowListEntries: no entries found"); return null; } return entries; } - public static void swapEvents(obj_id player, obj_id show, int idx1, int idx2) throws InterruptedException - { - if (!isIdValid(player) || !isIdValid(show)) - { + + public static void swapEvents(obj_id player, obj_id show, int idx1, int idx2) throws InterruptedException { + if (!isIdValid(player) || !isIdValid(show)) { return; } - if (idx1 < 0 || idx2 < 0) - { + if (idx1 < 0 || idx2 < 0) { sendSystemMessage(player, new string_id(STF, "cannot_reorder")); return; } Vector show_fx = getResizeableStringArrayObjVar(show, VAR_SHOW_FX); Vector show_delay = getResizeableFloatArrayObjVar(show, VAR_SHOW_DELAY); - if (show_fx == null || show_fx.size() == 0 || show_delay == null || show_delay.size() == 0) - { + if (show_fx == null || show_fx.size() == 0 || show_delay == null || show_delay.size() == 0) { + return; + } + if (show_fx.size() != show_delay.size()) { return; } - if (show_fx.size() != show_delay.size()) - { + if (idx2 >= show_fx.size()) { + sendSystemMessage(player, new string_id(STF, "cannot_reorder")); return; } - String tmpFx = ((String)show_fx.get(idx1)); - float tmpDelay = (Float) show_delay.get(idx1); - show_fx.set(idx1, ((String)show_fx.get(idx2))); + String tmpFx = ((String) show_fx.get(idx1)); + Float tmpDelay = (Float) show_delay.get(idx1); + show_fx.set(idx1, ((String) show_fx.get(idx2))); show_delay.set(idx1, (Float) show_delay.get(idx2)); show_fx.set(idx2, tmpFx); show_delay.set(idx2, tmpDelay); setObjVar(show, VAR_SHOW_FX, show_fx); setObjVar(show, VAR_SHOW_DELAY, show_delay); } - public static void setEventDelay(obj_id player, obj_id show, int idx, float delay) throws InterruptedException - { - if (!isIdValid(player) || !isIdValid(show)) - { + + public static void setEventDelay(obj_id player, obj_id show, int idx, float delay) throws InterruptedException { + if (!isIdValid(player) || !isIdValid(show)) { return; } - if (delay < 0.1f) - { + if (delay < 0.1f) { delay = 0.1f; } - if (delay > SHOW_DELAY_MAX) - { + if (delay > SHOW_DELAY_MAX) { delay = SHOW_DELAY_MAX; } Vector delays = getResizeableFloatArrayObjVar(show, VAR_SHOW_DELAY); - if (delays == null || delays.size() == 0 || idx >= delays.size()) - { + if (delays == null || delays.size() == 0 || idx >= delays.size()) { return; } - delays.set(idx, delay); - if (setObjVar(show, VAR_SHOW_DELAY, delays)) - { + delays.set(idx, Float.valueOf(delay)); + if (setObjVar(show, VAR_SHOW_DELAY, delays)) { prose_package ppDelayUpdated = prose.getPackage(new string_id(STF, "prose_delay_update"), idx + 1, delay); sendSystemMessageProse(player, ppDelayUpdated); } } - public static void setEffect(obj_id firework, String fx, color pColor) throws InterruptedException - { - if (!isIdValid(firework) || fx == null || fx.equals("") || pColor == null) - { + + public static void setEffect(obj_id firework, String fx, color pColor) throws InterruptedException { + if (!isIdValid(firework) || fx == null || fx.equals("") || pColor == null) { return; } setObjVar(firework, VAR_FIREWORK_FX, fx); } - public static void makeRandomEffect(obj_id firework) throws InterruptedException - { - if (!isIdValid(firework)) - { + + public static void makeRandomEffect(obj_id firework) throws InterruptedException { + if (!isIdValid(firework)) { return; } String fx = getRandomFireworkEffect(); setObjVar(firework, VAR_FIREWORK_FX, fx); } - public static String getRandomFireworkEffect() throws InterruptedException - { + + public static String getRandomFireworkEffect() throws InterruptedException { String[] names = dataTableGetStringColumn(TBL_FX, "name"); - if (names == null || names.length == 0) - { + if (names == null || names.length == 0) { return null; } int idx = rand(0, names.length - 1); return names[idx]; } - public static void dud(obj_id target) throws InterruptedException - { + + public static void dud(obj_id target) throws InterruptedException { sendSystemMessage(target, SID_DUD_FIREWORK); decrementFireworkCount(target); } - public static void decrementFireworkCount(obj_id target) throws InterruptedException - { + + public static void decrementFireworkCount(obj_id target) throws InterruptedException { int cnt = utils.getIntScriptVar(target, firework.SCRIPTVAR_COUNT); cnt--; - if (cnt < 1) - { + if (cnt < 1) { utils.removeScriptVar(target, firework.SCRIPTVAR_COUNT); detachScript(target, firework.SCRIPT_PLAYER); } } - public static void useCharge(obj_id firework) throws InterruptedException - { + + public static void useCharge(obj_id firework) throws InterruptedException { incrementCount(firework, -1); int cnt = getCount(firework); - if (cnt < 1) - { + if (cnt < 1) { destroyObject(firework); } } } +