Roll20’s API Scripts

Continuing from my previous post about Roll20, I wanted to talk about how script writing for Roll20 works and the particulars of the script I’m writing.

Roll20 has something called an API (Application Programming Interface) a term that the programmers reading this are already aware of, but one which I had to look up while writing this.

Behind all the fancy jargon I read, an API is a way to write and test programming code.

The simplest “API” is something like Notepad. You can design a program in it, but Notepad won’t run your program or tell you where you messed up.

There are more complicated APIs track syntax errors in your code, color the different key words, point out where you messed up, and even let you test run your code.

Roll20’s API tracks syntax and color codes. It tells you IF you messed up, but not WHERE. So when there is inevitably a problem you get to play hide and seek until you find it.

Every API is designed for a specific programming language. Roll20 uses Javascript.

I didn’t know any Javascript going into this.

I’m familiar with the basics of programming. I’ve taught myself a little bit of Python, I took a course on C in college, and I know a little about Perl and HTML* from various places.
*Not exactly a programming language but I’ll bet that nobody really cares.

To learn the particulars of Javascript I started taking a course on CodeAcademy.

The CodeAcademy course is pretty cool! Nice assisting prompts. A little poor on alternative ways of solving the problems, but that’s actually a good thing for programming courses.

I learned a little about Javascript from that, enough to write the program I wanted to for Roll20.

And what program is that? Something to automatically spit out the results of a critical hit in Hackmaster!

Hackmaster is a game like D&D that I play with my friends sometimes. Hackmaster has a ton of cool rules that make the game quite a bit more fun and shocking than D&D.

One of those rules is what happens when you hit your opponent real good. Depending on your height advantage over your opponent, the weapon you used, and how hard you hit, a special event occurs.

Why do I want a program for that? Well… Take a look.

Critical hit chart comes with lion and everything else you see here.
Critical hit chart comes with lion and everything else you see here.

There are about twenty pages like this that just go on and on.

It’s a bit much to flip through all those pages, cross reference with the different numbers you need, and then trail your finger down the chart to see what happens.

Instead, why not have a program do the work for you?

The program is started when a player uses the Critical Hit macro. Remember how macros can ask for values? That’s all the Critical Hit macro does. No dice are rolled.

The Critical Hit macro asks for seven different values: your size, your opponent’s size, your attack roll, your opponent’s defense roll, your damage roll, your opponent’s armor strength, and the type of weapon you’re using (Crushing, Hacking, or Piercing).

Next comes the script. The script is triggered when the Critical Hit macro is entered.

Nowhere near Matrix levels of code yet.
Nowhere near Matrix levels of code yet.

I looked around on Roll20’s forums and found the skeletons of some other scripts to use for the script to take information out of the Critical Hit macro and use it in the program.

From there, the script rolls a several thousand sided die that represents the location hit by the critical with different sized dice depending on the difference between the attacker’s and the defender’s sizes.

After getting that roll, the script enters a gigantic ~3,000 line long if/else tree that serves in place of the twenty page table. This comes up with a different results based on the location of the blow, how hard the target was hit, and what type of weapon was used.

Finally, the program spits out the result into Roll20’s chat along with some background information to make sure that it worked correctly.

Does the code work? Well, I don’t know yet. I’ve been typing away at it for about a week now and have transferred roughly one fifth of that giant table in the book to the programming script.

Due to how I structured the code, I can’t tell if it works correctly until I finish the whole thing.

Unfortunate, but what can I do at this point?

So here’s hoping that when I’m done in a few weeks and I press that Critical Hit macro button, it runs as smooth as melted chocolate.

If not, then I’ll probably have a blog post to make about code debugging…

-GoCorral

P.S. If you play Hackmaster and are interested in this code I will be posting the completed version of it on the Roll20 forums and the Hackmaster forums once I’ve finished. I’m also planning on doing a similar thing for the Fumble charts for Hackmaster so stay tuned for those as well.

Money Monster Review

Money Monster

I saw Money Monster with my wife the other week and we both enjoyed it quite a bit.

George Clooney plays Lee Gates, the host of a financial show called Mad Money. Julia Roberts plays his director, Patty.

