party system

Tomsa
01 May 2010, 18:06
So, I played around a little the other day, tried to create a party system which allows you to change the lead character. This is what I did:

1. Created a new window menu called "commands".
2. Window commands contain: swap character, cast arcane spells and cast divine spells. Each is connected to a command, which in turn is connected to a menu.
3. You have three characters in your party, one of them inaccessible (the one you are playing).
4. Choosing a character from the "swap character" menu will make the proper characters accessible/inaccessible and set a numeric variable to a specific value.
5. A numeric variable called "current character" will determine if you can cast arcane or divine spells, depending on current character (mage, thief or cleric).

Below is my ASL code. Please let me know if I can improve this further (changing inventories for instance)

' "Party system"
' Created with QDK Pro 4.1.2

!include <stdverbs.lib>

define game <Party system>
asl-version <410>
start <cell>
game info <Created with QDK Pro 4.1.2>
default fontname <System>
default fontsize <14>
startscript {
hide <Mandrake the Mage>
flag on <Tara dead>
}
command <swap character> choose <character list>
command <cast arcane spells> if ( %character% = 1 ) then choose <arcane spells> else msg <Only mages may cast arcane spells.>
command <cast divine spells> if ( %character% = 3 ) then choose <divine spells> else msg <Only clerics may cast divine spells.>
define variable <character>
type numeric
value <1>
end define
end define

define options
debug on
panes on
abbreviations on
end define

define menu <Commands>
swap character: swap character
cast arcane spells: cast arcane spells
cast divine spells: cast divine spells
end define

define room <cell>
prefix <a>
look <The cell is made entirely of stone slabs. It is damp and dark, with barely any light at all. Only an iron door lies between you and freedom.>
north locked <freedom; You are all locked in.>

define object <Mandrake the Mage>
look <Mandrake is a mage of tall stature. His black robe and hat match his red goatee.>
speak if ( %character% = 3 ) then msg <You should use your healing skills on Tara...that may be her only chance, as well as ours. She is the thief with lock picking skills after all...> else msg <There must be a way to get out of here...>
displaytype <Character>
article <him>
gender <he>
end define

define object <Tara the Thief>
look {
if flag <tara dead> then {
msg <Tara lies lifeless on the floor.> } else msg <Tara is quite slender.>
}
speak if flag <tara dead> then msg <She does not speak much for the time being.> else msg <I have prepared for this moment. Recently I put a few extra lock picks into a small leather pouch, which I fed to Donk. Now here is the problem...we need to wait for it to come out the natural route...unless you fed him something really nasty.>
displaytype <Character>
article <her>
gender <she>
end define

define object <Hans the Cleric>
look <Hans wears a gray tunic reminiscent of rags. His beard, also is in disarray.>
speak if ( %character% = 1 ) then msg <Do you have any idea what to do now?> else msg <God have mercy on us all...>
displaytype <Character>
article <him>
gender <he>
end define

define object <Donk>
look <Donk is a donkey and a beast of burden. And burdened he is, body and soul.>
displaytype <Object>
article <it>
gender <it>
end define

define object <iron door>
look <This is the door to the cell, made of thick iron. It is currently locked.>
prefix <an>
displaytype <Object>
article <it>
gender <it>
use <lock pick> {
if flag <tara dead> then msg <Tara is the only one who knows how to use a lock pick.> else {
msg <Tara uses the lock pick on the iron door. Soon, you hear a clicking noise.>
unlock <cell; north> }
}
end define

define object <rotten apple>
look <This apple has seen better days. Should you decide to eat it, only you can be held accountable for a runny stomach.>
take
displaytype <Object>
article <it>
gender <it>
give to <Donk> {
msg <You give the rotten apple to Donk, which he happily eats. It does not take long before his stomach starts grumbling, and moments later, Donk lifts his tail to drop a steaming pile of fresh dung on the stone floor, making the atmosphere of the cell unbearable.>
show <leather pouch>
}
end define

define object <leather pouch>
take
displaytype <Object>
article <it>
gender <it>
hidden
container
opened
add
remove
end define

define object <lock pick>
take
displaytype <Object>
article <it>
gender <it>
parent <leather pouch>
end define

end define

define room <freedom>
south <cell>
script playerwin
end define

define text <intro>
You awaken in a damp cell. Your party companions Tara the Thief and Hans the Cleric are here as well, but somebody is missing. Yes...that must be it - your other companion, Grogh the Orcish Berzerker, must have fallen asleep on his guard post the other night, that inexcusable sod. Even Donk, your pet donkey who carries your inventory, is here, which is kind of odd since his meat would have made an excellent stew.
end define

define text <win>
You have managed to escape the cell and a fate unknown. Now you and your merry band of adventurers may journey forth.
end define

define selection <character list>
info <Choose character>
choice <Mandrake the Mage> {
if ( %character% = 1 ) then msg <You ARE Mandrake.> else {
msg <You now play as Mandrake.>
set numeric <character; 1>
hide <Mandrake the Mage>
show <Tara the Thief>
show <Hans the Cleric> }
}
choice <Tara the Thief> {
if ( %character% = 2 ) then msg <You ARE Tara.> else {
if flag <tara dead> then msg <You cannot choose her...she is dead!> else {
msg <You now play as Tara.>
set numeric <character; 2>
hide <Tara the Thief>
show <Mandrake the Mage>
show <Hans the Cleric> } }
}
choice <Hans the Cleric> {
if ( %character% = 3 ) then msg <You ARE Hans.> else {
msg <You now play as Hans.>
set numeric <character; 3>
hide <Hans the Cleric>
show <Mandrake the Mage>
show <Tara the Thief> }
}
end define
define selection <divine spells>
choice <resurrect> choose <resurrect who>
end define
define selection <arcane spells>
choice <invisibility> msg <>
end define
define selection <resurrect who>
choice <Mandrake> msg <>
choice <Tara> {
msg <Hans casts resurrect on Tara, reviving her to full strenght.>
msg <"Thank you Hans...I am alive again!">
flag off <tara dead>