[MOD] Fading Arc HP Meter (MT1.3b82 Campaign Macros r01)

Discussion concerning lmarkus' campaign framework for D&D3.x and Pathfinder.

Moderators: dorpond, trevor, Azhrei, giliath, Gamerdude, jay, Mr.Ice, lmarkus001

Forum rules
Discussion regarding lmarkus001's framework only. Other posts deleted without notice! :)
Post Reply
User avatar
aliasmask
RPTools Team
Posts: 9023
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

[MOD] Fading Arc HP Meter (MT1.3b82 Campaign Macros r01)

Post by aliasmask »

I had a couple of requests for this, so here's how you implement it. First, replace subUpdateHPStatesBar under Utility (at the bottom) with the following code. I'm using the RPedit Notepad++ format, but you can just delete the first 2 lines and last line :
||| subUpdateHPStatesBar |||

Code: Select all

@@ @subUpdateHPStatesBars
@PROPS@ fontColor=black;autoExecute=true;fontSize=1.00em;sortBy=31;color=pink;playerEditable=false;applyToSelected=true;group=Utility;tooltip=;minWidth=
<!-- Updates most states and health bars.  Does not update StableHP. Does HP based updates to state Unconscious, can not update based on healing. -->
[H: gTok = "Lib:GlobalsSRDPF"]
[H: tToken = getStrProp(macro.args, "Token")]

[H: gTokenUncImgChange = getLibProperty("TokenUncImgChange", gTok)]

[H: switchToken(tToken)]

[H, IF(gTokenUncImgChange), CODE: {
    [ tImageID = getTokenImage() ]
    [ tImageHID = getTokenHandout() ]
    [IF( tImageHID != tImageID ): Private = setStrProp(Private, "TokenImageAssetID", tImageID) ]
    [ tIAID = getStrProp(Private, "TokenImageAssetID")]
}]

[H: deathpoint = eval( string( getLibProperty( "DeathPoint", gTok ) ) )]

[H: tType = json.get( Race, "type" )]
[H: tSubtype = json.get( Race, "subtype" )]
[H: variantRDP = table( "SysVars", json.get( table( "SysVars", 0 ), "variantRaceDeathPoint" ) ) ]
[H, FOREACH( dp, variantRDP ), CODE: {
   [H: tDP = json.get( dp, "deathPoint" )]
   [H: typeArray = json.get( dp, "typeArray" )]
   [H: subtypeArray = json.get( dp, "subtypeArray" )]
   [H, FOREACH( t, typeArray ): deathpoint = if( t == tType, tDP, deathpoint )]
   [H, FOREACH( t, subtypeArray ): deathpoint = if( json.contains( tSubtype, t ), tDP, deathpoint )]
}]

[H: tDieHard = getStrProp(Feats, "DieHard")]
[H: tDieHard = if(tDieHard == "", 0, tDieHard)]
[H: disabledPoint = if( tDieHard, deathpoint, 0)]
[H: effectiveHP = HP + HPTemp]
[H: tMaxEffectiveHP = HPmax + HPtemp]

[H: state.Disabled = if((effectiveHP) == 0, 1, 0)]
[H: state.Staggered = if(HPNonLethalDMG == (effectiveHP) && HP > 0, 1, 0)]

[H: active = if( ((effectiveHP) >= HPNonLethalDMG) && ((effectiveHP) >= 0), 1, if( tDieHard, 1, 0) )]

[H: state.Unconscious = if( ( ( (effectiveHP) < 0 ) || ( HPNonLethalDMG > (effectiveHP) ) ) && !tDieHard, 1, state.Unconscious)]

[H: state.Prone = if( active && (state.Prone < 1), 0, 1)]
[H: state.Dying = if(((effectiveHP) > deathpoint) && ((effectiveHP) < 0), 1, 0)]
[H, IF( isNPC() && !tDieHard ): eval(if(state.Dying, 'setLayer("object")', '0'))]
[H: state.StableHP = if(((effectiveHP) >= 0), 0, state.StableHP)]

[H: state.Dead = if((effectiveHP) <= deathpoint, 1, 0)]
[H, IF(state.Dead), CODE: {
  [H: if(isNPC(), setLayer("object"), '0')]
  [H: state.Dying = 0]
  [H: state.Unconscious = 0]
  [H: state.Prone = 0]
  [H: state.StableHP = 0]
}]
[H: eval(if(state.Dead, 'removeFromInitiative()', '0'))]

[H, IF( active ): setLayer("token")]

