• 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.

[GUI] Heath & Mana bar system v1.5

I'm lazy to decorate this topic >.<..so

Important Message

Remember:
  • -------- Remember: If you don't want to disable Fog of War, you must put this line on the first of Add Bar Trigger and then Enable again --------
  • Visibility - Disable fog of war
  • Visibility - Disable black mask
  • -------- Add your code here --------
  • ------------------------------------
  • -------- And then, enable again --------
  • Visibility - Enable fog of war
  • Visibility - Enable black mask
-Changelog-

v1.0: First release version !
v1.1: Remove Change bar trigger, more explanation from example trigger :)
v1.2: More explanation from example trigger, bugs fixed, trigger optimized, more debug messages when you go wrong !.
v1.3: Add feature: When unit is not detected, mana/heath bar will hide.
Add feature: When unit is hidden, mana/heath bar will hide.
Add feature: When unit have illusion, mana/heath bar will hide (Affected enemies only) (Apply to all unit have the same UnitTypeId, sorry for the inconvenience).
Add varriables creator.
More information about how to import.
v1.3b: Add important message.
v1.4: Minor bugs fixed.
v1.5: Remove global group
-If you want to this system show error messages-

Just go to Debug -> Check the Debug Mode box.
-Mana/Heath Bars System-

*GUI Version*
*This system has more features than vjass version*
I/How to import:
JASS:
//********************************************************************************
//********************************************************************************
//********************************************************************************
//********************************************************************************
//********************************************************************************
//         M A N A/ H E A T H    B A R S    S Y S T E M
//                    =======
//         System created by:
//                           - Elphis
//  What system does:
//                   This system allow you to create a mana/hp bars on unit :)
//
//               H O W   T O   I M P O R T
//    1: Export LightningData.slk, nhocklanhox6-Elphis.blp, nhocklanhox6-Nyuu.blp, Elphis-Nyuu and import it into your map
//    2: Change path of LightningData.slk = Splats\LightningData.slk
//    3: Change path of nhocklanhox6-Nyuu.blp = ReplaceableTextures\Manabar\nhocklanhox6-Nyuu.blp
//    4: Change path of nhocklanhox6-Elphis.blp = ReplaceableTextures\Manabar\nhocklanhox6-Elphis.blp
//    5: Change path of Elphis-Nyuu = ReplaceableTextures\HitPointBar\Elphis-Nyuu.blp
//    WARNING: DO NOT CHANGE THIS PATH, IF YOU CHAGE THIS PATH, ALL LIGHTNING WILL CRASH
//    Go to: File -> Preferences -> General -> Check the box labelled "Automatically create unknown variables while pasting trigger data"
//    5: Copy all trigger of folder Resources into your map
//    6: Read the Example Folder
//    7: Enjoy :D
//********************************************************************************
//********************************************************************************
//********************************************************************************
//********************************************************************************
//********************************************************************************
//********************************************************************************
II/How to use
  • Add Bars
    • Events
      • Player - Player 1 (Red) types a chat message containing -add as An exact match
    • Conditions
    • Actions
      • -------- Remember: If you don't want to disable Fog of War, you must put this line on the first of Add Bar Trigger and then Enable again --------
      • Visibility - Disable fog of war
      • Visibility - Disable black mask
      • -------- -- --------
      • -------- ADD UNIT TO SYSTEM --------
      • -------- Add Unit, Bar and Scale --------
      • -------- Unit you want to add bar --------
      • Set HM_UnitAddBars = Paladin 0001 <gen>
      • -------- Unit scale (optional, you can choose the value whatever you want ^^) --------
      • Set HM_UnitSetScale = 1.00
      • -------- Allow system to create Heath Bar --------
      • Set HM_ActiveHeathBar = True
      • -------- Allow system to create Mana Bar --------
      • Set HM_ActiveManaBar = True
      • -------- Run this trigger to operate this action --------
      • Trigger - Run HM System Run <gen> (ignoring conditions)
      • -------- ---- --------
      • -------- And then, enable again --------
      • Visibility - Enable fog of war
      • Visibility - Enable black mask
      • -------- -- --------
  • Remove
    • Events
      • Player - Player 1 (Red) types a chat message containing -remove as An exact match
    • Conditions
    • Actions
      • -------- REMOVE BARS FROM UNIT --------
      • -------- Add current unit --------
      • -------- Unit you want to remove bar --------
      • Set HM_Current_Unit = Paladin 0001 <gen>
      • -------- Run this trigger to operate this action --------
      • Trigger - Run Remove Bars <gen> (ignoring conditions)
  • Transfer Bar
    • Events
      • Player - Player 1 (Red) types a chat message containing -change as An exact match
    • Conditions
    • Actions
      • -------- CHANGE BARS FROM UNIT TO UNIT --------
      • -------- Add current unit and unit you want to change --------
      • -------- Current unit have bar --------
      • Set HM_Current_Unit = Paladin 0001 <gen>
      • -------- Unit you want to transfer bar --------
      • Set HM_Change_Unit = Priest 0002 <gen>
      • -------- Set this boolean = false if you only want to transfer bar --------
      • Set HM_Do_Changes = False
      • -------- Run this trigger to operate this action --------
      • Trigger - Run Change Data <gen> (ignoring conditions)
  • Change Data Bar
    • Events
      • Player - Player 1 (Red) types a chat message containing -change1 as An exact match
    • Conditions
    • Actions
      • -------- CHANGE CURRENT DATA --------
      • -------- Add current unit, change unit and change scale value --------
      • -------- Current unit have bar --------
      • Set HM_Current_Unit = Priestess of the Moon 0005 <gen>
      • -------- Unit you want to change bar --------
      • Set HM_Change_Unit = Rifleman 0003 <gen>
      • -------- Scale you want to change (Optional) --------
      • Set HM_UnitSetScale = 2.00
      • -------- Just remember, when you want to remove/add bars you must put this boolean below these action and set it = true --------
      • Set HM_Do_Bar_Changes = True
      • -------- Change Bar Data --------
      • -------- Active heath bar/True = Add bar (If it does not exist)/False = Remvoe bar (If it exist) --------
      • Set HM_ActiveHitPointsBar = True
      • -------- Active mana bar/True = Add bar (If it does not exist)/False = Remvoe bar (If it exist) --------
      • Set HM_ActiveManaBar = False
      • -------- Run this trigger to operate this action --------
      • Trigger - Run Change Data <gen> (ignoring conditions)
  • Hide Bars Enemies
    • Events
      • Player - Player 1 (Red) types a chat message containing -hidee as An exact match
    • Conditions
    • Actions
      • -------- HIDE BARS TO ENEMIES --------
      • -------- For example: I will hide bars for all enemies of Neutral Player --------
      • For each (Integer TEST_ONLY_Integer) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player(TEST_ONLY_Integer)) is an enemy of Neutral Hostile) Equal to True
            • Then - Actions
              • -------- Add current unit and enemies player --------
              • -------- Current unit have bar you want to hide --------
              • Set HM_Current_Unit = Wisp 0004 <gen>
              • -------- Player you want to hide from Current Unit --------
              • Set HM_Current_Player = (Player(TEST_ONLY_Integer))
              • -------- Hide/Show bars --------
              • -------- Hide/Show bars - True = Hide/False = Show --------
              • Set HM_Do_Hide = True
              • -------- Run this trigger to operate this action --------
              • Trigger - Run HM Hide Bars To Player <gen> (ignoring conditions)
            • Else - Actions
  • Show Bars Enemies
    • Events
      • Player - Player 1 (Red) types a chat message containing -hidee as An exact match
    • Conditions
    • Actions
      • -------- HIDE BARS TO ENEMIES --------
      • -------- For example: I will hide bars for all enemies of Neutral Player --------
      • For each (Integer TEST_ONLY_Integer) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player(TEST_ONLY_Integer)) is an enemy of Neutral Hostile) Equal to True
            • Then - Actions
              • -------- Add current unit and enemies player --------
              • -------- Current unit have bar you want to hide --------
              • Set HM_Current_Unit = Wisp 0004 <gen>
              • -------- Player you want to hide from Current Unit --------
              • Set HM_Current_Player = (Player(TEST_ONLY_Integer))
              • -------- Hide/Show bars --------
              • -------- Hide/Show bars - True = Hide/False = Show --------
              • Set HM_Do_Hide = False
              • -------- Run this trigger to operate this action --------
              • Trigger - Run HM Hide Bars To Player <gen> (ignoring conditions)
            • Else - Actions

