Files
dsrc/sku.0/sys.server/compiled/game/script/debug/test_message_to.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

167 lines
6.1 KiB
Java
Executable File

package script.debug;
import script.deltadictionary;
import script.dictionary;
import script.obj_id;
public class test_message_to extends script.base_script
{
public test_message_to()
{
}
public int OnSpeaking(obj_id self, String text) throws InterruptedException
{
if (!isGod(self))
{
return SCRIPT_CONTINUE;
}
boolean handled = true;
switch (text) {
case "startmessagetest": {
obj_id target = getLookAtTarget(self);
if (isIdValid(target)) {
if (!target.hasScript("debug.test_message_to")) {
attachScript(target, "debug.test_message_to");
}
} else {
target = self;
}
deltadictionary scriptVars = self.getScriptVars();
scriptVars.put("messagetestcount", 0);
scriptVars.put("messagetestspam", false);
runTest(self, target, 1);
break;
}
case "stopmessagetest": {
deltadictionary scriptVars = self.getScriptVars();
scriptVars.remove("messagetestcount");
scriptVars.remove("messagetesttest");
scriptVars.remove("messagetestspam");
break;
}
case "messagetestinfo": {
deltadictionary scriptVars = self.getScriptVars();
debugServerConsoleMsg(null, "messagetest count = " + scriptVars.getInt("messagetestcount") + ", current test = " + scriptVars.getInt("messagetesttest"));
break;
}
case "messagetestspam": {
deltadictionary scriptVars = self.getScriptVars();
boolean spam = scriptVars.getBoolean("messagetestspam");
scriptVars.put("messagetestspam", !spam);
break;
}
default:
handled = false;
break;
}
if (handled)
{
return SCRIPT_OVERRIDE;
}
return SCRIPT_CONTINUE;
}
public boolean runTest(obj_id self, obj_id target, int test) throws InterruptedException
{
deltadictionary scriptVars = self.getScriptVars();
if (!scriptVars.hasKey("messagetestcount"))
{
return true;
}
boolean spam = scriptVars.getBoolean("messagetestspam");
if (spam)
{
debugServerConsoleMsg(null, "testing messageTo, running test " + test);
}
dictionary params = new dictionary();
params.put("from", self);
params.put("time", getGameTime());
params.put("test", test);
switch (test)
{
case 1:
params.put("delay", 0.0f);
params.put("persist", false);
break;
case 2:
params.put("delay", 5.0f);
params.put("persist", false);
break;
case 3:
params.put("delay", 120.0f);
params.put("persist", false);
break;
case 4:
params.put("delay", 0.0f);
params.put("persist", true);
break;
case 5:
params.put("delay", 5.0f);
params.put("persist", true);
break;
case 6:
params.put("delay", 120.0f);
params.put("persist", true);
break;
default:
return false;
}
scriptVars.put("messagetestcount", scriptVars.getInt("messagetestcount") + 1);
scriptVars.put("messagetesttest", test);
messageTo(target, "testHandler", params, params.getFloat("delay"), params.getBoolean("persist"));
return true;
}
public int testHandler(obj_id self, dictionary params) throws InterruptedException
{
int currentTime = getGameTime();
float messageDelay = currentTime - params.getInt("time");
if (params.getFloat("delay") > 0)
{
if (messageDelay / params.getFloat("delay") > 1.5f)
{
debugServerConsoleMsg(null, "WARNING: testing messageTo, test " + params.getInt("test") + " had a long delay of " + messageDelay + " secs, desired = " + params.getFloat("delay"));
}
}
else if (messageDelay > 1.0f)
{
debugServerConsoleMsg(null, "WARNING: testing messageTo, test " + params.getInt("test") + " had a long delay of " + messageDelay + " secs, desired = 0");
}
if (self == params.getObjId("from"))
{
deltadictionary scriptVars = self.getScriptVars();
boolean spam = scriptVars.getBoolean("messagetestspam");
if (spam)
{
debugServerConsoleMsg(null, "testing messageTo, test " + params.getInt("test") + " completed with a delay of " + messageDelay);
}
if (!runTest(self, self, params.getInt("test") + 1))
{
runTest(self, self, 1);
}
}
else
{
dictionary newParams = new dictionary();
newParams.put("target", self);
newParams.put("test", params.getInt("test"));
newParams.put("delay", messageDelay);
messageTo(params.getObjId("from"), "nextTestHandler", newParams, 0, false);
}
return SCRIPT_CONTINUE;
}
public int nextTestHandler(obj_id self, dictionary params) throws InterruptedException
{
deltadictionary scriptVars = self.getScriptVars();
boolean spam = scriptVars.getBoolean("messagetestspam");
if (spam)
{
debugServerConsoleMsg(null, "testing messageTo, test " + params.getInt("test") + " completed with a delay of " + params.getFloat("delay"));
}
obj_id target = params.getObjId("target");
if (!runTest(self, target, params.getInt("test") + 1))
{
runTest(self, target, 1);
}
return SCRIPT_CONTINUE;
}
}