[H: setBarVisible("HP",0)]
[H: setBarVisible("HPM",0)]
[H: setBarVisible("HPNonLethalDMG",0)]
[H: setBarVisible("HPMNonLethalDMG",0)]
[H: setBarVisible("HP",0)]
[H: setBarVisible("HPM",0)]
[H, if( state.Dead ), code: {
   [H: setBarVisible("HPdamage",0)]
   [H: setBarVisible("EmptyHP",0)]
};{
   [H, if( effectiveHP >= 0 ), code: {
      [H: bar.HPdamage = (tMaxEffectiveHP - effectiveHP) / tMaxEffectiveHP]
      [H: setBarVisible("EmptyHP",0)]
   };{
      [H: bar.HPdamage = max(0,(deathPoint - effectiveHP) / deathPoint) ]
      [H: bar.EmptyHP = 1]
   }]   
}]
[H, if( effectiveHP < 0 || state.Dead), code: { 
   [H: setBarVisible("NLD_HP",0) ]
   [H: setBarVisible("TempHP",0) ]
};{
   [H: bar.TempHP = bar.HPdamage + (HPtemp / tMaxEffectiveHP) ]
   [H: bar.NLD_HP = HPNonLethalDMG / tMaxEffectiveHP ]
}]

[H, IF(gTokenUncImgChange), CODE: {
    [H: tImageID= if( ( state.Dead || state.Unconscious ), getTokenHandout(), tIAID ) ]
    [H, IF(tImageID != ""): setTokenImage(tImageID)]
}]

!!
Now for the hard part, which isn't all that hard. Adding the new health bars. Follow these steps precisely.
  • Download and extract the Health Bar images: Fading Arc
  • Open your campaign properties and go to the Bars tab.
  • Set up the bars needed (Example)
    • NLD_HP - Type "NLD_HP" under name.
      • Set the type to Two Image
      • Click Add (top half) and locate the extracted file Health100.png and click Open.
      • Click Add, select NonLethal100.png and click Open
      • Now click Add (bottom half) to add the bar to the list. You're not done yet, but clicking OK at bottom will save to Campaign Properties. You must do this after all the bars have been added or you'll have to do this again.
    • TempHP - Type "TempHP" under name
      • The next three bars are done the same way. All you need to do is enter a differnt bar name and file.
      • Set the type to Single Image
      • Click Add (top half) and locate the extracted file Temp100.png and click Open.
      • Click Add (bottom half) to add the bar.
    • Rinse and Repeat for "EmptyHP" (EmptyLife.png) and "HPdamage" (Damage100.png)
    • Click OK to save work.
  • You're done, congratulations. Click HPChange while selecting a token, click okay and you'll see the HP bar change (assuming your token is setup correctly with hitpoints).
Here are a couple of preference tweaks you can do.
  • Non-detailed hp bar. Under each health bar, set the increment to the amount of detail you want to show for hp change. You can set Increment to 10, and the bar will only change every 10% of the total. Personally, I don't bother with this but other people may not want players eye-balling the effect of their damage in detail.
  • Check Mouseover if you only want the bar to show when moused-over.
  • Colors. You can download the original creation file at my Fading Arc thread and change border thickness, position, color or whatever.
||| Example |||
Image
Last edited by aliasmask on Fri Mar 18, 2011 8:52 pm, edited 1 time in total.

neofax
Great Wyrm
Posts: 1694
Joined: Tue May 26, 2009 8:51 pm
Location: Philadelphia, PA
Contact:

Re: [MOD] Fading Arc HP Meter (MT1.3b82 Campaign Macros r01)

Post by neofax »

Thank you! Works perfectly. I just added it to my rehash of Lindsay's FW for Pathfinder Society games.

TheNeonKnight
Kobold
Posts: 2
Joined: Mon Jan 11, 2010 11:15 am

Re: [MOD] Fading Arc HP Meter (MT1.3b82 Campaign Macros r01)

Post by TheNeonKnight »

Thanks!

User avatar
lmarkus001
Great Wyrm
Posts: 1867
Joined: Sat Mar 29, 2008 12:30 am
Location: Layfayette Hill, PA

Re: [MOD] Fading Arc HP Meter (MT1.3b82 Campaign Macros r01)

Post by lmarkus001 »

Added the graphics to my core framework. If I get time I will put in a campaign setup option that lets the GM choose this bar vs. original bar.

User avatar
Oryan77
Dragon
Posts: 452
Joined: Sun Feb 20, 2011 3:14 pm

Re: [MOD] Fading Arc HP Meter (MT1.3b82 Campaign Macros r01)

Post by Oryan77 »

I've been using the macro for these bars and I noticed 2 features that are missing. I'm not sure if it was intentional or if you were not aware of this. I figured I'd mention it in case you wanted to know.

1. When at full health, the NLD_HP meter does not appear when the token takes Non-Lethal Damage but has not taken any Lethal Damage yet.

