Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Combining drills?
Streetboat Offline
Posting Freak

Posts: 1,099
Threads: 40
Joined: Mar 2011
Reputation: 56
#1
Combining drills?

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.

[Image: signature-2.png]
(This post was last modified: 12-22-2011, 04:40 AM by Streetboat.)
12-18-2011, 11:17 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#2
RE: Combining drills?

Have you looked in the inventory.hps file of the original game?

Tutorials: From Noob to Pro
12-18-2011, 11:21 PM
Website Find
palistov Offline
Posting Freak

Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation: 57
#3
RE: Combining drills?

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.

12-19-2011, 01:06 AM
Find
Streetboat Offline
Posting Freak

Posts: 1,099
Threads: 40
Joined: Mar 2011
Reputation: 56
#4
RE: Combining drills?

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

[Image: signature-2.png]
12-19-2011, 04:51 AM
Find
palistov Offline
Posting Freak

Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation: 57
#5
RE: Combining drills?

Post the script you're using to add the combination callbacks, it's likely a bug there.

12-19-2011, 04:55 AM
Find
Streetboat Offline
Posting Freak

Posts: 1,099
Threads: 40
Joined: Mar 2011
Reputation: 56
#6
RE: Combining drills?

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);
}

[Image: signature-2.png]
(This post was last modified: 12-19-2011, 07:47 AM by Streetboat.)
12-19-2011, 07:46 AM
Find
Streetboat Offline
Posting Freak

Posts: 1,099
Threads: 40
Joined: Mar 2011
Reputation: 56
#7
RE: Combining drills?

mermermer pleeeeease this is paramount to the success of my storyyyyy

[Image: signature-2.png]
12-21-2011, 09:12 AM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#8
RE: Combining drills?

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.

Tutorials: From Noob to Pro
(This post was last modified: 12-21-2011, 10:23 AM by Your Computer.)
12-21-2011, 10:23 AM
Website Find
Streetboat Offline
Posting Freak

Posts: 1,099
Threads: 40
Joined: Mar 2011
Reputation: 56
#9
RE: Combining drills?

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.

[Image: signature-2.png]
12-21-2011, 11:10 PM
Find
Streetboat Offline
Posting Freak

Posts: 1,099
Threads: 40
Joined: Mar 2011
Reputation: 56
#10
RE: Combining drills?

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.

[Image: signature-2.png]
12-22-2011, 03:41 AM
Find




Users browsing this thread: 3 Guest(s)