• 🏆 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] how to call a units mana regeneration?

Status
Not open for further replies.
Level 9
Joined
Jan 14, 2008
Messages
366
i want a specific units mana regeneration (including boni) to be displayed via game message.

similar to the "-ms" command in dota, wich displays the triggering player heros movement speed.

the problem is you are not simply able to call on the specific units mana regeneration rate (wich is obviously a real value).

so how can this be done? can it be done? im sure it can be done...
probably requires jass...

if it can only be done with jass, please could someone give me a custom script that performs said action? and explain it so i can use it with 0 jass knowledge?

wud be awsum
 
You could do something like this, allthough it would be very faulty. If you were to cast a spell during that 1 second, it would display the wrong number, or if you are using an ability that drains mana it would be wrong... But it's the best I could think of:
  • ManaRegenSet
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Set MRegenBefore = (Mana of "YourUnit")
      • Wait 1.00 seconds
      • Set MRegenAfter = (Mana of "YourUnit")
      • Set MRegen = (MRegenAfter - MRegenBefore)
  • ManaRegenDisplayP1
    • Events
      • Player - Player 1 (Red) types a chat message containing -mr as An exact match
    • Conditions
    • Actions
      • Game - Display to Player Group - Player 1 (Red) the text: (Your unit regenerates + ((String(MRegen)) + mana per second.))
(Just do more of these, 1 for each player.

Variables:
(Name, Type.)
MRegen, Real.
MRegenBefore, Real.
MRegenAfter, Real.
 
Level 12
Joined
Feb 13, 2009
Messages
386
Also this means that you should have some spent mana, because obviously if your mana is full it does nothing. And also it fails if you get the full mana in this 1 second. There should be some different way.

Justify's way should work if you know how to call unit's base mana, then you should count all mana+ skills, buffs and intelligence with +manareg per 1 int bonus, and you're set.
 
What you could do, is when they type the message, save the unit's current mana in a variable, wait one seconds, set variable manregen = current mana, set unit's mana back to the mana variable+manaregen, display message. Only problem is it takes a second to get results and the unit will have no mana for 1 second.

Edit:

I've refined my method of doing it - it now takes only 0.01 seconds and is completely accurate. It is also completely MPI and leakfree (I think, I'm not great at leak checking GUI). The only thing that could go wrong is if the unit has more mana regeneration than its maximum mana, when it will say the mana regeneration rate is equal to its maximum mana. It takes 3 triggers - initialization, the trigger which detects the chat message and starts the timer, and the trigger which gets the mana regeneration rate and displays it to the player who typed the message. Enjoy!

  • init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Units[1] = <Player 1's Unit>
      • Set Units[2] = <Player 2's Unit>
      • Set Units[3] = <Player 3's Unit>
      • Set Units[4] = <Player 4's Unit>
      • Set Units[5] = <Player 5's Unit>
      • Set Units[6] = <Player 6's Unit>
      • Set Units[7] = <Player 7's Unit>
      • Set Units[8] = <Player 8's Unit>
      • Set Units[9] = <Player 9's Unit>
      • Set Units[10] = <Player 10's Unit>
      • Set Units[11] = <Player 11's Unit>
      • Set Units[12] = <Player 12's Unit>
  • manregen1
    • Events
      • Player - Player 1 (Red) types a chat message containing -mr as An exact match
      • Player - Player 2 (Blue) types a chat message containing -mr as An exact match
      • Player - Player 3 (Teal) types a chat message containing -mr as An exact match
      • Player - Player 4 (Purple) types a chat message containing -mr as An exact match
      • Player - Player 5 (Yellow) types a chat message containing -mr as An exact match
      • Player - Player 6 (Orange) types a chat message containing -mr as An exact match
      • Player - Player 7 (Green) types a chat message containing -mr as An exact match
      • Player - Player 8 (Pink) types a chat message containing -mr as An exact match
      • Player - Player 9 (Gray) types a chat message containing -mr as An exact match
      • Player - Player 10 (Light Blue) types a chat message containing -mr as An exact match
      • Player - Player 11 (Dark Green) types a chat message containing -mr as An exact match
      • Player - Player 12 (Brown) types a chat message containing -mr as An exact match
    • Conditions
    • Actions
      • Set mana[(Player number of (Triggering player))] = (Mana of Units[(Player number of (Triggering player))])
      • Unit - Set mana of Units[(Player number of (Triggering player))] to 0.00
      • Countdown Timer - Start ManaTimers[(Player number of (Triggering player))] as a One-shot timer that will expire in 0.01 seconds
  • manaregen2
    • Events
      • Time - ManaTimers[1] expires
      • Time - ManaTimers[2] expires
      • Time - ManaTimers[3] expires
      • Time - ManaTimers[4] expires
      • Time - ManaTimers[5] expires
      • Time - ManaTimers[6] expires
      • Time - ManaTimers[7] expires
      • Time - ManaTimers[8] expires
      • Time - ManaTimers[9] expires
      • Time - ManaTimers[10] expires
      • Time - ManaTimers[11] expires
      • Time - ManaTimers[12] expires
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set temp_playergroup = (Player group((Player((Integer A)))))
          • Custom script: set udg_temp_bool = GetExpiredTimer() == udg_ManaTimers[bj_forLoopAIndex]
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • temp_bool Equal to True
            • Then - Actions
              • Set manaregen = ((Mana of Units[(Integer A)]) x 100.00)
              • Unit - Set mana of Units[(Integer A)] to mana[(Integer A)]
              • Game - Display to temp_playergroup the text: (Your mana regeneration rate is + ((String(manaregen)) + .))
              • Custom script: call DestroyForce(udg_temp_playergroup)
              • Custom script: exitwhen true
            • Else - Actions
