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,310 @@
package script.object;
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.loot;
import script.library.utils;
import script.library.sui;
import script.library.static_item;
import script.library.structure;
public class autostack extends script.base_script
{
public autostack()
{
}
public static final boolean BLOGGING_ON = false;
public static final String BLOGGING_CATEGORY = "auto_stack";
public int OnAttach(obj_id self) throws InterruptedException
{
messageTo(self, "msgStackItem", null, 1, false);
return SCRIPT_CONTINUE;
}
public int OnTransferred(obj_id self, obj_id sourceContainer, obj_id destContainer, obj_id transferer) throws InterruptedException
{
if (isIdValid(sourceContainer) && isIdValid(destContainer))
{
String templateNameSourceContainer = getTemplateName(sourceContainer);
String templateNameDestContainer = getTemplateName(destContainer);
if ((templateNameSourceContainer != null) && (templateNameDestContainer != null) && templateNameSourceContainer.equals(structure.TEMPLATE_CELL) && templateNameDestContainer.equals("object/tangible/inventory/character_inventory.iff"))
{
return SCRIPT_CONTINUE;
}
}
if (getGameObjectType(destContainer) != GOT_misc_factory_crate)
{
blog("Sending Stack messageTo msgStackItem");
messageTo(self, "msgStackItem", null, 1, false);
}
return SCRIPT_CONTINUE;
}
public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info mi) throws InterruptedException
{
if (!canRestack(self))
{
return SCRIPT_CONTINUE;
}
if (getCount(self) > 1)
{
mi.addRootMenu(menu_info_types.SERVER_MENU49, new string_id("autostack", "unstack"));
menu_info_data mid = mi.getMenuItemByType(menu_info_types.SERVER_MENU49);
if (mid == null)
{
return SCRIPT_CONTINUE;
}
else
{
mid.setServerNotify(true);
}
}
mi.addRootMenu(menu_info_types.SERVER_MENU50, new string_id("autostack", "stack"));
menu_info_data mid = mi.getMenuItemByType(menu_info_types.SERVER_MENU50);
if (mid == null)
{
return SCRIPT_CONTINUE;
}
else
{
mid.setServerNotify(true);
}
return SCRIPT_CONTINUE;
}
public int OnObjectMenuSelect(obj_id self, obj_id player, int item) throws InterruptedException
{
if (!canRestack(self))
{
return SCRIPT_CONTINUE;
}
if (getCount(self) > 1)
{
if (item == menu_info_types.SERVER_MENU49)
{
unstackIt(self, player);
}
}
if (item == menu_info_types.SERVER_MENU50)
{
utils.removeScriptVar(player, "autostack.ignoreitems");
restackIt(self);
}
return SCRIPT_CONTINUE;
}
public int OnGetAttributes(obj_id self, obj_id player, String[] names, String[] attribs) throws InterruptedException
{
int free = getFirstFreeIndex(names);
if (free == -1)
{
return SCRIPT_CONTINUE;
}
int numInStack = getCount(self);
names[free] = "num_in_stack";
attribs[free] = "" + numInStack;
return SCRIPT_CONTINUE;
}
public boolean canRestack(obj_id self) throws InterruptedException
{
blog("canRestack init");
if (isInSecureTrade(self))
{
blog("isInSecureTrade");
return false;
}
obj_id containerObject = utils.getContainingPlayer(self);
if (!isIdValid(containerObject))
{
if (!isContainerValidForStacking(self))
{
return false;
}
blog("containerObject is okay to use");
containerObject = getContainedBy(self);
}
blog("containerObject is valid");
return true;
}
public void restackIt(obj_id self) throws InterruptedException
{
blog("restackIt init");
if (!isIdValid(self) || !exists(self))
{
return;
}
blog("restackIt validation complete");
if (isInSecureTrade(self))
{
return;
}
blog("restackIt - not isInSecureTrade");
obj_id containerObject = utils.getContainingPlayer(self);
if (!isIdValid(containerObject))
{
blog("restackIt - not a player container");
if (!isContainerValidForStacking(self))
{
return;
}
blog("restackIt - containerObject = getContainedBy");
containerObject = getContainedBy(self);
}
blog("restackIt - containerObject = valid");
if (utils.hasScriptVar(containerObject, "autostack.ignoreitems"))
{
return;
}
obj_id item = loot.findItemToStack(self);
if (isIdValid(item) && !isInSecureTrade(item))
{
if (utils.hasScriptVar(self, "unstacking") || utils.hasScriptVar(item, "unstacking"))
{
return;
}
if (item != self)
{
loot.stackItem(self, item);
if (!hasScript(item, "object.autostack"))
{
attachScript(item, "object.autostack");
}
}
}
}
public void unstackIt(obj_id self, obj_id player) throws InterruptedException
{
if (!isInSecureTrade(self))
{
if (getCount(self) == 2)
{
createNewStack(player, self, 1, 2);
utils.setScriptVar(self, "unstacking", 1);
messageTo(self, "clearUnstackingScriptVar", null, 3, false);
}
else
{
sui.inputbox(self, player, "@autostack:stacksize", "msgUnstackItem");
}
}
}
public int msgStackItem(obj_id self, dictionary params) throws InterruptedException
{
blog("msgStackItem init");
restackIt(self);
return SCRIPT_CONTINUE;
}
public int clearUnstackingScriptVar(obj_id self, dictionary params) throws InterruptedException
{
utils.removeScriptVar(self, "unstacking");
return SCRIPT_CONTINUE;
}
public int msgUnstackItem(obj_id self, dictionary params) throws InterruptedException
{
obj_id player = sui.getPlayerId(params);
if (!canRestack(self))
{
return SCRIPT_CONTINUE;
}
String amount_str = sui.getInputBoxText(params);
if (amount_str == null || amount_str.equals(""))
{
return SCRIPT_CONTINUE;
}
int oldStackSize = getCount(self);
int newStackSize = utils.stringToInt(amount_str);
if (newStackSize == 0)
{
sendSystemMessage(player, new string_id("autostack", "zero_size"));
return SCRIPT_CONTINUE;
}
else if (newStackSize < 0)
{
sendSystemMessage(player, new string_id("autostack", "number_format_wrong"));
return SCRIPT_CONTINUE;
}
else if (newStackSize > oldStackSize)
{
sendSystemMessage(player, new string_id("autostack", "too_big"));
return SCRIPT_CONTINUE;
}
else if (newStackSize == oldStackSize)
{
return SCRIPT_CONTINUE;
}
createNewStack(player, self, newStackSize, oldStackSize);
utils.setScriptVar(self, "unstacking", 1);
messageTo(self, "clearUnstackingScriptVar", null, 3, false);
return SCRIPT_CONTINUE;
}
public void createNewStack(obj_id player, obj_id item, int newStackSize, int oldStackSize) throws InterruptedException
{
obj_id container = getContainedBy(item);
if (!isIdValid(container))
{
sendSystemMessage(player, new string_id("autostack", "bad_container"));
return;
}
if (getVolumeFree(container) <= 0)
{
sendSystemMessage(player, new string_id("autostack", "full_container"));
return;
}
utils.setScriptVar(player, "autostack.ignoreitems", true);
obj_id newItem = null;
if (static_item.isStaticItem(item))
{
newItem = static_item.createNewItemFunction(getStaticItemName(item), container);
}
else
{
newItem = createObject(item, container, "");
}
if (!isIdValid(newItem))
{
sendSystemMessage(player, new string_id("autostack", "unknown_failure"));
utils.removeScriptVar(player, "autostack.ignoreitems");
return;
}
setCount(item, (oldStackSize - newStackSize));
setCount(newItem, newStackSize);
utils.removeScriptVar(player, "autostack.ignoreitems");
}
public boolean isContainerValidForStacking(obj_id self) throws InterruptedException
{
if (!isValidId(self) || !exists(self))
{
return false;
}
String containerTemplate = getTemplateName(getContainedBy(self));
blog("isContainerValidForStacking containerTemplate: " + containerTemplate);
if (isGameObjectTypeOf(getContainedBy(self), GOT_misc_container_wearable))
{
return true;
}
else if (isGameObjectTypeOf(getContainedBy(self), GOT_misc_container))
{
if (containerTemplate.startsWith("object/tangible/furniture/") || containerTemplate.startsWith("object/tangible/poi/object/"))
{
return true;
}
return false;
}
return false;
}
public boolean blog(String msg) throws InterruptedException
{
if (!BLOGGING_ON)
{
return false;
}
else if (msg == null || msg.equals(""))
{
return false;
}
LOG(BLOGGING_CATEGORY, msg);
return true;
}
}
@@ -1,310 +0,0 @@
include library.loot;
include library.utils;
include library.sui;
include library.static_item;
include library.structure;
const boolean BLOGGING_ON = false;
const string BLOGGING_CATEGORY = "auto_stack";
trigger OnAttach()
{
//restackIt( self );
messageTo(self, "msgStackItem", null, 1, false);
return SCRIPT_CONTINUE;
}
trigger OnTransferred(obj_id sourceContainer, obj_id destContainer, obj_id transferer)
{
// Don't call "restack" if we're being moved from a top level cell object into the top level player
// inventory, so that the item decorative position/orientation can be restored if that is what the
// player is picking up the item for; if the player still want to stack the item, he can do it manually
if (isIdValid(sourceContainer) && isIdValid(destContainer))
{
string templateNameSourceContainer = getTemplateName(sourceContainer);
string templateNameDestContainer = getTemplateName(destContainer);
if ((templateNameSourceContainer != null) && (templateNameDestContainer != null) && templateNameSourceContainer.equals(structure.TEMPLATE_CELL) && templateNameDestContainer.equals("object/tangible/inventory/character_inventory.iff"))
return SCRIPT_CONTINUE;
}
// Don't call "restack" if we're in a factory crate. This causes wierdness.
if ( getGameObjectType(destContainer) != GOT_misc_factory_crate )
{
blog("Sending Stack messageTo msgStackItem");
messageTo(self, "msgStackItem", null, 1, false);
//restackIt( self );
}
return SCRIPT_CONTINUE;
}
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
{
if (!canRestack(self))
{
return SCRIPT_CONTINUE;
}
if (getCount(self) > 1 )
{
mi.addRootMenu (menu_info_types.SERVER_MENU49, new string_id("autostack","unstack"));
menu_info_data mid = mi.getMenuItemByType(menu_info_types.SERVER_MENU49);
if(mid == null)
return SCRIPT_CONTINUE;
else
mid.setServerNotify(true);
}
mi.addRootMenu (menu_info_types.SERVER_MENU50, new string_id("autostack","stack"));
menu_info_data mid = mi.getMenuItemByType(menu_info_types.SERVER_MENU50);
if(mid == null)
return SCRIPT_CONTINUE;
else
mid.setServerNotify(true);
return SCRIPT_CONTINUE;
}
trigger OnObjectMenuSelect(obj_id player, int item)
{
if(!canRestack(self))
return SCRIPT_CONTINUE;
//the unstack it:
if (getCount(self) > 1 )
{
if(item == menu_info_types.SERVER_MENU49)
{
unstackIt(self, player);
}
}
if(item == menu_info_types.SERVER_MENU50)
{
utils.removeScriptVar( player, "autostack.ignoreitems");
restackIt( self );
}
return SCRIPT_CONTINUE;
}
trigger OnGetAttributes(obj_id player, string[] names, string[] attribs)
{
int free = getFirstFreeIndex(names);
if (free == -1)
{
return SCRIPT_CONTINUE;
}
int numInStack = getCount(self);
names[free] = "num_in_stack"; // data\sku.0\sys.shared\built\game\string\en\obj_attr_n.stf
attribs[free] = "" + numInStack;
return SCRIPT_CONTINUE;
}
boolean canRestack(obj_id self)
{
blog("canRestack init");
if(isInSecureTrade(self))
{
blog("isInSecureTrade");
return false;//Do not restack in a secure trade.
}
obj_id containerObject = utils.getContainingPlayer(self);
if(!isIdValid(containerObject))
{
if(!isContainerValidForStacking(self))
return false;
blog("containerObject is okay to use");
containerObject = getContainedBy(self);
}
blog("containerObject is valid");
return true;//we're golden!
}
void restackIt(obj_id self)
{
blog("restackIt init");
if(!isIdValid(self) || !exists(self))
return;
blog("restackIt validation complete");
if(isInSecureTrade(self)) //Do not restack in a secure trade.
return;
blog("restackIt - not isInSecureTrade");
obj_id containerObject = utils.getContainingPlayer(self);
if(!isIdValid(containerObject))
{
blog("restackIt - not a player container");
if(!isContainerValidForStacking(self))
return;
blog("restackIt - containerObject = getContainedBy");
containerObject = getContainedBy(self);
}
blog("restackIt - containerObject = valid");
if(utils.hasScriptVar(containerObject, "autostack.ignoreitems"))
return;
obj_id item = loot.findItemToStack(self);
if(isIdValid(item) && !isInSecureTrade(item))
{
if(utils.hasScriptVar(self, "unstacking") || utils.hasScriptVar(item, "unstacking"))
return;
if(item!=self)
{
loot.stackItem(self, item);
if (!hasScript(item, "object.autostack"))
attachScript(item, "object.autostack");
}
}
}
void unstackIt( obj_id self, obj_id player )
{
if (!isInSecureTrade(self)) //Do not restack in a secure trade.
{
if ( getCount( self ) == 2 )
{
createNewStack( player, self, 1, 2);
utils.setScriptVar(self, "unstacking", 1);
messageTo(self, "clearUnstackingScriptVar", null, 3, false);
}
else
{
sui.inputbox(self, player, "@autostack:stacksize", "msgUnstackItem");
}
}
}
messageHandler msgStackItem()
{
blog("msgStackItem init");
restackIt( self );
return SCRIPT_CONTINUE;
}
messageHandler clearUnstackingScriptVar()
{
utils.removeScriptVar(self, "unstacking");
return SCRIPT_CONTINUE;
}
messageHandler msgUnstackItem()
{
obj_id player = sui.getPlayerId(params);
if(!canRestack(self))
return SCRIPT_CONTINUE;
string amount_str = sui.getInputBoxText(params);
if ( amount_str == null || amount_str == "" )
{
//sendSystemMessage( player, new string_id( "autostack", "invalid" ));
return SCRIPT_CONTINUE;
}
int oldStackSize = getCount( self );
int newStackSize = utils.stringToInt(amount_str);//will return a -1
if ( newStackSize == 0 )
{
sendSystemMessage( player, new string_id( "autostack", "zero_size" ));
return SCRIPT_CONTINUE;
}
else if ( newStackSize < 0 )
{
sendSystemMessage( player, new string_id( "autostack", "number_format_wrong" ));
return SCRIPT_CONTINUE;
}
else if ( newStackSize > oldStackSize )
{
sendSystemMessage( player, new string_id( "autostack", "too_big" ));
return SCRIPT_CONTINUE;
}
else if ( newStackSize == oldStackSize )
{
return SCRIPT_CONTINUE;//if they're the same size then we're done.
}
createNewStack( player, self, newStackSize, oldStackSize );
utils.setScriptVar(self, "unstacking", 1);
messageTo(self, "clearUnstackingScriptVar", null, 3, false);
return SCRIPT_CONTINUE;
}
void createNewStack( obj_id player, obj_id item, int newStackSize, int oldStackSize )
{
obj_id container = getContainedBy(item);
if (!isIdValid(container))
{
sendSystemMessage( player, new string_id( "autostack", "bad_container" ));
return ;
}
if (getVolumeFree(container) <= 0)
{
sendSystemMessage( player, new string_id( "autostack", "full_container" ));
return;
}
utils.setScriptVar( player, "autostack.ignoreitems", true );
obj_id newItem = null;
if(static_item.isStaticItem (item))
newItem = static_item.createNewItemFunction( getStaticItemName(item), container);
else
newItem = createObject( item, container, "" );
if ( !isIdValid( newItem ) )
{
sendSystemMessage( player, new string_id( "autostack", "unknown_failure" ));
utils.removeScriptVar( player, "autostack.ignoreitems");
return;
}
setCount( item, (oldStackSize - newStackSize) );
setCount( newItem, newStackSize );
utils.removeScriptVar( player, "autostack.ignoreitems");
}
boolean isContainerValidForStacking(obj_id self)
{
if(!isValidId(self) || !exists(self))
return false;
string containerTemplate = getTemplateName(getContainedBy(self));
blog("isContainerValidForStacking containerTemplate: "+containerTemplate);
if(isGameObjectTypeOf(getContainedBy(self), GOT_misc_container_wearable))//backpack or other player wearable is ok.
return true;
else if(isGameObjectTypeOf(getContainedBy(self), GOT_misc_container))//furniture is cool, other specialty containers = bad
{
if(containerTemplate.startsWith("object/tangible/furniture/") || containerTemplate.startsWith("object/tangible/poi/object/"))
return true;//Furniture and poi objects are cool
//all else isn't.
return false;
}
return false;
}
boolean blog(string msg)
{
if(!BLOGGING_ON)
return false;
else if(msg == null || msg.equals(""))
return false;
LOG(BLOGGING_CATEGORY, msg);
return true;
}
@@ -0,0 +1,145 @@
package script.object;
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.loot;
import script.library.utils;
import script.library.sui;
import script.library.static_item;
public class ch5_powerup_unstack extends script.base_script
{
public ch5_powerup_unstack()
{
}
public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info mi) throws InterruptedException
{
if (getCount(self) > 1)
{
mi.addRootMenu(menu_info_types.SERVER_MENU1, new string_id("autostack", "unstack"));
menu_info_data mid = mi.getMenuItemByType(menu_info_types.SERVER_MENU1);
if (mid == null)
{
return SCRIPT_CONTINUE;
}
else
{
mid.setServerNotify(true);
}
}
return SCRIPT_CONTINUE;
}
public int OnObjectMenuSelect(obj_id self, obj_id player, int item) throws InterruptedException
{
if (getCount(self) > 1)
{
if (item == menu_info_types.SERVER_MENU1)
{
unstackIt(self, player);
}
}
return SCRIPT_CONTINUE;
}
public int OnGetAttributes(obj_id self, obj_id player, String[] names, String[] attribs) throws InterruptedException
{
int free = getFirstFreeIndex(names);
if (free == -1)
{
return SCRIPT_CONTINUE;
}
int numInStack = getCount(self);
names[free] = "num_in_stack";
attribs[free] = "" + numInStack;
return SCRIPT_CONTINUE;
}
public void unstackIt(obj_id self, obj_id player) throws InterruptedException
{
if (!isInSecureTrade(self))
{
if (getCount(self) == 2)
{
createNewStack(player, self, 1, 2);
}
else
{
sui.inputbox(self, player, "@autostack:stacksize", "msgUnstackItem");
}
}
}
public int msgUnstackItem(obj_id self, dictionary params) throws InterruptedException
{
obj_id player = sui.getPlayerId(params);
String amount_str = sui.getInputBoxText(params);
if (amount_str == null || amount_str.equals(""))
{
return SCRIPT_CONTINUE;
}
int oldStackSize = getCount(self);
int newStackSize = utils.stringToInt(amount_str);
if (newStackSize < 1)
{
sendSystemMessage(player, new string_id("autostack", "zero_size"));
return SCRIPT_CONTINUE;
}
else if (newStackSize > oldStackSize)
{
sendSystemMessage(player, new string_id("autostack", "too_big"));
return SCRIPT_CONTINUE;
}
else if (newStackSize == oldStackSize)
{
return SCRIPT_CONTINUE;
}
createNewStack(player, self, newStackSize, oldStackSize);
return SCRIPT_CONTINUE;
}
public void createNewStack(obj_id player, obj_id item, int newStackSize, int oldStackSize) throws InterruptedException
{
obj_id container = getContainedBy(item);
if (!isIdValid(container))
{
sendSystemMessage(player, new string_id("autostack", "bad_container"));
return;
}
if (getVolumeFree(container) <= 0)
{
sendSystemMessage(player, new string_id("autostack", "full_container"));
return;
}
utils.setScriptVar(player, "autostack.ignoreitems", true);
obj_id newItem = null;
if (static_item.isStaticItem(item))
{
newItem = static_item.createNewItemFunction(getStaticItemName(item), container);
}
else
{
newItem = createObject(item, container, "");
}
if (!isIdValid(newItem))
{
sendSystemMessage(player, new string_id("autostack", "unknown_failure"));
utils.removeScriptVar(player, "autostack.ignoreitems");
return;
}
if (hasScript(item, "item.tool.reverse_engineering_powerup"))
{
int power = getIntObjVar(item, "reverse_engineering.reverse_engineering_power");
String mod = getStringObjVar(item, "reverse_engineering.reverse_engineering_modifier");
int ratio = getIntObjVar(item, "reverse_engineering.reverse_engineering_ratio");
setObjVar(newItem, "reverse_engineering.reverse_engineering_power", power);
setObjVar(newItem, "reverse_engineering.reverse_engineering_modifier", mod);
setObjVar(newItem, "reverse_engineering.reverse_engineering_ratio", ratio);
attachScript(newItem, "item.tool.reverse_engineering_powerup");
}
setCount(item, (oldStackSize - newStackSize));
setCount(newItem, newStackSize);
utils.removeScriptVar(player, "autostack.ignoreitems");
}
}
@@ -1,135 +0,0 @@
include library.loot;
include library.utils;
include library.sui;
include library.static_item;
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
{
if (getCount(self) > 1 )
{
mi.addRootMenu (menu_info_types.SERVER_MENU1, new string_id("autostack","unstack"));
menu_info_data mid = mi.getMenuItemByType(menu_info_types.SERVER_MENU1);
if(mid == null)
return SCRIPT_CONTINUE;
else
mid.setServerNotify(true);
}
return SCRIPT_CONTINUE;
}
trigger OnObjectMenuSelect(obj_id player, int item)
{
if (getCount(self) > 1 )
{
if(item == menu_info_types.SERVER_MENU1)
{
unstackIt(self, player);
}
}
return SCRIPT_CONTINUE;
}
trigger OnGetAttributes(obj_id player, string[] names, string[] attribs)
{
int free = getFirstFreeIndex(names);
if (free == -1)
{
return SCRIPT_CONTINUE;
}
int numInStack = getCount(self);
names[free] = "num_in_stack"; // data\sku.0\sys.shared\built\game\string\en\obj_attr_n.stf
attribs[free] = "" + numInStack;
return SCRIPT_CONTINUE;
}
void unstackIt( obj_id self, obj_id player )
{
if (!isInSecureTrade(self)) //Do not restack in a secure trade.
{
if ( getCount( self ) == 2 )
createNewStack( player, self, 1, 2);
else
sui.inputbox(self, player, "@autostack:stacksize", "msgUnstackItem");
}
}
messageHandler msgUnstackItem()
{
obj_id player = sui.getPlayerId(params);
string amount_str = sui.getInputBoxText(params);
if ( amount_str == null || amount_str == "" )
{
return SCRIPT_CONTINUE;
}
int oldStackSize = getCount( self );
int newStackSize = utils.stringToInt(amount_str);
if ( newStackSize < 1 )
{
sendSystemMessage( player, new string_id( "autostack", "zero_size" ));
return SCRIPT_CONTINUE;
}
else if ( newStackSize > oldStackSize )
{
sendSystemMessage( player, new string_id( "autostack", "too_big" ));
return SCRIPT_CONTINUE;
}
else if ( newStackSize == oldStackSize )
{
return SCRIPT_CONTINUE;//if they're the same size then we're done.
}
createNewStack( player, self, newStackSize, oldStackSize );
return SCRIPT_CONTINUE;
}
void createNewStack( obj_id player, obj_id item, int newStackSize, int oldStackSize )
{
obj_id container = getContainedBy(item);
if (!isIdValid(container))
{
sendSystemMessage( player, new string_id( "autostack", "bad_container" ));
return ;
}
if (getVolumeFree(container) <= 0)
{
sendSystemMessage( player, new string_id( "autostack", "full_container" ));
return;
}
utils.setScriptVar( player, "autostack.ignoreitems", true );
obj_id newItem = null;
if(static_item.isStaticItem (item))
newItem = static_item.createNewItemFunction( getStaticItemName(item), container);
else
newItem = createObject( item, container, "" );
if ( !isIdValid( newItem ) )
{
sendSystemMessage( player, new string_id( "autostack", "unknown_failure" ));
utils.removeScriptVar( player, "autostack.ignoreitems");
return;
}
if(hasScript(item, "item.tool.reverse_engineering_powerup") )
{
int power = getIntObjVar(item, "reverse_engineering.reverse_engineering_power");
string mod = getStringObjVar(item, "reverse_engineering.reverse_engineering_modifier");
int ratio = getIntObjVar(item, "reverse_engineering.reverse_engineering_ratio");
setObjVar(newItem, "reverse_engineering.reverse_engineering_power", power);
setObjVar(newItem, "reverse_engineering.reverse_engineering_modifier", mod);
setObjVar(newItem, "reverse_engineering.reverse_engineering_ratio", ratio);
attachScript(newItem, "item.tool.reverse_engineering_powerup");
}
setCount( item, (oldStackSize - newStackSize) );
setCount( newItem, newStackSize );
utils.removeScriptVar( player, "autostack.ignoreitems");
}
@@ -0,0 +1,54 @@
package script.object;
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.group;
import script.library.space_combat;
import script.library.money;
import script.library.utils;
public class credit_chip extends script.base_script
{
public credit_chip()
{
}
public int OnGetAttributes(obj_id self, obj_id player, String[] names, String[] attribs) throws InterruptedException
{
int intCredits = getIntObjVar(self, "loot.intCredits");
int idx = utils.getValidAttributeIndex(names);
if (idx == -1)
{
return SCRIPT_CONTINUE;
}
names[idx] = "amount";
attribs[idx] = Integer.toString(intCredits);
return SCRIPT_CONTINUE;
}
public int OnObjectMenuSelect(obj_id self, obj_id player, int item) throws InterruptedException
{
obj_id objTopmostContainer = utils.getContainingPlayer(self);
if (objTopmostContainer != player)
{
LOG("space", "container is " + objTopmostContainer);
return SCRIPT_CONTINUE;
}
if (item == menu_info_types.ITEM_USE)
{
int intCredits = getIntObjVar(self, "loot.intCredits");
money.bankTo("space_loot", player, intCredits);
destroyObject(self);
}
return SCRIPT_CONTINUE;
}
public int OnObjectMenuRequest(obj_id self, obj_id objPlayer, menu_info mi) throws InterruptedException
{
mi.addRootMenu(menu_info_types.ITEM_USE, new string_id("space/space_loot", "use_credit_chip"));
return SCRIPT_CONTINUE;
}
}
@@ -1,79 +0,0 @@
include library.group;
include library.space_combat;
include library.money;
include library.utils;
trigger OnGetAttributes(obj_id player, string[] names, string[] attribs)
{
int intCredits = getIntObjVar(self, "loot.intCredits");
int idx = utils.getValidAttributeIndex(names);
if (idx == -1)
return SCRIPT_CONTINUE;
names[idx] = "amount";
attribs[idx] = Integer.toString(intCredits);
return SCRIPT_CONTINUE;
}
trigger OnObjectMenuSelect(obj_id player, int item)
{
obj_id objTopmostContainer = utils.getContainingPlayer(self);
if(objTopmostContainer!=player)
{
LOG("space", "container is "+objTopmostContainer);
return SCRIPT_CONTINUE;
}
if ( item == menu_info_types.ITEM_USE )
{
int intCredits = getIntObjVar(self, "loot.intCredits");
money.bankTo("space_loot", player, intCredits);
destroyObject(self);
}
/*
else if(item==menu_info_types.SPLIT)
{//{ THIS STUFF DOESN'T FUCKING WORK. THE GROUP MONEY FUNCTIONS EAT CASH. THIS SUCKS
int intCredits = getIntObjVar(self, "loot.intCredits");
string_id strPayout = new string_id("space/space_loot", "group_credit_payout");
group.systemPayoutToGroup("space_loot", player, intCredits, strPayout, null, null);
destroyObject(self);
}
*/
return SCRIPT_CONTINUE;
}
trigger OnObjectMenuRequest (obj_id objPlayer, menu_info mi)
{
// somethign about groups here
//obj_id objGroup = getGroupObject(objPlayer);
//if(isIdValid(objGroup))
//{ THIS STUFF DOESN'T FUCKING WORK. THE GROUP MONEY FUNCTIONS EAT CASH. THIS SUCKS
// mi.addRootMenu(menu_info_types.SPLIT, new string_id("space/space_loot", "split_with_group"));
//}
mi.addRootMenu(menu_info_types.ITEM_USE, new string_id("space/space_loot", "use_credit_chip"));
return SCRIPT_CONTINUE;
}
/*
// when put into someone's invnetory, we check for auto stacking.
trigger OnTransferred(obj_id objSource, obj_id objDest , obj_id objTransferer)
{
obj_id objOwner = getContainedBy(objDest);
if(isPlayer(objOwner))
{
space_combat.handleCreditChips(objOwner, self, objSource);
}
return SCRIPT_CONTINUE;
}
*/
@@ -0,0 +1,48 @@
package script.object;
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 destroy_message extends script.base_script
{
public destroy_message()
{
}
public int OnIncapacitated(obj_id self, obj_id attacker) throws InterruptedException
{
sendMessages(self);
return SCRIPT_CONTINUE;
}
public int OnDestroy(obj_id self) throws InterruptedException
{
sendMessages(self);
return SCRIPT_CONTINUE;
}
public int OnObjectDisabled(obj_id self, obj_id killer) throws InterruptedException
{
sendMessages(self);
return SCRIPT_CONTINUE;
}
public void sendMessages(obj_id object) throws InterruptedException
{
if (!hasObjVar(object, "destroyMessageList"))
{
return;
}
String[] destroyMessageNames = getStringArrayObjVar(object, "destroyMessageList.handlerNames");
float[] destroyMessageDelays = getFloatArrayObjVar(object, "destroyMessageList.delays");
obj_id[] destroyMessageRecipients = getObjIdArrayObjVar(object, "destroyMessageList.recipients");
removeObjVar(object, "destroyMessageList");
dictionary parms = new dictionary();
parms.put("object", object);
for (int i = 0; i < destroyMessageNames.length; i++)
{
messageTo(destroyMessageRecipients[i], destroyMessageNames[i], parms, destroyMessageDelays[i], isObjectPersisted(destroyMessageRecipients[i]));
}
}
}
@@ -1,36 +0,0 @@
trigger OnIncapacitated( obj_id attacker )
{
sendMessages( self );
return SCRIPT_CONTINUE;
}
trigger OnDestroy()
{
sendMessages( self );
return SCRIPT_CONTINUE;
}
trigger OnObjectDisabled(obj_id killer)
{
sendMessages( self );
return SCRIPT_CONTINUE;
}
void sendMessages( obj_id object )
{
if (!hasObjVar( object, "destroyMessageList" ))
return;
string[] destroyMessageNames = getStringArrayObjVar( object, "destroyMessageList.handlerNames" );
float[] destroyMessageDelays = getFloatArrayObjVar( object, "destroyMessageList.delays" );
obj_id[] destroyMessageRecipients = getObjIdArrayObjVar( object, "destroyMessageList.recipients" );
removeObjVar( object, "destroyMessageList" );
dictionary parms = new dictionary();
parms.put( "object", object );
for ( int i = 0; i < destroyMessageNames.length; i++ )
messageTo( destroyMessageRecipients[i], destroyMessageNames[i], parms, destroyMessageDelays[i], isObjectPersisted( destroyMessageRecipients[i] ));
}
@@ -0,0 +1,21 @@
package script.object;
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 location_object extends script.base_script
{
public location_object()
{
}
public int handlerDestroyLocationObject(obj_id self, dictionary params) throws InterruptedException
{
destroyObject(self);
return SCRIPT_CONTINUE;
}
}
@@ -1,10 +0,0 @@
// This script handles destroying the location object that reserves
// asynch locations for the requestLocation() function.
//
// The message is sent by locations.destroyLocationObject(obj_id locationObject)
messageHandler handlerDestroyLocationObject()
{
destroyObject(self);
return SCRIPT_CONTINUE;
}
@@ -0,0 +1,92 @@
package script.object;
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.craftinglib;
public class onewayunstack extends script.base_script
{
public onewayunstack()
{
}
public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info mi) throws InterruptedException
{
if (!canUnstack(player))
{
return SCRIPT_CONTINUE;
}
mi.addRootMenu(menu_info_types.SERVER_MENU10, new string_id("sui", "unstack"));
menu_info_data mid = mi.getMenuItemByType(menu_info_types.SERVER_MENU10);
if (mid == null)
{
return SCRIPT_CONTINUE;
}
mid.setServerNotify(true);
return SCRIPT_CONTINUE;
}
public int OnObjectMenuSelect(obj_id self, obj_id player, int item) throws InterruptedException
{
if (!canUnstack(player))
{
return SCRIPT_CONTINUE;
}
if (item == menu_info_types.SERVER_MENU10)
{
unstackIt(self, player);
}
return SCRIPT_CONTINUE;
}
public void unstackIt(obj_id stackedItem, obj_id player) throws InterruptedException
{
obj_id self = getSelf();
obj_id container = utils.getInventoryContainer(player);
if (getVolumeFree(container) < getVolume(stackedItem))
{
sendSystemMessage(player, new string_id("sui", "unstack_noroom"));
return;
}
String template = getTemplateName(stackedItem);
obj_id copy_item = createObject(template, container, "");
if (!isIdValid(copy_item))
{
return;
}
copyObjVar(stackedItem, copy_item, "crafting");
copyObjVar(stackedItem, copy_item, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME);
copyObjVar(stackedItem, copy_item, "attribute");
setCraftedId(copy_item, getObjIdObjVar(stackedItem, "unstack.serialNumber"));
setCrafter(copy_item, getCrafter(stackedItem));
setAttributeBonuses(copy_item, getAttributeBonuses(stackedItem));
incrementCount(stackedItem, -1);
int count = getCount(stackedItem);
if (count == 1)
{
removeObjVar(stackedItem, "unstack.serialNumber");
detachScript(stackedItem, "object.onewayunstack");
sendDirtyObjectMenuNotification(stackedItem);
}
return;
}
public boolean canUnstack(obj_id player) throws InterruptedException
{
obj_id self = getSelf();
obj_id playerInventory = utils.getInventoryContainer(player);
int count = getCount(self);
if (count < 2)
{
return false;
}
if (!hasObjVar(self, "unstack.serialNumber"))
{
return false;
}
return utils.isNestedWithin(getSelf(), playerInventory);
}
}
@@ -1,112 +0,0 @@
/**
* Title: object.onewayunstack
* Description: Allows "stacked" loot items. An item can be extracted from the stack for use in crafting.
*/
/***************************!!!!!!!!!!!IMPORTANT!!!!!!!!!!!!!!!!*****************************/
/***************************!!!!!!!!!!!IMPORTANT!!!!!!!!!!!!!!!!*****************************/
// The name of this script is used in the serverGame file PlayerObject.cpp to reject components that have this script attached.
// When we have more time, we should make these items work the same as crates (FactoryObject.cpp).
/***************************!!!!!!!!!!!IMPORTANT!!!!!!!!!!!!!!!!*****************************/
/***************************!!!!!!!!!!!IMPORTANT!!!!!!!!!!!!!!!!*****************************/
include library.utils;
include library.craftinglib;
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
{
if (!canUnstack(player))
{
// can't unstack unless inside of your inventory and we actually have a "stack"
return SCRIPT_CONTINUE;
}
mi.addRootMenu (menu_info_types.SERVER_MENU10, new string_id("sui","unstack"));
menu_info_data mid = mi.getMenuItemByType(menu_info_types.SERVER_MENU10);
if(mid == null)
{
return SCRIPT_CONTINUE;
}
mid.setServerNotify(true);
return SCRIPT_CONTINUE;
}
trigger OnObjectMenuSelect(obj_id player, int item)
{
if(!canUnstack(player))
{
return SCRIPT_CONTINUE;
}
if(item == menu_info_types.SERVER_MENU10)
{
unstackIt(self, player);
}
return SCRIPT_CONTINUE;
}
void unstackIt(obj_id stackedItem, obj_id player)
{
obj_id self = getSelf();
obj_id container = utils.getInventoryContainer(player);
if(getVolumeFree(container) < getVolume(stackedItem)) // do we have room for another item like the the stack item?
{
sendSystemMessage(player, new string_id("sui", "unstack_noroom")); // ~ No room in inventory, try again...
return;
}
string template = getTemplateName(stackedItem);
obj_id copy_item = createObject(template, container, "");
if(!isIdValid(copy_item))
{
return;
}
copyObjVar(stackedItem, copy_item, "crafting");
copyObjVar(stackedItem, copy_item, craftinglib.COMPONENT_ATTRIBUTE_OBJVAR_NAME);
copyObjVar(stackedItem, copy_item, "attribute");
setCraftedId(copy_item, getObjIdObjVar(stackedItem, "unstack.serialNumber"));
setCrafter(copy_item, getCrafter(stackedItem));
setAttributeBonuses(copy_item, getAttributeBonuses(stackedItem));
// decrement count
incrementCount(stackedItem, -1);
int count = getCount(stackedItem);
if(count == 1)
{
removeObjVar(stackedItem, "unstack.serialNumber");
detachScript(stackedItem, "object.onewayunstack");
sendDirtyObjectMenuNotification(stackedItem);
}
return;
}
boolean canUnstack(obj_id player)
{
obj_id self = getSelf();
obj_id playerInventory = utils.getInventoryContainer(player);
int count = getCount(self);
if(count < 2)
{
return false;
}
if(!hasObjVar(self, "unstack.serialNumber"))
{
return false;
}
return utils.isNestedWithin(getSelf(), playerInventory);
}
@@ -0,0 +1,16 @@
package script.object;
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 safety_net extends script.base_script
{
public safety_net()
{
}
}
@@ -0,0 +1,89 @@
package script.object;
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.locations;
import script.library.regions;
import script.library.utils;
public class sign extends script.base_script
{
public sign()
{
}
public int OnAttach(obj_id self) throws InterruptedException
{
location here = getLocation(self);
String planet = here.area;
region rgnTest = getSmallestVisibleRegionAtPoint(here);
if (rgnTest == null)
{
debugServerConsoleMsg(self, "DAN FAILED");
debugServerConsoleMsg(self, "location is " + here);
region[] rgnFoos = getRegionsAtPoint(here);
if (rgnFoos == null || rgnFoos.length == 0)
{
debugServerConsoleMsg(self, "fucked");
}
for (int intI = 0; intI < rgnFoos.length; intI++)
{
debugServerConsoleMsg(self, "rgnFooes[" + intI + "] is " + rgnFoos[intI].getName());
}
return SCRIPT_OVERRIDE;
}
String strTest = rgnTest.getName();
string_id city = utils.unpackString(strTest);
if (city == null)
{
setObjVar(self, "city", "none");
return SCRIPT_CONTINUE;
}
utils.setScriptVar(self, "cityName", strTest);
messageTo(self, "setCityName", null, 5, false);
return SCRIPT_CONTINUE;
}
public int OnInitialize(obj_id self) throws InterruptedException
{
location here = getLocation(self);
String planet = here.area;
region rgnTest = getSmallestVisibleRegionAtPoint(here);
if (rgnTest == null)
{
return SCRIPT_OVERRIDE;
}
String strTest = rgnTest.getName();
string_id city = utils.unpackString(strTest);
if (city == null)
{
setObjVar(self, "city", "none");
return SCRIPT_CONTINUE;
}
utils.setScriptVar(self, "cityName", strTest);
messageTo(self, "setCityName", null, 5, false);
return SCRIPT_CONTINUE;
}
public int setCityName(obj_id self, dictionary params) throws InterruptedException
{
if (!utils.hasScriptVar(self, "cityName"))
{
return SCRIPT_CONTINUE;
}
String cityName = utils.getStringScriptVar(self, "cityName");
string_id city = utils.unpackString(cityName);
if (city == null)
{
setObjVar(self, "city", "none");
return SCRIPT_CONTINUE;
}
if (!setName(self, cityName))
{
}
return SCRIPT_CONTINUE;
}
}
@@ -1,105 +0,0 @@
include library.locations;
include library.regions;
include library.utils;
trigger OnAttach()
{
location here = getLocation (self);
string planet = here.area;
region rgnTest = getSmallestVisibleRegionAtPoint(here);
if (rgnTest == null)
{
debugServerConsoleMsg(self, "DAN FAILED");
debugServerConsoleMsg(self, "location is "+here);
region[] rgnFoos= getRegionsAtPoint(here);
if(rgnFoos==null || rgnFoos.length == 0)
{
debugServerConsoleMsg(self, "fucked");
}
for(int intI = 0; intI<rgnFoos.length; intI++)
{
debugServerConsoleMsg(self, "rgnFooes["+intI+"] is "+rgnFoos[intI].getName());
}
return SCRIPT_OVERRIDE;
}
string strTest = rgnTest.getName();
string_id city = utils.unpackString(strTest);
if (city == null)
{
setObjVar (self, "city", "none");
return SCRIPT_CONTINUE;
}
//string_id cityName = new string_id ("tatooine_region_names", city);
utils.setScriptVar(self, "cityName", strTest);
messageTo(self, "setCityName", null, 5, false);
//setName (self, city);
return SCRIPT_CONTINUE;
}
trigger OnInitialize()
{
location here = getLocation (self);
string planet = here.area;
region rgnTest = getSmallestVisibleRegionAtPoint(here);
if (rgnTest == null)
{
return SCRIPT_OVERRIDE;
}
string strTest = rgnTest.getName();
string_id city = utils.unpackString(strTest);
if (city == null)
{
setObjVar (self, "city", "none");
return SCRIPT_CONTINUE;
}
//string_id cityName = new string_id ("tatooine_region_names", city);
utils.setScriptVar(self, "cityName", strTest);
//LOG("jloy","OnInitialize");
messageTo(self, "setCityName", null, 5, false);
//setName (self, city);
return SCRIPT_CONTINUE;
}
messageHandler setCityName()
{
//LOG("jloy","madeit");
if(!utils.hasScriptVar(self, "cityName"))
{
//LOG("jloy","noscriptvar");
return SCRIPT_CONTINUE;
}
string cityName = utils.getStringScriptVar(self, "cityName");
//LOG("jloy","cityName "+cityName);
string_id city = utils.unpackString(cityName);
//LOG("jloy","city "+city);
if (city == null)
{
//LOG("jloy","cityNull");
setObjVar (self, "city", "none");
return SCRIPT_CONTINUE;
}
//LOG("jloy","settingName");
if(!setName (self, cityName))
{
//LOG("jloy","fail");
}
return SCRIPT_CONTINUE;
}