Files
dsrc/sku.0/sys.server/compiled/game/script/event/holiday_controller.script
T

460 lines
14 KiB
Plaintext

/**
* Title: holiday_controller.script
*/
/***** INCLUDES ********************************************************/
include library.utils;
include library.holiday;
/***** INSTRUCTIONS ********************************************************/
/*
1. To make a new event copy a code block of another event and rename variables
2. Make sure to keep your event name simple enough to remember. For instance "halloween".
3. In your DRIVE:\swg\exe\shared directory add your event under the [GameServer]
for instance: halloween=true
4. Create your event buildout tab files with the objects of your event. The name of the
buildout file should be prefixed with the event. Example halloween_mos_eisley. The
startUniverseWideEvent(String eventnameHere) looks for all buildout files with your
event name and turns them on.
5. IMPORTANT: Make sure to modify the datatables/buildout/areas_<planet_name_here>.tab file.
For instance the areas_naboo.tab has a few entries for event buildout table references.
YOU MUST ADD A ROW FOR YOUR EVENT BUILDOUT TABLE HERE. MAKE SURE TO MODIFY THE "eventRequired"
COLUMN TO LOOK FOR YOUR EVENT OR YOU WILL JUST WASTE TIME.
6. To test your build out, make sure you have Tatooine running. This file is attached
to an object on Tatooine 3250 4 -4807, so if Tatooine isn't running you won't see your changes at
server restart.
*/
/***** FUNCTIONS ********************************************************/
trigger OnInitialize()
{
CustomerServiceLog("holidayEvent", "holiday_controller.OnInitialize planet initialized, holiday controller called.");
//Halloween
messageTo(self, "halloweenServerStart", null, 600.0f, false);
//Life Day
messageTo(self, "lifedayServerStart", null, 610.0f, false);
//Ewok Festival of Love
messageTo(self, "lovedayServerStart", null, 615.0f, false);
//Empire/Remembrance Day
messageTo(self, "empiredayServerStart", null, holiday.EMPIRE_DAY_EVENT_START_DELAY, false);
return SCRIPT_CONTINUE;
}
trigger OnAttach()
{
//Halloween
messageTo(self, "halloweenServerStart", null, 720.0f, false);
//Life Day
messageTo(self, "lifedayServerStart", null, 730.0f, false);
//Ewok Festival of Love
messageTo(self, "lovedayServerStart", null, 735.0f, false);
//Empire/Remembrance Day
messageTo(self, "empiredayServerStart", null, (holiday.EMPIRE_DAY_EVENT_START_DELAY + 100), false);
return SCRIPT_CONTINUE;
}
trigger OnGetAttributes(obj_id player, string[] names, string[] attribs)
{
int idx = utils.getValidAttributeIndex(names);
if (idx == -1)
return SCRIPT_CONTINUE;
if(!isGod(player))
return SCRIPT_CONTINUE;
string halloweenRunning = getConfigSetting("GameServer", "halloween");
string lifedayRunning = getConfigSetting("GameServer", "lifeday");
string lovedayRunning = getConfigSetting("GameServer", "loveday");
string empiredayRunning = getConfigSetting("GameServer", "empireday_ceremony");
if(halloweenRunning != null && (halloweenRunning.equals("true") || halloweenRunning.equals("1")))
{
names[idx] = "holiday_event";
attribs[idx] = "Halloween Event Running = True";
idx++;
}
else
{
names[idx] = "holiday_event";
attribs[idx] = "Halloween Event Running = False";
idx++;
}
if(lifedayRunning != null && (lifedayRunning.equals("true") || lifedayRunning.equals("1")))
{
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(lovedayRunning != null && (lovedayRunning.equals("true") || lovedayRunning.equals("1")))
{
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(empiredayRunning != null && (empiredayRunning.equals("true") || empiredayRunning.equals("1")))
{
names[idx] = "holiday_event";
attribs[idx] = "Empire Day Event Running = True";
idx++;
}
else
{
names[idx] = "holiday_event";
attribs[idx] = "Empire Day Event Running = False";
idx++;
}
return SCRIPT_CONTINUE;
}
//God Mode Control
trigger OnHearSpeech(obj_id speaker, string text)
{
if (!isGod(speaker))
{
return SCRIPT_CONTINUE;
}
//Halloween
string halloweenString = getCurrentUniverseWideEvents();
int halloween = halloweenString.indexOf("halloween");
string halloweenRunning = getConfigSetting("GameServer", "halloween");
if (text.equals("halloweenStart"))
{
startHolidayEvent(speaker, "halloween", halloweenRunning, halloween);
return SCRIPT_OVERRIDE;
}
if (text.equals("halloweenStop"))
{
stopHolidayEvent(speaker, "halloween", halloweenRunning, halloween);
return SCRIPT_OVERRIDE;
}
if (text.equals("halloweenStartForReals"))
{
startHolidayEventForReals(speaker, "halloween", halloweenRunning);
return SCRIPT_OVERRIDE;
}
if (text.equals("halloweenStopForReals"))
{
stopHolidayEventForReals(speaker, "halloween");
return SCRIPT_OVERRIDE;
}
//Life Day
string lifedayString = getCurrentUniverseWideEvents();
int lifeday = lifedayString.indexOf("lifeday");
string lifedayRunning = getConfigSetting("GameServer", "lifeday");
if (text.equals("lifedayStart"))
{
startHolidayEvent(speaker, "lifeday", lifedayRunning, lifeday);
return SCRIPT_OVERRIDE;
}
if (text.equals("lifedayStop"))
{
stopHolidayEvent(speaker, "lifeday", lifedayRunning, lifeday);
return SCRIPT_OVERRIDE;
}
if (text.equals("lifedayStartForReals"))
{
startHolidayEventForReals(speaker, "lifeday", lifedayRunning);
return SCRIPT_OVERRIDE;
}
if (text.equals("lifedayStopForReals"))
{
stopHolidayEventForReals(speaker, "lifeday");
return SCRIPT_OVERRIDE;
}
//Love Day
string lovedayString = getCurrentUniverseWideEvents();
int loveday = lifedayString.indexOf("loveday");
string lovedayRunning = getConfigSetting("GameServer", "loveday");
if (text.equals("lovedayStart"))
{
startHolidayEvent(speaker, "loveday", lovedayRunning, loveday);
return SCRIPT_OVERRIDE;
}
if (text.equals("lovedayStop"))
{
stopHolidayEvent(speaker, "loveday", lovedayRunning, loveday);
return SCRIPT_OVERRIDE;
}
if (text.equals("lovedayStartForReals"))
{
startHolidayEventForReals(speaker, "loveday", lovedayRunning);
return SCRIPT_OVERRIDE;
}
if (text.equals("lovedayStopForReals"))
{
stopHolidayEventForReals(speaker, "loveday");
return SCRIPT_OVERRIDE;
}
//Empire Day
string empiredayString = getCurrentUniverseWideEvents();
int empireday = empiredayString.indexOf("empireday_ceremony");
string empiredayRunning = getConfigSetting("GameServer", "empireday_ceremony");
if (text.equals("empiredayStart"))
{
startHolidayEvent(speaker, "empireday_ceremony", empiredayRunning, empireday);
return SCRIPT_OVERRIDE;
}
if (text.equals("empiredayStop"))
{
stopHolidayEvent(speaker, "empireday_ceremony", empiredayRunning, empireday);
return SCRIPT_OVERRIDE;
}
if (text.equals("empiredayStartForReals"))
{
startHolidayEventForReals(speaker, "empireday_ceremony", empiredayRunning);
return SCRIPT_OVERRIDE;
}
if (text.equals("empiredayStopForReals"))
{
stopHolidayEventForReals(speaker, "empireday_ceremony");
return SCRIPT_OVERRIDE;
}
return SCRIPT_CONTINUE;
}
void startHolidayEvent(obj_id speaker, string holidayName, string holidayRunning, int holidayStatus)
{
if (holidayRunning == null)
{
sendSystemMessageTestingOnly(speaker, "Server config is not marked as " +holidayName+ " running");
return;
}
if (holidayRunning.equals("true") || holidayRunning.equals("1"))
{
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);
}
return;
}
return;
}
void startHolidayEventForReals(obj_id speaker, string holidayName, string holidayRunning)
{
if (holidayRunning == null)
{
sendSystemMessageTestingOnly(speaker, "Server config is not marked as "+holidayName+" running");
return;
}
if (holidayRunning.equals("true") || holidayRunning.equals("1"))
{
sendSystemMessageTestingOnly(speaker, holidayName+" started.");
startUniverseWideEvent(holidayName);
return;
}
return;
}
void stopHolidayEvent(obj_id speaker, string holidayName, string holidayRunning, int holidayStatus)
{
if (holidayRunning.equals("true") || holidayRunning.equals("1"))
{
sendSystemMessageTestingOnly(speaker, "Server config is marked as "+holidayName+" running. If you are sure that it should not be running anyway, say "+holidayName+"StopForReals");
return;
}
if (holidayRunning == null)
{
if (holidayStatus < 0)
sendSystemMessageTestingOnly(speaker, "Server says that "+holidayName+" is already stopped. If you are sure that it's not, say "+holidayName+"StartForReal");
if (holidayStatus > -1)
{
sendSystemMessageTestingOnly(speaker, holidayName+" stopped.");
stopUniverseWideEvent(holidayName);
}
return;
}
return;
}
void stopHolidayEventForReals(obj_id speaker, string holidayName)
{
sendSystemMessageTestingOnly(speaker, holidayName+" stopped.");
stopUniverseWideEvent(holidayName);
return;
}
/***** MESSAGES ********************************************************/
messageHandler halloweenServerStart()
{
CustomerServiceLog("holidayEvent", "holiday_controller.halloweenServerStart Halloween event handler called.");
string halloweenString = getCurrentUniverseWideEvents();
int halloween = halloweenString.indexOf("halloween");
string halloweenRunning = getConfigSetting("GameServer", "halloween");
CustomerServiceLog("holidayEvent", "holiday_controller.halloweenServerStart halloweenString: "+halloweenString+" halloween: "+halloween+" halloweenRunning: "+halloweenRunning);
if (halloweenRunning == null)
{
CustomerServiceLog("holidayEvent", "holiday_controller.halloweenServerStart Halloween event is either not running or not in the server configs.");
if (halloween > -1)
stopUniverseWideEvent("halloween");
}
else if (halloweenRunning.equals("true") || halloweenRunning.equals("1"))
{
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;
}
messageHandler lifedayServerStart()
{
CustomerServiceLog("holidayEvent", "holiday_controller.lifedayServerStart Life Day event handler called.");
string lifedayString = getCurrentUniverseWideEvents();
int lifeday = lifedayString.indexOf("lifeday");
string lifedayRunning = getConfigSetting("GameServer", "lifeday");
CustomerServiceLog("holidayEvent", "holiday_controller.lifedayServerStart lifedayString: "+lifedayString+" lifeday: "+lifeday+" lifedayRunning: "+lifedayRunning);
if (lifedayRunning == null)
{
CustomerServiceLog("holidayEvent", "holiday_controller.lifedayServerStart event is either not running or not in the server configs.");
if (lifeday > -1)
stopUniverseWideEvent("lifeday");
}
else if (lifedayRunning.equals("true") || lifedayRunning.equals("1"))
{
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;
}
messageHandler lovedayServerStart()
{
CustomerServiceLog("holidayEvent", "holiday_controller.lovedayServerStart Love Day event handler called.");
string lovedayString = getCurrentUniverseWideEvents();
int loveday = lovedayString.indexOf("loveday");
string lovedayRunning = getConfigSetting("GameServer", "loveday");
CustomerServiceLog("holidayEvent", "holiday_controller.lovedayServerStart lovedayString: "+lovedayString+" loveday: "+loveday+" lovedayRunning: "+lovedayRunning);
if (lovedayRunning == null)
{
CustomerServiceLog("holidayEvent", "holiday_controller.lovedayServerStart event is either not running or not in the server configs.");
if (loveday > -1)
stopUniverseWideEvent("loveday");
}
else if (lovedayRunning.equals("true") || lovedayRunning.equals("1"))
{
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;
}
messageHandler empiredayServerStart()
{
CustomerServiceLog("holidayEvent", "holiday_controller.empiredayServerStart Empire Day event handler called.");
string empiredayString = getCurrentUniverseWideEvents();
int empireday = empiredayString.indexOf("empireday_ceremony");
string empiredayRunning = getConfigSetting("GameServer", "empireday_ceremony");
CustomerServiceLog("holidayEvent", "holiday_controller.empiredayServerStart empiredayString: "+empiredayString+" empireday: "+empireday+" empiredayRunning: "+empiredayRunning);
if (empiredayRunning == null)
{
CustomerServiceLog("holidayEvent", "holiday_controller.empiredayServerStart event is either not running or not in the server configs.");
if (empireday > -1)
stopUniverseWideEvent("empireday_ceremony");
}
else if (empiredayRunning.equals("true") || empiredayRunning.equals("1"))
{
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;
}
// END END END END END END END END END END END END END END END END END END END END END END END END END