• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Custom Mana Regeneration

Status
Not open for further replies.
Level 11
Joined
Aug 11, 2009
Messages
605
I want to make a triggered mana regeneration for my Heroes but here is my issue:

Event - Every 1 sec of the game.

Action - Set mana of HERO to (0.25 + 0.02x Intelligence of HERO)

Obviously not all triggers are there, but that is not the issue, the issue is when the mana gained each sec is less than 1, the Hero never regenerates mana. In addition, only whole numbers like 1, 2, 3 etc counts towards the mana regeneration, not the numbers after the . like 1.25 only gives 1 mana per sec.

So my question is:

Is there an easy way to fix this or do i need timers or something? If so, could someone help me create the necessary triggers?


P.S.
The reason why I want triggered mana regeneration is because some Heroes use the formula above to regenerate mana, some Heroes regenerate (3 + 0.05x Intelligence) per sec and some Heroes have no mana regeneration but have some spells that generates mana and some that consumes.

Would be very grateful fr some help, +rep ofc!
 
Level 17
Joined
Jul 17, 2011
Messages
1,863
you cant tell if 1.25 regens mana but it does its not possible to see because mana is not in decimals anyways this is simple just make a periodic trigger that runs every 1 second(mana per second) and preset the mana amount into a variable so its easier to configure then set your unit's mana to mana + the amount in the variable
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
As you can see from this test, the Mana Regen of Blood Mage raised from 1 to 3 (+1.5 MP Regen/second).
Which means, it does accept Real values.

0 + 1.5 = 1.5 (Show 1)
1.5 + 1.5 = 3.0 (Show 3)

You just can't see Real values inside the UI, but the fact that it is in Real.
 

Attachments

  • Mana Regen Test.w3x
    12.3 KB · Views: 94
Level 11
Joined
Aug 11, 2009
Messages
605
Yeah, but if the total value is below 1, the Hero wont regenerate any mana at all. For example if the total mana regen is 0.5/sec, then it should restore 1 mana every 2 sec, but the Hero never gets any mana.

Anyway, I solved it, maybe in a inefficient way. I made a variable with array for every player and through a loop I added the mana value every 0.1 sec. And each time it added new numbers to the variable I made a check if the value of the variable is 1 or more. If it is then the Hero gains 1 mana and the variable is reduced in value by 1.

It is working as intended but if someone knows a better way you are welcome to share :)

Thanks for your help gorillabull and defskull :)
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Yeah, but if the total value is below 1, the Hero wont regenerate any mana at all. For example if the total mana regen is 0.5/sec, then it should restore 1 mana every 2 sec, but the Hero never gets any mana.
Have you tested the test map, carefully ?
Try change the 1.50 to 0.50, and you will notice the Blood Mage will gain 1 MP per 2 second (because 0.50 MP per 1 second).

Okay, so the test map download is 0 at the moment, no wonder you're throwing theories ;p
 
I have no problems in setting mana regen to below 1 when using the JASS natives... I mean they still regenerate correctly...

btw, I think you have a wrong action peacehagen:

  • Action - Set mana of HERO to (0.25 + 0.02x Intelligence of HERO)
no wonder you don't regen, because you're setting mana to the same value over and over again...
 
Level 11
Joined
Aug 11, 2009
Messages
605
It may be the action, didnt test the map because it didnt work for
me when using the same thing. But it must have been the action.

Sorry for all the problem and thank you for helping out everyone :)
 
Status
Not open for further replies.
Top