IV: Trigger Code:
  • HM System Init
    • Events
      • Map initializationHM System Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Non - Configurables --------
      • Set HM_Location = (Point(0.00, 0.00))
      • -------- Mana bar model --------
      • Set MN_MODEL = ELPH
      • -------- Hit Points bar model --------
      • Set HP_MODEL = ICEF
      • -------- Empty bar model --------
      • Set HM_EMPTY_MODEL = NYUU
      • -------- Another Configurables --------
      • -------- Bars height --------
      • Set HM_Z_OFFSET = 181.00
      • -------- Bars long --------
      • Set HM_LONG = 66.00
      • -------- Height safer --------
      • Set HM_SAFE = 20.00
      • -------- Hit points bar height --------
      • Set HM_HP_Z = 21.00
      • -------- Location you want to move when unit dead --------
      • Set HM_DEAD_LOC = 0.00
      • -------- - --------
      • Custom script: set udg_HM_Hashtable = InitHashtable()
      • -------- System Period --------
      • Set HM_PERIODIC = 0.03HM System Run
    • Events
    • Conditions
    • Actions
      • -------- ------- --------
      • Custom script: local real x
      • Custom script: local real y
      • -------- ------- --------
      • Custom script: set udg_HM_HandleId = GetHandleId(udg_HM_UnitAddBars)
      • Custom script: set udg_HM_Current_Unit = LoadUnitHandle(udg_HM_Hashtable,1,udg_HM_HandleId)
      • -------- ------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HM_UnitAddBars Not equal to HM_Current_Unit
        • Then - Actions
          • -------- --------------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • HM_UnitAddBars Not equal to No unit
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • HM_UnitSetScale Greater than 0.00
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • HM_ActiveHeathBar Equal to True
                          • HM_ActiveManaBar Equal to True
                    • Then - Actions
                      • Set HM_MUI = (HM_MUI + 1)
                      • Set HM_MUI_Data[HM_MUI] = HM_MUI
                      • -------- New Data Configuration --------
                      • Set HM_Caster[HM_MUI] = HM_UnitAddBars
                      • Set HM_Scale[HM_MUI] = HM_UnitSetScale
                      • Set HM_UnitHandleId[HM_MUI] = HM_HandleId
                      • Set HM_Player[HM_MUI] = (Owner of HM_UnitAddBars)
                      • Custom script: set udg_HM_Unit_Handle[udg_HM_MUI] = udg_HM_HandleId
                      • -------- --------------------------- --------
                      • -------- Bars Activator --------
                      • -------- --------------------------- --------
                      • -------- Hit Points bar activator --------
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • HM_ActiveHeathBar Equal to True
                        • Then - Actions
                          • Custom script: set x = GetUnitX(udg_HM_Caster[udg_HM_MUI])
                          • Custom script: set y = GetUnitY(udg_HM_Caster[udg_HM_MUI])
                          • -------- - --------
                          • Custom script: set udg_HM_LightningH[udg_HM_MUI] = AddLightning(udg_HP_MODEL,true,x,y,x,y)
                          • Custom script: set udg_HM_LightningSE[udg_HM_MUI] = AddLightning(udg_HM_EMPTY_MODEL,true,x,y,x,y)
                          • -------- - --------
                        • Else - Actions
                          • Custom script: set udg_HM_LightningH[udg_HM_MUI] = null
                          • Custom script: set udg_HM_LightningFE[udg_HM_MUI] = null
                      • -------- Mana bar activator --------
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • HM_ActiveManaBar Equal to True
                        • Then - Actions
                          • Custom script: set x = GetUnitX(udg_HM_Caster[udg_HM_MUI])
                          • Custom script: set y = GetUnitY(udg_HM_Caster[udg_HM_MUI])
                          • -------- - --------
                          • Custom script: set udg_HM_LightningM[udg_HM_MUI] = AddLightning(udg_MN_MODEL,true,x,y,x,y)
                          • Custom script: set udg_HM_LightningFE[udg_HM_MUI] = AddLightning(udg_HM_EMPTY_MODEL,true,x,y,x,y)
                        • Else - Actions
                          • Custom script: set udg_HM_LightningM[udg_HM_MUI] = null
                          • Custom script: set udg_HM_LightningSE[udg_HM_MUI] = null
                      • -------- - --------
                      • -------- Save Unit --------
                      • Custom script: call SaveUnitHandle(udg_HM_Hashtable,1,udg_HM_HandleId,udg_HM_Caster[udg_HM_MUI])
                      • Custom script: call SaveInteger(udg_HM_Hashtable,2,udg_HM_HandleId,udg_HM_MUI)
                      • -------- - --------
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • HM_MUI Equal to 1
                        • Then - Actions
                          • Countdown Timer - Start HM_TIMER as a Repeating timer that will expire in HM_PERIODIC seconds
                        • Else - Actions
                    • Else - Actions
                      • Custom script: debug call BJDebugMsg("Error: Can't operate this action, did you active the boolean heath or mana bar ??")
                  • -------- - --------
                  • Set HM_UnitSetScale = 0.00
                  • -------- - --------
                • Else - Actions
                  • Custom script: debug call BJDebugMsg("Error: Can't operate this action, did you add the scale value for heath/mana bar ?")
              • -------- - --------
              • Set HM_UnitAddBars = No unit
              • -------- - --------
            • Else - Actions
              • Custom script: debug call BJDebugMsg("Error: Can't add bars, check your data again !!")
        • Else - Actions
          • Custom script: debug call BJDebugMsg("Error: Can't add bars, this hero already exist")
      • -------- ------- --------
  • HM System Period
    • Events
      • Time - HM_TIMER expires
    • Conditions
    • Actions
      • -------- Local Variables --------
      • Custom script: local real locX = 0.
      • Custom script: local real locY = 0.
      • Custom script: local real locZ = 0.
      • Custom script: local real barX = 0.
      • Custom script: local real barY = 0.
      • Custom script: local real barZ = 0.
      • Custom script: local real indX = 0.
      • Custom script: local real ind2X = 0.
      • Custom script: local real percentage
      • -------- - --------
      • For each (Integer HM_Loop) from 1 to HM_MUI, do (Actions)
        • Loop - Actions
          • -------- - --------
          • Set HM_Data = HM_MUI_Data[HM_Loop]
          • -------- - --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Unit-type of HM_Caster[HM_Data]) Equal to No unit-type
                  • HM_Release[HM_Data] Equal to True
            • Then - Actions
              • -------- ..Recycle Data.. --------
              • Lightning - Destroy HM_LightningSE[HM_Data]
              • Lightning - Destroy HM_LightningFE[HM_Data]
              • Lightning - Destroy HM_LightningH[HM_Data]
              • Lightning - Destroy HM_LightningM[HM_Data]
              • -------- - --------
              • Hashtable - Clear all child hashtables of child HM_UnitHandleId[HM_Data] in HM_Hashtable
              • -------- - --------
              • Set HM_MUI_Data[HM_Data] = HM_MUI_Data[HM_MUI]
              • Set HM_MUI_Data[HM_MUI] = -1
              • Set HM_MUI = (HM_MUI - 1)
              • -------- - --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • HM_MUI Equal to 0
                • Then - Actions
                  • Countdown Timer - Pause HM_TIMER
                • Else - Actions
              • -------- - --------
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (HM_Caster[HM_Data] is dead) Equal to True
                • Then - Actions
                  • Custom script: call MoveLightning(udg_HM_LightningH[udg_HM_Data] ,true,udg_HM_DEAD_LOC,udg_HM_DEAD_LOC,udg_HM_DEAD_LOC,udg_HM_DEAD_LOC)
                  • Custom script: call MoveLightning(udg_HM_LightningSE[udg_HM_Data] ,true,udg_HM_DEAD_LOC,udg_HM_DEAD_LOC,udg_HM_DEAD_LOC,udg_HM_DEAD_LOC)
                  • Custom script: call MoveLightning(udg_HM_LightningFE[udg_HM_Data] ,true,udg_HM_DEAD_LOC,udg_HM_DEAD_LOC,udg_HM_DEAD_LOC,udg_HM_DEAD_LOC)
                  • Custom script: call MoveLightning(udg_HM_LightningM[udg_HM_Data] ,true,udg_HM_DEAD_LOC,udg_HM_DEAD_LOC,udg_HM_DEAD_LOC,udg_HM_DEAD_LOC)
                • Else - Actions
                  • Custom script: set locX = GetUnitX(udg_HM_Caster[udg_HM_Data])
                  • Custom script: set locY = GetUnitY(udg_HM_Caster[udg_HM_Data])
                  • -------- - --------
                  • Custom script: call MoveLocation(udg_HM_Location,locX,locY)
                  • Custom script: set locZ = GetLocationZ(udg_HM_Location)
                  • Custom script: set percentage = GetCameraField(CAMERA_FIELD_TARGET_DISTANCE)/(bj_CAMERA_DEFAULT_DISTANCE+250)
                  • Custom script: set barX = locX - udg_HM_LONG*percentage
                  • Custom script: set barZ = locZ + GetUnitFlyHeight(udg_HM_Caster[udg_HM_Data]) + udg_HM_Z_OFFSET*udg_HM_Scale[udg_HM_Data] - udg_HM_SAFE
                  • Custom script: set ind2X = locX + udg_HM_LONG*percentage
                  • -------- - --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Max mana of HM_Caster[HM_Data]) Greater than 0.00
                    • Then - Actions
                      • -------- - --------
                      • Custom script: set indX = barX + percentage*udg_HM_LONG*2*GetUnitState(udg_HM_Caster[udg_HM_Data],UNIT_STATE_MANA)/GetUnitState(udg_HM_Caster[udg_HM_Data],UNIT_STATE_MAX_MANA)
                      • -------- - --------
                    • Else - Actions
                      • -------- - --------
                      • Custom script: set indX = barX + percentage*udg_HM_LONG*2*0./1.
                      • -------- - --------
                  • -------- - --------
                  • Custom script: call MoveLightningEx(udg_HM_LightningSE[udg_HM_Data],true,ind2X,locY,barZ,barX,locY,barZ)
                  • Custom script: call MoveLightningEx(udg_HM_LightningM[udg_HM_Data],true,barX,locY,barZ,indX,locY,barZ)
                  • -------- - --------
                  • Custom script: set indX = barX + percentage*udg_HM_LONG*2*GetUnitState(udg_HM_Caster[udg_HM_Data],UNIT_STATE_LIFE)/GetUnitState(udg_HM_Caster[udg_HM_Data],UNIT_STATE_MAX_LIFE)
                  • -------- - --------
                  • Custom script: call MoveLightningEx(udg_HM_LightningFE[udg_HM_Data],true,ind2X,locY,barZ+udg_HM_HP_Z,barX,locY,barZ+udg_HM_HP_Z)
                  • Custom script: call MoveLightningEx(udg_HM_LightningH[udg_HM_Data],true,barX,locY,barZ+udg_HM_HP_Z,indX,locY,barZ+udg_HM_HP_Z)
                  • -------- - --------
                  • For each (Integer HM_Player_Integer) from 1 to 12, do (Actions)
                    • Loop - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Or - Any (Conditions) are true
                            • Conditions
                              • (HM_Caster[HM_Data] is visible to (Player(HM_Player_Integer))) Equal to False
                              • (HM_Caster[HM_Data] is hidden) Equal to True
                              • (Life of HM_Illusion_Unit[HM_Data]) Greater than 0.00
                        • Then - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Life of HM_Illusion_Unit[HM_Data]) Equal to 0.00
                            • Then - Actions
                              • Set HM_Current_Unit = HM_Caster[HM_Data]
                              • Set HM_Current_Player = (Player(HM_Player_Integer))
                              • Set HM_Do_Hide = True
                              • Trigger - Run HM Hide Bars To Player Execution <gen> (ignoring conditions)
                            • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • ((Player(HM_Player_Integer)) is an enemy of HM_Player[HM_Data]) Equal to True
                                • Then - Actions
                                  • Set HM_Current_Unit = HM_Caster[HM_Data]
                                  • Set HM_Current_Player = (Player(HM_Player_Integer))
                                  • Set HM_Do_Hide = True
                                  • Trigger - Run HM Hide Bars To Player Execution <gen> (ignoring conditions)
                                • Else - Actions
                        • Else - Actions
                          • -------- - --------
                          • Custom script: set udg_HM_Do_Hide= LoadBoolean(udg_HM_Hashtable,10+udg_HM_Player_Integer,udg_HM_Unit_Handle[udg_HM_Data])
                          • -------- - --------
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • HM_Do_Hide Equal to False
                            • Then - Actions
                              • Set HM_Current_Unit = HM_Caster[HM_Data]
                              • Set HM_Current_Player = (Player(HM_Player_Integer))
                              • Set HM_Do_Hide = False
                              • Trigger - Run HM Hide Bars To Player Execution <gen> (ignoring conditions)
                            • Else - Actions
                  • -------- - --------
                  • Trigger - Run Illusion Checker Plugin <gen> (ignoring conditions)
          • -------- - --------
      • -------- - --------
