Using an inventory item on another item and using both together on an object

Started by lapsking, Tue 20/12/2022 14:19:50

Previous topic - Next topic

lapsking

Oh no, me again. (wrong) And believe me I've searched the forum already and couldn't find the solution. But maybe it already exists and I used wrong keywords. So forgive me.

I want to use x item on y item and then use both on an object or hotspot. I know how to combine inventory items but it doesn't make sense here. The action bar should read "Use X with Y with Z". X and Y are inventory items and Z is an object. I've seen it in some other games. I appreciate any help.

Danvzare

Quote from: lapsking on Tue 20/12/2022 14:19:50Oh no, me again. (wrong) And believe me I've searched the forum already and couldn't find the solution. But maybe it already exists and I used wrong keywords. So forgive me.

I want to use x item on y item and then use both on an object or hotspot. I know how to combine inventory items but it doesn't make sense here. The action bar should read "Use X with Y with Z". X and Y are inventory items and Z is an object. I've seen it in some other games. I appreciate any help.
Usually what I do in these situations, is have the character automatically use X with Y when either X or Y is used with Z and both X and Y are in your inventory. And then throw in a hint about needing something when you try to use X or Y with Z when you don't have both X and Y.

Alternatively, you could just allow the temporarily combining of X and Y. You use X with Y and then you get XY (which would literally just be called X with Y) and then you use XY with Z. Perhaps even having the item automatically active, and removed from your inventory if you click on anything other than the correct solution.

But of course there is a third possible option if it fits with the puzzle. You could use either X or Y with Z, and then have the character point out that he'll need to add something else, and then if the player uses the other correct item, the puzzle is solved, otherwise it resets when you use the wrong item or walk away, possibly with the character saying something along the lines of "Ah, never mind then." to show that you were on the right path.

lapsking

Thanks Danvzare. First option makes the puzzle so much easy and third option doesn't work with this puzzle since one has to use both items at the same time to make a change on the object. The second option is closer to what I need but without adding the temporary combined item to inventory. Can I make an item active automatically without being/showing in the inventory? I don't know how to active "use item" automatically! Thank you.

Khris

Neither AGS nor the Tumbleweed template supports this out of the box.

If combining x and y first doesn't make sense it's going to get complicated. You would have to create an additional global .ActiveInventory item pointer and set it in the handler of using X on Y / Y on X. Next you have to adjust the function that updates the action text, this is relatively simple though: check if the second inventory item isn't null and compose the text from there.

Also, Danvzare's 3rd option sounds like a good workaround for this.

lapsking

Hi Khris, I would love to know about your solution in more details before using Danvzare's method. I spent two hours to understand what you said actually means with no avail. I'll appreciate explaining in details whenever you have time. I'm embarrassed with my programming knowledge. Sorry for bothering you.

newwaveburritos

If I understand what you're saying you want the player to make a peanut butter and jelly sandwich.  The bread has to stay on the counter and you don't want the player to make a mixture of peanut butter and jelly because that's not how you make a peanut butter and jelly sandwich.  You want the player to use the peanut butter on the bread and then next the jelly?  The analogy breaks down here, I think.  Is it like a situation in which the player must hold peanut butter in one hand while holding jelly in the other and then they click the bread?  The order of operations is important?

Another work around you could try if you didn't want to update the actual "action text" you could just make some variables and use a GUI that imitates the action text when the correct conditions are met.  Not sure how well that would work with Tumbleweed, though.

Khris

I'm sorry, this is going to require a deep dive into the Tumbleweed template I'm afraid and I don't really have the time currently to do that.

If this is going to be an essential mechanic in your game you might want to change the GUI anyway, for instance using an inventory system where you're basically equipping items (using a slot for each hand).

lapsking

Thanks Khris. Ok burritos, I wish it was jelly, peanut and bread. I'll explain the  puzzle for better understanding:

Spoiler
the player has to put tinder on the wood in the room. Then scrape down the flint (item) with his dagger (item) to make sparks on the tinder (object) to start a fire.
[close]

If that's too complicated which it seems it is, my next idea is when player uses an item on another item in a specific room, specific things happen and if he does the same in the rest of the rooms another thing happens. But I don't know how to do that either.

