Crafting at a vendor, using items from inventory

Level 4
Joined
Nov 16, 2019
Messages
55
Hello.

I am currently making an rpg map, and I need to make you capable of making/buying some specific items, when you carry some specific items in your inventory.

I've been able to make a trigger, that adds an item to a shop when a player carries a specific item in the inventory. However, I have not been able to get the item used in the crafting/buying process to be removed from the inventory after the buy/crafting.

And another thing I want to do as well, is make the player have to carry fx 2 of the same items/crafting materials in the inventory, in order to get to buy/craft an item. But I still haven't figured out how to make the triggers count for a certain amount of a specific type of item.


So for short, I need to:
- Make items disappear from inventory, after using them as the requirement for buying/crafting an item at a shop.
- Have the requirement for buying/crafting a specific item, be multiple items, both different and/or same item type.
 
Level 27
Joined
Feb 18, 2014
Messages
3,543
Make items disappear from inventory, after using them as the requirement for buying/crafting an item at a shop.
Maybe make an event that detects when a shop sells a type of item and then remove the item requirement from the buying unit.
Have the requirement for buying/crafting a specific item, be multiple items, both different and/or same item type.
Use an integer variable that increases by 1 every time the hero picks up the same type of item.
 
- Have the requirement for buying/crafting a specific item, be multiple items, both different and/or same item type.
Use an integer variable that increases by 1 every time the hero picks up the same type of item.
You can loop through a unit's inventory on demand and perform any checks. Maintaining a counter sounds complicated in comparison, considering MUI and item giving/dropping/remvoval.
 
Level 4
Joined
Nov 16, 2019
Messages
55
Maybe make an event that detects when a shop sells a type of item and then remove the item requirement from the buying unit.

Use an integer variable that increases by 1 every time the hero picks up the same type of item.

I have done something similar, however I cannot get the 'crafting' item removed from the buying unit. And I am also a bit of a noob when it comes to integer variables and variables in general. Could you possibly give a simple example of how you'd execute this?
 
Level 27
Joined
Feb 18, 2014
Messages
3,543
I have done something similar, however I cannot get the 'crafting' item removed from the buying unit
First of, make sure the shop has the "Sell items" ability, then make a trigger like this :
  • Sell Item
    • Events
      • Unit - A unit owned by Neutral Passif Sells an item (from shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to Crown of Kings +5
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Buying unit) has an item of type "Crafting Item") Equal to TRUE
        • Then - Actions
          • Item - Remove (Item carried by (Buying unit) of type "Crafting Item")
        • Else - Actions
          • Item - Remove (Sold Item)
And I am also a bit of a noob when it comes to integer variables and variables in general. Could you possibly give a simple example of how you'd execute this?
Create a variable of type "Integer" then do this :
  • Item Count
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to "Some Item"
    • Actions
      • Set ItemCount = (ItemCount + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ItemCount Equal to 10
        • Then - Actions
          • -------- Do what you want here --------
        • Else - Actions
 
Level 4
Joined
Nov 16, 2019
Messages
55
First of, make sure the shop has the "Sell items" ability, then make a trigger like this :
  • Sell Item
    • Events
      • Unit - A unit owned by Neutral Passif Sells an item (from shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to Crown of Kings +5
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Buying unit) has an item of type "Crafting Item") Equal to TRUE
        • Then - Actions
          • Item - Remove (Item carried by (Buying unit) of type "Crafting Item")
        • Else - Actions
          • Item - Remove (Sold Item)
Create a variable of type "Integer" then do this :
  • Item Count
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to "Some Item"
    • Actions
      • Set ItemCount = (ItemCount + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ItemCount Equal to 10
        • Then - Actions
          • -------- Do what you want here --------
        • Else - Actions

Thanks! I will try that out!
 
Level 4
Joined
Nov 16, 2019
Messages
55
First of, make sure the shop has the "Sell items" ability, then make a trigger like this :
  • Sell Item
    • Events
      • Unit - A unit owned by Neutral Passif Sells an item (from shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to Crown of Kings +5
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Buying unit) has an item of type "Crafting Item") Equal to TRUE
        • Then - Actions
          • Item - Remove (Item carried by (Buying unit) of type "Crafting Item")
        • Else - Actions
          • Item - Remove (Sold Item)
Create a variable of type "Integer" then do this :
  • Item Count
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to "Some Item"
    • Actions
      • Set ItemCount = (ItemCount + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ItemCount Equal to 10
        • Then - Actions
          • -------- Do what you want here --------
        • Else - Actions

Okay, so I've tested out the triggers you've suggested. I decided that you need 3 "Bear Pelts" in order to be able to buy the "Tough Leather Armor". So it works initially. You acquire 3 pelts, and the item becomes available.

There are two problems now however.

1. How do I make it, so when the item is bought, all 3 Bear Pelts are removed from the inventory of the buyer? Because right now, only 1 Bear Pelt is removed from the inventory.
2. For some reason, when I've bought the item, and then manage to reach 3 Bear Pelts in inventory again, the item won't show up in the shop again. I am just using the "add item to marketplace" trigger.

Here's what I've set up:

29372Q3.png
 
Level 27
Joined
Feb 18, 2014
Messages
3,543
1. How do I make it, so when the item is bought, all 3 Bear Pelts are removed from the inventory of the buyer? Because right now, only 1 Bear Pelt is removed from the inventory.
Are these "Bear Pelts" stackable? I mean are they placed in the same slot or each one of them take one slot in the inventory? If it's the latter, you just have to repeat the "Remove (Item carried by (Buying unit))" x3 times, if it's the former, then you can directly remove them with "Remove item carried" once (I think)
2. For some reason, when I've bought the item, and then manage to reach 3 Bear Pelts in inventory again, the item won't show up in the shop again. I am just using the "add item to marketplace" trigger.
You can either increase the stock of the item or add it once the buying unit acquires the item.
  • Sell Item
    • Events
      • Unit - A unit owned by Neutral Passif Sells an item (from shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to Tough Leather Jerkin
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Buying unit) has an item of type Bear Pelt) Equal to TRUE
        • Then - Actions
          • Item - Remove (Item carried by (Buying unit) of type Bear Pelt)
          • Neutral Building - Add Tough Leather Jerkin to Kelgos the Blacksmith 0181 <gen> with 1 in stock and a max stock of 1
        • Else - Actions
          • Item - Remove (Sold Item)
          • Neutral Building - Add Tough Leather Jerkin to Kelgos the Blacksmith 0181 <gen> with 1 in stock and a max stock of 1
 
Top