Frictional Games Forum (read-only)

Full Version: Combining drills?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I have a question: how on earth did Frictional games make the script for combining the drill in Storage? Right now, I have a puzzle wherein the player has to look for the parts for a drill, but there's a slight twist thrown in: there are two drills, and one is a red herring. One is a smaller, plastic toy drill, and then there's the real one. I want to make it possible to combine the appropriate three parts together for each drill. The toy drill and the real drill can be combined separately, but the toy drill has no real use. Is this possible? I looked all over the 12_storage hps file, and found absolutely nothing about the actual combination process, except for a GlobalVarInt called "DrillParts" that adds up to 3.
Have you looked in the inventory.hps file of the original game?
Most or all of the item combination scripts are in the inventory.hps file like Your Computer mentioned. They're there so the player can combine them anywhere in the game, instead of just in the map where the items are usable.

The global variable tracks how many parts the player has, so they can only combine the drill when all three parts are obtained.

My advice for this red herring toy drill is to just create a separate variable and a separate combination callback for it, so you can avoid the player combining the toy drill parts with real drill parts.
Okay, sooooo it doesn't seem to work. Here's how I have it set up:

I have the 6 items, 3 drill pieces per drill. Each one is labeled according to its part, like 'drill_bit' and 'drill_bit_plastic', 'drill_crank' and 'drill_crank_plastic', and 'drill_part' and 'drill_part_plastic'. Each time one is picked up, a GlobalVarInt is added, adding up to 3 total, according to which type is picked up. And in my inventory.hps, I have an AddCombineCallback (or whatever it's called, I'm not at my computer right now) for each part, but it doesn't register. It just says 'combination doesn't work' when I combine them in the inventory. Hulp? I have no idea how Frictional made it work. Sad
Post the script you're using to add the combination callbacks, it's likely a bug there.
from my inventory.hps:

if (GetGlobalVarInt("DrillParts") == 3)
{
AddCombineCallback("", "drill_bit", "drill_handle", "CombineDrill", true);
AddCombineCallback("", "drill_bit", "drill_part", "CombineDrill", true);
AddCombineCallback("", "drill_part", "drill_handle", "CombineDrill", true);
}
if (GetGlobalVarInt("DrillPartsPlastic") == 3)
{
AddCombineCallback("", "drill_bit_plastic", "drill_handle_plastic", "CombineDrillToy", true);
AddCombineCallback("", "drill_bit_plastic", "drill_part_plastic", "CombineDrillToy", true);
AddCombineCallback("", "drill_part_plastic", "drill_handle_plastic", "CombineDrillToy", true);
}
void CombineDrill(string &in asItemA, string &in asItemB)
{
if(GetGlobalVarInt("DrillParts") != 3){
SetInventoryMessage("Inventory", "CombineDrillError", -1);
return;
}

PlayGuiSound("12_make_drill", 1.0f);

RemoveItem("drill_bit");
RemoveItem("drill_part");
RemoveItem("drill_handle");

GiveItem("hand_drill_1", "hand_drill", "handdrill", "hand_drill.tga", 0);
SetMessage("Inventory", "MadeDrill", 0);
}
void CombineDrillPlastic(string &in asItemA, string &in asItemB)
{
if(GetGlobalVarInt("DrillPartsPlastic") != 3){
SetInventoryMessage("Inventory", "CombineDrillError", -1);
return;
}

PlayGuiSound("12_make_drill", 1.0f);

RemoveItem("drill_bit_plastic");
RemoveItem("drill_part_plastic");
RemoveItem("drill_handle_plastic");

GiveItem("hand_drill_plastic", "hand_drill", "handdrillplastic", "hand_drill.tga", 0);
SetMessage("Inventory", "MadeDrill", 0);
}
mermermer pleeeeease this is paramount to the success of my storyyyyy
Why are there if statements out of a function? Look at Amnesia's inventory.hps; see how everything is structured, where things are called at. Of course your item combine callbacks aren't being registered. Try to figure out the reason and purpose for why things are written the way they are in Amnesia's inventory.hps. Also, you shouldn't be trying to add item combine callbacks when the player has retrieved 3 parts of one item. You should instead be verifying whether or not the player has those 3 items at the time a combination is attempted.
I don't understand where to place the combine callbacks. I haven't had much trouble figuring out fairly complex scripting thus far, but this is really hard to wrap my head around. There are a couple of variables at play that I don't know how to communicate with the game.
1- If the player has all three drill parts (for both the real and the fake drills), then they can be combined with each other to form the drill.
2- If the player doesn't have all three parts, and tried to combine them, there is a message that says you need all three parts to make it work and the pieces are returned.
3-If the player tried to combine a real part with a plastic part, or vice versa, it gives a message saying they won't fit together and the pieces are returned.

