1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. Seek unity between the elements in the 22nd Terraining Contest Poll.
    Dismiss Notice
  3. Seize the moment! The 18th Mini Mapping Contest has commenced.
    Dismiss Notice
  4. The heavens smile on the old faithful. The 16th Techtree Contest has begun.
    Dismiss Notice
  5. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[GUI] Heath & Mana bar system v1.5

Submitted by nhocklanhox6
This bundle is marked as approved. It works and satisfies the submission rules.
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:
Click
Code (vJASS):
//********************************************************************************
//********************************************************************************
//********************************************************************************
//********************************************************************************
//********************************************************************************
//         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 a bar to unit
  • 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
      • -------- -- --------

How to remove & recycle a bar from unit
  • 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)

How to transfer bar between unit
  • 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)

How to change current bars data from unit
  • 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)

How to hide bar if they're an enemies
  • 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

How to show bar if they're an enemies
  • 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:
System Init
  • 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")
      • -------- ------- --------


System Period
  • 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)
          • -------- - --------
      • -------- - --------


Hide bars all players
Code (vJASS):
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

 


Hide heath/mana bar to a player
Code (vJASS):
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
 


Change heath/Mana bar data or transfer bar
Code (vJASS):
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
 


Remove bar
Code (vJASS):
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
 


Hide bar to players Execution
Code (vJASS):
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
 


Illusion Checker Plugin
Code (vJASS):
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:
[​IMG]

Keywords:
mana,heath,bar,system
Contents

Mana/Heath bars system (Map)

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

    Changes made. Approved. Nicely made system.
     
  2. nhocklanhox6

    nhocklanhox6

    Joined:
    Feb 12, 2012
    Messages:
    335
    Resources:
    28
    Models:
    6
    Spells:
    21
    Tutorials:
    1
    Resources:
    28
    Too advance ==!
     
  3. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,526
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
    Don't use integer A /B they are slower and less efficient.

    Remove this BJ LoadIntegerBJ

    You need to null these at the end of the functions. local player
     
  4. nhocklanhox6

    nhocklanhox6

    Joined:
    Feb 12, 2012
    Messages:
    335
    Resources:
    28
    Models:
    6
    Spells:
    21
    Tutorials:
    1
    Resources:
    28
    It's just an example about how to show/hide bar >.<
     
  5. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,526
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
    Still it's bad to use them in example triggers as people think it is ok to use in normal triggers.

    Also i edited my above post.
     
  6. Maker

    Maker

    Joined:
    Mar 6, 2006
    Messages:
    9,174
    Resources:
    17
    Maps:
    2
    Spells:
    14
    Tutorials:
    1
    Resources:
    17
    I don't think local players need to be nulled. I really should test it once more but I'm out of time.
     
  7. DeuceGorgon

    DeuceGorgon

    Joined:
    Nov 25, 2012
    Messages:
    171
    Resources:
    7
    Models:
    6
    Maps:
    1
    Resources:
    7
    Thank youuuu so much!
     
  8. Wrda

    Wrda

    Joined:
    Nov 18, 2012
    Messages:
    1,309
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    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:
     
  9. nhocklanhox6

    nhocklanhox6

    Joined:
    Feb 12, 2012
    Messages:
    335
    Resources:
    28
    Models:
    6
    Spells:
    21
    Tutorials:
    1
    Resources:
    28
    Alaways confused T.T, i'm wrong >.<....
     
  10. BPower

    BPower

    Joined:
    Mar 18, 2012
    Messages:
    1,709
    Resources:
    21
    Spells:
    15
    Tutorials:
    1
    JASS:
    5
    Resources:
    21
    Yes, I've read it many times that nulling player variables is redundant. I think once Dr. Super Good argument was: it will leak a maximum of 16 handles. (and a lot of explanation why)
     
  11. abcde

    abcde

    Joined:
    Jun 3, 2013
    Messages:
    13
    Resources:
    0
    Resources:
    0
    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!
     
  12. edo494

    edo494

    Joined:
    Apr 16, 2012
    Messages:
    3,846
    Resources:
    5
    Spells:
    1
    JASS:
    4
    Resources:
    5
    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
     
  13. Legal_Ease

    Legal_Ease

    Joined:
    Feb 8, 2013
    Messages:
    1,453
    Resources:
    28
    Icons:
    11
    Packs:
    1
    Skins:
    2
    Maps:
    10
    Template:
    1
    Tutorials:
    3
    Resources:
    28
    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: Feb 4, 2014
  14. BPower

    BPower

    Joined:
    Mar 18, 2012
    Messages:
    1,709
    Resources:
    21
    Spells:
    15
    Tutorials:
    1
    JASS:
    5
    Resources:
    21
    I guess its pretty much the same as the vJass version and just made to make it available for GUI'ers aswell.
    Judging from the screenshot it looks great and useful.

    Like the vJass version bars could be added and removed via UnitIndexer plus a UnitFilter and a boolean enabled = ?.
     
  15. EyeCandy

    EyeCandy

    Joined:
    May 13, 2012
    Messages:
    64
    Resources:
    0
    Resources:
    0
    Hmm, I don't like thick mana bar. How to configure thickness? Could someone point me to the right trigger code? I can see how u can adjust height.

    Anyway very good system for my MOBA map.
     
  16. EyeCandy

    EyeCandy

    Joined:
    May 13, 2012
    Messages:
    64
    Resources:
    0
    Resources:
    0
    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.
     
  17. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,429
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    Review:
    • 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
     
  18. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,429
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    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.
     
  19. nhocklanhox6

    nhocklanhox6

    Joined:
    Feb 12, 2012
    Messages:
    335
    Resources:
    28
    Models:
    6
    Spells:
    21
    Tutorials:
    1
    Resources:
    28
    @PurgeandFire
    ----------------
    In the period trigger ;)

    • Trigger - Run Illusion Checker Plugin <gen> (ignoring conditions)