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

Question about a script/macro

Hello. I have a question about a script or macro that may be able to do attack and calculate everything with just one click. I explain myself better down. Let’s say I have a character that encounter an orc in the middle of the forest and a combat encounter start. The player decide to kill the orc and use his sword to kill it. So what I wonder is if there is a macro or script that do this. 1 .The player click on a button “attack” 2 .After he press “attack” he may target the orc token 3 .He click on the Orc and automatic roll for his Weapon Skill to see if he succeed or fail. Let say he have to roll below 35% to make a successful attack, if he roll over 35 he fail his attack. He roll 27 so attack sucess 4 .The Orc wich is not a stranger to combat automatic roll for parry, he have to roll below 40 to be able to parry. In this case he roll 42 and fail. 5 .Damage is automatic calculated, for simplicity let’s say that damage for sword is 1d10+his strength. In this case he have train a lot in the gym so he have a strength of 5. He roll an 8 so he will make 13 points of damage. 6. The 13 points of damage are mitigated by the orc Amor of 4 and his toughness of 5 so he take actual damage of 4. 7. Those 4 points of damage are automatic taken away from the Orcs health bar 8 .If the attack fail or the orc is able to parry none damage is taken away from the Orcs health bar My first question here is if it’s possible to create all this in just 1 macro or script, second question is if there is already a script or macro that already do this and third is this even possible with API script or Macro. Hope you guys understand what I am trying to show. I just wonder as I find combat one of the things that takes most of the time when I am roleplaying and I would like to make it as fast and automatic as possible. 
1507725513
The Aaron
Pro
API Scripter
The answers to your questions: 1) Yes, it is absolutely possible to do in a single script. 2) No, there is no such script currently in existence that I know of. 3) Yes, it is absolutely possible to do with the API. Going into slightly more depth, this would be a very complicated script to write.  It would require a great deal of work figuring out how you would want to store each of these things, and how to make it extensible. Just to take the Parry aspect above as an example, you would not want to hard code every single creature it was possible to attack into the script.  You would not want to have code that said something like: if(creature.type === 'orc'){ ... because when you introduce a new creature, you don't want to edit your script.  Additionally, you might have orcs with other capabilities.  Dodge, block with shield, use a magic ring to shield itself, become fog, grab the sword, etc.  You have to write abstractions.  All of these things could be abstracted as "Reaction to Physical Attack", so you'd write a system for that.  You'd come up with a way to store the types of reactions a creature can take, then you'd load them up. For example, you might have attributes on the Orc character that begin with "RtPA: " and search for all of those. "RtPA: Parry", "RtPA: Dodge", etc.  Which brings up that a creature might have multiple of those, so when does it choose Parry over Dodge?  You'd need an abstract way to deal with that.  You'd need an abstract way to deal with the effect. Negate all damage? Prevent a hit? Increase the difficulty of an attack?  You'd need to build a directed acyclic graph of all the decisions that would need to be made during an attack and find a way to fulfill the intent of each node.  You'd need to build a system that can load all of those nodes and build a decision tree for that entity to make the choice at the time the attack is initiated.  Then you'd need to do that for every facet of the combat, then you'd need to configure all of the creatures with that information.   It starts to get a bit overwhelming.  It's definitely possible, people write this kind of code all the time in the Game Industry, but it's unlikely to happen as an API script.
thx, aaron, good to know
1507728564
The Aaron
Pro
API Scripter
No reason you couldn't write one yourself.  It would probably have to be a labor of love, especially if it only works for a single and possibly obscure system.  I'm happy to answer questions or make suggestions if you decide to pursue it.
I myslef dont know so much of scripting, but i am trying to learn some javascript (2nd day), it seems like something good to know. but wanted to see if it was possible. The system i am playing is warhammer rpg. I do wonder would it be possible that in istead of assign it to a creature, like orc, to be able to assign it to a token or a character sheet?
what i mean is that after you create a token and assign it to the char sheet, that character sheet execute the script?
1507731228
The Aaron
Pro
API Scripter
Character Sheet rolls are limited in what they can accomplish without an API script. A roll could reference another character’s Attribute via @{target|attribute_name}, but couldn’t make changes to the token or apply decision trees about its actions. Roll Templates have limited logic capabilities that revolve around displaying different things based on the results of formulas, but don’t have the capability to manipulate anything. Character Sheet’s have Sheet Workers which let them manipulate their own attributes in response to certain events (like setting your strength score) but not as a result of initiating a roll and not on another character. API is pretty much the only place you can get full automation.