JASS:
function Trig_Hide_Bars_All_Player_Actions takes nothing returns nothing
        local integer i           = 0
        local player  casterOwner = udg_HM_Current_Player
        local integer curData = LoadInteger(udg_HM_Hashtable,2,GetHandleId(udg_HM_Current_Unit))
        local player  curPlayer

        if curData > 0 then
            if udg_HM_Current_Unit != null then
                if udg_HM_Current_Player != null then
                    loop
                        exitwhen i > 11
                        set curPlayer = Player(i)
                        if curPlayer != casterOwner then
                            set udg_HM_Current_Player = curPlayer
                            call TriggerExecute(gg_trg_HM_Hide_Bars_To_Player)
                        endif
                        set i = i + 1
                    endloop
                    //
                    set udg_HM_Current_Player = null
                    //
                else
                    debug call BJDebugMsg("Can't operate bars: Did you add the current player you want to hide heath/mana bar ?.")
                endif
            else
                debug call BJDebugMsg("Can't operate bars: Did you add the current unit have heath/mana bar ?.")
            endif
        else
            debug call BJDebugMsg("Can't operate bars: the unit does not exist.")
        endif
endfunction

//===========================================================================
function InitTrig_Hide_Bars_All_Players takes nothing returns nothing
    set gg_trg_Hide_Bars_All_Players = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Hide_Bars_All_Players, function Trig_Hide_Bars_All_Player_Actions )
