• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Kill detection..

Status
Not open for further replies.
Level 9
Joined
Jul 20, 2009
Messages
427
Does anyone have any idea how to detect kills by a non hero unit..I need these triggers for my map wherein a unit, upon killing a certain number of enemy will be replaced by another unit of its type, only stronger( created via unit replace trigger). I tried making my units hero type so that when it reaches a level it will be replaced but I cannot seem to handle the hero icon appearing at the top left corner( deleting the hero icon from the object editor yields a green one, the ones used by wc3 for missing icons) and also when it dies the message hero has fallen plays.So to make it easier I just used a normal unit..I created a trigger wherein I used real and integer variables, but the problem with my triggers is that it would only work once.FOr example i have 2 footmen, the first one gains 3 kill, my trigger runs and it is replaced with the unit I specified in my trigger but then when another unit of its type in this case footman number 2 kills 3 units the trigger stop working..I guess it is entirely because of my trigger, I'm not so familiar with using variables, so here Iam asking for help..Anyone?
 
Level 6
Joined
Mar 22, 2009
Messages
276
You can hide the hero icon on the top left corner. It is on the hero properties i forgot what it is but its there, i'll try to help you when i got home. coz i dont have my WE here in my lappy :). And on the other problem you got, the answer there is variable array.
I'll edit this post when i got home. good luck
 
Level 9
Joined
Jul 20, 2009
Messages
427
Yixx> thing is i don't know how hashtables works
swipe5weep> looking forward to any help you could give me. One more thing, the units that are to be transformed are initially not on the map. In my map, the villager units can be upgraded into footmen via a unit replace trigger using a custom spell. So basically I want each of these footmen to be transformed into veteran footmen after lets say it killed 5 enemy units then be transformed once again after killing 5 more, this time into elite footmen.
 
Last edited:
Level 6
Joined
Mar 22, 2009
Messages
276
first initialize the variables.
use integer array.
  • var init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set kill_count[1] = 0
      • Set kill_count[2] = 0
next the event that will count the kills made by a unit.
  • kill count
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Killing unit)) Equal to Footman
        • Then - Actions
          • Set kill_count[1] = (kill_count[1] + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • kill_count[1] Greater than or equal to 5
            • Then - Actions
              • Unit - Replace (Killing unit) with a Knight using The old unit's relative life and mana
              • Set kill_count[1] = 0
            • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Killing unit)) Equal to Knight
        • Then - Actions
          • Set kill_count[2] = (kill_count[2] + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • kill_count[2] Greater than or equal to 5
            • Then - Actions
              • Unit - Replace (Killing unit) with a Footman using The old unit's relative life and mana
              • Set kill_count[2] = 0
            • Else - Actions
        • Else - Actions
i just want to give you an idea and here is a short one.
you just need to add more on it to make it usable on your map :grin:
NOTE: its not yet MUI just an idea. :wink:
i think you're a pinoy bka magkasundo tau hehe
 
Level 12
Joined
Jul 27, 2008
Messages
1,181
Create a hashtable named "KillTable", Then recreate this:
  • HASHTABLE
  • Events
    • Unit - A unit Dies
  • Conditions
    • ((Killing unit) is A Hero) Equal to False
  • Actions
    • Hashtable - Save ((Load 0 of (Key (Killing unit)) from (Last created hashtable)) + 1) as 0 of (Key (Killing unit)) in KillTable
Also, in your startup trigger add:

  • Set KillTable = Initialize Hashtable
 
Level 9
Joined
Jul 20, 2009
Messages
427
The map I would be using the trigger on is a melee type map. The triggers were more or less the one I made before,the problem I had with it is that for example I have 2 footmen on the map. Footman 1 has already killed 4 units and Footman 2 has 2 kills,what happens is when Footman 1 killed a total of 5 the replace unit trigger works, but then the kill count would reset to 0, right? So for Footman 2 his killcount would also reset to 0?I wanted the kill detection trig to work for every single unit of any type..Nevertheless I would try if your suggestions would work, thanks to everyone who replied..
 
Level 9
Joined
Jul 20, 2009
Messages
427
EI sweep, your trigger worked and more or less its the same trigger that I made and the same problem occurs.I have 2 footmen, footman 1 kills 4, then when footman 2 kills 1 he is transformed..What I wanted is a kill count trig that detects the kill count for every individual unit not unit type..Any workarounds?
 
Level 9
Joined
Jul 20, 2009
Messages
427
Do what I said (post #6), and get some if/then/elses right after that.

I'm not familiar with hashtables but did you mean, an if then else statement that states if key of killing unit is equal to 5 then unit replace killing unit with unit using the old unit's relative.. something like that for the transformation...?
 
Level 6
Joined
Mar 22, 2009
Messages
276
EI sweep, your trigger worked and more or less its the same trigger that I made and the same problem occurs.I have 2 footmen, footman 1 kills 4, then when footman 2 kills 1 he is transformed..What I wanted is a kill count trig that detects the kill count for every individual unit not unit type..Any workarounds?

like what i've said at my second post its not MUI so that problem will occur.
ill try to get home early so i can make it MUI for you. but for now try it yourself :thumbs_up:
 
Level 11
Joined
May 31, 2008
Messages
698
Custom value never fails when it comes to MUI :)

  • CustomValueInit
    • Events
      • Time - Elapsed game time is 0.50 seconds
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Entire map)) and do (Actions)
        • Loop - Actions
          • Set CustomValueCount = (CustomValueCount + 1)
          • Unit - Set the custom value of (Picked unit) to CustomValueCount
  • SetCustomValue
    • Events
      • Unit - A unit enters (Entire map)
    • Conditions
    • Actions
      • Set CustomValueCount = (CustomValueCount + 1)
      • Unit - Set the custom value of (Entering unit) to CustomValueCount
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CustomValueCount Greater than 2000
        • Then - Actions
          • Set CustomValueCount = 0
        • Else - Actions
  • SetKillz
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set KillCount[(Custom value of (Killing unit))] = (KillCount[(Custom value of (Killing unit))] + 1)
 
Level 6
Joined
Mar 22, 2009
Messages
276
@wolfman i think it will not work fine. because custom value of a unit like footman was share to all units of its type. if you increase the custom value of one footman, the custom value of all of them will increase.
 
Level 11
Joined
May 31, 2008
Messages
698
Ummmm no it wont... How would you know that? I have made many spells that are MUI using custom value. The custom value is attached to each single unit, not a whole group of one unit type. It will work and im pretty sure its the only way to do it without using hashtables.
 
Status
Not open for further replies.
Top