2. When Non-Lethal Damage exceeds current hitpoints, the state only changes to prone, but it should also show the unconscious state (assuming it was meant to work like the D&D 3.5 rules).

User avatar
aliasmask
RPTools Team
Posts: 9023
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: [MOD] Fading Arc HP Meter (MT1.3b82 Campaign Macros r01)

Post by aliasmask »

Thanks for finding that. Here's the new code as it should be used in the framework:
||| subUpdateHPStatesBarsAliasmask |||

Code: Select all

@@ @subUpdateHPStatesBarsAliasmask
@PROPS@ fontColor=black ; autoExecute=true ; fontSize=11pt ; sortBy=16 ; color=pink ; playerEditable=false ; applyToSelected=false ; group=Utility ; tooltip= ; minWidth=200 ; 
[H: gTok = "Lib:GlobalsSRDPF"]
[H: tToken = getStrProp(macro.args, "Token")]

[H: gTokenUncImgChange = getLibProperty("TokenUncImgChange", gTok)]

[H: switchToken(tToken)]

[H, IF(gTokenUncImgChange), CODE: {
    [ tImageID = getTokenImage() ]
    [ tImageHID = getTokenHandout() ]
    [IF( tImageHID != tImageID ): Private = setStrProp(Private, "TokenImageAssetID", tImageID) ]
    [ tIAID = getStrProp(Private, "TokenImageAssetID")]
};{}]

[H: deathpoint = eval( string( getLibProperty( "DeathPoint", gTok ) ) )]

[H: tType = json.get( Race, "type" )]
[H: tSubtype = json.get( Race, "subtype" )]
[H: variantRDP = table( "SysVars", json.get( table( "SysVars", 0 ), "variantRaceDeathPoint" ) ) ]
[H, FOREACH( dp, variantRDP ), CODE: {
   [H: tDP = json.get( dp, "deathPoint" )]
   [H: typeArray = json.get( dp, "typeArray" )]
   [H: subtypeArray = json.get( dp, "subtypeArray" )]
   [H, FOREACH( t, typeArray ): deathpoint = if( t == tType, tDP, deathpoint )]
   [H, FOREACH( t, subtypeArray ): deathpoint = if( json.contains( tSubtype, t ), tDP, deathpoint )]
}]

[H: tDieHard = getStrProp(Feats, "DieHard")]
[H: tDieHard = if(tDieHard == "", 0, tDieHard)]
[H: disabledPoint = if( tDieHard, deathpoint, 0)]
[H: effectiveHP = HP + HPTemp]
[H: tMaxEffectiveHP = HPmax + HPtemp]

[H: state.Disabled = if((effectiveHP) == 0, 1, 0)]
[H: state.Staggered = if(HPNonLethalDMG == (effectiveHP) && HP > 0, 1, 0)]

[H: active = if( ((effectiveHP) >= HPNonLethalDMG) && ((effectiveHP) >= 0), 1, if( tDieHard, 1, 0) )]

[H: state.Unconscious = if( ( ( (effectiveHP) < 0 ) || ( HPNonLethalDMG > (effectiveHP) ) ) && !tDieHard, 1, state.Unconscious)]

[H: state.Prone = if( active && (state.Prone < 1), 0, 1)]
[H: state.Dying = if(((effectiveHP) > deathpoint) && ((effectiveHP) < 0), 1, 0)]
[H, IF( isNPC() && !tDieHard ): eval(if(state.Dying, 'setLayer("object")', '0'))]
[H: state.StableHP = if(((effectiveHP) >= 0), 0, state.StableHP)]
[H, if(state.StableHP): state.Dying = 0]

[H: state.Dead = if((effectiveHP) <= deathpoint, 1, 0)]
[H, IF(state.Dead), CODE: {
  [H: if(isNPC(), setLayer("object"), '0')]
  [H: state.Dying = 0]
  [H: state.Unconscious = 0]
  [H: state.Prone = 0]
  [H: state.StableHP = 0]
};{}]

[H, if(effectiveHP - HPNonLethalDMG > 0), code: {
   [H: state.Dying = 0]
   [H: state.Unconscious = 0]
   [H: state.StableHP = 0]
}; {}]

[H: eval(if(state.Dead, 'removeFromInitiative()', '0'))]

[H, IF( active ): setLayer("token")]

[H: setBarVisible("HP",0)]
[H: setBarVisible("HPM",0)]
[H: setBarVisible("HPNonLethalDMG",0)]
[H: setBarVisible("HPMNonLethalDMG",0)]

