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

[Solved] question about Kill Counter for towers

Status
Not open for further replies.
Level 12
Joined
Nov 13, 2010
Messages
277
hey hive
i have been trying to make a Kill Counter for towers
i have not work with how edit tooltip with triggers before i did try with this but ofc is not working i can use some help
  • Kill Counter
    • Events
      • Unit - A unit owned by Player 24 (Peanut) Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Killing unit)) controller) Equal to User
        • Then - Actions
          • Ability - Set Ability: (Unit: (Killing unit)'s Ability with Ability Code: |cffff0000Kill Counter|r )'s String Level Field: Tooltip - Normal - Extended ('aub1') of Level: 0 to (String((0.00 + 1.00)))
        • Else - Actions
the tooltip-normal-extended says : Has done 0 kills. so i need it to update the 0 to a new number when the tower kills a mob
 
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Currently you're setting the string to 1.00 every single time.

You need to introduce a variable that keeps track of the total number of kills:
  • Kill Counter
    • Events
      • Unit - A unit owned by Player 24 (Peanut) Dies
    • Conditions
      • (Killing unit) Not equal to No unit
      • ((Owner of (Killing unit)) controller) Equal to User
    • Actions
      • Set Variable Kill_CV = (Custom value of (Killing unit))
      • Set Variable Kill_Counter[Kill_CV] = (Kill_Counter[Kill_CV] + 1)
      • Set Variable Kill_String = (Total number of unit's killed: + (Integer(Kill_Counter[Kill_CV]))
      • Ability - Set Ability: (Unit: (Killing unit)'s Ability with Ability Code: |cffff0000Kill Counter|r )'s String Level Field: Tooltip - Normal - Extended ('aub1') of Level: 0 to Kill_String
This uses Unit Indexing, which solves most GUI problems in regards to making something MUI.

If the ability string still doesn't update then the function may be broken, a lot of the new natives don't work properly. Also, you maybe you need to refresh the ability (increase level, decrease level) for the changes to take effect.
 
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
it seams it only work with increase level to bad then you cant get more then 100 kills on it
No, you just increase the level then decrease it. It'll always remain at level 1.
  • Ability - Set Ability: (Unit: (Killing unit)'s Ability with Ability Code: |cffff0000Kill Counter|r )'s String Level Field: Tooltip - Normal - Extended ('aub1') of Level: 0 to Kill_String
  • Unit - Increase level of Ability for (Killing unit)
  • Unit - Decrease level of Ability for (Killing unit)
I'm pretty sure it can stay at Level 1 in the Object Editor, but if not try giving it 2 levels.
 
Last edited:
Level 12
Joined
Nov 13, 2010
Messages
277
did some tests and i only can get it to work like this
  • Kill Counter
    • Events
      • Unit - A unit owned by Player 24 (Peanut) Dies
    • Conditions
    • Actions
      • Unit - Increase level of |cffff0000Kill Counter|r for (Killing unit)
northing els works
i did try a lot of deffent thinks with with trigger but dont work
  • Kill Counter
    • Events
      • Unit - A unit owned by Player 24 (Peanut) Dies
    • Conditions
      • (Killing unit) Equal to No unit
      • ((Owner of (Killing unit)) controller) Equal to User
    • Actions
      • Set VariableSet Kill_Counter[(Player number of (Owner of (Killing unit)))] = (Kill_Counter[(Player number of (Owner of (Killing unit)))] + 1)
      • Set VariableSet Kill_Counter[Kill_CV] = (Kill_Counter[Kill_CV] + 1)
      • Set VariableSet Kill_String = (Total Number of units killed: + (String(Kill_Counter[Kill_CV])))
      • Ability - Set Ability: (Unit: (Killing unit)'s Ability with Ability Code: |cffff0000Kill Counter|r )'s String Level Field: Tooltip - Normal - Extended ('aub1') of Level: 1 to Kill_String
      • Unit - Increase level of |cffff0000Kill Counter|r for (Killing unit)
      • Unit - Decrease level of |cffff0000Kill Counter|r for (Killing unit)
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
An alternative to using the broken Set Ability Field action:
  • Kill Counter
    • Events
      • Unit - A unit owned by Player 24 (Peanut) Dies
    • Conditions
      • (Killing unit) Not equal to No unit
      • ((Owner of (Killing unit)) controller) Equal to User
    • Actions
      • Set VariableSet Kill_CV = (Custom value of (Killing unit))
      • Set VariableSet Kill_Counter[Kill_CV] = (Kill_Counter[Kill_CV] + 1)
      • Set VariableSet Kill_String = (Total Number of units killed: + (String(Kill_Counter[Kill_CV])))
      • Custom script: if GetLocalPlayer() == GetOwningPlayer(GetKillingUnit()) then
      • Custom script: call BlzSetAbilityTooltip('A00G', udg_Kill_String, 0)
      • Custom script: endif
Replace A00G with the rawcode of your ability.

But this updates it globally for that player, so you'll probably want to manage it with unit selection events.

Edit: Attached an example map. Requires a Unit Indexer (has a crappy workaround in the demo).
 

Attachments

  • Kill Counter Tooltip 1.w3m
    19.5 KB · Views: 6
Last edited:
Status
Not open for further replies.
Top