Need help coding 3 types of hit points

Thoughts, Help, Feature Requests, Bug Reports, Developing code for...

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. :)
gotenl5
Kobold
Posts: 6
Joined: Sat Dec 28, 2013 10:16 pm

Need help coding 3 types of hit points

Post by gotenl5 »

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)

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Need help coding 3 types of hit points

Post by wolph42 »

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?
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]
}]
 
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'?

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

Re: Need help coding 3 types of hit points

Post by aliasmask »

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.")]

!!

gotenl5
Kobold
Posts: 6
Joined: Sat Dec 28, 2013 10:16 pm

Re: Need help coding 3 types of hit points

Post by gotenl5 »

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

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

Re: Need help coding 3 types of hit points

Post by aliasmask »

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.

gotenl5
Kobold
Posts: 6
Joined: Sat Dec 28, 2013 10:16 pm

Re: Need help coding 3 types of hit points

Post by gotenl5 »

aliasmask 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.")]

!!
this is what it say when i use this
Illegal argument type java.lang.String, expecting java.math.BigDecimal

gotenl5
Kobold
Posts: 6
Joined: Sat Dec 28, 2013 10:16 pm

Re: Need help coding 3 types of hit points

Post by gotenl5 »

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?
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]
}]
 
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'?

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

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

Re: Need help coding 3 types of hit points

Post by aliasmask »

gotenl5 wrote:
aliasmask 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.")]

!!
this is what it say when i use this
Illegal argument type java.lang.String, expecting java.math.BigDecimal
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
Kobold
Posts: 6
Joined: Sat Dec 28, 2013 10:16 pm

Re: Need help coding 3 types of hit points

Post by gotenl5 »

aliasmask 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.
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 much :D

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Need help coding 3 types of hit points

Post by wolph42 »

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 :D). I would look at both of them so you can get to understand a bit was is going on.

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

Re: Need help coding 3 types of hit points

Post by aliasmask »

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 :D). I would look at both of them so you can get to understand a bit was is going on.
There's actually an error in logic with your code, but I bet you can find it. ;)

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Need help coding 3 types of hit points

Post by wolph42 »

aliasmask wrote:
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 :D). I would look at both of them so you can get to understand a bit was is going on.
There's actually an error in logic with your code, but I bet you can find it. ;)
urgh...lines are the wrong way round...

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>
 
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?

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

Re: Need help coding 3 types of hit points

Post by aliasmask »

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?
For the output. Saving each type of damage could be important.

AirPower25
Kobold
Posts: 3
Joined: Mon May 10, 2010 6:36 pm

Re: Need help coding 3 types of hit points

Post by AirPower25 »

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.

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Need help coding 3 types of hit points

Post by wolph42 »

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.

Post Reply

Return to “MapTool”