• 🏆 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!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

Hero & Unit Levels

Status
Not open for further replies.
{Solved} Hero & Unit Levels

{Solved}

I've got some heros that have certain specific UNIT Levels.
In-game however, when my trigger grabs their unit level, it always comes out to be 1.

Trigger:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • ((Dying unit) is A Hero) Equal to True
    • Then - Actions
      • Set Reputation[TempInt] = (Reputation[TempInt] - (((Level of (Dying unit)) x 10) + ((Hero level of (Dying unit)) x 5)))
      • Game - Display to (All players) the text: (- + ((String((((Level of (Dying unit)) x 10) + ((Hero level of (Dying unit)) x 5)))) + Rep Recieved.))
    • Else - Actions
      • Set Reputation[TempInt] = (Reputation[TempInt] - ((Level of (Dying unit)) x 10))
      • Game - Display to (All players) the text: (- + ((String((10 x (Level of (Dying unit))))) + Rep Recieved.))
In this situation the hero's UNIT Level is 10 and his HERO level is 1 but it comes out to be -15Rep instead of the expected -105Rep.
Is there a way to fix this?
 
Last edited:
Level 20
Joined
Jul 14, 2011
Messages
3,213
1- If the event is "A unit dies" change "Dying unit" for "Triggering Unit" (It's more system efficient)
2- Declare "Triggering Unit" into a variable like "u" and use that variable, instead of using "Dying Unit/Triggering Unit" over and over. (It improves efficiency).

"Hero level of Unit" and "Level of Unit" is nearly the same... And, so far, I don't really get what you want. How does Reputation Works? What's the "TempInt"? Is there any other variable around there?

In the trigger you have, Hero level of Dying Unit, and Level of Dying Unit is the same. afaik. You're not including Reputation in the Game text message. Is Reputation = 0?

This is what you think ->
Reputation = 0
Level of Unit = 10
Hero level of Unit = 1

0 - (10 x 10) + (1 x 5)
0 - (100 + 5)
0 - 105
= -105

This is reality ->
Reputation = 0
Level of Unit = 1
Hero level of Unit = 1

0 - (1 x 10) + (1 x 5)
0 - (1 + 5)
0 - 15
= -15

Happens that Hero Level of Dying Unit and Level of Dying unit is the same value, since it's the same Dying Unit. To achieve you want you have to declare the Hero into a variable, and your other unit into another variable, and check the Level of HeroUnit and lvl of CommonUnit, and use those in the formula.
 
I think your over thinking this alittle.
I gave you all the information you needed, you shouldn't need to know what the trigger is for or what it does. I stated my problem and that is all I wanted help with.

1- If the event is "A unit dies" change "Dying unit" for "Triggering Unit" (It's more system efficient)
2- Declare "Triggering Unit" into a variable like "u" and use that variable, instead of using "Dying Unit/Triggering Unit" over and over. (It improves efficiency).
I'll code things my way, thank you.

"Hero level of Unit" and "Level of Unit" is nearly the same...
No. A unit level is a constant that is the level of well....the unit.
A hero level is a variable that is something heroes get from gaining experience.

And, so far, I don't really get what you want. How does Reputation Works? What's the "TempInt"? Is there any other variable around there?
Why would you need to know that? This is a simple question that should have a simple answer.

In the trigger you have, Hero level of Dying Unit, and Level of Dying Unit is the same. afaik. You're not including Reputation in the Game text message. Is Reputation = 0?
No. The hero's level through gaining of experience is 1, and his unit level is 10. Something I've already said....
Reputation is a variable that is Irrelevant. I did not wish to show the reputation in the message.

This is what you think ->
Reputation = 0
Level of Unit = 10
Hero level of Unit = 1

0 - (10 x 10) + (1 x 5)
0 - (100 + 5)
0 - 105
= -105

This is reality ->
Reputation = 0
Level of Unit = 1
Hero level of Unit = 1

0 - (1 x 10) + (1 x 5)
0 - (1 + 5)
0 - 15
= -15

I already Pointed this out. I've also pointed out that his unit level is 10

Happens that Hero Level of Dying Unit and Level of Dying unit is the same value, since it's the same Dying Unit. To achieve you want you have to declare the Hero into a variable, and your other unit into another variable, and check the Level of HeroUnit and lvl of CommonUnit, and use those in the formula.

If I were to do that then the end result would be exactly the same because the unit i'm trying to get the levels from is exactly the same unit.
So what difference would it make to take one unit and spread it over two variables?


I appreciate you trying to help.

However if it means that much to you:
  • FactionDeath
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Owner of (Dying unit)) controller) Not equal to User
      • ((Owner of (Killing unit)) controller) Equal to User
    • Actions
      • Set TempInt = (Player number of (Owner of (Dying unit)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Dying unit) is A Hero) Equal to True
        • Then - Actions
          • Set Reputation[TempInt] = (Reputation[TempInt] - (((Level of (Dying unit)) x 10) + ((Hero level of (Dying unit)) x 5)))
          • Game - Display to (All players) the text: (- + ((String((((Level of (Dying unit)) x 10) + ((Hero level of (Dying unit)) x 5)))) + Rep Recieved.))
          • Game - Display to (All players) the text: (String((Level of (Dying unit))))
        • Else - Actions
          • Set Reputation[TempInt] = (Reputation[TempInt] - ((Level of (Dying unit)) x 10))
          • Game - Display to (All players) the text: (- + ((String((10 x (Level of (Dying unit))))) + Rep Recieved.))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Reputation[TempInt] Less than -10
        • Then - Actions
          • Player - Make Player 1 (Red) treat (Owner of (Dying unit)) as an Enemy
          • Player - Make Player 2 (Blue) treat (Owner of (Dying unit)) as an Enemy
          • Player - Make (Owner of (Dying unit)) treat Player 1 (Red) as an Enemy
          • Player - Make (Owner of (Dying unit)) treat Player 2 (Blue) as an Enemy
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Reputation[TempInt] Greater than or equal to -10
          • Reputation[TempInt] Less than or equal to 10
        • Then - Actions
          • Player - Make Player 1 (Red) treat (Owner of (Dying unit)) as an Neutral
          • Player - Make Player 2 (Blue) treat (Owner of (Dying unit)) as an Neutral
          • Player - Make (Owner of (Dying unit)) treat Player 1 (Red) as an Neutral
          • Player - Make (Owner of (Dying unit)) treat Player 2 (Blue) as an Neutral
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Reputation[TempInt] Greater than 10
          • Reputation[TempInt] Less than or equal to 70
        • Then - Actions
          • Player - Make Player 1 (Red) treat (Owner of (Dying unit)) as an Ally
          • Player - Make Player 2 (Blue) treat (Owner of (Dying unit)) as an Ally
          • Player - Make (Owner of (Dying unit)) treat Player 1 (Red) as an Ally
          • Player - Make (Owner of (Dying unit)) treat Player 2 (Blue) as an Ally
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Reputation[TempInt] Greater than 70
        • Then - Actions
          • Player - Make Player 1 (Red) treat (Owner of (Dying unit)) as an Ally with shared vision
          • Player - Make Player 2 (Blue) treat (Owner of (Dying unit)) as an Ally with shared vision
          • Player - Make (Owner of (Dying unit)) treat Player 1 (Red) as an Ally with shared vision
          • Player - Make (Owner of (Dying unit)) treat Player 2 (Blue) as an Ally with shared vision
        • Else - Actions
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,233
You can not get the unit level of a hero, only the hero level of a hero.

There is a work around though. Map the unit level to the hero type using a hashtable. You can then recall the unit level from a hero unit by getting the unit type and looking it up in the hashtable.
 
Status
Not open for further replies.
Top