HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Item limits & Shops

08-04-2003, 12:55 PM#1
Telperion01
In my map a hero can only have one of various types of items, and I have a trigger set up to drop duplicates with a message that you can't carry extras (carried items are represented in the unit's custom value by an integer of base 2). Now, I need to set up a catch that checks if the item is being sold, and if so refund the gold cost of the item and remove it from play. The problem is, when I add a seperate trigger with the UnitSellsItem event, it's still dropped via the AquiresItem trigger. I tried checking if the "selling unit" value was null in the AquiresItem trigger, but apparently that value is only set in triggers with a registered event of UnitSellsItem (adding that to the event list didn't help either). Anyone know how I can intercept an aquire order, and if it's sold do different actions? Here's my trigger as it stands:

Code:
[size=2]Aquire Shield
Events
   Unit - A unit Acquires an item
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
   If - Conditions
      Or - Any (Conditions) are true
         Conditions
            (Item-type of (Item being manipulated)) Equal to Shield
            (Item-type of (Item being manipulated)) Equal to Iron Shield
            (Item-type of (Item being manipulated)) Equal to Steel Shield
            (Item-type of (Item being manipulated)) Equal to Mithril Shield
   Then - Actions
      If (All Conditions are True) then do (Then Actions) else do (Else Actions)
         If - Conditions
            ((Custom value of (Hero manipulating item)) mod 2) Equal to 1
         Then - Actions
            Set temp_String = |cffffcc00Cannot carry more than one shield.|r
            Set temp_Player = (Owner of (Hero manipulating item))
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                If - Conditions
                   (Selling unit) Equal to No unit
                Then - Actions
                   -------- If it wasn't sold, drop the item --------
                   Trigger - Turn off Drop Shield <gen>
                   Hero - Drop (Item being manipulated) from (Hero manipulating item)
                   Trigger - Turn on Drop Shield <gen>
                   Sound - Play HeroDropItem1 <gen>
                   If (b_Knows_Shield[(Player number of (Owner of (Hero manipulating item)))] Equal to False) then do
                     (Custom script:   call DisplayTextToPlayer( udg_temp_Player, 0, 0, udg_temp_String )) else do (Do nothing)
                Else - Actions
                   -------- Refund the gold cost and remove item --------
                   Custom script:   call DisplayTextToPlayer( udg_temp_Player, 0, 0, udg_temp_String )
                   Player - Add (Integer((Life of (Item manipulated)))) to (Owner of (Hero manipulating item)) Current gold
                   Item - Remove (Item being manipulated)
             Set b_Knows_Shield[(Player number of (Owner of (Hero manipulating item)))] = True
         Else - Actions
             Unit - Set the custom value of (Hero manipulating item) to ((Custom value of (Hero manipulating item)) + 1)
      Else - Actions[/size]

Code:
Drop Shield
Events
    Unit - A unit Loses an item
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
   If - Conditions
      Or - Any (Conditions) are true
         Conditions
            (Item-type of (Item being manipulated)) Equal to Shield
            (Item-type of (Item being manipulated)) Equal to Iron Shield
            (Item-type of (Item being manipulated)) Equal to Steel Shield
            (Item-type of (Item being manipulated)) Equal to Mithril Shield
   Then - Actions
      Unit - Set the custom value of (Hero manipulating item) to ((Custom value of (Hero manipulating item)) - 1)
   Else - Actions
... other checks ...
08-05-2003, 02:51 AM#2
Telperion01
Anyone? I mostly just need a way to distinguish if an item is picked up, vs bought from a shop.
08-05-2003, 09:29 AM#3
Krakou
Maybe you could add a test in your trigger, check if player's gold lowers, this would tell you that he bought the item.