RPTools.net

Discussion and Support

Skip to content

It is currently Tue Nov 21, 2017 3:22 am 




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. :)



Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

Previous topic | Next topic 

  Print view

Author Message
 Offline
Kobold
 
Joined: Sat Dec 28, 2013 10:16 pm
Posts: 6
 Post subject: Need help coding 3 types of hit points
PostPosted: Mon Aug 21, 2017 2:27 pm 
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)


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 9419
Location: Netherlands
 Post subject: Re: Need help coding 3 types of hit points
PostPosted: Mon Aug 21, 2017 3:05 pm 
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?

UNTESTED
Code:
[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'?

_________________
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC

My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent and
DPI.
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


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7948
Location: Bay Area
 Post subject: Re: Need help coding 3 types of hit points
PostPosted: Mon Aug 21, 2017 3:12 pm 
So, the order is TempHP > SP > HP when applying damage?

Code:
@@ @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:


Top
 Profile  
 
 Offline
Kobold
 
Joined: Sat Dec 28, 2013 10:16 pm
Posts: 6
 Post subject: Re: Need help coding 3 types of hit points
PostPosted: Tue Aug 22, 2017 4:36 pm 
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


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7948
Location: Bay Area
 Post subject: Re: Need help coding 3 types of hit points
PostPosted: Tue Aug 22, 2017 4:39 pm 
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:


Top
 Profile  
 
 Offline
Kobold
 
Joined: Sat Dec 28, 2013 10:16 pm
Posts: 6
 Post subject: Re: Need help coding 3 types of hit points
PostPosted: Tue Aug 22, 2017 4:41 pm 
aliasmask wrote:
So, the order is TempHP > SP > HP when applying damage?

Code:
@@ @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


Top
 Profile  
 
 Offline
Kobold
 
Joined: Sat Dec 28, 2013 10:16 pm
Posts: 6
 Post subject: Re: Need help coding 3 types of hit points
PostPosted: Tue Aug 22, 2017 4:43 pm 
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?

UNTESTED
Code:
[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


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7948
Location: Bay Area
 Post subject: Re: Need help coding 3 types of hit points
PostPosted: Tue Aug 22, 2017 4:47 pm 
gotenl5 wrote:
aliasmask wrote:
So, the order is TempHP > SP > HP when applying damage?

Code:
@@ @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.

_________________
Downloads:


Top
 Profile  
 
 Offline
Kobold
 
Joined: Sat Dec 28, 2013 10:16 pm
Posts: 6
 Post subject: Re: Need help coding 3 types of hit points
PostPosted: Tue Aug 22, 2017 4:54 pm 
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


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 9419
Location: Netherlands
 Post subject: Re: Need help coding 3 types of hit points
PostPosted: Tue Aug 22, 2017 5:18 pm 
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.

_________________
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC

My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent and
DPI.
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


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7948
Location: Bay Area
 Post subject: Re: Need help coding 3 types of hit points
PostPosted: Tue Aug 22, 2017 6:15 pm 
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. ;)

_________________
Downloads:


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 9419
Location: Netherlands
 Post subject: Re: Need help coding 3 types of hit points
PostPosted: Wed Aug 23, 2017 4:00 am 
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:
[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?

_________________
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC

My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent and
DPI.
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


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7948
Location: Bay Area
 Post subject: Re: Need help coding 3 types of hit points
PostPosted: Wed Aug 23, 2017 6:15 am 
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.

_________________
Downloads:


Top
 Profile  
 
 Offline
Kobold
 
Joined: Mon May 10, 2010 5:36 pm
Posts: 3
 Post subject: Re: Need help coding 3 types of hit points
PostPosted: Mon Aug 28, 2017 9:23 am 
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.


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Fri Mar 20, 2009 4:40 am
Posts: 9419
Location: Netherlands
 Post subject: Re: Need help coding 3 types of hit points
PostPosted: Mon Aug 28, 2017 1:02 pm 
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.

_________________
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC

My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent and
DPI.
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 243 on Sun Nov 04, 2012 6:14 am

Users browsing this forum: No registered users and 1 guest





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman