who isn't sick of converting the freaking scripts? this negates the need

This commit is contained in:
DarthArgus
2015-11-24 09:27:45 -06:00
parent 2e64106bc8
commit bbee2d328c
11077 changed files with 2604347 additions and 3425075 deletions
@@ -0,0 +1,160 @@
package script.structure;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
import script.library.sui;
import script.library.utils;
import script.library.player_structure;
import script.library.space_utils;
import script.library.space_transition;
public class custom_sign extends script.base_script
{
public custom_sign()
{
}
public static final String SIGN_TYPE = new String("hangingStanding");
public static final String MODIFIED_SIGN = new String("modifiedSign");
public static final String SPAM = new String("spam");
public static final string_id SUI_TITLE = new string_id(SPAM, "replace_sign_sui");
public static final string_id SUI_QUESTION = new string_id(SPAM, "replace_sign_sui_question");
public static final string_id SID_USE = new string_id(SPAM, "change_sign");
public static final string_id CANT_USE = new string_id(SPAM, "not_sign");
public static final string_id CANT_DROP = new string_id(SPAM, "cant_drop_sign");
public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info mi) throws InterruptedException
{
menu_info_data data = mi.getMenuItemByType(menu_info_types.SERVER_MENU1);
obj_id target = getIntendedTarget(player);
obj_id house = utils.getObjIdScriptVar(target, "player_structure.parent");
String templateName = getTemplateName(target);
if (player_structure.isOwner(house, player))
{
if (exists(house) && isIdValid(house) && validSign(target, self, house) == true)
{
mi.addRootMenu(menu_info_types.SERVER_MENU1, SID_USE);
}
}
return SCRIPT_CONTINUE;
}
public int OnObjectMenuSelect(obj_id self, obj_id player, int item) throws InterruptedException
{
obj_id target = getIntendedTarget(player);
obj_id house = utils.getObjIdScriptVar(target, "player_structure.parent");
String templateName = getTemplateName(target);
if (item == menu_info_types.SERVER_MENU1)
{
if (exists(house) && isIdValid(house) && validSign(target, self, house) == true)
{
if (player_structure.isOwner(house, player))
{
String title = utils.packStringId(SUI_TITLE);
String prompt = getString(SUI_QUESTION);
int pid = sui.msgbox(self, player, prompt, sui.YES_NO, title, "signReplacementSui");
}
}
else
{
sendSystemMessage(player, CANT_USE);
}
}
return SCRIPT_CONTINUE;
}
public int OnAboutToBeTransferred(obj_id self, obj_id destContainer, obj_id transferer) throws InterruptedException
{
obj_id newLocationNonPlayer = getTopMostContainer(destContainer);
obj_id newLocationPlayer = getContainedBy(destContainer);
obj_id ship = space_transition.getContainingShip(destContainer);
String templateName = "";
if (isIdValid(ship))
{
templateName = getTemplateName(ship);
}
if (isPlayer(newLocationPlayer))
{
return SCRIPT_CONTINUE;
}
else if (player_structure.isPlayerStructure(newLocationNonPlayer) || space_utils.isPobType(templateName))
{
sendSystemMessage(transferer, CANT_DROP);
return SCRIPT_OVERRIDE;
}
return SCRIPT_CONTINUE;
}
public int signReplacementSui(obj_id self, dictionary params) throws InterruptedException
{
obj_id player = sui.getPlayerId(params);
if (!isIdValid(player))
{
return SCRIPT_CONTINUE;
}
int bp = sui.getIntButtonPressed(params);
if (bp == sui.BP_CANCEL)
{
return SCRIPT_CONTINUE;
}
replaceSign(player, self);
return SCRIPT_CONTINUE;
}
public void replaceSign(obj_id player, obj_id sign) throws InterruptedException
{
obj_id target = getIntendedTarget(player);
obj_id house = utils.getObjIdScriptVar(target, "player_structure.parent");
String templateName = getTemplateName(target);
if (exists(house) && isIdValid(house) && validSign(target, sign, house) == true)
{
if (player_structure.isOwner(house, player))
{
String signType = getStringObjVar(sign, MODIFIED_SIGN);
setObjVar(house, player_structure.MODIFIED_HOUSE_SIGN, signType);
player_structure.destroyStructureSign(house);
player_structure.createStructureSign(house);
String customSign = getStringObjVar(sign, player_structure.MODIFIED_HOUSE_SIGN_MODEL);
setObjVar(house, player_structure.MODIFIED_HOUSE_SIGN_MODEL, customSign);
CustomerServiceLog("playerStructure", "Player " + player + "replaced his house sign for building " + house + "with a custom sign. Static item name for custome sign was " + customSign);
destroyObject(sign);
}
}
else
{
sendSystemMessage(player, CANT_USE);
}
}
public boolean validSign(obj_id target, obj_id self, obj_id structure) throws InterruptedException
{
String templateName = getTemplateName(target);
String structureName = getTemplateName(structure);
if (hasObjVar(self, SIGN_TYPE))
{
int signType = getIntObjVar(self, SIGN_TYPE);
if (signType == 1)
{
if (structureName.indexOf("merchant_tent") > -1)
{
return false;
}
if (templateName.startsWith("object/tangible/sign/player/house_address"))
{
return true;
}
if (templateName.startsWith("object/tangible/sign/municipal/municipal_sign_hanging_cantina"))
{
return true;
}
}
if (signType == 2)
{
if (templateName.startsWith("object/tangible/sign/player/shop_sign"))
{
return true;
}
}
}
return false;
}
}
@@ -1,159 +0,0 @@
include library.sui;
include library.utils;
include library.player_structure;
include library.space_utils;
include library.space_transition;
/***** CONSTS **********************************************************/
const string SIGN_TYPE = new string("hangingStanding");
const string MODIFIED_SIGN = new string("modifiedSign");
const string SPAM = new string("spam");
const string_id SUI_TITLE = new string_id(SPAM, "replace_sign_sui");
const string_id SUI_QUESTION = new string_id(SPAM, "replace_sign_sui_question");
const string_id SID_USE = new string_id(SPAM, "change_sign");
const string_id CANT_USE = new string_id(SPAM, "not_sign");
const string_id CANT_DROP = new string_id(SPAM, "cant_drop_sign");
/***** FUNCTIONS ********************************************************/
//This script will change the regular house sign for a modified custome one.
//To make a custom house sign, attach this script and see the item_event_halloween_house_sign entry in item_stats.tab for the objvar setup.
//Sign template has to be in the object/tangible/sign/player/ folder and begin with house_address_ or shop_sign_
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
{
menu_info_data data = mi.getMenuItemByType (menu_info_types.SERVER_MENU1);
obj_id target = getIntendedTarget(player);
obj_id house = utils.getObjIdScriptVar(target, "player_structure.parent");
string templateName = getTemplateName(target);
if (player_structure.isOwner(house, player))
{
if (exists(house) && isIdValid(house) && validSign(target, self, house) == true)
mi.addRootMenu(menu_info_types.SERVER_MENU1, SID_USE);
}
return SCRIPT_CONTINUE;
}
trigger OnObjectMenuSelect(obj_id player, int item)
{
obj_id target = getIntendedTarget(player);
obj_id house = utils.getObjIdScriptVar(target, "player_structure.parent");
string templateName = getTemplateName(target);
if (item == menu_info_types.SERVER_MENU1)
{
if (exists(house) && isIdValid(house) && validSign(target, self, house) == true)
{
if (player_structure.isOwner(house, player))
{
string title = utils.packStringId(SUI_TITLE); // Confirm Sign Replacement
string prompt = getString(SUI_QUESTION); // Are you sure that you want to replace your sign?
int pid = sui.msgbox(self, player, prompt, sui.YES_NO, title, "signReplacementSui");
}
}
else
sendSystemMessage(player, CANT_USE);
}
return SCRIPT_CONTINUE;
}
//Making sure you can't drop the house sign in your house or a POB ship.
trigger OnAboutToBeTransferred(obj_id destContainer, obj_id transferer)
{
obj_id newLocationNonPlayer = getTopMostContainer(destContainer);
obj_id newLocationPlayer = getContainedBy(destContainer);
obj_id ship = space_transition.getContainingShip(destContainer);
string templateName ="";
if(isIdValid(ship))
{
templateName = getTemplateName(ship);
}
if (isPlayer(newLocationPlayer))
return SCRIPT_CONTINUE;
else if (player_structure.isPlayerStructure(newLocationNonPlayer) || space_utils.isPobType(templateName))
{
sendSystemMessage(transferer, CANT_DROP);
return SCRIPT_OVERRIDE;
}
return SCRIPT_CONTINUE;
}
messageHandler signReplacementSui()
{
obj_id player = sui.getPlayerId(params);
if(!isIdValid(player))
return SCRIPT_CONTINUE;
int bp = sui.getIntButtonPressed(params);
if(bp == sui.BP_CANCEL)
return SCRIPT_CONTINUE;
replaceSign(player, self);
return SCRIPT_CONTINUE;
}
void replaceSign(obj_id player, obj_id sign)
{
obj_id target = getIntendedTarget(player);
obj_id house = utils.getObjIdScriptVar(target, "player_structure.parent");
string templateName = getTemplateName(target);
if (exists(house) && isIdValid(house) && validSign(target, sign, house) == true)
{
if (player_structure.isOwner(house, player))
{
string signType = getStringObjVar(sign, MODIFIED_SIGN);
setObjVar(house, player_structure.MODIFIED_HOUSE_SIGN, signType);
player_structure.destroyStructureSign(house);
player_structure.createStructureSign(house);
string customSign = getStringObjVar(sign, player_structure.MODIFIED_HOUSE_SIGN_MODEL);
setObjVar(house, player_structure.MODIFIED_HOUSE_SIGN_MODEL, customSign);
CustomerServiceLog( "playerStructure", "Player " + player + "replaced his house sign for building " + house + "with a custom sign. Static item name for custome sign was " + customSign);
destroyObject(sign);
}
}
else
sendSystemMessage(player, CANT_USE);
}
//Makes sure that the sign is of the same type as the one its trying to replace. This is why naming convention of templates are so important.
boolean validSign(obj_id target, obj_id self, obj_id structure)
{
string templateName = getTemplateName(target);
string structureName = getTemplateName(structure);
if (hasObjVar(self, SIGN_TYPE))
{
//Sign Type 1 = Hanging sign (normal house sign)
//Sign Type 2 = Standing sign (shop sign)
int signType = getIntObjVar(self, SIGN_TYPE);
if (signType == 1)
{
//We don't allow a hanging sign on a merchant tent.
if (structureName.indexOf("merchant_tent") > -1)
return false;
if (templateName.startsWith("object/tangible/sign/player/house_address"))
return true;
//We allow cantinas.
if (templateName.startsWith("object/tangible/sign/municipal/municipal_sign_hanging_cantina"))
return true;
}
if (signType == 2)
{
if (templateName.startsWith("object/tangible/sign/player/shop_sign"))
return true;
}
}
return false;
}
@@ -0,0 +1,49 @@
package script.structure.filler;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
import script.library.structure;
public class filler extends script.base_script
{
public filler()
{
}
public static final String SCRIPT_ME = "structure.filler.filler";
public static final float DELAY_TIME = 5f;
public static final String HANDLER_INIT_FILLER_SPAWN = "handleInitFillerSpawn";
public static final String HANDLER_CLEANUP_FILLER_SPAWN = "handleCleanupFillerSpawn";
public int OnInitialize(obj_id self) throws InterruptedException
{
return SCRIPT_CONTINUE;
}
public int OnDetach(obj_id self) throws InterruptedException
{
return SCRIPT_CONTINUE;
}
public int OnUnloadedFromMemory(obj_id self) throws InterruptedException
{
return SCRIPT_CONTINUE;
}
public int OnDestroy(obj_id self) throws InterruptedException
{
return SCRIPT_CONTINUE;
}
public int handleInitFillerSpawn(obj_id self, dictionary params) throws InterruptedException
{
LOG("FILLER_BUILDING", "**************** TIME = " + getGameTime() + " ******************");
structure.resetFillerSpawns(self);
return SCRIPT_CONTINUE;
}
public int handleCleanupFillerSpawn(obj_id self, dictionary params) throws InterruptedException
{
structure.cleanupFillerSpawns(self);
return SCRIPT_CONTINUE;
}
}
@@ -1,55 +0,0 @@
/* Title: filler.script
* Description: script for filler buildings
*/
/***** INCLUDES ********************************************************/
include library.structure;
/***** CONSTANTS *******************************************************/
const string SCRIPT_ME = "structure.filler.filler";
const float DELAY_TIME = 5f;
const string HANDLER_INIT_FILLER_SPAWN = "handleInitFillerSpawn";
const string HANDLER_CLEANUP_FILLER_SPAWN = "handleCleanupFillerSpawn";
/***** TRIGGERS ********************************************************/
trigger OnInitialize()
{
// messageTo(self, HANDLER_INIT_FILLER_SPAWN, null, 5 + rand(0,10), true);
return SCRIPT_CONTINUE;
}
trigger OnDetach()
{
// messageTo(self, HANDLER_CLEANUP_FILLER_SPAWN, null, 0, true);
return SCRIPT_CONTINUE;
}
trigger OnUnloadedFromMemory()
{
// messageTo(self, HANDLER_CLEANUP_FILLER_SPAWN, null, 0, true);
return SCRIPT_CONTINUE;
}
trigger OnDestroy()
{
// messageTo(self, HANDLER_CLEANUP_FILLER_SPAWN, null, 0, true);
return SCRIPT_CONTINUE;
}
/***** MESSAGEHANDLERS *************************************************/
messageHandler handleInitFillerSpawn()
{
LOG("FILLER_BUILDING", "**************** TIME = " + getGameTime() + " ******************");
structure.resetFillerSpawns(self);
return SCRIPT_CONTINUE;
}
messageHandler handleCleanupFillerSpawn()
{
structure.cleanupFillerSpawns(self);
return SCRIPT_CONTINUE;
}
@@ -0,0 +1,32 @@
package script.structure;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
import script.library.player_structure;
public class hologram_control extends script.base_script
{
public hologram_control()
{
}
public int OnReceivedItem(obj_id self, obj_id srcContainer, obj_id transferer, obj_id item) throws InterruptedException
{
obj_id[] players = player_structure.getPlayersInBuilding(self);
if (players == null || players.length == 0)
{
return SCRIPT_CONTINUE;
}
if (players.length > 1)
{
return SCRIPT_CONTINUE;
}
broadcastMessage("handleActivateHolograms", new dictionary());
return SCRIPT_CONTINUE;
}
}
@@ -1,16 +0,0 @@
include library.player_structure;
trigger OnReceivedItem(obj_id srcContainer, obj_id transferer, obj_id item)
{
obj_id[] players = player_structure.getPlayersInBuilding(self);
if(players == null || players.length == 0)
return SCRIPT_CONTINUE;
if(players.length > 1)
return SCRIPT_CONTINUE;
broadcastMessage("handleActivateHolograms", new dictionary());
return SCRIPT_CONTINUE;
}
@@ -0,0 +1,84 @@
package script.structure;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
import script.library.utils;
public class house_container_lock extends script.base_script
{
public house_container_lock()
{
}
public static final string_id SID_LOCK_BAD_STRUCTURE = new string_id("spam", "sid_lock_bad_structure");
public static final string_id SID_LOCK_BAD_LOCK_TARGET = new string_id("spam", "sid_lock_bad_lock_target");
public static final string_id SID_LOCK_BAD_ALREADY_LOCKED = new string_id("spam", "sid_lock_bad_already_locked");
public static final string_id SID_LOCK_BAD_INVENTORY_LOCATION = new string_id("spam", "sid_lock_bad_inventory_location");
public static final string_id SID_LOCK_BAD_LOCK_CONTAINER = new string_id("spam", "sid_lock_bad_lock_container");
public static final string_id SID_LOCK_APPLIED = new string_id("spam", "sid_lock_applied");
public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info mi) throws InterruptedException
{
return SCRIPT_CONTINUE;
}
public int OnObjectMenuSelect(obj_id self, obj_id player, int item) throws InterruptedException
{
if (!isIdValid(player))
{
return SCRIPT_CONTINUE;
}
obj_id structure = getTopMostContainer(self);
obj_id containedBy = utils.getContainingPlayer(self);
if (!isIdValid(containedBy) || containedBy != player)
{
return SCRIPT_CONTINUE;
}
if (!isIdValid(structure) || !exists(structure) || structure == player || getOwner(structure) != player)
{
sendSystemMessage(player, SID_LOCK_BAD_STRUCTURE);
return SCRIPT_CONTINUE;
}
if (item == menu_info_types.ITEM_USE)
{
obj_id target = getIntendedTarget(player);
if (!isIdValid(target))
{
sendSystemMessage(player, SID_LOCK_BAD_LOCK_TARGET);
return SCRIPT_CONTINUE;
}
if (hasScript(target, "structure.locked_container"))
{
sendSystemMessage(player, SID_LOCK_BAD_ALREADY_LOCKED);
return SCRIPT_CONTINUE;
}
if (!isGameObjectTypeOf(target, GOT_misc_container) && !isGameObjectTypeOf(target, GOT_misc_container_wearable))
{
sendSystemMessage(player, SID_LOCK_BAD_LOCK_TARGET);
return SCRIPT_CONTINUE;
}
if (getOwner(target) != player)
{
sendSystemMessage(player, SID_LOCK_BAD_LOCK_TARGET);
return SCRIPT_CONTINUE;
}
setObjVar(target, "lock_owner", player);
setObjVar(target, "lock_owner_name", getName(player));
clearUserAccessList(target);
clearGuildAccessList(target);
addUserToAccessList(target, player);
attachScript(target, "structure.locked_container");
sendSystemMessage(player, SID_LOCK_APPLIED);
messageTo(self, "destroySelf", null, 1, true);
}
return SCRIPT_CONTINUE;
}
public int destroySelf(obj_id self, dictionary params) throws InterruptedException
{
destroyObject(self);
return SCRIPT_CONTINUE;
}
}
@@ -1,93 +0,0 @@
include library.utils;
const string_id SID_LOCK_BAD_STRUCTURE = new string_id("spam", "sid_lock_bad_structure");
const string_id SID_LOCK_BAD_LOCK_TARGET = new string_id("spam", "sid_lock_bad_lock_target");
const string_id SID_LOCK_BAD_ALREADY_LOCKED = new string_id("spam", "sid_lock_bad_already_locked");
const string_id SID_LOCK_BAD_INVENTORY_LOCATION = new string_id("spam", "sid_lock_bad_inventory_location");
const string_id SID_LOCK_BAD_LOCK_CONTAINER = new string_id("spam", "sid_lock_bad_lock_container");
const string_id SID_LOCK_APPLIED = new string_id("spam", "sid_lock_applied");
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
{
return SCRIPT_CONTINUE;
}
trigger OnObjectMenuSelect(obj_id player, int item)
{
if(!isIdValid(player))
{
return SCRIPT_CONTINUE;
}
// debugSpeakMsg(player, "OnObjectMenuSelect start");
obj_id structure = getTopMostContainer(self);
obj_id containedBy = utils.getContainingPlayer(self);
if(!isIdValid(containedBy) || containedBy != player)
{
return SCRIPT_CONTINUE;
}
if(!isIdValid(structure) || !exists(structure) || structure == player || getOwner(structure) != player)
{
sendSystemMessage(player, SID_LOCK_BAD_STRUCTURE);
return SCRIPT_CONTINUE;
}
// debugSpeakMsg(player, "OnObjectMenuSelect valid " + structure);
if(item == menu_info_types.ITEM_USE)
{
obj_id target = getIntendedTarget(player);
if(!isIdValid(target))
{
sendSystemMessage(player, SID_LOCK_BAD_LOCK_TARGET);
return SCRIPT_CONTINUE;
}
// If the container is already locked, don't do anything.
if(hasScript(target, "structure.locked_container"))
{
sendSystemMessage(player, SID_LOCK_BAD_ALREADY_LOCKED);
return SCRIPT_CONTINUE;
}
// If the target is not a container, this lock should not be applied to it.
if(!isGameObjectTypeOf(target, GOT_misc_container) && !isGameObjectTypeOf(target, GOT_misc_container_wearable))
{
sendSystemMessage(player, SID_LOCK_BAD_LOCK_TARGET);
return SCRIPT_CONTINUE;
}
// If the target is not yours, then it shouldn't be lockable by you.
if(getOwner(target) != player)
{
sendSystemMessage(player, SID_LOCK_BAD_LOCK_TARGET);
return SCRIPT_CONTINUE;
}
setObjVar(target, "lock_owner", player);
setObjVar(target, "lock_owner_name", getName(player));
clearUserAccessList(target);
clearGuildAccessList(target);
addUserToAccessList(target, player);
attachScript(target, "structure.locked_container");
sendSystemMessage(player, SID_LOCK_APPLIED);
messageTo(self, "destroySelf", null, 1, true);
}
return SCRIPT_CONTINUE;
}
messageHandler destroySelf()
{
destroyObject(self);
return SCRIPT_CONTINUE;
}
@@ -0,0 +1,218 @@
package script.structure;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
import script.library.utils;
import script.library.sui;
import script.library.player_structure;
import script.library.trace;
import script.player.base.base_player;
public class house_control_device extends script.base_script
{
public house_control_device()
{
}
public static final string_id UNPACK_HOUSE = new string_id("sui", "unpack_house");
public static final string_id SID_NO_PLACING_STRUCTURES_IN_SPACE = new string_id("space/space_interaction", "no_placing_structures_in_space");
public static final String IN_USE_OBJVAR = "house_redeed.inUse";
public int OnAttach(obj_id self) throws InterruptedException
{
setObjVar(self, "noTrade", 1);
return SCRIPT_CONTINUE;
}
public int OnInitialize(obj_id self) throws InterruptedException
{
setObjVar(self, "noTrade", 1);
removeObjVar(self, IN_USE_OBJVAR);
if (!hasObjVar(self, player_structure.VAR_DEED_SCENE))
{
obj_id[] contents = getContents(self);
if (contents != null && contents.length == 1)
{
obj_id structure = contents[0];
if (isIdValid(structure))
{
if (hasObjVar(structure, player_structure.VAR_DEED_SCENE))
{
setObjVar(self, player_structure.VAR_DEED_SCENE, player_structure.getDeedScene(structure));
}
}
}
}
if (hasObjVar(self, "player_structure.deed.scene"))
{
String deed_scene = getStringObjVar(self, "player_structure.deed.scene");
if (deed_scene != null && deed_scene.length() > 0)
{
if (deed_scene.equals("tatooine,lok,naboo,rori,dantooine,corellia,talus"))
{
CustomerServiceLog("playerStructure", "Deed " + self + " has had all invalid/old objvars removed.");
removeObjVar(self, "player_structure.deed.scene");
}
}
}
return SCRIPT_CONTINUE;
}
public int OnDestroy(obj_id self) throws InterruptedException
{
obj_id player = utils.getContainingPlayer(self);
trace.log("housepackup", "Structure control device " + self + ", contained by %TU has been destroyed.", player, trace.TL_CS_LOG);
return SCRIPT_CONTINUE;
}
public int OnLostItem(obj_id self, obj_id destContainer, obj_id transferer, obj_id item) throws InterruptedException
{
destroyObject(self);
return SCRIPT_CONTINUE;
}
public int OnGetAttributes(obj_id self, obj_id objPlayer, String[] strNames, String[] strAttribs) throws InterruptedException
{
int intIndex = utils.getValidAttributeIndex(strNames);
if (intIndex == -1)
{
return SCRIPT_CONTINUE;
}
String strName = getAssignedName(self);
if ((strName != null) && (!strName.equals("")))
{
strNames[intIndex] = "ship_name";
strAttribs[intIndex] = strName;
intIndex++;
}
if (hasObjVar(self, player_structure.VAR_DEED_SCENE))
{
String deed_scene = player_structure.getDeedScene(self);
java.util.StringTokenizer st = new java.util.StringTokenizer(deed_scene, ",");
while (st.hasMoreTokens())
{
String curScene = st.nextToken();
strNames[intIndex] = "examine_scene";
strAttribs[intIndex] = curScene;
intIndex++;
}
}
return SCRIPT_CONTINUE;
}
public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info mi) throws InterruptedException
{
if (!utils.isNestedWithin(self, player))
{
return SCRIPT_CONTINUE;
}
if (isDead(player) || isIncapacitated(player))
{
return SCRIPT_CONTINUE;
}
mi.addRootMenu(menu_info_types.SERVER_MENU9, UNPACK_HOUSE);
mi.addRootMenu(menu_info_types.SERVER_TERMINAL_MANAGEMENT_STATUS, new string_id("player_structure", "management_status"));
mi.addRootMenu(menu_info_types.SERVER_TERMINAL_MANAGEMENT_PAY, new string_id("player_structure", "management_pay"));
return SCRIPT_CONTINUE;
}
public int OnObjectMenuSelect(obj_id self, obj_id player, int item) throws InterruptedException
{
if (hasObjVar(self, "player_structure.deed.scene"))
{
String deed_scene = getStringObjVar(self, "player_structure.deed.scene");
if (deed_scene != null && deed_scene.length() > 0)
{
if (deed_scene.equals("tatooine,lok,naboo,rori,dantooine,corellia,talus"))
{
CustomerServiceLog("playerStructure", "Deed " + self + " has had all invalid/old objvars removed.");
removeObjVar(self, "player_structure.deed.scene");
}
}
}
if (!utils.isNestedWithin(self, player))
{
return SCRIPT_CONTINUE;
}
if (isDead(player) || isIncapacitated(player))
{
return SCRIPT_CONTINUE;
}
obj_id[] contents = getContents(self);
if (contents == null || contents.length != 1)
{
return SCRIPT_CONTINUE;
}
obj_id structure = contents[0];
if (item == menu_info_types.SERVER_MENU9)
{
if (isSpaceScene())
{
sendSystemMessage(player, SID_NO_PLACING_STRUCTURES_IN_SPACE);
return SCRIPT_CONTINUE;
}
queueCommand(player, (123886506), self, "", COMMAND_PRIORITY_DEFAULT);
}
else if (item == menu_info_types.SERVER_TERMINAL_MANAGEMENT_STATUS)
{
queueCommand(player, (335013253), structure, "", COMMAND_PRIORITY_DEFAULT);
}
else if (item == menu_info_types.SERVER_TERMINAL_MANAGEMENT_PAY)
{
queueCommand(player, (-404530384), structure, "", COMMAND_PRIORITY_DEFAULT);
}
return SCRIPT_CONTINUE;
}
public int OnAboutToBeTransferred(obj_id self, obj_id destContainer, obj_id transferer) throws InterruptedException
{
return SCRIPT_OVERRIDE;
}
public int OnPack(obj_id self, dictionary params) throws InterruptedException
{
obj_id[] contents = getContents(self);
if (contents == null || contents.length != 1)
{
return SCRIPT_CONTINUE;
}
obj_id structure = contents[0];
if (!isIdValid(structure))
{
return SCRIPT_CONTINUE;
}
String template = getTemplateName(structure);
if (template == null || template.equals(""))
{
return SCRIPT_CONTINUE;
}
String footprint_template = player_structure.getFootprintTemplate(template);
if (footprint_template == null || footprint_template.equals(""))
{
return SCRIPT_CONTINUE;
}
int idx = player_structure.getStructureTableIndex(template);
if (idx == -1)
{
return SCRIPT_CONTINUE;
}
int ignore_lots = dataTableGetInt(player_structure.PLAYER_STRUCTURE_DATATABLE, idx, player_structure.DATATABLE_COL_NO_LOT_REQ);
int struct_lots = 0;
if (ignore_lots != 1)
{
struct_lots = (player_structure.getNumberOfLots(footprint_template) / 4) - dataTableGetInt(player_structure.PLAYER_STRUCTURE_DATATABLE, idx, player_structure.DATATABLE_COL_LOT_REDUCTION);
if (struct_lots < 1)
{
struct_lots = 1;
}
}
obj_id player = utils.getContainingPlayer(self);
if (!isIdValid(player))
{
return SCRIPT_CONTINUE;
}
if (hasObjVar(player, base_player.CTS_LOT_COUNT))
{
struct_lots = struct_lots + getIntObjVar(player, base_player.CTS_LOT_COUNT);
}
CustomerServiceLog("CharacterTransfer", "setting lot count adjustment(" + self + ", " + struct_lots + ")");
setObjVar(player, base_player.CTS_LOT_COUNT, struct_lots);
return SCRIPT_CONTINUE;
}
}
@@ -1,240 +0,0 @@
include library.utils;
include library.sui;
include library.player_structure;
include library.trace;
include player.base.base_player;
const string_id UNPACK_HOUSE = new string_id("sui", "unpack_house");
const string_id SID_NO_PLACING_STRUCTURES_IN_SPACE = new string_id("space/space_interaction", "no_placing_structures_in_space");
const string IN_USE_OBJVAR = "house_redeed.inUse";
trigger OnAttach()
{
setObjVar(self, "noTrade", 1);
return SCRIPT_CONTINUE;
}
trigger OnInitialize()
{
setObjVar(self, "noTrade", 1);
removeObjVar(self, IN_USE_OBJVAR);
// add the scene restrictions if they are missing
if(!hasObjVar( self, player_structure.VAR_DEED_SCENE))
{
obj_id[] contents = getContents(self);
if(contents != null && contents.length == 1)
{
obj_id structure = contents[0];
if(isIdValid (structure))
{
if(hasObjVar(structure, player_structure.VAR_DEED_SCENE))
{
setObjVar(self, player_structure.VAR_DEED_SCENE, player_structure.getDeedScene(structure));
}
}
}
}
if(hasObjVar(self, "player_structure.deed.scene"))
{
string deed_scene = getStringObjVar( self, "player_structure.deed.scene" );
if (deed_scene != null && deed_scene.length() > 0)
{
//removed because harvesters no longer worked
if(deed_scene.equals("tatooine,lok,naboo,rori,dantooine,corellia,talus"))
{
CustomerServiceLog("playerStructure", "Deed " + self + " has had all invalid/old objvars removed.");
removeObjVar(self, "player_structure.deed.scene");
}
}
}
return SCRIPT_CONTINUE;
}
trigger OnDestroy()
{
obj_id player = utils.getContainingPlayer(self);
trace.log("housepackup", "Structure control device " + self + ", contained by %TU has been destroyed.", player, trace.TL_CS_LOG);
return SCRIPT_CONTINUE;
}
trigger OnLostItem(obj_id destContainer, obj_id transferer, obj_id item)
{
destroyObject(self);
return SCRIPT_CONTINUE;
}
trigger OnGetAttributes( obj_id objPlayer, string[] strNames, string[] strAttribs)
{
int intIndex= utils.getValidAttributeIndex(strNames);
if (intIndex==-1)
{
return SCRIPT_CONTINUE;
}
string strName = getAssignedName(self);
//LOG("space", "strName is "+strName);
if((strName!=null)&&(strName!=""))
{
strNames[intIndex] = "ship_name";
strAttribs[intIndex] = strName;
intIndex++;
}
if ( hasObjVar( self, player_structure.VAR_DEED_SCENE ) )
{
string deed_scene = player_structure.getDeedScene( self );
java.util.StringTokenizer st = new java.util.StringTokenizer( deed_scene, "," );
while ( st.hasMoreTokens() )
{
string curScene = st.nextToken();
strNames[intIndex] = "examine_scene";
strAttribs[intIndex] = curScene;
intIndex++;
}
}
return SCRIPT_CONTINUE;
}
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
{
if(!utils.isNestedWithin(self, player))
{
return SCRIPT_CONTINUE;
}
if(isDead(player) || isIncapacitated(player))
{
return SCRIPT_CONTINUE;
}
mi.addRootMenu(menu_info_types.SERVER_MENU9, UNPACK_HOUSE);
mi.addRootMenu(menu_info_types.SERVER_TERMINAL_MANAGEMENT_STATUS, new string_id("player_structure", "management_status"));
mi.addRootMenu(menu_info_types.SERVER_TERMINAL_MANAGEMENT_PAY, new string_id("player_structure", "management_pay"));
return SCRIPT_CONTINUE;
}
trigger OnObjectMenuSelect(obj_id player, int item)
{
if(hasObjVar(self, "player_structure.deed.scene"))
{
string deed_scene = getStringObjVar( self, "player_structure.deed.scene" );
if (deed_scene != null && deed_scene.length() > 0)
{
//removed because harvesters no longer worked
if(deed_scene.equals("tatooine,lok,naboo,rori,dantooine,corellia,talus"))
{
CustomerServiceLog("playerStructure", "Deed " + self + " has had all invalid/old objvars removed.");
removeObjVar(self, "player_structure.deed.scene");
}
}
}
if(!utils.isNestedWithin(self, player))
{
return SCRIPT_CONTINUE;
}
if(isDead(player) || isIncapacitated(player))
{
return SCRIPT_CONTINUE;
}
obj_id[] contents = getContents(self);
if(contents == null || contents.length != 1)
{
return SCRIPT_CONTINUE;
}
obj_id structure = contents[0];
if(item == menu_info_types.SERVER_MENU9) // Unpack House
{
if(isSpaceScene())
{
sendSystemMessage(player, SID_NO_PLACING_STRUCTURES_IN_SPACE);
return SCRIPT_CONTINUE;
}
queueCommand(player, ##"placeStructureMode", self, "", COMMAND_PRIORITY_DEFAULT);
}
else if(item == menu_info_types.SERVER_TERMINAL_MANAGEMENT_STATUS)
{
queueCommand(player, ##"structureStatus", structure, "", COMMAND_PRIORITY_DEFAULT);
}
else if (item == menu_info_types.SERVER_TERMINAL_MANAGEMENT_PAY)
{
queueCommand(player, ##"payMaintenance", structure, "", COMMAND_PRIORITY_DEFAULT);
}
return SCRIPT_CONTINUE;
}
trigger OnAboutToBeTransferred(obj_id destContainer, obj_id transferer)
{
return SCRIPT_OVERRIDE;
}
messageHandler OnPack()
{
// get the contained structure
obj_id[] contents = getContents(self);
if(contents == null || contents.length != 1)
{
return SCRIPT_CONTINUE;
}
obj_id structure = contents[0];
if(!isIdValid(structure))
return SCRIPT_CONTINUE;
// get the template of our contained house.
string template = getTemplateName(structure);
if(template == null || template == "")
return SCRIPT_CONTINUE;
// TODO: The code to get the number of lots should really be broken out of the
// player_structure.scriptlib "addStructure" call and be its own method.
// get the footprint template
string footprint_template = player_structure.getFootprintTemplate(template);
if(footprint_template == null || footprint_template=="")
return SCRIPT_CONTINUE;
// get the lot count for the footprint.
// Get our datatable entry index.
int idx = player_structure.getStructureTableIndex( template );
if ( idx == -1 )
return SCRIPT_CONTINUE; // no entry for the template.
int ignore_lots = dataTableGetInt( player_structure.PLAYER_STRUCTURE_DATATABLE, idx, player_structure.DATATABLE_COL_NO_LOT_REQ );
int struct_lots = 0;
if ( ignore_lots != 1 )
{
struct_lots = (player_structure.getNumberOfLots(footprint_template) / 4) - dataTableGetInt( player_structure.PLAYER_STRUCTURE_DATATABLE, idx, player_structure.DATATABLE_COL_LOT_REDUCTION );
if (struct_lots < 1)
struct_lots = 1;
}
// get our parent.
obj_id player = utils.getContainingPlayer(self);
if(!isIdValid(player))
return SCRIPT_CONTINUE;
// find out if he has the lot objvar
if(hasObjVar(player, base_player.CTS_LOT_COUNT))
{
// if so, increase its value by the number of lots that we contain.
struct_lots = struct_lots + getIntObjVar(player, base_player.CTS_LOT_COUNT);
}
// and set the lot count.
CustomerServiceLog("CharacterTransfer", "setting lot count adjustment(" + self + ", " + struct_lots + ")" );
setObjVar(player, base_player.CTS_LOT_COUNT, struct_lots);
return SCRIPT_CONTINUE;
}
@@ -0,0 +1,20 @@
package script.structure;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
public class item_structure extends script.base_script
{
public item_structure()
{
}
public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info mi) throws InterruptedException
{
return SCRIPT_CONTINUE;
}
}
@@ -1,13 +0,0 @@
/**********************************************************************
* Title: temporary_structure.script
* Description: script that handles the temporary player structure
**********************************************************************/
/***** TRIGGERS ********************************************************/
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
{
return SCRIPT_CONTINUE;
}
@@ -0,0 +1,377 @@
package script.structure;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
import script.library.sui;
import script.library.utils;
public class locked_container extends script.base_script
{
public locked_container()
{
}
public static final string_id SID_LOCK_MENU = new string_id("spam", "sid_lock_menu");
public static final string_id SID_MENU_REMOVE_LOCK = new string_id("spam", "sid_menu_lock_remove");
public static final string_id SID_MENU_ADD_ACCESS_PLAYER = new string_id("spam", "sid_menu_lock_add_player");
public static final string_id SID_MENU_REMOVE_ACCESS_PLAYER = new string_id("spam", "sid_menu_lock_remove_player");
public static final string_id SID_MENU_ADD_ACCESS_GUILD = new string_id("spam", "sid_menu_lock_add_guild");
public static final string_id SID_MENU_REMOVE_ACCESS_GUILD = new string_id("spam", "sid_menu_lock_remove_guild");
public static final string_id SID_LOCK_VIEW_ACCESS_LIST = new string_id("spam", "sid_menu_lock_view_access_list");
public static final string_id SID_LOCK_ADDED_PLAYER = new string_id("spam", "sid_lock_added_player");
public static final string_id SID_LOCK_ADDED_GUILD = new string_id("spam", "sid_lock_added_guild");
public static final string_id SID_LOCK_GUILD_ALREADY_ADDED = new string_id("spam", "sid_lock_guild_already_added");
public static final string_id SID_LOCK_REMOVED_PLAYER = new string_id("spam", "sid_lock_removed_player");
public static final string_id SID_LOCK_REMOVED_GUILD = new string_id("spam", "sid_lock_removed_guild");
public static final string_id SID_LOCK_GUILD_NOT_ADDED = new string_id("spam", "sid_lock_guild_not_added");
public static final string_id SID_LOCK_GUILD_NOT_FOUND = new string_id("spam", "sid_lock_guild_not_found");
public static final string_id SID_LOCK_REMOVED = new string_id("spam", "sid_lock_removed");
public static final String SID_SUI_ADD_PLAYER_PROMPT = "@spam:sid_sui_add_player_prompt";
public static final String SID_SUI_ADD_PLAYER_TITLE = "@spam:sid_sui_add_player_title";
public static final String SID_SUI_ADD_GUILD_PROMPT = "@spam:sid_sui_add_guild_prompt";
public static final String SID_SUI_ADD_GUILD_TITLE = "@spam:sid_sui_add_guild_title";
public static final String SID_SUI_REMOVE_GUILD_PROMPT = "@spam:sid_sui_remove_guild_prompt";
public static final String SID_SUI_REMOVE_GUILD_TITLE = "@spam:sid_sui_remove_guild_title";
public static final String SID_SUI_REMOVE_PLAYER_PROMPT = "@spam:sid_sui_remove_player_prompt";
public static final String SID_SUI_REMOVE_PLAYER_TITLE = "@spam:sid_sui_remove_player_title";
public static final String SID_SUI_LOCK_ACCESSORS_PROMPT = "@spam:sid_sui_lock_accessors_prompt";
public static final String SID_SUI_LOCK_ACCESSORS_TITLE = "@spam:sid_sui_lock_accessors_title";
public static final string_id SID_LOCK_ADD_ACCESSOR_NOT_FOUND = new string_id("spam", "sid_lock_add_accessor_not_found");
public static final string_id SID_LOCK_REMOVE_ACCESSOR_NOT_FOUND = new string_id("spam", "sid_lock_remove_accessor_not_found");
public static final String OBJVAR_PLAYER_ACCESS_LIST = "tangible_object.accessList";
public static final String OBJVAR_GUILD_ACCESS_LIST = "tangible_object.guildAccessList";
public void addGuildToAccess(obj_id container, int guildId) throws InterruptedException
{
if (!isIdValid(container) || !exists(container) || guildId == 0)
{
return;
}
addGuildToAccessList(container, guildId);
}
public void removeGuildFromAccess(obj_id container, int guildId) throws InterruptedException
{
if (!isIdValid(container) || !exists(container) || guildId == 0)
{
return;
}
removeGuildFromAccessList(container, guildId);
}
public void clearGuildAccess(obj_id container) throws InterruptedException
{
if (!isIdValid(container) || !exists(container))
{
return;
}
clearGuildAccessList(container);
}
public int[] getGuildAccess(obj_id container) throws InterruptedException
{
if (!isIdValid(container) || !exists(container))
{
return null;
}
return getIntArrayObjVar(container, OBJVAR_GUILD_ACCESS_LIST);
}
public void addPlayerToAccess(obj_id container, obj_id player) throws InterruptedException
{
if (!isIdValid(container) || !exists(container) || !isIdValid(player) || !exists(player))
{
return;
}
addUserToAccessList(container, player);
}
public void removePlayerFromAccess(obj_id container, obj_id player) throws InterruptedException
{
if (!isIdValid(container) || !exists(container) || !isIdValid(player) || !exists(player))
{
return;
}
removeUserFromAccessList(container, player);
}
public void clearPlayerAccess(obj_id container) throws InterruptedException
{
if (!isIdValid(container) || !exists(container))
{
return;
}
clearUserAccessList(container);
}
public obj_id[] getPlayerAccess(obj_id container) throws InterruptedException
{
if (!isIdValid(container) || !exists(container))
{
return null;
}
return getObjIdArrayObjVar(container, OBJVAR_PLAYER_ACCESS_LIST);
}
public int OnGetAttributes(obj_id self, obj_id player, String[] names, String[] attribs) throws InterruptedException
{
int idx = utils.getValidAttributeIndex(names);
if (idx == -1)
{
return SCRIPT_CONTINUE;
}
if (!exists(self))
{
return SCRIPT_CONTINUE;
}
String name = getStringObjVar(self, "lock_owner_name");
if (name != null && name.length() > 0)
{
names[idx] = "locked_by";
attribs[idx] = name;
idx++;
}
return SCRIPT_CONTINUE;
}
public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info mi) throws InterruptedException
{
obj_id lockedBy = getObjIdObjVar(self, "lock_owner");
if (isIdValid(lockedBy) && player == lockedBy)
{
int lockMenu = mi.addRootMenu(menu_info_types.SERVER_MENU1, SID_LOCK_MENU);
mi.addSubMenu(lockMenu, menu_info_types.SERVER_MENU2, SID_MENU_REMOVE_LOCK);
mi.addSubMenu(lockMenu, menu_info_types.SERVER_MENU3, SID_MENU_ADD_ACCESS_PLAYER);
obj_id[] accessors = getUserAccessList(self);
boolean anyAccess = false;
if (accessors != null && accessors.length > 0)
{
mi.addSubMenu(lockMenu, menu_info_types.SERVER_MENU4, SID_MENU_REMOVE_ACCESS_PLAYER);
anyAccess = true;
}
int guildId = getGuildId(player);
int[] guildsWithAccess = getGuildAccess(self);
if (guildsWithAccess != null && guildsWithAccess.length > 0)
{
anyAccess = true;
}
mi.addSubMenu(lockMenu, menu_info_types.SERVER_MENU5, SID_MENU_ADD_ACCESS_GUILD);
if (guildsWithAccess != null && guildsWithAccess.length > 0)
{
mi.addSubMenu(lockMenu, menu_info_types.SERVER_MENU6, SID_MENU_REMOVE_ACCESS_GUILD);
}
if (anyAccess)
{
mi.addSubMenu(lockMenu, menu_info_types.SERVER_MENU7, SID_LOCK_VIEW_ACCESS_LIST);
}
}
return SCRIPT_CONTINUE;
}
public int OnObjectMenuSelect(obj_id self, obj_id player, int item) throws InterruptedException
{
obj_id lockedBy = getObjIdObjVar(self, "lock_owner");
if (isIdValid(lockedBy) && player == lockedBy && item == menu_info_types.SERVER_MENU2)
{
obj_id container = utils.getInventoryContainer(player);
obj_id craftedItem = makeCraftedItem("object/draft_schematic/furniture/furniture_house_container_lock.iff", 100.0f, container);
if (isIdValid(craftedItem))
{
removeObjVar(self, "lock_owner");
removeObjVar(self, "lock_owner_name");
clearCondition(self, CONDITION_LOCKED);
clearPlayerAccess(self);
clearGuildAccess(self);
sendSystemMessage(player, SID_LOCK_REMOVED);
detachScript(self, "structure.locked_container");
}
return SCRIPT_CONTINUE;
}
if (isIdValid(lockedBy) && player == lockedBy && item == menu_info_types.SERVER_MENU3)
{
int pid = sui.inputbox(self, player, SID_SUI_ADD_PLAYER_PROMPT, sui.OK_CANCEL, SID_SUI_ADD_PLAYER_TITLE, sui.INPUT_NORMAL, null, "lockAddPlayer");
return SCRIPT_CONTINUE;
}
if (isIdValid(lockedBy) && player == lockedBy && item == menu_info_types.SERVER_MENU4)
{
int pid = sui.inputbox(self, player, SID_SUI_REMOVE_PLAYER_PROMPT, sui.OK_CANCEL, SID_SUI_REMOVE_PLAYER_TITLE, sui.INPUT_NORMAL, null, "lockRemovePlayer");
sendSystemMessage(player, SID_MENU_REMOVE_ACCESS_PLAYER);
return SCRIPT_CONTINUE;
}
int guildId = getGuildId(player);
int[] guildsWithAccess = getGuildAccess(self);
if (isIdValid(lockedBy) && player == lockedBy && item == menu_info_types.SERVER_MENU5)
{
int pid = sui.inputbox(self, player, SID_SUI_ADD_GUILD_PROMPT, sui.OK_CANCEL, SID_SUI_ADD_GUILD_TITLE, sui.INPUT_NORMAL, null, "lockAddGuild");
return SCRIPT_CONTINUE;
}
if (isIdValid(lockedBy) && player == lockedBy && guildsWithAccess != null && guildsWithAccess.length > 0 && item == menu_info_types.SERVER_MENU6)
{
int pid = sui.inputbox(self, player, SID_SUI_REMOVE_GUILD_PROMPT, sui.OK_CANCEL, SID_SUI_REMOVE_GUILD_TITLE, sui.INPUT_NORMAL, null, "lockRemoveGuild");
return SCRIPT_CONTINUE;
}
if (isIdValid(lockedBy) && player == lockedBy && item == menu_info_types.SERVER_MENU7)
{
obj_id[] accessors = getPlayerAccess(self);
Vector accessList = new Vector();
accessList.setSize(0);
int accessorsCount = 0;
if (accessors != null)
{
accessorsCount = accessors.length;
}
int guildsCount = 0;
if (guildsWithAccess != null)
{
guildsCount = guildsWithAccess.length;
}
if (guildsWithAccess != null && guildsWithAccess.length > 0)
{
for (int i = 0, j = guildsWithAccess.length; i < j; i++)
{
utils.addElement(accessList, "Guild: " + guildGetName(guildsWithAccess[i]));
}
}
if (accessors != null && accessors.length > 0)
{
for (int i = 0, j = accessors.length; i < j; i++)
{
if (isIdValid(accessors[i]))
{
utils.addElement(accessList, "" + getPlayerFullName(accessors[i]));
}
}
}
int pid = sui.listbox(player, player, SID_SUI_LOCK_ACCESSORS_PROMPT, sui.OK_CANCEL, SID_SUI_LOCK_ACCESSORS_TITLE, accessList, "onLockAccessList", false, true);
sui.showSUIPage(pid);
}
return SCRIPT_CONTINUE;
}
public int lockAddPlayer(obj_id self, dictionary params) throws InterruptedException
{
obj_id player = params.getObjId("player");
if (sui.getIntButtonPressed(params) == sui.BP_OK)
{
String accessorName = sui.getInputBoxText(params);
obj_id target = utils.getNearbyPlayerByName(player, accessorName);
if (!isIdValid(target))
{
target = getPlayerIdFromFirstName(accessorName);
}
if (isIdValid(target))
{
addPlayerToAccess(self, target);
sendSystemMessage(player, SID_LOCK_ADDED_PLAYER);
}
else
{
prose_package pp = new prose_package();
pp.actor.set(accessorName);
pp.stringId = SID_LOCK_ADD_ACCESSOR_NOT_FOUND;
sendSystemMessageProse(player, pp);
}
}
return SCRIPT_CONTINUE;
}
public int lockRemovePlayer(obj_id self, dictionary params) throws InterruptedException
{
obj_id player = params.getObjId("player");
obj_id lockedBy = getObjIdObjVar(self, "lock_owner");
if (sui.getIntButtonPressed(params) == sui.BP_OK)
{
String accessorName = sui.getInputBoxText(params);
obj_id target = utils.getNearbyPlayerByName(player, accessorName);
if (!isIdValid(target))
{
target = getPlayerIdFromFirstName(accessorName);
}
if (lockedBy == target)
{
return SCRIPT_CONTINUE;
}
if (isIdValid(target))
{
removePlayerFromAccess(self, target);
sendSystemMessage(player, SID_LOCK_REMOVED_PLAYER);
}
else
{
prose_package pp = new prose_package();
pp.actor.set(accessorName);
pp.stringId = SID_LOCK_REMOVE_ACCESSOR_NOT_FOUND;
sendSystemMessageProse(player, pp);
}
}
return SCRIPT_CONTINUE;
}
public int lockAddGuild(obj_id self, dictionary params) throws InterruptedException
{
obj_id player = params.getObjId("player");
if (sui.getIntButtonPressed(params) == sui.BP_OK)
{
String accessorName = sui.getInputBoxText(params);
int guildId = findGuild(accessorName);
if (guildId != 0)
{
int[] guildsOnContainer = getGuildAccess(self);
boolean addable = true;
if (guildsOnContainer != null && guildsOnContainer.length > 0)
{
for (int i = 0, j = guildsOnContainer.length; i < j; i++)
{
if (guildsOnContainer[i] == guildId)
{
addable = false;
}
}
}
if (addable)
{
addGuildToAccess(self, guildId);
sendSystemMessage(player, SID_LOCK_ADDED_GUILD);
}
else
{
sendSystemMessage(player, SID_LOCK_GUILD_ALREADY_ADDED);
}
}
else
{
sendSystemMessage(player, SID_LOCK_GUILD_NOT_FOUND);
}
}
return SCRIPT_CONTINUE;
}
public int lockRemoveGuild(obj_id self, dictionary params) throws InterruptedException
{
obj_id player = params.getObjId("player");
if (sui.getIntButtonPressed(params) == sui.BP_OK)
{
String accessorName = sui.getInputBoxText(params);
int guildId = findGuild(accessorName);
if (guildId != 0)
{
int[] guildsOnContainer = getGuildAccess(self);
boolean removable = false;
if (guildsOnContainer != null && guildsOnContainer.length > 0)
{
for (int i = 0, j = guildsOnContainer.length; i < j; i++)
{
if (guildsOnContainer[i] == guildId)
{
removable = true;
}
}
}
if (removable)
{
removeGuildFromAccess(self, guildId);
sendSystemMessage(player, SID_LOCK_REMOVED_GUILD);
}
else
{
sendSystemMessage(player, SID_LOCK_GUILD_NOT_ADDED);
}
}
else
{
sendSystemMessage(player, SID_LOCK_GUILD_NOT_FOUND);
}
}
return SCRIPT_CONTINUE;
}
}
@@ -1,505 +0,0 @@
include library.sui;
include library.utils;
const string_id SID_LOCK_MENU = new string_id("spam", "sid_lock_menu");
const string_id SID_MENU_REMOVE_LOCK = new string_id("spam", "sid_menu_lock_remove");
const string_id SID_MENU_ADD_ACCESS_PLAYER = new string_id("spam", "sid_menu_lock_add_player");
const string_id SID_MENU_REMOVE_ACCESS_PLAYER = new string_id("spam", "sid_menu_lock_remove_player");
const string_id SID_MENU_ADD_ACCESS_GUILD = new string_id("spam", "sid_menu_lock_add_guild");
const string_id SID_MENU_REMOVE_ACCESS_GUILD = new string_id("spam", "sid_menu_lock_remove_guild");
const string_id SID_LOCK_VIEW_ACCESS_LIST = new string_id("spam", "sid_menu_lock_view_access_list");
const string_id SID_LOCK_ADDED_PLAYER = new string_id("spam", "sid_lock_added_player");
const string_id SID_LOCK_ADDED_GUILD = new string_id("spam", "sid_lock_added_guild");
const string_id SID_LOCK_GUILD_ALREADY_ADDED = new string_id("spam", "sid_lock_guild_already_added");
const string_id SID_LOCK_REMOVED_PLAYER = new string_id("spam", "sid_lock_removed_player");
const string_id SID_LOCK_REMOVED_GUILD = new string_id("spam", "sid_lock_removed_guild");
const string_id SID_LOCK_GUILD_NOT_ADDED = new string_id("spam", "sid_lock_guild_not_added");
const string_id SID_LOCK_GUILD_NOT_FOUND = new string_id("spam", "sid_lock_guild_not_found");
const string_id SID_LOCK_REMOVED = new string_id("spam", "sid_lock_removed");
const string SID_SUI_ADD_PLAYER_PROMPT = "@spam:sid_sui_add_player_prompt";
const string SID_SUI_ADD_PLAYER_TITLE = "@spam:sid_sui_add_player_title";
const string SID_SUI_ADD_GUILD_PROMPT = "@spam:sid_sui_add_guild_prompt";
const string SID_SUI_ADD_GUILD_TITLE = "@spam:sid_sui_add_guild_title";
const string SID_SUI_REMOVE_GUILD_PROMPT = "@spam:sid_sui_remove_guild_prompt";
const string SID_SUI_REMOVE_GUILD_TITLE = "@spam:sid_sui_remove_guild_title";
const string SID_SUI_REMOVE_PLAYER_PROMPT = "@spam:sid_sui_remove_player_prompt";
const string SID_SUI_REMOVE_PLAYER_TITLE = "@spam:sid_sui_remove_player_title";
const string SID_SUI_LOCK_ACCESSORS_PROMPT = "@spam:sid_sui_lock_accessors_prompt";
const string SID_SUI_LOCK_ACCESSORS_TITLE = "@spam:sid_sui_lock_accessors_title";
const string_id SID_LOCK_ADD_ACCESSOR_NOT_FOUND = new string_id("spam", "sid_lock_add_accessor_not_found");
const string_id SID_LOCK_REMOVE_ACCESSOR_NOT_FOUND = new string_id("spam", "sid_lock_remove_accessor_not_found");
const string OBJVAR_PLAYER_ACCESS_LIST = "tangible_object.accessList";
const string OBJVAR_GUILD_ACCESS_LIST = "tangible_object.guildAccessList";
void addGuildToAccess(obj_id container, int guildId)
{
if(!isIdValid(container) || !exists(container) || guildId == 0)
{
return;
}
addGuildToAccessList(container, guildId);
}
void removeGuildFromAccess(obj_id container, int guildId)
{
if(!isIdValid(container) || !exists(container) || guildId == 0)
{
return;
}
removeGuildFromAccessList(container, guildId);
}
void clearGuildAccess(obj_id container)
{
if(!isIdValid(container) || !exists(container))
{
return;
}
clearGuildAccessList(container);
}
int [] getGuildAccess(obj_id container)
{
if(!isIdValid(container) || !exists(container))
{
return null;
}
return getIntArrayObjVar(container, OBJVAR_GUILD_ACCESS_LIST);
}
void addPlayerToAccess(obj_id container, obj_id player)
{
if(!isIdValid(container) || !exists(container) || !isIdValid(player) || !exists(player))
{
return;
}
addUserToAccessList(container, player);
}
void removePlayerFromAccess(obj_id container, obj_id player)
{
if(!isIdValid(container) || !exists(container) || !isIdValid(player) || !exists(player))
{
return;
}
removeUserFromAccessList(container, player);
}
void clearPlayerAccess(obj_id container)
{
if(!isIdValid(container) || !exists(container))
{
return;
}
clearUserAccessList(container);
}
obj_id [] getPlayerAccess(obj_id container)
{
if(!isIdValid(container) || !exists(container))
{
return null;
}
return getObjIdArrayObjVar(container, OBJVAR_PLAYER_ACCESS_LIST);
}
trigger OnGetAttributes(obj_id player, string[] names, string[] attribs)
{
int idx = utils.getValidAttributeIndex(names);
if(idx == -1)
return SCRIPT_CONTINUE;
if(!exists(self))
{
return SCRIPT_CONTINUE;
}
string name = getStringObjVar(self, "lock_owner_name");
if(name != null && name.length() > 0)
{
names[idx] = "locked_by";
attribs[idx] = name;
idx++;
}
return SCRIPT_CONTINUE;
}
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
{
obj_id lockedBy = getObjIdObjVar(self, "lock_owner");
if(isIdValid(lockedBy) && player == lockedBy)
{
int lockMenu = mi.addRootMenu(menu_info_types.SERVER_MENU1, SID_LOCK_MENU);
mi.addSubMenu(lockMenu, menu_info_types.SERVER_MENU2, SID_MENU_REMOVE_LOCK); // TODO: Add confirmation
mi.addSubMenu(lockMenu, menu_info_types.SERVER_MENU3, SID_MENU_ADD_ACCESS_PLAYER);
obj_id [] accessors = getUserAccessList(self);
boolean anyAccess = false;
if(accessors != null && accessors.length > 0)
{
mi.addSubMenu(lockMenu, menu_info_types.SERVER_MENU4, SID_MENU_REMOVE_ACCESS_PLAYER);
anyAccess = true;
}
int guildId = getGuildId(player);
int [] guildsWithAccess = getGuildAccess(self);
if(guildsWithAccess != null && guildsWithAccess.length > 0)
{
anyAccess = true;
}
// Player is in a guild, but no guilds have access to this container. The player may add access.
mi.addSubMenu(lockMenu, menu_info_types.SERVER_MENU5, SID_MENU_ADD_ACCESS_GUILD);
// Player may or may not be in a guild, but a guild does have access. The player may remove access.
if(guildsWithAccess != null && guildsWithAccess.length > 0)
{
mi.addSubMenu(lockMenu, menu_info_types.SERVER_MENU6, SID_MENU_REMOVE_ACCESS_GUILD);
}
if(anyAccess)
{
mi.addSubMenu(lockMenu, menu_info_types.SERVER_MENU7, SID_LOCK_VIEW_ACCESS_LIST);
}
}
return SCRIPT_CONTINUE;
}
trigger OnObjectMenuSelect(obj_id player, int item)
{
// debugSpeakMsg(player, "locked_container OnObjectMenuSelect");
obj_id lockedBy = getObjIdObjVar(self, "lock_owner");
if(isIdValid(lockedBy) && player == lockedBy && item == menu_info_types.SERVER_MENU2)
{
obj_id container = utils.getInventoryContainer(player);
// TODO: Check inventory capacity and deny if it is too full.
obj_id craftedItem = makeCraftedItem("object/draft_schematic/furniture/furniture_house_container_lock.iff", 100.0f, container);
if(isIdValid(craftedItem))
{
removeObjVar(self, "lock_owner");
removeObjVar(self, "lock_owner_name");
clearCondition(self, CONDITION_LOCKED);
clearPlayerAccess(self);
clearGuildAccess(self);
sendSystemMessage(player, SID_LOCK_REMOVED);
detachScript(self, "structure.locked_container");
}
return SCRIPT_CONTINUE;
}
if(isIdValid(lockedBy) && player == lockedBy && item == menu_info_types.SERVER_MENU3)
{
int pid = sui.inputbox(
self,
player,
SID_SUI_ADD_PLAYER_PROMPT,
sui.OK_CANCEL,
SID_SUI_ADD_PLAYER_TITLE,
sui.INPUT_NORMAL,
null,
"lockAddPlayer");
return SCRIPT_CONTINUE;
}
if(isIdValid(lockedBy) && player == lockedBy && item == menu_info_types.SERVER_MENU4)
{
int pid = sui.inputbox(
self,
player,
SID_SUI_REMOVE_PLAYER_PROMPT,
sui.OK_CANCEL,
SID_SUI_REMOVE_PLAYER_TITLE,
sui.INPUT_NORMAL,
null,
"lockRemovePlayer");
sendSystemMessage(player, SID_MENU_REMOVE_ACCESS_PLAYER);
return SCRIPT_CONTINUE;
}
int guildId = getGuildId(player);
int [] guildsWithAccess = getGuildAccess(self);
// Player is in a guild, but no guilds have access to this container. The player may add access.
if(isIdValid(lockedBy) && player == lockedBy && item == menu_info_types.SERVER_MENU5)
{
int pid = sui.inputbox(
self,
player,
SID_SUI_ADD_GUILD_PROMPT,
sui.OK_CANCEL,
SID_SUI_ADD_GUILD_TITLE,
sui.INPUT_NORMAL,
null,
"lockAddGuild");
return SCRIPT_CONTINUE;
}
// Player may or may not be in a guild, but a guild does have access. The player may remove access.
if(isIdValid(lockedBy) && player == lockedBy && guildsWithAccess != null && guildsWithAccess.length > 0 && item == menu_info_types.SERVER_MENU6)
{
int pid = sui.inputbox(
self,
player,
SID_SUI_REMOVE_GUILD_PROMPT,
sui.OK_CANCEL,
SID_SUI_REMOVE_GUILD_TITLE,
sui.INPUT_NORMAL,
null,
"lockRemoveGuild");
return SCRIPT_CONTINUE;
}
if(isIdValid(lockedBy) && player == lockedBy && item == menu_info_types.SERVER_MENU7)
{
obj_id [] accessors = getPlayerAccess(self);
resizeable string [] accessList = new string[0];
int accessorsCount = 0;
if(accessors != null)
{
accessorsCount = accessors.length;
}
int guildsCount = 0;
if(guildsWithAccess != null)
{
guildsCount = guildsWithAccess.length;
}
// debugSpeakMsg(player, "accessors: " + accessorsCount + " guilds: " + guildsCount);
if(guildsWithAccess != null && guildsWithAccess.length > 0)
{
for(int i = 0, j = guildsWithAccess.length; i < j; i++)
{
utils.addElement(accessList, "Guild: " + guildGetName(guildsWithAccess[i]));
}
}
if(accessors != null && accessors.length > 0)
{
for(int i = 0, j = accessors.length; i < j; i++)
{
if(isIdValid(accessors[i]))
{
utils.addElement(accessList, "" + getPlayerFullName(accessors[i]));
}
}
}
// debugSpeakMsg(player, "accessList size: " + accessList.length);
int pid = sui.listbox(player, player, SID_SUI_LOCK_ACCESSORS_PROMPT, sui.OK_CANCEL, SID_SUI_LOCK_ACCESSORS_TITLE, accessList, "onLockAccessList", false, true);
sui.showSUIPage(pid);
}
return SCRIPT_CONTINUE;
}
messageHandler lockAddPlayer()
{
obj_id player = params.getObjId("player");
if(sui.getIntButtonPressed(params) == sui.BP_OK)
{
string accessorName = sui.getInputBoxText(params);
obj_id target = utils.getNearbyPlayerByName(player, accessorName);
if(!isIdValid(target))
{
target = getPlayerIdFromFirstName(accessorName);
}
// debugSpeakMsg(player, "Name added: " + accessorName + " object: " + target);
if(isIdValid(target))
{
addPlayerToAccess(self, target);
sendSystemMessage(player, SID_LOCK_ADDED_PLAYER);
}
else
{
prose_package pp = new prose_package();
pp.actor.set(accessorName);
pp.stringId = SID_LOCK_ADD_ACCESSOR_NOT_FOUND;
sendSystemMessageProse(player, pp);
}
}
return SCRIPT_CONTINUE;
}
messageHandler lockRemovePlayer()
{
obj_id player = params.getObjId("player");
obj_id lockedBy = getObjIdObjVar(self, "lock_owner");
if(sui.getIntButtonPressed(params) == sui.BP_OK)
{
string accessorName = sui.getInputBoxText(params);
obj_id target = utils.getNearbyPlayerByName(player, accessorName);
if(!isIdValid(target))
{
target = getPlayerIdFromFirstName(accessorName);
}
// debugSpeakMsg(player, "Name removed: " + accessorName + " object: " + target);
if(lockedBy == target)
{
return SCRIPT_CONTINUE;
}
if(isIdValid(target))
{
removePlayerFromAccess(self, target);
sendSystemMessage(player, SID_LOCK_REMOVED_PLAYER);
}
else
{
prose_package pp = new prose_package();
pp.actor.set(accessorName);
pp.stringId = SID_LOCK_REMOVE_ACCESSOR_NOT_FOUND;
sendSystemMessageProse(player, pp);
}
}
return SCRIPT_CONTINUE;
}
messageHandler lockAddGuild()
{
obj_id player = params.getObjId("player");
if(sui.getIntButtonPressed(params) == sui.BP_OK)
{
string accessorName = sui.getInputBoxText(params);
int guildId = findGuild(accessorName);
if(guildId != 0)
{
int [] guildsOnContainer = getGuildAccess(self);
boolean addable = true;
if(guildsOnContainer != null && guildsOnContainer.length > 0)
{
for(int i = 0, j = guildsOnContainer.length; i < j; i++)
{
// We do not want to add the same guild to the container repeatedly.
if(guildsOnContainer[i] == guildId)
{
addable = false;
}
}
}
if(addable)
{
addGuildToAccess(self, guildId);
sendSystemMessage(player, SID_LOCK_ADDED_GUILD);
}
else
{
// Already on container.
sendSystemMessage(player, SID_LOCK_GUILD_ALREADY_ADDED);
}
}
else
{
sendSystemMessage(player, SID_LOCK_GUILD_NOT_FOUND);
}
}
return SCRIPT_CONTINUE;
}
messageHandler lockRemoveGuild()
{
obj_id player = params.getObjId("player");
if(sui.getIntButtonPressed(params) == sui.BP_OK)
{
string accessorName = sui.getInputBoxText(params);
int guildId = findGuild(accessorName);
if(guildId != 0)
{
int [] guildsOnContainer = getGuildAccess(self);
boolean removable = false;
if(guildsOnContainer != null && guildsOnContainer.length > 0)
{
for(int i = 0, j = guildsOnContainer.length; i < j; i++)
{
// We do not want to add the same guild to the container repeatedly.
if(guildsOnContainer[i] == guildId)
{
removable = true;
}
}
}
if(removable)
{
removeGuildFromAccess(self, guildId);
sendSystemMessage(player, SID_LOCK_REMOVED_GUILD);
}
else
{
// Not on container.
sendSystemMessage(player, SID_LOCK_GUILD_NOT_ADDED);
}
}
else
{
sendSystemMessage(player, SID_LOCK_GUILD_NOT_FOUND);
}
}
return SCRIPT_CONTINUE;
}
@@ -0,0 +1,21 @@
package script.structure;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
public class make_private extends script.base_script
{
public make_private()
{
}
public int OnInitialize(obj_id self) throws InterruptedException
{
permissionsMakePrivate(self);
return SCRIPT_CONTINUE;
}
}
@@ -1,5 +0,0 @@
trigger OnInitialize()
{
permissionsMakePrivate (self);
return SCRIPT_CONTINUE;
}
@@ -0,0 +1,373 @@
package script.structure.manufacture;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
import script.library.player_structure;
import script.library.craftinglib;
import script.library.prose;
import script.library.sui;
public class manufacture extends script.base_script
{
public manufacture()
{
}
public static final String SCRIPT_ME = "structure.manufacture.manufacture";
public static final string_id SID_FACTORY_OPTIONS = new string_id("manf_station", "options");
public static final string_id SID_SCHEMATIC = new string_id("manf_station", "schematic");
public static final string_id SID_FACTORY_EXAMINE_PROMPT = new string_id("manf_station", "examine_prompt");
public static final string_id SID_ACTIVATE = new string_id("manf_station", "activate");
public static final string_id SID_DEACTIVATE = new string_id("manf_station", "deactivate");
public static final string_id SID_INPUT_HOPPER = new string_id("manf_station", "input_hopper");
public static final string_id SID_OUTPUT_HOPPER = new string_id("manf_station", "output_hopper");
public static final string_id SID_SCHEMATIC_ADDED = new string_id("manf_station", "schematic_added");
public static final string_id SID_SCHEMATIC_NOT_ADDED = new string_id("manf_station", "schematic_not_added");
public static final string_id SID_SCHEMATIC_REMOVED = new string_id("manf_station", "schematic_removed");
public static final string_id SID_SCHEMATIC_NOT_REMOVED = new string_id("manf_station", "schematic_not_removed");
public static final string_id SID_INGREDIENTS = new string_id("manf_station", "ingredients");
public static final string_id SID_STATION_ACTIVATED = new string_id("manf_station", "activated");
public static final string_id SID_STATION_DEACTIVATED = new string_id("manf_station", "deactivated");
public static final string_id SID_NO_VALID_SCHEMATIC = new string_id("manf_station", "no_valid_schematic");
public static final String HANDLER_UPDATE_SCHEMATIC = "handleUpdateSchematic";
public static final String OBJVAR_SCHEMATICS = "crafting.schematics";
public int OnInitialize(obj_id self) throws InterruptedException
{
removeObjVar(self, OBJVAR_SCHEMATICS);
String template = getTemplateName(self);
if (template != null && template.indexOf("weapon_factory.iff") >= 0)
{
int craftingType = getIntObjVar(self, craftinglib.OBJVAR_CRAFTING_TYPE);
craftingType &= ~CT_genericItem;
craftingType |= CT_misc;
craftingType |= CT_space;
craftingType |= CT_reverseEngineering;
setObjVar(self, craftinglib.OBJVAR_CRAFTING_TYPE, craftingType);
}
return SCRIPT_CONTINUE;
}
public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info mi) throws InterruptedException
{
if (!isIdValid(player))
{
return SCRIPT_CONTINUE;
}
if (player_structure.isStructureCondemned(self) && player_structure.isOwner(player, self))
{
player_structure.doCondemnedSui(self, player);
return SCRIPT_OVERRIDE;
}
boolean canAccess = player_structure.canHopper(self, player) || player_structure.isAdmin(self, player);
int mnu;
menu_info_data mid = mi.getMenuItemByType(menu_info_types.EXAMINE);
if (mid == null)
{
mnu = mi.addRootMenu(menu_info_types.EXAMINE, new string_id("", ""));
}
else
{
mid.setServerNotify(true);
}
mnu = mi.addRootMenu(menu_info_types.SERVER_ITEM_OPTIONS, SID_FACTORY_OPTIONS);
int id;
if (isHarvesterActive(self))
{
id = mi.addSubMenu(mnu, menu_info_types.ITEM_DEACTIVATE, SID_DEACTIVATE);
if (id != 0 && !canAccess)
{
(mi.getMenuItemById(id)).setEnabled(false);
}
}
else
{
String stationSchematic = getManufactureStationSchematic(self);
if (stationSchematic != null)
{
id = mi.addSubMenu(mnu, menu_info_types.ITEM_ACTIVATE, SID_ACTIVATE);
if (id != 0 && !canAccess)
{
(mi.getMenuItemById(id)).setEnabled(false);
}
id = mi.addSubMenu(mnu, menu_info_types.SERVER_HARVEST_CORPSE, SID_INGREDIENTS);
if (id != 0 && !canAccess)
{
(mi.getMenuItemById(id)).setEnabled(false);
}
}
if (stationSchematic != null || hasValidManufactureSchematicsForStation(player, self))
{
id = mi.addSubMenu(mnu, menu_info_types.SERVER_MANF_STATION_SCHEMATIC, SID_SCHEMATIC);
if (id != 0 && !canAccess)
{
(mi.getMenuItemById(id)).setEnabled(false);
}
}
else
{
sendSystemMessage(player, SID_NO_VALID_SCHEMATIC);
}
id = mi.addSubMenu(mnu, menu_info_types.SERVER_MANF_HOPPER_INPUT, SID_INPUT_HOPPER);
if (id != 0 && !canAccess)
{
(mi.getMenuItemById(id)).setEnabled(false);
}
id = mi.addSubMenu(mnu, menu_info_types.SERVER_MANF_HOPPER_OUTPUT, SID_OUTPUT_HOPPER);
if (id != 0 && !canAccess)
{
(mi.getMenuItemById(id)).setEnabled(false);
}
}
return SCRIPT_CONTINUE;
}
public int OnObjectMenuSelect(obj_id self, obj_id player, int item) throws InterruptedException
{
if (!isIdValid(player))
{
return SCRIPT_CONTINUE;
}
if (player_structure.isStructureCondemned(self))
{
player_structure.doCondemnedSui(self, player);
return SCRIPT_CONTINUE;
}
boolean canAccess = player_structure.canHopper(self, player) || player_structure.isAdmin(self, player);
if (!canAccess)
{
return SCRIPT_CONTINUE;
}
if (item == menu_info_types.SERVER_HARVEST_CORPSE)
{
if (getManufactureStationSchematic(self) != null)
{
String[][] ingredients = new String[1][];
ingredients[0] = null;
getIngredientsForManufactureStation(self, ingredients);
String prompt = getString(SID_FACTORY_EXAMINE_PROMPT);
if (ingredients[0] != null)
{
sui.listbox(player, prompt, ingredients[0]);
}
else
{
}
}
}
else if (item == menu_info_types.ITEM_ACTIVATE || (item == menu_info_types.ITEM_USE && !isHarvesterActive(self)))
{
activate(self);
if (isHarvesterActive(self))
{
prose_package pp = prose.getPackage(SID_STATION_ACTIVATED, self);
if (pp != null)
{
sendSystemMessageProse(player, pp);
}
}
}
else if (item == menu_info_types.ITEM_DEACTIVATE || (item == menu_info_types.ITEM_USE && isHarvesterActive(self)))
{
deactivate(self);
if (!isHarvesterActive(self))
{
prose_package pp = prose.getPackage(SID_STATION_DEACTIVATED, self);
if (pp != null)
{
sendSystemMessageProse(player, pp);
}
}
}
else if (item == menu_info_types.SERVER_MANF_HOPPER_INPUT)
{
obj_id inputHopper = getManufactureStationInputHopper(self);
if (inputHopper != null)
{
queueCommand(player, (1880585606), inputHopper, "", COMMAND_PRIORITY_DEFAULT);
}
}
else if (item == menu_info_types.SERVER_MANF_HOPPER_OUTPUT || item == menu_info_types.SERVER_ITEM_OPTIONS)
{
obj_id outputHopper = getManufactureStationOutputHopper(self);
if (outputHopper != null)
{
queueCommand(player, (1880585606), outputHopper, "", COMMAND_PRIORITY_DEFAULT);
}
}
else if (item == menu_info_types.SERVER_MANF_STATION_SCHEMATIC)
{
String currentSchematicName = getManufactureStationSchematic(self);
if (currentSchematicName != null)
{
int markerPos = currentSchematicName.indexOf('*');
if (markerPos >= 0)
{
currentSchematicName = currentSchematicName.substring(markerPos + 1);
}
}
else
{
currentSchematicName = "";
}
String prompt = "Current schematic installed: " + currentSchematicName;
String[][] schematics = new String[1][];
schematics[0] = null;
getValidManufactureSchematicsForStation(player, self, schematics);
if (schematics[0] != null)
{
String[] schematicIds = new String[schematics[0].length];
for (int i = 0; i < schematicIds.length; ++i)
{
int markerPos = schematics[0][i].indexOf('*');
if (markerPos >= 0)
{
schematicIds[i] = schematics[0][i].substring(0, markerPos);
schematics[0][i] = schematics[0][i].substring(markerPos + 1);
}
else
{
String err = "ERROR " + (getClass()).getName() + ".OnObjectMenuSelect: handling SERVER_HARVESTER_MANAGE " + "schematics for player " + player + " returned invalid schematic string <" + schematics[0][i] + ">";
debugServerConsoleMsg(null, err);
LOG("crafting", err);
schematicIds[i] = "";
schematics[0][i] = "";
}
}
if (schematicIds.length > 0)
{
setObjVar(self, OBJVAR_SCHEMATICS, schematicIds);
}
else
{
removeObjVar(self, OBJVAR_SCHEMATICS);
}
int pid = -1;
if (schematics[0].length > 0)
{
pid = sui.listbox(self, player, prompt, sui.OK_CANCEL, sui.DEFAULT_TITLE, schematics[0], HANDLER_UPDATE_SCHEMATIC, false);
}
else
{
pid = sui.emptylistbox(self, player, prompt, sui.OK_CANCEL, sui.DEFAULT_TITLE, HANDLER_UPDATE_SCHEMATIC, false);
}
if (pid == -1)
{
LOG("crafting", "Error creating schematic listbox");
}
else
{
if (!currentSchematicName.equals(""))
{
sui.listboxUseOtherButton(pid, "@remove_schematic");
}
sui.setSUIProperty(pid, sui.LISTBOX_BTN_OK, sui.PROP_TEXT, "@use_schematic");
sui.showSUIPage(pid);
}
}
}
return SCRIPT_CONTINUE;
}
public int handleUpdateSchematic(obj_id self, dictionary params) throws InterruptedException
{
String[] schematicIds = getStringArrayObjVar(self, OBJVAR_SCHEMATICS);
removeObjVar(self, OBJVAR_SCHEMATICS);
if ((params == null) || (params.isEmpty()))
{
return SCRIPT_CONTINUE;
}
obj_id player = sui.getPlayerId(params);
int bp = sui.getIntButtonPressed(params);
switch (bp)
{
case sui.BP_CANCEL:
return SCRIPT_CONTINUE;
case sui.BP_REVERT:
{
if (sui.getListboxOtherButtonPressed(params) == true)
{
removeSchematicFromStation(self, player);
return SCRIPT_CONTINUE;
}
}
}
if (schematicIds == null)
{
return SCRIPT_CONTINUE;
}
int idx = sui.getListboxSelectedRow(params);
if (idx < 0)
{
return SCRIPT_CONTINUE;
}
else if (idx >= schematicIds.length)
{
String err = "ERROR " + (getClass()).getName() + ".handleUpdateSchematic: bad index " + idx + " chosen for schematic list of length " + schematicIds.length;
debugServerConsoleMsg(null, err);
LOG("crafting", err);
}
else if (schematicIds[idx] == null || schematicIds[idx].length() == 0)
{
String err = "ERROR " + (getClass()).getName() + ".handleUpdateSchematic: null/empty schematic id at index " + idx;
debugServerConsoleMsg(null, err);
LOG("crafting", err);
}
else
{
removeSchematicFromStation(self, player);
prose_package pp = null;
obj_id schematic = obj_id.getObjId(Long.parseLong(schematicIds[idx]));
if (schematic == null || schematic == obj_id.NULL_ID)
{
String err = "ERROR " + (getClass()).getName() + ".handleUpdateSchematic: schematic id " + schematicIds[idx] + "at index " + idx + " gives an invalid obj_id";
debugServerConsoleMsg(null, err);
LOG("crafting", err);
}
else
{
if (transferManufactureSchematicToStation(schematic, self))
{
pp = prose.getPackage(SID_SCHEMATIC_ADDED, schematic);
}
else
{
pp = prose.getPackage(SID_SCHEMATIC_NOT_ADDED, schematic);
}
}
if (pp != null)
{
sendSystemMessageProse(player, pp);
}
}
return SCRIPT_CONTINUE;
}
public boolean removeSchematicFromStation(obj_id station, obj_id player) throws InterruptedException
{
prose_package pp = null;
String schematicName = getManufactureStationSchematic(station);
boolean transferred = transferManufactureSchematicToPlayer(station, player);
if (schematicName != null && schematicName.length() > 0)
{
obj_id schematicId = obj_id.getObjId(Long.valueOf(schematicName.substring(0, schematicName.indexOf('*'))));
if (isIdValid(schematicId))
{
if (transferred)
{
pp = prose.getPackage(SID_SCHEMATIC_REMOVED, schematicId);
}
else
{
pp = prose.getPackage(SID_SCHEMATIC_NOT_REMOVED, schematicId);
}
}
}
if (pp != null)
{
sendSystemMessageProse(player, pp);
}
return transferred;
}
}
@@ -1,391 +0,0 @@
/**
* Title: manufacture.script
* Description: script for manufacturing installations
*/
/***** INCLUDES ********************************************************/
include library.player_structure;
include library.craftinglib;
include library.prose;
include library.sui;
/***** CONSTANTS *******************************************************/
const string SCRIPT_ME = "structure.manufacture.manufacture";
const string_id SID_FACTORY_OPTIONS = new string_id("manf_station","options");
const string_id SID_SCHEMATIC = new string_id("manf_station","schematic");
const string_id SID_FACTORY_EXAMINE_PROMPT = new string_id("manf_station","examine_prompt");
const string_id SID_ACTIVATE = new string_id("manf_station","activate");
const string_id SID_DEACTIVATE = new string_id("manf_station","deactivate");
const string_id SID_INPUT_HOPPER = new string_id("manf_station","input_hopper");
const string_id SID_OUTPUT_HOPPER = new string_id("manf_station","output_hopper");
const string_id SID_SCHEMATIC_ADDED = new string_id("manf_station","schematic_added");
const string_id SID_SCHEMATIC_NOT_ADDED = new string_id("manf_station","schematic_not_added");
const string_id SID_SCHEMATIC_REMOVED = new string_id("manf_station","schematic_removed");
const string_id SID_SCHEMATIC_NOT_REMOVED = new string_id("manf_station","schematic_not_removed");
const string_id SID_INGREDIENTS = new string_id("manf_station","ingredients");
const string_id SID_STATION_ACTIVATED = new string_id("manf_station","activated");
const string_id SID_STATION_DEACTIVATED = new string_id("manf_station","deactivated");
const string_id SID_NO_VALID_SCHEMATIC = new string_id("manf_station", "no_valid_schematic");
const string HANDLER_UPDATE_SCHEMATIC = "handleUpdateSchematic";
const string OBJVAR_SCHEMATICS = "crafting.schematics";
/***** TRIGGERS ********************************************************/
/**
* Called when an object has been initialized.
**/
trigger OnInitialize()
{
// clear internal objvars that may be hanging around
removeObjVar(self, OBJVAR_SCHEMATICS);
// Check if this is a weapon factory and update it's data
string template = getTemplateName(self);
if (template != null && template.indexOf("weapon_factory.iff") >= 0)
{
int craftingType = getIntObjVar(self, craftinglib.OBJVAR_CRAFTING_TYPE);
craftingType &= ~CT_genericItem; // Clear CT_genericItem bit
craftingType |= CT_misc; // Set CT_misc bit
craftingType |= CT_space; // Set CT_space bit
craftingType |= CT_reverseEngineering; // Set CT_reverseEngineering bit
setObjVar(self, craftinglib.OBJVAR_CRAFTING_TYPE, craftingType);
}
return SCRIPT_CONTINUE;
}
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
{
if ( !isIdValid(player) )
return SCRIPT_CONTINUE;
//string player_name = getFirstName(player);
//if ( player_name == null || player_name.length() == 0 )
// return SCRIPT_CONTINUE;
if(player_structure.isStructureCondemned(self) && player_structure.isOwner(player, self))
{
player_structure.doCondemnedSui(self, player);
return SCRIPT_OVERRIDE;
}
boolean canAccess = player_structure.canHopper(self, player) || player_structure.isAdmin(self, player);
int mnu;
menu_info_data mid = mi.getMenuItemByType(menu_info_types.EXAMINE);
if ( mid == null )
{
mnu = mi.addRootMenu(menu_info_types.EXAMINE, new string_id("",""));
}
else
{
mid.setServerNotify(true);
}
mnu = mi.addRootMenu(menu_info_types.SERVER_ITEM_OPTIONS, SID_FACTORY_OPTIONS);
int id;
if ( isHarvesterActive(self) )
{
id = mi.addSubMenu(mnu, menu_info_types.ITEM_DEACTIVATE, SID_DEACTIVATE);
if ( id != 0 && !canAccess )
mi.getMenuItemById(id).setEnabled(false);
}
else
{
string stationSchematic = getManufactureStationSchematic(self);
if ( stationSchematic != null )
{
id = mi.addSubMenu(mnu, menu_info_types.ITEM_ACTIVATE, SID_ACTIVATE);
if ( id != 0 && !canAccess )
mi.getMenuItemById(id).setEnabled(false);
id = mi.addSubMenu(mnu, menu_info_types.SERVER_HARVEST_CORPSE, SID_INGREDIENTS);
if ( id != 0 && !canAccess )
mi.getMenuItemById(id).setEnabled(false);
}
if (stationSchematic != null || hasValidManufactureSchematicsForStation(player, self))
{
id = mi.addSubMenu(mnu, menu_info_types.SERVER_MANF_STATION_SCHEMATIC, SID_SCHEMATIC);
if ( id != 0 && !canAccess )
mi.getMenuItemById(id).setEnabled(false);
}
else
{
// send a system message to the player saying they don't have a valid schematic
sendSystemMessage (player, SID_NO_VALID_SCHEMATIC);
}
id = mi.addSubMenu(mnu, menu_info_types.SERVER_MANF_HOPPER_INPUT, SID_INPUT_HOPPER);
if ( id != 0 && !canAccess )
mi.getMenuItemById(id).setEnabled(false);
id = mi.addSubMenu(mnu, menu_info_types.SERVER_MANF_HOPPER_OUTPUT, SID_OUTPUT_HOPPER);
if ( id != 0 && !canAccess )
mi.getMenuItemById(id).setEnabled(false);
}
return SCRIPT_CONTINUE;
}
trigger OnObjectMenuSelect(obj_id player, int item)
{
if ( !isIdValid(player) )
return SCRIPT_CONTINUE;
if(player_structure.isStructureCondemned(self))
{
player_structure.doCondemnedSui(self, player);
return SCRIPT_CONTINUE;
}
//string player_name = getFirstName(player);
//if ( player_name == null || player_name.length() == 0 )
// return SCRIPT_CONTINUE;
boolean canAccess = player_structure.canHopper(self, player) || player_structure.isAdmin(self, player);
if ( !canAccess )
return SCRIPT_CONTINUE;
if ( item == menu_info_types.SERVER_HARVEST_CORPSE )
{
if (getManufactureStationSchematic(self) != null)
{
//get ingredients list here
string[][] ingredients = new string[1][];
ingredients[0] = null;
getIngredientsForManufactureStation(self, ingredients);
string prompt = getString(SID_FACTORY_EXAMINE_PROMPT);
if ( ingredients[0] != null )
{
sui.listbox(player, prompt, ingredients[0]);
}
else
{
// sui.listbox(player, prompt, (string[])null);
}
}
}
else if ( item == menu_info_types.ITEM_ACTIVATE ||
( item == menu_info_types.ITEM_USE && !isHarvesterActive(self) )
)
{
activate(self);
if ( isHarvesterActive(self) )
{
prose_package pp = prose.getPackage( SID_STATION_ACTIVATED, self );
if ( pp != null )
sendSystemMessageProse( player, pp );
}
}
else if ( item == menu_info_types.ITEM_DEACTIVATE ||
( item == menu_info_types.ITEM_USE && isHarvesterActive(self) )
)
{
deactivate(self);
if ( !isHarvesterActive(self) )
{
prose_package pp = prose.getPackage( SID_STATION_DEACTIVATED, self );
if ( pp != null )
sendSystemMessageProse( player, pp );
}
}
else if ( item == menu_info_types.SERVER_MANF_HOPPER_INPUT )
{
obj_id inputHopper = getManufactureStationInputHopper(self);
if ( inputHopper != null )
queueCommand(player, ##"openContainer", inputHopper, "", COMMAND_PRIORITY_DEFAULT);
}
else if ( item == menu_info_types.SERVER_MANF_HOPPER_OUTPUT || item == menu_info_types.SERVER_ITEM_OPTIONS )
{
obj_id outputHopper = getManufactureStationOutputHopper(self);
if ( outputHopper != null )
queueCommand(player, ##"openContainer", outputHopper, "", COMMAND_PRIORITY_DEFAULT);
}
else if ( item == menu_info_types.SERVER_MANF_STATION_SCHEMATIC )
{
//do schematic stuff here
string currentSchematicName = getManufactureStationSchematic(self);
if ( currentSchematicName != null )
{
int markerPos = currentSchematicName.indexOf('*');
if ( markerPos >= 0 )
currentSchematicName = currentSchematicName.substring(markerPos + 1);
}
else
currentSchematicName = "";
string prompt = "Current schematic installed: " + currentSchematicName;
string[][] schematics = new string[1][];
schematics[0] = null;
getValidManufactureSchematicsForStation(player, self, schematics);
if ( schematics[0] != null )
{
// extract the schematic ids from the returned strings and save them to an objvar
string[] schematicIds = new string[schematics[0].length];
for ( int i = 0; i < schematicIds.length; ++i )
{
int markerPos = schematics[0][i].indexOf('*');
if ( markerPos >= 0 )
{
schematicIds[i] = schematics[0][i].substring(0, markerPos);
schematics[0][i] = schematics[0][i].substring(markerPos + 1);
}
else
{
string err = "ERROR " + getClass().getName() + ".OnObjectMenuSelect: handling SERVER_HARVESTER_MANAGE " +
"schematics for player " + player + " returned invalid schematic string <" + schematics[0][i] + ">";
debugServerConsoleMsg(null, err);
LOG("crafting", err);
schematicIds[i] = "";
schematics[0][i] = "";
}
}
if ( schematicIds.length > 0 )
setObjVar(self, OBJVAR_SCHEMATICS, schematicIds);
else
removeObjVar(self, OBJVAR_SCHEMATICS);
int pid = -1;
if ( schematics[0].length > 0 )
pid = sui.listbox(self, player, prompt, sui.OK_CANCEL, sui.DEFAULT_TITLE, schematics[0], HANDLER_UPDATE_SCHEMATIC, false);
else
pid = sui.emptylistbox(self, player, prompt, sui.OK_CANCEL, sui.DEFAULT_TITLE, HANDLER_UPDATE_SCHEMATIC, false);
if ( pid == -1 )
{
LOG("crafting", "Error creating schematic listbox");
}
else
{
if (currentSchematicName != "")
sui.listboxUseOtherButton (pid, "@remove_schematic");
sui.setSUIProperty(pid, sui.LISTBOX_BTN_OK, sui.PROP_TEXT, "@use_schematic");
sui.showSUIPage(pid);
}
}
}
return SCRIPT_CONTINUE;
}
/***** FUNCTIONS *******************************************************/
/***** MESSAGEHANDLERS *************************************************/
/**
* Handles a player selcting a schematic to use in the station.
*/
messageHandler handleUpdateSchematic()
{
string[] schematicIds = getStringArrayObjVar(self, OBJVAR_SCHEMATICS);
removeObjVar(self, OBJVAR_SCHEMATICS);
if ( (params == null) || (params.isEmpty()) )
{
return SCRIPT_CONTINUE;
}
obj_id player = sui.getPlayerId(params);
int bp = sui.getIntButtonPressed(params);
switch (bp)
{
case sui.BP_CANCEL:
return SCRIPT_CONTINUE;
case sui.BP_REVERT:
{
if (sui.getListboxOtherButtonPressed (params) == true)
{
// transfer the manf schematic in the station back to the player
removeSchematicFromStation(self, player);
return SCRIPT_CONTINUE;
}
}
}
if ( schematicIds == null )
{
return SCRIPT_CONTINUE;
}
int idx = sui.getListboxSelectedRow(params);
if ( idx < 0 )
{
return SCRIPT_CONTINUE;
}
else if (idx >= schematicIds.length)
{
string err = "ERROR " + getClass().getName() + ".handleUpdateSchematic: bad index " + idx +
" chosen for schematic list of length " + schematicIds.length;
debugServerConsoleMsg(null, err);
LOG("crafting", err);
}
else if (schematicIds[idx] == null || schematicIds[idx].length() == 0)
{
string err = "ERROR " + getClass().getName() + ".handleUpdateSchematic: null/empty schematic id at index " + idx;
debugServerConsoleMsg(null, err);
LOG("crafting", err);
}
else
{
// see if we need to remove the current schematic
removeSchematicFromStation(self, player);
prose_package pp = null;
obj_id schematic = obj_id.getObjId(Long.parseLong(schematicIds[idx]));
if ( schematic == null || schematic == obj_id.NULL_ID )
{
string err = "ERROR " + getClass().getName() + ".handleUpdateSchematic: schematic id " + schematicIds[idx] +
"at index " + idx + " gives an invalid obj_id";
debugServerConsoleMsg(null, err);
LOG("crafting", err);
}
else
{
if (transferManufactureSchematicToStation(schematic, self))
pp = prose.getPackage( SID_SCHEMATIC_ADDED, schematic );
else
pp = prose.getPackage( SID_SCHEMATIC_NOT_ADDED, schematic );
}
if ( pp != null )
sendSystemMessageProse( player, pp );
}
return SCRIPT_CONTINUE;
}
/**
* Removes a schematic from a manf station and puts it in a player's datapad.
*
* @param station the manf station
* @param player the player
*
* @return true if the schematic was removed, false if not
**/
boolean removeSchematicFromStation(obj_id station, obj_id player)
{
prose_package pp = null;
string schematicName = getManufactureStationSchematic(station);
boolean transferred = transferManufactureSchematicToPlayer(station, player);
if ( schematicName != null && schematicName.length() > 0 )
{
obj_id schematicId = obj_id.getObjId(Long.valueOf(schematicName.substring(0, schematicName.indexOf('*'))));
if (isIdValid(schematicId))
{
if ( transferred )
pp = prose.getPackage( SID_SCHEMATIC_REMOVED, schematicId );
else
pp = prose.getPackage( SID_SCHEMATIC_NOT_REMOVED, schematicId );
}
}
if ( pp != null )
sendSystemMessageProse( player, pp );
return transferred;
}
@@ -0,0 +1,106 @@
package script.structure;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
import script.library.player_structure;
import script.library.utils;
public class mini_vehicle_control extends script.base_script
{
public mini_vehicle_control()
{
}
public static final String VEHICLE_ID = "mini_vehicle.vehicle";
public int OnAttach(obj_id self) throws InterruptedException
{
messageTo(self, "checkVehicleId", null, 3, false);
return SCRIPT_CONTINUE;
}
public int OnReceivedItem(obj_id self, obj_id srcContainer, obj_id transferer, obj_id item) throws InterruptedException
{
if (isPlayer(item))
{
messageTo(self, "handlerMiniVehicleReceived", null, 6, false);
}
return SCRIPT_CONTINUE;
}
public int OnLostItem(obj_id self, obj_id srcContainer, obj_id transferer, obj_id item) throws InterruptedException
{
if (isPlayer(item))
{
messageTo(self, "handlerMiniVehicleLost", null, 6, false);
}
return SCRIPT_CONTINUE;
}
public int checkVehicleId(obj_id self, dictionary params) throws InterruptedException
{
if (!isValidId(getObjIdObjVar(self, VEHICLE_ID)))
{
detachScript(self, "structure.mini_vehicle_control");
}
return SCRIPT_CONTINUE;
}
public int handlerMiniVehicleReceived(obj_id self, dictionary params) throws InterruptedException
{
if (!isValidId(self) && !exists(self))
{
return SCRIPT_CONTINUE;
}
if (!hasObjVar(self, VEHICLE_ID))
{
detachScript(self, "structure.mini_vehicle_control");
}
obj_id vehicle = getObjIdObjVar(self, VEHICLE_ID);
if (!isValidId(vehicle) && !exists(vehicle))
{
return SCRIPT_CONTINUE;
}
if (utils.hasScriptVar(vehicle, "vehicle.moving") || utils.hasScriptVar(vehicle, "vehicle.settingPatrol"))
{
return SCRIPT_CONTINUE;
}
obj_id[] players = player_structure.getPlayersInBuilding(self);
if (players == null || players.length == 0)
{
return SCRIPT_CONTINUE;
}
if (players.length >= 1)
{
return SCRIPT_CONTINUE;
}
broadcastMessage("handleActivateVehicle", new dictionary());
return SCRIPT_CONTINUE;
}
public int handlerMiniVehicleLost(obj_id self, dictionary params) throws InterruptedException
{
if (!isValidId(self) && !exists(self))
{
return SCRIPT_CONTINUE;
}
if (!hasObjVar(self, VEHICLE_ID))
{
detachScript(self, "structure.mini_vehicle_control");
}
obj_id vehicle = getObjIdObjVar(self, VEHICLE_ID);
if (!isValidId(vehicle) && !exists(vehicle))
{
return SCRIPT_CONTINUE;
}
if (utils.hasScriptVar(vehicle, "vehicle.settingPatrol"))
{
return SCRIPT_CONTINUE;
}
obj_id[] players = player_structure.getPlayersInBuilding(self);
if (players == null || players.length == 0)
{
broadcastMessage("handleDeactivateVehicle", new dictionary());
}
return SCRIPT_CONTINUE;
}
}
@@ -1,99 +0,0 @@
// ALL MINI VEHICLE SCRIPTS
// structure/mini_vehicle_control.script
// creature/mini_vehicle.script
// terminal/mini_vehicle_terminal.script
include library.player_structure;
include library.utils;
//variable constants
const string VEHICLE_ID = "mini_vehicle.vehicle";
trigger OnAttach()
{
messageTo(self, "checkVehicleId", null, 3, false);
return SCRIPT_CONTINUE;
}
trigger OnReceivedItem(obj_id srcContainer, obj_id transferer, obj_id item)
{
if(isPlayer(item))
messageTo(self, "handlerMiniVehicleReceived", null, 6, false);
return SCRIPT_CONTINUE;
}
trigger OnLostItem(obj_id srcContainer, obj_id transferer, obj_id item)
{
if(isPlayer(item))
messageTo(self, "handlerMiniVehicleLost", null, 6, false);
return SCRIPT_CONTINUE;
}
//This is called on init to get the terminal user's OID
messageHandler checkVehicleId()
{
if(!isValidId(getObjIdObjVar(self, VEHICLE_ID)))
detachScript(self, "structure.mini_vehicle_control");
return SCRIPT_CONTINUE;
}
messageHandler handlerMiniVehicleReceived()
{
//remove the script if no vehicle exists
if(!isValidId(self) && !exists(self))
return SCRIPT_CONTINUE;
if(!hasObjVar(self, VEHICLE_ID))
{
detachScript(self, "structure.mini_vehicle_control");
}
obj_id vehicle = getObjIdObjVar(self, VEHICLE_ID);
if(!isValidId(vehicle) && !exists(vehicle))
return SCRIPT_CONTINUE;
//the vehicle is moving already or the owner is setting patrols
if(utils.hasScriptVar(vehicle, "vehicle.moving") || utils.hasScriptVar(vehicle, "vehicle.settingPatrol"))
{
return SCRIPT_CONTINUE;
}
obj_id[] players = player_structure.getPlayersInBuilding(self);
if(players == null || players.length == 0)
return SCRIPT_CONTINUE;
//players already here
if(players.length >= 1)
return SCRIPT_CONTINUE;
//Reactivate the sleeping vehicle
broadcastMessage("handleActivateVehicle", new dictionary());
return SCRIPT_CONTINUE;
}
messageHandler handlerMiniVehicleLost()
{
//remove the script if no vehicle exists
if(!isValidId(self) && !exists(self))
return SCRIPT_CONTINUE;
if(!hasObjVar(self, VEHICLE_ID))
detachScript(self, "structure.mini_vehicle_control");
obj_id vehicle = getObjIdObjVar(self, VEHICLE_ID);
if(!isValidId(vehicle) && !exists(vehicle))
return SCRIPT_CONTINUE;
if(utils.hasScriptVar(vehicle, "vehicle.settingPatrol"))
return SCRIPT_CONTINUE;
obj_id[] players = player_structure.getPlayersInBuilding(self);
if(players == null || players.length == 0)
{
broadcastMessage("handleDeactivateVehicle", new dictionary());
}
return SCRIPT_CONTINUE;
}
@@ -0,0 +1,61 @@
package script.structure.municipal;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
import script.library.create;
import script.library.structure;
import script.library.utils;
public class bank extends script.base_script
{
public bank()
{
}
public static final String SCRIPT_ME = "structure.municipal.bank";
public static final String JUNK_DEALER = "junk_dealer";
public static final String DATATABLE_TERMINAL_LIST = "datatables/structure/municipal/bank_terminal.iff";
public int OnInitialize(obj_id self) throws InterruptedException
{
messageTo(self, "createBankTerminalsAndVendors", null, 9, false);
return SCRIPT_CONTINUE;
}
public int createBankTerminalsAndVendors(obj_id self, dictionary params) throws InterruptedException
{
location bankLoc = getLocation(self);
String planet = bankLoc.area;
float bankYaw = getYaw(self);
location junkDealerLoc01 = new location(bankLoc.x + 11.8f, bankLoc.y + 0.5f, bankLoc.z + 11.8f, planet, null);
float junkDealerYaw01 = -135.0f;
location junkDealerLoc02 = new location(bankLoc.x - 11.8f, bankLoc.y + 0.5f, bankLoc.z - 11.8f, planet, null);
float junkDealerYaw02 = 45.0f;
if (bankYaw != 0)
{
junkDealerLoc01 = utils.rotatePointXZ(bankLoc, junkDealerLoc01, bankYaw);
junkDealerYaw01 -= (90 - bankYaw);
junkDealerLoc02 = utils.rotatePointXZ(bankLoc, junkDealerLoc02, bankYaw);
junkDealerYaw02 -= (90 - bankYaw);
}
obj_id junkDealer01 = create.object(JUNK_DEALER, junkDealerLoc01);
if (isIdValid(junkDealer01))
{
setYaw(junkDealer01, junkDealerYaw01);
setInvulnerable(junkDealer01, true);
setObjVar(junkDealer01, "creation.myBank", self);
}
obj_id junkDealer02 = create.object(JUNK_DEALER, junkDealerLoc02);
if (isIdValid(junkDealer02))
{
setYaw(junkDealer02, junkDealerYaw02);
setInvulnerable(junkDealer02, true);
setObjVar(junkDealer02, "creation.myBank", self);
}
structure.createStructureTerminals(self, SCRIPT_ME, DATATABLE_TERMINAL_LIST);
return SCRIPT_CONTINUE;
}
}
@@ -1,79 +0,0 @@
/**
* Title: bank.script
* Description: script for bank buildings
*/
/***** INCLUDES ********************************************************/
include library.create;
include library.structure;
include library.utils;
/***** CONSTANTS *******************************************************/
const string SCRIPT_ME = "structure.municipal.bank";
const string JUNK_DEALER = "junk_dealer";
//FACILITY DATATABLES
const string DATATABLE_TERMINAL_LIST = "datatables/structure/municipal/bank_terminal.iff";
/***** TRIGGERS ********************************************************/
trigger OnInitialize()
{
messageTo(self, "createBankTerminalsAndVendors", null, 9, false);
return SCRIPT_CONTINUE;
}
messageHandler createBankTerminalsAndVendors()
{
// ------------------------------------
// create 2 junk dealers
location bankLoc = getLocation(self);
string planet = bankLoc.area;
float bankYaw = getYaw(self);
location junkDealerLoc01 = new location(bankLoc.x + 11.8f, bankLoc.y + 0.5f, bankLoc.z + 11.8f, planet, null);
float junkDealerYaw01 = -135.0f;
location junkDealerLoc02 = new location(bankLoc.x - 11.8f, bankLoc.y + 0.5f, bankLoc.z - 11.8f, planet, null);
float junkDealerYaw02 = 45.0f;
if ( bankYaw != 0 )
{
junkDealerLoc01 = utils.rotatePointXZ(bankLoc, junkDealerLoc01, bankYaw);
junkDealerYaw01 -= (90 - bankYaw);
junkDealerLoc02 = utils.rotatePointXZ(bankLoc, junkDealerLoc02, bankYaw);
junkDealerYaw02 -= (90 - bankYaw);
}
obj_id junkDealer01 = create.object(JUNK_DEALER, junkDealerLoc01);
if ( isIdValid(junkDealer01) )
{
setYaw(junkDealer01, junkDealerYaw01);
setInvulnerable (junkDealer01, true);
setObjVar(junkDealer01, "creation.myBank", self);
}
obj_id junkDealer02 = create.object(JUNK_DEALER, junkDealerLoc02);
if ( isIdValid(junkDealer02) )
{
setYaw(junkDealer02, junkDealerYaw02);
setInvulnerable (junkDealer02, true);
setObjVar(junkDealer02, "creation.myBank", self);
}
// ------------------------------------
structure.createStructureTerminals(self, SCRIPT_ME, DATATABLE_TERMINAL_LIST);
return SCRIPT_CONTINUE;
}
/***** FUNCTIONS *******************************************************/
/***** MESSAGEHANDLERS *************************************************/
@@ -0,0 +1,45 @@
package script.structure.municipal;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
import script.library.create;
import script.library.ai_lib;
public class cantina extends script.base_script
{
public cantina()
{
}
public int OnInitialize(obj_id self) throws InterruptedException
{
location behindBar = getLocation(self);
String planet = behindBar.area;
obj_id cantina = getCellId(self, "cantina");
if (cantina == null)
{
return SCRIPT_OVERRIDE;
}
behindBar = new location(8.54f, -0.89f, 0.14f, planet, cantina);
obj_id bartender = create.object("bartender", behindBar);
setYaw(bartender, 87);
setCreatureStatic(bartender, true);
setInvulnerable(bartender, true);
ai_lib.setDefaultCalmBehavior(self, ai_lib.BEHAVIOR_SENTINEL);
if (hasScript(self, "theme_park.lok.cantina"))
{
if (hasScript(self, "city.imperial_crackdown.crackdown_cantina"))
{
detachScript(self, "city.imperial_crackdown.crackdown_cantina");
}
return SCRIPT_CONTINUE;
}
attachScript(self, "city.imperial_crackdown.crackdown_cantina");
return SCRIPT_CONTINUE;
}
}
@@ -1,49 +0,0 @@
/**********************************************************************
* Title: hospital_heal
* Description: allows the slow healing of wounds and shock for all within
* the building.
**********************************************************************/
/***** FUNCTIONS *******************************************************/
// This script is empty so that it can be attached to structures for gold master
// and later augmented to add functionality.
include library.create;
include library.ai_lib;
trigger OnInitialize ()
{
location behindBar = getLocation (self);
string planet = behindBar.area;
obj_id cantina = getCellId(self, "cantina");
if (cantina == null)
{
return SCRIPT_OVERRIDE;
}
behindBar = new location (8.54f, -0.89f, 0.14f, planet, cantina);
obj_id bartender = create.object ("bartender", behindBar);
setYaw (bartender, 87);
setCreatureStatic (bartender, true);
setInvulnerable(bartender, true);
ai_lib.setDefaultCalmBehavior( self, ai_lib.BEHAVIOR_SENTINEL );
// The cantina in Nym's Stronghold has this script attached to it
// We do not want to attach the Imperial Crackdown script to the cantina in Nym's Stronghold
if(hasScript(self, "theme_park.lok.cantina")) {
if(hasScript(self, "city.imperial_crackdown.crackdown_cantina")) {
detachScript(self, "city.imperial_crackdown.crackdown_cantina");
}
return SCRIPT_CONTINUE;
}
attachScript (self, "city.imperial_crackdown.crackdown_cantina");
return SCRIPT_CONTINUE;
}
@@ -0,0 +1,371 @@
package script.structure.municipal;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
import script.library.player_structure;
import script.library.planetary_map;
import script.library.structure;
import script.library.city;
import script.library.cloninglib;
import script.library.regions;
import script.library.space_dungeon;
import script.library.utils;
import java.util.Enumeration;
public class cloning_base extends script.base_script
{
public cloning_base()
{
}
public static final String SCRIPT_CLONING_FACILITY = "structure.municipal.cloning_facility";
public static final String VAR_NUM_RESPAWN_TUBES = "numRespawnTubes";
public static final String VAR_CURRENT_RESPAWN_TUBE = "currentTube";
public int OnAttach(obj_id self) throws InterruptedException
{
if (player_structure.isCivic(self))
{
int city_id = getCityAtLocation(getLocation(self), 0);
city.setCloneInfo(city_id, getLocation(self), cloninglib.getCloneSpawnLocation(self), self);
}
return SCRIPT_CONTINUE;
}
public int OnDetach(obj_id self) throws InterruptedException
{
obj_id planet = getPlanetByName(getCurrentSceneName());
if (isIdValid(planet))
{
dictionary params = new dictionary();
params.put("id", self);
messageTo(planet, "unregisterCloningFacility", params, 1.0f, false);
}
return SCRIPT_CONTINUE;
}
public int OnInitialize(obj_id self) throws InterruptedException
{
if (!requestCloningFacilityRegistration(self))
{
CustomerServiceLog("Cloning_Center", "The cloning center " + self + " registration reports a failure. Attempted to register cloning center(" + getTemplateName(self) + "/" + self + ") but this action failed.");
}
int numberOfRetry = 0;
dictionary params = new dictionary();
params.put("number_of_retry", numberOfRetry);
messageTo(self, "retryInitializeCloningFacility", params, 120.0f, false);
return SCRIPT_CONTINUE;
}
public int OnDestroy(obj_id self) throws InterruptedException
{
if (player_structure.isCivic(self))
{
int city_id = getLocatedInCityId(self);
city.setCloneInfo(city_id, null, null, null);
return SCRIPT_CONTINUE;
}
obj_id planet = getPlanetByName(getCurrentSceneName());
if (isIdValid(planet))
{
dictionary params = new dictionary();
params.put("id", self);
messageTo(planet, "unregisterCloningFacility", params, 1.0f, false);
}
return SCRIPT_CONTINUE;
}
public int OnGetRespawnLocation(obj_id self, modifiable_int tubeIndex) throws InterruptedException
{
deltadictionary scriptvars = self.getScriptVars();
int numTubes = scriptvars.getInt(VAR_NUM_RESPAWN_TUBES);
if (numTubes > 0)
{
int currentTube = scriptvars.getInt(VAR_CURRENT_RESPAWN_TUBE);
tubeIndex.set(currentTube++);
if (currentTube == numTubes)
{
currentTube = 0;
}
scriptvars.put(VAR_CURRENT_RESPAWN_TUBE, currentTube);
}
return SCRIPT_CONTINUE;
}
public int registerCloningFacility(obj_id self, dictionary params) throws InterruptedException
{
String myTemplate = getTemplateName(self);
dictionary facilityData = new dictionary();
if (params.containsKey("facilityData"))
{
facilityData = params.getDictionary("facilityData");
}
else
{
facilityData = dataTableGetRow(structure.DATATABLE_CLONING_FACILITY_RESPAWN, myTemplate);
}
String planetName = getCurrentSceneName();
obj_id planet = getPlanetByName(planetName);
if (isIdValid(planet))
{
location spawnLoc = cloninglib.getCloneSpawnLocation(getLocation(self), facilityData);
if (spawnLoc != null)
{
if (regions.isInPvPRegion(self))
{
CustomerServiceLog("Cloning_Center", "Attempted to register cloning center(" + getTemplateName(self) + "/" + self + ") but was within a PvP region.)");
return SCRIPT_CONTINUE;
}
int cloneType = 0;
if (facilityData != null)
{
cloneType = facilityData.getInt("CLONE_TYPE");
}
dictionary data = new dictionary();
data.put("id", self);
location facilityLoc = getLocation(self);
data.put("loc", facilityLoc);
data.put("respawn", spawnLoc);
data.put("type", cloneType);
String cloneName = getCloneName(cloneType, facilityData.getString("NAME"));
if (cloneName == null)
{
CustomerServiceLog("Cloning_Center", "Unable to determine facility name for Cloning Facility(" + getTemplateName(self) + "/" + self + ") at location(" + getLocation(self) + ") - Waiting...");
messageTo(self, "registerCloningFacility", params, 180.0f, false);
return SCRIPT_CONTINUE;
}
data.put("name", cloneName);
obj_id pobId = null;
if (space_dungeon.isSpaceDungeon(self) || hasObjVar(self, "isControllerObject"))
{
pobId = self;
}
else
{
pobId = getTopMostContainer(self);
if (pobId == self)
{
pobId = obj_id.NULL_ID;
}
}
data.put("areaId", pobId);
location facilityWorldLoc = getWorldLocation(self);
String buildoutName = cloninglib.getBuildoutAreaName(facilityWorldLoc.x, facilityWorldLoc.z);
dictionary cloneAreaList = cloninglib.getCloningAreas(planetName, buildoutName);
CustomerServiceLog("Cloning_Center", "Registering Cloning Facility(" + getTemplateName(self) + "/" + self + ") at location(" + getLocation(self) + ") spawnLoc(" + spawnLoc + ") cloneType(" + cloneType + ")");
int idx = 0;
while (cloneAreaList.containsKey("scene_" + idx))
{
String cloneScene = cloneAreaList.getString("scene_" + idx);
String cloneArea = cloneAreaList.getString("area_" + idx);
data.put("buildout", cloneArea);
obj_id scene = getPlanetByName(cloneScene);
if (isIdValid(scene))
{
messageTo(scene, "registerCloningFacility", data, 1.0f, false);
CustomerServiceLog("Cloning_Center", "Mapping Cloning Region(" + getTemplateName(self) + "/" + self + ") to " + cloneScene + "(" + cloneArea + ")");
}
else
{
CustomerServiceLog("Cloning_Center", "Failed to map clone region(" + getTemplateName(self) + "/" + self + ") invalid scene name " + cloneScene);
}
idx++;
}
}
else
{
LOG("DESIGNER_FATAL", "************* registerCloningFacility ****************");
LOG("DESIGNER_FATAL", "spawnLoc was returned as null & therefore aborted facility registration");
LOG("DESIGNER_FATAL", "facility = " + self + " on planet = " + getCurrentSceneName());
LOG("DESIGNER_FATAL", "facility location = " + (getLocation(self)).toString());
LOG("DESIGNER_FATAL", "facility template = " + getTemplateName(self));
CustomerServiceLog("Cloning_Center", "Attempted to register cloning center but spawn location was null: (" + getTemplateName(self) + "/" + self + ") failed to register on planet(" + getCurrentSceneName() + ")");
return SCRIPT_CONTINUE;
}
}
else
{
CustomerServiceLog("Cloning_Center", "Attempted to register cloning center(" + getTemplateName(self) + "/" + self + ") but could not find planet object for(" + getCurrentSceneName() + ")");
}
return SCRIPT_CONTINUE;
}
public String getCloneName(obj_id self) throws InterruptedException
{
String myTemplate = getTemplateName(self);
dictionary facilityData = dataTableGetRow(structure.DATATABLE_CLONING_FACILITY_RESPAWN, myTemplate);
if (facilityData == null)
{
return "@base_player:clone_location_unknown";
}
return getCloneName(facilityData.getInt("CLONE_TYPE"), facilityData.getString("NAME"));
}
public String getCloneName(int cloneType, String nameOverride) throws InterruptedException
{
obj_id self = getSelf();
String cloneName = "@base_player:clone_location_unknown";
switch (cloneType)
{
case cloninglib.CLONE_TYPE_STANDARD:
case cloninglib.CLONE_TYPE_PLAYER_CITY:
case cloninglib.CLONE_TYPE_RESTRICTED:
map_location cl = getPlanetaryMapLocation(self);
if (cl != null)
{
cloneName = cl.getLocationName();
}
else if (nameOverride != null && !nameOverride.equals(""))
{
cloneName = nameOverride;
}
else
{
cloneName = null;
}
break;
case cloninglib.CLONE_TYPE_JEDI_ONLY:
location spawnLoc = cloninglib.getCloneSpawnLocation(self);
cloneName = "@base_player:clone_location_force_shrine (" + (int)spawnLoc.x + ", " + (int)spawnLoc.z + ")";
break;
case cloninglib.CLONE_TYPE_LIGHT_JEDI_ONLY:
case cloninglib.CLONE_TYPE_DARK_JEDI_ONLY:
cloneName = "@base_player:clone_location_jedi_enclave";
break;
case cloninglib.CLONE_TYPE_FACTION_IMPERIAL:
cloneName = nameOverride;
break;
case cloninglib.CLONE_TYPE_FACTION_REBEL:
cloneName = nameOverride;
break;
case cloninglib.CLONE_TYPE_PVP_REGION_ADVANCED_IMPERIAL:
cloneName = nameOverride;
break;
case cloninglib.CLONE_TYPE_PVP_REGION_ADVANCED_REBEL:
cloneName = nameOverride;
break;
case cloninglib.CLONE_TYPE_CAMP:
obj_id parent = getObjIdObjVar(self, "theater.parent");
if (isIdValid(parent))
{
String name = getName(parent);
if (name != null && !name.equals(""))
{
cloneName = name;
}
else
{
cloneName = nameOverride;
}
}
else
{
cloneName = nameOverride;
}
break;
case cloninglib.CLONE_TYPE_PRIVATE_INSTANCE:
cloneName = nameOverride;
break;
}
return cloneName;
}
public int requestCloningData(obj_id self, dictionary params) throws InterruptedException
{
obj_id requester = params.getObjId("requester");
dictionary data = new dictionary();
String cloneName = getCloneName(self);
location facilityLoc = getLocation(self);
location spawnLoc = cloninglib.getCloneSpawnLocation(self);
data.put("faciltyId", self);
data.put("cloneName", cloneName);
data.put("facilityLoc", facilityLoc);
data.put("spawnLoc", spawnLoc);
messageTo(requester, "handleCloningDataUpdate", data, 0, false);
return SCRIPT_CONTINUE;
}
public int retryInitializeCloningFacility(obj_id self, dictionary params) throws InterruptedException
{
int numberOfRetry = params.getInt("number_of_retry");
if (numberOfRetry >= 5)
{
return SCRIPT_CONTINUE;
}
String planetName = getCurrentSceneName();
if (planetName == null || planetName.length() <= 0)
{
CustomerServiceLog("Cloning_Center", "The cloning center " + self + " registration reports a failure. Attempted to register cloning center but could not get a valid planet name! Aborting registration.");
return SCRIPT_CONTINUE;
}
obj_id planet = getPlanetByName(planetName);
if (!isValidId(planet))
{
CustomerServiceLog("Cloning_Center", "The cloning center " + self + " registration reports a failure. Attempted to register cloning center but could not get a valid planet OID for planet: " + planetName + ". Aborting registration.");
return SCRIPT_CONTINUE;
}
obj_id[] idList = utils.getObjIdArrayScriptVar(planet, cloninglib.VAR_PLANET_CLONE_ID);
if (idList != null && idList.length > 0)
{
for (int i = 0; i < idList.length - 1; i++)
{
if (idList[i] != self)
{
continue;
}
return SCRIPT_CONTINUE;
}
}
if (!requestCloningFacilityRegistration(self))
{
CustomerServiceLog("Cloning_Center", "The cloning center " + self + " registration reports a failure. Attempted to register cloning center(" + getTemplateName(self) + "/" + self + ") but this action failed.");
}
++numberOfRetry;
if (numberOfRetry < 5)
{
params.put("number_of_retry", numberOfRetry);
messageTo(self, "retryInitializeCloningFacility", params, 120.0f, false);
}
return SCRIPT_CONTINUE;
}
public boolean requestCloningFacilityRegistration(obj_id cloningFacility) throws InterruptedException
{
if (!isValidId(cloningFacility))
{
return false;
}
if (player_structure.isCivic(cloningFacility))
{
planetary_map.addMapLocation(cloningFacility);
int city_id = getCityAtLocation(getLocation(cloningFacility), 0);
if (city_id < 0)
{
CustomerServiceLog("Cloning_Center", "The cloning center (which is " + cloningFacility + ") could not continue the planet registration process because the city_id was invalid. Registeration of cloning center(" + getTemplateName(cloningFacility) + "/" + cloningFacility + ") aborted.");
return false;
}
city.setCloneInfo(city_id, getLocation(cloningFacility), cloninglib.getCloneSpawnLocation(cloningFacility), cloningFacility);
}
String myTemplate = getTemplateName(cloningFacility);
if (myTemplate == null || myTemplate.length() <= 0)
{
CustomerServiceLog("Cloning_Center", "The cloning center which is " + cloningFacility + " could not continue the planet registration process because the object template for the cloning center was invalid. Registeration of cloning center(" + getTemplateName(cloningFacility) + "/" + cloningFacility + ") aborted.");
return false;
}
dictionary facilityData = dataTableGetRow(structure.DATATABLE_CLONING_FACILITY_RESPAWN, myTemplate);
if (facilityData == null)
{
CustomerServiceLog("Cloning_Center", "The cloning center (which is " + cloningFacility + " of template: " + myTemplate + ") was not found in the datatables/structure/municipal/cloning_facility_respawn.iff table. Registeration aborted.");
return false;
}
dictionary dict = new dictionary();
dict.put("facilityData", facilityData);
int numTubes = 0;
if (facilityData != null)
{
numTubes = facilityData.getInt(structure.DATATABLE_COL_TUBES);
}
if (numTubes > 0)
{
deltadictionary scriptvars = cloningFacility.getScriptVars();
scriptvars.put(VAR_NUM_RESPAWN_TUBES, numTubes);
scriptvars.put(VAR_CURRENT_RESPAWN_TUBE, 0);
}
messageTo(cloningFacility, "registerCloningFacility", dict, 60.0f, false);
return true;
}
}
@@ -1,435 +0,0 @@
/**
* Title: cloning_facility.script
* Description: script for cloning facilities
*/
/***** INCLUDES ********************************************************/
include library.player_structure;
include library.planetary_map;
include library.structure;
include library.city;
include library.cloninglib;
include library.regions;
include library.space_dungeon;
include library.utils;
include java.util.Enumeration;
/***** CONSTANTS *******************************************************/
const string SCRIPT_CLONING_FACILITY = "structure.municipal.cloning_facility";
const string VAR_NUM_RESPAWN_TUBES = "numRespawnTubes";
const string VAR_CURRENT_RESPAWN_TUBE = "currentTube";
/***** TRIGGERS ********************************************************/
trigger OnAttach()
{
if ( player_structure.isCivic( self ) )
{
// Player city registration.
int city_id = getCityAtLocation( getLocation( self ), 0 );
city.setCloneInfo( city_id, getLocation( self ), cloninglib.getCloneSpawnLocation(self), self );
}
return SCRIPT_CONTINUE;
}
trigger OnDetach()
{
obj_id planet = getPlanetByName(getCurrentSceneName());
if (isIdValid(planet))
{
dictionary params = new dictionary();
params.put("id", self);
messageTo(planet, "unregisterCloningFacility", params, 1.0f, false);
}
return SCRIPT_CONTINUE;
}
trigger OnInitialize()
{
if(!requestCloningFacilityRegistration(self))
{
CustomerServiceLog("Cloning_Center", "The cloning center "+self+" registration reports a failure. Attempted to register cloning center("+getTemplateName(self)+"/"+self+") but this action failed.");
}
int numberOfRetry = 0;
dictionary params = new dictionary();
params.put("number_of_retry", numberOfRetry);
messageTo(self, "retryInitializeCloningFacility", params, 120.0f, false);
return SCRIPT_CONTINUE;
}
// ----------------------------------------------------------------------
trigger OnDestroy()
{
if ( player_structure.isCivic( self ) )
{
// Player city deregistration.
int city_id = getLocatedInCityId( self );
city.setCloneInfo( city_id, null, null, null );
return SCRIPT_CONTINUE;
}
obj_id planet = getPlanetByName(getCurrentSceneName());
if (isIdValid(planet))
{
dictionary params = new dictionary();
params.put("id", self);
messageTo(planet, "unregisterCloningFacility", params, 1.0f, false);
}
return SCRIPT_CONTINUE;
}
/**
* Special trigger that should be attached to cloning facilities. This is used to tell the server
* which tube the player should be respawned in.
*
* @param tubeIndex to be filled with the index of the tube to respawn in
*
* @return ignored
*/
trigger OnGetRespawnLocation(modifiable_int tubeIndex)
{
// see if we have respawn tubes
deltadictionary scriptvars = self.getScriptVars();
int numTubes = scriptvars.getInt(VAR_NUM_RESPAWN_TUBES);
if ( numTubes > 0 )
{
// get the tube to respawn in
int currentTube = scriptvars.getInt(VAR_CURRENT_RESPAWN_TUBE);
tubeIndex.set(currentTube++);
// set the next tube to respawn in
if ( currentTube == numTubes )
currentTube = 0;
scriptvars.put(VAR_CURRENT_RESPAWN_TUBE, currentTube);
}
return SCRIPT_CONTINUE;
}
/***** FUNCTIONS *******************************************************/
/***** MESSAGEHANDLERS *************************************************/
messageHandler registerCloningFacility()
{
// get datatable entry
string myTemplate = getTemplateName(self);
dictionary facilityData = new dictionary();
if (params.containsKey("facilityData"))
{
facilityData = params.getDictionary("facilityData");
}
else
{
facilityData = dataTableGetRow(structure.DATATABLE_CLONING_FACILITY_RESPAWN, myTemplate);
}
// register with the planet
string planetName = getCurrentSceneName();
obj_id planet = getPlanetByName(planetName);
if (isIdValid(planet))
{
location spawnLoc = cloninglib.getCloneSpawnLocation(getLocation(self), facilityData);
if ( spawnLoc != null )
{
if (regions.isInPvPRegion(self))
{
CustomerServiceLog("Cloning_Center", "Attempted to register cloning center("+getTemplateName(self)+"/"+self+") but was within a PvP region.)");
return SCRIPT_CONTINUE;
}
int cloneType = 0;
if (facilityData != null)
cloneType = facilityData.getInt("CLONE_TYPE");
dictionary data = new dictionary();
data.put("id", self);
location facilityLoc = getLocation(self);
data.put("loc", facilityLoc);
data.put("respawn", spawnLoc);
data.put("type", cloneType);
string cloneName = getCloneName(cloneType, facilityData.getString("NAME"));
if (cloneName == null)
{
CustomerServiceLog("Cloning_Center", "Unable to determine facility name for Cloning Facility("+getTemplateName(self)+"/"+self+") at location("+getLocation(self)+") - Waiting...");
messageTo(self, "registerCloningFacility", params, 180.0f, false);
return SCRIPT_CONTINUE;
}
data.put("name", cloneName);
obj_id pobId = null;
if (space_dungeon.isSpaceDungeon(self) || hasObjVar(self, "isControllerObject"))
{
pobId = self;
}
else
{
pobId = getTopMostContainer(self);
if (pobId == self) pobId = obj_id.NULL_ID;
}
data.put("areaId", pobId);
location facilityWorldLoc = getWorldLocation(self);
string buildoutName = cloninglib.getBuildoutAreaName(facilityWorldLoc.x, facilityWorldLoc.z);
dictionary cloneAreaList = cloninglib.getCloningAreas(planetName, buildoutName);
CustomerServiceLog("Cloning_Center", "Registering Cloning Facility("+getTemplateName(self)+"/"+self+") at location("+getLocation(self)+") spawnLoc("+spawnLoc+") cloneType("+cloneType+")");
int idx = 0;
while (cloneAreaList.containsKey("scene_"+idx))
{
string cloneScene = cloneAreaList.getString("scene_"+idx);
string cloneArea = cloneAreaList.getString("area_"+idx);
data.put("buildout", cloneArea);
obj_id scene = getPlanetByName(cloneScene);
if (isIdValid(scene))
{
messageTo(scene, "registerCloningFacility", data, 1.0f, false);
CustomerServiceLog("Cloning_Center", "Mapping Cloning Region("+getTemplateName(self)+"/"+self+") to "+cloneScene+"("+cloneArea+")");
}
else
{
CustomerServiceLog("Cloning_Center", "Failed to map clone region("+getTemplateName(self)+"/"+self+") invalid scene name "+cloneScene);
}
idx++;
}
}
else
{
LOG("DESIGNER_FATAL","************* registerCloningFacility ****************");
LOG("DESIGNER_FATAL","spawnLoc was returned as null & therefore aborted facility registration");
LOG("DESIGNER_FATAL","facility = " + self + " on planet = " + getCurrentSceneName());
LOG("DESIGNER_FATAL","facility location = " + getLocation(self).toString());
LOG("DESIGNER_FATAL","facility template = " + getTemplateName(self));
CustomerServiceLog("Cloning_Center", "Attempted to register cloning center but spawn location was null: ("+getTemplateName(self)+"/"+self+") failed to register on planet("+getCurrentSceneName()+")");
return SCRIPT_CONTINUE;
}
}
else
{
CustomerServiceLog("Cloning_Center", "Attempted to register cloning center("+getTemplateName(self)+"/"+self+") but could not find planet object for("+getCurrentSceneName()+")");
}
return SCRIPT_CONTINUE;
}
string getCloneName(obj_id self)
{
string myTemplate = getTemplateName(self);
dictionary facilityData = dataTableGetRow(structure.DATATABLE_CLONING_FACILITY_RESPAWN, myTemplate);
if (facilityData == null)
return "@base_player:clone_location_unknown";
return getCloneName(facilityData.getInt("CLONE_TYPE"), facilityData.getString("NAME"));
}
string getCloneName(int cloneType, string nameOverride)
{
obj_id self = getSelf();
string cloneName = "@base_player:clone_location_unknown";
switch (cloneType)
{
case cloninglib.CLONE_TYPE_STANDARD:
case cloninglib.CLONE_TYPE_PLAYER_CITY:
case cloninglib.CLONE_TYPE_RESTRICTED:
map_location cl = getPlanetaryMapLocation(self);
if ( cl != null )
{
cloneName = cl.getLocationName();
}
else if (nameOverride != null && nameOverride != "")
{
cloneName = nameOverride;
}
else
{
cloneName = null;
}
break;
case cloninglib.CLONE_TYPE_JEDI_ONLY:
location spawnLoc = cloninglib.getCloneSpawnLocation(self);
cloneName = "@base_player:clone_location_force_shrine ("+(int)spawnLoc.x+", "+(int)spawnLoc.z+")";
break;
case cloninglib.CLONE_TYPE_LIGHT_JEDI_ONLY:
case cloninglib.CLONE_TYPE_DARK_JEDI_ONLY:
cloneName = "@base_player:clone_location_jedi_enclave";
break;
case cloninglib.CLONE_TYPE_FACTION_IMPERIAL:
cloneName = nameOverride;
break;
case cloninglib.CLONE_TYPE_FACTION_REBEL:
cloneName = nameOverride;
break;
case cloninglib.CLONE_TYPE_PVP_REGION_ADVANCED_IMPERIAL:
cloneName = nameOverride;
break;
case cloninglib.CLONE_TYPE_PVP_REGION_ADVANCED_REBEL:
cloneName = nameOverride;
break;
case cloninglib.CLONE_TYPE_CAMP:
obj_id parent = getObjIdObjVar(self, "theater.parent");
if(isIdValid(parent))
{
string name = getName(parent);
if(name != null && !name.equals(""))
cloneName = name;
else
cloneName = nameOverride;
}
else
cloneName = nameOverride;
break;
case cloninglib.CLONE_TYPE_PRIVATE_INSTANCE:
cloneName = nameOverride;
break;
}
return cloneName;
}
messageHandler requestCloningData()
{
obj_id requester = params.getObjId("requester");
dictionary data = new dictionary();
string cloneName = getCloneName(self);
location facilityLoc = getLocation(self);
location spawnLoc = cloninglib.getCloneSpawnLocation(self);
data.put("faciltyId", self);
data.put("cloneName", cloneName);
data.put("facilityLoc", facilityLoc);
data.put("spawnLoc", spawnLoc);
messageTo(requester, "handleCloningDataUpdate", data, 0, false);
return SCRIPT_CONTINUE;
}
messageHandler retryInitializeCloningFacility()
{
// stop after 5 retry
int numberOfRetry = params.getInt("number_of_retry");
if (numberOfRetry >= 5)
return SCRIPT_CONTINUE;
string planetName = getCurrentSceneName();
if(planetName == null || planetName.length() <= 0)
{
CustomerServiceLog("Cloning_Center", "The cloning center "+self+" registration reports a failure. Attempted to register cloning center but could not get a valid planet name! Aborting registration.");
return SCRIPT_CONTINUE;
}
obj_id planet = getPlanetByName(planetName);
if(!isValidId(planet))
{
CustomerServiceLog("Cloning_Center", "The cloning center "+self+" registration reports a failure. Attempted to register cloning center but could not get a valid planet OID for planet: "+planetName+". Aborting registration.");
return SCRIPT_CONTINUE;
}
obj_id[] idList = utils.getObjIdArrayScriptVar(planet, cloninglib.VAR_PLANET_CLONE_ID);
if(idList != null && idList.length > 0)
{
for(int i = 0; i < idList.length - 1; i++)
{
if(idList[i] != self)
continue;
//the cloning facility has been registered
return SCRIPT_CONTINUE;
}
}
// if the idList doesnt have the clonign facility, try again
if(!requestCloningFacilityRegistration(self))
{
CustomerServiceLog("Cloning_Center", "The cloning center "+self+" registration reports a failure. Attempted to register cloning center("+getTemplateName(self)+"/"+self+") but this action failed.");
}
// check again in 1 minute and try again if for some reason we didn't get initialized
++numberOfRetry;
if (numberOfRetry < 5)
{
params.put("number_of_retry", numberOfRetry);
messageTo(self, "retryInitializeCloningFacility", params, 120.0f, false);
}
return SCRIPT_CONTINUE;
}
boolean requestCloningFacilityRegistration(obj_id cloningFacility)
{
if(!isValidId(cloningFacility))
return false;
if ( player_structure.isCivic( cloningFacility ) )
{
planetary_map.addMapLocation( cloningFacility );
// Rick do I need to do this each time?
int city_id = getCityAtLocation( getLocation( cloningFacility ), 0 );
if(city_id < 0)
{
CustomerServiceLog("Cloning_Center", "The cloning center (which is "+cloningFacility+") could not continue the planet registration process because the city_id was invalid. Registeration of cloning center("+getTemplateName(cloningFacility)+"/"+cloningFacility+") aborted.");
return false;
}
city.setCloneInfo( city_id, getLocation( cloningFacility ), cloninglib.getCloneSpawnLocation(cloningFacility), cloningFacility );
}
// get datatable entry
string myTemplate = getTemplateName(cloningFacility);
if(myTemplate == null || myTemplate.length() <= 0)
{
CustomerServiceLog("Cloning_Center", "The cloning center which is "+cloningFacility+" could not continue the planet registration process because the object template for the cloning center was invalid. Registeration of cloning center("+getTemplateName(cloningFacility)+"/"+cloningFacility+") aborted.");
return false;
}
dictionary facilityData = dataTableGetRow(structure.DATATABLE_CLONING_FACILITY_RESPAWN, myTemplate);
if(facilityData == null)
{
CustomerServiceLog("Cloning_Center", "The cloning center (which is "+cloningFacility+" of template: "+myTemplate+") was not found in the datatables/structure/municipal/cloning_facility_respawn.iff table. Registeration aborted.");
return false;
}
dictionary dict = new dictionary();
dict.put("facilityData", facilityData);
// determine how many spawning tubes we have
int numTubes = 0;
if (facilityData != null)
numTubes = facilityData.getInt(structure.DATATABLE_COL_TUBES);
if ( numTubes > 0 )
{
deltadictionary scriptvars = cloningFacility.getScriptVars();
scriptvars.put(VAR_NUM_RESPAWN_TUBES, numTubes);
scriptvars.put(VAR_CURRENT_RESPAWN_TUBE, 0);
}
messageTo(cloningFacility, "registerCloningFacility", dict, 60.0f, false);
return true;
}
@@ -0,0 +1,105 @@
package script.structure.municipal;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
import script.library.create;
import script.library.structure;
import script.library.player_structure;
import script.library.utils;
public class cloning_facility extends script.structure.municipal.cloning_base
{
public cloning_facility()
{
}
public static final String SCRIPT_CLONING_FACILITY = "structure.municipal.cloning_facility";
public static final String DATATABLE_TERMINAL_LIST = "datatables/structure/municipal/cloning_facility_terminal.iff";
public int OnInitialize(obj_id self) throws InterruptedException
{
messageTo(self, "handleTerminalSpawning", null, 5f, false);
return super.OnInitialize(self);
}
public int OnDetach(obj_id self) throws InterruptedException
{
obj_id planet = getPlanetByName(getCurrentSceneName());
if (isIdValid(planet))
{
dictionary params = new dictionary();
params.put("id", self);
messageTo(planet, "unregisterCloningFacility", params, 1.0f, false);
}
return super.OnDetach(self);
}
public int handleTerminalSpawning(obj_id self, dictionary params) throws InterruptedException
{
createCloningDroid(self);
if (!player_structure.isCivic(self))
{
structure.createStructureTerminals(self, SCRIPT_CLONING_FACILITY, DATATABLE_TERMINAL_LIST);
}
return SCRIPT_CONTINUE;
}
public void createCloningDroid(obj_id facility) throws InterruptedException
{
if (!isIdValid(facility))
{
return;
}
String facilityTemplate = getTemplateName(facility);
float fYaw = getYaw(facility);
String sceneName = getCurrentSceneName();
int numRows = dataTableGetNumRows(DATATABLE_TERMINAL_LIST);
Vector terminals = new Vector();
terminals.setSize(0);
for (int i = 0; i < numRows; i++)
{
String buildingTemplate = dataTableGetString(DATATABLE_TERMINAL_LIST, i, structure.DATATABLE_COL_STRUCTURE);
if (buildingTemplate.equals(facilityTemplate))
{
dictionary item = dataTableGetRow(DATATABLE_TERMINAL_LIST, i);
String droid_name = item.getString("DROID");
if (droid_name == null || droid_name.equals(""))
{
continue;
}
float x = item.getFloat(structure.DATATABLE_COL_X);
float y = item.getFloat(structure.DATATABLE_COL_Y);
float z = item.getFloat(structure.DATATABLE_COL_Z);
float relativeHeading = item.getFloat(structure.DATATABLE_COL_HEADING);
String cell_name = item.getString(structure.DATATABLE_COL_CELL);
obj_id cell_id = obj_id.NULL_ID;
if (!cell_name.equals(structure.WORLD_DELTA))
{
cell_id = getCellId(facility, cell_name);
}
if (cell_id != null)
{
obj_id droid_id = obj_id.NULL_ID;
location spot = new location(x, y, z, sceneName, cell_id);
float heading = relativeHeading;
if (cell_id == obj_id.NULL_ID)
{
location fLoc = getLocation(facility);
spot = new location(fLoc.x + x, fLoc.y + y, fLoc.z + z, sceneName, cell_id);
if (fYaw != 0)
{
spot = utils.rotatePointXZ(fLoc, spot, fYaw);
heading -= (90 - fYaw);
}
}
droid_id = create.object(droid_name, spot);
if ((droid_id != null) && (droid_id != obj_id.NULL_ID))
{
setYaw(droid_id, heading);
}
}
}
}
}
}
@@ -1,129 +0,0 @@
/**
* Title: cloning_facility.script
* Description: script for cloning facilities
*/
/***** INCLUDES ********************************************************/
include library.create;
include library.structure;
include library.player_structure;
include library.utils;
/***** INHERITS ********************************************************/
inherits structure.municipal.cloning_base;
/***** CONSTANTS *******************************************************/
const string SCRIPT_CLONING_FACILITY = "structure.municipal.cloning_facility";
//FACILITY DATATABLES
const string DATATABLE_TERMINAL_LIST = "datatables/structure/municipal/cloning_facility_terminal.iff";
/***** TRIGGERS ********************************************************/
trigger OnInitialize()
{
messageTo( self, "handleTerminalSpawning", null, 5f, false );
return super.OnInitialize(self);
}
trigger OnDetach()
{
obj_id planet = getPlanetByName(getCurrentSceneName());
if (isIdValid(planet))
{
dictionary params = new dictionary();
params.put("id", self);
messageTo(planet, "unregisterCloningFacility", params, 1.0f, false);
}
return super.OnDetach(self);
}
/***** FUNCTIONS *******************************************************/
/***** MESSAGEHANDLERS *************************************************/
messageHandler handleTerminalSpawning()
{
createCloningDroid(self);
if(!player_structure.isCivic(self))
structure.createStructureTerminals(self, SCRIPT_CLONING_FACILITY, DATATABLE_TERMINAL_LIST);
return SCRIPT_CONTINUE;
}
void createCloningDroid(obj_id facility)
{
if(!isIdValid(facility))
return;
string facilityTemplate = getTemplateName(facility);
float fYaw = getYaw(facility);
string sceneName = getCurrentSceneName();
int numRows = dataTableGetNumRows(DATATABLE_TERMINAL_LIST);
resizeable obj_id[] terminals = new obj_id[0];
for(int i = 0; i < numRows; i++)
{
string buildingTemplate = dataTableGetString(DATATABLE_TERMINAL_LIST, i, structure.DATATABLE_COL_STRUCTURE);
if(buildingTemplate.equals(facilityTemplate))
{
dictionary item = dataTableGetRow(DATATABLE_TERMINAL_LIST, i);
string droid_name = item.getString("DROID");
if(droid_name == null || droid_name.equals(""))
continue;
float x = item.getFloat(structure.DATATABLE_COL_X);
float y = item.getFloat(structure.DATATABLE_COL_Y);
float z = item.getFloat(structure.DATATABLE_COL_Z);
float relativeHeading = item.getFloat(structure.DATATABLE_COL_HEADING);
string cell_name = item.getString(structure.DATATABLE_COL_CELL);
obj_id cell_id = obj_id.NULL_ID;
if(!cell_name.equals(structure.WORLD_DELTA))
{
cell_id = getCellId(facility, cell_name);
}
if(cell_id != null)
{
obj_id droid_id = obj_id.NULL_ID;
location spot = new location(x, y, z, sceneName, cell_id);
float heading = relativeHeading;
if(cell_id == obj_id.NULL_ID)
{
location fLoc = getLocation(facility);
spot = new location(fLoc.x + x, fLoc.y + y, fLoc.z + z, sceneName, cell_id);
if(fYaw != 0)
{
spot = utils.rotatePointXZ(fLoc, spot, fYaw);
heading -= (90 - fYaw);
}
}
droid_id = create.object(droid_name, spot);
if((droid_id != null) && (droid_id != obj_id.NULL_ID))
setYaw(droid_id, heading);
}
}
}
}
@@ -0,0 +1,46 @@
package script.structure.municipal;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
import script.library.healing;
import script.library.structure;
import script.library.player_structure;
import script.library.utils;
public class hospital extends script.base_script
{
public hospital()
{
}
public static final int HEALING_PULSE_MIN = 200;
public static final int HEALING_PULSE_MAX = 400;
public static final int WOUND_HEAL = 10;
public static final int SHOCK_HEAL = 3;
public int OnAttach(obj_id self) throws InterruptedException
{
if (player_structure.isCivic(self))
{
if (!utils.hasScriptVar(self, "terminalsCreated"))
{
structure.createStructureTerminals(self, "datatables/structure/municipal/registration_terminal.iff");
utils.setScriptVar(self, "terminalsCreated", true);
}
}
return SCRIPT_CONTINUE;
}
public int OnInitialize(obj_id self) throws InterruptedException
{
if (!utils.hasScriptVar(self, "terminalsCreated"))
{
structure.createStructureTerminals(self, "datatables/structure/municipal/registration_terminal.iff");
utils.setScriptVar(self, "terminalsCreated", true);
}
return SCRIPT_CONTINUE;
}
}
@@ -1,52 +0,0 @@
/**********************************************************************
* Title: hospital_heal
* Description: allows the slow healing of wounds and shock for all within
* the building.
**********************************************************************/
/***** INCLUDES ********************************************************/
include library.healing;
include library.structure;
include library.player_structure;
include library.utils;
/***** CONSTANTS *******************************************************/
const int HEALING_PULSE_MIN = 200;
const int HEALING_PULSE_MAX = 400;
const int WOUND_HEAL = 10;
const int SHOCK_HEAL = 3 ;
/***** TRIGGERS ********************************************************/
trigger OnAttach()
{
if ( player_structure.isCivic( self ) )
{
if (!utils.hasScriptVar(self, "terminalsCreated" ))
{
structure.createStructureTerminals( self, "datatables/structure/municipal/registration_terminal.iff" );
utils.setScriptVar(self, "terminalsCreated",true );
}
}
return SCRIPT_CONTINUE;
}
trigger OnInitialize()
{
if (!utils.hasScriptVar(self, "terminalsCreated" ))
{
structure.createStructureTerminals( self, "datatables/structure/municipal/registration_terminal.iff" );
utils.setScriptVar(self, "terminalsCreated",true );
}
return SCRIPT_CONTINUE;
}
/***** MESSAGEHANDLERS *************************************************/
/***** COMMANDHANDLERS *************************************************/
/***** FUNCTIONS *******************************************************/
@@ -0,0 +1,135 @@
package script.structure.municipal;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
import script.library.travel;
import script.library.player_structure;
public class starport extends script.base_script
{
public starport()
{
}
public int OnAttach(obj_id self) throws InterruptedException
{
LOG("LOG_CHANNEL", "starport::OnAttach -- " + self);
if (player_structure.isCivic(self))
{
return SCRIPT_CONTINUE;
}
doInitializeStarport(self);
return SCRIPT_CONTINUE;
}
public int OnDetach(obj_id self) throws InterruptedException
{
travel.destroyBaseObjects(self);
travel.removeTravelPoint(self);
return SCRIPT_CONTINUE;
}
public int OnInitialize(obj_id self) throws InterruptedException
{
LOG("LOG_CHANNEL", "starport::OnIntialize -- " + self);
if (player_structure.isCivic(self))
{
return SCRIPT_CONTINUE;
}
doInitializeStarport(self);
int numberOfRetry = 0;
dictionary params = new dictionary();
params.put("number_of_retry", numberOfRetry);
messageTo(self, "retryInitializeStarport", params, 60.0f, false);
return SCRIPT_CONTINUE;
}
public int OnUnloadedFromMemory(obj_id self) throws InterruptedException
{
LOG("LOG_CHANNEL", "starport::OnUnloadedFromMemory -- " + self);
return SCRIPT_CONTINUE;
}
public int OnDestroy(obj_id self) throws InterruptedException
{
LOG("LOG_CHANNEL", "starport::OnDestroy -- " + self);
boolean success = travel.removeTravelPoint(self);
if (!success)
{
LOG("LOG_CHANNEL", "Unable to remove travel point for " + self);
}
travel.destroyBaseObjects(self);
return SCRIPT_CONTINUE;
}
public int msgArrivalLocation(obj_id self, dictionary params) throws InterruptedException
{
LOG("LOG_CHANNEL", "starport::msgArrivalLocation -- " + self + " " + params);
location loc = travel.getArrivalLocation(self);
obj_id player = params.getObjId("player");
LOG("LOG_CHANNEL", "starport::msgArrivalLocation -- loc ->" + loc);
params.put("location", loc);
messageTo(player, "msgTravelToStarport", params, 0.0f, true);
return SCRIPT_CONTINUE;
}
public int msgRestartShuttle(obj_id self, dictionary params) throws InterruptedException
{
LOG("LOG_CHANNEL", "starport::msgRestartShuttle -- " + self);
obj_id shuttle = params.getObjId("shuttle");
if (shuttle == null || shuttle == obj_id.NULL_ID)
{
LOG("LOG_CHANNEL", "starport::msgRestartShuttle -- shuttle is null for " + self);
return SCRIPT_CONTINUE;
}
setPosture(shuttle, POSTURE_UPRIGHT);
queueCommand(shuttle, (-1465754503), self, "", COMMAND_PRIORITY_FRONT);
setObjVar(self, travel.VAR_SHUTTLE_AVAILABLE, 1);
setObjVar(self, travel.VAR_SHUTTLE_TIMESTAMP, getGameTime());
params.put("starport", self);
int ground_time = travel.getGroundTime(self);
messageTo(shuttle, "msgRestartShuttle", params, 1.0f, false);
LOG("LOG_CHANNEL", "starport::msgRestartShuttle -- sending message to " + shuttle);
return SCRIPT_CONTINUE;
}
public int retryInitializeStarport(obj_id self, dictionary params) throws InterruptedException
{
String planet = getCurrentSceneName();
String travel_point = travel.getTravelPointName(self);
if ((planet != null) && (travel_point != null))
{
location loc = getPlanetTravelPointLocation(planet, travel_point);
if (loc != null)
{
return SCRIPT_CONTINUE;
}
}
int numberOfRetry = params.getInt("number_of_retry");
if (numberOfRetry >= 5)
{
return SCRIPT_CONTINUE;
}
doInitializeStarport(self);
++numberOfRetry;
if (numberOfRetry < 5)
{
params.put("number_of_retry", numberOfRetry);
messageTo(self, "retryInitializeStarport", params, 60.0f, false);
}
return SCRIPT_CONTINUE;
}
public void doInitializeStarport(obj_id self) throws InterruptedException
{
if (player_structure.isCivic(self))
{
return;
}
String travel_point = travel.getTravelPointName(self);
int travel_cost = travel.getTravelCost(self);
if (travel_point == null || travel_cost == -1)
{
LOG("LOG_CHANNEL", "starport::doInitializeStarport -- Unable to obtain valid travel_point information for " + self);
return;
}
travel.initializeStarport(self, travel_point, travel_cost, false);
}
}
@@ -1,172 +0,0 @@
/**********************************************************************
* Title: starport.script
* Description: handles the travel location functionality on starports
**********************************************************************/
/***** INCLUDES ********************************************************/
include library.travel;
include library.player_structure;
/***** CONSTANTS *******************************************************/
/***** TRIGGERS ********************************************************/
trigger OnAttach()
{
LOG("LOG_CHANNEL", "starport::OnAttach -- " + self);
if ( player_structure.isCivic( self ) )
return SCRIPT_CONTINUE;
doInitializeStarport(self);
return SCRIPT_CONTINUE;
}
trigger OnDetach()
{
travel.destroyBaseObjects(self);
travel.removeTravelPoint(self);
return SCRIPT_CONTINUE;
}
trigger OnInitialize()
{
LOG("LOG_CHANNEL", "starport::OnIntialize -- " + self);
// Ignore this for the case of civic starports.
if ( player_structure.isCivic( self ) )
return SCRIPT_CONTINUE;
doInitializeStarport(self);
// check again in 1 minute and try again if for some reason we didn't get initialized
int numberOfRetry = 0;
dictionary params = new dictionary();
params.put("number_of_retry", numberOfRetry);
messageTo(self, "retryInitializeStarport", params, 60.0f, false);
return SCRIPT_CONTINUE;
}
trigger OnUnloadedFromMemory()
{
LOG("LOG_CHANNEL", "starport::OnUnloadedFromMemory -- " + self);
return SCRIPT_CONTINUE;
}
trigger OnDestroy()
{
LOG("LOG_CHANNEL", "starport::OnDestroy -- " + self);
// Remove the travel point
boolean success = travel.removeTravelPoint(self);
if (!success)
LOG("LOG_CHANNEL", "Unable to remove travel point for " + self);
// Clean up travel base objects
travel.destroyBaseObjects(self);
return SCRIPT_CONTINUE;
}
/***** MESSAGEHANDLERS *************************************************/
messageHandler msgArrivalLocation()
{
LOG("LOG_CHANNEL", "starport::msgArrivalLocation -- " + self + " " + params);
location loc = travel.getArrivalLocation(self);
obj_id player = params.getObjId("player");
LOG("LOG_CHANNEL", "starport::msgArrivalLocation -- loc ->" + loc);
params.put("location", loc);
messageTo(player, "msgTravelToStarport", params, 0.0f, true);
return SCRIPT_CONTINUE;
}
messageHandler msgRestartShuttle()
{
LOG("LOG_CHANNEL", "starport::msgRestartShuttle -- " + self);
obj_id shuttle = params.getObjId("shuttle");
if (shuttle == null || shuttle == obj_id.NULL_ID)
{
LOG("LOG_CHANNEL", "starport::msgRestartShuttle -- shuttle is null for " + self);
return SCRIPT_CONTINUE;
}
setPosture(shuttle, POSTURE_UPRIGHT);
queueCommand(shuttle, ##"stand", self, "", COMMAND_PRIORITY_FRONT);
setObjVar(self, travel.VAR_SHUTTLE_AVAILABLE, 1);
setObjVar(self, travel.VAR_SHUTTLE_TIMESTAMP, getGameTime());
params.put("starport", self);
int ground_time = travel.getGroundTime(self);
messageTo(shuttle, "msgRestartShuttle", params, 1.0f, false);
LOG("LOG_CHANNEL", "starport::msgRestartShuttle -- sending message to " + shuttle);
return SCRIPT_CONTINUE;
}
messageHandler retryInitializeStarport()
{
// nothing to do if already initialized
string planet = getCurrentSceneName();
string travel_point = travel.getTravelPointName(self);
if ((planet != null) && (travel_point != null))
{
location loc = getPlanetTravelPointLocation(planet, travel_point);
if (loc != null)
return SCRIPT_CONTINUE;
}
// stop after 5 retry
int numberOfRetry = params.getInt("number_of_retry");
if (numberOfRetry >= 5)
return SCRIPT_CONTINUE;
// try again
doInitializeStarport(self);
// check again in 1 minute and try again if for some reason we didn't get initialized
++numberOfRetry;
if (numberOfRetry < 5)
{
params.put("number_of_retry", numberOfRetry);
messageTo(self, "retryInitializeStarport", params, 60.0f, false);
}
return SCRIPT_CONTINUE;
}
/***** COMMANDHANDLERS *************************************************/
/***** FUNCTIONS *******************************************************/
void doInitializeStarport(obj_id self)
{
// Ignore this for the case of civic starports.
if ( player_structure.isCivic( self ) )
return;
// Add the structure's travel point.
string travel_point = travel.getTravelPointName(self);
int travel_cost = travel.getTravelCost(self);
if (travel_point == null || travel_cost == -1)
{
LOG("LOG_CHANNEL", "starport::doInitializeStarport -- Unable to obtain valid travel_point information for " + self);
return;
}
travel.initializeStarport(self, travel_point, travel_cost,false);
}
@@ -0,0 +1,68 @@
package script.structure.municipal;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
import script.library.city;
import script.library.travel;
public class starport_city extends script.structure.municipal.starport
{
public starport_city()
{
}
public int OnAttach(obj_id self) throws InterruptedException
{
messageTo(self, "setupStartport", null, 1.f, false);
return super.OnAttach(self);
}
public int OnInitialize(obj_id self) throws InterruptedException
{
String planet = getCurrentSceneName();
String travel_point = travel.getTravelPointName(self);
location arrival_loc = travel.getArrivalLocation(self);
int travel_cost = travel.getTravelCost(self);
if (travel_point == null || travel_cost == -1)
{
return super.OnInitialize(self);
}
travel.initializeStarport(self, travel_point, travel_cost, true);
return super.OnInitialize(self);
}
public int setupStartport(obj_id self, dictionary params) throws InterruptedException
{
int city_id = getCityAtLocation(getLocation(self), 0);
obj_id mayor = cityGetLeader(city_id);
int cost = cityGetTravelCost(city_id);
if (cost > 0)
{
destroyObject(self);
return SCRIPT_CONTINUE;
}
String cityName = cityGetName(city_id);
String travel_point = cityName;
int travel_cost = 100;
travel.initializeStarport(self, travel_point, travel_cost, true);
return SCRIPT_CONTINUE;
}
public int OnDestroy(obj_id self) throws InterruptedException
{
boolean initd = false;
obj_id[] objects = getObjIdArrayObjVar(self, "travel.base_object");
for (int i = 0; i < objects.length; i++)
{
destroyObject(objects[i]);
initd = true;
}
if (initd)
{
city.removeStarport(self);
}
return super.OnInitialize(self);
}
}
@@ -1,83 +0,0 @@
/**********************************************************************
* Title: starport.script
* Description: handles the travel location functionality on starports
**********************************************************************/
include library.city;
include library.travel;
inherits structure.municipal.starport;
trigger OnAttach()
{
messageTo( self, "setupStartport", null, 1.f, false );
return super.OnAttach(self);
}
trigger OnInitialize()
{
// Add the structure's travel point.
string planet = getCurrentSceneName();
string travel_point = travel.getTravelPointName( self );
location arrival_loc = travel.getArrivalLocation( self );
int travel_cost = travel.getTravelCost( self );
if ( travel_point == null || travel_cost == -1 )
return super.OnInitialize(self);
travel.initializeStarport( self, travel_point, travel_cost, true );
return super.OnInitialize(self);
}
messageHandler setupStartport()
{
// Get city info.
int city_id = getCityAtLocation( getLocation( self ), 0 );
obj_id mayor = cityGetLeader( city_id );
// Do we already have a shuttleport?
int cost = cityGetTravelCost( city_id );
if ( cost > 0 )
{
// CHEATERS! They somehow were able to almost place a 2nd shuttleport.
// Notify the mayor that this happened.
// DIE!
destroyObject( self );
return SCRIPT_CONTINUE;
}
// Set an initial object name.
string cityName = cityGetName( city_id );
string travel_point = cityName;
// Set an initial cost.
int travel_cost = 100;
// Do it!
travel.initializeStarport( self, travel_point, travel_cost, true );
return SCRIPT_CONTINUE;
}
trigger OnDestroy()
{
// We need to clean up our travel objects.
boolean initd = false;
obj_id[] objects = getObjIdArrayObjVar( self, "travel.base_object" );
for ( int i=0; i<objects.length; i++ )
{
destroyObject( objects[i] );
initd = true;
}
// Get rid of our travel location.
if ( initd )
city.removeStarport( self );
return super.OnInitialize(self);
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,106 @@
package script.structure;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
import script.library.player_structure;
import script.library.utils;
public class serving_droid_control extends script.base_script
{
public serving_droid_control()
{
}
public static final String DROID_ID = "serving_droid.droid";
public int OnAttach(obj_id self) throws InterruptedException
{
messageTo(self, "checkdroidId", null, 3, false);
return SCRIPT_CONTINUE;
}
public int OnReceivedItem(obj_id self, obj_id srcContainer, obj_id transferer, obj_id item) throws InterruptedException
{
if (isPlayer(item))
{
messageTo(self, "handleReceived", null, 6, false);
}
return SCRIPT_CONTINUE;
}
public int OnLostItem(obj_id self, obj_id srcContainer, obj_id transferer, obj_id item) throws InterruptedException
{
if (isPlayer(item))
{
messageTo(self, "handleLost", null, 6, false);
}
return SCRIPT_CONTINUE;
}
public int checkDroidId(obj_id self, dictionary params) throws InterruptedException
{
if (!isValidId(getObjIdObjVar(self, DROID_ID)))
{
detachScript(self, "structure.serving_droid_control");
}
return SCRIPT_CONTINUE;
}
public int handleReceived(obj_id self, dictionary params) throws InterruptedException
{
if (!isValidId(self) && !exists(self))
{
return SCRIPT_CONTINUE;
}
if (!hasObjVar(self, DROID_ID) && !exists(self))
{
detachScript(self, "structure.serving_droid_control");
}
obj_id droid = getObjIdObjVar(self, DROID_ID);
if (!isValidId(droid) && !exists(self))
{
return SCRIPT_CONTINUE;
}
if (utils.hasScriptVar(droid, "droid.moving") || utils.hasScriptVar(droid, "droid.settingPatrol"))
{
return SCRIPT_CONTINUE;
}
obj_id[] players = player_structure.getPlayersInBuilding(self);
if (players == null || players.length == 0)
{
return SCRIPT_CONTINUE;
}
if (players.length > 1)
{
return SCRIPT_CONTINUE;
}
broadcastMessage("handleActivateDroid", new dictionary());
return SCRIPT_CONTINUE;
}
public int handleLost(obj_id self, dictionary params) throws InterruptedException
{
if (!isValidId(self) && !exists(self))
{
return SCRIPT_CONTINUE;
}
if (!hasObjVar(self, DROID_ID) && !exists(self))
{
detachScript(self, "structure.serving_droid_control");
}
obj_id droid = getObjIdObjVar(self, DROID_ID);
if (!isValidId(droid) && !exists(self))
{
return SCRIPT_CONTINUE;
}
if (utils.hasScriptVar(droid, "droid.settingPatrol"))
{
return SCRIPT_CONTINUE;
}
obj_id[] players = player_structure.getPlayersInBuilding(self);
if (players == null || players.length == 0)
{
broadcastMessage("handleDeactivateDroid", new dictionary());
}
return SCRIPT_CONTINUE;
}
}
@@ -1,99 +0,0 @@
// ALL SERVING DROID SCRIPTS
// structure/serving_droid_control.script
// creature/serving_droid.script
// item/droid/serving_droid_terminal.script
include library.player_structure;
include library.utils;
//variable constants
const string DROID_ID = "serving_droid.droid";
trigger OnAttach()
{
messageTo(self, "checkdroidId", null, 3, false);
return SCRIPT_CONTINUE;
}
trigger OnReceivedItem(obj_id srcContainer, obj_id transferer, obj_id item)
{
if(isPlayer(item))
messageTo(self, "handleReceived", null, 6, false);
return SCRIPT_CONTINUE;
}
trigger OnLostItem(obj_id srcContainer, obj_id transferer, obj_id item)
{
if(isPlayer(item))
messageTo(self, "handleLost", null, 6, false);
return SCRIPT_CONTINUE;
}
//This is called on init to get the terminal user's OID
messageHandler checkDroidId()
{
//remove the script if no droid exists
//IFhASoBJVAR here
//if !exists if (incubator.isStatEnzyme(self) && exists(self))
if(!isValidId(getObjIdObjVar(self, DROID_ID)))
detachScript(self, "structure.serving_droid_control");
return SCRIPT_CONTINUE;
}
messageHandler handleReceived()
{
//remove the script if no droid exists
if(!isValidId(self) && !exists(self))
return SCRIPT_CONTINUE;
if(!hasObjVar(self, DROID_ID) && !exists(self))
detachScript(self, "structure.serving_droid_control");
obj_id droid = getObjIdObjVar(self, DROID_ID);
if(!isValidId(droid) && !exists(self))
return SCRIPT_CONTINUE;
//the droid is moving already or the owner is setting patrols
if(utils.hasScriptVar(droid, "droid.moving") || utils.hasScriptVar(droid, "droid.settingPatrol"))
return SCRIPT_CONTINUE;
obj_id[] players = player_structure.getPlayersInBuilding(self);
if(players == null || players.length == 0)
return SCRIPT_CONTINUE;
//players already here
if(players.length > 1)
return SCRIPT_CONTINUE;
//Reactivate the sleeping droid
broadcastMessage("handleActivateDroid", new dictionary());
return SCRIPT_CONTINUE;
}
messageHandler handleLost()
{
//remove the script if no droid exists
if(!isValidId(self) && !exists(self))
return SCRIPT_CONTINUE;
if(!hasObjVar(self, DROID_ID) && !exists(self))
detachScript(self, "structure.serving_droid_control");
obj_id droid = getObjIdObjVar(self, DROID_ID);
if(!isValidId(droid) && !exists(self))
return SCRIPT_CONTINUE;
if(utils.hasScriptVar(droid, "droid.settingPatrol"))
return SCRIPT_CONTINUE;
obj_id[] players = player_structure.getPlayersInBuilding(self);
if(players == null || players.length == 0)
{
broadcastMessage("handleDeactivateDroid", new dictionary());
}
return SCRIPT_CONTINUE;
}
@@ -0,0 +1,159 @@
package script.structure;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
import script.library.utils;
import script.library.player_structure;
import script.library.city;
import script.library.prose;
import script.library.trace;
import script.library.vendor_lib;
public class structure_rollup extends script.base_script
{
public structure_rollup()
{
}
public int OnDoStructureRollup(obj_id self, obj_id player, boolean warnOnly) throws InterruptedException
{
String structName = player_structure.getStructureName(self);
if (structName.length() < 1)
{
structName = "Structure";
}
location where = getLocation(self);
if (warnOnly)
{
string_id subject = new string_id("player_structure", "structure_purge_warning_subject");
string_id body = new string_id("player_structure", "structure_purge_warning_body");
prose_package pp = new prose_package();
prose.setStringId(pp, body);
prose.setTO(pp, getPlayerFullName(player));
String body_oob = chatMakePersistentMessageOutOfBandBody(null, pp);
String subject_str = "@" + subject.toString();
body_oob = chatAppendPersistentMessageWaypointData(body_oob, where.area, where.x, where.z, null, structName);
String[] admins = player_structure.getAdminListNames(self);
for (int i = 0; i < admins.length; ++i)
{
chatSendPersistentMessage("Galactic Housing Authority", admins[i], subject_str, null, body_oob);
}
if (city.isInCity(self))
{
int cityId = city.getStructureCityId(self);
if (cityId != 0)
{
obj_id mayor = cityGetLeader(cityId);
if (mayor != obj_id.NULL_ID)
{
chatSendPersistentMessage("Galactic Housing Authority", mayor, subject_str, null, body_oob);
}
}
}
obj_id nameTarget = self;
if (player_structure.isBuilding(nameTarget))
{
obj_id sign = getObjIdObjVar(nameTarget, player_structure.VAR_SIGN_ID);
if (isIdValid(sign))
{
nameTarget = sign;
}
}
String abandoned = " \\#FF0000\\(Abandoned)";
setName(nameTarget, structName + abandoned);
if (nameTarget != self)
{
setObjVar(self, player_structure.VAR_SIGN_NAME, structName + abandoned);
}
}
else
{
if (player_structure.isBuilding(self))
{
obj_id[] players = player_structure.getPlayersInBuilding(self);
if (players != null)
{
for (int i = 0; i < players.length; i++)
{
expelFromBuilding(players[i]);
}
}
String[] cells = getCellNames(self);
if (cells != null)
{
for (int i = 0; i < cells.length; i++)
{
obj_id cellid = getCellId(self, cells[i]);
obj_id contents[] = getContents(cellid);
if (contents != null)
{
for (int j = 0; j < contents.length; j++)
{
if (hasCondition(contents[j], CONDITION_VENDOR))
{
obj_id owner = getObjIdObjVar(contents[j], "vendor_owner");
if (!isIdValid(owner))
{
owner = getOwner(contents[j]);
}
vendor_lib.finalizePackUp(owner, contents[j], player, player_structure.isAbandoned(self));
}
}
}
}
}
}
obj_id scd = createObject("object/intangible/house/generic_house_control_device.iff", where);
setName(scd, structName);
setOwner(scd, player);
if (!persistObject(scd))
{
LOG("LOG_CHANNEL", "structure_rollup.OnDoStructureRollup persist SCD failed!");
return SCRIPT_CONTINUE;
}
attachScript(scd, "structure.house_control_device");
if (hasObjVar(self, player_structure.VAR_WAYPOINT_STRUCTURE))
{
obj_id waypoint = getObjIdObjVar(self, player_structure.VAR_WAYPOINT_STRUCTURE);
if (isIdValid(waypoint))
{
destroyWaypointInDatapad(waypoint, player);
removeObjVar(self, player_structure.VAR_WAYPOINT_STRUCTURE);
}
}
player_structure.destroyStructureSign(self);
if (player_structure.isResidence(self, player))
{
setHouseId(player, obj_id.NULL_ID);
removeObjVar(self, player_structure.VAR_RESIDENCE_BUILDING);
city.removeCitizen(player, self);
}
city.removeStructureFromCity(self);
String template = getTemplateName(self);
player_structure.setDeedTemplate(scd, template);
if (isIdValid(player) && exists(player))
{
obj_id lotOverlimitStructure = getObjIdObjVar(player, "lotOverlimit.structure_id");
if (isIdValid(lotOverlimitStructure) && (lotOverlimitStructure == self))
{
setObjVar(player, "lotOverlimit.structure_location", "Datapad");
}
}
putIn(self, scd);
if (hasObjVar(self, "purge_process.rollup_on_load"))
{
removeObjVar(self, "purge_process.rollup_on_load");
}
final int maxDepth = player_structure.isFactory(self) ? 101 : 1;
moveToOfflinePlayerDatapadAndUnload(scd, player, maxDepth + 1);
fixLoadWith(self, player, maxDepth);
trace.log("housepackup", getPlayerFullName(player) + "(" + player + ") had their house rolled up by the purge process (" + self + ", loc " + where.toString() + ") into structure control device " + scd, player, trace.TL_CS_LOG);
}
return SCRIPT_CONTINUE;
}
}
@@ -1,188 +0,0 @@
/**********************************************************************
* Title: structure_rollup.script
* Description: script to rollup a structure, placing all the contents in a player's inventory
**********************************************************************/
/***** INCLUDES ********************************************************/
include library.utils;
include library.player_structure;
include library.city;
include library.prose;
include library.trace;
include library.vendor_lib;
/***** TRIGGERS ********************************************************/
trigger OnDoStructureRollup(obj_id player, boolean warnOnly)
{
// Get the structure name and location
string structName = player_structure.getStructureName(self);
if(structName.length() < 1)
{
structName = "Structure";
}
location where = getLocation(self);
if (warnOnly)
{
string_id subject = new string_id("player_structure", "structure_purge_warning_subject");
string_id body = new string_id("player_structure", "structure_purge_warning_body");
prose_package pp = new prose_package ();
prose.setStringId(pp, body);
prose.setTO(pp, getPlayerFullName(player));
string body_oob = chatMakePersistentMessageOutOfBandBody(null, pp);
string subject_str = "@" + subject.toString();
body_oob = chatAppendPersistentMessageWaypointData (body_oob, where.area, where.x, where.z, null, structName );
string[] admins = player_structure.getAdminListNames(self);
for (int i = 0; i < admins.length; ++i)
{
chatSendPersistentMessage( "Galactic Housing Authority", admins[i], subject_str, null, body_oob );
}
if ( city.isInCity( self ) )
{
int cityId = city.getStructureCityId( self );
if (cityId != 0)
{
obj_id mayor = cityGetLeader( cityId );
if (mayor != obj_id.NULL_ID)
{
chatSendPersistentMessage( "Galactic Housing Authority", mayor, subject_str, null, body_oob );
}
}
}
// rename the structure
obj_id nameTarget = self;
if ( player_structure.isBuilding(nameTarget) )
{
obj_id sign = getObjIdObjVar(nameTarget, player_structure.VAR_SIGN_ID);
if ( isIdValid(sign) )
nameTarget = sign;
}
string abandoned = " \\#FF0000\\(Abandoned)";
setName(nameTarget, structName + abandoned);
if ( nameTarget != self )
{
setObjVar(self, player_structure.VAR_SIGN_NAME, structName + abandoned);
}
}
else
{
if (player_structure.isBuilding(self))
{
// eject all players from house
obj_id[] players = player_structure.getPlayersInBuilding(self);
if (players != null)
{
for (int i = 0; i < players.length; i++)
{
expelFromBuilding(players[i]);
}
}
// Destroy vendors inside this structure.
string[] cells = getCellNames(self);
if( cells != null)
{
for(int i = 0; i < cells.length; i++)
{
obj_id cellid = getCellId(self, cells[i]);
obj_id contents[] = getContents(cellid);
if(contents != null)
{
for(int j=0; j<contents.length; j++)
{
if(hasCondition(contents[j], CONDITION_VENDOR))
{
obj_id owner = getObjIdObjVar(contents[j], "vendor_owner");
if (!isIdValid(owner))
owner = getOwner( contents[j] );
vendor_lib.finalizePackUp(owner, contents[j], player, player_structure.isAbandoned(self));
}
}
}
}
}
}
// Create a new structure control device
obj_id scd = createObject("object/intangible/house/generic_house_control_device.iff", where );
setName(scd, structName);
setOwner(scd, player);
// Persist the structure control device
if (!persistObject(scd))
{
LOG("LOG_CHANNEL", "structure_rollup.OnDoStructureRollup persist SCD failed!");
return SCRIPT_CONTINUE;
}
attachScript(scd, "structure.house_control_device");
// destroy waypoint if it exists
if(hasObjVar(self, player_structure.VAR_WAYPOINT_STRUCTURE))
{
obj_id waypoint = getObjIdObjVar(self, player_structure.VAR_WAYPOINT_STRUCTURE);
if(isIdValid(waypoint))
{
destroyWaypointInDatapad(waypoint, player);
removeObjVar(self, player_structure.VAR_WAYPOINT_STRUCTURE);
}
}
// Destroy house sign and name the control device whatever the building name was
player_structure.destroyStructureSign(self);
//player_structure.destroyBaseObjects(self);
// Remove the structure as the player's residence
if ( player_structure.isResidence( self, player ) )
{
setHouseId( player, obj_id.NULL_ID );
removeObjVar( self, player_structure.VAR_RESIDENCE_BUILDING );
// Also remove the player from his current city.
city.removeCitizen( player, self );
}
city.removeStructureFromCity( self );
// set the template objvar, this is required by the re-placement code
string template = getTemplateName(self);
player_structure.setDeedTemplate(scd, template);
// if the structure is a "lot over limit structure", set objvar to indicate it has been moved to the datapad
if (isIdValid(player) && exists(player))
{
obj_id lotOverlimitStructure = getObjIdObjVar(player, "lotOverlimit.structure_id");
if (isIdValid(lotOverlimitStructure) && (lotOverlimitStructure == self))
{
setObjVar(player, "lotOverlimit.structure_location", "Datapad");
}
}
// put the house into the structure control device
putIn(self, scd );
// remove the rollup_on_load objvar
if(hasObjVar(self, "purge_process.rollup_on_load"))
{
removeObjVar(self, "purge_process.rollup_on_load");
}
// @TODO - test this code if house purge is enabled
const int maxDepth = player_structure.isFactory(self) ? 101 : 1;
moveToOfflinePlayerDatapadAndUnload(scd, player, maxDepth + 1); // add one for the scd
fixLoadWith(self, player, maxDepth);
trace.log("housepackup", getPlayerFullName(player) + "(" + player + ") had their house rolled up by the purge process (" + self + ", loc " + where.toString() + ") into structure control device " + scd, player, trace.TL_CS_LOG);
}
return SCRIPT_CONTINUE;
}
@@ -0,0 +1,207 @@
package script.structure;
import script.*;
import script.base_class.*;
import script.combat_engine.*;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import script.base_script;
import script.library.player_structure;
import script.library.utils;
import script.library.sui;
public class temporary_structure extends script.base_script
{
public temporary_structure()
{
}
public static final string_id SID_TERMINAL_MANAGEMENT_STATUS = new string_id("player_structure", "management_status");
public int OnBuildingComplete(obj_id self, dictionary params) throws InterruptedException
{
LOG("LOG_CHANNEL", "temporary_structure::msgBuildingComplete");
String template = params.getString("template");
dictionary deed_info = params.getDictionary("deed_info");
obj_id owner = params.getObjId("owner");
int rot = params.getInt("rotation");
int build_time = params.getInt("buildTime");
int time_stamp = params.getInt("timestamp");
int time = getGameTime();
location loc = getLocation(self);
if (player_structure.isBuildingName(template))
{
loc.y = params.getFloat("placementHeight");
}
destroyObject(self);
obj_id structure = player_structure.createPlayerStructure(template, owner, loc, rot, deed_info);
dictionary new_params = new dictionary();
new_params.put("structure", self);
new_params.put("template", template);
messageTo(owner, "OnRemoveStructure", new_params, 0, true);
return SCRIPT_CONTINUE;
}
public int msgDestroyStructure(obj_id self, dictionary params) throws InterruptedException
{
player_structure.destroyStructure(self);
return SCRIPT_CONTINUE;
}
public int OnInitialize(obj_id self) throws InterruptedException
{
messageTo(self, "validateConstruction", null, 180, false);
return SCRIPT_CONTINUE;
}
public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info mi) throws InterruptedException
{
mi.addRootMenu(menu_info_types.SERVER_TERMINAL_MANAGEMENT_STATUS, SID_TERMINAL_MANAGEMENT_STATUS);
return SCRIPT_CONTINUE;
}
public int OnObjectMenuSelect(obj_id self, obj_id player, int item) throws InterruptedException
{
LOG("LOG_CHANNEL", "temporary_structure::OnObjectMenuSelect");
if (item == menu_info_types.SERVER_TERMINAL_MANAGEMENT_STATUS)
{
LOG("LOG_CHANNEL", "temporary_structure::OnStatus");
showConstructionStatus(self, player);
}
return SCRIPT_CONTINUE;
}
public int statusMenuRefresh(obj_id self, dictionary params) throws InterruptedException
{
int btn = sui.getIntButtonPressed(params);
if (btn == sui.BP_OK)
{
obj_id player = sui.getPlayerId(params);
if (isIdValid(player))
{
showConstructionStatus(self, player);
}
}
return SCRIPT_CONTINUE;
}
public int showConstructionStatus(obj_id self) throws InterruptedException
{
return showConstructionStatus(self, null);
}
public int showConstructionStatus(obj_id self, obj_id player) throws InterruptedException
{
int build_time = getIntObjVar(self, player_structure.VAR_DEED_BUILDTIME);
int timestamp = getIntObjVar(self, player_structure.VAR_DEED_TIMESTAMP);
int current_time = getGameTime();
int time_passed = current_time - timestamp;
int percent = time_passed * 100 / build_time;
int time = build_time - time_passed;
if (time < 1)
{
if (restartConstruction(self))
{
sendSystemMessageTestingOnly(player, "Construction process restarted.");
}
else
{
sendSystemMessageTestingOnly(player, "Construction restart failed.");
CustomerServiceLog("structure", "Building Marker " + self + "destroyed");
destroyObject(self);
}
}
else
{
int[] conv_time = player_structure.convertSecondsTime(time);
String time_str = player_structure.assembleTimeRemaining(conv_time);
String[] dsrc = new String[4];
dsrc[0] = "Owner: " + player_structure.getStructureOwner(self);
dsrc[1] = "This structure is " + percent + "% complete";
dsrc[2] = "";
dsrc[3] = "Time Remaining: " + time_str;
String title = "Structure Construction Status";
String prompt = "Structure Construction Status";
return sui.listbox(self, player, prompt, sui.REFRESH_CANCEL, title, dsrc, "statusMenuRefresh");
}
return -1;
}
public boolean restartConstruction(obj_id self) throws InterruptedException
{
if (!isIdValid(self))
{
return false;
}
dictionary params = new dictionary();
if (hasObjVar(self, player_structure.VAR_TEMP_TEMPLATE))
{
params.put("template", getStringObjVar(self, player_structure.VAR_TEMP_TEMPLATE));
}
else
{
return false;
}
if (hasObjVar(self, player_structure.VAR_TEMP_ROTATION))
{
params.put("rotation", getIntObjVar(self, player_structure.VAR_TEMP_ROTATION));
}
else
{
return false;
}
if (hasObjVar(self, player_structure.VAR_TEMP_ROTATION))
{
params.put("owner", getObjIdObjVar(self, player_structure.VAR_TEMP_OWNER));
}
else
{
return false;
}
if (hasObjVar(self, player_structure.VAR_TEMP_PLACEMENT_HEIGHT))
{
params.put("placementHeight", getFloatObjVar(self, player_structure.VAR_TEMP_PLACEMENT_HEIGHT));
}
dictionary deed_info = new dictionary();
deed_info.put("template", player_structure.getDeedTemplate(self));
if (hasObjVar(self, player_structure.VAR_DEED_SCENE))
{
deed_info.put("scene", getStringObjVar(self, player_structure.VAR_DEED_SCENE));
}
if (hasObjVar(self, player_structure.VAR_DEED_BUILDTIME))
{
deed_info.put("build_time", getIntObjVar(self, player_structure.VAR_DEED_BUILDTIME));
}
else
{
return false;
}
if (hasObjVar(self, player_structure.VAR_TEMP_OWNER_NAME))
{
deed_info.put("owner_name", getStringObjVar(self, player_structure.VAR_TEMP_OWNER_NAME));
}
else
{
return false;
}
if (hasObjVar(self, "cityName"))
{
deed_info.put("cityName", getStringObjVar(self, "cityName"));
}
params.put("deed_info", deed_info);
int buildtime = getIntObjVar(self, player_structure.VAR_DEED_BUILDTIME);
setObjVar(self, player_structure.VAR_DEED_TIMESTAMP, getGameTime());
messageTo(self, "OnBuildingComplete", params, buildtime, false);
return true;
}
public int validateConstruction(obj_id self, dictionary params) throws InterruptedException
{
int timestamp = getIntObjVar(self, player_structure.VAR_DEED_TIMESTAMP);
if (timestamp < 0)
{
timestamp = 0;
}
int current_time = getGameTime();
int time = current_time - timestamp;
if (time > 600 || time < 0)
{
obj_id owner = getObjIdObjVar(self, player_structure.VAR_TEMP_OWNER);
String template = getStringObjVar(self, player_structure.VAR_TEMP_TEMPLATE);
CustomerServiceLog("structure", "Building Marker destroyed" + self + "Owned by " + owner + "House template" + template);
destroyObject(self);
}
return SCRIPT_CONTINUE;
}
}
@@ -1,247 +0,0 @@
/**********************************************************************
* Title: temporary_structure.script
* Description: script that handles the temporary player structure
**********************************************************************/
/***** INCLUDES ********************************************************/
include library.player_structure;
include library.utils;
include library.sui;
/***** CONSTANTS *******************************************************/
const string_id SID_TERMINAL_MANAGEMENT_STATUS = new string_id("player_structure", "management_status");
/***** TRIGGERS ********************************************************/
/***** MESSAGEHANDLERS *************************************************/
messageHandler OnBuildingComplete()
{
// This is called when the building process is complete. The message
// originated in player_structure.createTemporaryStructure
LOG("LOG_CHANNEL", "temporary_structure::msgBuildingComplete");
string template = params.getString("template");
dictionary deed_info = params.getDictionary("deed_info");
obj_id owner = params.getObjId("owner");
int rot = params.getInt("rotation");
int build_time = params.getInt("buildTime");
int time_stamp = params.getInt("timestamp");
int time = getGameTime();
location loc = getLocation(self);
if (player_structure.isBuildingName(template))
loc.y = params.getFloat("placementHeight");
//LOG("LOG_CHANNEL", "time -> " + time + " timestamp ->" + time_stamp + " buildTime ->" + build_time);
// Get rid of the old and bring in the new
// Can't use player_structure.destroyStructure at this point since the makeshift
// temporary structure doesn't have the correct sized template.
destroyObject(self);
obj_id structure = player_structure.createPlayerStructure(template, owner, loc, rot, deed_info);
dictionary new_params = new dictionary();
new_params.put("structure", self);
new_params.put("template", template);
messageTo(owner, "OnRemoveStructure", new_params, 0, true);
return SCRIPT_CONTINUE;
}
messageHandler msgDestroyStructure()
{
player_structure.destroyStructure(self);
return SCRIPT_CONTINUE;
}
/***** COMMANDHANDLERS *************************************************/
trigger OnInitialize ()
{
messageTo(self, "validateConstruction", null, 180, false);
return SCRIPT_CONTINUE;
}
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
{
mi.addRootMenu (menu_info_types.SERVER_TERMINAL_MANAGEMENT_STATUS, SID_TERMINAL_MANAGEMENT_STATUS);
return SCRIPT_CONTINUE;
}
trigger OnObjectMenuSelect(obj_id player, int item)
{
LOG("LOG_CHANNEL", "temporary_structure::OnObjectMenuSelect");
if (item == menu_info_types.SERVER_TERMINAL_MANAGEMENT_STATUS)
{
LOG("LOG_CHANNEL", "temporary_structure::OnStatus");
// Determine % complete
showConstructionStatus(self, player);
}
return SCRIPT_CONTINUE;
}
/***** OTHER MESSAGEHANDLERS **************************************************/
messageHandler statusMenuRefresh()
{
int btn = sui.getIntButtonPressed(params);
if ( btn == sui.BP_OK )
{
obj_id player = sui.getPlayerId(params);
if ( isIdValid(player) )
showConstructionStatus(self, player);
}
return SCRIPT_CONTINUE;
}
int showConstructionStatus(obj_id self)
{
return showConstructionStatus( self, null);
}
int showConstructionStatus(obj_id self, obj_id player)
{
int build_time = getIntObjVar(self, player_structure.VAR_DEED_BUILDTIME);
int timestamp = getIntObjVar(self, player_structure.VAR_DEED_TIMESTAMP);
int current_time = getGameTime();
int time_passed = current_time - timestamp;
int percent = time_passed * 100 / build_time;
// Determine time remaining.
int time = build_time - time_passed;
if (time < 1)
{
// This shouldn't happen, but if it does, try to force completion of the structure.
// Use the fallback objvar data to reconstruct the missing message data.
if (restartConstruction(self))
sendSystemMessageTestingOnly(player, "Construction process restarted.");
else
{
//if we are down here we have no idea who owns the house or what to make, lets clean us up and generate a less than useful log
sendSystemMessageTestingOnly(player, "Construction restart failed.");
CustomerServiceLog("structure", "Building Marker " +self+ "destroyed");
destroyObject(self);
}
}
else
{
int[] conv_time = player_structure.convertSecondsTime(time);
string time_str = player_structure.assembleTimeRemaining(conv_time);
string[] dsrc = new string[4];
dsrc[0] = "Owner: " + player_structure.getStructureOwner(self);
dsrc[1] = "This structure is " + percent + "% complete";
dsrc[2] = "";
dsrc[3] = "Time Remaining: " + time_str;
string title = "Structure Construction Status";
string prompt = "Structure Construction Status";
return sui.listbox(self, player, prompt, sui.REFRESH_CANCEL, title, dsrc, "statusMenuRefresh");
}
return -1;
}
boolean restartConstruction(obj_id self)
{
if (!isIdValid(self))
return false;
dictionary params = new dictionary();
if (hasObjVar(self, player_structure.VAR_TEMP_TEMPLATE))
params.put("template", getStringObjVar(self, player_structure.VAR_TEMP_TEMPLATE));
else
return false;
if (hasObjVar(self, player_structure.VAR_TEMP_ROTATION))
params.put("rotation", getIntObjVar(self, player_structure.VAR_TEMP_ROTATION));
else
return false;
if (hasObjVar(self, player_structure.VAR_TEMP_ROTATION))
params.put("owner", getObjIdObjVar(self, player_structure.VAR_TEMP_OWNER));
else
return false;
if (hasObjVar(self, player_structure.VAR_TEMP_PLACEMENT_HEIGHT))
params.put("placementHeight", getFloatObjVar(self, player_structure.VAR_TEMP_PLACEMENT_HEIGHT));
dictionary deed_info = new dictionary();
//deed_info.put("template", getStringObjVar(self, player_structure.VAR_DEED_TEMPLATE));
deed_info.put("template", player_structure.getDeedTemplate(self));
if (hasObjVar(self, player_structure.VAR_DEED_SCENE))
deed_info.put("scene", getStringObjVar(self, player_structure.VAR_DEED_SCENE));
if (hasObjVar(self, player_structure.VAR_DEED_BUILDTIME))
deed_info.put("build_time", getIntObjVar(self, player_structure.VAR_DEED_BUILDTIME));
else
return false;
if (hasObjVar(self, player_structure.VAR_TEMP_OWNER_NAME))
deed_info.put("owner_name", getStringObjVar(self, player_structure.VAR_TEMP_OWNER_NAME));
else
return false;
if ( hasObjVar( self, "cityName" ) )
deed_info.put( "cityName", getStringObjVar( self, "cityName" ) );
params.put("deed_info", deed_info);
// Restart the construction.
int buildtime = getIntObjVar(self, player_structure.VAR_DEED_BUILDTIME);
setObjVar(self, player_structure.VAR_DEED_TIMESTAMP, getGameTime());
messageTo(self, "OnBuildingComplete", params, buildtime, false);
return true;
}
messageHandler validateConstruction()
{
//lets cleanup the various objects in the world
int timestamp = getIntObjVar(self, player_structure.VAR_DEED_TIMESTAMP);
//if objvar was munged lets clamp it at 0
if(timestamp < 0)
{
timestamp = 0;
}
int current_time = getGameTime();
int time = current_time - timestamp;
//if its been more than 10 minutes destroy
if (time > 600 || time < 0 )
{
obj_id owner = getObjIdObjVar(self, player_structure.VAR_TEMP_OWNER);
string template = getStringObjVar(self, player_structure.VAR_TEMP_TEMPLATE);
CustomerServiceLog("structure", "Building Marker destroyed" +self+ "Owned by " +owner+ "House template" +template);
destroyObject(self);
}
return SCRIPT_CONTINUE;
}