Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[Script] Hackmaster Criticals

1463587432

Edited 1465431896
I'm trying to make a script to automatically determine the effect of a critical hit in Hackmaster. There's a couple different variables that go into that. I'd like the script to ask the player for those values with popup box like what you get with a prompt() or a macro's ?{}. Searching on the forums showed there wasn't a way to do that two years ago, but is there a way now? EDIT: Since I finished here's the link to the GitHub in the first post. <a href="https://gist.github.com/GoCorral/1297d794e80e78f6238e2bd6c7661e37" rel="nofollow">https://gist.github.com/GoCorral/1297d794e80e78f6238e2bd6c7661e37</a>
1463590869
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
As a thought, you could have the script look for the value through a command like !crit dieroll(i.e. 1d20) effect1 ... effectn. And then save the script call in a macro that would be setup like: !crit 1d20+2 ?{Effect1|Drop down or textbox entry} ... ?{Effectn|Drop down or textbox entry}. This would utilize the script for applying the effects, but allow you to utilize the pop-ups available in the VTT.
Ooo! That should work perfectly! Thanks!
1463606518
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Glad it was what you were looking for.
Do you want to put all the tables into the script too? If not you can do the basics with a simple macro. My friend uses this. &{template:default} {{name=Critical Hit!}} {{Severitiy= [[?{attack roll|1} + d6!p-1 - ?{defense roll|1} + ?{damage|1} - ?{DR|1} ]]}} {{Location= [[?{location| d10000}]]}}
Yeah, I wanted all the tables there as well. I've got the macro setup right now similar to how you have it, but with an API command. Inputing all the table info to the API script is taking a while though. I'll update here and on the Hackmaster forums when its done so other people can use it. Should make critical hits a lot easier. I'm planning on doing one for fumbles too.
Finished at last! The code is triggered by a macro which asks the user for the values relevant to the critical hit. Those values would be the attacker and defender's sizes, the attack roll, the defense roll, the damage roll, the defender's DR, and the weapon type. Here's the macro which I just dubbed "Critical." !Critical ?{Enter the number corresponding to the ATTACKER's size. Tiny (1), Small (2), Medium (3), Large (4), Huge (5), Gargantuan (6), Enormous (7), and Colossal (8)|1|2|3|4|5|6|7|8}, ?{Enter the number corresponding to the DEFENDER's size. Tiny (1), Small (2), Medium (3), Large (4), Huge (5), Gargantuan (6), Enormous (7), and Colossal (8)|1|2|3|4|5|6|7|8}, ?{Enter the attack roll after all modifiers have been applied.}, ?{Enter the defense roll after all modifiers have been applied.}, ?{Enter the damage, but do not deduct the defender's DR.}, ?{Enter the defender's DR.}, ?{What kind of weapon did the attack use? Crushing (1), Hacking (2), and Piercing (3)|1|2|3} After the macro is filled out it triggers the script with a line that looks like this. The script could also be triggered if this sequence of numbers were entered manually into the chat. !Critical [atksize], [defsize], [atkroll], [defroll], [atkdmg], [defdr], [weapontype] The script then goes through an enormous tree of if/else statements to spit out the critical hit result along with the location roll and the severity if you want to crosscheck it in the Hackmaster GMG. There was probably a more elegant way of doing the script than an if/else tree, but I'm new to programming and learning how to use an array for this seemed like it was more trouble than it was worth. Since I'm new to programming I don't really know how to upload this thing to github or whatever the appropriate thing to do is. I would drop the script here, but it ended up being ~2500 lines of code which I believe is too big for the forums. If anyone's got any tips for getting it onto github and sharing it I'd appreciate it. And a big thanks to Warklaw for having a setup that I used in my code for extracting the variables from the macro.&nbsp; <a href="https://github.com/Warklaw/roll20/blob/master/rol" rel="nofollow">https://github.com/Warklaw/roll20/blob/master/rol</a>...
Congrats, Isaac S. !
Thanks Silvyre! Got it up on GitHub. I was just a little exhausted after finishing debugging to learn how to do that myself. <a href="https://gist.github.com/GoCorral/1297d794e80e78f6238e2bd6c7661e37" rel="nofollow">https://gist.github.com/GoCorral/1297d794e80e78f6238e2bd6c7661e37</a>
Excellent work and thanks a bunch.