mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-08-01 01:15:59 -04:00
93 lines
2.5 KiB
Plaintext
93 lines
2.5 KiB
Plaintext
//Script to manage NPC blurts in the NPE
|
|
|
|
//inlcudes
|
|
include library.utils;
|
|
include library.create;
|
|
include library.chat;
|
|
include java.util.HashSet;
|
|
include library.ai_lib;
|
|
|
|
|
|
trigger OnInitialize()
|
|
{
|
|
setCondition (self, CONDITION_CONVERSABLE);
|
|
setInvulnerable (self, true);
|
|
setAnimationMood(self, "standing");
|
|
messageTo(self,"npeSetName", null, 1, false);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnAttach()
|
|
{
|
|
setCondition (self, CONDITION_CONVERSABLE);
|
|
setInvulnerable (self, true);
|
|
setAnimationMood(self, "standing");
|
|
messageTo(self,"npeSetName", null, 1, false);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnObjectMenuRequest (obj_id player, menu_info menuInfo)
|
|
{
|
|
int menu = menuInfo.addRootMenu (menu_info_types.CONVERSE_START, null);
|
|
menu_info_data menuInfoData = menuInfo.getMenuItemById (menu);
|
|
menuInfoData.setServerNotify (false);
|
|
setCondition (self, CONDITION_CONVERSABLE);
|
|
string room = getStringObjVar(self, "npe.blurt.room");
|
|
string name = getStringObjVar(self, "npe.blurt.name");
|
|
blurtChosenStatement(self, player, room, name);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler npeSetName()
|
|
{
|
|
string myName = utils.getStringObjVar(self, "npe.blurt.name");
|
|
string_id stIdName = new string_id("npe", myName);
|
|
string stfName = utils.packStringId(stIdName);
|
|
|
|
if(myName == "entertainer_2")
|
|
setAnimationMood(self, "npc_dance_basic");
|
|
if(myName == "patron_1")
|
|
setAnimationMood(self, "npc_sitting_chair");
|
|
if(myName.startsWith("pilot"))
|
|
{
|
|
stIdName = new string_id("npe", "pilot");
|
|
stfName = utils.packStringId(stIdName);
|
|
}
|
|
if(myName.startsWith("guard"))
|
|
{
|
|
stIdName = new string_id("npe", "guard");
|
|
stfName = utils.packStringId(stIdName);
|
|
}
|
|
if(myName.startsWith("patient"))
|
|
{
|
|
stIdName = new string_id("npe", "patient");
|
|
stfName = utils.packStringId(stIdName);
|
|
}
|
|
setName(self, stfName);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
string_id blurtChosenStatement(obj_id npc, obj_id player, string roomName, string npcName)
|
|
{
|
|
|
|
string_id message = randomizeChat(roomName, npcName);
|
|
chat.chat (npc, player, message, chat.ChatFlag_targetOnly);
|
|
return message;
|
|
}
|
|
|
|
string_id randomizeChat(string roomName, string npcName)
|
|
{
|
|
//HashSet theSet = new HashSet();
|
|
//theSet.add(npcName+"_1");
|
|
//theSet.add(npcName+"_2");
|
|
//theSet.add(npcName+"_3");
|
|
string[] myArray = new string[3];
|
|
myArray[0] = npcName+"_1";
|
|
myArray[1] = npcName+"_2";
|
|
myArray[2] = npcName+"_3";
|
|
//theSet.toArray(myArray);
|
|
int max = myArray.length;
|
|
string_id message = new string_id("npe/"+roomName, myArray[rand(0, max-1)]);
|
|
return message;
|
|
}
|