Files
dsrc/sku.0/sys.server/compiled/game/script/systems/crafting/station_cell.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

156 lines
6.2 KiB
Java
Executable File

package script.systems.crafting;
import script.library.buff;
import script.library.craftinglib;
import script.library.utils;
import script.obj_id;
import java.util.Vector;
public class station_cell extends script.base_script
{
public station_cell()
{
}
public int OnReceivedItem(obj_id self, obj_id srcContainer, obj_id transferer, obj_id item) throws InterruptedException
{
if (getGameObjectType(item) == GOT_misc_crafting_station)
{
if (utils.hasScriptVar(self, craftinglib.SCRIPTVAR_CELL_STATIONS))
{
Vector stations = utils.getResizeableObjIdArrayScriptVar(self, craftinglib.SCRIPTVAR_CELL_STATIONS);
if (!utils.isElementInArray(stations, item))
{
stations = utils.addElement(stations, item);
utils.setScriptVar(self, craftinglib.SCRIPTVAR_CELL_STATIONS, stations);
}
}
else
{
Vector stations = new Vector();
stations.setSize(0);
stations = utils.addElement(stations, item);
utils.setScriptVar(self, craftinglib.SCRIPTVAR_CELL_STATIONS, stations);
}
int craftingType = getIntObjVar(item, craftinglib.OBJVAR_CRAFTING_TYPE);
if (craftingType < 0)
{
return SCRIPT_CONTINUE;
}
String[] buffNames = craftinglib.getAllStationBuffNames(craftingType);
if (buffNames == null || buffNames.length <= 0)
{
return SCRIPT_CONTINUE;
}
obj_id[] cellContents = getContents(self);
if (cellContents == null || cellContents.length <= 0)
{
return SCRIPT_CONTINUE;
}
for (obj_id cellContent : cellContents) {
if (!isPlayer(cellContent)) {
continue;
}
for (String buffName : buffNames) {
buff.applyBuff(cellContent, item, buffName);
}
}
}
if (!isPlayer(item))
{
return SCRIPT_CONTINUE;
}
if (!utils.hasScriptVar(self, craftinglib.SCRIPTVAR_CELL_STATIONS))
{
return SCRIPT_CONTINUE;
}
obj_id[] stations = utils.getObjIdArrayScriptVar(self, craftinglib.SCRIPTVAR_CELL_STATIONS);
if (stations == null || stations.length <= 0)
{
return SCRIPT_CONTINUE;
}
for (obj_id station : stations) {
if (!isIdValid(station) || !exists(station)) {
continue;
}
int craftingType = getIntObjVar(station, craftinglib.OBJVAR_CRAFTING_TYPE);
if (craftingType < 0) {
return SCRIPT_CONTINUE;
}
String[] buffNames = craftinglib.getAllStationBuffNames(craftingType);
if (buffNames == null || buffNames.length <= 0) {
return SCRIPT_CONTINUE;
}
for (String buffName : buffNames) {
buff.applyBuff(item, station, buffName);
}
}
return SCRIPT_CONTINUE;
}
public int OnAboutToLoseItem(obj_id self, obj_id destContainer, obj_id transferer, obj_id item) throws InterruptedException
{
if (getGameObjectType(item) == GOT_misc_crafting_station)
{
if (utils.hasScriptVar(self, craftinglib.SCRIPTVAR_CELL_STATIONS))
{
boolean secondStation = false;
int craftingTypeItem = getIntObjVar(item, craftinglib.OBJVAR_CRAFTING_TYPE);
if (craftingTypeItem < 0)
{
return SCRIPT_CONTINUE;
}
String[] buffNames = craftinglib.getAllStationBuffNames(craftingTypeItem);
if (buffNames == null || buffNames.length <= 0)
{
return SCRIPT_CONTINUE;
}
Vector stations = utils.getResizeableObjIdArrayScriptVar(self, craftinglib.SCRIPTVAR_CELL_STATIONS);
obj_id secondStationId = obj_id.NULL_ID;
if (stations != null && stations.size() > 0)
{
for (Object station : stations) {
int craftingTypeSearch = getIntObjVar(((obj_id) station), craftinglib.OBJVAR_CRAFTING_TYPE);
if (craftingTypeSearch == craftingTypeItem && ((obj_id) station) != item) {
secondStation = true;
secondStationId = ((obj_id) station);
break;
}
}
}
stations = utils.removeElement(stations, item);
utils.setScriptVar(self, craftinglib.SCRIPTVAR_CELL_STATIONS, stations);
obj_id[] cellContents = getContents(self);
if (cellContents != null && cellContents.length > 0)
{
for (obj_id cellContent : cellContents) {
if (!isPlayer(cellContent)) {
continue;
}
for (String buffName1 : buffNames) {
buff.removeBuff(cellContent, buffName1);
}
if (secondStation && isIdValid(secondStationId) && exists(secondStationId)) {
for (String buffName : buffNames) {
buff.applyBuff(cellContent, secondStationId, buffName);
}
}
}
}
}
}
if (!isPlayer(item))
{
return SCRIPT_CONTINUE;
}
int[] stationBuffs = buff.getAllBuffsByEffect(item, "station_buff");
if (stationBuffs == null || stationBuffs.length <= 0)
{
return SCRIPT_CONTINUE;
}
for (int stationBuff : stationBuffs) {
buff.removeBuff(item, stationBuff);
}
return SCRIPT_CONTINUE;
}
}