mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-31 00:15:54 -04:00
68 lines
2.0 KiB
Plaintext
68 lines
2.0 KiB
Plaintext
include library.craftinglib;
|
|
|
|
/*
|
|
This script places an invisible player private crafting station template in one or more
|
|
of the building cells for a structure upon initialization. The
|
|
crafting station applies all appropriate station buffs on the player based on the building template name.
|
|
*/
|
|
|
|
const string OBJVAR_CRAFTING_TYPE = "crafting.type";
|
|
|
|
const string INVISIBLE_CRAFTING_STATION_TEMPLATE = "object/tangible/crafting/station/inivisible_crafting_station.iff";
|
|
const string DINER_TEMPLATE_NO_PATH = "diner_no_planet_restriction";
|
|
|
|
|
|
trigger OnInitialize()
|
|
{
|
|
string buildingTemplate = getTemplateName(self);
|
|
if(buildingTemplate == null || buildingTemplate.equals(""))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
//if this is the diner buff...
|
|
if(buildingTemplate.indexOf(DINER_TEMPLATE_NO_PATH) > 0)
|
|
spawnInvCraftingStation(self, craftinglib.STATION_TYPE_FOOD_AND_STRUCTURE);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
boolean spawnInvCraftingStation(obj_id building, int craftingBuff)
|
|
{
|
|
return spawnInvCraftingStation(building, craftingBuff, null);
|
|
}
|
|
|
|
boolean spawnInvCraftingStation(obj_id building, int craftingBuff, string specificCell)
|
|
{
|
|
if(!isValidId(building) || !exists(building))
|
|
return false;
|
|
|
|
if(craftingBuff < 0)
|
|
return false;
|
|
|
|
string[] allCells = getCellNames(building);
|
|
if(allCells == null)
|
|
return false;
|
|
|
|
for(int i = 0; i < allCells.length; i++)
|
|
{
|
|
if(specificCell != null && specificCell != allCells[i])
|
|
continue;
|
|
|
|
if(specificCell != null && specificCell == allCells[i])
|
|
{
|
|
obj_id singleCellStation = createObjectInCell(INVISIBLE_CRAFTING_STATION_TEMPLATE, building, allCells[i]);
|
|
if(!isValidId(singleCellStation) || !exists(singleCellStation))
|
|
return false;
|
|
|
|
setObjVar(singleCellStation, OBJVAR_CRAFTING_TYPE, craftingBuff);
|
|
break;
|
|
}
|
|
|
|
obj_id allCellsStation = createObjectInCell(INVISIBLE_CRAFTING_STATION_TEMPLATE, building, allCells[i]);
|
|
if(!isValidId(allCellsStation) || !exists(allCellsStation))
|
|
return false;
|
|
|
|
setObjVar(allCellsStation, OBJVAR_CRAFTING_TYPE, craftingBuff);
|
|
}
|
|
return true;
|
|
}
|