• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

How to make items cost food.

Status
Not open for further replies.

SpasMaster

Hosted Project: SC
Level 23
Joined
Jan 29, 2010
Messages
1,969
Guys, I have a problem here. I made one really cool item for my map but I want to limit it as one per hero. I mean that each hero can have only one of that item. I decided to make each hero cost 5 food (there are no other units except the hero in the map), and the item cost 1 food. But when I went to the part making the item 1 food, I saw that I can't. Can anyone tell me how to make an item cost food? Or any other ideas of limiting 1 item per hero? Thanks!
 
Level 14
Joined
Aug 8, 2010
Messages
1,022
You can try to create a custom unit that is invisible (or you can simply set its height to -200 and it selection size to -200 if its possible), set it's food cost to the amount you want and change it's selection size to 0 or 1. Make that unit targeted as tree or something.And create a trigger that looks like this
  • Item cost food
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Picked item)) Equal to Your item
    • Actions
      • Unit - Create 1 Invisible unit for (Triggering player) at (Center of (Playable map area)) facing Default building facing degrees
i am not so sure about the event! :) :thumbs_up:
 
  • Like
Reactions: ZIR
Level 3
Joined
Aug 17, 2010
Messages
33
You can try to create a custom unit that is invisible (or you can simply set its height to -200 and it selection size to -200 if its possible), set it's food cost to the amount you want and change it's selection size to 0 or 1. Make that unit targeted as tree or something.And create a trigger that looks like this
  • Item cost food
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Picked item)) Equal to Your item
    • Actions
      • Unit - Create 1 Invisible unit for (Triggering player) at (Center of (Playable map area)) facing Default building facing degrees
i am not so sure about the event! :) :thumbs_up:

I think it most be manipulated item instead of picked item like this.
  • Actions
    • (Item-type of (Item being manipulated)) Equal to Tome of Experience
 
Level 7
Joined
Dec 24, 2009
Messages
257
The easiest way is making a trigger that checks if there's already an item of that type in your Hero's inventory using Boolean Comparison - Hero - Hero has item of type [ABC]
  • ((Triggering unit has item of type [ABC]) Equal to True
then set Then/Else actions:
True: remove the item acquired (The 2nd [ABC] I mean) and create one [ABC] on the ground
Else: (Do nothing)
 

SpasMaster

Hosted Project: SC
Level 23
Joined
Jan 29, 2010
Messages
1,969
You can try to create a custom unit that is invisible (or you can simply set its height to -200 and it selection size to -200 if its possible), set it's food cost to the amount you want and change it's selection size to 0 or 1. Make that unit targeted as tree or something.And create a trigger that looks like this
  • Item cost food
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Picked item)) Equal to Your item
    • Actions
      • Unit - Create 1 Invisible unit for (Triggering player) at (Center of (Playable map area)) facing Default building facing degrees
i am not so sure about the event! :) :thumbs_up:

The bad thing is that the item I am talking about is purchasable from a shop :confused:
 

SpasMaster

Hosted Project: SC
Level 23
Joined
Jan 29, 2010
Messages
1,969
Ok my Trigger is like:
Events:
-A unit owned by Player 1 Red acquires an item
Conditions:
-Triggering unit has item of type (my item) Equal to True
Actions
-If Conditions
(nothing here)
-Then Actions
How to make: Remove last acquired item <--- ??
-Else
Do nothing
 
Level 14
Joined
Aug 8, 2010
Messages
1,022
Create a variable (with your custom name) type of 'item' with array 1. Create a trigger like this
  • Item for food
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Set ItemforFood[1] = (Last created item)
and when you want to remove the item -
  • Item - Remove ItemforFood[1]
Hope i helped. :thumbs_up:
 
Level 14
Joined
Aug 8, 2010
Messages
1,022
I want to thank all of you but triggering is not my strenght. I know it's simple but it just doesn't work. So back to the beginning: Can I make an item cost food?
Hmm... i don't have any ideas than the one with the invisible unit... are you sure you make the trigger right? (you say the triggers are not your strenght...) If you want - you can post your map so we can make it? :) :thumbs_up:
 
