mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-10-13 04:13:01 -04:00
161 lines
3.9 KiB
Plaintext
161 lines
3.9 KiB
Plaintext
include library.create;
|
|
include library.utils;
|
|
include library.player_structure;
|
|
include library.locations
|
|
include library.space_transition;
|
|
include library.space_utils;
|
|
include library.buff;
|
|
include library.ai_lib;
|
|
|
|
/***** CONSTS **********************************************************/
|
|
const string LIFEDAY = new string("event/life_day");
|
|
//chair sounds
|
|
const string SOUND_1 = new string("sound/proton_chair_adorable.snd");
|
|
const string SOUND_2 = new string("sound/proton_chair_create_me.snd");
|
|
const string SOUND_3 = new string("sound/proton_chair_exist_for_you.snd");
|
|
const string SOUND_4 = new string("sound/proton_chair_relax.snd");
|
|
const string SOUND_5 = new string("sound/proton_chair_searching_for.snd");
|
|
const string SOUND_6 = new string("sound/proton_chair_time.snd");
|
|
const string SOUND_7 = new string("sound/proton_chair_voice_for_you_alone.snd");
|
|
//Misc
|
|
const string_id SID_TURN_ON = new string_id(LIFEDAY, "chair_on");
|
|
const string_id SID_TURN_OFF = new string_id(LIFEDAY, "chair_off");
|
|
|
|
/***** FUNCTIONS ********************************************************/
|
|
|
|
trigger OnInitialize()
|
|
{
|
|
if (hasObjVar(self, "chairOn"))
|
|
removeObjVar(self, "chairOn");
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnAttach()
|
|
{
|
|
if (hasObjVar(self, "chairOn"))
|
|
removeObjVar(self, "chairOn");
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
|
|
{
|
|
if (inHouse(self))
|
|
{
|
|
menu_info_data data = mi.getMenuItemByType (menu_info_types.SERVER_MENU6);
|
|
|
|
if (getPosture(player) == POSTURE_SITTING)
|
|
{
|
|
mi.addRootMenu (menu_info_types.SERVER_MENU6, new string_id("",""));
|
|
|
|
if (hasObjVar(self, "chairOn"))
|
|
int chairOn = mi.addRootMenu(menu_info_types.SERVER_MENU6, SID_TURN_OFF);
|
|
else
|
|
int chairOn = mi.addRootMenu(menu_info_types.SERVER_MENU6, SID_TURN_ON);
|
|
}
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnObjectMenuSelect(obj_id player, int item)
|
|
{
|
|
sendDirtyObjectMenuNotification(self);
|
|
if (inHouse(self))
|
|
{
|
|
if (item == menu_info_types.SERVER_MENU6 && !hasObjVar(self, "chairOn"))
|
|
{
|
|
if (getPosture(player) == POSTURE_SITTING)
|
|
{
|
|
//Start looping sounds
|
|
dictionary params = new dictionary ();
|
|
params.put("player", player);
|
|
messageTo(self, "soundLoop", params, 3, false);
|
|
setObjVar(self, "chairOn", 1);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
if (item == menu_info_types.SERVER_MENU6 && hasObjVar(self, "chairOn"))
|
|
{
|
|
//Stop playing sounds
|
|
removeObjVar(self, "chairOn");
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//House or POB ship check.
|
|
boolean inHouse(obj_id device)
|
|
{
|
|
obj_id selfContainer = getContainedBy(device);
|
|
obj_id ship = space_transition.getContainingShip(selfContainer);
|
|
string templateName ="";
|
|
|
|
if (isIdValid(ship))
|
|
{
|
|
templateName = getTemplateName(ship);
|
|
}
|
|
|
|
if ((utils.isInHouseCellSpace(device) || space_utils.isPobType(templateName)) && !utils.isNestedWithinAPlayer(device))
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
//Playing sounds
|
|
messageHandler soundLoop()
|
|
{
|
|
if (!inHouse(self))
|
|
removeObjVar(self, "chairOn");
|
|
|
|
if (hasObjVar(self, "chairOn"))
|
|
{
|
|
int idx = rand(1,7);
|
|
int lastSound = params.getInt("lastSound");
|
|
|
|
if (idx == lastSound)
|
|
idx = rand(1,7);
|
|
|
|
obj_id player = params.getObjId("player");
|
|
if (getPosture(player) == POSTURE_SITTING)
|
|
{
|
|
switch(idx)
|
|
{
|
|
case 1:
|
|
play2dNonLoopingMusic(player, SOUND_1);
|
|
break;
|
|
case 2:
|
|
play2dNonLoopingMusic(player, SOUND_2);
|
|
break;
|
|
case 3:
|
|
play2dNonLoopingMusic(player, SOUND_3);
|
|
break;
|
|
case 4:
|
|
play2dNonLoopingMusic(player, SOUND_4);
|
|
break;
|
|
case 5:
|
|
play2dNonLoopingMusic(player, SOUND_5);
|
|
break;
|
|
case 6:
|
|
play2dNonLoopingMusic(player, SOUND_6);
|
|
break;
|
|
case 7:
|
|
play2dNonLoopingMusic(player, SOUND_7);
|
|
break;
|
|
|
|
default:
|
|
}
|
|
params.put("lastSound", idx);
|
|
params.put("player", player);
|
|
messageTo(self, "soundLoop", params, 10, false);
|
|
}
|
|
else
|
|
removeObjVar(self, "chairOn");
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|