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

Boss Targeting System

Status
Not open for further replies.
Level 6
Joined
Feb 6, 2008
Messages
166
Alright, it's 4am, so I'll keep this concise. It's not 4am anymore. Time to add fluff? I am partially succeeding at solving this. If I do solve the problem, I will go to Triggers and Scripts to ask regarding efficiency.

I've got an array of integers keeping track of kill-death scores. The boss of the arena is ridiculously tank, but only attacks the player with the highest priority.

This is what I have so far:
  • Titan Priority
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • -------- Triggers that update titanPriority go here. --------
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • titanPriority[(Integer A)] Equal to True
            • Then - Actions
              • Player - Make Neutral Extra treat PlayerIndex[(Integer A)] as an Enemy
            • Else - Actions
              • Player - Make Neutral Extra treat PlayerIndex[(Integer A)] as an Ally
I have an integer array named kdScore keeping track of kills and deaths for each player. kdScore[1] through [12] contain the kill scores of players 1 through 12 respectively, and kdScore[13] through [24] contain the death scores of players 1 through 12 respectively.

Key details:
  • The player with the most kills and least deaths has boss targeting priority. Set titanPriority[Player number] = true.
  • If more than one player are tied for most kills and least deaths, they are all enemies in the eyes of the boss.
  • All other players are "safe". Set titanPriority[Player number] = false.
  • Each time someone's hero dies, the triggers update titanPriority for all players, then updates alliance status accordingly.

((Edit: Just in case a mod is here... even though I have part of a trigger there, I believe this thread belongs here in WE Help Zone, because I am asking for help on a piece of the trigger that is missing, not defective. Hopefully, I understand the distinction between the two sections correctly.))
 
Last edited:
Hmm.. I think I understand what you are trying to do. Basically, you need some sort of setup. Each player will have a set of kills and deaths. It is up to you what you want to do in terms of calculating most kills/death, but I'll use that ratio to determine who is priority. (whoever has the highest kill / death ration will have priority) An example to explain the reasoning of this is here:
- Player A has 4 kills and 6 deaths
- Player B has 3 kills and 4 deaths

While Player A has more kills, he has less deaths. But Player B has less kills, and less deaths. If you use the ratio, Player A will have 0.66 (2/3) and Player B will have 0.75 (3/4). Thus, Player B gets priority when being attacked.

Essentially, run a loop and set the values.
  • Priority
    • Events
    • Conditions
    • Actions
      • Set highestRatio = 0.00
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set kill_death_ratio[(Integer A)] = (kdScore[(Integer A)] / kdScore[((Integer A) + 12)])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • kill_death_ratio[(Integer A)] Greater than highestRatio
            • Then - Actions
              • Set highestRatio = kill_death_ratio[(Integer A)]
            • Else - Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • kill_death_ratio[(Integer A)] Equal to highestRatio
            • Then - Actions
              • Player - Make Neutral Extra treat (Player((Integer A))) as an Enemy
            • Else - Actions
              • Player - Make Neutral Extra treat (Player((Integer A))) as an Ally
The first loop will retrieve which ratio is the highest and sets a variable to the ratio of each player. In the second loop, it will check if their ratio is equal to the highest ratio variable retrieved. If so, it will be an enemy. Otherwise it is an ally. Because I use a variable to store the ratios and check, it works for when they have equal ratios as well.

Hopefully that works, because I didn't test it. It should work though.

EDIT: The two variables are:
  • Real array - kill_death_ratio
  • Real - highestRatio
 
Level 6
Joined
Feb 6, 2008
Messages
166
Ah, thanks for the reply. Although not exactly what I was looking for, it gave me an idea of what triggers to set up. Thanks.

Edit: Here is what I ended up using. I normally use only a few comments at most, but I almost couldn't think clearly at all while working on this trigger. Now that it seems to be done, I think anyone else interested deserves a chance to use it.

  • Titan Priority
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • -------- When any hero dies, reset all titanPriority to true. --------
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set titanPriority[(Integer A)] = True
      • -------- Players that don't have top kills are set to titanPriority false. --------
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • -------- Compare the number of kills to that of all other players. --------
          • For each (Integer B) from 1 to 12, do (Actions)
            • Loop - Actions
              • -------- If the player has fewer kills than any player (other than self), set titanPriority for that player to false. --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Integer A) Not equal to (Integer B)
                  • kdScore[(Integer A)] Less than kdScore[(Integer B)]
                • Then - Actions
                  • Set titanPriority[(Integer A)] = False
                • Else - Actions
      • -------- All the remaining titanPriority true players are tied for most kills. --------
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • -------- Only run this section for Player A if Player A is among those tied for most kills. --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • titanPriority[(Integer A)] Equal to True
            • Then - Actions
              • -------- Compare the number of kills to that of all other players. --------
              • For each (Integer B) from 1 to 12, do (Actions)
                • Loop - Actions
                  • -------- Only compare Player A to Player B if Player B is among those tied for most kills. --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • titanPriority[(Integer B)] Equal to True
                    • Then - Actions
                      • -------- If the player has more deaths than any player (other than self) also tied for most kills, set titanPriority for that player to false. --------
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Integer A) Not equal to (Integer B)
                          • kdScore[((Integer A) + 12)] Greater than kdScore[((Integer B) + 12)]
                        • Then - Actions
                          • Set titanPriority[(Integer A)] = False
                        • Else - Actions
                    • Else - Actions
            • Else - Actions
      • -------- After titanPriority is decided for each player, adjust alliance status to each player accordingly. --------
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • titanPriority[(Integer A)] Equal to True
            • Then - Actions
              • Player - Make Neutral Extra treat PlayerIndex[ForLoop_Temp_Integer] as an Enemy
            • Else - Actions
              • Player - Make Neutral Extra treat PlayerIndex[ForLoop_Temp_Integer] as an Ally
I just worry that this isn't as efficient as it could be.
 
Last edited:
Status
Not open for further replies.
Top