• 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.

[Trigger] Help!!!! with units to gain xp

Status
Not open for further replies.
Level 2
Joined
Feb 6, 2012
Messages
14
Hi there.. i am working on a college project..on warcraft editor...
I am in need of help...with making my units gain xp every time they kill an opponent unit.. Is that possible... I am aware that in warcraft only hero's gain xp..but is there anyway i can make a group of unit gain experience points?
 
Level 2
Joined
Feb 6, 2012
Messages
14
Try using Bribe's UnitIndexer (GUI)

Then, you can use an integer array to store unit experience :)

  • GiveXP
    • Events
      • Unit - A unit dies
    • Conditions
    • Actions
      • Set TempInt = (Custom value of (Killing unit))
      • Set XP[TempInt] = (XP[TempInt] + ___)

i really have no clue how that would work on my map.. i am really new to this..this is my 3rd day of using the editor..i checked the unit indexer test map..but i couldn't make any sense out of it.. i am attaching my map here.. of some tires and test that i have been doing on this test build...i would really appreciate if you could help...thanks in advance :)

http://www.4shared.com/folder/RiI4VKWj/_online.html
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Lets see.. ¿What's the effect of experience on these units?... If it has no effect do:

1- Set an amount of exp for every creep.
2- Create a Hashtable and create a variable to handle that hash (Set ExpHash = last created hashtable. Name doesn't really matter)
2- When the creep dies, pick every unit in about 500~800 range and give these units the CreepExp divided by the amount of units which belongs to allies of the Killing Unit. (That way each unit gets exp. We assume the range as they helped)
3- ¿How to give the exp?
3.1 - Create an integer variable = i
3.2 - Inside the "Pick every unit" loop do
  • Custom script: set udg_i = GetHandleId(GetEnumUnit())
3.3 Save the amount of exp (CreepExp / #Units in range) as 0 of i in ExpHash

That way the trigger will store the amount of exp inside each unit Unit ID (Which is unique per unit). You can use another trigger to clean the Unit ID data from the hashtable, and also handle the other leaks (Unit Group, Points, etc.)

A Unit Dies
->
  • Custom script: Set i = GetHandleId(GetTriggerUnit())
->Clear all child data of i in ExpHash
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
Lets see.. ¿What's the effect of experience on these units?... If it has no effect do:

1- Set an amount of exp for every creep.
2- Create a Hashtable and create a variable to handle that hash (Set ExpHash = last created hashtable. Name doesn't really matter)
2- When the creep dies, pick every unit in about 500~800 range and give these units the CreepExp divided by the amount of units which belongs to allies of the Killing Unit. (That way each unit gets exp. We assume the range as they helped)
3- ¿How to give the exp?
3.1 - Create an integer variable = i
3.2 - Inside the "Pick every unit" loop do
  • Custom script: set udg_i = GetHandleId(GetEnumUnit())
3.3 Save the amount of exp (CreepExp / #Units in range) as 0 of i in ExpHash

That way the trigger will store the amount of exp inside each unit Unit ID (Which is unique per unit). You can use another trigger to clean the Unit ID data from the hashtable, and also handle the other leaks (Unit Group, Points, etc.)

A Unit Dies
->
  • Custom script: Set i = GetHandleId(GetTriggerUnit())
->Clear all child data of i in ExpHash

You should NEVER use i as a global. udg_i included
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
i, same as ExpHash, same as CreepExp, same as range pick, same as the whole method, is just an example... But good to make it clear.
 
Status
Not open for further replies.
Top