• 🏆 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!

Item Combination

Status
Not open for further replies.
Level 17
Joined
Mar 21, 2011
Messages
1,597
Hi,
i know.. this is not the first thread about that,
i want to do an item combination system like in dota.
that includes:
-purchase recipes with full inventory.
-if inventory is full, and you buy an item, its dropped on the ground.
theres no system on hive yet that works well, because there is always the same mistake: they replaced item with a powerup, if the hero recieves the powerup, the item transforms to its original item. thats right, but.....if you now drop for example a recipe , it wont switch to a powerup form. if you want to pick it up... "your inventory is full".
so i did a trigger which says:
events: a unit looses an item
conditions:
actions: remove item being manipulated
create 1 powerup_fake at position of hero

next problem: if i sell an item, the trigger triggers also, so every time i sell an item, i get the item again in front of my hero.

i rly need help
TY
 
Level 17
Joined
Mar 21, 2011
Messages
1,597
well... i added that conditon, but it works only sometimes. if i sell the item, sometimes it works.. sometimes not
trigger:
  • Drop
    • Events
      • Unit - A unit looses an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • 'IF'-Conditions
          • (Distance between (Position of (Item being manipulated)) and (Position of (Triggering unit))) smaller than 200.00
        • 'THEN'-Actions
          • For each (Integer A) from 0 to 10, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • 'IF'-Conditions
                  • (Item-type of (Item being manipulated)) equal to item_standard[integer A]
                • 'THEN'-Actions
                  • Item - Remove (Item being manipulated)
                  • Set Point_Item = (Position of (Triggering unit))
                  • Item - Create Item_Powerup[(Integer A)] at Point_Item
                  • Custom script: call RemoveLocation (udg_Point_Item)
                • 'ELSE'-Actions
        • 'ELSE'-Actions
 
Level 11
Joined
Nov 15, 2007
Messages
781
What do you exactly want to achieve by detecting dropped item?

He wants items on the ground to be powerups so that they can be picked up without an empty inventory space, but to become normal items if there's inventory space for them (and if there isn't they'll either be used in a recipe or dropped again). The problem is "Loses an item" applies to sold items as well, so selling an item would create a new dummy item.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
  • Untitled Trigger 001
    • Events
      • Unit - A unit Loses an item
    • Conditions
    • Actions
      • Wait 0.00 seconds
      • Game - Display to (All players) the text: (String((Current life of (Item being manipulated))))
If you drop it, It will give you the item hp (Default 75.000), if you sell it, it will display 0.000. So, you can use Life of Item to know if it was pwned or it was sold.
 
Level 9
Joined
Jun 25, 2009
Messages
427
So it's an awesome thread cause i've been handling the same problem just now :D

I've got the simple solution: (At least if you want the system to be the same as DotA's)

First of all, change your treasure chest with the model i'll upload (has no birth animation). When you export it use this 'link' Objects\InventoryItems\TreasureChest\treasurechest.blp and treasurechest.mdx

Secondly, you must have two triggers:
1.When unit picks up a powerup item. >>Check the recipes do the stuff. Win.
2.When unit BUYS the SAME powerup item. >>Check the recipes do the stuff. Double win.
3.These two sample triggers I use: (Note that if you wish to store consumables into custom values you can just adjust the if/then/else in the item replacement trigger

First trigger of any item drop.


  • Item Drop
    • Events
      • Unit - A unit Loses an item
    • Conditions
    • Actions
      • Item - Set the custom value of (Item being manipulated) to 1
      • Trigger - Turn on Item change into dummies <gen>


The second trigger which this trigger turns on


  • Item change into dummies
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Item - Pick every item in (Playable map area) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Custom value of (Picked item)) Equal to 1
            • Then - Actions
              • For each (Integer Item_Interval_Loop) from 1 to 87, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Item-type of (Picked item)) Equal to Item_Dummies_Normal[Item_Interval_Loop]
                    • Then - Actions
                      • Set Item_Pos = (Position of (Picked item))
                      • Item - Remove (Picked item)
                      • Item - Create Item_Dummies[Item_Interval_Loop] at Item_Pos
                      • Custom script: call RemoveLocation(udg_Item_Pos)
                    • Else - Actions
              • Trigger - Turn off (This trigger)
            • Else - Actions


Now let me explain what are the variables.

For example Item_Dummies[1]=Ancient Rod - 1200 (POWERUP)
Item_Dummie_Normal[1]=Ancient Rod [Recipe] (Permanent)
(1 to 87 loop is because I have 87 items :p)

So if i drop recipe, the loop will remove recipe and place powerup in its place.
Also, you can adjust the names. F.E. you can make ancient rods name in shop to be Ancient Rod-1200 but on ground it can be Ancient Rod [Recipe] thus making a perfect copy of the original when replaced.

Have fun mapping and hopefully it will fix all your problems :D (ofc you'll need work to implement it)

FAST EDIT: Checked and almost forgot to say that if you have two different triggers (buy and pick up) for powerups, be sure to turn off the other one while one of them runs actions and then turn it back on

Tiche3
 

Attachments

  • TreasureChest.rar
    12 KB · Views: 49
Level 20
Joined
Jul 14, 2011
Messages
3,213
That doesn't seem very efficient. You'll have a periodic trigger with a loop through around 100 items every 0.04 seconds.

It's better if you save the ItemType ID of the PowerUp in the ItemTypeID of the Droppped Item, detect Dropped Item, and replace it with the ItemType saved within it's ID.

Use the Custom Value of the Item to set the Owning Player of the item
 
Level 9
Joined
Jun 25, 2009
Messages
427
That doesn't seem very efficient. You'll have a periodic trigger with a loop through around 100 items every 0.04 seconds.

It's better if you save the ItemType ID of the PowerUp in the ItemTypeID of the Droppped Item, detect Dropped Item, and replace it with the ItemType saved within it's ID.

Use the Custom Value of the Item to set the Owning Player of the item

See that's the part where you're wrong ;)

I don't like posting triggers and suggestions unless I do test them out. It took me like +-2hours or so to perfect this system and actually it runs only once, since you can see the Trigger-Turn off (this trigger) at the end of the loop :) It runs once :p and after a 0.04 delay, the item is replaced and since the chest doesn't have the birth animation you CAN'T spot the change :p

Also, as far as I know the trigger action takes about 0.0000012seconds to execute so you can't drop two items in a 0.00000012 interval and even if you did (with triggers) the loop would execute so fast it wouldn't change any game speed :p

You don't want to hear what issues and fun stuff i saw to come up with this :D

Tiche3
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
It's still better to make the system look in a preplaced Hashtable slot for the Item replacement. It reduces by (total items -1) the amount of elements to search through to find the right one.
 
Status
Not open for further replies.
Top