How are these things made possible? My inventory.hps looks like this now:
Quote:void CombineDrill(string &in asItemA, string &in asItemB)
{
if(GetGlobalVarInt("DrillParts") != 3){
SetInventoryMessage("Inventory", "CombineDrillError", -1);
return;
}

PlayGuiSound("12_make_drill", 1.0f);

RemoveItem("drill_bit");
RemoveItem("drill_part");
RemoveItem("drill_handle");

GiveItem("hand_drill_1", "hand_drill", "handdrill", "hand_drill.tga", 0);
SetMessage("Inventory", "MadeDrill", 0);
}
void CombineDrillPlastic(string &in asItemA, string &in asItemB)
{
if(GetGlobalVarInt("DrillPartsPlastic") != 3){
SetInventoryMessage("Inventory", "CombineDrillError", -1);
return;
}

PlayGuiSound("12_make_drill", 1.0f);

RemoveItem("drill_bit_plastic");
RemoveItem("drill_part_plastic");
RemoveItem("drill_handle_plastic");

GiveItem("hand_drill_plastic", "hand_drill", "handdrillplastic", "hand_drill.tga", 0);
SetMessage("Inventory", "MadeDrill", 0);
}
And the drill portion of my level code looks like this:
Quote:void drillhandle(string &in asEntity)
{
SetGlobalVarInt("gothandle", 1);
AddGlobalVarInt("DrillParts", 1);
if (GetGlobalVarInt("DrillParts") == 3)
{
AddCombineCallback("", "drill_bit", "drill_handle", "CombineDrill", true);
AddCombineCallback("", "drill_bit", "drill_part", "CombineDrill", true);
AddCombineCallback("", "drill_part", "drill_handle", "CombineDrill", true);
}
SetMessage("Messages4", "DrillHandle", 0);
if(GetGlobalVarInt("DrillParts") == 2) GiveHint("combinehint", "Hints", "CombineHint", 0);
}
void drillbit(string &in asEntity)
{
SetGlobalVarInt("gothandle", 1);
AddGlobalVarInt("DrillParts", 1);
if (GetGlobalVarInt("DrillParts") == 3)
{
AddCombineCallback("", "drill_bit", "drill_handle", "CombineDrill", true);
AddCombineCallback("", "drill_bit", "drill_part", "CombineDrill", true);
AddCombineCallback("", "drill_part", "drill_handle", "CombineDrill", true);
}
SetMessage("Messages4", "DrillBit", 0);
if(GetGlobalVarInt("DrillParts") == 2) GiveHint("combinehint", "Hints", "CombineHint", 0);
}
void drillbitplastic(string &in asEntity)
{
AddGlobalVarInt("DrillPartsPlastic", 1);
if (GetGlobalVarInt("DrillPartsPlastic") == 3)
{
AddCombineCallback("", "drill_bit_plastic", "drill_handle_plastic", "CombineDrillToy", true);
AddCombineCallback("", "drill_bit_plastic", "drill_part_plastic", "CombineDrillToy", true);
AddCombineCallback("", "drill_part_plastic", "drill_handle_plastic", "CombineDrillToy", true);
}
SetMessage("Messages4", "DrillBitPlastic", 0);
if(GetGlobalVarInt("DrillPartsPlastic") == 2) GiveHint("combinehint", "Hints", "CombineHint", 0);
}
void drillpartplastic(string &in asEntity)
{
AddGlobalVarInt("DrillPartsPlastic", 1);
if (GetGlobalVarInt("DrillPartsPlastic") == 3)
{
AddCombineCallback("", "drill_bit_plastic", "drill_handle_plastic", "CombineDrillToy", true);
AddCombineCallback("", "drill_bit_plastic", "drill_part_plastic", "CombineDrillToy", true);
AddCombineCallback("", "drill_part_plastic", "drill_handle_plastic", "CombineDrillToy", true);
}
SetMessage("Messages4", "DrillPartPlastic", 0);
if(GetGlobalVarInt("DrillPartsPlastic") == 2) GiveHint("combinehint", "Hints", "CombineHint", 0);
}
void drillhandleplastic(string &in asEntity)
{
AddGlobalVarInt("DrillPartsPlastic", 1);
if (GetGlobalVarInt("DrillPartsPlastic") == 3)
{
AddCombineCallback("", "drill_bit_plastic", "drill_handle_plastic", "CombineDrillToy", true);
AddCombineCallback("", "drill_bit_plastic", "drill_part_plastic", "CombineDrillToy", true);
AddCombineCallback("", "drill_part_plastic", "drill_handle_plastic", "CombineDrillToy", true);
}
SetMessage("Messages4", "DrillHandlePlastic", 0);
if(GetGlobalVarInt("DrillPartsPlastic") == 2) GiveHint("combinehint", "Hints", "CombineHint", 0);
}
And the reason one of the three parts of the real drill is missing from that code, is because another portion of the drill is hidden on another level entirely. The code is exactly the same, though.
I thought I had it figured out... Sad It looks great in my inventory.hps file, exactly like in the main Amnesia game. Here:
Quote:void OnGameStart()
{
AddCombineCallback("", "drill_bit", "drill_handle_plastic", "CombineDrillMix", true);
AddCombineCallback("", "drill_bit", "drill_part_plastic", "CombineDrillMix", true);
AddCombineCallback("", "drill_handle", "drill_part_plastic", "CombineDrillMix", true);
AddCombineCallback("", "drill_bit_plastic", "drill_part", "CombineDrillMix", true);
AddCombineCallback("", "drill_bit_plastic", "drill_handle", "CombineDrillMix", true);
AddCombineCallback("", "drill_bit", "drill_handle", "CombineDrill", true);
AddCombineCallback("", "drill_bit", "drill_part", "CombineDrill", true);
AddCombineCallback("", "drill_part", "drill_handle", "CombineDrill", true);
AddCombineCallback("", "drill_bit_plastic", "drill_handle_plastic", "CombineDrillToy", true);
AddCombineCallback("", "drill_bit_plastic", "drill_part_plastic", "CombineDrillToy", true);
AddCombineCallback("", "drill_part_plastic", "drill_handle_plastic", "CombineDrillToy", true);
}
void CombineDrillMix(string &in asItemA, string &in asItemB)
{
SetInventoryMessage("Inventory", "CombineDrillPlastic", -1);
return;
}
void CombineDrill(string &in asItemA, string &in asItemB)
{
if(GetGlobalVarInt("DrillParts") != 3){
SetInventoryMessage("Inventory", "CombineDrillError", -1);
return;
}
if(GetGlobalVarInt("DrillParts") == 3)
{
PlayGuiSound("12_make_drill", 1.0f);

RemoveItem("drill_bit");
RemoveItem("drill_part");
RemoveItem("drill_handle");

GiveItem("hand_drill_1", "hand_drill", "handdrill", "hand_drill.tga", 0);
SetMessage("Inventory", "MadeDrill", 0);
}
}
void CombineDrillToy(string &in asItemA, string &in asItemB)
{
if(GetGlobalVarInt("DrillPartsPlastic") != 3){
SetInventoryMessage("Inventory", "CombineDrillError", -1);
return;
}
if(GetGlobalVarInt("DrillPartsPlastic") == 3)
{
PlayGuiSound("12_make_drill", 1.0f);

RemoveItem("drill_bit_plastic");
RemoveItem("drill_part_plastic");
RemoveItem("drill_handle_plastic");

GiveItem("hand_drill_plastic", "hand_drill", "handdrillplastic", "hand_drill.tga", 0);
SetMessage("Inventory", "MadeDrillPlastic", 0);
}
}
And here is an example of how one of the pickup scripts looks in the level files:
Quote:void drillhandle(string &in asEntity)
{
SetGlobalVarInt("gothandle", 1);
AddGlobalVarInt("DrillParts", 1);
SetMessage("Messages4", "DrillHandle", 0);
if(GetGlobalVarInt("DrillParts") == 2)
{
GiveHint("combinehint", "Hints", "CombineHint", 0);
}
}

It just tells me 'combination does not work' when I try to combine them. It seems as if it isn't running any of the scripts in inventory.hps for some reason.
Pages: 1 2