mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-13 22:01:04 -04:00
* Code compiles - execution NOT tested * updating gitignore * Removed intellij settings files * Removed more intellij files * Added exclusion for JDK classes. * Fixed purchasing script for vendors that have listed coin types. * Updated script to not kick off until the entire preload is complete. * adds static name entry for Solo movie poster and tcg9 vendor entry * clean up empty and orphaned object templates * adds placeholder black market (static) spawns * corrects entries for the video game table to correctly set it in tcg series 2 and remove series 1 console errors * Updated gitignore and removed intellij project files * Fixed appearance reference for thranta payroll and kashyyyk door, added skipLosCheck objvar due to cannit see issue. Requires updated src * Fixed appearance and template for terminal (#2) * Fixed appearance and template for terminal (#3) * Fixed appearance and template for terminal (#4) * Deleted another faulty/orphaned object template * Fixed gcw ranks option on frog. Only issue is that it doesn't award the officer commands or badges. * Fixed some unneeded java 11 changes
133 lines
5.0 KiB
Java
Executable File
133 lines
5.0 KiB
Java
Executable File
package script.item;
|
|
|
|
import script.library.prose;
|
|
import script.library.trial;
|
|
import script.library.utils;
|
|
import script.*;
|
|
|
|
public class heroic_token extends script.base_script
|
|
{
|
|
public heroic_token()
|
|
{
|
|
}
|
|
public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info mi) throws InterruptedException
|
|
{
|
|
menu_info_data mid = mi.getMenuItemByType(menu_info_types.ITEM_USE);
|
|
int menuStoreToken = mi.addRootMenu(menu_info_types.ITEM_USE, new string_id("spam", "heroic_token_store"));
|
|
if (getCount(self) > 1)
|
|
{
|
|
mi.addSubMenu(menuStoreToken, menu_info_types.SERVER_MENU1, new string_id("spam", "heroic_token_store_all"));
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public int OnObjectMenuSelect(obj_id self, obj_id player, int item) throws InterruptedException
|
|
{
|
|
if (isDead(player) || isIncapacitated(player))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (getContainedBy(self) != utils.getInventoryContainer(player))
|
|
{
|
|
sendSystemMessage(player, new string_id("spam", "use_top_level_only"));
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (item == menu_info_types.ITEM_USE)
|
|
{
|
|
findAndUpdateTokenBox(self, player, 1);
|
|
}
|
|
else if (item == menu_info_types.SERVER_MENU1)
|
|
{
|
|
findAndUpdateTokenBox(self, player, getCount(self));
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public void findAndUpdateTokenBox(obj_id self, obj_id player, int amount) throws InterruptedException
|
|
{
|
|
obj_id inventory = utils.getInventoryContainer(player);
|
|
obj_id[] inventoryContents = getContents(inventory);
|
|
int myId = findMyId(self);
|
|
if (myId < 0)
|
|
{
|
|
sendSystemMessage(player, new string_id("set_bonus", "heroic_token_token_error"));
|
|
return;
|
|
}
|
|
for (obj_id inventoryItem : inventoryContents) {
|
|
if (!isIdValid(inventoryItem)) {
|
|
continue;
|
|
}
|
|
String itemName = getStaticItemName(inventoryItem);
|
|
if (itemName != null && !itemName.equals("") && itemName.equals("item_heroic_token_box_01_01")) {
|
|
if (hasObjVar(inventoryItem, "item.set.tokens_held")) {
|
|
updateTokenBox(myId, inventoryItem, self, player, amount);
|
|
break;
|
|
} else {
|
|
trial.initializeBox(self);
|
|
if (hasObjVar(inventoryItem, "item.set.tokens_held")) {
|
|
updateTokenBox(myId, inventoryItem, self, player, amount);
|
|
} else {
|
|
sendSystemMessage(player, new string_id("spam", "heroic_token_box_error"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
public int findMyId(obj_id self) throws InterruptedException
|
|
{
|
|
int failId = -1;
|
|
String myName = getStaticItemName(self);
|
|
for (int i = 0; i < trial.HEROIC_TOKENS.length; i++)
|
|
{
|
|
if (myName.equals(trial.HEROIC_TOKENS[i]))
|
|
{
|
|
return i;
|
|
}
|
|
}
|
|
return failId;
|
|
}
|
|
public void updateTokenBox(int myId, obj_id tokenBox, obj_id self, obj_id player, int amount) throws InterruptedException
|
|
{
|
|
int[] currentHeroicTokens = getIntArrayObjVar(tokenBox, "item.set.tokens_held");
|
|
if (currentHeroicTokens != null && currentHeroicTokens.length == trial.NUM_HEROIC_TOKEN_TYPES)
|
|
{
|
|
updateTokenCount(currentHeroicTokens, myId, self, tokenBox, player, amount);
|
|
}
|
|
else
|
|
{
|
|
trial.verifyBox(self);
|
|
currentHeroicTokens = getIntArrayObjVar(tokenBox, "item.set.tokens_held");
|
|
if (currentHeroicTokens != null && currentHeroicTokens.length == trial.NUM_HEROIC_TOKEN_TYPES)
|
|
{
|
|
updateTokenCount(currentHeroicTokens, myId, self, tokenBox, player, amount);
|
|
}
|
|
else
|
|
{
|
|
sendSystemMessage(player, new string_id("spam", "heroic_token_box_error"));
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
public void updateTokenCount(int[] currentHeroicTokens, int myId, obj_id self, obj_id tokenBox, obj_id player, int amount) throws InterruptedException
|
|
{
|
|
currentHeroicTokens[myId] += amount;
|
|
setObjVar(tokenBox, "item.set.tokens_held", currentHeroicTokens);
|
|
decrementTokenCount(self, player, amount);
|
|
return;
|
|
}
|
|
public void decrementTokenCount(obj_id self, obj_id player, int amount) throws InterruptedException
|
|
{
|
|
prose_package pp = new prose_package();
|
|
pp = prose.setStringId(pp, new string_id("spam", "heroic_token_box_success"));
|
|
pp = prose.setTT(pp, self);
|
|
sendSystemMessageProse(player, pp);
|
|
if (getCount(self) > amount)
|
|
{
|
|
setCount(self, getCount(self) - amount);
|
|
}
|
|
else
|
|
{
|
|
destroyObject(self);
|
|
}
|
|
}
|
|
}
|