Files
dsrc/sku.0/sys.server/compiled/game/script/library/hue.java
T
TekaohandGitHub 5c2e112349 Java 11.0.2 migration (#32)
* 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
2019-04-18 18:31:52 -05:00

334 lines
11 KiB
Java
Executable File

package script.library;
import script.*;
public class hue extends script.base_script
{
public hue()
{
}
public static final String INDEX_BASE = "/private/index_color_";
public static final String INDEX_1 = "/private/index_color_1";
public static final String INDEX_2 = "/private/index_color_2";
public static boolean setColor(obj_id target, int varIdx, color c) throws InterruptedException
{
if (!isIdValid(target) || (c == null) || (varIdx < 0))
{
return false;
}
String varPathName = INDEX_BASE + varIdx;
return setColor(target, varPathName, c);
}
public static boolean setColor(obj_id target, String varPathName, color c) throws InterruptedException
{
if (!isIdValid(target) || (varPathName == null) || (c == null))
{
return false;
}
if (varPathName.startsWith("/"))
{
varPathName = varPathName.substring(1);
}
custom_var cv = getCustomVarByName(target, varPathName);
if (cv == null)
{
return false;
}
if (!cv.isPalColor())
{
return false;
}
palcolor_custom_var pcv = (palcolor_custom_var)cv;
if (pcv == null)
{
return false;
}
pcv.setToClosestColor(c);
return true;
}
public static boolean setColor(obj_id target, int varIdx, int paletteIdx) throws InterruptedException
{
if (!isIdValid(target) || (varIdx < 0) || (paletteIdx < 0))
{
return false;
}
String varPathName = INDEX_BASE + varIdx;
return setColor(target, varPathName, paletteIdx);
}
public static boolean setColor(obj_id target, String varPathName, int paletteIdx) throws InterruptedException
{
if (!isIdValid(target) || (varPathName == null) || (paletteIdx < 0))
{
return false;
}
if (varPathName.startsWith("/"))
{
varPathName = varPathName.substring(1);
}
custom_var cv = getCustomVarByName(target, varPathName);
if (cv == null)
{
return false;
}
if (!cv.isPalColor())
{
return false;
}
ranged_int_custom_var ri = (ranged_int_custom_var)cv;
if (ri == null)
{
return false;
}
ri.setValue(paletteIdx);
return true;
}
public static int getVarColorIndex(obj_id target, String varPathName) throws InterruptedException
{
if (!isIdValid(target) || (varPathName == null))
{
return -1;
}
if (varPathName.startsWith("/"))
{
varPathName = varPathName.substring(1);
}
custom_var cv = getCustomVarByName(target, varPathName);
if (cv == null)
{
return -1;
}
if (!cv.isPalColor())
{
return -1;
}
ranged_int_custom_var ri = (ranged_int_custom_var)cv;
if (ri == null)
{
return -1;
}
return ri.getValue();
}
public static void setPalcolorCustomVarClosestColor(obj_id target, String varPathName, color c) throws InterruptedException
{
if (varPathName.startsWith("/"))
{
varPathName = varPathName.substring(1);
}
setPalcolorCustomVarClosestColor(target, varPathName, c.getR(), c.getG(), c.getB(), c.getA());
}
public static ranged_int_custom_var[] getPalcolorVars(obj_id target) throws InterruptedException
{
if (!isIdValid(target))
{
return null;
}
PROFILER_START("hue.getPalcolorVars");
custom_var[] allVars = getAllCustomVars(target);
if (allVars == null)
{
PROFILER_STOP("hue.getPalcolorVars");
return null;
}
int count = 0;
for (custom_var allVar1 : allVars) {
if (allVar1.isPalColor()) {
++count;
}
}
ranged_int_custom_var[] ret = new ranged_int_custom_var[count];
int pos = 0;
for (custom_var allVar : allVars) {
if (allVar.isPalColor()) {
ranged_int_custom_var ri = (ranged_int_custom_var) (allVar);
ret[pos++] = ri;
}
}
if ((ret == null) || (ret.length == 0))
{
PROFILER_STOP("hue.getPalcolorVars");
return null;
}
PROFILER_STOP("hue.getPalcolorVars");
return ret;
}
public static dictionary getPalcolorData(obj_id target) throws InterruptedException
{
if (!isIdValid(target))
{
return null;
}
PROFILER_START("hue.getPalcolorData");
ranged_int_custom_var[] palColors = getPalcolorVars(target);
if ((palColors == null) || (palColors.length == 0))
{
PROFILER_STOP("hue.getPalcolorData");
return null;
}
dictionary d = new dictionary();
for (ranged_int_custom_var ri : palColors) {
d.put(ri.getVarName(), ri.getValue());
}
PROFILER_STOP("hue.getPalcolorData");
return d;
}
public static void setPalcolorData(obj_id target, dictionary colorData) throws InterruptedException
{
if (!isIdValid(target))
{
return;
}
if (colorData == null)
{
return;
}
ranged_int_custom_var[] palColors = getPalcolorVars(target);
if (palColors == null || palColors.length == 0)
{
return;
}
for (ranged_int_custom_var palColor : palColors) {
String varName = palColor.getVarName();
if (colorData.containsKey(varName)) {
int colorValue = colorData.getInt(varName);
palColor.setValue(colorValue);
}
}
}
public static void hueObject(obj_id target) throws InterruptedException
{
PROFILER_START("hue.hueObject");
ranged_int_custom_var[] c = getPalcolorVars(target);
if (c != null)
{
for (ranged_int_custom_var ranged_int_custom_var : c) {
int min = ranged_int_custom_var.getMinRangeInclusive();
int max = ranged_int_custom_var.getMaxRangeInclusive();
int randVal = rand(min, max);
ranged_int_custom_var.setValue(randVal);
}
}
PROFILER_STOP("hue.hueObject");
}
public static void hueObject(obj_id target, int color) throws InterruptedException
{
PROFILER_START("hue.hueObjectColor");
ranged_int_custom_var[] c = getPalcolorVars(target);
if (c != null)
{
for (ranged_int_custom_var ranged_int_custom_var : c) {
ranged_int_custom_var.setValue(color);
}
}
PROFILER_STOP("hue.hueObjectColor");
}
public static ranged_int_custom_var[] getRangedIntVars(obj_id target) throws InterruptedException
{
if (!isIdValid(target))
{
return null;
}
PROFILER_START("hue.getRangedIntVars.custom");
custom_var[] allVars = getAllCustomVars(target);
PROFILER_STOP("hue.getRangedIntVars.custom");
if (allVars == null)
{
return null;
}
PROFILER_START("hue.getRangedIntVars.alloc");
ranged_int_custom_var[] ri = new ranged_int_custom_var[allVars.length];
PROFILER_STOP("hue.getRangedIntVars.alloc");
if (ri == null)
{
return null;
}
int n = 0;
PROFILER_START("hue.getRangedIntVars.loopA." + allVars.length);
for (custom_var allVar : allVars) {
if (allVar.isRangedInt()) {
ri[n] = (ranged_int_custom_var) allVar;
n++;
}
}
PROFILER_STOP("hue.getRangedIntVars.loopA." + allVars.length);
if (n == 0)
{
return null;
}
PROFILER_START("hue.getRangedIntVars.alloc2");
ranged_int_custom_var[] ret = new ranged_int_custom_var[n];
PROFILER_STOP("hue.getRangedIntVars.alloc2");
if (ret == null)
{
return null;
}
PROFILER_START("hue.getRangedIntVars.loopB." + n);
for (int i = 0; i < n; i++)
{
ret[i] = ri[i];
}
PROFILER_STOP("hue.getRangedIntVars.loopB." + n);
return ret;
}
public static void reshapeObject(obj_id target) throws InterruptedException
{
PROFILER_START("hue.reshapeObject");
ranged_int_custom_var[] c = getRangedIntVars(target);
if (c != null)
{
for (ranged_int_custom_var ranged_int_custom_var : c) {
PROFILER_START("hue.reshapeObject.innerLoop");
int min = ranged_int_custom_var.getMinRangeInclusive();
int max = ranged_int_custom_var.getMaxRangeInclusive();
int randVal = rand(min, max);
ranged_int_custom_var.setValue(randVal);
PROFILER_STOP("hue.reshapeObject.innerLoop");
}
}
else
{
}
PROFILER_STOP("hue.reshapeObject");
}
public static void randomizeObject(obj_id target) throws InterruptedException
{
reshapeObject(target);
hueObject(target);
}
public static boolean setRangedIntCustomVar(obj_id target, String cvar_name, int idx) throws InterruptedException
{
if (!isIdValid(target) || (cvar_name == null) || cvar_name.equals("") || (idx < 0))
{
return false;
}
if (cvar_name.startsWith("/"))
{
cvar_name = cvar_name.substring(1);
}
custom_var cv = getCustomVarByName(target, cvar_name);
if (cv == null)
{
return false;
}
if (!cv.isRangedInt())
{
return false;
}
ranged_int_custom_var ri = (ranged_int_custom_var)cv;
if (ri == null)
{
return false;
}
ri.setValue(idx);
return true;
}
public static boolean setTexture(obj_id target, int idx, int value) throws InterruptedException
{
if (!isIdValid(target) || (idx < 1) || (value < 0))
{
return false;
}
String varPathName = "private/index_texture_" + idx;
return setRangedIntCustomVar(target, varPathName, value);
}
}