Attributes not showing up in Command Panel properly

So I've made sure that my attributes are integers in the right spot and that they're added as Status Attributes with the right spelling, but only some of them will show up with the numbers added into the attributes integers.

The status bar looks like this:

HitPoints: 5
Damage: 0
Attack: 0
Armour: 1
Defence: 0

NOTE: None of them should be 0 as I set them all at 1 just to take a look. The player's code is below. For reference, I've started trying to put together the excellent Zombie Combat code described here: https://github.com/ThePix/quest/wiki/The-Zombie-Apocalypse-(on-the-web-version)

I should also add that I've changed attack and damage in all the other code to Attack and Damage so it would show up in the Control panel properly.

      <inherit name="editor_object" />
      <inherit name="editor_player" />
      <attr name="pov_look">Looking like you could use a shower and some rest and relaxation.  When was the last time you got a good night's sleep anyhow?</attr>
      <dead type="boolean">false</dead>
      <HitPoints type="int">5</HitPoints>
      <statusattributes type="stringdictionary">
        <item>
          <key>HitPoints</key>
          <value></value>
        </item>
        <item>
          <key>Damage</key>
          <value></value>
        </item>
        <item>
          <key>Attack</key>
          <value></value>
        </item>
        <item>
          <key>Armour</key>
          <value></value>
        </item>
        <item>
          <key>Defence</key>
          <value></value>
        </item>
      </statusattributes>
      <Attack type="int">1</Attack>
      <Damage type="int">1</Damage>
      <Defence type="int">1</Defence>
      <equipped type="string"></equipped>
      <feature_startscript />
      <Armour type="int">1</Armour>
      <changedHitPoints type="script"><![CDATA[
        if (this.HitPoints < 1) {
          msg ("You're dead!")
          this.dead = true
        }
      ]]></changedHitPoints>
      <attr name="_initialise_" type="script"><![CDATA[
        player.alias = "you"
        player.HitPoints = 5
        player.Damage = 0
        player.Attack = 0
        player.Defence = 0
        player.changedHitPoints => {
          if (player.HitPoints > 0) {
            msg ("Hits points now " + player.hitpoints)
          }
          else {
            msg ("You are dead!")
            wait {
              MoveObject (player, Starting Area)
            }
          }
        }
      ]]></attr>

Okay, I solved it ... the Initialisation Script trumps what I put in the attributes section. Silly me!


