Need help coding 3 types of hit points
Moderators: dorpond, trevor, Azhrei
Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior.
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior.
Need help coding 3 types of hit points
hi i need help coding 3 types of hit points into one code, not good at coding any help would be greatly appreciated.
so hit points in order.
Stamina Points (this is always reduce by damage like hp) the codes i have for this is (SPmax) for max stamina points and (SP) for how many stamina points they have
Hit Points (this is like your normal hit points but the damage doesn't affect this to all the stamina points are gone or O stamina points, so lets say they have 10 stamina and they take 15 points of damage, the 5 points of damage that's left is taken from hit points) the codes i have for this is (HPmax) for max hit points and (HP) for how many hit points they have
Temporary hit points this is just like any temporary hit points from 3.0/3.5/pathfinder/5th, so if a player has gain temporary hit points, this becomes first on the list from witch is reduced, the code i have for this is (HPtemp)
so hit points in order.
Stamina Points (this is always reduce by damage like hp) the codes i have for this is (SPmax) for max stamina points and (SP) for how many stamina points they have
Hit Points (this is like your normal hit points but the damage doesn't affect this to all the stamina points are gone or O stamina points, so lets say they have 10 stamina and they take 15 points of damage, the 5 points of damage that's left is taken from hit points) the codes i have for this is (HPmax) for max hit points and (HP) for how many hit points they have
Temporary hit points this is just like any temporary hit points from 3.0/3.5/pathfinder/5th, so if a player has gain temporary hit points, this becomes first on the list from witch is reduced, the code i have for this is (HPtemp)
Re: Need help coding 3 types of hit points
so if someone gets a blow:
- the first part of the hit is deducted from HPtemp
- the second part of the hit is deducted from SP (when HPtemp hits 0)
- the third and last part of the hit is deducted from HP (when SP hits 0).
Is this correct?
Then the next question is what if HP hits 0 and there's still hitpoints to deduct? does HP remain 0 or do you go 'down under'?
- the first part of the hit is deducted from HPtemp
- the second part of the hit is deducted from SP (when HPtemp hits 0)
- the third and last part of the hit is deducted from HP (when SP hits 0).
Is this correct?
if so
UNTESTED
Code: Select all
[HPt=10]
[SP=10]
[HP=10]
[blow = 35]
[if(blow > HPt), CODE:{
[HPt = 0]
[blow = blow - HPt]
};{
[blow = 0]
[HPt = HPt - blow]
}]
[if(blow > SP && blow > 0), CODE:{
[SP = 0]
[blow = blow - SP]
};{
[blow = 0]
[SP = SP - blow]
}]
[if(blow > HP && blow > 0), CODE:{
[HP = 0]
[blow = blow - HP]
};{
[blow = 0]
[HP = HP - blow]
}]
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: Need help coding 3 types of hit points
So, the order is TempHP > SP > HP when applying damage?
Code: Select all
@@ @damageTarget
<!-- damageTarget(damage) -->
[H: damage = arg(0)]
[H: damageLeft = damage]
[H, if(HPtemp), code: {
[H: tempDmg = min(HPtemp,damageLeft)]
[H: HPtemp = HPtemp - tempDmg]
[H: damageLeft = damageLeft - tempDmg]
};{
[H: tempDmg = 0]
}]
[H, if(SP && damageLeft), code: {
[H: spDmg = min(SP,damageLeft)]
[H: SP = SP - spDmg]
[H: damageLeft = damageLeft - spDmg]
};{
[H: spDmg = 0]
}]
[H, if(damageLeft), code: {
[H: hpDmg = damageLeft]
[H: HP = HP - hpDmg]
};{
[H: hpDmg = 0]
}]
[H: output = strformat("Target takes %{damage} damage for %{tempDmg} Temp | %{spDmg} SP | %{hpDmg} HP damage.")]
!!
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Need help coding 3 types of hit points
no its like normal hit points and temporary hit points like 3.5 and pathfinder if theres any temporary hit points then the damage reduces this first but it theres no temp hit points then it reduces stamina points first and then hit points, so if you had something like this
50 SP
50 HP
and the monster deals 60 points of damage then its hit points would end up like this
0 SP
40 HP
if there was 50 temporary hit points it would be like this
50 HPtemp
50 SP
50 HP
and the 60 points of damage would reduce it like this
0 HPtemp
40 SP
50 HP
50 SP
50 HP
and the monster deals 60 points of damage then its hit points would end up like this
0 SP
40 HP
if there was 50 temporary hit points it would be like this
50 HPtemp
50 SP
50 HP
and the 60 points of damage would reduce it like this
0 HPtemp
40 SP
50 HP
Re: Need help coding 3 types of hit points
That's what my code does. It reduces temp to 0, then uses the remainder to reduce SP and then HP if any are left.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Need help coding 3 types of hit points
this is what it say when i use thisaliasmask wrote:So, the order is TempHP > SP > HP when applying damage?
Code: Select all
@@ @damageTarget <!-- damageTarget(damage) --> [H: damage = arg(0)] [H: damageLeft = damage] [H, if(HPtemp), code: { [H: tempDmg = min(HPtemp,damageLeft)] [H: HPtemp = HPtemp - tempDmg] [H: damageLeft = damageLeft - tempDmg] };{ [H: tempDmg = 0] }] [H, if(SP && damageLeft), code: { [H: spDmg = min(SP,damageLeft)] [H: SP = SP - spDmg] [H: damageLeft = damageLeft - spDmg] };{ [H: spDmg = 0] }] [H, if(damageLeft), code: { [H: hpDmg = damageLeft] [H: HP = HP - hpDmg] };{ [H: hpDmg = 0] }] [H: output = strformat("Target takes %{damage} damage for %{tempDmg} Temp | %{spDmg} SP | %{hpDmg} HP damage.")] !!
Illegal argument type java.lang.String, expecting java.math.BigDecimal
Re: Need help coding 3 types of hit points
wolph42 wrote:so if someone gets a blow:
- the first part of the hit is deducted from HPtemp
- the second part of the hit is deducted from SP (when HPtemp hits 0)
- the third and last part of the hit is deducted from HP (when SP hits 0).
Is this correct?
Then the next question is what if HP hits 0 and there's still hitpoints to deduct? does HP remain 0 or do you go 'down under'?if so
UNTESTEDCode: Select all
[HPt=10] [SP=10] [HP=10] [blow = 35] [if(blow > HPt), CODE:{ [HPt = 0] [blow = blow - HPt] };{ [blow = 0] [HPt = HPt - blow] }] [if(blow > SP && blow > 0), CODE:{ [SP = 0] [blow = blow - SP] };{ [blow = 0] [SP = SP - blow] }] [if(blow > HP && blow > 0), CODE:{ [HP = 0] [blow = blow - HP] };{ [blow = 0] [HP = HP - blow] }]
no its like normal hit points and temporary hit points like 3.5 and pathfinder if theres any temporary hit points then the damage reduces this first but it theres no temp hit points then it reduces stamina points first and then hit points, so if you had something like this
50 SP
50 HP
and the monster deals 60 points of damage then its hit points would end up like this
0 SP
40 HP
if there was 50 temporary hit points it would be like this
50 HPtemp
50 SP
50 HP
and the 60 points of damage would reduce it like this
0 HPtemp
40 SP
50 HP
Re: Need help coding 3 types of hit points
You'll have to post your code for me to see the issue. But the above assumes all the values have values and are not blank. That error suggests that some value is blank and should contain and numeric value.gotenl5 wrote:this is what it say when i use thisaliasmask wrote:So, the order is TempHP > SP > HP when applying damage?
Code: Select all
@@ @damageTarget <!-- damageTarget(damage) --> [H: damage = arg(0)] [H: damageLeft = damage] [H, if(HPtemp), code: { [H: tempDmg = min(HPtemp,damageLeft)] [H: HPtemp = HPtemp - tempDmg] [H: damageLeft = damageLeft - tempDmg] };{ [H: tempDmg = 0] }] [H, if(SP && damageLeft), code: { [H: spDmg = min(SP,damageLeft)] [H: SP = SP - spDmg] [H: damageLeft = damageLeft - spDmg] };{ [H: spDmg = 0] }] [H, if(damageLeft), code: { [H: hpDmg = damageLeft] [H: HP = HP - hpDmg] };{ [H: hpDmg = 0] }] [H: output = strformat("Target takes %{damage} damage for %{tempDmg} Temp | %{spDmg} SP | %{hpDmg} HP damage.")] !!
Illegal argument type java.lang.String, expecting java.math.BigDecimal
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Need help coding 3 types of hit points
ok i got it to work lol like i say im bad with coding and it takes me a while to figure out, so now its doing what i wanted it to do thanks you very muchaliasmask wrote:That's what my code does. It reduces temp to 0, then uses the remainder to reduce SP and then HP if any are left.
Re: Need help coding 3 types of hit points
same here: that's what my code does. Actually AM's and mine code are very similar with a slightly different approach (and I ninja'd him ). I would look at both of them so you can get to understand a bit was is going on.
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: Need help coding 3 types of hit points
There's actually an error in logic with your code, but I bet you can find it.wolph42 wrote:same here: that's what my code does. Actually AM's and mine code are very similar with a slightly different approach (and I ninja'd him ). I would look at both of them so you can get to understand a bit was is going on.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Need help coding 3 types of hit points
urgh...lines are the wrong way round...aliasmask wrote:There's actually an error in logic with your code, but I bet you can find it.wolph42 wrote:same here: that's what my code does. Actually AM's and mine code are very similar with a slightly different approach (and I ninja'd him ). I would look at both of them so you can get to understand a bit was is going on.
here's the correction:
Code: Select all
[h:HPt=10]
[h:SP=10]
[h:HP=10]
[h:blow = 35]
[h,if(blow > HPt), CODE:{
[blow = blow - HPt]
[HPt = 0]
};{
[HPt = HPt - blow]
[blow = 0]
}]
[h,if(blow > SP && blow > 0), CODE:{
[blow = blow - SP]
[SP = 0]
};{
[SP = SP - blow]
[blow = 0]
}]
[h,if(blow > HP && blow > 0), CODE:{
[blow = blow - HP]
[HP = 0]
};{
[HP = HP - blow]
[blow = 0]
}]
[HPt]<br>
[SP]<br>
[HP]<br>
[blow]<br>
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: Need help coding 3 types of hit points
For the output. Saving each type of damage could be important.wolph42 wrote:In the process I had a better look at your code and I cannot help but wondering: why on earth do you do it so complicated?
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
-
- Kobold
- Posts: 3
- Joined: Mon May 10, 2010 6:36 pm
Re: Need help coding 3 types of hit points
To go further on this, since this is just the HP system used by Starfinder, how would I go about tying this code to depleting bars? So, lets say the names of the bars are 'Stamina' and 'HP', one on the top and one on the bottom.
Re: Need help coding 3 types of hit points
you would need these:Category:Bar_Function
then you could get e.g.
[setBar("Hitpoints", HP/HPMax)]
for a bar created with the name: "Hitpoints" (in the campaign settings).
IRC you can also do
[bar.Hitpoints=HP/HPMax]
where HP is the current HP and HPMax the max hitpoints.
then you could get e.g.
[setBar("Hitpoints", HP/HPMax)]
for a bar created with the name: "Hitpoints" (in the campaign settings).
IRC you can also do
[bar.Hitpoints=HP/HPMax]
where HP is the current HP and HPMax the max hitpoints.
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS