Monday, June 4, 2018

Automatic fights in ICONS


This is going to be boring programming talk, related to ICONS. Feel free to read and say, "Wow, that feature's absence is a deal-breaker for me" or "Really? Why do you think it's important, because I'd never use it."

For a couple of years I have been working desultorily on a project to produce a simple ICONS fight emulator in PDF on my phone.

All sorts of things that I figured the computer could handle have been moved to the person as I discovered that my programming isn't up to the task. :)


I know, you're saying, "In PDF?"

Also, "on your phone?"

I am sufficiently aware of the idiocies involved. Still, here's why:

  1. "On my phone" is the key part. This is something I want to do when I'm riding in the back of a car or on a train. The iPhone (and I have an iPhone) being what it is, just writing a website and making it available probably isn't going to cut it. I have to connect, I have to get the current version of the emulator, and probably use data as I do it. Because the iPhone doesn't allow a straight programming interpreter, I have to get creative. Hence the PDF, which includes a JavaScript interpreter.
  2. Doesn't hurt me to actually use JavaScript. I'm still weak on exception handling, but at least this project has brought me up to speed on a number of idioms and referring to objects and functions by reference. I still won't pass a "How well do you understand JavaScript scopes" test, but it does actually help me at work.
  3. The JavaScript interpreter in PDF is old (about ECMAScript 3) so I don't get to use fancy things like keys. Still, it's there and I have a cheap PDF editor that lets me create JavaScript, though not without its own limitations. (I no longer have access to Acrobat Pro, though debugging there is much much easier...without the console, it's a pain.)

My first thought was to write it in Java, but the iPhone isn't going to support Java in my phone's lifetime. I've been meaning to learn Java, but this isn't the excuse. Doing it in JavaScript gives me the phone my kids (hah! the youngest is 18) slowly take over my home hardware, this is important.

Could I make this work as a web page? Probably. It would do me good to learn the web page DOM. But I didn't.

Second Digression: PDF?

Doing it in PDF imposes certain constraints as well.

First, there is a size constraint, though I think that's imposed by the tool.

Second, the PDF security restrictions impose on me as well.

  • I don't have a generic way to save or export stuff from the PDF form, which places another limitation on it. In answer to that, I created a way to turn the characters to and from text, so you can at least export and import characters between versions of the PDF form without re-creating the whole thing.
  • Also security restrictions: no pictures loaded dynamically. You can't pick what your characters look like, except in the very limited case where I insert some number of images and you choose them.
  • The tool that I'm using limits the size of the actual code, so when I hit the limit, I say, "Okay." Sometimes that means using shorter and largely incomprehensible variable names; sometimes that means abandoning an idea.
  • As an example of an abandoned idea, I wanted to have some kind of graphic way to represent levels, maybe a level bar, maybe a dot of a particular size or a circle partially filled in, maybe a size of triangle. Drawing it on the fly, while generically possible in PDF, does not seem possible here. Oh, I could make each level a field and diddle with the length and colour, but there are other things to do instead. Make it work first, make it pretty second.

The UI part of it is useful, too. Learning how to put things in a small amount of real estate and trading off between cluttered in space and cluttered in motions has been eye-opening.

So what is there?

Well, I've got:

  • Random character creator
  • Space for two characters: a protagonist and an antagonist
  • There's an object constructor for a character; when you generate a person, it creates the object and fills it in. You can edit the fields and then update the object and save it.
  • Tests based on the attributes of the characters. Though you have to roll for each character separately, when using Prowess or Coordination, it does pre-set the attribute, so Prowess versus Prowess is relatively easy; you just have to change characters and possibly mods and press "go"
  • If you need to roll on a power, you can specify "no attribute" and set a higher modifier (power level and possible modifier), so the modifiers list goes from -5 to +16 (Supreme Master plus and additional +3).

Currently it gets used as such:

  1. Generate a character:
    1. Hit "Make"
    2. Edit the fields.
    3. Mark the character as done; it gets saved as-is.
  2. Switch acting characters.
  3. Repeat first three steps for opponent.
  4. Roll a test:
    1. Pick a character to start
    2. Set attribute to test.
    3. Set modifiers.
    4. Roll "Test!"
  5. Change characters.
    1. Attribute is probably set.
    2. Set character modifiers.
    3. Roll "Test!"
  6. Compare the numbers (a big '<', '>', or '=' appears to help)

  7. If necessary, change appropriate stamina. You have to mentally apply armor and such-like yourself.

So you can see that at this point, there's a lot of set-up involved to roll even a simple combat exchange.

Wish list (a generic to do)

What I want...

  • Combat exchanges should be easier. It should remember the last setting for that character, though that might necessitate differentiating the "attack" and "defense" rolls, because they can have different settings.
  • An easy way to adjust stamina and determination; though some present themselves, I dislike them because I'm hampered by screen size. The PDF listbox is kind of ugly and the phone implementation on PDF Expert is a little wonky; I might use comboboxes with 0-20 and 0-10 lists pre-populated.
  • To handle both minions and non-minions. Right now it does just non-minions, but you should be able to say that there are, oh, six minions and use, I dunno, checkmarks instead of Stamina.
  • An automatic way to adjust for the powers that have second rolls or continuing rolls, such as Affliction or Slam or Stun rolls. I thought about it, but it's part of making powers very complex: does a power require a second roll, does the power aid or replace an existing attribute? Does the power have extras? Are there limits that apply to the actual environment we're testing? Right now, all that kind of stuff happens in the user's mind because I can't find an easy way to represent it.
  • I'd love to be able to export and import characters as files but that's impossible beyond my own heavily-modified and probably insecure system.
  • A way to import pictures for characters; for security reasons, I don't believe I'll ever have that.
  • Automatic combat task resolution (if you pick Prowess or Coordination, it remembers the previous levels set for the opponent and rolls the test automatically; if you wanted to change values, you still can and re-roll for the opponent).
  • It should remember the characters you created (or at least the last five or so) so that you can go back to characters in a sequence. Then you could use it for things like solo roleplaying.

I have considered making the modifiers list being a set of maneuvers, and you can select multiple events (that is, the maneuver is -2 because it's a grab, +1 because you have Matrial Arts, and another +1 because you're doing it underwater and you have Underwater Combat) except:

  • I think multiple selections only works with listboxes, and see previous comment on PDF listboxes
  • I'd have to build the list of modifiers on the fly, depending on the character, to account for specialties

Off-hand, I suspect I could fix all the security problems by setting up a security certificate that was available on the web...but at this stage, that's far too much hassle. I'm not even testing this, let alone selling it.

The random character generator itself might be worthwhile, attached to a character sheet. It does only the Assembled edition (not Great Power), though of course you can type in things from Great Power. I want it to be a little prettier graphically and perfect the import/export stuff so that people can at least upgrade the character sheet. Also, if I were selling it, I'd probably want to obfuscate the code somehow.

No comments:

Post a Comment