Struggling with Actions   Leave a comment

I’m back at the cafe and ready to work some more on TextWorld. Whenever I see Mr. Notch pop up on the Twitter and I see he’s working on his space game, I think to myself “Why aren’t I working on MY game?”

Well, I don’t feel comfortable making my own space game untill I have a computer that can handle 3D nicely, but the TextWorld still needs much work, so working I shall be doing!

Now, after my previous post I had many deep and great thoughts on the walk home, and it occured to me that in order to generate custom actions, I would need to create some sort of scripting language, which seems terribly grandiose at this stage. As such, I’ll begin by only using hard-coded actions, and grow the TextWorld from that. I have considered that I could do a simpler form by ‘overriding’ various actions. An action which changes the name and description of a thing could be overridden to change the name and description in a different way. That may be a good way to go in the mid-term.

For now, I’ll make an Action class, which will contain a list of static functions taken from the ActionTasks class. Each of those ActionTasks will be something like ‘Set this property’ or ‘Remove this property’ or ‘test against this attribute’. Hmm… There goes that if tree again. I worry that I’ll need to do conditionals and loops in the actions.

Maybe I should go for the overrides earlier on. Make the possible actions all big complicated affairs. Hmm… This’d be easier to visualize if I had some solid examples. Let’s try a few.

Guntry uses the Get action on a Cake he found in the street. The Get action first checks to make sure that Guntry can lift the cake by checking Guntry’s strength against the cake’s weight plus his encumberance. Guntry can lift the cake, so the cake is removed from the street and added to Guntry’s “Held” location in his equipment.

So even with something as simple as a get action, I’ve got to test against a mobile’s statline and do an if tree.

Hmm… Maybe instead of making ‘build your own’ actions, I should hard code all the actions and just have some actions where you can change the text or flags that you’re setting or removing.

Shoot. So complicated.

Hmm… What if the tasks are each function objects that pass their product down the line?

Hmmmmm… What if the tasks are each arguments of the next task?

Oh! What if for a conditional task, I pass the option tasks as arguments?

TestStat(_stat, _value, _winCondition = null, _loseCondition = null, _epicWinCondition = null, _epicLoseCondition = null);

Then each of those option tasks would be able to call another task, and another, untill the action was resolved.

Test the Strength against 100grams
if pass then transfer cake to inventory

Here’s another action. Swing Sword at Steve

Determine Steve’s response, Steve tries to dodge
Test player agility against Steve’s agility
If Player wins, then
-> Test penetration between player’s sword and steve’s defenses,
-> If Sword wins, then
—> Assign damage to Steve based on the force of the blow
—> Apply the Injury property to Steve
—> Apply the Bleeding property to Steve
-> Reduce durability on steve’s defenses, where applicable

In another way…

Player clicks Steve. The …

Hold on a minute. It just occured to me that the Context Menus won’t be constant, and many different things interacting with the same thing would require different Context Menus. There’s no reason to have the Context Menu be a member of the Thing class; a Context Menu should be generated on the fly by the TextWorld when the player clicks on a thing. I’mma remove that from the Thing class right now.

Okay back to the thing.

The player clicks Steve. A context menu is generated by the TextWorld based on the player’s proximity to Steve. The player is right next to Steve so it gives them the options Talk, Interact, Offer, Attack. The player chooses Attack, and since they’re equipped with a short sword and a buckler, it gives them the options Swing Sword, Thrust Sword, Shield Bash, and Kick.

Each of those three options is an Action; the first four would lead into another context menu. The Actions have their text changed to suit the context. Swing Sword is based off of Swing Thing. Whatever’s in your hand, you can swing it at somebody, including an empty hand, which is a Punch. A thrust in that instance would be a Jab, if I have my fighting words right.

These are standard actions from the action library. Oh! I should call the class ActionLibrary! I tell you it has been hard coming up with a name for that class. FOCUS. These are standard actions from the ActionLibrary. Each one is made up of a list of Tasks from the TaskLibrary. So, the TextWorld sees that the player is in range to use the swingThing Action and includes it on the ContextMenu. The swingThing Action’s task list is as follows:

interrupt(target), // This prematurely ends the target’s previous Action.
requestCombatResponse(target, dodge, block, parry, counter, ignore), // This asks the target to respond, and offers five handler actions as choices. The handler action takes over, from the target’s perspective

The dodge Action’s task list is like this:

testAttribute( AGILITY, // A Constant for the particular stat
testCondition, // In this case, the attacker’s agility
winCase, // Another

… Wait wait wait stop. This is getting really really really complicated and I’m not sure it all fits together properly.

The more I do this the more I wonder if I should just hard code complex actions instead of building them out of tasks. The time thing is the most difficult, though. It’s like, everything in the world is constantly doing something, and in order for one thing to interact with another, it has to interrupt that thing. Doing an action takes time. If you’re walking down a street, that might take a minute. In that minute, you might walk all the way, or you might be interrupted. What that means is that I have to be prepared for partially finished actions.

Hah, I’ve really got myself into a lot of trouble with this. This is what I get for trying to simulate a world in Text instead of just making a regular sort of text game.

Well I’m getting really very uncomfortably hot and it’s getting surprisingly close to my bed time, so I’m going to wrap this up and give it some thought overnight, perhaps. I’m sure I’ll either figure it out or figure out a different way to do what I want.

Posted April 6, 2012 by Arthur Payne in TextWorld

Tagged with , , ,

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.