[H, if( state.Dead ), code: {
   [H: setBarVisible("HPdamage",0)]
   [H: setBarVisible("EmptyHP",0)]
}; {
   [H, if( effectiveHP >= 0 ), code: {
      [H: bar.HPdamage = (tMaxEffectiveHP - effectiveHP) / tMaxEffectiveHP]
      [H: setBarVisible("EmptyHP",0)]
   }; {
      [H: bar.HPdamage = max(0,(deathPoint - effectiveHP) / deathPoint) ]
      [H: bar.EmptyHP = 1]
   }]   
}]
[H, if( effectiveHP < 0 || state.Dead), code: {
   [H: setBarVisible("NLD_HP",0) ]
   [H: setBarVisible("TempHP",0) ]
}; {
   [H: bar.TempHP = bar.HPdamage + (HPtemp / tMaxEffectiveHP) ]
   [H: bar.NLD_HP = HPNonLethalDMG / tMaxEffectiveHP ]
}]

[H, if(HP == HPmax && effectiveHP == HP && HPNonLethalDMG == 0), code: {
   [H: "<!-- Turn off all the bars when at max HP with no HP mods -->"]
   [H: setBarVisible("TempHP",0)]
   [H: setBarVisible("HPdamage",0)]
   [H: setBarVisible("NLD_HP",0)]
}; {}]

[H, IF(gTokenUncImgChange), CODE: {
    [H: tImageID= if( ( state.Dead || state.Unconscious ), getTokenHandout(), tIAID ) ]
    [H, IF(tImageID != ""): setTokenImage(tImageID)]
};{}]

!!

madmaxneo
Giant
Posts: 148
Joined: Thu Jun 20, 2013 5:04 pm
Location: NW Indiana

Re: [MOD] Fading Arc HP Meter (MT1.3b82 Campaign Macros r01)

Post by madmaxneo »

Wow, that is a lot of code. I was going to try to implement something like this into my HARP game but there are so many variables relating to the game this is based on (4ed D&D?) I wouldn't know where to start.
Aliasmask, Is it possible I could get some help in this?
Actually, what I want to do is probably much more simple that this code. I don't need the non-lethal, and other types of damage, just damage, which fades as it does in your description above. I would also like to have the token states that automatically show up when one is unconscious, then dying, then dead.

Also based on my recent reply to you in my topic "How do I import new health bars..." I am looking to add at least two more bars, experience and power point use (magic points). But one thing at a time.

Bruce

User avatar
aliasmask
RPTools Team
Posts: 9023
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: [MOD] Fading Arc HP Meter (MT1.3b82 Campaign Macros r01)

Post by aliasmask »

I think once you understand how bars work, it should be easy. I'm stacking several bars to get my various colors, so that's part of the complication. Setting the value from 0 to 1 (0 to 100%) sets how much of the top is shown. The is true for all but the multi-image bar. That will divide up the number of images and show the closest the next highest one.

So, if you set a bar at 0.5. The bar moves halfway. For one tone, two tone and two image it goes from right to left/top to bottom. The single image goes from left to right/bottom to top as the number decreases. For multi image, the who image switches. You need at least 2 images and you have to set your increment to match the number of images. Bottom image in list is top image with highest percent and Top image is always 0. Any number of images in between are divided up. So, if you have 5 images (full bar, empty bar, increment 1, increment 2, increment 3) then your increments are at 0.25 (1.00,0.75,0.50,0.25,0 - 5 values).

To keep the example simple, lets just create a solid bar that is green and call it Health.

Code: Select all

[H: maxHP = 100]
[H: currentHP = 50]
[H: bar.Health = currentHP / maxHP]

[H: unconscious = 0]
[H: dead = -10]

[H, if(currentHP <= dead): state.Dead = 1; state.Dead = 0]
[H, if(currentHP <= unconscious && ! state.Dead): state.Unconscious = 1; state.Unconscious = 0]
I put the Dead check before unconscious because I don't want people to know I'm sleeping when dead. So, it turns off the unconscious state when dead. To remove a bar use Wiki: setBarVisible() to 0.

You would need to create states for "Unconscious" and "Dead" that you want. Just a note about adding bars and states. Be sure to click the correct "Update" button and then "Okay" to make sure it's saved when done.

I also use single state names because I can then use them in variables like state.stateName, not state.state name (which would be wrong).

madmaxneo
Giant
Posts: 148
Joined: Thu Jun 20, 2013 5:04 pm
Location: NW Indiana

Re: [MOD] Fading Arc HP Meter (MT1.3b82 Campaign Macros r01)

Post by madmaxneo »

I was able to figure out how to do the power point and experience bars. It all works pretty good so far. I have a few questions. I will post those in a new thread.


Bruce

Post Reply

Return to “D&D 3.5/Pathfinder 1e Campaign Macros”