Implementing logical puzzles for Stendhal

From Arianne
Jump to navigation Jump to search

Stendhal code design


This page describes a concept for implementing logical puzzles in Stendhal.

This article describes a future concept. It may still have some open issues and it was not decided, yet, whether to implement it in this way.

Basic Objectives

  • It should be easy for content creators to define logical puzzles.
  • Puzzles should consists of basic building blocks (such as switches, doors)

Entities

Entities are basic building blocks that can be used by puzzle creators.

General properties

All entities have these general properties:

active
values: true, false
default: false
An entity may be activated. For example a player activate a pressure plate by stepping on it, which in turn activates (opens) a door.
enabled
values: true, false
default: true
An entity only reacts to input, if it is enabled. For example a switch will ignore all player actions, if it is disabled. A door will ignore the state of its associated switches, if it is disabled. Entities should indicate disabled state visibly and/or audibly.

Timer

time
datatype: integer
required
The number of seconds until an action occurs.
target
datatype: entity reference
required
The target entity to modify
propname
datatype: string
required
The name of the property of the target entity that will be changed
propvalue
datatype: string
required
The new value of the property of the target entity

Switches

  • Different kinds of switches and objects which contain a switch mechanism.

Pressure plate

A pressure plate is a tile with a switch, that gets active when a player steps on it.

Weight plate

A weight plate is a tile with a switch that only gets active when the exact weight is put on it.

Weights

Weights are objects with a special weight. They exist in different sizes with different weight and have to be put on weight plates to activate them.

Wall switch

A wall switch is an entity with a switch mechanism, assembled to a wall. It can have different forms, such as a huge lever or a pushbutton.

Moveable block

A moveable block can be pushed or dragged on the floor and fits to a moveable block receiver.

Moveable block receiver

A movable block receiver is an entity set on the floor with a switch mechanism that gets active when a moveable block is pushed on it.

Passive Entities

  • These entities don't contain a switch mechanism itself, but are affected by one.

Door

A door is a barrier that prevents players from crossing unless the switch for opening it is active.

Switch Mechanisms

  • These are different mechanisms for switches. Pushing is to understand as triggering, as the mechanisms work with different kind of switches, not only with Push-Buttons.

Tap-On Switch

Tap-Switch, which is active when pushed continuously and inactive when released.

Toggle Switch

On/Off-Switch, which is active when pushed and stays active after releasing. Gets inactive when pushed again.

Linked-Toggle Switch

On/Off-Mechanism, works like a Toggle Switch, but has two seperated but linked switches which affects each other. One of the linked switches (the On-Switch) is inactive, the other one (the Off-Switch) active by default. When switching the On-Switch to active, the Off-Switch switches automatically to inactive. Only the inactive switch can be pushed, pushing the active switch again has no effect.

Multi Switch

More-way-switch, is inactive in the default setting and can be pushed in different directions to change the output number.

Incremental Switch

More-way-switch, is inactive in the default setting and increases the output number by 1, every time when pushed. After reaching the maximum output number it switches to inactive again.

Delay-On Switch

Time-delayed switch, delays the time before switching to active after pushing.

Delay-Off Switch

Time-delayed switch, switches immediately to active when pushed, but switches back to inactive after the delay.

Advanced mechanisms

  • These more complex mechanisms contain different elements, merged together.

Lock systems

  • Lock systems are mechanisms build from two or more entities, to activate doors or other passive entities in a more tricky way than just with a simple switch.

Number Lock

Lock system, contains one or more Incremental Switches and/or Multi Switches which have all to be set to the correct numbers/settings to unlock the door.

Item Lock

Lock system, where an item has to be placed on a special place like a small column and a Tap-On Switch has to be pushed after in order to open the lock. There can be locks with more than one place to set the item but just the correct one will open the lock, or there can be locks with some different items and some different places to put them in the correct way.

Two-Man-Lock

Multiplayer lock, which is build of two seperated Tap-On Switches which both have to be switched on by two players in the same time. The system can have more than two switches so more players are necessary for unlocking.

Delay-Off Multilock

Lock system, which has at least one Delay-Off Switch and a second switch to unlock the door. The first switch (the Delay-Off Switch) has to be pushed first which enables the second switch for a specific time. Within this time the second switch has to be pushed, before it gets disabled again. There can be several Delay-Off Switches linked as a chain which have to be pushed in the correct order and within the set delay times before disableing again.

