• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Random item abilities

Status
Not open for further replies.

SpasMaster

Hosted Project: SC
Level 24
Joined
Jan 29, 2010
Messages
1,986
Hello guys!

Quick question here,

I was wondering if you could add an ability to an item via triggers...
I saw that there is no such option in the editor, but I decided to ask you if you have any ideas.

Say an item drops (via trigger). Before that I made a list with abilities.
Example: Ability 1 - Attack Speed bonus, Ability 2 - Strength bonus, Ability 3 - Health regen.

So the item drops and a trigger randomly selects one ability from the list and gives it to the item.

Any ideas?
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
  • call SaveInteger(hash, ItemTypeID, 0, 3)
  • call SaveInteger(hash, ItemTypeID, 1, 'asdf')
  • call SaveInteger(hash, ItemTypeID, 2, 'qwer')
  • call SaveInteger(hash, ItemTypeID, 3, 'zxcv')
  • Event
  • Unit acquires an item
  • Actions
  • set int1 = LoadInteger(hash, ItemTypeID, 0)
  • if int1 != 0 then
  • call UnitAddAbility(GetTriggerUnit(), LoadInteger(hash, ItemTypeID, GetRandomInt(1, int1))
  • endif
The first trigger initializes the item type. The first line tells there are 3 possible abilities.
The following lines are the abilities stored for the item type.

The second trigger gives a unit a random ability.
 

SpasMaster

Hosted Project: SC
Level 24
Joined
Jan 29, 2010
Messages
1,986
He is suggesting that you give the ability to the "picking up" unit "on pickup".

Alternately, you can create 3 different items each with an ability, and then when one item will "drop", you can randomly choose one of the 3.

In that way, each time when the unit picks the same item it will generate random ability?

The ability of the item should be generated when it drops, not when its picked up. Thats what I don't know how to do.
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
When it drops, you can set the custom value of it to a random integer between 0 and 2 and choose the ability based on the custom value of the item
 
Level 37
Joined
Mar 6, 2006
Messages
9,243

  • Untitled Trigger 036
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set hash = (Last created hashtable)
      • -------- ---------------------------------------- --------
      • Set ityp = Claws of Attack +15
      • Custom script: set udg_i = udg_ityp
      • Custom script: call SaveInteger(udg_hash, udg_i, 0, 3)
      • Custom script: call SaveInteger(udg_hash, udg_i, 1, 'Amls')
      • Custom script: call SaveInteger(udg_hash, udg_i, 2, 'Aroc')
      • Custom script: call SaveInteger(udg_hash, udg_i, 3, 'Aclf')
      • -------- ---------------------------------------- --------
  • Untitled Trigger 041
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Item - Create Claws of Attack +15 at (Position of Blademaster 0038 <gen>)
      • Custom script: set udg_i = LoadInteger(udg_hash, GetItemTypeId(bj_lastCreatedItem), 0)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • i Not equal to 0
        • Then - Actions
          • Custom script: call SaveInteger(udg_hash, GetHandleId(bj_lastCreatedItem), 0, LoadInteger(udg_hash, GetItemTypeId(bj_lastCreatedItem), GetRandomInt(1, udg_i)))
        • Else - Actions
  • Untitled Trigger 051
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Custom script: set udg_i = LoadInteger(udg_hash, GetHandleId(GetManipulatedItem()), 0)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • i Not equal to 0
        • Then - Actions
          • Game - Display to Player Group - Player 1 (Red) the text: (String(i))
          • Custom script: call UnitAddAbility(GetTriggerUnit(), udg_i)
        • Else - Actions
  • Untitled Trigger 051 Copy
    • Events
      • Unit - A unit Loses an item
    • Conditions
    • Actions
      • Custom script: set udg_i = LoadInteger(udg_hash, GetHandleId(GetManipulatedItem()), 0)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • i Not equal to 0
        • Then - Actions
          • Custom script: call UnitRemoveAbility(GetTriggerUnit(), udg_i)
        • Else - Actions


If you equip two of the same items and unequip the other, you'll lose the ability. It bugs if the ability is not stacking. For example if the item gives you Holy Light. Equip two items, unequip the other. No more Holy Light though you still have an item that grants you Holy Light. That's quite easy to fix, just save the ability id for the unit that gets the item. Use unit handle id as the parent key, ability id as the childkey and store the stack count.
 
Level 17
Joined
Jul 17, 2011
Messages
1,863
well it depends on what ability you need to add to the item. . . you can store an ability when a unit drops and item and then give that ability to another unit who will acquire the item later. i dont know what you are trying to do but there is no way to add an ability to an item via a specific function in gui or jass
 
Status
Not open for further replies.
Top