I wish matches were available in 1093AD. :~(

heltenjon

Here's a suggestion for a workaround. Make an area near the third object (which should be visible on mouseover now) that is activated when you put that item in the right place, then if you use the two other inventory items inside the area, the puzzle is solved, outside the area, another message appears.

In your puzzle, that would be
Spoiler
When you put the tinder on the firewood, you activate the area. If you use the knife and flintstone while player character is in the area, the fire is lit. If outside the area, you're just told that it produces a spark.
[close]

...but if this was a game using first person perspective, that won't work. You could make a closeup view instead of the area, but perhaps that would make the puzzle too easy again.

lapsking

Thank you heltenjon, that was a good idea if my game was 3rd person, but yes it's 1st person. I also thought of making a closeup view, I might do that. I don't think it makes the puzzle much easier, still the player must have some kind of clue why he's doing it there, or just keep trying it randomly in each room hoping for something to happen. Doesn't matter if he starts a fire by accident, that's how starting a fire was invented by our ancestors anyway.  :-D

Snarky

Quote from: lapsking on Wed 21/12/2022 12:45:41
Spoiler
the player has to put tinder on the wood in the room. Then scrape down the flint (item) with his dagger (item) to make sparks on the tinder (object) to start a fire.
[close]

I would suggest doing this in a pretty traditional inventory manner:
Spoiler
Combining dagger and flint creates spark item in inventory. (Ideally, spark item disappears after a few seconds if not used.*) Put tinder on wood, create spark, use spark on tinder. (If player uses spark on wood without tinder, give feedback that the fire doesn't catch.)

* You can use a Timer to remove it. And you can use some Ron Gilbert-style "elastic time" to make it feel more urgent while not making it too difficult. Say for example that the spark goes away after 5 seconds, but if you select it as your inventory item, that gets extended by another 5 seconds, giving you 10 seconds from creating the spark to using it.
[close]

arj0n

What snarky said.
Or something like:
- Combining dagger and flint removes dagger item and flint item and creates a new 'combined' inv item 'dagger+flint'.
- Use new dagger+flint item on wood or on wrong objects/hotspots
- When dropping the item (putting back in inv box) you can choose to keep the combined item or to un-combine them automatically (that is remove combined item and give back flint item and dagger item) 

lapsking

Thank you Snarky, that was actually my first thought about doing this puzzle while lying on the bed few days ago. Though adding spark as an inventory item didn't make much sense, but now that you mentioned it and arj0n agreed too I'm more convinced, specially with timer which I didn't think of it, but makes it much more realistic. I've never used Timer. Can anyone tell me how to set a Timer for an inventory object and extend it after selecting it? Or refer me to a topic explaining them? Thank you all!
PS. I think I found the code. SetTimer and IsTimerExpired. I'm going to check it out.

Cassiebsg

Think we might be complicating this a bit too much maybe? I'm no expert in the Tumbleweed template, so I'll just talk my thoughs on this process:

Spoiler

- Use tinder on firewood (nothing weird here).
- Use knife on tinder/firewood (nothing new here either)
- Eventually zoom in so that you now can see, the firewood, tinder and knife.
- Now, you just need to use the flint on the knife

If your zoom in is close enough you can even make the flint become the cursor and then use the mouse to strike the flint in the right place (or correct movement) to make the spark fly towards the tinder and start the fire.

I think this would give the player a good feel of actually doing it instead of randomly combine object x with y and use on Z.

It would be a cool interactive piece, I think. :) Then you can make it easier or harder (like placing the tinder in the correct place, the knife and strike with just the right movement/direction/strength).
[close]
There are those who believe that life here began out there...

newwaveburritos

Quote from: lapsking on Wed 21/12/2022 12:45:41...my next idea is when player uses an item on another item in a specific room, specific things happen and if he does the same in the rest of the rooms another thing happens. But I don't know how to do that either.

The way to do this is with an if statement.  Something like:

Code: AGS

//from the global script.  The function is created when you click on the "..." in the events pane on the inventory item on "use inventory on this item."

function iDagger_UseInv()
{
  if (player.ActiveInventory==iFlint){
    if (player.Room!=3){  //or whatever room this needs to happen in
      player.Say("It's too dangerous to try that right here."); //message which indicates this is possible just not right here.
    }
    else{
      //creating spark code goes here
    }
  }
}

lapsking

It's interesting that there are so many ways to deal with this puzzle, I think it's just a matter of taste. I personally prefer the two items first interact directly with each other, so I did as Snarky said.

SMF spam blocked by CleanTalk