• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

How to give items back to a hero?

Status
Not open for further replies.
Level 6
Joined
Sep 27, 2008
Messages
258
How would i give a hero his items back i already know i can save them in a hashtable but i can't see how to give them back to them
 
Assuming you saved them in a hashtable and that the unit is TempUnit and the hashtable is ItemHash:

  • GiveItems
    • Events
    • Conditions
    • Actions
      • Custom script: local integer id = GetHandleId(udg_TempUnit)
      • Custom script: if HaveSavedItemHandle(udg_ItemHash,id,1) then
      • Custom script: call UnitAddItem(udg_TempUnit,LoadItemHandle(udg_ItemHash,id,1))
      • Custom script: endif
      • Custom script: if HaveSavedItemHandle(udg_ItemHash,id,2) then
      • Custom script: call UnitAddItem(udg_TempUnit,LoadItemHandle(udg_ItemHash,id,2))
      • Custom script: endif
      • Custom script: if HaveSavedItemHandle(udg_ItemHash,id,3) then
      • Custom script: call UnitAddItem(udg_TempUnit,LoadItemHandle(udg_ItemHash,id,3))
      • Custom script: endif
      • Custom script: if HaveSavedItemHandle(udg_ItemHash,id,4) then
      • Custom script: call UnitAddItem(udg_TempUnit,LoadItemHandle(udg_ItemHash,id,4))
      • Custom script: endif
      • Custom script: if HaveSavedItemHandle(udg_ItemHash,id,1) then
      • Custom script: call UnitAddItem(udg_TempUnit,LoadItemHandle(udg_ItemHash,id,5))
      • Custom script: endif
      • Custom script: if HaveSavedItemHandle(udg_ItemHash,id,1) then
      • Custom script: call UnitAddItem(udg_TempUnit,LoadItemHandle(udg_ItemHash,id,6))
      • Custom script: endif
 
Level 6
Joined
Sep 27, 2008
Messages
258
so this is all i have so far
  • Koromon Agumon
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Digivolve(Agumon)
    • Actions
      • Set Caster[8] = (Triggering unit)
      • Set Digivolve_Owner[1] = (Owner of Caster[8])
      • Set CasterLoc[6] = (Position of Caster[8])
      • Set HeroLevel_Upgrade[1] = (Level of Caster[8])
      • Hashtable - Save Handle Of(Item carried by Caster[8] in slot 1) as 0 of 1 in Item_Table
      • Hashtable - Save Handle Of(Item carried by Caster[8] in slot 1) as 0 of 2 in Item_Table
      • Hashtable - Save Handle Of(Item carried by Caster[8] in slot 1) as 0 of 3 in Item_Table
      • Hashtable - Save Handle Of(Item carried by Caster[8] in slot 1) as 0 of 4 in Item_Table
      • Hashtable - Save Handle Of(Item carried by Caster[8] in slot 1) as 0 of 5 in Item_Table
      • Hashtable - Save Handle Of(Item carried by Caster[8] in slot 1) as 0 of 6 in Item_Table
      • Unit - Remove Caster[8] from the game
      • Unit - Create 1 Agumon for Digivolve_Owner[1] at CasterLoc[6] facing Default building facing degrees
      • Set Caster[9] = (Last created unit)
      • Hero - Set Caster[9] Hero-level to HeroLevel_Upgrade[1], Hide level-up graphics
and if i add what you put it would be like this?
  • Koromon Agumon
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Digivolve(Agumon)
    • Actions
      • Set Caster[8] = (Triggering unit)
      • Set Digivolve_Owner[1] = (Owner of Caster[8])
      • Set CasterLoc[6] = (Position of Caster[8])
      • Set HeroLevel_Upgrade[1] = (Level of Caster[8])
      • Hashtable - Save Handle Of(Item carried by Caster[8] in slot 1) as 0 of 1 in Item_Table
      • Hashtable - Save Handle Of(Item carried by Caster[8] in slot 1) as 0 of 2 in Item_Table
      • Hashtable - Save Handle Of(Item carried by Caster[8] in slot 1) as 0 of 3 in Item_Table
      • Hashtable - Save Handle Of(Item carried by Caster[8] in slot 1) as 0 of 4 in Item_Table
      • Hashtable - Save Handle Of(Item carried by Caster[8] in slot 1) as 0 of 5 in Item_Table
      • Hashtable - Save Handle Of(Item carried by Caster[8] in slot 1) as 0 of 6 in Item_Table
      • Unit - Remove Caster[8] from the game
      • Unit - Create 1 Agumon for Digivolve_Owner[1] at CasterLoc[6] facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_CasterLoc[6])
      • Set Caster[9] = (Last created unit)
      • Hero - Set Caster[9] Hero-level to HeroLevel_Upgrade[1], Hide level-up graphics
      • Custom script: local integer id = GetHandleId(udg_Caster[8])
      • Custom script: if HaveSavedItemHandle(udg_Item_Table,id,1) then
      • Custom script: call UnitAddItem(udg_Caster[8],LoadItemHandle(udg_Item_Table,id,1))
      • Custom script: endif
      • Custom script: if HaveSavedItemHandle(udg_Item_Table,id,2) then
      • Custom script: call UnitAddItem(udg_Caster[8],LoadItemHandle(udg_Item_Table,id,2))
      • Custom script: endif
      • Custom script: if HaveSavedItemHandle(udg_Item_Table,id,3) then
      • Custom script: call UnitAddItem(udg_Caster[8],LoadItemHandle(udg_ItemTable,id,3))
      • Custom script: endif
      • Custom script: if HaveSavedItemHandle(udg_Item_Table,id,4) then
      • Custom script: call UnitAddItem(udg_Caster[8],LoadItemHandle(udg_Item_Table,id,4))
      • Custom script: endif
      • Custom script: if HaveSavedItemHandle(udg_Item_Table,id,1) then
      • Custom script: call UnitAddItem(udg_Caster[8],LoadItemHandle(udg_Item_Table,id,5))
      • Custom script: endif
      • Custom script: if HaveSavedItemHandle(udg_Item_Table,id,1) then
      • Custom script: call UnitAddItem(udg_Caster[8],LoadItemHandle(udg_Item_Table,id,6))
      • Custom script: endif
 
Oh sorry, I made a huge mistake :p
I'll also fix it to work with your example ;)

One minute. I'll edit this post.

  • Untitled Trigger 002
    • Events
    • Conditions
    • Actions
      • Custom script: call UnitAddItem(udg_Caster[9],LoadItemHandle(udg_ItemTable,1,0)
      • Custom script: call UnitAddItem(udg_Caster[9],LoadItemHandle(udg_ItemTable,2,0)
      • Custom script: call UnitAddItem(udg_Caster[9],LoadItemHandle(udg_ItemTable,3,0)
      • Custom script: call UnitAddItem(udg_Caster[9],LoadItemHandle(udg_ItemTable,4,0)
      • Custom script: call UnitAddItem(udg_Caster[9],LoadItemHandle(udg_ItemTable,5,0)
      • Custom script: call UnitAddItem(udg_Caster[9],LoadItemHandle(udg_ItemTable,6,0)
Just put those under your original trigger :)
And don't forget to change those "Save Handle ... " so that they don't all save the same item ;)
 
Level 6
Joined
Sep 27, 2008
Messages
258
ok thanks

Edit

Ok i keep getting an error
the error says
line 260:expected a name
line 261:expected a name
line 262:expected a name
line 263:expected a name
line 264:expected a name
line 265:expected a name
 
Last edited:
Status
Not open for further replies.
Top