• 🏆 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] Checking Mana Amount Every Second

Status
Not open for further replies.
Level 13
Joined
Dec 3, 2005
Messages
501
Is there a way to check the amount of mana a unit group has every second w/o using a periodic event? As to avoid unwanted lag spikes.

I know there's the event that checks a single preplaced units mana when it drops below a certain number,but it doesn't help on a large scale when I want to check an entire groups mana.
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
Maybe this is what you want?

  • Check Mana
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set TotalGroupMana = 0.00
      • Unit Group - Pick every unit in YourUnitGroup and do (Actions)
        • Loop - Actions
          • Set TotalGroupMana = (TotalGroupMana + (Mana of (Picked unit)))
      • ***I suppose you are going to make something after checking mana***
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TotalGroupMana (greater than/equal/less than....) to (example 100)
        • Then - Actions
          • do something
        • Else - Actions
          • do something
/Regards

Edit: You should declare the "YourUnitGroup" somewhere else, determinating which units it shall contain
Just remember, if you want to replace this group with another unit group, but as the same variable name, you have to paste
  • Custom script: call DestroyGroup( udg_YourUnitGroup )
before you create the new group in that variable.
 
Level 7
Joined
Dec 8, 2005
Messages
319
well think you could tell us how your units are loosing mana and what you want to happen... like lets say mountain king casts slam and costs him a 100 mana... well then instead needing a periodic event... you could just simply put it as Unit - A unit Finishes casting an ability... but if you are using a negative value like mana regen -1 then simply use the Unit - Your Unit mana becomes Less than or equal to 100.00... but with the second option... you would either need to have the unit already on the map or you would need another trigger to select that unit and set it as a variable. and that other trigger would need to be a periodic event... so give us alittle more information and lets see what we can do for you.
 
Level 13
Joined
Dec 3, 2005
Messages
501
Yes it'll be for a negative value on mana regeneration.

It's for a Airplane system. When a units mana(fuel) becomes lower than 1 it will tell the plane to fly to the nearest airfield.

However I can't have it checking & running through it every 5 secs because there's a lag spike.
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
You could instead use immolation as a fuel spell

It drains mana over time so

I think its something like

  • Event
  • Unit is issued to target no point
  • Conditions
  • Unit-type of ordering unit equals to airplane
  • issued order equal to unimmolation
  • Actions
  • do something here
The spell immolation will automatically deactivate when your plane's mana is going down to 0. Therefor we use the order "unimmolation"
If the user is not clicking deactivate by himself, everything will do automatically
Everytime a unit flies from the airplane, make a trigger saying that it should order to activate immolation. And if the player tries to stop this by deactivating the skill, the plane just flies back :)

Could this work out for you?
/Regards
 
Level 7
Joined
Dec 8, 2005
Messages
319
but see when your units man goes to 0 the unit is not issued that order... it just simply turns off... but i am not sure how to check for that... but it is a good idea. maybe have to have 2 triggers... one to check for units casting immolation and set it to a variable and have a second trigger to check for units "variable" mana is below or equal to X then do this.
 
Status
Not open for further replies.
Top