Level 18
Joined
Mar 7, 2005
Messages
824
Strange, I can't go to page 2, it always loads page 1 again. So there might be a solution on page 2, but I can't see it. However I'm going to post my ideas here now.

1.
You could create a unit, like already mentioned. Make it invisible (add some empty model to it), or change it to a tree, stone or whatever.
The owner of the Item is also the owner of the created unit. It doesn't need to use food, just that you own the unit and it's there.
You need to create this unit only, if the item will be aquired!
If you lose the item, also remove the Unit from the Game! Next step is to check if you own such a unit.

Trigger: Check if Unit was created
Events:
- Unit acquires an Item (or: buys an item, there's an event that uses sold or bought items from shops)
Conditions:
- Owner of triggering Unit (or: Hero manipulating the Item) owns Unit XY equal to true
Action
- Drop last acquired item (or: use a variable for it, like "drop Item1[0]")
Use If/Then/Else to drop or not drop the Item if the Unit is owned by the triggering Player, or not.
2.
Instead of using a Unit for it, a variable might work, too. It can be integer or boolean.

Integer: set it to 1 and check if the variable is 1 (item already in use) or 0 (no item in inventory)
Boolean: same as above, just with true (equal to 1 for integer) if you have the item, or false, if not.
3.
The triggers from earlier posts don't work, because:
- you pick up the item
- trigger checks, if you own such a item
- trigger came to te result, that you do
- drops item


=> Of course will it drop the item, because you just acquired it and therefore own it, so the trigger makes you loosing this item.
This will work if you create a new item and drop the picked up item. Like aquiring item > drop aquired item > create new item > give it to hero


BUT this won't work, because you create a whole lot of new items. So you have to check it with variables or something to not create a new one, if he owns that item before picking up the new one.

Could be something like this:
Unit aquires Item > Unit drops Item > Trigger checks if unit owns such a item > If yes leave item on the ground > if not pick it up again
Hope this time it'll work for you ;)
 
Level 18
Joined
Mar 7, 2005
Messages
824
I just wrote it out of my head, without looking it up in the WE, but you're right, there is no action like "Drop last acquired item".

Use this: Hero - Drop (Item being manipulated) from (Triggering unit)

Sometimes it's good to read the hints, that WE shows up. Here's your hint:

When responding to "Uses/Acquires/Loses An Item" unit events, this refers to the item being manipulated.
 

SpasMaster

Hosted Project: SC
Level 23
Joined
Jan 29, 2010
Messages
1,969
Yeah, sorry as I said previously: Triggering is not my part :( However will check if it works now.

Edit: Aaaaand, no. Again it doesn't work... I am sure I did everything from step 1 as you said.
Look thanks for all the help but I just saw that this thing is hell. I made the item drop from a mob on my map, so I won't bother myself with it anymore. I am just sooo curious. If you know the map: Castle Fight. There is an item that costs food there O_O.
 
Level 18
Joined
Mar 7, 2005
Messages
824
Just took the time to make the trigger for you, as I read that you're no pro in triggering ;) (me neither, hehe)

I just use a variable instead of the Unit. Create a Variable based on boolean values, I named it Item_in_use. Set this value to "false" at Map Initialization and basicly we need 2 Triggers:

  • Drops Item
    • Events
      • Einheit - A unit drops/loses and Item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Test Item
    • Actions
      • Set Item_in_use = False
  • Acquires Item
    • Events
      • Unit - A unit Acquires an Item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Test Item
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • 'IF'-Conditions
          • Item_in_use Equal to False
        • 'THEN'-Actions
          • Set Item_in_use = True
        • 'ELSE'-Actions
          • Trigger - Turn off Drops Item <gen>
          • Hero - Drop (Item being manipulated) from (Hero manipulating item)
          • Wait 0.01 seconds
          • Trigger - Turn on Drops Item <gen>
The wait function is important, because if the Hero already has that item and drops it, the Drop Item Trigger will run and change the value of our variable, but it's not ment to be changed at that moment, so we have to turn off that trigger to not interupt our process ;)

*edit*
Oh and if you want to use this with multiple Players just add array to the Variable. Like using Item_in_use[1] for Player1 and Item_in_use[2] for Player2 and so on.
 
Status
Not open for further replies.
Top