Monsters?

Is it possible to create characters that give items, take (rob) items, or kill ? And how are they created?


(filler for getting my edited post, updated/posted)


yes, there's an infinite number of designs...


here's one quick simple example:

<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>

  <attr name="weapon" type="object">unarmed</attr>

  <attr name="actions" type="simplestringlist">attack;steal</attr>

  <attr name="currency" type="int">0</attr>
  <attr name="experience" type="int">0</attr>

  <attr name="life" type="string">999/999</attr>

  <attr name="statusattributes" type="stringdictionary">

    <item>
     <key>name</key>
     <value>Name: !</value>
    </item>

    <item>
      <key>life</key>
     <value>Life: !</value>
    </item>

    <item>
     <key>weapon</key>
     <value>Weapon: !</value>
    </item>

    <item>
     <key>currency</key>
     <value>Currency: !</value>
    </item>

    <item>
     <key>experience</key>
     <value>Experience: !</value>
    </item>

  </attr>

  <attr name="current_life" type="int">999</attr>

  <attr name="changedcurrent_life" type="script">
    <![CDATA[
      if (this.current_life > this.maximum_life) {
        this.current_life = this.maximum_life
      } else if (this.current_life < 1) {
        msg ("You were killed or have died")
        msg ("GAME OVER")
        finish
      }
      this.life = this.current_life + "/" + this.maximum_life
    ]]>
  </attr>

  <attr name="maximum_life" type="int">999</attr>

  <attr name="changedmaximum_life" type="script">
    <![CDATA[
      if (this.current_life > this.maximum_life) {
        this.current_life = this.maximum_life
      }
      this.life = this.current_life + "/" + this.maximum_life
    ]]>
  </attr>

</object>

<object name="orc">

  <inherit name="editor_object" />

  <attr name="parent" type="object">room</attr>

  <attr name="dead" type="boolean">false</attr>

  <attr name="actions" type="simplestringlist">attack;steal</attr>

  <attr name="weapon" type="object">club</attr>

  <attr name="currency" type="int">100</attr>
  <attr name="experience" type="int">50</attr>

  <attr name="current_life" type="int">10</attr>

  <attr name="changedcurrent_life" type="script">
    <![CDATA[
      if (this.current_life > this.maximum_life) {
        this.current_life = this.maximum_life
      } else if (this.current_life < 1) {
        this.current_life = 0
        this.dead = true
        msg ("The " + this.name + " was killed")
      }
      this.life = this.current_life + "/" + this.maximum_life
    ]]>
  </attr>

  <attr name="maximum_life" type="int">10</attr>

  <attr name="changedmaximum_life" type="script">
    <![CDATA[
      if (this.current_life > this.maximum_life) {
        this.current_life = this.maximum_life
      }
      this.life = this.current_life + "/" + this.maximum_life
    ]]>
  </attr>

  <attr name="displayverbs" type="listextend">fight</attr>

  <attr name="fight" type="script">
    if (this.dead) {
      firsttime {
        player.experience = player.experience + this.experience
        player.currency = player.currency + this.currency
        player.parent = this.weapon
        msg ("You loot the " + this.name + "'s dead corpse")
      } otherwise {
        msg ("The " + this.name + " is dead and already has been looted")
      }
    } else {
      show menu ("Action?", player.actions, false) {
        if (result = "attack") {
          this.current_life = this.current_life - player.weapon.damage
          msg ("You attack the " + this.name + " for " + player.weapon.damage + " damage")
          msg (this.name + "'s Life: " + this.life) 
        } else if (result = "steal" and not this.weapon = unarmed) {
          if (RandomChance (GetRandomInt (0, 100))) {
            player.parent = this.weapon
            this.weapon = unarmed
            msg ("You stole the " + this.weapon.name + " from the " + this.name)
          } else {
            msg ("Your attempt at stealing failed")
          }
        }
      }
      if (not this.dead) {
        action = GetRandomInt (0, ListCount (this.actions) - 1)
        if (action = "fight") {
          player.current_life = player.current_life - this.weapon.damage
          msg ("The " + this.name + " attacks you for " + this.weapon.damage + " damage")
          msg (player.name + "'s Life: " + player.life)
        } else if (action = "steal" and not this.weapon = unarmed) {
          if (RandomChance (GetRandomInt (0, 100))) {
            this.parent = player.weapon
            player.weapon = unarmed
            msg ("The " + this.name + " stole the " + player.weapon.name + " from you")
          } 
        }
      }
    }
  </attr>

</object>

<object name="unarmed">

  <inherit name="editor_object" />

  <attr name="damage" type="int">1</attr>

</object>

<object name="club">

  <inherit name="editor_object" />

  <attr name="damage" type="int">5</attr>

</object>

<verb>

  <property>fight</property>
  <pattern>fight</pattern>

  <defaultexpression>You can't fight that!</defaultexpression>

</verb>

forgot to show 'giving items'... (it can be the same method as my 'steal' as well) but you can look at the tutorial on how to do this:

http://docs.textadventures.co.uk/quest/tutorial/ (main page)

http://docs.textadventures.co.uk/quest/tutorial/more_things_to_do_with_objects.html (specifically, but it uses a more advanced example with 'use' and Command usage...)

you might also want to look at this page too:

http://docs.textadventures.co.uk/quest/tutorial/moving_objects_during_the_game.html

ask if you need help with anything


It's complicated.

I recommend downloading or looking at someone else's combat code.
In particular, recommend The Pixie's zombie code, since it has the most features, has simple instructions, and it has a lot of the things you described. https://github.com/ThePix/quest/wiki/The-Zombie-Apocalypse-(on-the-web-version)


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums