Files
dsrc/sku.0/sys.server/compiled/game/script/npc/skillteacher/trainer_spawner.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

121 lines
3.9 KiB
Java
Executable File

package script.npc.skillteacher;
import script.dictionary;
import script.library.ai_lib;
import script.library.city;
import script.library.create;
import script.library.utils;
import script.obj_id;
import script.string_id;
public class trainer_spawner extends script.base_script
{
public trainer_spawner()
{
}
public static final boolean TRAINERS_OFF = true;
public int OnInitialize(obj_id self) throws InterruptedException
{
if (TRAINERS_OFF)
{
return SCRIPT_CONTINUE;
}
String spawn = getStringObjVar(self, "spawns");
if (spawn == null)
{
return SCRIPT_OVERRIDE;
}
if (getIntObjVar(self, "city_id") > 0)
{
city.validateSpecialStructure(self);
}
messageTo(self, "spawnTrainer", null, 1.0f, false);
return SCRIPT_CONTINUE;
}
public int OnDestroy(obj_id self) throws InterruptedException
{
if (getIntObjVar(self, "city_id") > 0)
{
obj_id trainer = utils.getObjIdScriptVar(self, "trainer");
destroyObject(trainer);
city.removeSkillTrainer(self);
}
return SCRIPT_CONTINUE;
}
public int OnUnloadedFromMemory(obj_id self) throws InterruptedException
{
if (getIntObjVar(self, "city_id") > 0)
{
obj_id trainer = utils.getObjIdScriptVar(self, "trainer");
destroyObject(trainer);
utils.removeScriptVar(self, "trainer");
}
return SCRIPT_CONTINUE;
}
public int spawnTrainer(obj_id self, dictionary params) throws InterruptedException
{
if (utils.hasScriptVar(self, "trainer"))
{
return SCRIPT_CONTINUE;
}
String spawn = getStringObjVar(self, "spawns");
if (spawn == null)
{
return SCRIPT_OVERRIDE;
}
if (!isTrainerAllowed(spawn))
{
return SCRIPT_CONTINUE;
}
obj_id trainer = create.object(spawn, getLocation(self));
if (trainer == null || !isIdValid(trainer))
{
obj_id creator = getObjIdObjVar(self, "creator");
sendSystemMessage(creator, new string_id("city/city", "st_fail"));
destroyObject(self);
return SCRIPT_CONTINUE;
}
setInvulnerable(trainer, true);
setCreatureStatic(trainer, true);
ai_lib.setDefaultCalmBehavior(trainer, ai_lib.BEHAVIOR_SENTINEL);
if (getIntObjVar(self, "city_id") > 0)
{
setYaw(trainer, getYaw(self));
setObjVar(trainer, "spawner", self);
utils.setScriptVar(self, "trainer", trainer);
attachScript(trainer, "npc.skillteacher.civic_skillteacher");
String spawn_r = "st" + spawn.substring(spawn.indexOf('_'), spawn.length());
}
return SCRIPT_CONTINUE;
}
public int requestDestroy(obj_id self, dictionary params) throws InterruptedException
{
obj_id trainer = utils.getObjIdScriptVar(self, "trainer");
destroyObject(trainer);
destroyObject(self);
return SCRIPT_CONTINUE;
}
public boolean isTrainerAllowed(String strTrainer) throws InterruptedException
{
if (utils.checkConfigFlag("ScriptFlags", "noEliteTrainers"))
{
String[] strAllowedTrainers =
{
"trainer_artisan",
"trainer_brawler",
"trainer_entertainer",
"trainer_marksman",
"trainer_medic",
"trainer_scout"
};
for (String strTest : strAllowedTrainers) {
if (strTrainer.equals(strTest)) {
return true;
}
}
return false;
}
return true;
}
}