All seems like it’ll be just another normal day for the show until an armed gunman, played by Jack O’Connell, comes onto the show and threatens to shoot Lee if he doesn’t do what he says.

The gunman pulls out a suicide vest and straps Lee into it. The vest is wirelessly connected to a deadman switch that the gunman, named Kyle, holds in his hand. If Kyle lets go of the switch then the bomb goes off.

While arguing and threatening Kyle explains that he invested his entire savings into a stock named IBIS that Lee previously recommended. The stock has now tanked due to some unknown error.

Lee and Patty work to keep everyone in the studio alive until the police can deal with the situation. Eventually they come to
Continue reading

Roll20 and D&D

I’ve mentioned Roll20 in past posts about how my group plays D&D, but I figure it deserves a post all its own.

Roll20 was a Kickstarter project back in 2012. It raised $39,651, well past its goal of $5,000.

Once funded the project team set out to create a free and simple way to play D&D and other roleplaying games online.

They created something that has been dubbed a virtual tabletop (VTT). D&D is normally played at a table, so when you play online everyone sits at their computers around the virtual tabletop.

What does that actually mean though?

First, Roll20 transmits your voice, video, and any typed messages you want to the other people you’re playing with. Continue reading

Characters of Cimmeria: King Jevaninada the First

Today we take a short departure for the heroes of the Dragon War and focus on Jevaninada the First, the villain of a previous campaign I ran in Cimmeria. King Jev was a bit of wish fulfillment on my part for where I wanted my first D&D character, Anxe, to end up if I played him all the way to level 20. I gave Jev a whole kingdom, sweet loot, and an angel for a wife. Might not have been the most mature thing, but I was in high school when I created this character…

Jevaninada I

King Jevaninada the First set Xoria on a path of rapid expansion that has continued to this day. His personal magnetism and cunning manipulation of the Xorian nobles allowed him to discredit his sister’s claim to the throne. With her out of way Jevaninada built an unshakable power base for his invasions into the surrounding lands of Xoria. A well-timed marriage to Anajakaze, Queen of the Amazons and daughter of Zeus, ended the war between Xoria and Amazonia. As if the combined might of the two militaristic cultures wasn’t enough, Jev also commanded a mysterious group of powerful warriors known as the Seven Rages. Jev planned to conquer Cimmeria in its entirety, but his plans were cut short by the mercenaries his sister hired to oppose him. Jevaninada the First was slain at the Battle of Danar’s River. Queen Anajakaze carried on his dream of conquering Cimmeria and after her, his son, Jevaninada the Second.

Jevaninada was born the first prince of Xoria in 478 BCE to his father, King Demotinira, and his mother, Queen Biiratofara. The Queen died in child birth, leaving Demotinira with Jev and his older sister, Tarigananata, as the only surviving members of the royal family. Jev was raised by his Greek wetnurse, Andreiya, while his father attended matters of state such as warring with the Amazons and supplying the new Xorian colony of Petar. Andreiya was an Ionian Greek priestess of Artemis at Ephesus before she was enslaved and sold to the Xorian royal family. She tended the library at Ephesus and had read and copied many books prior to her captivity. She passed this knowledge onto the young prince as he was brought up. There was nary a topic that Jevaninada did not know something about.

When Jevaninada was not studying with Andreiya he learned martial arts with his instructor, General Antapike. The general used a spear when teaching, augmenting his already superior reach. Jev learned to close the gap with speed and trickery. Additionally he learned warcraft from Antapike and his father while observing their war councils before their numerous battles with the Amazons.

Jev’s final teacher was brought about by his father’s neglect. Demotinira believed a Spartan lifestyle bereft of comforts would develop sympathetic feeling in his children for their subjects. this worked for Tarigananata. She developed a natural love for the people of Xoria. Jevaninada reacted… differently. Lacking the luxuries he felt he deserved, Jev turned to theft. He stole jewelery, fine weapons, and elaborate toys from visitors to the castle. When Jev was taken on trips outside the castle he always managed to sneak something back in with him, be it a gold necklace or only a sweet bun. His father ordered Jev’s bodyguards to put a stop to it. The prince only learned which guards could be bribed and which he could hide from.