endfunction

JASS:
function Trig_HM_Hide_Bars_To_Player_Actions takes nothing returns nothing
    local real alphaNum = 1.
    local integer h = GetHandleId(udg_HM_Current_Unit)
    local integer curData = LoadInteger(udg_HM_Hashtable,2,h)
    local boolean curHidden
    local integer curPlayer
    //
    if curData > 0 then
        if udg_HM_Current_Unit != null then
            if udg_HM_Current_Player != null then
                //
                set curPlayer = GetPlayerId(udg_HM_Current_Player)
                // Special case: hidden units.
                if not udg_HM_Do_Hide and IsUnitHidden(udg_HM_Current_Unit) then
                    debug call BJDebugMsg("Can't show bars: the unit is hidden.")
                else
                    //
                    if udg_HM_Do_Hide then
                        set alphaNum = 0.
                    endif
                    //
                    call SaveBoolean(udg_HM_Hashtable,11+curPlayer,h,udg_HM_Do_Hide)
                    //
                    if GetLocalPlayer() == udg_HM_Current_Player then
                        call SetLightningColor(udg_HM_LightningH[curData],1.,1.,1.,alphaNum)
                        call SetLightningColor(udg_HM_LightningM[curData],1.,1.,1.,alphaNum)
                        call SetLightningColor(udg_HM_LightningSE[curData],1.,1.,1.,alphaNum)
                        call SetLightningColor(udg_HM_LightningFE[curData],1.,1.,1.,alphaNum)
                    endif 
                endif
                //
                set udg_HM_Current_Player = null
                //
            else
                debug call BJDebugMsg("Can't operate bars: Did you add the current player you want to hide heath/mana bar ?.")
            endif
            //
             set udg_HM_Current_Unit = null
            //
        else
            debug call BJDebugMsg("Can't operate bars: Did you add the current unit have heath/mana bar ?.")
        endif
    else
        debug call BJDebugMsg("Can't operate bars: the unit does not exist.")
    endif