If you can't get it to work, PM me and I'll send you my test map.
 
Last edited:
Level 9
Joined
May 30, 2008
Messages
430
What you could do, is when they type the message, save the unit's current mana in a variable, wait one seconds, set variable manregen = current mana, set unit's mana back to the mana variable+manaregen, display message. Only problem is it takes a second to get results and the unit will have no mana for 1 second.

Edit:

I've refined my method of doing it - it now takes only 0.01 seconds and is completely accurate. It is also completely MPI and leakfree (I think, I'm not great at leak checking GUI). The only thing that could go wrong is if the unit has more mana regeneration than its maximum mana, when it will say the mana regeneration rate is equal to its maximum mana. It takes 3 triggers - initialization, the trigger which detects the chat message and starts the timer, and the trigger which gets the mana regeneration rate and displays it to the player who typed the message. Enjoy!

  • init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Units[1] = <Player 1's Unit>
      • Set Units[2] = <Player 2's Unit>
      • Set Units[3] = <Player 3's Unit>
      • Set Units[4] = <Player 4's Unit>
      • Set Units[5] = <Player 5's Unit>
      • Set Units[6] = <Player 6's Unit>
      • Set Units[7] = <Player 7's Unit>
      • Set Units[8] = <Player 8's Unit>
      • Set Units[9] = <Player 9's Unit>
      • Set Units[10] = <Player 10's Unit>
      • Set Units[11] = <Player 11's Unit>
      • Set Units[12] = <Player 12's Unit>
  • manregen1
    • Events
      • Player - Player 1 (Red) types a chat message containing -mr as An exact match
      • Player - Player 2 (Blue) types a chat message containing -mr as An exact match
      • Player - Player 3 (Teal) types a chat message containing -mr as An exact match
      • Player - Player 4 (Purple) types a chat message containing -mr as An exact match
      • Player - Player 5 (Yellow) types a chat message containing -mr as An exact match
      • Player - Player 6 (Orange) types a chat message containing -mr as An exact match
      • Player - Player 7 (Green) types a chat message containing -mr as An exact match
      • Player - Player 8 (Pink) types a chat message containing -mr as An exact match
      • Player - Player 9 (Gray) types a chat message containing -mr as An exact match
      • Player - Player 10 (Light Blue) types a chat message containing -mr as An exact match
      • Player - Player 11 (Dark Green) types a chat message containing -mr as An exact match
      • Player - Player 12 (Brown) types a chat message containing -mr as An exact match
    • Conditions
    • Actions
      • Set mana[(Player number of (Triggering player))] = (Mana of Units[(Player number of (Triggering player))])
      • Unit - Set mana of Units[(Player number of (Triggering player))] to 0.00
      • Countdown Timer - Start ManaTimers[(Player number of (Triggering player))] as a One-shot timer that will expire in 0.01 seconds
  • manaregen2
    • Events
      • Time - ManaTimers[1] expires
      • Time - ManaTimers[2] expires
      • Time - ManaTimers[3] expires
      • Time - ManaTimers[4] expires
      • Time - ManaTimers[5] expires
      • Time - ManaTimers[6] expires
      • Time - ManaTimers[7] expires
      • Time - ManaTimers[8] expires
      • Time - ManaTimers[9] expires
      • Time - ManaTimers[10] expires
      • Time - ManaTimers[11] expires
      • Time - ManaTimers[12] expires
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set temp_playergroup = (Player group((Player((Integer A)))))
          • Custom script: set udg_temp_bool = GetExpiredTimer() == udg_ManaTimers[bj_forLoopAIndex]
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • temp_bool Equal to True
            • Then - Actions
              • Set manaregen = ((Mana of Units[(Integer A)]) x 100.00)
              • Unit - Set mana of Units[(Integer A)] to mana[(Integer A)]
              • Game - Display to temp_playergroup the text: (Your mana regeneration rate is + ((String(manaregen)) + .))
              • Custom script: call DestroyForce(udg_temp_playergroup)
              • Custom script: exitwhen true
            • Else - Actions
If you can't get it to work, PM me and I'll send you my test map.



that was already sugested. Please read the posts above and the upper variant is better than yours
 
Status
Not open for further replies.
Top