<object name="spell">
<inherit name="editor_object" />
<alias> A Fireball Spell</alias>
<drop type="boolean">false</drop>
<take type="boolean">false</take>
<inventoryverbs type="stringlist">
<value>Cast</value>
</inventoryverbs>
<changedtype>spell</changedtype>
<feature_usegive />
<usedefaultprefix type="boolean">false</usedefaultprefix>
<look type="string"></look>
<usestandardverblist />
<displayverbs type="stringlist">
<value>Learn</value>
</displayverbs>
<learn type="script">
</learn>
<cast type="script">
<object name="spell">
<inherit name="editor_object" />
<alias> A Fireball Spell</alias>
<learn type="script">
if (not this.parent = game.pov) {
msg ("How about that? You can now cast fireballs " + this.alias + ".")
}
"else {
msg ("Er, you already know that spell!")
}
</learn>
<drop type="boolean">false</drop>
<take type="boolean">false</take>
<inventoryverbs type="stringlist">
<value>Cast</value>
</inventoryverbs>
<changedtype>spell</changedtype>
<feature_usegive />
<usedefaultprefix type="boolean">false</usedefaultprefix>
<look type="string"></look>
<usestandardverblist />
<displayverbs type="stringlist">
<value>Learn</value>
</displayverbs>
<learn type="script">
</learn>
<cast type="script">
<object name="orc_1">
<attr name="alias" type="string">orc</attr>
<attr name="strength" type="int">25</attr>
<attr name="endurance" type="int">25</attr>
<attr name="agility" type="int">25</attr>
<attr name="dexterity" type="int">25</attr>
<attr name="speed" type="int">25</attr>
<attr name="luck" type="int">25</attr>
<attr name="fight" type="script">
// blah Scripts
</attr>
</object>
<object name="orc_2">
<attr name="alias" type="string">orc</attr>
<attr name="strength" type="int">25</attr>
<attr name="endurance" type="int">25</attr>
<attr name="agility" type="int">25</attr>
<attr name="dexterity" type="int">25</attr>
<attr name="speed" type="int">25</attr>
<attr name="luck" type="int">25</attr>
<attr name="fight" type="script">
// blah Scripts
</attr>
</object>
<object name="orc_3">
<attr name="alias" type="string">orc</attr>
<attr name="strength" type="int">25</attr>
<attr name="endurance" type="int">25</attr>
<attr name="agility" type="int">25</attr>
<attr name="dexterity" type="int">25</attr>
<attr name="speed" type="int">25</attr>
<attr name="luck" type="int">25</attr>
<attr name="fight" type="script">
// blah Scripts
</attr>
</object>
<object name="orc_chief_1">
<attr name="alias" type="string">orc chief</attr>
<attr name="strength" type="int">50</attr>
<attr name="endurance" type="int">50</attr>
<attr name="agility" type="int">50</attr>
<attr name="dexterity" type="int">50</attr>
<attr name="speed" type="int">50</attr>
<attr name="luck" type="int">50</attr>
<attr name="fight" type="script">
// blah Scripts
</attr>
</object>
<object name="orc_chief_2">
<attr name="alias" type="string">orc chief</attr>
<attr name="strength" type="int">50</attr>
<attr name="endurance" type="int">50</attr>
<attr name="agility" type="int">50</attr>
<attr name="dexterity" type="int">50</attr>
<attr name="speed" type="int">50</attr>
<attr name="luck" type="int">50</attr>
<attr name="fight" type="script">
// blah Scripts
</attr>
</object>
<object name="orc_chief_3">
<attr name="alias" type="string">orc chief</attr>
<attr name="strength" type="int">50</attr>
<attr name="endurance" type="int">50</attr>
<attr name="agility" type="int">50</attr>
<attr name="dexterity" type="int">50</attr>
<attr name="speed" type="int">50</attr>
<attr name="luck" type="int">50</attr>
<attr name="fight" type="script">
// blah Scripts
</attr>
</object>
<object name="orc_1">
<inherit name="monster" />
<inherit name="orc" />
</object>
<object name="orc_2">
<inherit name="monster" />
<inherit name="orc" />
</object>
<object name="orc_3">
<inherit name="monster" />
<inherit name="orc" />
</object>
<object name="orc_chief_1">
<inherit name="monster" />
<inherit name="orc_chief" />
</object>
<object name="orc_chief_2">
<inherit name="monster" />
<inherit name="orc_chief" />
</object>
<object name="orc_chief_3">
<inherit name="monster" />
<inherit name="orc_chief" />
</object>
<type name="monster">
<attr name="fight" type="script">
// blah Scripts
</attr>
</type>
<type name="orc">
<attr name="alias" type="string">orc</attr>
<attr name="strength" type="int">25</attr>
<attr name="endurance" type="int">25</attr>
<attr name="agility" type="int">25</attr>
<attr name="dexterity" type="int">25</attr>
<attr name="speed" type="int">25</attr>
<attr name="luck" type="int">25</attr>
</type>
<type name="orc_chief">
<attr name="alias" type="string">orc chief</attr>
<attr name="strength" type="int">50</attr>
<attr name="endurance" type="int">50</attr>
<attr name="agility" type="int">50</attr>
<attr name="dexterity" type="int">50</attr>
<attr name="speed" type="int">50</attr>
<attr name="luck" type="int">50</attr>
</type>
<object name="fireball">
<inherit name="spell" />
<inherit name="fire" />
<attr name="power" type="int">25</attr>
<attr name="mana_cost" type="int">5</attr>
// etc Attributes
</object>
<object name="inferno">
<inherit name="spell" />
<inherit name="fire" />
<attr name="power" type="int">50</attr>
<attr name="mana_cost" type="int">10</attr>
// etc Attributes
</object>
<object name="blizzard">
<inherit name="spell" />
<inherit name="ice" />
<attr name="power" type="int">50</attr>
<attr name="mana_cost" type="int">10</attr>
// etc Attributes
</object>
<object name="iceball">
<inherit name="spell" />
<inherit name="ice" />
<attr name="power" type="int">50</attr>
<attr name="mana_cost" type="int">5</attr>
// etc Attributes
</object>
<type name="fire">
<attr name="elemental" type="string">fire</attr>
// etc Attributes
</type>
<type name="ice">
<attr name="elemental" type="string">ice</attr>
// etc Attributes
</type>
<type name="spell">
<attr name="learn" type="script">
// blah scripts
</attr>
<attr name="cast" type="script">
// blah scripts
</attr>
// etc Attributes
</type>
<?xml version="1.0"?>
<library>
<!--
This library adds a basic magic system to quest. It allows for three types of spells:
nonattackspell: Instant effect
lastingspell: An on-going spell. These last until another spell is cast
attackspell: Instant effect, attacking anything of the "monster" type that is not dead
Attack spells must be of an element, and eight are already set up. Monsters
can be assigned to elements too; they will be immune to that element, but take
four-fold damage from the opposed element.
A "Magic" tab is added to the editor to make setting up spells and monsters as easy as possible.
-->
<!--
Adding new elements involves a bit of effort. This system requires that elements are added in pairs or opposites,
such as fire and frost.
1. Create a new type for both elements, named [elemem]_type
2. In the data section, the object element_struct needs both elements added to both "elements" and
"opposedelements", and for the latter you need to put them in both ways around (look at existing entries)
3. You need to add both elements to the tab, both for "monster" and for "attackspell". Again, see existing
entries.
-->
<!-- =================================================== -->
<!-- Templates -->
<!--
Using templates makes it easier to convert to other languages, but also for other users to word it how they want it.
When templates are in the library that uses them (as here) the way to change the language is to
modify the template in the library, so really the only benefit is that all the text is together here.
Also modify the default responses in the verbs!
-->
<template name="Learn">learn</template>
<template name="Cast">cast</template>
<template name="LookDead">Oh, and it is dead.</template>
<template name="SpellAlreadyKnown">Er, you already know that one!</template>
<template name="SpellNotKnown">Er, you don't know that one!</template>
<template name="NoMonstersPresent">No monsters present</template>
<dynamictemplate name="SpellEnds"><![CDATA["The <i>" + GetDisplayAlias(object) + "</i> spell ends."]]></dynamictemplate>
<dynamictemplate name="SpellCast"><![CDATA["You cast <i>" + GetDisplayAlias(object) + "</i>."]]></dynamictemplate>
<dynamictemplate name="SpellLearnt"><![CDATA["In a process that seems at once unfathomable, and yet familiar, the spell fades away, and you realise you are now able to cast the <i>" + GetDisplayAlias(object) + "</i> spell."]]></dynamictemplate>
<!-- =================================================== -->
<!-- Verbs -->
<verb>
<property>learn</property>
<pattern>[Learn]</pattern>
<defaultexpression>"You can't learn " + object.article + "."</defaultexpression>
</verb>
<verb>
<property>cast</property>
<pattern>[Cast]</pattern>
<defaultexpression>"You can't cast " + object.article + "."</defaultexpression>
</verb>
<!-- =================================================== -->
<!-- Functions -->
<!--
Handles an attack on the given monster, using the given spell.
Monster loses hit points according to the spell's powerrating.
If they share an element, then no damage, if elements are opposed, damage is multplied by 4
Handles monsters with no elements too, but spell must have an element set.
-->
<function name="SpellAttackMonster" parameters="monster, spell"><![CDATA[
element = GetElement (monster)
handled = False
if (not element = Null) {
if (DoesInherit (spell, element + "_type")) {
msg ("... " + monster.ignoreselement)
handled = True
}
if (DoesInherit (spell, StringDictionaryItem (element_struct.opposedelements, element) + "_type")) {
monster.hitpoints = monster.hitpoints - 4 * spell.powerrating
handled = True
if (monster.hitpoints > 0) {
msg ("... " + monster.hurtbyelement)
}
else {
msg ("... " + monster.deathbyelement)
Death (monster)
}
}
}
if (not handled) {
monster.hitpoints = monster.hitpoints - spell.powerrating
if (monster.hitpoints > 0) {
msg ("... " + monster.hurt)
}
else {
msg ("... " + monster.death)
Death (monster)
}
}
]]></function>
<!--
Call this when a spell is cast, to ensure any on-going spells
are terminated.
-->
<function name="CancelSpell"><![CDATA[
if (HasObject (player, "currentspell")) {
spell = player.currentspell
msg (DynamicTemplate("SpellEnds", spell))
player.currentspell = null
if (HasScript (spell, "terminate")) {
do (spell, "terminate")
}
}
]]></function>
<!--
Call this when a monster dies for some housekeeping.
-->
<function name="Death" parameters="monster"><![CDATA[
monster.alias = monster.alias + " (dead)"
if (HasString (monster, "lookwhendead")) {
monster.look = monster.lookwhendead
}
else {
monster.look = monster.look + " [LookDead]"
}
monster.dead = True
]]></function>
<!--
Returns as a string the name of this object's element (or null).
-->
<function name="GetElement" parameters="obj" type="string"><![CDATA[
result = Null
foreach (element, element_struct.elements) {
type = element + "_type"
if (DoesInherit (obj, type)) {
result = element
}
}
return (result)
]]></function>
<!--
Describes casting
-->
<function name="DescribeCast" parameters="spell"><![CDATA[
if (HasString (spell, "description")) {
msg (DynamicTemplate("SpellCast", spell) + " " + spell.description)
}
else {
msg (DynamicTemplate("SpellCast", spell))
}
]]></function>
<!-- =================================================== -->
<!-- Object types -->
<type name="spell">
<inventoryverbs type="list">Learn</inventoryverbs>
<displayverbs type="list">Learn</displayverbs>
<drop type="boolean">false</drop>
<take type="boolean">false</take>
<usedefaultprefix type="boolean">false</usedefaultprefix>
<learn type="script"><![CDATA[
if (not this.parent = player) {
this.parent = player
this.inventoryverbs = Split ("Cast", " ")
msg (DynamicTemplate("SpellLearnt", this))
}
else {
msg ("[SpellAlreadyKnown]")
}
]]></learn>
</type>
<type name="attackspell">
<inherit name="spell"/>
<cast type="script"><![CDATA[
// Check the player has the spell
// If so iterate through all objects in the room
// Apply attack to those with the monster type that are not dead
if (this.parent = player) {
DescribeCast (this)
flag = False
foreach (obj, ScopeVisibleNotHeld ()) {
if (DoesInherit (obj, "monster") and not GetBoolean (obj, "dead")) {
SpellAttackMonster (obj, this)
flag = True
}
}
if (not flag) {
msg ("... [NoMonstersPresent]")
}
CancelSpell ()
}
else {
msg ("[SpellNotKnown]")
}
]]></cast>
</type>
<type name="nonattackspell">
<inherit name="spell"/>
<cast type="script"><![CDATA[
if (this.parent = player) {
DescribeCast (this)
do (this, "spelleffect")
CancelSpell ()
}
else {
msg ("[SpellNotKnown]")
}
]]></cast>
</type>
<type name="lastingspell">
<inherit name="spell"/>
<cast type="script"><![CDATA[
if (this.parent = player) {
DescribeCast (this)
do (this, "spelleffect")
CancelSpell ()
player.currentspell = this
player.status = this.status
}
else {
msg ("[SpellNotKnown]")
}
]]></cast>
</type>
<type name="fire_type">
</type>
<type name="frost_type">
</type>
<type name="storm_type">
</type>
<type name="earthmight_type">
</type>
<type name="shadow_type">
</type>
<type name="rainbow_type">
</type>
<type name="divine_type">
</type>
<type name="necrotic_type">
</type>
<type name="monster">
</type>
<!-- =================================================== -->
<!-- Data -->
<!--
This is a data store for elements (I call it a "struct" after the keyword in the C programming language)
If you add more elements to the name, you need to add them to both lists as well as creating a new type.
Note that your new type must end "_type", but that must not be included on these lists.
-->
<object name="element_struct">
<elements type="list">fire; frost; storm; earthmight; shadow; rainbow; divine; necrotic</elements>
<opposedelements type="stringdictionary">fire = frost;frost = fire;storm = earthmight;earthmight = storm;shadow = rainbow;rainbow = shadow;necrotic = divine;divine=necrotic</opposedelements>
</object>
<!-- =================================================== -->
<!-- Tabs -->
<tab>
<parent>_ObjectEditor</parent>
<caption>Magic</caption>
<mustnotinherit>editor_room; defaultplayer</mustnotinherit>
<control>
<controltype>dropdowntypes</controltype>
<caption>Spell type</caption>
<types>*=None; nonattackspell=Non-attack spell; lastingspell=Lasting spell; attackspell=Attack spell; monster=Monster</types>
<width>150</width>
</control>
<control>
<controltype>title</controltype>
<caption>Non-Attack Spell</caption>
<mustinherit>nonattackspell</mustinherit>
</control>
<control>
<controltype>textbox</controltype>
<caption>Description (optional)</caption>
<attribute>description</attribute>
<mustinherit>nonattackspell</mustinherit>
</control>
<control>
<controltype>script</controltype>
<caption>Spell effect</caption>
<attribute>spelleffect</attribute>
<mustinherit>nonattackspell</mustinherit>
</control>
<control>
<controltype>title</controltype>
<caption>Lasting Spell</caption>
<mustinherit>lastingspell</mustinherit>
</control>
<control>
<controltype>textbox</controltype>
<caption>Description (optional)</caption>
<attribute>description</attribute>
<mustinherit>lastingspell</mustinherit>
</control>
<control>
<controltype>textbox</controltype>
<caption>Status when active</caption>
<attribute>status</attribute>
<mustinherit>lastingspell</mustinherit>
</control>
<control>
<controltype>script</controltype>
<caption>Spell effect</caption>
<attribute>spelleffect</attribute>
<mustinherit>lastingspell</mustinherit>
</control>
<control>
<controltype>script</controltype>
<caption>Cacel spell effect</caption>
<attribute>terminate</attribute>
<mustinherit>lastingspell</mustinherit>
</control>
<control>
<controltype>title</controltype>
<caption>Attack Spell</caption>
<mustinherit>attackspell</mustinherit>
</control>
<control>
<controltype>number</controltype>
<caption>Power of attack (1-10)</caption>
<attribute>powerrating</attribute>
<width>100</width>
<mustinherit>attackspell</mustinherit>
<minimum>0</minimum>
<maximum>10</maximum>
</control>
<control>
<controltype>textbox</controltype>
<caption>Description (optional)</caption>
<attribute>description</attribute>
<mustinherit>attackspell</mustinherit>
</control>
<control>
<controltype>dropdowntypes</controltype>
<caption>Element</caption>
<types>*=None; fire_type=Fire; frost_type=Frost; storm_type=Storm; earthmight_type=Earthmight; shadow_type=Shadow; rainbow_type=Rainbow; necrotic_type=Necrotic; divine_type=Divine</types>
<width>150</width>
<mustinherit>attackspell</mustinherit>
</control>
<control>
<controltype>title</controltype>
<caption>Monster</caption>
<mustinherit>monster</mustinherit>
</control>
<control>
<controltype>dropdowntypes</controltype>
<caption>Element</caption>
<types>*=None; fire_type=Fire; frost_type=Frost; storm_type=Storm; earthmight_type=Earthmight; shadow_type=Shadow; rainbow_type=Rainbow; necrotic_type=Necrotic; divine_type=Divine</types>
<width>150</width>
<mustinherit>monster</mustinherit>
</control>
<control>
<controltype>number</controltype>
<caption>Hit points</caption>
<attribute>hitpoints</attribute>
<width>100</width>
<mustinherit>monster</mustinherit>
<minimum>0</minimum>
</control>
<control>
<controltype>textbox</controltype>
<caption>Description on injury</caption>
<attribute>hurt</attribute>
<mustinherit>monster</mustinherit>
</control>
<control>
<controltype>textbox</controltype>
<caption>Description on death</caption>
<attribute>death</attribute>
<mustinherit>monster</mustinherit>
</control>
<control>
<controltype>textbox</controltype>
<caption>Description on injury by opposed element</caption>
<attribute>hurtbyelement</attribute>
<mustinherit>monster</mustinherit>
</control>
<control>
<controltype>textbox</controltype>
<caption>Description on death by opposed element</caption>
<attribute>deathbyelement</attribute>
<mustinherit>monster</mustinherit>
</control>
<control>
<controltype>textbox</controltype>
<caption>Description on ignore</caption>
<attribute>ignoreselement</attribute>
<mustinherit>monster</mustinherit>
</control>
<control>
<controltype>textbox</controltype>
<caption>Look (when dead)</caption>
<attribute>lookwhendead</attribute>
<mustinherit>monster</mustinherit>
</control>
</tab>
</library>
<?xml version="1.0"?>
<!--Saved by Quest 5.2.4515.34846-->
<asl version="520">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<include ref="SpellLibrary.aslx" />
<game name="In the Lair of the Demon Witch">
<gameid>9b1b2320-14a1-4ae7-903c-5dd29b2c66ff</gameid>
<version>1.0</version>
<autodescription />
<statusattributes type="stringdictionary"></statusattributes>
<start type="script">
msg ("You open you eyes, and wonder where you are... And who you are...")
msg (" ")
</start>
<showscore />
<showhealth />
<autodescription_youcango type="int">3</autodescription_youcango>
<autodescription_youcansee type="int">4</autodescription_youcansee>
<autodescription_description type="int">2</autodescription_description>
<autodescription_youarein_useprefix type="boolean">false</autodescription_youarein_useprefix>
</game>
<object name="nowhere">
<inherit name="editor_room" />
<object name="parchment">
<inherit name="editor_object" />
<inherit name="surface" />
<hidechildren />
<listchildren />
<take />
<look type="script"><![CDATA[
if (unlock_spell.parent = parchment) {
msg ("The parchment is very high quality, thick and smooth, with neat writting on one side. Somehow you know the writing is an <i>Unlock</i> spell; it is almost buzzing with power. Further, you sense that the spell wants to become part of you. Is it possible you could... learn the spell?")
}
else {
msg ("The parchment is very high quality, thick and smooth, and blank on both sides.")
}
]]></look>
<object name="unlock_spell">
<inherit name="editor_object" />
<inherit name="nonattackspell" />
<alias>Unlock</alias>
<spelleffect type="script">
flag = False
foreach (ex, ScopeExits ()) {
if (GetBoolean (ex, "locked")) {
ex.locked = False
flag = True
msg ("...The door " + ex.alias + " magically unlocks!")
}
}
if (not flag) {
msg ("...There were no doors locked")
}
</spelleffect>
</object>
</object>
</object>
<object name="cell">
<inherit name="editor_room" />
<usedefaultprefix type="boolean">false</usedefaultprefix>
<alias>A cell</alias>
<description>A small cell, with stone walls, arching to form a ceiling above your head. The only furniture are a bucket, and a shelf; the only exit the iron door to the east. The only light comes from a narrow window above the door.</description>
<object name="player">
<inherit name="defaultplayer" />
<status>-</status>
<statusattributes type="stringdictionary">status = </statusattributes>
</object>
<object name="spellbook">
<inherit name="editor_object" />
<inherit name="container_open" />
<open />
<close />
<transparent type="boolean">false</transparent>
<hidechildren />
<isopen type="boolean">false</isopen>
<listchildren />
<listchildrenprefix>On it:</listchildrenprefix>
<take />
<inventoryverbs>Look at; Use; Drop; Open; Close</inventoryverbs>
<object name="fireball_spell">
<inherit name="editor_object" />
<inherit name="attackspell" />
<inherit name="fire_type" />
<alias>Fireball</alias>
<powerrating type="int">6</powerrating>
<description>A huge ball of fire envelops the entire room!</description>
</object>
<object name="aura_spell">
<inherit name="editor_object" />
<inherit name="spell" />
<inherit name="lastingspell" />
<alias>Aura</alias>
<status>Glowing</status>
<description>Suddenly you are glowing.</description>
<spelleffect type="script">
player.glowing = True
</spelleffect>
<terminate type="script">
player.status = "-"
</terminate>
</object>
</object>
<exit name="cell_door" alias="east" to="hall_of_cells">
<inherit name="eastdirection" />
<first />
<script type="script">
if (cell_door.first) {
msg ("The door is locked. Not surprising but it had to be worth a try.")
if (parchment.parent = nowhere) {
msg ("A piece of parchment is slipped under the door, and a voice, perhaps familiar you think, say; 'Use this.'")
parchment.parent = cell
cell_door.locked = True
cell_door.first = False
}
}
else {
MoveObject (player, hall_of_cells)
}
</script>
</exit>
</object>
<object name="hall_of_cells">
<inherit name="editor_room" />
<description>This is where the prison guard sits as he watches the cells. There are six cells on one side, and another six on the other side, but the only important one is yours, to the east.</description>
<usedefaultprefix type="boolean">false</usedefaultprefix>
<alias>Hall of Cells</alias>
<exit alias="west" to="cell">
<inherit name="westdirection" />
</exit>
<object name="frostguard">
<inherit name="editor_object" />
<inherit name="monster" />
<inherit name="male" />
<inherit name="frost_type" />
<alias>Frostguard</alias>
<usedefaultprefix />
<hitpoints type="int">20</hitpoints>
<hurt>The troll staggers back, clearly damaged, but still alive.</hurt>
<death>The troll falls to the ground; it is dead.</death>
<hurtbyelement>The troll staggers back, its skin blackened; it is unable to regenerate the fire damage.</hurtbyelement>
<deathbyelement>The troll falls to the ground burning; it is dead.</deathbyelement>
<ignoreselement>The troll is immune to the effects of frost.</ignoreselement>
</object>
<object name="imp">
<inherit name="editor_object" />
<inherit name="monster" />
<inherit name="male" />
<inherit name="fire_type" />
<alias>Imp</alias>
<usedefaultprefix />
<hitpoints type="int">6</hitpoints>
<hurt>The imp staggers back, clearly damaged, but still alive.</hurt>
<death>The imp falls to the ground; it is dead.</death>
<hurtbyelement>The imp staggers back, its fiery skin has darkened, cooled by your spell.</hurtbyelement>
<deathbyelement>The imp falls to the ground, no longer burning; it is dead and cold.</deathbyelement>
<ignoreselement>The imp ignores the magical fire.</ignoreselement>
</object>
<object name="goblin">
<inherit name="editor_object" />
<inherit name="female" />
<inherit name="monster" />
<alias>Goblin Skulker</alias>
<hurt>The goblin recoils from the blast, hurt, but still very much alive.</hurt>
<death>The goblin lies dead.</death>
<hitpoints type="int">12</hitpoints>
<lookwhendead>It is a dead goblin</lookwhendead>
</object>
</object>
<function name="TestFunction" parameters="obj">
if (DoesInherit (obj, "spell")) {
msg ("This is a spell")
}
</function>
<walkthrough name="test">
<steps type="list">
open spellbook
learn fireball
e
x parchment
cast unlock
learn unlock
cast unlock
e
cast unlock
e
cast fireball
west
learn aura
cast aura
cast unlock
cast aura
east
</steps>
</walkthrough>
</asl>
<library>
<template name="Learn">learn</template>
<template name="Cast">cast</template>
<template name="LookDead">Oh, and it is dead.</template>
<template name="SpellAlreadyKnown">Er, you already know that one!</template>
<template name="SpellNotKnown">Er, you don't know that one!</template>
<template name="NoMonstersPresent">No monsters are present</template>
<dynamictemplate name="SpellEnds"><![CDATA["The <i>" + GetDisplayAlias(object) + "</i> spell ends."]]></dynamictemplate>
<dynamictemplate name="SpellCast"><![CDATA["You cast <i>" + GetDisplayAlias(object) + "</i>."]]></dynamictemplate>
<dynamictemplate name="SpellLearned"><![CDATA["You have learned, and can now cast <i>" + GetDisplayAlias(object) + "</i> spell."]]></dynamictemplate>
<verb>
<property>learn</property>
<pattern>[Learn]</pattern>
<defaultexpression>"You can't learn " + object.article + "."</defaultexpression>
</verb>
<verb>
<property>cast</property>
<pattern>[Cast]</pattern>
<defaultexpression>"You can't cast " + object.article + "."</defaultexpression>
</verb>
<function name="SpellAttackMonster" parameters="monster, spell"><![CDATA[
element = GetElement (monster)
handled = False
if (not element = Null) {
if (DoesInherit (spell, element + "_type")) {
msg ("... " + monster.ignoreselement)
handled = True
}
if (DoesInherit (spell, StringDictionaryItem (element_structure.opposedelements, element) + "_type")) {
monster.hitpoints = monster.hitpoints - 2 * spell.powerrating
handled = True
if (monster.hitpoints > 0) {
msg ("... " + monster.hurtbyelement)
}
else {
msg ("... " + monster.deathbyelement)
Death (monster)
}
}
}
if (not handled) {
monster.hitpoints = monster.hitpoints - spell.powerrating
if (monster.hitpoints > 0) {
msg ("... " + monster.hurt)
}
else {
msg ("... " + monster.death)
Death (monster)
}
}
]]></function>
<function name="CancelSpell"><![CDATA[
if (HasObject (player, "currentspell")) {
spell = player.currentspell
msg (DynamicTemplate("SpellEnds", spell))
player.currentspell = null
if (HasScript (spell, "terminate")) {
do (spell, "terminate")
}
}
]]></function>
<function name="Death" parameters="monster"><![CDATA[
monster.alias = monster.alias + " (dead)"
if (HasString (monster, "lookwhendead")) {
monster.look = monster.lookwhendead
}
else {
monster.look = monster.look + " [LookDead]"
}
monster.dead = True
]]></function>
<function name="GetElement" parameters="obj" type="string"><![CDATA[
result = Null
foreach (element, element_structure.elements) {
type = element + "_type"
if (DoesInherit (obj, type)) {
result = element
}
}
return (result)
]]></function>
<function name="DescribeCast" parameters="spell"><![CDATA[
if (HasString (spell, "description")) {
msg (DynamicTemplate("SpellCast", spell) + " " + spell.description)
}
else {
msg (DynamicTemplate("SpellCast", spell))
}
]]></function>
<type name="spell">
<inventoryverbs type="list">Learn</inventoryverbs>
<displayverbs type="list">Learn</displayverbs>
<drop type="boolean">false</drop>
<take type="boolean">false</take>
<usedefaultprefix type="boolean">false</usedefaultprefix>
<learn type="script"><![CDATA[
if (not this.parent = player) {
this.parent = player
this.inventoryverbs = Split ("Cast", " ")
msg (DynamicTemplate("SpellLearned", this))
}
else {
msg ("[SpellAlreadyKnown]")
}
]]></learn>
</type>
<type name="attackspell">
<inherit name="spell"/>
<cast type="script"><![CDATA[
if (this.parent = player) {
DescribeCast (this)
flag = False
foreach (obj, ScopeVisibleNotHeld ()) {
if (DoesInherit (obj, "monster") and not GetBoolean (obj, "dead")) {
SpellAttackMonster (obj, this)
flag = True
}
}
if (not flag) {
msg ("... [NoMonstersPresent]")
}
CancelSpell ()
}
else {
msg ("[SpellNotKnown]")
}
]]></cast>
</type>
<type name="nonattackspell">
<inherit name="spell"/>
<cast type="script"><![CDATA[
if (this.parent = player) {
DescribeCast (this)
do (this, "spelleffect")
CancelSpell ()
}
else {
msg ("[SpellNotKnown]")
}
]]></cast>
</type>
<type name="lastingspell">
<inherit name="spell"/>
<cast type="script"><![CDATA[
if (this.parent = player) {
DescribeCast (this)
do (this, "spelleffect")
CancelSpell ()
player.currentspell = this
player.status = this.status
}
else {
msg ("[SpellNotKnown]")
}
]]></cast>
</type>
<type name="fire_type">
</type>
<type name="water_type">
</type>
<type name="air_type">
</type>
<type name="earth_type">
</type>
<type name="dark_type">
</type>
<type name="light_type">
</type>
<type name="monster">
</type>
<object name="element_structure">
<elements type="list">fire; water; air; earth; dark; light</elements>
<opposedelements type="stringdictionary">fire = water;water = fire;air = earth;earth = air;dark = light;light = dark</opposedelements>
</object>
<tab>
<parent>_ObjectEditor</parent>
<caption>Magic</caption>
<mustnotinherit>editor_room; defaultplayer</mustnotinherit>
<control>
<controltype>dropdowntypes</controltype>
<caption>Spell type</caption>
<types>*=None; nonattackspell=Non-attack spell; lastingspell=Lasting spell; attackspell=Attack spell; monster=Monster</types>
<width>150</width>
</control>
<control>
<controltype>title</controltype>
<caption>Non-Attack Spell</caption>
<mustinherit>nonattackspell</mustinherit>
</control>
<control>
<controltype>textbox</controltype>
<caption>Description (optional)</caption>
<attribute>description</attribute>
<mustinherit>nonattackspell</mustinherit>
</control>
<control>
<controltype>script</controltype>
<caption>Spell effect</caption>
<attribute>spelleffect</attribute>
<mustinherit>nonattackspell</mustinherit>
</control>
<control>
<controltype>title</controltype>
<caption>Lasting Spell</caption>
<mustinherit>lastingspell</mustinherit>
</control>
<control>
<controltype>textbox</controltype>
<caption>Description (optional)</caption>
<attribute>description</attribute>
<mustinherit>lastingspell</mustinherit>
</control>
<control>
<controltype>textbox</controltype>
<caption>Status when active</caption>
<attribute>status</attribute>
<mustinherit>lastingspell</mustinherit>
</control>
<control>
<controltype>script</controltype>
<caption>Spell effect</caption>
<attribute>spelleffect</attribute>
<mustinherit>lastingspell</mustinherit>
</control>
<control>
<controltype>script</controltype>
<caption>Cancel spell effect</caption>
<attribute>terminate</attribute>
<mustinherit>lastingspell</mustinherit>
</control>
<control>
<controltype>title</controltype>
<caption>Attack Spell</caption>
<mustinherit>attackspell</mustinherit>
</control>
<control>
<controltype>number</controltype>
<caption>Power of attack (1-10)</caption>
<attribute>powerrating</attribute>
<width>100</width>
<mustinherit>attackspell</mustinherit>
<minimum>0</minimum>
<maximum>10</maximum>
</control>
<control>
<controltype>textbox</controltype>
<caption>Description (optional)</caption>
<attribute>description</attribute>
<mustinherit>attackspell</mustinherit>
</control>
<control>
<controltype>dropdowntypes</controltype>
<caption>Element</caption>
<types>*=None; fire_type=Fire; water_type=Water; air_type=Air; earth_type=Earth; dark_type=Dark; light_type=Light</types>
<width>150</width>
<mustinherit>attackspell</mustinherit>
</control>
<control>
<controltype>title</controltype>
<caption>Monster</caption>
<mustinherit>monster</mustinherit>
</control>
<control>
<controltype>dropdowntypes</controltype>
<caption>Element</caption>
<types>*=None; fire_type=Fire; water_type=Water; air_type=Air; earth_type=Earth; dark_type=Dark; light_type=Light</types>
<width>150</width>
<mustinherit>monster</mustinherit>
</control>
<control>
<controltype>number</controltype>
<caption>Hit points</caption>
<attribute>hitpoints</attribute>
<width>100</width>
<mustinherit>monster</mustinherit>
<minimum>0</minimum>
</control>
<control>
<controltype>textbox</controltype>
<caption>Description on injury</caption>
<attribute>hurt</attribute>
<mustinherit>monster</mustinherit>
</control>
<control>
<controltype>textbox</controltype>
<caption>Description on death</caption>
<attribute>death</attribute>
<mustinherit>monster</mustinherit>
</control>
<control>
<controltype>textbox</controltype>
<caption>Description on injury by opposed element</caption>
<attribute>hurtbyelement</attribute>
<mustinherit>monster</mustinherit>
</control>
<control>
<controltype>textbox</controltype>
<caption>Description on death by opposed element</caption>
<attribute>deathbyelement</attribute>
<mustinherit>monster</mustinherit>
</control>
<control>
<controltype>textbox</controltype>
<caption>Description on ignore</caption>
<attribute>ignoreselement</attribute>
<mustinherit>monster</mustinherit>
</control>
<control>
<controltype>textbox</controltype>
<caption>Look (when dead)</caption>
<attribute>lookwhendead</attribute>
<mustinherit>monster</mustinherit>
</control>
</tab>
</library>
Neonayon wrote:So I've been rummaging through the old Quest documents about how to implement combat, but I think some of it might be outdated and possibly not clear enough for people to follow. Specifically, I ran across some instances that might need updating, and since I'm creating my own combat system following the guide I hope someone can help correct me along the way!
The information comes from this page. http://docs.textadventures.co.uk/quest/ ... types.html
Here is my spell.object<object name="spell">
<inherit name="editor_object" />
<alias> A Fireball Spell</alias>
<drop type="boolean">false</drop>
<take type="boolean">false</take>
<inventoryverbs type="stringlist">
<value>Cast</value>
</inventoryverbs>
<changedtype>spell</changedtype>
<feature_usegive />
<usedefaultprefix type="boolean">false</usedefaultprefix>
<look type="string"></look>
<usestandardverblist />
<displayverbs type="stringlist">
<value>Learn</value>
</displayverbs>
<learn type="script">
</learn>
<cast type="script">
and here is what that guide is telling me to put.
<type name="spell">
'''<learn type="script">'''
'''if (not this.parent = game.pov) {'''
'''this.parent = player'''
'''msg ("How about that? You can now cast " + this.alias + ".")'''
'''}'''
'''else {'''
'''msg ("Er, you already know that one!")'''
'''}
'''</learn>'''
<drop type="boolean">false</drop>
<take type="boolean">false</take>
</type>
Now I'm a noob at programming and coding. There's no question but looking at these two, I can see some obvious differences, especially some that might intimidate a newcomer to Quest. For one, things don't match up.
For example, <type name="spell">
I am going to assume that type name was changed to <object name="spell"> correct? Or have I misinterpreted this?
Also, following these directions, is this correct? The additions are in bold.
[quote]<object name="spell">
<inherit name="editor_object" />
<alias> A Fireball Spell</alias>
<learn type="script">
if (not this.parent = game.pov) {
msg ("How about that? You can now cast fireballs " + this.alias + ".")
}
"else {
msg ("Er, you already know that spell!")
}
</learn>
<drop type="boolean">false</drop>
<take type="boolean">false</take>
<inventoryverbs type="stringlist">
<value>Cast</value>
</inventoryverbs>
<changedtype>spell</changedtype>
<feature_usegive />
<usedefaultprefix type="boolean">false</usedefaultprefix>
<look type="string"></look>
<usestandardverblist />
<displayverbs type="stringlist">
<value>Learn</value>
</displayverbs>
<learn type="script">
</learn>
<cast type="script">
<inherit name="spell" />
A type is different to an object. A type describes a set of objects, in this case spells. Your object is a fireball spell, a specific instance of the spell type. To set a fireball spell to be of the type spell, you need a line like this:
<inherit name="spell" />
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="xxx">
<gameid>xxx</gameid>
<version>1.0</version>
</game>
<object name="room">
<inherit name="editor_room" />
</object>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<attr name="parent" type="object">room</attr>
</object>
<object name="fireball">
<inherit name="editor_object" />
<inherit name="spell" />
<inherit name="fire" />
<attr name="parent" type="object">xxx</attr>
<alias>A Fireball Spell</alias>
<drop type="boolean">false</drop>
<take type="boolean">false</take>
<feature_usegive />
<usedefaultprefix type="boolean">false</usedefaultprefix>
<look type="string"></look>
<usestandardverblist />
</object>
<type name="fire">
<attr name="elemental" type="string">fire</attr>
</type>
<type name="spell">
<learn type="script">
// blah scripts
</learn>
<cast type="script">
// blah scripts
</cast>
<inventoryverbs type="stringlist">
<value>Cast</value>
</inventoryverbs>
<displayverbs type="stringlist">
<value>Learn</value>
</displayverbs>
</type>
</asl>
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="xxx">
<gameid>xxx</gameid>
<version>1.0</version>
</game>
<object name="room">
<inherit name="editor_room" />
</object>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<attr name="parent" type="object">xxx</attr>
</object>
<object name="fireball">
<inherit name="editor_object" />
<attr name="parent" type="object">xxx</attr>
<alias>A Fireball Spell</alias>
<drop type="boolean">false</drop>
<take type="boolean">false</take>
<feature_usegive />
<usedefaultprefix type="boolean">false</usedefaultprefix>
<look type="string"></look>
<usestandardverblist />
<attr name="type_of_object" type="string">spell</attr>
<attr name="elemental" type="string">fire</attr>
<learn type="script">
// blah scripts
</learn>
<cast type="script">
// blah scripts
</cast>
<inventoryverbs type="stringlist">
<value>Cast</value>
</inventoryverbs>
<displayverbs type="stringlist">
<value>Learn</value>
</displayverbs>
</object>
</asl>
Neonayon wrote:Oh, Pixie did you get my email a few days ago? Sorry to pester you, just wondering.
Neonayon wrote:
Oh, Pixie did you get my email a few days ago? Sorry to pester you, just wondering.
I did. the issue about inventory limits looks to be a bug to me, and I am trying to get is acknowledged as such, without much success!
https://github.com/textadventures/quest/issues/816
I will reply properly soon(ish).
Neonayon wrote:I wish I could just create an object "Spell"
and then make a bunch of children, "Fire Ball", "Ice Blast", "Earth Quake", "Shadow Slice", "Luminaire" and "Wind Concussion"
Although, from what it sounds like, that is exactly what types do.
<elementname name1="value1" name2="value2">The content</elementname>
^^^^^^^start tag wiith attributes^^^^^^^^^^ ^^^^end tag^^^
<learn type="script">
<![CDATA[
]]></learn>
<object name="xxx">
// body~contents
</object>
<![CDATA[
// scripting with the '< (lesser than)' and '> (greater than)' symbols used for logic-math comparisons
]]>
<function name="addition_function" type="int" parameters="A,B">
return (A+B)
</function>
// function call: addition_function(5,10)
// outputs~returns: 15
<function name="game_over_function"><![CDATA[
if (player.current_life <= 0) {
msg ("You died.")
msg ("GAME OVER")
finish
}
]]></function>
-------------
using these examples:
<statusattributes type="simplestringdictionary">status = ;equippedstatus = !</statusattributes>
the KEY is to the left of the equals (=) sign.
the VALUE~EXPRESSION is to the right of the equals (=) sign.
the semicolon separates the items (KEY1=VALUE1; KEY2=VALUE2; etc etc etc)
KEYS:
status
equippedstatus
VALUES:
(empty, default Value display)
! (represents the Attribute's Value)
---
strength Strength: !
<statusattributes type="simplestringdictionary">strength = Strength: !</statusattributes
KEY:
strength
VALUE~EXPRESSION:
Strength: !
-----
for horizontal form, you use: type="simplestringdictionary"
for vertical form, you use: type="stringdictionary"
------
this:
<equippedstatus>Wielding: nothing</equippedstatus>
is a String Attribute, not a Stringdictionary Attribute.
unless it is a special scripting (like the special "changed" script), it's been a long time since I've worked with Status Attributes, and Equipment Stuff ~ Libraries of Pixie~Chase~Pertex.
-------------------------
Lists and Dictionaries are a way to store multiple values into a single Variable name:
[code]<attr name="color_list" type="simplestringlist">red;blue;yellow;green;orange;purple;black;white</attr>
// conceptually:
color_list = {
red
blue
yellow
green
orange
purple
black
white
}
<attr name="season_dictionary" type="simplestringdictionary">january=winter; february=winter; march=spring; april=spring; may=spring; june=summer; july=summer; august=summer; september=autumn; october=autumn; november=autumn; december=winter</attr>
// conceptually:
season_dictionary = {
january = winter
february = winter
march = spring
april = spring
etc etc etc
}
<object name="Fists">
<inherit name="melee" />
<attr name="alias" type="string">fists</attr>
</object>
<object name="Scissors">
<inherit name="melee" />
<attr name="alias" type="string">scissors</attr>
</object>
<object name="Rickety_Machete">
<inherit name="melee" />
<attr name="alias" type="string">machete</attr>
</object>
// and for your 'player' Object:
<object name="player">
<attr name="equipped" type="object">Fists</attr>
// or, you may want~need to use an Objectlist Attribute, as I believe you're not using a single equipment item for your character, right?:
// <attr name="equipped" type="objectlist">Fists;Shirt;Pants;Socks;Shoes</attr>
// we can help you with using Objectlists Attributes.
</object>
game.pov.equipped.alias: your weapon Object needs an 'alias' String Attribute added to it, else ERROR!
the error code is saying that your scripting requires Objects (for the 'this' to get~represent the parent~corresponding Object: this.alias, or: game.pov.equipped.alias), and you don't have those Objects (or don't have the Attributes added to those Objects).
if (this.parent = game.pov) {
if (not game.pov.equipped = fists and not game.pov.equipped = null) {
msg ("You put away your " + game.pov.equipped.alias + " and draw your " + this.alias + ".")
}
else {
msg ("You draw your " + this.alias + ".")
}
game.pov.equipped = this
this.inventoryverbs = Split ("Look at;Drop;Unequip", ";")
game.pov.equippedstatus = "Wielding: " + this.alias
}
else {
msg ("<br/>You dont have it.<br/>")
}
if (this.parent = game.pov) {
msg ("You put away your " + game.pov.equipped.alias + ".")
game.pov.equipped = fists
this.inventoryverbs = Split ("Look at;Drop;Equip", ";")
game.pov.equippedstatus = "Wielding: nothing"
}
else {
msg ("You don't have it.")
}
if (this.parent = game.pov) {
msg ("You put away your " + game.pov.equipped.alias + ".")
game.pov.equipped = fists
this.inventoryverbs = Split ("Look at;Drop;Equip", ";")
game.pov.equippedstatus = "Wielding: nothing"
}
else {
msg ("You don't have it.")
}
if (this.parent = game.pov) {
msg ("You put away your " + game.pov.equipped.alias + ".")
game.pov.equipped = fists
this.inventoryverbs = Split ("Look at;Drop;Equip", ";")
game.pov.equippedstatus = "Wielding: nothing"
}
else {
msg ("You don't have it.")
}
if (this.parent = game.pov) {
msg ("You put away your " + game.pov.equipped.alias + ".")
game.pov.equipped = this.name
this.inventoryverbs = Split ("Look at;Drop;Unequip", ";")
game.pov.equippedstatus = "Wielding: " + this.alias
}
else {
msg ("You don't have it.")
}
in your PLAYER'S* STATUS ATTRIBUTES, change it to this:
* (I'm just making sure you're not using the: 'game' Object -> 'attributes' tab -> Status Attributes)
Sounds like game.pov.equipped has not been set. Might be worth checking the spelling of "equipped" where it is supposed to be set. You could also put in a "msg" after the line where equipped is supposed to get set, to see if Quest gets to that line.
No, this can't work. "game.pov.equipped" is a string attribute and does not have an alias attribute. Try the following
Code: Select all
if (this.parent = game.pov) {
x=GetObject(game.pov.equipped)
msg ("You put away your " + x.alias + ".")
...
if (this.parent = game.pov) {
x = GetObject(game.pov.equipped)
msg ("You put away your " + x.alias + ".")
game.pov.equipped = this.name
this.inventoryverbs = Split ("Look at;Drop;Unequip", ";")
game.pov.equippedstatus = "Wielding: " + this.alias
}
else {
msg ("You don't have it.")
}
if (this.parent = game.pov) {
x = GetObject(game.pov.equipped)
msg ("You put away your " + x.alias + ".")
game.pov.equipped = this.name
this.inventoryverbs = Split ("Look at;Drop;Unequip", ";")
game.pov.equippedstatus = "Wielding: " + this.alias
}
else {
msg ("You don't have it.")
}
HegemonKhan wrote:I think neonayon wanted to use the 'equipped' as an Object Attribute, as this is only going (is supposed to) hold a single weapon. Also, working with lists (objectlists) would probably be too difficult for her currently, I think (I'd love to be wrong, impress me neonayon!, lol, hehe).
I told her to use the '= this.name' (or would it just be: this, and not this.name ???) as I thought 'equipped' was an Object Attribute....
if (this.parent = game.pov) {
x = GetObject(game.pov.equipped)
if (not game.pov.equipped = fists and not game.pov.equipped = null) {
msg ("You put away your " + x.alias + " and draw your " + x.alias + ".")
}
else {
msg ("You draw your " + x.alias + ".")
}
game.pov.equipped = this
this.inventoryverbs = Split ("Look at;Drop;Unequip", ";")
game.pov.equippedstatus = "Wielding: " + x.alias
}
else {
msg ("<br/>You dont have it.<br/>")
}
if (this.parent = game.pov) {
x = GetObject(game.pov.equipped = this)
msg ("You put away your " + x.alias + ".")
game.pov.equipped = this.name
this.inventoryverbs = Split ("Look at;Drop;Unequip", ";")
game.pov.equippedstatus = "Wielding: " + this.alias
}
else {
msg ("You don't have it.")
}
if (this.parent = game.pov) {
// you do not need the next line (or any reference to x)
// the error is because GetObject expects a string, and you have sent it an object
x = GetObject(game.pov.equipped)
if (not game.pov.equipped = fists and not game.pov.equipped = null) {
// in the next line you are telling player he puts something away, and then draws the same thing here!
msg ("You put away your " + x.alias + " and draw your " + x.alias + ".")
// he should be putting away player.pov.equipped.alias
// and drawing this.alias
}
else {
// again, he should be drawing this.alias
msg ("You draw your " + x.alias + ".")
}
// next to lines you get it right
game.pov.equipped = this
this.inventoryverbs = Split ("Look at;Drop;Unequip", ";")
// but again, he should be drawing this.alias
game.pov.equippedstatus = "Wielding: " + x.alias
}
else {
msg ("<br/>You dont have it.<br/>")
}
if (this.parent = game.pov) {
if (not game.pov.equipped = fists and not game.pov.equipped = null) {
msg ("You put away your " + player.pov.equipped.alias + " and draw your " + this.alias + ".")
}
else {
msg ("You draw your " + this.alias + ".")
}
game.pov.equipped = this
this.inventoryverbs = Split ("Look at;Drop;Unequip",";")
game.pov.equippedstatus = "Wielding: " + this.alias
}
else {
msg ("<br/>You dont have it.<br/>")
}
if (this.parent = game.pov) {
if (not game.pov.equipped = fists and not game.pov.equipped = null) {
msg ("You put away your " + player.pov.equipped.alias + " and draw your " + this.alias + ".")
}
else {
msg ("You draw your " + this.alias + ".")
}
game.pov.equipped = this
this.inventoryverbs = Split ("Look at;Drop;Unequip",";")
game.pov.equippedstatus = "Wielding: " + this.alias
}
else {
msg ("<br/>You dont have it.<br/>")
}
if (this.parent = game.pov) {
if (not game.pov.equipped = fists and not game.pov.equipped = null) {
msg ("You put away your " + game.pov.equipped.alias + " and draw your " + this.alias + ".")
}
else {
msg ("You draw your " + this.alias + ".")
}
game.pov.equipped = this
this.inventoryverbs = Split ("Look at;Drop;Unequip", ";")
game.pov.equippedstatus = "Wielding: " + this.alias
}
else {
msg ("<br/>You dont have it.<br/>")
}
if (this.parent = game.pov) {
msg ("You put away your " + game.pov.equipped.alias + ".")
game.pov.equipped = fists
this.inventoryverbs = Split ("Look at;Drop;Equip", ";")
game.pov.equippedstatus = "Wielding: nothing"
}
else {
msg ("You don't have it.")
}
Do you have a fists object? If you do, make sure player.equipped is set to that object on the attributes tab. If not create one, and then set it.
game.pov.equippedstatus = "Wielding: " + this.alias
...
and the player.equipped (attribute) reads: fists, rickety_machete, scissors
...
"You put away your " + player.pov.equipped.alias + " and draw your " + this.alias + "."
<object name="player">
<attr name="equipped" type="object">Fists</attr>
</object>
Equip Fists:
player.equipped = Fists
player.equippedstatus = this.alias + "(Equipped)"
// output: Fists (Equipped)
Unequip Fists:
(this should not exist)
Equip Knife:
player.equipped = Knife
player.equippedstatus = this.alias + "(Equipped)"
// output: Knife (Equipped)
Unequip Knife:
player.equipped = Fists
player.equippedstatus = this.alias + "(Equipped)"
// output: Fists (Equipped)
Neonayon wrote:if (this.parent = game.pov) {
if (not game.pov.equipped = fists and not game.pov.equipped = null) {
msg ("You put away your " + player.pov.equipped.alias + " and draw your " + this.alias + ".")
}
else {
msg ("You draw your " + this.alias + ".")
}
game.pov.equipped = this
this.inventoryverbs = Split ("Look at;Drop;Unequip",";")
game.pov.equippedstatus = "Wielding: " + this.alias
}
else {
msg ("<br/>You dont have it.<br/>")
}
'Equip' Verb (use this code for all of your weapons' 'Equip' Verbs):
if (this.parent = game.pov) {
if (not game.pov.equipped = Fists) {
previous_weapon_alias = game.pov.equipped.alias
game.pov.equipped = this
game.pov.equippedstatus = "Wielding: " + game.pov.equipped.alias
this.inventoryverbs = Split ("Look at;Drop;Unequip",";")
msg ("You put away your " + previous_weapon_alias + " and draw your " + game.pov.equipped.alias + ".")
} else {
msg ("You already are equipped with just your " + Fists.alias + ".")
}
}
else {
msg ("<br/>You dont have it.<br/>")
}
'Unequip' Verb (use this code for all of your weapons' 'Unequip' Verbs, EXCEPT for your 'FISTS' weapon as it doesn't have an 'Unequip' Verb*):
// * Whenever you unequip your other weapons, their 'Unequip' Verb's code, will equip the 'Fists' weapon, so this is why there's no 'Unequip' Verb for the 'Fists' weapon
if (this.parent = game.pov) {
// I removed the if, as it's not needed, due to the verb in 'inventoryverbs'
game.pov.equipped = Fists
game.pov.equippedstatus = "Wielding: " + game.pov.equipped.alias
this.inventoryverbs = Split ("Look at;Drop;Equip",";")
msg ("You put away your " + this.alias + " and draw your " + game.pov.equipped.alias + ".")
// I removed the else, as it's not needed, due to switching the verb in 'inventoryverbs'
}
else {
msg ("<br/>You dont have it.<br/>")
}
if (this.parent = game.pov) {
if (not game.pov.equipped = Fists) {
previous_weapon_alias = game.pov.equipped.alias
game.pov.equipped = this
game.pov.equippedstatus = "Wielding: " + game.pov.equipped.alias
this.inventoryverbs = Split ("Look at;Drop;Unequip",";")
msg ("You put away your " + previous_weapon_alias + " and draw your " + game.pov.equipped.alias + ".")
} else {
msg ("You already are equipped with just your " + Fists.alias + ".")
}
}