endfunction

//===========================================================================
function InitTrig_HM_Hide_Bars_To_Player takes nothing returns nothing
    set gg_trg_HM_Hide_Bars_To_Player = CreateTrigger(  )
    call TriggerAddAction(gg_trg_HM_Hide_Bars_To_Player, function Trig_HM_Hide_Bars_To_Player_Actions)
endfunction

JASS:
function Trig_Change_Data_Actions takes nothing returns nothing
    local integer curData = LoadInteger(udg_HM_Hashtable,2,GetHandleId(udg_HM_Current_Unit))
    //
    if curData > 0 then
        if udg_HM_Current_Unit != null then
            if udg_HM_Change_Unit != null then
                if udg_HM_Caster[curData] != udg_HM_Change_Unit then
                    set udg_HM_Caster[curData] = udg_HM_Change_Unit
                else
                    debug call BJDebugMsg("Can't operate bars: Current unit fit with the unit unit want to transfer heath/mana bar >.<.")
                endif
                //
                set udg_HM_Change_Unit = null
                //
            else
                debug call BJDebugMsg("Can't operate bars: Did you add the unit you want to transfer heath/mana bar ?.")
            endif
            //
            if udg_HM_Do_Changes then
                //
                if udg_HM_UnitSetScale > 0. then
                    set udg_HM_Scale[curData] = udg_HM_UnitSetScale
                endif
                //
                set udg_HM_UnitSetScale = 0.
                //
                if udg_HM_ActiveHeathBar then
                    if udg_HM_LightningH[curData] != null then
                        debug call BJDebugMsg("Can't operate this action: HP bar already exist.")
                    else
                        set udg_HM_LightningH[curData] = AddLightning(udg_HP_MODEL,true,0.,0.,0.,0.)
                        set udg_HM_LightningFE[curData] = AddLightning(udg_HM_EMPTY_MODEL,true,0.,0.,0.,0.)
                    endif
                elseif udg_HM_ActiveManaBar then
                    if udg_HM_LightningM[curData] != null then
                        debug call BJDebugMsg("Can't operate this action: MP bar already exist.")
                    else
                        set udg_HM_LightningM[curData] = AddLightning(udg_MN_MODEL,true,0.,0.,0.,0.)
                        set udg_HM_LightningSE[curData] = AddLightning(udg_HM_EMPTY_MODEL,true,0.,0.,0.,0.)
                    endif
                endif
                //
                if not udg_HM_ActiveHeathBar then
                    if udg_HM_LightningH[curData] == null then
                        debug call BJDebugMsg("Can't operate this action: HP bar does not exist.")
                    else
                        call DestroyLightning(udg_HM_LightningH[curData])
                        call DestroyLightning(udg_HM_LightningFE[curData])
                        set udg_HM_LightningH[curData] = null
                        set udg_HM_LightningFE[curData] = null
                    endif
                elseif not udg_HM_ActiveManaBar then
                    if udg_HM_LightningM[curData] == null then
                        debug call BJDebugMsg("Can't operate this action: MP bar does not exist.")
                    else
                        call DestroyLightning(udg_HM_LightningM[curData])
                        call DestroyLightning(udg_HM_LightningSE[curData])
                        set udg_HM_LightningM[curData] = null
                        set udg_HM_LightningSE[curData] = null
                    endif
                endif
                //
                set udg_HM_ActiveHeathBar = false
                set udg_HM_ActiveManaBar = false
            endif
            //
            set udg_HM_Current_Unit = null
            //
        else
            debug call BJDebugMsg("Can't operate bars: Did you add the current unit have heath/mana bar ?.")
        endif
    else
        debug call BJDebugMsg("Can't operate bars: the unit does not exist.")
    endif
    //
