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
94 lines
3.9 KiB
Java
Executable File
94 lines
3.9 KiB
Java
Executable File
package script.npe;
|
|
|
|
import script.dictionary;
|
|
import script.library.npe;
|
|
import script.library.utils;
|
|
import script.location;
|
|
import script.obj_id;
|
|
|
|
import java.util.Vector;
|
|
|
|
public class npe_public_instance extends script.base_script
|
|
{
|
|
public npe_public_instance()
|
|
{
|
|
}
|
|
public static final boolean LOGGING = true;
|
|
public static final float POPULATION_UPDATE_TIME = 20.0f;
|
|
public static final float STATION_SCAN_RADIUS = 500.0f;
|
|
public static final String VAR_STATION_INSTANCE_ID = "npe.station_instance_id";
|
|
public int OnInitialize(obj_id self) throws InterruptedException
|
|
{
|
|
getClusterWideData(npe.DUNGEON_PUBLIC_MANAGER_NAME, getStringObjVar(self, "instance_name") + "_" + self, true, self);
|
|
doLogging("OnInitialize", "Requested cluster wide data for " + getStringObjVar(self, "instance_name") + "_" + self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public int OnClusterWideDataResponse(obj_id self, String manage_name, String name, int request_id, String[] element_name_list, dictionary[] data, int lock_key) throws InterruptedException
|
|
{
|
|
Vector players = getPlayersInStation(self);
|
|
String players_string = new String(utils.packObject(players));
|
|
dictionary info = new dictionary();
|
|
location wloc = getLocation(self);
|
|
info.put("building_id", self);
|
|
info.put("population_info", players_string);
|
|
info.put("population_num", players.size());
|
|
info.put("world_location.x", wloc.x);
|
|
info.put("world_location.y", wloc.y);
|
|
info.put("world_location.z", wloc.z);
|
|
doLogging("OnClusterWideDataResponse", "Updated info for: " + self + " size: " + info.size());
|
|
replaceClusterWideData(manage_name, name, info, true, lock_key);
|
|
releaseClusterWideDataLock(manage_name, lock_key);
|
|
dictionary params = new dictionary();
|
|
messageTo(self, "updatePopulation", params, POPULATION_UPDATE_TIME, false);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public int updatePopulation(obj_id self, dictionary params) throws InterruptedException
|
|
{
|
|
doLogging("updatePopulation", "Got message to updatePopulation");
|
|
getClusterWideData(npe.DUNGEON_PUBLIC_MANAGER_NAME, getStringObjVar(self, "instance_name") + "_" + self, true, self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public Vector getPlayersInStation(obj_id self) throws InterruptedException
|
|
{
|
|
obj_id[] players = getPlayerCreaturesInRange(getLocation(self), STATION_SCAN_RADIUS);
|
|
Vector players_ret = new Vector();
|
|
if (players != null && players.length > 0)
|
|
{
|
|
for (obj_id player : players) {
|
|
if (isIdValid(player) && utils.hasScriptVar(player, VAR_STATION_INSTANCE_ID)) {
|
|
obj_id station = utils.getObjIdScriptVar(player, VAR_STATION_INSTANCE_ID);
|
|
if (isIdValid(station) && station == self) {
|
|
players_ret.add(player);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return players_ret;
|
|
}
|
|
public void doLogging(String section, String message) throws InterruptedException
|
|
{
|
|
if (LOGGING)
|
|
{
|
|
LOG("npe_public_instance:" + section, message);
|
|
}
|
|
}
|
|
public int OnLostItem(obj_id self, obj_id destContainer, obj_id transferer, obj_id item) throws InterruptedException
|
|
{
|
|
if (isPlayer(item))
|
|
{
|
|
removeObjVar(item, VAR_STATION_INSTANCE_ID);
|
|
utils.removeScriptVar(item, VAR_STATION_INSTANCE_ID);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public int OnReceivedItem(obj_id self, obj_id srcContainer, obj_id transferer, obj_id item) throws InterruptedException
|
|
{
|
|
if (isPlayer(item))
|
|
{
|
|
removeObjVar(item, VAR_STATION_INSTANCE_ID);
|
|
utils.setScriptVar(item, VAR_STATION_INSTANCE_ID, self);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|