package script.event; import script.dictionary; import script.library.events; import script.library.holiday; import script.library.utils; import script.obj_id; public class holiday_controller extends script.base_script { public holiday_controller() { } private static final boolean GALACTIC_MOON_FESTIVAL_ENABLED = events.isEventActive(events.GALACTIC_MOON_FESTIVAL); private static final boolean LIFEDAY_ENABLED = events.isEventActive(events.LIFEDAY); private static final boolean EWOK_FESTIVAL_OF_LOVE_ENABLED = events.isEventActive(events.EWOK_FESTIVAL_OF_LOVE); private static final boolean EMPIRE_DAY_ENABLED = events.isEventActive(events.EMPIRE_DAY); public int OnInitialize(obj_id self) throws InterruptedException { CustomerServiceLog("holidayEvent", "holiday_controller.OnInitialize planet initialized, holiday controller called."); messageTo(self, "halloweenServerStart", null, 600.0f, false); messageTo(self, "lifedayServerStart", null, 610.0f, false); messageTo(self, "lovedayServerStart", null, 615.0f, false); messageTo(self, "empiredayServerStart", null, holiday.EMPIRE_DAY_EVENT_START_DELAY, false); return SCRIPT_CONTINUE; } public int OnAttach(obj_id self) throws InterruptedException { messageTo(self, "halloweenServerStart", null, 720.0f, false); messageTo(self, "lifedayServerStart", null, 730.0f, false); messageTo(self, "lovedayServerStart", null, 735.0f, false); messageTo(self, "empiredayServerStart", null, (holiday.EMPIRE_DAY_EVENT_START_DELAY + 100), false); return SCRIPT_CONTINUE; } public int OnGetAttributes(obj_id self, obj_id player, String[] names, String[] attribs) throws InterruptedException { int idx = utils.getValidAttributeIndex(names); if (idx == -1) { return SCRIPT_CONTINUE; } if (!isGod(player)) { return SCRIPT_CONTINUE; } if (GALACTIC_MOON_FESTIVAL_ENABLED) { names[idx] = "holiday_event"; attribs[idx] = "Halloween Event Running = True"; idx++; } else { names[idx] = "holiday_event"; attribs[idx] = "Halloween Event Running = False"; idx++; } if (LIFEDAY_ENABLED) { names[idx] = "holiday_event"; attribs[idx] = "Life Day Event Running = True"; idx++; } else { names[idx] = "holiday_event"; attribs[idx] = "Life Day Event Running = False"; idx++; } if (EWOK_FESTIVAL_OF_LOVE_ENABLED) { names[idx] = "holiday_event"; attribs[idx] = "Love Day Event Running = True"; idx++; } else { names[idx] = "holiday_event"; attribs[idx] = "Love Day Event Running = False"; idx++; } if (EMPIRE_DAY_ENABLED) { names[idx] = "holiday_event"; attribs[idx] = "Empire Day Event Running = True"; } else { names[idx] = "holiday_event"; attribs[idx] = "Empire Day Event Running = False"; } return SCRIPT_CONTINUE; } public int OnHearSpeech(obj_id self, obj_id speaker, String text) throws InterruptedException { if (!isGod(speaker)) { return SCRIPT_CONTINUE; } String universeWideEvents = getCurrentUniverseWideEvents(); int halloween = universeWideEvents.indexOf("halloween"); int lifeday = universeWideEvents.indexOf("lifeday"); int loveday = universeWideEvents.indexOf("loveday"); int empireday = universeWideEvents.indexOf("empireday_ceremony"); switch (text) { case "halloweenStart": startHolidayEvent(speaker, "halloween", GALACTIC_MOON_FESTIVAL_ENABLED, halloween); return SCRIPT_OVERRIDE; case "halloweenStop": stopHolidayEvent(speaker, "halloween", GALACTIC_MOON_FESTIVAL_ENABLED, halloween); return SCRIPT_OVERRIDE; case "halloweenStartForReals": startHolidayEventForReals(speaker, "halloween", GALACTIC_MOON_FESTIVAL_ENABLED); return SCRIPT_OVERRIDE; case "halloweenStopForReals": stopHolidayEventForReals(speaker, "halloween"); return SCRIPT_OVERRIDE; case "lifedayStart": startHolidayEvent(speaker, "lifeday", LIFEDAY_ENABLED, lifeday); return SCRIPT_OVERRIDE; case "lifedayStop": stopHolidayEvent(speaker, "lifeday", LIFEDAY_ENABLED, lifeday); return SCRIPT_OVERRIDE; case "lifedayStartForReals": startHolidayEventForReals(speaker, "lifeday", LIFEDAY_ENABLED); return SCRIPT_OVERRIDE; case "lifedayStopForReals": stopHolidayEventForReals(speaker, "lifeday"); return SCRIPT_OVERRIDE; case "lovedayStart": startHolidayEvent(speaker, "loveday", EWOK_FESTIVAL_OF_LOVE_ENABLED, loveday); return SCRIPT_OVERRIDE; case "lovedayStop": stopHolidayEvent(speaker, "loveday", EWOK_FESTIVAL_OF_LOVE_ENABLED, loveday); return SCRIPT_OVERRIDE; case "lovedayStartForReals": startHolidayEventForReals(speaker, "loveday", EWOK_FESTIVAL_OF_LOVE_ENABLED); return SCRIPT_OVERRIDE; case "lovedayStopForReals": stopHolidayEventForReals(speaker, "loveday"); return SCRIPT_OVERRIDE; case "empiredayStart": startHolidayEvent(speaker, "empireday_ceremony", EMPIRE_DAY_ENABLED, empireday); return SCRIPT_OVERRIDE; case "empiredayStop": stopHolidayEvent(speaker, "empireday_ceremony", EMPIRE_DAY_ENABLED, empireday); return SCRIPT_OVERRIDE; case "empiredayStartForReals": startHolidayEventForReals(speaker, "empireday_ceremony", EMPIRE_DAY_ENABLED); return SCRIPT_OVERRIDE; case "empiredayStopForReals": stopHolidayEventForReals(speaker, "empireday_ceremony"); return SCRIPT_OVERRIDE; } return SCRIPT_CONTINUE; } // Make sure CSRs can't take the master object on a stroll down Amidala's Beach when they should be home doing their homework public int OnAboutToBeTransferred(obj_id self, obj_id destContainer, obj_id transferer) throws InterruptedException { sendSystemMessageTestingOnly(transferer, "You cannot move this item!"); return SCRIPT_OVERRIDE; } private void startHolidayEvent(obj_id speaker, String holidayName, boolean holidayRunning, int holidayStatus) throws InterruptedException { if (!holidayRunning) { sendSystemMessageTestingOnly(speaker, "Server config is not marked as " + holidayName + " running"); } else { if (holidayStatus > -1) { sendSystemMessageTestingOnly(speaker, "Server says that " + holidayName + " is already running. If you are sure that it's not, say " + holidayName + "StartForReals"); } if (holidayStatus < 0) { sendSystemMessageTestingOnly(speaker, holidayName + " started."); startUniverseWideEvent(holidayName); } } } private void startHolidayEventForReals(obj_id speaker, String holidayName, boolean holidayRunning) throws InterruptedException { if (!holidayRunning) { sendSystemMessageTestingOnly(speaker, "Server config is not marked as " + holidayName + " running"); } else { sendSystemMessageTestingOnly(speaker, holidayName + " started."); startUniverseWideEvent(holidayName); } } private void stopHolidayEvent(obj_id speaker, String holidayName, boolean holidayRunning, int holidayStatus) throws InterruptedException { if (holidayRunning) { sendSystemMessageTestingOnly(speaker, "Server config is marked as " + holidayName + " running. If you are sure that it should not be running anyway, say " + holidayName + "StopForReals"); } } private void stopHolidayEventForReals(obj_id speaker, String holidayName) throws InterruptedException { sendSystemMessageTestingOnly(speaker, holidayName + " stopped."); stopUniverseWideEvent(holidayName); } public int halloweenServerStart(obj_id self, dictionary params) throws InterruptedException { CustomerServiceLog("holidayEvent", "holiday_controller.halloweenServerStart Halloween event handler called."); String halloweenString = getCurrentUniverseWideEvents(); int halloween = halloweenString.indexOf("halloween"); CustomerServiceLog("holidayEvent", "holiday_controller.halloweenServerStart halloweenString: " + halloweenString + " halloween: " + halloween + " halloweenRunning: " + GALACTIC_MOON_FESTIVAL_ENABLED); if (!GALACTIC_MOON_FESTIVAL_ENABLED) { CustomerServiceLog("holidayEvent", "holiday_controller.halloweenServerStart Halloween event is either not running or not in the server configs."); if (halloween > -1) { stopUniverseWideEvent("halloween"); } } else { if (halloween < 0) { if (!startUniverseWideEvent("halloween")) { CustomerServiceLog("holidayEvent", "holiday_controller.halloweenServerStart startUniverseWideEvent reports FAILURE to start universe wide event."); } else { CustomerServiceLog("holidayEvent", "holiday_controller.halloweenServerStart startUniverseWideEvent reports SUCCESS starting universe wide event."); } } } return SCRIPT_CONTINUE; } public int lifedayServerStart(obj_id self, dictionary params) throws InterruptedException { CustomerServiceLog("holidayEvent", "holiday_controller.lifedayServerStart Life Day event handler called."); String lifedayString = getCurrentUniverseWideEvents(); int lifeday = lifedayString.indexOf("lifeday"); CustomerServiceLog("holidayEvent", "holiday_controller.lifedayServerStart lifedayString: " + lifedayString + " lifeday: " + lifeday + " lifedayRunning: " + LIFEDAY_ENABLED); if (!LIFEDAY_ENABLED) { CustomerServiceLog("holidayEvent", "holiday_controller.lifedayServerStart event is either not running or not in the server configs."); if (lifeday > -1) { stopUniverseWideEvent("lifeday"); } } else { if (lifeday < 0) { if (!startUniverseWideEvent("lifeday")) { CustomerServiceLog("holidayEvent", "holiday_controller.lifedayServerStart startUniverseWideEvent reports FAILURE to start universe wide event."); } else { CustomerServiceLog("holidayEvent", "holiday_controller.lifedayServerStart startUniverseWideEvent reports SUCCESS starting universe wide event."); } } } return SCRIPT_CONTINUE; } public int lovedayServerStart(obj_id self, dictionary params) throws InterruptedException { CustomerServiceLog("holidayEvent", "holiday_controller.lovedayServerStart Love Day event handler called."); String lovedayString = getCurrentUniverseWideEvents(); int loveday = lovedayString.indexOf("loveday"); CustomerServiceLog("holidayEvent", "holiday_controller.lovedayServerStart lovedayString: " + lovedayString + " loveday: " + loveday + " lovedayRunning: " + EWOK_FESTIVAL_OF_LOVE_ENABLED); if (!EWOK_FESTIVAL_OF_LOVE_ENABLED) { CustomerServiceLog("holidayEvent", "holiday_controller.lovedayServerStart event is either not running or not in the server configs."); if (loveday > -1) { stopUniverseWideEvent("loveday"); } } else { if (loveday < 0) { if (!startUniverseWideEvent("loveday")) { CustomerServiceLog("holidayEvent", "holiday_controller.lovedayServerStart startUniverseWideEvent reports FAILURE to start universe wide event."); } else { CustomerServiceLog("holidayEvent", "holiday_controller.lovedayServerStart startUniverseWideEvent reports SUCCESS starting universe wide event."); } } } return SCRIPT_CONTINUE; } public int empiredayServerStart(obj_id self, dictionary params) throws InterruptedException { CustomerServiceLog("holidayEvent", "holiday_controller.empiredayServerStart Empire Day event handler called."); String empiredayString = getCurrentUniverseWideEvents(); int empireday = empiredayString.indexOf("empireday_ceremony"); CustomerServiceLog("holidayEvent", "holiday_controller.empiredayServerStart empiredayString: " + empiredayString + " empireday: " + empireday + " empiredayRunning: " + EMPIRE_DAY_ENABLED); if (!EMPIRE_DAY_ENABLED) { CustomerServiceLog("holidayEvent", "holiday_controller.empiredayServerStart event is either not running or not in the server configs."); if (empireday > -1) { stopUniverseWideEvent("empireday_ceremony"); } } else { CustomerServiceLog("holidayEvent", "holiday_controller.empiredayServerStart event is starting."); if (empireday < 0) { if (!startUniverseWideEvent("empireday_ceremony")) { CustomerServiceLog("holidayEvent", "holiday_controller.empiredayServerStart startUniverseWideEvent reports FAILURE to start universe wide event."); } else { CustomerServiceLog("holidayEvent", "holiday_controller.empiredayServerStart startUniverseWideEvent reports SUCCESS starting universe wide event."); } } } return SCRIPT_CONTINUE; } }