endfunction

//===========================================================================
function InitTrig_Change_Data takes nothing returns nothing
    set gg_trg_Change_Data = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Change_Data, function Trig_Change_Data_Actions )
endfunction

JASS:
function Trig_Remove_Bars_Actions takes nothing returns nothing
    local integer curData = LoadInteger(udg_HM_Hashtable,2,GetHandleId(udg_HM_Current_Unit))
    //
    if curData > 0 then
        if udg_HM_Current_Unit != null then
            set udg_HM_Release[curData] = true
        else
            debug call BJDebugMsg("Can't operate bars: Did you add the current unit have heath/mana bar ?.")
        endif
        //
        set udg_HM_Current_Unit = null
        //
    else
        debug call BJDebugMsg("Can't operate bars: the unit does not exist.")
    endif
endfunction

//===========================================================================
function InitTrig_Remove_Bars takes nothing returns nothing
    set gg_trg_Remove_Bars = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Remove_Bars, function Trig_Remove_Bars_Actions )
endfunction

JASS:
function Execution_Actions takes nothing returns nothing
    local real alphaNum = 1.
    // Special case: hidden units.
    if not udg_HM_Do_Hide and IsUnitHidden(udg_HM_Current_Unit) then
        debug call BJDebugMsg("Can't show bars: the unit is hidden.")
    else
        //
        if udg_HM_Do_Hide then
            set alphaNum = 0.
        endif
        //
        if GetLocalPlayer() == udg_HM_Current_Player then
            call SetLightningColor(udg_HM_LightningH[udg_HM_Data],1.,1.,1.,alphaNum)
            call SetLightningColor(udg_HM_LightningM[udg_HM_Data],1.,1.,1.,alphaNum)
            call SetLightningColor(udg_HM_LightningSE[udg_HM_Data],1.,1.,1.,alphaNum)
            call SetLightningColor(udg_HM_LightningFE[udg_HM_Data],1.,1.,1.,alphaNum)
        endif 
    endif
    //
