mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-10-12 03:13:00 -04:00
169 lines
3.4 KiB
Plaintext
169 lines
3.4 KiB
Plaintext
include library.utils;
|
|
include library.gcw;
|
|
include library.sui;
|
|
include library.chat;
|
|
|
|
/***** TRIGGERS ********************************************************/
|
|
|
|
/*
|
|
trigger OnAttach()
|
|
{
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
*/
|
|
|
|
|
|
trigger OnInitialize()
|
|
{
|
|
callAttentionBarker(self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
|
|
const float MIN_BARK_TIME = 30f;
|
|
const float MAX_BARK_TIME = 240f;
|
|
|
|
|
|
const float[] RATINGS = {
|
|
.10f,
|
|
.25f,
|
|
.50f,
|
|
.75f,
|
|
1.0f,
|
|
1.25f,
|
|
1.5f,
|
|
2.0f,
|
|
2.5f
|
|
};
|
|
|
|
const string[] RATING_STRINGS ={
|
|
"rebel_losing_4",
|
|
"rebel_losing_3",
|
|
"rebel_losing_2",
|
|
"rebel_losing_1",
|
|
"equal",
|
|
"rebel_winning_1",
|
|
"rebel_winning_2",
|
|
"rebel_winning_3",
|
|
"rebel_winning_4"
|
|
};
|
|
|
|
const string[] BARK_STRINGS = {
|
|
"newsnet_extra",
|
|
"newsnet_read_all"
|
|
};
|
|
|
|
trigger OnObjectMenuRequest(obj_id player, menu_info item)
|
|
{
|
|
int menuOption = item.addRootMenu ( menu_info_types.ITEM_USE, new string_id("gcw","read_headline"));
|
|
return SCRIPT_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
trigger OnObjectMenuSelect (obj_id player, int item)
|
|
{
|
|
if ( item == menu_info_types.ITEM_USE )
|
|
{
|
|
LOG("LOG_CHANNEL", "newsnet_terminal::OnItemUse");
|
|
doNewsNetUI(self, player);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
|
|
|
|
// 3 dictions
|
|
|
|
// naboo, corellia and general
|
|
|
|
// naboo is righty
|
|
// corellia is lefty
|
|
// general is farmtimes
|
|
void doNewsNetUI(obj_id self, obj_id player)
|
|
{
|
|
float fltRatio = gcw.getRebelRatio(self);
|
|
LOG("gcw", "ratio is "+fltRatio);
|
|
string headlineString = getHeadlineString(fltRatio);
|
|
location locTest = getLocation(self);
|
|
string strPlanetID = locTest.area;
|
|
|
|
//select planet name string to use. Use general if we haven't prepped specifics for that planet yet.
|
|
string planetSTFName = "general";
|
|
if(strPlanetID.equals("naboo") || strPlanetID.equals("corellia"))
|
|
planetSTFName = strPlanetID;
|
|
|
|
string strBody = "headline_"+planetSTFName+"_"+headlineString;
|
|
string strTitle = planetSTFName+"_newsnet_name";
|
|
|
|
string_id strTitleId = new string_id("gcw",strTitle);
|
|
string_id strBodyID = new string_id("gcw", strBody);
|
|
|
|
//sui.msgbox(self, self, utils.packStringId(strBodyID), sui.OK_ONLY, utils.packStringId(strTitleId), "noHandlerNeeded");
|
|
sui.msgbox(player, player, utils.packStringId(strBodyID), sui.OK_ONLY, utils.packStringId(strTitleId), "noHandler");
|
|
}
|
|
|
|
|
|
|
|
string getHeadlineString(float fltRatio)
|
|
{
|
|
if(fltRatio<=RATINGS[0])
|
|
{
|
|
return RATING_STRINGS[0];
|
|
}
|
|
else if((fltRatio>=RATINGS[0])&&(fltRatio<=RATINGS[1]))
|
|
{
|
|
return RATING_STRINGS[1];
|
|
}
|
|
else if((fltRatio>=RATINGS[1])&&(fltRatio<=RATINGS[2]))
|
|
{
|
|
return RATING_STRINGS[2];
|
|
}
|
|
else if((fltRatio>=RATINGS[2])&&(fltRatio<=RATINGS[3]))
|
|
{
|
|
return RATING_STRINGS[3];
|
|
}
|
|
else if((fltRatio>=RATINGS[3])&&(fltRatio<=RATINGS[5]))
|
|
{
|
|
return RATING_STRINGS[4];
|
|
}
|
|
else if((fltRatio>=RATINGS[5])&&(fltRatio<=RATINGS[6]))
|
|
{
|
|
return RATING_STRINGS[5];
|
|
}
|
|
else if((fltRatio>=RATINGS[6])&&(fltRatio<=RATINGS[7]))
|
|
{
|
|
return RATING_STRINGS[6];
|
|
}
|
|
else if((fltRatio>=RATINGS[7])&&(fltRatio<=RATINGS[8]))
|
|
{
|
|
return RATING_STRINGS[7];
|
|
}
|
|
else if(fltRatio>=RATINGS[8])
|
|
{
|
|
return RATING_STRINGS[8];
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
void callAttentionBarker(obj_id self)
|
|
{
|
|
float bark_delay = rand(MIN_BARK_TIME, MIN_BARK_TIME);
|
|
messageTo( self, "barkForAttention", null, bark_delay, false );
|
|
}
|
|
|
|
|
|
messageHandler factionBaseUnitRefund()
|
|
{
|
|
string_id barkMessage = new string_id("gcw",BARK_STRINGS[rand(0,BARK_STRINGS.length)]);
|
|
chat.chat( self, "exclaim", barkMessage );
|
|
callAttentionBarker(self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|