As Demotinira grew old he made it clear that Princess Tarigananata was his heir. She was the first born and she was a kinder, more generous person. Demotinira wanted a virtuous kingdom to follow his death. Jev’s father died when the prince was 20 years old. At that point Jev had already set his plans in motion to disinherit his sister.

Jevaninada had many friends at court. He convinced the nobles to forestall Princess Tari’s coronation until after consulting the Oracle at Delphi, the Oracle which he had already bribed to reveal a prophecy to his liking. The Oracle returned a prediction that Tarigananata would loose a terrible demon into Xoria twenty years after her father’s death. Jevaninada had her arrested and supposedly executed. In fact, she was saved by General Antapike who had realized Jevaninada’s trickery even if he could not prove it. The General and the Princess fled Xoria while Jevaninada was crowned King Jevaninada the First.

After stealing the throne, Jev was quick to restart war with the nearby Amazons of Dradelden. Half a decade of war proved indecisive until Jev disguised his army as slaves and snuck into Dradelden along with them. A chaotic melee broke out between the Xorian and Amazon troops while Jev sought out the Amazon Queen. After a day and a night of fighting King Jevaninada and Queen Anajakaze emerged together and declared an end to hostilities. From that moment on Xorian and Amazon would work together. Combat stopped and a magical spell initiated an orgy between the previously adversarial parties. King and Queen were soon married with seven strange warriors in attendance. These warriors would come to be known as the Seven Rages.

King Jevaninada used the combined strength of the Xorian army, the Amazon warriors, and the Seven Rages to conquer Makotako, Semanarie, and Colchis. King Aeetes of Colchis was cast into magical servitude, forced to serve Jevaninada as a lord against his will. Meanwhile, Princess Tarigananata had gathered allies of her own.

Nineteen years after King Demotinira’s death, his daughter struck against Jevaninada in a three pronged assault. She led an attack from the east along with Leopold Anigama, Atreides, Salzar, King Archidamus II of Sparta, King Willard of Aractrash, and Amalgami of Phoenix. In the south, Duke Prusu’s city of Jeutontic revolted and the Persian Satrap Orontes invaded. In the west, Tari had freed Aeetes from his the King’s binding magicks. Aeetes led a revolt as well.

King Jevaninada met the eastern attack himself at Danar’s River. Tari’s forces used magic to halt the river’s flow while they crossed and collided with the King’s waiting army. Jevaninada may have prevailed, but the war mage, Salzar, used forbidden destructive magic to kill the king and decimate his army. The Xorian loyalists lost the battle and Jevaninada’s body was taken by the rebels.

Queen Anajakaze ruled on in King Jevaninada’s stead, only recently pregnant with their first child after over a decade of marriage. Jevaninada’s spirit slept fitfully, but when resurrection was attempted upon his ransomed body he chose to remain in the afterlife rather than return to lead his country through the war. Queen Anajakaze’s regency for her unborn son would continue until her death twenty years later.

-GoCorral

Characters of Cimmeria: Tentineh

Tentineh

Tentineh was one of the most powerful wizards who ever lived. Master of the elements he came up with many new spells never seen before. He became the defender of Greshendale during the Age of Monsters. Frustrated with draconic tyranny, Tentineh led the heroes of the land during the Dragon War. He invented the Orbs of Dragonkind to imprison the dragons. Greshendale was destroyed during the war, but upon the heroes’ victory, Tentineh used half of the Orbs to rebuild Greshendale as a flying city. Tentineh now lies with the other heroes of the Dragon War, deep beneath the earth awaiting the return of the silver dragons which he personally imprisoned.

Tentineh was the first son born to a wealthy farmer in the Greshen Valley. Tentineh’s family did not know, but he was destined for great things. His mother had been attacked by one of the wyverns of the Terror Mountains in her youth. The poison from the wyvern’s sting lingered in her body and transferred into the babe during her pregnancy. The poison tested the boy and he came through, not weakened, but fortified with the might of the dragon.

