Control (Talk)
When an object receives a message, it reacts. For example, an
object receiving the "Draw" message shows itself on screen.
The messages are sent at appropriate times by the Engine. For
example, Dream II sends "PlaceChange" messages to everybody in the
world every time the player moves from place to place.
Some messages are very generic, and their meaning changes in
relation to their intended target. For example, when "HitUse"
reaches a monster, it means the monster was wounded; when the same
message reaches an item, it means the item was used by someone.
The Scenario Designer can send messages to the objects in the
Dream II world. So if, for example, you send a "Move" message to a
window, the window moves on screen. If you send the "Move" message
to a monster, the monster walks accordingly to your dictates.
DreamCode
The Scenario Designer manipulates the Dream II worls via
DreamCode, an object-oriented language based on AppleScript.
DreamCode lets you attach routines to objects. For example, if
you created a monster, you could state:
on Talk (message)
if (message = "Dragonspawn") then
return "Why didn't you say before you are of the Dragon
Society?"
else
return "I don't talk with invaders"
end if
end Talk
And, if you mean to create an item which explodes when thrown
away, you can simply write:
on Die
-- 12 hit points of damage!
owner.hitUse (12)
-- let the boom be heard
-- 1000 is the resource id of the sampled boom
-- SOUND is the DreamBasic name for the Mac speaker
SOUND.talk ("1000")
end Die
(Warning: the syntax of DreamCode is not finalized yet. These
examples might not work, in the current form, in a released
version of the game engine. They are only intended as a generic
example).
DreamCode allows incredible freedom in designing a game
scenario. The following example (our first working magic item for
Dream II) will give you a glimpse of what can be done.
This code is for a magic sword. It's a sentient sword, which,
from time to time, says something. Notice how easy it is to
program the talking sword.
on Time (minutesPassed)
-- Create a pool of phrases
copy {"Nice weather we've been having, lately",
"Why don't you buy me a leather scabbard? This one tickles
me.",
"Don't you think swords are way better than axes?",
"I'm proud of my sharp remarks. Ha ha. You get it? "Sharp" remarks
",
"Don't you think I'm a wonderful sword?"}
to phrases
-- choose one of those at random
copy some item of phrases to onePhrase
-- Put the chosen phrase in the same window player characters
use
to talk
-- to each other. The format is usually:
-- Galahad: Don't wake that red dragon!
-- (where "Galahad" is the name of the player which said the
phrase)
-- So we format the phrase to look like the above. tell
application "DreamII"
transcribe "Magic sword: " & onePhrase & " " end tell
end Time
Network play
Sword Dream II allows up to four players to play together, over
any network. We are considering the feasibility of game play over
the Internet.
During exploration, the group leader takes the lead and moves
the group. During combat, every player moves his or her own
character. At any time, players can chat over the network.
Back to theSword Dream main Web page