All right new issue that may relate to the above code so posting it here ... I've got the zombies following, I've got them attacking and I can attack back, but it's not changing the player's hit points. It counts down the zombie's hit points but when they hit 0 it just says They're Dead but they keep moving (in other words it's not changing their dead to true).

THE ZOMBIE

      <inherit name="editor_object" />
      <inherit name="surface" />
      <inherit name="talkingchar" />
      <inherit name="male" />
      <alias>Zed-Synth</alias>
      <displayverbs type="stringlist">
        <value>Look at</value>
        <value>Attack</value>
      </displayverbs>
      <feature_startscript />
      <feature_container />
      <dead type="boolean">false</dead>
      <contentsprefix>on which there are</contentsprefix>
      <hidechildren />
      <listchildren />
      <listchildrenprefix>It is carrying</listchildrenprefix>
      <gender>it</gender>
      <article>it</article>
      <possessive>its</possessive>
      <Attack type="int">0</Attack>
      <Armour type="int">0</Armour>
      <Defence type="int">0</Defence>
      <HitPoints type="int">2</HitPoints>
      <Damage>1d6</Damage>
      <alt type="stringlist">
        <value>zed</value>
        <value>zed-synth</value>
        <value>zombie</value>
      </alt>
      <look type="script">
        if (zombie.dead = false) {
          msg ("The creature twitches weirdly as you watch it.")
        }
        else if (zombie.dead = true) {
          msg ("It's so hard not to think of the zed-synth's corpse as a person who once had hopes and desires.")
        }
      </look>
      <greet type="script">
        msg ("It snarls at you.")
      </greet>
      <changedHitPoints type="script"><![CDATA[
        if (zombie.HitPoints < 1) {
          msg ("It collapses to the ground with a gurgle.")
          this.dead = true
          this.listalias = this.listalias + " (dead)"
        }
      ]]></changedHitPoints>
      <attr name="_initialise_" type="script"><![CDATA[
        zombie.alias = "zed-synth"
        zombie.HitPoints = 7
        zombie.Damage = 3
        zombie.Attack = 0
        zombie.Defence = 0
        zombie.Armour = 0
        zombie.changedHitPoints => {
          if (zombie.HitPoints > 0) {
            msg ("Hit points now " + zombie.HitPoints)
          }
          else {
            msg ("It collapses, dead!")
          }
        }
      ]]></attr>

THE DO ATTACK FUNCTION.  Please note I replaced weapon with attacker because I don't want to include weapons.

````  <function name="DoAttack" parameters="attacker, weapon, target"><![CDATA[
    roll = GetRandomInt(1, 10) + attacker.Attack - target.Defence
    Damage = DiceRoll(attacker.Damage) * (100 - target.Armour) / 100
    if (Damage < 1) {
      Damage = 1
    }
    if (roll > 9) {
      Damage = Damage * 2
      msg (CapFirst(attacker.alias) + " attacks " + target.alias + " and gets a critical (" + Damage + " Hits)!")
      target.HitPoints = target.HitPoints - Damage
    }
    else if (roll > 4) {
      msg (CapFirst(attacker.alias) + " attacks " + target.alias + " and hit (" + Damage + " Hits).")
      target.Hitpoints = target.HitPoints - Damage
    }
    else {
      msg (CapFirst(attacker.alias) + " attacks " + target.alias + " and misses...")
    }

And Solved ... not sure what the error was but I was fresh in that I just re-did it in a fresh area and got it working. I'd delete the thread buuuuut it doesn't look like that's a thing.


Same error as the first one.
Your initialise script was setting the changedHitPoints script to:

        if (zombie.HitPoints > 0) {
            msg ("Hit points now " + zombie.HitPoints)
          }
          else {
            msg ("It collapses, dead!")
          }

which prints a message to say it's dead, but doesn't set the dead attribute. If you change script attributes during the game, you need to remember that it will only execute the latest version.


This is what my start script looks like.
(Putting stuff here)

player.alias = "you"
player.hitpoints = 110
player.max = 110
player.damage = 3
player.attack = 1
player.defence = 0
player.armour = 0
player.exp = 0
player.level = 0
player.attackers = NewObjectList()
player.ammo = 50
player.potion = 1
player.hyper_potion = 0
player.gold = 0
player.statusattributes = NewStringDictionary()
dictionary add (player.statusattributes, "hitpoints", "Hit points: !")
dictionary add (player.statusattributes, "ammo", "Spare ammo: !")
dictionary add (player.statusattributes, "equippedname", "Weapon: !")
dictionary add (player.statusattributes, "ammonote", "Ammo: !")
dictionary add (player.statusattributes, "reallevel", "Level: !")
dictionary add (player.statusattributes, "exp", "EXP: !")
dictionary add (player.statusattributes, "potion", "Potions: !")
dictionary add (player.statusattributes, "hyper_potion", "Hyper Potions: !")
Spade.damage = "2d5"
Spade.attack = 3
Spade.critdesc = "You smash the spade down on #target# (#hits# hits)."
Spade.attackdesc = "You swing the spade at #target# (#hits# hits)."
Spade.missdesc = "You swing wildly and entirely miss #target#."
Pistol.damage = 0
Pistol.attack = 0
Pistol.firearmdamage = "3d7"
Pistol.firearmattack = 3
Pistol.ammo = 7
Pistol.ammomax = 7
Pistol.critdesc = "A well placed shot with the pistol on #target# (#hits# hits)."
Pistol.attackdesc = "You shot the pistol at #target# (#hits# hits)."
Pistol.missdesc = "You shoot wildly and entirely miss #target#."
game.notarealturn = false
dictionary add (player.statusattributes, "gold", "Gold: !")
player.changedhitpoints => {
  if (player.hitpoints > 0) {
    msg ("Hits points now " + player.hitpoints)
  }
  else {
    finish
  }
}
player.reallevel = 1
Spade1.damage = "5d6"
Spade1.attack = 6
Spade1.critdesc = "You slash the sword down on #target# (#hits# hits)."
Spade1.attackdesc = "You swing the sword at #target# (#hits# hits)."
Spade1.missdesc = "You swing wildly and entirely miss #target#."
SMG.damage = 2
SMG.attack = 1
SMG.firearmdamage = "4d8"
SMG.firearmattack = 11
SMG.ammo = 7
SMG.ammomax = 7
SMG.critdesc = "You shoot a fiery, well placed shot with the SMG on #target# (#hits# hits)."
SMG.attackdesc = "You shot the SMG at #target# (#hits# hits)."
SMG.missdesc = "You shoot, but entirely miss #target#."
game.hard = false
game.ultrahard = false
game.spawn = false
game.spawncount = 0
game.count2 = 0
player.critdesc = "You attack #target# with your bare hands and get a critical (#hits# hits)."
player.attackdesc = "You attack #target# with your bare hands and hit (#hits# hits)."
player.missdesc = "You swing wildly and entirely miss #target#."

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

Support

Forums