Check die result from eval(someproperty) and return a true/false if a certain die face is rolled
Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice
Check die result from eval(someproperty) and return a true/false if a certain die face is rolled
so the game we are playing is dark heresy 2nd edition and im setting up macros for everyone. i have stumbled along just fine until i reached this question.
my campaign property is filled in as such: 2d10 + [r: 2 + STB + USTB]
i roll this value in my macros with eval(getProperty("Weapon1Damage"))]
this works no problem to get me the total value.
what i need to check is if one of those 2d10 ended up with a showing 10.
if so i need to roll a 1d5 for critical damage.
it also can only happen once so if both die roll 10 i still only roll 1d5.
is there a way to do this?
my campaign property is filled in as such: 2d10 + [r: 2 + STB + USTB]
i roll this value in my macros with eval(getProperty("Weapon1Damage"))]
this works no problem to get me the total value.
what i need to check is if one of those 2d10 ended up with a showing 10.
if so i need to roll a 1d5 for critical damage.
it also can only happen once so if both die roll 10 i still only roll 1d5.
is there a way to do this?
Re: Check die result from eval(someproperty) and return a true/false if a certain die face is rolled
just to be clear you are aware that theres a W40K framework? granted its based on DH 1 but we've implemented RT, DW, OW and BC systems as well, so most rules should be covered by it!
and yes theres' obviously a way to do what you want but that would require a more step like macro with a couple of if statements and Im guessing that the '2' in '2d10' is arbitrary depending on weapon in use so a loop is required as well!
else you would get something like
(youll have to add the [] yourself)
and yes theres' obviously a way to do what you want but that would require a more step like macro with a couple of if statements and Im guessing that the '2' in '2d10' is arbitrary depending on weapon in use so a loop is required as well!
else you would get something like
Code: Select all
d1 = 1d10
d2 = 1d10
crit = if(d1==10 || d2==10, 1d5,0)
rolled damage is: d1+d2+stb+ustb
if(crit): "Crit is rolled for: "+crit+" damage"
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: Check die result from eval(someproperty) and return a true/false if a certain die face is rolled
so yea i figured that wh40k had framework but im not the gm. im throwing the gm macros that i create for his game.
let me be more specific tho. the campaign property weapon1damage has this : (numDice)d10 + (bonuses)
what im trying to do is seperate the numDice from the bonuses, check the rolled values and such while depending on the property itself. so i need to have a specific way to pull and seperate that data. i want the person to be able to modify his sheet and not have to worry about his macro.
let me be more specific tho. the campaign property weapon1damage has this : (numDice)d10 + (bonuses)
what im trying to do is seperate the numDice from the bonuses, check the rolled values and such while depending on the property itself. so i need to have a specific way to pull and seperate that data. i want the person to be able to modify his sheet and not have to worry about his macro.
Re: Check die result from eval(someproperty) and return a true/false if a certain die face is rolled
getRolled() will give you the individual die rolls as a string list.
listContains() will tell you how many times a particular result is in that string list.
If the listContains() returns more than one, you have your crit.
listContains() will tell you how many times a particular result is in that string list.
If the listContains() returns more than one, you have your crit.
Re: Check die result from eval(someproperty) and return a true/false if a certain die face is rolled
awesome ill try it out real quick.
Re: Check die result from eval(someproperty) and return a true/false if a certain die face is rolled
this was exactly what i needed. thanks my dude. big help.
Re: Check die result from eval(someproperty) and return a true/false if a certain die face is rolled
I have a similar need for a Hero framework I've been dabbling with. Happy to help.
Re: Check die result from eval(someproperty) and return a true/false if a certain die face is rolled
well i seem to have run into a strange problem. when using listcontains it seems to not see every number that matches its parameter. for instance i roll 2d10 and get 5 and 10 but when list contains searches it for 10's it finds nothing. but it works if i use more dice. if i roll 10d10 and get only one or more 10s then it sees it and works correctly. im very confused.
Re: Check die result from eval(someproperty) and return a true/false if a certain die face is rolled
here is the code for the area where the issue is. i have a couple of lines to show me what numbers are being stored but do nothing else.
and i get outcomes like this:
[6] 0 0 The Chainsword deals 8 Rending Damage to target's left leg. Sadly, there was no Righteous Fury in this attack.
[1] 0 0 The Chainsword deals 3 Rending Damage to target's left arm. Sadly, there was no Righteous Fury in this attack.
[10] 0 0 The Chainsword deals 12 Rending Damage to target's body. Sadly, there was no Righteous Fury in this attack.
[3] 0 0 The Chainsword deals 5 Rending Damage to target's body. Sadly, there was no Righteous Fury in this attack.
[1] 0 0 The Chainsword deals 3 Rending Damage to target's left leg. Sadly, there was no Righteous Fury in this attack.
Code: Select all
[COUNT(numberOfHits, ""),CODE:
{
<br>
[h: didCrit = 0]
[h: hitLocation = 1d100]
[h: critDamage = ""]
[h:switchToken(targetName)]
[h: armor = if(hitLocation >= 1 && hitLocation <= 10, armorHead, armor)]
[h: armor = if(hitLocation >= 11 && hitLocation <= 20, armorRightArm, armor)]
[h: armor = if(hitLocation >= 21 && hitLocation <= 30, armorLeftArm, armor)]
[h: armor = if(hitLocation >= 31 && hitLocation <= 70, armorBody, armor)]
[h: armor = if(hitLocation >= 71 && hitLocation <= 85, armorRightLeg, armor)]
[h: armor = if(hitLocation >= 86 && hitLocation <= 100, armorLeftLeg, armor)]
[h: clearRolls()]
[h: penetration = armor - weaponPen]
[h:switchToken(currentT)]
[h: damageByWeapon = eval(getProperty("Weapon1Damage"))]<br>
[r: getRolled()]
[r: listContains(getRolled(), 10)]
[r: didCrit = if(listContains(getRolled(), 10) >= 1, 1, didCrit)]<br>
[h: remainingArmor = if(penetration > 0, penetration, 0)]
<!-- output -->
[h:switchToken(targetName)]
[r: "The "]
[r: weaponName]
[r: " deals "]
<b><font color="blue">[r: damageByWeapon - (remainingArmor + TB)]</color></b>
[r: " "]
<b><font color="green">[r: damageType]</color></b>
[r: " to target's "]
[r: if((hitLocation >= 1 && hitLocation <= 10),"head.","")]
[r: if((hitLocation >= 11 && hitLocation <= 20),"right arm.","")]
[r: if((hitLocation >= 21 && hitLocation <= 30),"left arm.","")]
[r: if((hitLocation >= 31 && hitLocation <= 70),"body.","")]
[r: if((hitLocation >= 71 && hitLocation <= 85),"right leg.","")]
[r: if((hitLocation >= 86 && hitLocation <= 100),"left leg.","")]
[h: critPreText = "Sadly, there was no Righteous Fury"]
[h: critPostText = " in this attack."]
[h, if(didCrit == true), code:
{
[h: critDamage = roll(1, 5)]
[h: critPreText = "The " + weaponName + " also deals "]
[h: critPostText = " critical " + damageType + " to target's "]
[h: critPostText = if((hitLocation >= 1 && hitLocation <= 10), critPostText + "head.",critPostText)]
[h: critPostText = if((hitLocation >= 11 && hitLocation <= 20), critPostText + "right arm.",critPostText)]
[h: critPostText = if((hitLocation >= 21 && hitLocation <= 30), critPostText + "left arm.",critPostText)]
[h: critPostText = if((hitLocation >= 31 && hitLocation <= 70), critPostText + "body.",critPostText)]
[h: critPostText = if((hitLocation >= 71 && hitLocation <= 85), critPostText + "right leg.",critPostText)]
[h: critPostText = if((hitLocation >= 86 && hitLocation <= 100), critPostText + "left leg.",critPostText)]
};{""}]
<br>
[r: critPreText]
<b><font color="red">[r: critDamage]</color></b>
[r: critPostText]
}]
[6] 0 0 The Chainsword deals 8 Rending Damage to target's left leg. Sadly, there was no Righteous Fury in this attack.
[1] 0 0 The Chainsword deals 3 Rending Damage to target's left arm. Sadly, there was no Righteous Fury in this attack.
[10] 0 0 The Chainsword deals 12 Rending Damage to target's body. Sadly, there was no Righteous Fury in this attack.
[3] 0 0 The Chainsword deals 5 Rending Damage to target's body. Sadly, there was no Righteous Fury in this attack.
[1] 0 0 The Chainsword deals 3 Rending Damage to target's left leg. Sadly, there was no Righteous Fury in this attack.
Re: Check die result from eval(someproperty) and return a true/false if a certain die face is rolled
As you found in your other post on the same issue, Wiki: getRolled() returns a JSON array.
You'll want to use Wiki: json.indexOf(), Wiki: json.count() or other functions to check for values.
You'll want to use Wiki: json.indexOf(), Wiki: json.count() or other functions to check for values.