endfunction

//===========================================================================
function InitTrig_HM_Hide_Bars_To_Player_Execution takes nothing returns nothing
    set gg_trg_HM_Hide_Bars_To_Player_Execution = CreateTrigger(  )
    call TriggerAddAction(gg_trg_HM_Hide_Bars_To_Player_Execution, function Execution_Actions)
endfunction

JASS:
function UnitIllusion takes nothing returns boolean
    local unit f = GetFilterUnit()
    local integer i

    if IsUnitIllusion(f) and GetUnitTypeId(f) == GetUnitTypeId(udg_HM_Caster[udg_HM_Data]) then
        set udg_HM_Illusion_Unit[udg_HM_Data] = f
    endif
   
    set f = null
   
    return false
endfunction

function Trig_Illusion_Checker_Plugin_Actions takes nothing returns nothing
    local integer i = 0
   
    loop
        exitwhen i > 11
        //I think I don't need to using boolean to check Players are playing or not
        call GroupEnumUnitsOfPlayer(udg_HM_Illusion_Group,Player(i),function UnitIllusion)
       
        set i = i + 1
    endloop
endfunction

//===========================================================================
function InitTrig_Illusion_Checker_Plugin takes nothing returns nothing
    set gg_trg_Illusion_Checker_Plugin = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Illusion_Checker_Plugin, function Trig_Illusion_Checker_Plugin_Actions )
endfunction

III/Screenshot:
untit192.jpg


Keywords:
mana,heath,bar,system
Contents

Mana/Heath bars system (Map)

Reviews
22:41, 8th Mar 2014 PurgeandFire: (old) Review: http://www.hiveworkshop.com/forums/2537794-post18.html Changes made. Approved. Nicely made system.

Moderator

M

Moderator

22:41, 8th Mar 2014
PurgeandFire: (old) Review:
http://www.hiveworkshop.com/forums/2537794-post18.html

Changes made. Approved. Nicely made system.
 

Wrda

Spell Reviewer
Level 28
Joined
Nov 18, 2012
Messages
1,994
How to show bar if they're an allies
  • Show Bars Enemies
    • Events
      • Player - Player 1 (Red) types a chat message containing -showe as An exact match
    • Conditions
    • Actions
      • -------- SHOW BARS TO ENEMIES --------
      • -------- For example: I will show bars for all enemies of Neutral Player --------
      • 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
            • ((Player((Integer A))) is an enemy of Neutral Hostile) Equal to True --> Ally????
          • Then - Actions
            • -------- Add current unit and enemies player --------
            • Set HM_Current_Unit = Wisp 0004 <gen>
            • Set HM_Current_Player = (Player((Integer A)))
            • -------- Hide/Show bars --------
            • Set HM_Do_Hide = False
            • -------- Run this trigger to operate this action --------
            • Trigger - Run HM Hide Bars To Player <gen> (ignoring conditions)
          • Else - Actions
Huh? Correct me if I'm wrong, but I guess you meant "ally" not enemy here. Didn't see the rest, but it seems to look very fine. Good job :thumbs_up:
 
Level 2
Joined
Jun 3, 2013
Messages
13
OMG! God sent you to the Earth! Thats what I'm looking for a long time:ogre_kawaii:
Thank you!:))) + rep
Merry Xmas for all Hive member!
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
keep in your head this rule: only null agents that can be constructed and if they have potential to be removed from game
Player is not group or unit, it cant just be deconstructed or created at will, and even if player leaves, you will have leak of like 4 bytes, and since there are only 16 players, you will leak maximum of 16 handle id leaks
I think risking leak of 64 bytes is nothing compared to the amount of time lost nulling players over and over again(both development speed and game speed)

on topic: this looks pretty good the images, cant check ingame because of mobile
 
