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

[Solved] question about Kill Counter for towers

Level 11
Joined
Nov 13, 2010
Messages
211
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 64
Joined
Aug 10, 2018
Messages
6,583
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 64
Joined
Aug 10, 2018
Messages
6,583
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 11
Joined
Nov 13, 2010
Messages
211
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 64
Joined
Aug 10, 2018
Messages
6,583
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: 1
Last edited:
Top