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
#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


Messages In This Thread
Combining drills? - by Streetboat - 12-18-2011, 11:17 PM
RE: Combining drills? - by Your Computer - 12-18-2011, 11:21 PM
RE: Combining drills? - by palistov - 12-19-2011, 01:06 AM
RE: Combining drills? - by Streetboat - 12-19-2011, 04:51 AM
RE: Combining drills? - by palistov - 12-19-2011, 04:55 AM
RE: Combining drills? - by Streetboat - 12-19-2011, 07:46 AM
RE: Combining drills? - by Streetboat - 12-21-2011, 09:12 AM
RE: Combining drills? - by Your Computer - 12-21-2011, 10:23 AM
RE: Combining drills? - by Streetboat - 12-21-2011, 11:10 PM
RE: Combining drills? - by Streetboat - 12-22-2011, 03:41 AM
RE: Combining drills? - by Your Computer - 12-22-2011, 04:28 AM
RE: Combining drills? - by Streetboat - 12-22-2011, 04:40 AM



Users browsing this thread: 1 Guest(s)