Files
dsrc/sku.0/sys.server/compiled/game/script/systems/crafting/base_station.script
T

172 lines
4.3 KiB
Plaintext

/**
* Copyright (c) ©2000-2002 Sony Online Entertainment Inc.
* All Rights Reserved
*
* Title: systems.crafting.base_station.script
* Description:
* @author Steve Jakab
* @version $Revision: 0$
*/
include library.buff;
include library.craftinglib;
include library.utils;
/**
* Prevents a player from putting an object in the station's output hopper or any other slot.
*
* @param self the container about to gain the item
* @param srcContainer the container about to lose the item
* @param transferer the thing transferring the object
* @param item the object being transfered
*
* @return SCRIPT_CONTINUE to allow the transfer, SCRIPT_OVERRIDE to stop it
**/
trigger OnAboutToReceiveItem(obj_id srcContainer, obj_id transferer, obj_id item)
{
if ( transferer == obj_id.NULL_ID || transferer == srcContainer)
return SCRIPT_CONTINUE;
return SCRIPT_OVERRIDE;
}
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
{
if(utils.isInHouseCellSpace(self))
mi.addRootMenu (menu_info_types.CRAFT_HOPPER_INPUT, null);
return SCRIPT_CONTINUE;
}
trigger OnGetAttributes(obj_id player, string[] names, string[] attribs)
{
int idx = utils.getValidAttributeIndex(names);
if (idx == -1)
return SCRIPT_CONTINUE;
if (hasObjVar(self, "crafting.stationMod"))
{
names[idx] = "stationmod";
float attrib = getFloatObjVar(self, "crafting.stationMod");
attribs[idx] = "" + attrib;
idx++;
if (idx >= names.length)
return SCRIPT_CONTINUE;
}
return SCRIPT_CONTINUE;
}
trigger OnInitialize()
{
//attempt to get a cell id we are contained in.
if(isInWorldCell(self))
return SCRIPT_CONTINUE;
obj_id cell = getContainedBy(self);
if(!isIdValid(cell) || !exists(cell))
return SCRIPT_CONTINUE;
if(isPlayer(cell))
return SCRIPT_CONTINUE;
if(utils.isNestedWithinAPlayer(cell))
return SCRIPT_CONTINUE;
if(isMob(cell))
return SCRIPT_CONTINUE;
if(!hasScript(cell, "systems.crafting.station_cell"))
attachScript(cell, "systems.crafting.station_cell");
//check to see if we already have a list of stations
if(utils.hasScriptVar(cell, craftinglib.SCRIPTVAR_CELL_STATIONS))
{
//add myself to the list
resizeable obj_id[] stations = utils.getResizeableObjIdArrayScriptVar(cell, craftinglib.SCRIPTVAR_CELL_STATIONS);
if(!utils.isElementInArray(stations, self))
{
stations = utils.addElement(stations, self);
utils.setScriptVar(cell, craftinglib.SCRIPTVAR_CELL_STATIONS, stations);
}
}
else
{
//create a new list
resizeable obj_id[] stations = new obj_id [0];
stations = utils.addElement(stations, self);
utils.setScriptVar(cell, craftinglib.SCRIPTVAR_CELL_STATIONS, stations);
}
return SCRIPT_CONTINUE;
}
//need to clean up buffs and scriptvars if I am moved
trigger OnTransferred(obj_id sourceContainer, obj_id destContainer, obj_id transferer)
{
if(isInWorldCell(self) || !isIdValid(destContainer))
return SCRIPT_CONTINUE;
obj_id cell = getContainedBy(self);
if(!isIdValid(cell) || !exists(cell))
return SCRIPT_CONTINUE;
if(isPlayer(cell))
return SCRIPT_CONTINUE;
if(isMob(cell))
return SCRIPT_CONTINUE;
if(utils.isNestedWithinAPlayer(cell))
return SCRIPT_CONTINUE;
if(!hasScript(cell, "systems.crafting.station_cell"))
attachScript(cell, "systems.crafting.station_cell");
//check to see if we already have a list of stations
if(utils.hasScriptVar(cell, craftinglib.SCRIPTVAR_CELL_STATIONS))
{
//add myself to the list
resizeable obj_id[] stations = utils.getResizeableObjIdArrayScriptVar(cell, craftinglib.SCRIPTVAR_CELL_STATIONS);
if(!utils.isElementInArray(stations, self))
{
stations = utils.addElement(stations, self);
utils.setScriptVar(cell, craftinglib.SCRIPTVAR_CELL_STATIONS, stations);
}
}
else
{
//create a new list
resizeable obj_id[] stations = new obj_id [0];
stations = utils.addElement(stations, self);
utils.setScriptVar(cell, craftinglib.SCRIPTVAR_CELL_STATIONS, stations);
}
if(isPlayer(transferer))
{
int craftingType = getIntObjVar(self, craftinglib.OBJVAR_CRAFTING_TYPE);
//possible list of buffs to apply
string[] buffNames = craftinglib.getAllStationBuffNames(craftingType);
if(buffNames == null || buffNames.length <= 0)
return SCRIPT_CONTINUE;
for(int a = 0; a < buffNames.length; a++)
buff.applyBuff(transferer, self, buffNames[a]);
}
return SCRIPT_CONTINUE;
}