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

[Trigger] Unit Veterancy System

Status
Not open for further replies.
Level 9
Joined
Apr 23, 2010
Messages
312
I've been working on this unit veterancy system for about a week but it's still a bit buggy. The system doesn't work properly until a unit get to the max rank and is fairly simple. The problem i'm having is that when unit-A gets a kill all units owned by that player (at least i think it's only by that player) get +1 toward their "Rank_Kills[(Custom value of (Killing unit))]".

  • Setup
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Set TempGroup = (Units in (Playable map area))
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Not equal to Player 9 (Gray)
            • Then - Actions
              • Set Unit_v[UnitNum_v] = (Picked unit)
              • Unit - Set the custom value of (Picked unit) to UnitNum_v
              • Set UnitNum_v = (UnitNum_v + 1)
            • Else - Actions
      • Custom script: call DestroyGroup(udg_TempGroup)
  • Created Units
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
      • Set Unit_v[UnitNum_v] = (Last created unit)
      • Unit - Set the custom value of Unit_v[UnitNum_v] to UnitNum_v
      • Set UnitNum_v = (UnitNum_v + 1)
There are 10 ranks in total so this next trigger is kinda long.
  • Record
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Killing unit)) Not equal to Watch Tower
    • Actions
      • Set Rank_Kills[(Custom value of (Killing unit))] = (Rank_Kills[(Custom value of (Killing unit))] + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Rank_Kills[(Custom value of (Killing unit))] Equal to 2
        • Then - Actions
          • Unit - Remove Rank [|cFF4BC428Private|r] dummy #1 from (Killing unit)
          • Unit - Add +1 to (Killing unit)
          • Unit - Add 2% to (Killing unit)
          • Unit - Add Rank [|cFF4BC428Private First Class|r] dummy #2 to (Killing unit)
          • Special Effect - Create a special effect attached to the origin of (Killing unit) using Abilities\Spells\Demon\DarkPortal\DarkPortalTarget.mdl
          • Wait 2.00 game-time seconds
          • Special Effect - Destroy (Last created special effect)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Rank_Kills[(Custom value of (Killing unit))] Equal to 5
            • Then - Actions
              • Unit - Remove Rank [|cFF4BC428Private First Class|r] dummy #2 from (Killing unit)
              • Unit - Remove +1 from (Killing unit)
              • Unit - Remove 2% from (Killing unit)
              • Unit - Add +2 to (Killing unit)
              • Unit - Add 4% to (Killing unit)
              • Unit - Add Rank [|cFF4BC428Corporal|r] dummy #3 to (Killing unit)
              • Special Effect - Create a special effect attached to the origin of (Killing unit) using Abilities\Spells\Demon\DarkPortal\DarkPortalTarget.mdl
              • Wait 2.00 game-time seconds
              • Special Effect - Destroy (Last created special effect)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Rank_Kills[(Custom value of (Killing unit))] Equal to 8
                • Then - Actions
                  • Unit - Remove Rank [|cFF4BC428Corporal|r] dummy #3 from (Killing unit)
                  • Unit - Remove +2 from (Killing unit)
                  • Unit - Remove 4% from (Killing unit)
                  • Unit - Add +3 to (Killing unit)
                  • Unit - Add 6% to (Killing unit)
                  • Unit - Add Rank [|cFF4BC428Sergeant|r] dummy #4 to (Killing unit)
                  • Special Effect - Create a special effect attached to the origin of (Killing unit) using Abilities\Spells\Demon\DarkPortal\DarkPortalTarget.mdl
                  • Wait 2.00 game-time seconds
                  • Special Effect - Destroy (Last created special effect)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Rank_Kills[(Custom value of (Killing unit))] Equal to 11
                    • Then - Actions
                      • Unit - Remove Rank [|cFF4BC428Sergeant|r] dummy #4 from (Killing unit)
                      • Unit - Remove +3 from (Killing unit)
                      • Unit - Remove 6% from (Killing unit)
                      • Unit - Add +4 to (Killing unit)
                      • Unit - Add 8% to (Killing unit)
                      • Unit - Add Rank [|cFF4BC428Sergeant Major|r] dummy #5 to (Killing unit)
                      • Special Effect - Create a special effect attached to the origin of (Killing unit) using Abilities\Spells\Demon\DarkPortal\DarkPortalTarget.mdl
                      • Wait 2.00 game-time seconds
                      • Special Effect - Destroy (Last created special effect)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Rank_Kills[(Custom value of (Killing unit))] Equal to 14
                        • Then - Actions
                          • Unit - Remove Rank [|cFF4BC428Sergeant Major|r] dummy #5 from (Killing unit)
                          • Unit - Remove +4 from (Killing unit)
                          • Unit - Remove 8% from (Killing unit)
                          • Unit - Add +5 to (Killing unit)
                          • Unit - Add 10% to (Killing unit)
                          • Unit - Add Rank [|cFF4BC428Warrent Officer|r] dummy #6 to (Killing unit)
                          • Special Effect - Create a special effect attached to the origin of (Killing unit) using Abilities\Spells\Demon\DarkPortal\DarkPortalTarget.mdl
                          • Wait 2.00 game-time seconds
                          • Special Effect - Destroy (Last created special effect)
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • Rank_Kills[(Custom value of (Killing unit))] Equal to 17
                            • Then - Actions
                              • Unit - Remove Rank [|cFF4BC428Warrent Officer|r] dummy #6 from (Killing unit)
                              • Unit - Remove +5 from (Killing unit)
                              • Unit - Remove 10% from (Killing unit)
                              • Unit - Add +6 to (Killing unit)
                              • Unit - Add 12% to (Killing unit)
                              • Unit - Add Rank [|cFF4BC428Chief Warrent Officer|r] dummy #7 to (Killing unit)
                              • Special Effect - Create a special effect attached to the origin of (Killing unit) using Abilities\Spells\Demon\DarkPortal\DarkPortalTarget.mdl
                              • Wait 2.00 game-time seconds
                              • Special Effect - Destroy (Last created special effect)
                            • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • Rank_Kills[(Custom value of (Killing unit))] Equal to 20
                                • Then - Actions
                                  • Unit - Remove Rank [|cFF4BC428Chief Warrent Officer|r] dummy #7 from (Killing unit)
                                  • Unit - Remove +6 from (Killing unit)
                                  • Unit - Remove 12% from (Killing unit)
                                  • Unit - Add +7 to (Killing unit)
                                  • Unit - Add 14% to (Killing unit)
                                  • Unit - Add Rank [|cFF4BC428Lieutenant|r] dummy #8 to (Killing unit)
                                  • Special Effect - Create a special effect attached to the origin of (Killing unit) using Abilities\Spells\Demon\DarkPortal\DarkPortalTarget.mdl
                                  • Wait 2.00 game-time seconds
                                  • Special Effect - Destroy (Last created special effect)
                                • Else - Actions
                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • If - Conditions
                                      • Rank_Kills[(Custom value of (Killing unit))] Equal to 23
                                    • Then - Actions
                                      • Unit - Remove Rank [|cFF4BC428Lieutenant|r] dummy #8 from (Killing unit)
                                      • Unit - Remove +7 from (Killing unit)
                                      • Unit - Remove 14% from (Killing unit)
                                      • Unit - Add +8 to (Killing unit)
                                      • Unit - Add 16% to (Killing unit)
                                      • Unit - Add Rank [|cFF4BC428Captain|r] dummy #9 to (Killing unit)
                                      • Special Effect - Create a special effect attached to the origin of (Killing unit) using Abilities\Spells\Demon\DarkPortal\DarkPortalTarget.mdl
                                      • Wait 2.00 game-time seconds
                                      • Special Effect - Destroy (Last created special effect)
                                    • Else - Actions
                                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                        • If - Conditions
                                          • Rank_Kills[(Custom value of (Killing unit))] Equal to 26
                                        • Then - Actions
                                          • Unit - Remove Rank [|cFF4BC428Captain|r] dummy #9 from (Killing unit)
                                          • Unit - Remove +8 from (Killing unit)
                                          • Unit - Remove 16% from (Killing unit)
                                          • Unit - Add +9 to (Killing unit)
                                          • Unit - Add 18% to (Killing unit)
                                          • Unit - Add Rank [|cFF4BC428Major|r] dummy #10 to (Killing unit)
                                          • Special Effect - Create a special effect attached to the origin of (Killing unit) using Abilities\Spells\Demon\DarkPortal\DarkPortalTarget.mdl
                                          • Wait 2.00 game-time seconds
                                          • Special Effect - Destroy (Last created special effect)
                                        • Else - Actions
If anyone can help me out here it would be much appreciated and the fixer of this will get +rep and credits.

The map that this system and my "Advanced Alliance System" are going into is nearly complete and will be uploaded once my other map is either accepted or rejected.
 
Level 9
Joined
Apr 23, 2010
Messages
312
If I remove those waits, then the special effect will be useless. I'm using the special effect to show when a unit has ranked up.

For the record trigger, if I set all the abilities to arrays wouldn't I still have to remove/add all the same ones as before?

No, i'm not using "Bribes UnitIndexer".
 
Level 26
Joined
Mar 19, 2008
Messages
3,140
Two first triggers has issues mentioned above. They should be more like:
For what sake you create group and do not use it? Btw you dont this group anyways..
  • Setup
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Hashtable - Create hashtable
      • Set yourHash = (Last created Hashtable)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Not equal to Player 9 (Gray)
            • Then - Actions
              • Hashtable - Save 0 as 0 of (Key of (Picked unit)) in yourHash
            • Else - Actions
  • Created Units
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Hashtable - Save 0 as 0 of (Key of (Triggering unit)) in yourHash
Looking on last one now..

EDIT: You want Special effects have a little break before being destroyed? This is for you.
 
If I remove those waits, then the special effect will be useless. I'm using the special effect to show when a unit has ranked up.

No it wouldn't.
Here:
  • TestSfx
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Special Effect - Create a special effect at (Center of (Playable map area)) using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
      • Special Effect - Destroy (Last created special effect)
For the record trigger, if I set all the abilities to arrays wouldn't I still have to remove/add all the same ones as before?

Yes, but then you don't have continuously use if/then/else/if/then/else/if/then/else...

You'd check if (Rank + 1) mod 3 = 0
and greater than 0 and less than 27

Then, you'd remove the abilities:
- AbilNum[Rank-1]
- AbilPercent[Rank-1]
And you'd add the abilities:
- AbilNum[Rank]
- AbilPercent[Rank]

No, i'm not using "Bribes UnitIndexer"

Trust me. Eventually, the entire GUI community on this site will begin to use it ;)
 