Automatic entities

  • Automatic entities do some actions without being triggered by the player.

Unlock-Delay Door

Automatic door, at default it can be opened, but after a player passed it, the door stays locked for a specific time and unlocks itself after this time again.

Set Time Door

Automatic door, has individually set times for being open or closed, checking the server time. For example, the door is only open from 06:00 to 21:00 or opens every hour for five minutes.

Date Door

Automatic door, opens only at specific dates, set to single time (only opens at the set dates), repeating yearly (opens at the set dates every year again), repeating weekly (opens for example every saturday) or repeating monthly (opens for example every third friday in a month). Also has optional time parameters like the Set Time Door to specify the opening and closing times even more exactly.

Backend implementation

  • Although most puzzles will be confined to one zone each, the backend must support multi zone puzzles.
  • Entity references default to entities in the same zone, unless an optional zone name was specified.
  • Event bus or listeners
  • Events are fired on change of a property (setting a property to the value, which it already had, must not fire an event)
  • Limit number of nested events to prevent infinite loops

Ideas for Puzzles

  • This is about puzzle ideas and mechanisms with a story behind and a place where to set them.

"Riddle Caves"

There are a few small and well hidden caves and dungeons all over the world, which contain a puzzle or riddle.

  • Introduction: [to do]
  • Place: At different spots all over the world.
  • Storyline/Goal: [to do]

General Ideas

  • Every cave has only one puzzle mechanism, not different ones in the same cave. (For example a cave has a block-pushing puzzle, another cave has a logical-switch puzzle.)
  • The caves have three rooms: The entrance room, the puzzle room and the treasure room.
  • The riddles may be in linear order, so the puzzle room of Cave 2 stays locked until the player solved the puzzle of Cave 1.
  • or: The riddles may be in random order, so the puzzle rooms can be entered in any order.
  • There is a "final cave" which is bigger than the others and has to be unlocked by solving all other Riddle Caves.
  • The treasure rooms of the caves may contain some reward and a special item to unlock the next cave. The treasure room of the "final cave" may contain a big reward.
  • An achievement can be gained for solving all Riddle Caves and getting the big reward from the "final cave".

"Dwarvish Machines"

  • Introduction:

"The dwarvish tales know about an ancient city, hidden deep within the mountain. For ages it was a place of invention, a secret factory where strange machines were forged by one dwarvish clan. Nobody knows why one day suddenly the dwarves left this city... After centuries have passed, all the plans and notes might have withered away, but the dwarvish machines still stand silently on their places, waiting for someone to switch them on again."

  • Place: [to be discussed]
  • Storyline/Goal: [to do]

Item Press

The item press creates an item out of two other items. Item A has to be placed on Socket A and Item B on Socket B, then a lever has to be pushed and Item C is forged from them and appears in the output slot.

  • This machine can be used for enhancing items or for creating special quest-items.
  • There can be different item presses you have to use in the correct order, for example first use Press 1 two times with Item A and B to create two Item C and then use the two Item C with another machine to create Item D, then use Item D and Item A on a third press to create Item E finally.
  • Item A and Item B can be the same item, for example putting two iron bars in the machine and pushing the lever creates the new item.
  • Some item presses can have more than one lever to push, which creates different items.
  • There can be many different combinations which work with the correct press.
  • Failure: There might be a small chance of malfunction, which destroys the items which are about to be forged together. Trying to forge the wrong items with the wrong press maybe also destroys the items (or could just prevent the machine from working, but not destroying the items). In case of failure there might be a scrumbled trash-iron in the output slot, which can be put in the Melting Kettle.

Melting Kettle

Iron items are put into the Melting Kettle, for every item there has to be one wood or one coal in the fireplace and a button has to be pushed to heat the fire up. It takes some time for the iron to melt and after that a lever has to be pushed to tilt the kettle and to fill a form with the hot fluid iron for creating iron bars.

  • Trash-iron and iron items created with the Item Press can be used again by this way. Other iron items like armors or weapons can also be recycled with melting them.
  • Every iron item needs to get a "size", to tell how much iron bars you can get from melting it. You might get two iron bars for a chain helmet but five for a plate armor.
  • Recycling has to take value from the item, to not make it attractive to melt valueable items, but to have it as a way to put unused items to a good use again.