Tentineh’s father saved up all his gold to pay for the boy’s education. He apprenticed his son to an accomplished wizard who also happened to be a descendant of Sadroston. From a young age Tentineh learned all the secrets passed down by Sadroston. He mastered them with a unnatural speed due to the draconic power flowing in his veins. He swiftly surpassed his master and rose to be the greatest spellcaster in the whole of Greshen Valley.

The dragons in the Terror Mountains did not permit the people in the valley to organize armies, but the same could not be said for the trolls in the foothills. Tentineh had experience repelling smaller troll attacks with his command over the elements, but his powers could not stop an entire army of the beasts when they attacked. Instead, the young wizard turned to dark, forbidden magicks. He summoned a fiery demon from beyond the realm of Hades to vanquish the trolls. This slaad, as it was called, defeated the troll army, but it demanded a terrible price. It would see the whole world burn in payment for it’s service.

Tentineh moved quickly to thwart this new threat to Greshendale’s safety. The infernal slaad rested after obliterating the trolls to regain its power. Tentineh  dug through old tomes of binding spells. He found what he needed and used the magic to imprison the slaad forever. A magical rod provided the key to the slaad’s prison and the key could only be turned by three mages, one of good nature, one of evil, and one of neither. The rod was broken into pieces and scattered across the realm to prevent the slaad’s return.

Tentineh never wanted to resort to such dire measures again. He began secretly training the people of Greshendale in the magical and martial arts. If the dragons would not let him have an army, then he would hide it from them. In time, a force of giants descended from the mountains. Tentineh could not halt the giants’ advance on his own. He was forced to use his army and in so doing, reveal it to the dragons. The punishment was certain, death.

Rather than submit to the dragons’ judgement, Tentineh gathered the heroes of the land alongside his army. Thus began the Dragon War. The war lasted many long years. Killing the dragons proved difficult. The elder wyrms that ruled their species could regenerate even the most dire of wounds. Tentineh’s past experience proved invaluable in solving this problem. Instead of killing the dragons he bound their leaders to ten crystal orbs. Each dragon color had two elder wyrms that led it. Each Orb contained within it one of those leaders while the other leader was set to guard the Orb for all eternity. The Orbs in turn gave great power to any mortal that possessed them.

Tentineh advised the other heroes he had fought with to place eternal defenses around the Orbs. Those who could not or would not gave their Orbs to their architect. Tentineh used them to build a new Greshendale, for the original city in the valley had been destroyed during the war. Vast power was poured into the city. A volcano imprisoning an ancient enemy of Zeus was used in the creation of the new city, freeing the monstrous Dahak and winning its gratitude. Other powerful artifacts besides the Orbs were used in the city’s construction but it was still not enough. Tentineh took more magic from the surrounding land and the valley died as its life energy was given over to the city. Holes in the fabric of the world were ripped asunder. These holes are still present in the valley as empty spheres, consuming all that is placed within them.

In the end, Tentineh completed his vision. Greshendale flew. The magic within the city made it a paradise, providing light, food, water, shelter, communication, and entertainment to all who lived within it. The people of the valley were offered a choice, live in the floating city or strike out on their own. Many accepted Tentineh’s offer and moved into new homes. The others attempted to settle a new Greshendale to the south, but the settlement upon the ground atrophied within a few generations.

Tentineh did his best to be a good leader to his subjects. He set up the War Mage Academy to teach them battle magic for defense. He invited druids, sorcerers, and psions to the city to teach other forms of magic. He bound elementals to his service to further enhance the city’s comforts. Tentineh even set up a ruling council of mages so that he would not have absolute tyrannical power over the city.

Despite all his accomplishments, a dark fear still lingered in Tentineh’s heart. The Orbs were not indestructible. The dragons could return in time. He worked out a plan along with the nine other heroes who had imprisoned the dragons. Should an Orb be broken, the hero who defeated that dragon would be summoned once more to re-imprison the beast. To keep their youthful edge sharp for all eternity, the heroes would voluntarily accept a death-like slumber. Eons could pass, but they would not age. They would wait, and when the dragons returned, they would be ready.

Tentineh sleeps with his companions beneath the earth now, awaiting the return of the silver dragons.

-GoCorral