There should be a simple way to import this and have every unit with mana automatically have a mana bar. Its not fun to have to add a mana bar during the game. Please revise. Also, there is no need to remake a health bar since most players keep the health bars on during games. I grant you this - the bars look good and its a great addition to the spell section but its a bit useless without a functional way to implement it. On/Off commands don't make the game more fun. These should be done by trigger and should be simple. There should be triggers marked with comments that say "disable this trigger to hide enemy bars," or "enable this trigger to make bars on heroes only." You should explain how to make these modifications so that people can use this spell. I worked on this for a while and can't get it. It could have been so much cooler. Explain & Simplify!
 
Last edited:
Level 5
Joined
May 13, 2012
Messages
68
There should be a simple way to import this and have every unit with mana automatically have a mana bar. Its not fun to have to add a mana bar during the game. Please revise. Also, there is no need to remake a health bar since most players keep the health bars on during games. I grant you this - the bars look good and its a great addition to the spell section but its a bit useless without a functional way to implement it. On/Off commands don't make the game more fun. These should be done by trigger and should be simple. There should be triggers marked with comments that say "disable this trigger to hide enemy bars," or "enable this trigger to make bars on heroes only." You should explain how to make these modifications so that people can use this spell. I worked on this for a while and can't get it. It could have been so much cooler. Explain & Simplify!

Why health bar? An issue with Warcraft 3 is that unit health bar sizes aren't consistent.

Add Mana bar? Run trigger when hero enters map. remove bar when hero dies, hides, leaves map.
 
Review:
  • nhocklanhox6 said:
    If you want to this system show error messages-

    Just remove "debug" in front of the error messages.
    You actually just need to enable debug mode. I think it is an option under "Grimoire", or maybe "Jasshelper". I don't remember. But that is how you should display debug messages--not by removing the debug keyword. That is too much work. :p
  • If you're going to use JASS, remove some of the BJ's. BJDebugMsg is fine, but fix the LoadIntegerBJ().
  • In the illusion checker plug-in, you forgot to null local unit f. Also, you shouldn't group every single unit on the map. It can be a big performance drop if it is a really big map. You should take advantage of something like GroupEnumUnitsOfPlayer instead.
  • Fix the trigger tags for System Period in the spell description.

Otherwise, it is pretty good. I haven't thoroughly checked "System Period" though. I'll wait for the trigger tags to be fixed. :p
 
In your illusion checker, you use a globals block. If you want this to be completely GUI-friendly, then I recommend using a global from the variable editor instead (otherwise the system will require vJASS. That is okay, but since the rest of the system doesn't use vJASS, you might as well make that change).

Also, when does illusion checker run? I can't check the map atm. I just want to know where it is used.
 
Level 6
Joined
Jan 4, 2014
Messages
227
Good Day and thanks for such an awsome system :)
What i want to do is to colorize the Health bar to Green and Red, Green for Team 1 and Red for Team 2, so what i did is modifying Elphis-Nyuu.Blp from green to white, like that:
HM%20Bars.jpg

and i tried to colorize the lightning using GUI command :

Lightning - Change color of HM_LightningH[HM_MUI] to (0.00 1.00 0.00) with 0.80 alpha

in order to turn the white Bar into Green but it does not work, can you help with this ?

- it will be also good if you remove the ManaBar file and just use a white model bar and colorize it in blue
 
Why health bar? An issue with Warcraft 3 is that unit health bar sizes aren't consistent.

Add Mana bar? Run trigger when hero enters map. remove bar when hero dies, hides, leaves map.

I can't believe this system was accepted. It crashes a map if you apply it to more than a hand-full of units. I wasn't good enough to make the adjustments myself last time I posted but I tried it again, because I have been trying to get manabars in my maps.

I did this as suggested:
  • Add Bars
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Visibility - Disable fog of war
      • Visibility - Disable black mask
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • -------- Remember: If you don't want to disable Fog of War, you must put this line on the first of Add Bar Trigger and then Enable again --------
          • -------- -- --------
          • -------- ADD UNIT TO SYSTEM --------
          • -------- Add Unit, Bar and Scale --------
          • -------- Unit you want to add bar --------
          • Set HM_UnitAddBars = (Picked unit)
          • -------- Unit scale (optional, you can choose the value whatever you want ^^) --------
          • Set HM_UnitSetScale = 1.00
          • -------- Allow system to create Heath Bar --------
          • Set HM_ActiveHeathBar = True
          • -------- Allow system to create Mana Bar --------
          • Set HM_ActiveManaBar = True
          • -------- Run this trigger to operate this action --------
          • Trigger - Run HM System Run <gen> (ignoring conditions)
          • -------- ---- --------
          • -------- And then, enable again --------
          • -------- -- --------
      • Visibility - Enable fog of war
      • Visibility - Enable black mask
...and you got it ... el crasho. This system is only good for a few units. It should say so. Having this system here discourages others from creating other ones, for fear it won't be as good and will be rejected.

Now, there is a chance I am wrong, so if someone can prove it to me, with say a .w3x where 20 or more units are using the bar without lag, I will gladly remove this post. Otherwise, this should be removed, it is a practically useless system.
 
Top