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

adding random abilities to items

Status
Not open for further replies.
Level 8
Joined
Jan 8, 2010
Messages
493
is there an easier way to add random abilities to items other than using custom values?

OBJECTIVE:
an item is to be enchanted 1-4 times. each enchantment will add a random ability out of the set of abilities i have (33 for now). if i create a specific item from possible combinations, that would be a total of 982080 4-enchantment items (for only one type of item)

METHOD SO FAR:
if an item is enchanted, i use custom values of up to 8 digits (00000000) and add it to the item. first enchantment will use the first 2 digits (00000022), second the next 2 (00001122) and so on until sets of 2 digits have numbers other than 00. then when a unit equips that item ("equip" is different from "pick up", i triggered it) i use triggers to check the custom value of the item and add disabled spellbooks with corresponding abilities to the unit. and when the unit unequips the item, those spellbooks are also removed.

so there, i'm sorta wondering if there is another way other than using custom values because i once read somewhere that custom values should as much as possible be avoided. i tried using hashtables but then again, i realized i didn't know much about how to use it, and figured if i save the item and load it, it won't tell me what kind of abilities it supposedly have since it only loaded the item itself.
 
You are using a hard method to control the enhancements. You can use a hashtable and save an increasing integer to the item, everytime it receives the enchant. You can alternatively use a charged item and increase its charges by 1, everytime it receives the supposed enchant.
e.g.
  • Trigger
  • Events
    • Unit - A unit is issued an order targeting an object
  • Conditions
    • (Item-class of (Target item of issued order)) Equal to Charged
  • Actions
    • Custom script: local integer i = 0
    • Item - Set charges remaining in (Target item of issued order) to ((Charges remaining in (Target item of issued order) + 1)
    • Custom script: loop
    • Custom script: exitwhen GetUnitAbilityLevel (GetTriggerUnit(), udg_AbilityList[i]) < 1
    • Custom script: if i < 33 then
    • Custom script: set i = i + GetRandomInt (0, 33)
    • Custom script: else
    • Custom script: set i = i - GetRandomint (0, 33)
    • Custom script: endif
    • Custom script: endloop
    • Custom script: call UnitAddAbility (GetTriggerUnit(), udg_AbilityList[i])
AbilityList is an Ability variable (array enhanced) where you have stored every ability from those 33 ones. This trigger will loop through that list of abilities, randomly check which one you don't have and add it.

I don't have World Editor at the moment to check the trigger, but I guess it will work.
 
Level 8
Joined
Jan 8, 2010
Messages
493
hmm. the way i understood the trigger, is that when a spell (for example) is used for enchanting an item. and the item will have 1 charge for each enchantment? thing is, how will i know which item have which ability? the item is supposed to have the enchantment and add the same ability to any unit it is equipped.

i think the trigger will make a unit enchant the item, then add random abilities to the unit. if the unit unequips the item and another unit picks it up and equips it, another loop will give the next unit another set of abilities.
 
Level 7
Joined
May 18, 2010
Messages
264
why dont u make few variables and track it
when hero aquires the item from 1/4 (1 add fireball)(2 add ...)
add varibale *hero with item* and *what spell* and turn that tracker trigger off
if som1 else can carry item you can easy find what item got what spell
But it requires alot of work and tweeking
Just dump the idea...
 
Level 8
Joined
Jan 8, 2010
Messages
493
i was also thinking of using variables, but yes, it's a lot of work, and i also have no idea how to add a variable to an item (other than setting an item to a variable, they're different.. right?) XD
so i guess i'll continue with using custom values for a while until i figured out another way or understood hashtables more (something about what Pharaoh_ said about increasing integers)
 
Status
Not open for further replies.
Top