mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-14 23:07:51 -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
129 lines
4.9 KiB
Java
Executable File
129 lines
4.9 KiB
Java
Executable File
package script.systems.event_perk;
|
|
|
|
import script.dictionary;
|
|
import script.library.money;
|
|
import script.library.sui;
|
|
import script.library.utils;
|
|
import script.obj_id;
|
|
import script.string_id;
|
|
|
|
public class promoter extends script.base_script
|
|
{
|
|
public promoter()
|
|
{
|
|
}
|
|
public int OnAttach(obj_id self) throws InterruptedException
|
|
{
|
|
setInvulnerable(self, true);
|
|
if (!hasScript(self, "systems.storyteller.storyteller_vendor"))
|
|
{
|
|
attachScript(self, "systems.storyteller.storyteller_vendor");
|
|
}
|
|
if (hasScript(self, "conversation.event_promoter"))
|
|
{
|
|
detachScript(self, "conversation.event_promoter");
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public int OnInitialize(obj_id self) throws InterruptedException
|
|
{
|
|
setInvulnerable(self, true);
|
|
if (!hasScript(self, "systems.storyteller.storyteller_vendor"))
|
|
{
|
|
attachScript(self, "systems.storyteller.storyteller_vendor");
|
|
}
|
|
if (hasScript(self, "conversation.event_promoter"))
|
|
{
|
|
detachScript(self, "conversation.event_promoter");
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public int showPromoterItemList(obj_id self, dictionary params) throws InterruptedException
|
|
{
|
|
obj_id player = params.getObjId("player");
|
|
String table = params.getString("table");
|
|
utils.setScriptVar(player, "promoter.table_select", table);
|
|
int[] cost = dataTableGetIntColumn(table, 2);
|
|
String[] rawName = dataTableGetStringColumn(table, 1);
|
|
String[] derivedName = new String[rawName.length];
|
|
String[] concatMsg = new String[rawName.length];
|
|
for (int i = 0; i < rawName.length; i++)
|
|
{
|
|
derivedName[i] = "@event_perk:" + rawName[i];
|
|
string_id sid_name = utils.unpackString(derivedName[i]);
|
|
String name = getString(sid_name);
|
|
concatMsg[i] = "[" + cost[i] + "] " + name;
|
|
}
|
|
sui.listbox(self, player, "@event_perk:pro_show_list_desc", sui.OK_CANCEL, "@event_perk:pro_show_list_title", concatMsg, "selectPromoterItem", true);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public int selectPromoterItem(obj_id self, dictionary params) throws InterruptedException
|
|
{
|
|
obj_id player = sui.getPlayerId(params);
|
|
String table = utils.getStringScriptVar(player, "promoter.table_select");
|
|
int idx = sui.getListboxSelectedRow(params);
|
|
if (idx < 0)
|
|
{
|
|
idx = 0;
|
|
}
|
|
int btn = sui.getIntButtonPressed(params);
|
|
if (btn == sui.BP_CANCEL)
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
String[] templateTable = dataTableGetStringColumn(table, 0);
|
|
int[] costTable = dataTableGetIntColumn(table, 2);
|
|
if (templateTable == null || templateTable.length == 0)
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (costTable == null || costTable.length == 0)
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
obj_id[] allContents = utils.getAllItemsInBankAndInventory(player);
|
|
int perkCount = 0;
|
|
for (obj_id allContent1 : allContents) {
|
|
if (hasObjVar(allContent1, "event_perk")) {
|
|
perkCount++;
|
|
}
|
|
if (perkCount >= 5) {
|
|
sendSystemMessage(player, new string_id("event_perk", "pro_too_many_perks"));
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
String template = templateTable[idx];
|
|
int cost = costTable[idx];
|
|
for (obj_id allContent : allContents) {
|
|
String whatsThis = getTemplateName(allContent);
|
|
if (whatsThis.equals("object/tangible/deed/event_perk/shuttle_beacon.iff") && whatsThis.equals(template)) {
|
|
sendSystemMessage(player, new string_id("event_perk", "promoter_only_one"));
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
if (cost < 1)
|
|
{
|
|
sendSystemMessage(player, new string_id("event_perk", "pro_error_cost"));
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
int totalMoney = getTotalMoney(player);
|
|
if (cost > totalMoney)
|
|
{
|
|
sendSystemMessage(player, new string_id("event_perk", "lottery_add_credits_nsf"));
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
obj_id playerInventory = utils.getInventoryContainer(player);
|
|
obj_id purchasedItem = createObject(template, playerInventory, "");
|
|
if (isIdValid(purchasedItem))
|
|
{
|
|
money.pay(player, self, cost, "derpDerpDerp", null);
|
|
CustomerServiceLog("EventPerk", "(Promoter - [" + self + "]) Player [" + player + "] purchased " + purchasedItem + " at a cost of " + cost);
|
|
}
|
|
else
|
|
{
|
|
sendSystemMessage(player, new string_id("event_perk", "promoter_full_inv"));
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|