Level 9
Joined
Apr 23, 2010
Messages
312
@Spinnaker, I'm not familiar with using hashtables, I better learn how ;)

@Magtheridon96, i'll try that out real fast. BTW, I am checking to make sure the rank is greater than 0 but why check up to 27? There are 10 ranks so shouldn't it be UnitRank[rank +1] less than or equal to 10? Then i would do the same for UnitRank_Speed and UnitRank_Damage.
 
Level 26
Joined
Mar 19, 2008
Messages
3,140
Trust me. Eventually, the entire GUI community on this site will begin to use it ;)

It is true, and whoever doubts it, will burn.

Third trigger:
  • Record
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Killing unit)) Not equal to Watch Tower
    • Actions
      • Set Rank_Kills = ((Load 0 of (Key of (Killing unit)) from yourHash) +1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Rank_Kills Greater or Equal to 2
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Your_ability) greater than 0))
            • Then
              • Unit - Set of Your_ability for (Killing unit) to ((Rank_Kills + 1) / 3)
            • Else - Actions
              • Unit - Add Your_Ability to (Killing unit)
          • Special Effect - Create a special effect attached to the origin of (Killing unit) using Abilities\Spells\Demon\DarkPortal\DarkPortalTarget.mdl
          • <system actions>
        • Else - Actions
      • Hashtable - Save Rank_Kills as 0 of (Key of (Killing unit)) in yourHash
