• 🏆 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] Automatically add droppable items to a unit

Status
Not open for further replies.
Level 8
Joined
Aug 18, 2015
Messages
165
Hey guys!

I'm working on a little project now where one of the main protagonists (a neutral enemy boss unit) actually revives itself at midnight if killed. Like, he revives *every* midnight if he dies. I was able to make it up to that part without a problem.

The thing is, I'd like him to keep looting his items everytime our heroes defeat him (a few custom items from a selection I made, the same as in his first 'life'). I thought I could simply add the item dropping list to his revived self but I can't figure out how. Can anyone tell me how to proceed? Thanks a lot for any piece of advice or clue! :)
 

Attachments

  • Anador.PNG
    Anador.PNG
    1.4 MB · Views: 48
Level 13
Joined
May 10, 2009
Messages
868
The Item Table is basically converted into JASS code when you save your map. Unfortunately, the trigger responsible for dropping an item when a unit/destructible dies is then destroyed upon being executed, which means Blizzard didn't take heroes into account.

You'd be better off making your own trigger for that specific hero.

EDIT: Here's an example.
I used the very same logic Blizzard had used in order to add a new item type to form a list.

upload_2018-12-25_17-28-5.png

  • Item Table Archmage
    • Events
      • Unit - Archmage 0000 <gen> Dies
    • Conditions
    • Actions
      • -------- Reset list --------
      • Custom script: call RandomDistReset()
      • -------- Add a new item type to the list, and you'll also need to specify a "chance amount". --------
      • Set ItemType = Claws of Attack +15
      • Custom script: call RandomDistAddItem(udg_ItemType, 33)
      • -------- Add --------
      • Set ItemType = Crown of Kings +5
      • Custom script: call RandomDistAddItem(udg_ItemType, 33)
      • -------- Add --------
      • Set ItemType = Mask of Death
      • Custom script: call RandomDistAddItem(udg_ItemType, 33)
      • -------- Randomly gets a random item in the list mentioned above, and then create such item at dying unit's position --------
      • Set point = (Position of (Triggering unit))
      • Custom script: set udg_ItemType = RandomDistChoose()
      • Item - Create ItemType at point
      • Custom script: call RemoveLocation(udg_point)
Those custom script functions exist by default, and they are used for the same purpose.

Also, if your map makes use of the Market building, then replace
  • Set point = (Position of (Triggering unit))
  • Custom script: set udg_ItemType = RandomDistChoose()
  • Item - Create ItemType at point
  • Custom script: call RemoveLocation(udg_point)
with
  • Custom script: call UnitDropItem(GetTriggerUnit(), RandomDistChoose())
 

Attachments

  • test.w3x
    16.4 KB · Views: 25
Last edited:
Status
Not open for further replies.
Top