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

[Trigger] Duplicate item created when passing charges to another item type.

Status
Not open for further replies.
Level 4
Joined
Jun 22, 2016
Messages
71
I don't understand what is happening with this code. The functionality is to get the number of remaining charges from the dropped holdable item version and then removed. Then it creates a rune item version in its place with the charges passed on to it.

So far it's creating a new item in a nearby point that isn't the place I dropped it and a duplicate were I picked it up.

Also I'm doing my best to avoid memory leaks.

Any help would be appreciated.

  • Blood Vial Drop
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Blood Vial
    • Actions
      • -------- Dropping the Purchase version and giving the charges to the Powerup version. --------
      • Set tempItem = (Item being manipulated)
      • Set tempInteger = (Charges remaining in tempItem)
      • Set tempPoint = (Position of tempItem)
      • Item - Remove tempItem
      • Item - Create Blood Vial at tempPoint
      • Set tempItem = (Last created item)
      • Item - Set charges remaining in tempItem to tempInteger
      • Custom script: call RemoveLocation(udg_tempPoint)
 
It's an issue with the UNIT_DROP_ITEM event that is used.

When the code runs, the item is not really dropped yet. It's only about to be dropped.
This is probably, so you can still check like for example the respective inventory slot where the item is, and so on.

Set tempPoint = (Position of tempItem)
will return something like the previous item position (in general, not specified for the item), that is here probably the position where the unit picked up the last item.

After a minimal of timeout, in GUI 0-wait action, in JASS 0-timer timeout, the item is properly dropped.
As alternative, what is probably just a better solution here, is to create the new item just directly at the position of "(TriggeringUnit)".

Also I'm doing my best to avoid memory leaks.
Correctly.

Funny side note; don't try to give an item that is being dropped to an other unit under this event.;)
 
Status
Not open for further replies.
Top