This shows only 1 ability being added, but no problem to add additional one, I hope you will do it by yourself since it's just copy + paste previous lines about first ability.

EDIT: Btw next time use Trigger tags between such big trigs like yours third one.
 
@Magtheridon96, i'll try that out real fast. BTW, I am checking to make sure the rank is greater than 0 but why check up to 27? There are 10 ranks so shouldn't it be UnitRank[rank +1] less than or equal to 10? Then i would do the same for UnitRank_Speed and UnitRank_Damage.

I only assumed that you should check if it's less than 27 because your third trigger was checking if the final rank is 26 :p
 
Level 9
Joined
Apr 23, 2010
Messages
312
@Magtheridon96, Nah, the Set Rank_Kills[(Custom Value of (Killing Unit))] = Rank_Kills[(Custom Value of (Killing Unit))] was supposed to be keeping track of how many kills the triggering unit has. In a way it did work, but only for all the units and they all shared the same custom value some how.

@Spinnaker, I'm looking all over for how you got the (Key of (Picked Unit)), I can only get it for (Key (Picked Unit)). Does that make a difference or is it the same thing?
 
Level 9
Joined
Apr 23, 2010
Messages
312
Here is the working system, thank you guys so much +rep for you guys!
  • Setup
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set UnitHash = (Last created hashtable)
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Not equal to Player 9 (Gray)
            • Then - Actions
              • Hashtable - Save 0 as 0 of (Key (Picked unit)) in UnitHash
            • Else - Actions
  • Created Units
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Hashtable - Save 0 as 0 of (Key (Last created unit)) in UnitHash
  • Record
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Killing unit)) Not equal to Watch Tower
    • Actions
      • Set Rank_Kills = ((Load 0 of (Key (Killing unit)) from UnitHash) + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Rank_Kills Equal to 2
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Rank dummy #1 for (Killing unit)) Greater than 0
            • Then - Actions
              • Unit - Set level of Rank dummy #1 for (Killing unit) to ((Level of Rank dummy #1 for (Killing unit)) + 1)
              • Unit - Set level of Damage Bonus for (Killing unit) to ((Level of Damage Bonus for (Killing unit)) + 1)
              • Unit - Set level of Speed Bonus for (Killing unit) to ((Level of Speed Bonus for (Killing unit)) + 1)
              • Special Effect - Create a special effect attached to the origin of (Killing unit) using Abilities\Spells\Demon\DarkPortal\DarkPortalTarget.mdl
              • Set Rank_Kills = ((Load 0 of (Key (Killing unit)) from UnitHash) - 1)
            • Else - Actions
              • Unit - Add Rank dummy #1 to (Killing unit)
              • Unit - Add Damage Bonus to (Killing unit)
              • Unit - Add Speed Bonus to (Killing unit)
        • Else - Actions
      • Hashtable - Save Rank_Kills as 0 of (Key (Killing unit)) in UnitHash
Unit - Set "your_ability" for (killing Unit) to ((Rank +1) /3), did nothing so i changes it to Unit - Set "your_ability" for (Killing unit) to ((Level of "your_ability" for (Killing unit)) + 1). It just made more sense to me to do it this way. Setting Rank_Kills = ((Load 0 of (Key (Killing Unit)) from UnitHash) - 1) sets Rank_Kills back to 0 so the unit has to get 2 more kills before it can rank again, doing -2 would make it 3 kills needed.
 
Level 9
Joined
Apr 23, 2010
Messages
312
@mckill2009, that doesn't exactly matter. I'm using Player 9 (Grey) as the AI, but if I didn't want the AI to use the veterancy system, then yes I should put a condition like the one you stated. Now that I look at the full triggers I do realize in the Setup it's not getting the AI units on the map, but that's the easiest fix ill probably get :)
 
Status
Not open for further replies.
Top