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

[General] Item effect stays after removing it!

Status
Not open for further replies.
Level 12
Joined
Jan 13, 2008
Messages
559
  • Axe of Destruction
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to Axe of Destruction
      • ((Unit-type of (Buying unit)) is A Hero) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Buying unit) has an item of type Power Claws) Equal to True
          • ((Buying unit) has an item of type Iron Sword) Equal to True
        • Then - Actions
          • Item - Remove (Item carried by (Buying unit) of type Iron Sword)
          • Item - Remove (Item carried by (Buying unit) of type Power Claws)
          • Special Effect - Create a special effect at (Position of (Buying unit)) using Abilities\Spells\Demon\DarkPortal\DarkPortalTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Skip remaining actions
        • Else - Actions
          • Item - Remove (Item being manipulated)
          • Item - Remove (Sold Item)
          • Player - Add 4000 to (Owner of (Buying unit)) Current gold
          • Game - Display to (Player group((Owner of (Buying unit)))) for 1.00 seconds the text: You are missing an ...
          • Skip remaining actions
The item gets removed from the heroes' inventory but the item abilities stay...how can I resolve this problem?

/e: i solved it by adding a wait - 0.03 seconds before removing it (which can lead to problems if 2 players buy smthg at the same time tho)
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
Instead of using waits, which is not that good, especially in multiplayer, use timers with 0.00 seconds.
Paste
JASS:
function Trig_BuyItem_RemoveItem takes nothing returns nothing
    call RemoveItem( udg_RemovingItem )
endfunction
to your map header and use
  • BuyItem2
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
    • Actions
      • Set RemovingItem = (Sold Item)
      • Custom script: call TimerStart(udg_RemovingTimer, 0.00, false, function Trig_BuyItem_RemoveItem)
to remove the bought item immediatly.

Variables:
- Item RemovingItem
- Timer RemovingTimer
 
Status
Not open for further replies.
Top