TextWorld’s Basic Logic Pt 2

Okay last time I was going over the logic of how TextWorld will operate, and I intend to continue that today. Continuing from last time, the world will be loaded from a .xml file by the TextWorld object, populating the world property of the TextWorld object with the first Space of the world, which will then contain all of the Spaces and Things.

One of the most important Things in the world is the Player Mobile. It’ll also be linked to directly by the TextWorld object, as the player property.

The assembleLocationText method will use the perspective of the Player Mobile to determine the point of reference for the location, then assemble the text out of the long and short descs of the relevant Spaces and Things.

The Action area will be populated with the current actions of everything in the area. The time progresses as the player makes choices, so if you save everything is frozen in time untill you continue.

The Status and Menu areas will be populated with their appropriate data, and then the simulation is ready to continue. It just waits for the player to click on a hyperlink.

Flash has a very limited implementation of the HTML standard, and it has a few built-in modifications. Most important to what I’m doing, it can send a flash event when a link is clicked. I’m going to use that to pull user clicks out of the text. Well, sort of. I can find out what they clicked on, but the link event doesn’t say where the specific line of text is on the screen. So, I’m going to have to poll the mouse to find the xy at the same time, for the context menu.

Everything has a context menu, including the context menus, untill you reach your choice. It’s a list of actions, or families of actions that you might want to choose one of. There will be standard actions that everything should have a response of some kind for, and unique actions tied to the specific existance of the object. The choices will be restricted to what’s sensible, to avoid players frantically running down every option untill they stumble on something useful, like in most adventure games.

When the player chooses an action from the context menu or the standard commands menu, a function linked to that interaction is run. If the player clicks on “Hank” and chooses “Speak” then “Introduce Yourself”, then the standard conversation function is run, and it measures the relationship between the player’s character and Hank in order to determine what action Hank will take in response. This relationship data is a list each mobile has of everymobile they know and their knowledge and feelings regarding that mobile, as well as a list of prejudices, since if they meet a frightning stranger they shouldn’t give them the benefit of the doubt.

If the player was fighting an Orc and they clicked “Attack” and “Swing Sword”, the TextWorld would compare the player and the orc’s statstics and perform skill rolls, and if the player hit the orc it would calculate the weapon’s weight and force as well as the player’s strength into a damage… It’ll be a pretty complex calculation, the gears are already turning in my head.

For a more non-standard action let’s try a fire. There’s a fire in the fireplace at the Roaring Turkey Inn. If you click on it and chose the get option, a special function will be run that burns your hands. Actually I haven’t decided if Fire will be a Thing or a Status; it might be a Burning Log instead of a Fire. Another thing you can do with fire is heat things. If you have a Pot and the Pot contains Water, you can click on Pot while you’re near the Burning Log, and the option “Heat Pot” will be on its list. Most things can’t be used to heat other things, so it’s not a standard action. Hmm… Well maybe it would be, if things are either flamable or not, and fire is common enough.

Shoot, it’s getting hard to come up with a non-standard action. Maybe a special herb you grind into medicine. You can’t grind everything, and grindables would be relatively rare. Or a letter! You can read a letter, and it has a unique function containing the text of the letter.

I suppose even standard actions would be functions though, they’d just mostly be standard functions.

Hmm… I was thinking just now about how I was hoping to have some way to expand the actions in the simulation without changing the code. It occurs to me that there’s only a handful of things objects could do. Change the location of another object or itself, change the description of another object or itself, add or remove an effect or property, change the stastics or attributes of a mobile, perform a combat action, or display text in the action bar.

I should be able to set up those so that they can be scripted. At least, I hope I can. ^.^

Once the player has chosen their action, the TextWorld goes through a list of all the mobiles who aren’t currently doing an action, and uses their behavior function to decide what they should do. Then the TextWorld starts performing actions based on their timing order, untill the player’s action choice is carried out or something provokes a response from the player.

And that’s the basic logic of the TextWorld. I think the most important part I’m trying to figure out here is the gathering of information for the Location window. Each Thing will have to have information relating to its type, so that they can be coloured properly. Thing, Space, Mobile or Exit? It’ll also have to have its Name, so that that word in the description will be specifically selected.

I want threatning or dangerous things to be Red, so should they be tagged as threatning at the Thing level, so that they’re threatning to everything, or should it be based on relationship, or what? A fire is dangerous but doesn’t have a relationship. Hmm, well, if I go with the Burning Log rather than making Fire a Thing, then the Effect of Fire would make it appear aggressive, rather than any intention. Then I could change the text based on that.

Another thing, should the html be in the description or should it be added by the formatter? Obviously the formatter would have to change the description of a thing if it was threatning, and objects may change the description of a thing as well. Hmm… I have an idea. When I was messing around with Neverwinter Nights before, they used special flags in the text like #Name and #Gender that would be substituted with the name, etc, of the thing. I can do that! That way if these values are changed it’ll be reflected in the description without having to change the description, and if the description is changed then the changer doesn’t have to worry about the name.

So, the name will be coloured/anchored based on the type of the thing, or the threat if it’s got a threatning tag and/or attribute.

Alright, it’s getting a bit uncomfortable where I am so I’m going to post this, and go someplace else, and try to put together the three spaces I’ll be using to test this logical format. In the mean time, I’ll post this now.

Tagged ,

Leave a Reply

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