Player Cannot Equip Sentret Because Of Inherited Type

I was working on my game, Pokemon Type Harley Johto And Sinnoh, and I had another problem. I can't equip certain Pokemon, even after editing the equip command. The game says there is an inherited type the object needs to be equipped. It probably has something to do with that. I'm using a modified version of the Pixie's Zombie Survival game. I keep getting this error.

jj

This is the code for my equip command.

if (not HasAttribute(object, "damage")) {
  msg ("That's not something you can equip.")
}
else if (not object.parent = player) {
  msg ("You are not carrying it.")
}
else if (object = player.equipped) {
  msg ("You already have.")
}
else {
  if (HasAttribute (object, "dead")) {
    if (not HasAttribute(object, "damage")) {
      msg ("That's not something you can equip.")
    }
    else if (not object.parent = player) {
      msg ("You are not carrying it.")
    }
    else if (object = player.equipped) {
      msg ("You already have.")
    }
    else {
      if (player.equipped = null) {
        msg ("You equip your " + GetDisplayAlias(object) + ".")
      }
      else {
        msg ("You put away your " + GetDisplayAlias(player.equipped) + " and equip your " + GetDisplayAlias(object) + ".")
        list add (player.equipped.inventoryverbs, "Equip")
        list remove (player.equipped.inventoryverbs, "Unequip")
        player.equipped.alias = Replace(player.equipped.alias, " (equipped)", "")
      }
      player.equipped = object
      list add (object.inventoryverbs, "Unequip")
      list remove (object.inventoryverbs, "Equip")
      object.alias = object.alias + " (equipped)"
    }
  }
  else {
    if (player.equipped = null) {
      msg ("You equip your " + GetDisplayAlias(object) + ".")
    }
    else {
      msg ("You put away your " + GetDisplayAlias(player.equipped) + " and equip your " + GetDisplayAlias(object) + ".")
      list add (player.equipped.inventoryverbs, "Equip")
      list remove (player.equipped.inventoryverbs, "Unequip")
      player.equipped.alias = Replace(player.equipped.alias, " (equipped)", "")
    }
    player.equipped = object
    list add (object.inventoryverbs, "Unequip")
    list remove (object.inventoryverbs, "Equip")
    object.alias = object.alias + " (equipped)"
  }
}
WeaponUpdate

This is the code for my SpawnSentret function.

player.current_room = player.parent
player.old_room = player.current_room
MoveObject (player, Battle Room)
if (HasInt(game, "crittercount")) {
  game.crittercount = game.crittercount + 1
}
else {
  game.crittercount = 1
}
create ("crittercount" + game.crittercount)
obj = GetObject("crittercount" + game.crittercount)
obj.parent = room
obj.displayverbs = Split("Look at;Attack;Direct Hit;Stat;Status", ";")
obj.dead = false
obj.hero = false
obj.changedhitpoints => {
  if (this.hitpoints < 1) {
    this.dead = true
    msg ("It whited out!")
    player.exp = player.exp + 20
    player.pokedollar = player.pokedollar + 5
    roll2 = GetRandomInt(1,20)
    pokeroll = player.catchrate + roll2
    if (pokeroll > 16) {
      if (player.team > 7) {
        MoveObject (this, PC)
        this.displayverbs = Split("Look at;Equip;Reload", ";")
        msg ("object.alias was moved to the PC.")
        obj.hero = true
        player.parent = player.old_room
      }
      else {
        this.displayverbs = Split("Look at;Equip;Reload", ";")
        AddToInventory (this)
        obj.hero = true
        player.team = player.team + 1
        player.parent = player.old_room
      }
    }
    else {
      RemoveObject (this)
      player.parent = player.old_room
    }
  }
}
obj.element = "Normal"
obj.alias = "Sentret"
obj.listalias = CapFirst(obj.alias)
obj.look = ProcessText("A " + obj.alias + ". A normal type. A very cautious Pokémon, it raises itself up using its tail to get a better view of its surroundings.")
obj.critdesc = "A well-placed blow by #attacker# sends you reeling (#hits# hits)."
obj.attackdesc = "#Attacker# hits you (#hits# hits)."
obj.missdesc = "#Attacker# misses you."
obj.hitpoints = 20
obj.max = 20
obj.damage = 3
obj.maxdamage = 3
obj.attack = 1
obj.maxattack = 1
obj.defence = 0
obj.maxdefence = 0
obj.armour = 0
obj.maxarmour = 0
obj.speed = 10
obj.maxspeed = 10
obj.contestpoints = 100
obj.maxcontestpoints = 100
obj.tough = 5
obj.maxtough = 5
obj.beauty = 6
obj.maxbeauty = 6
obj.cool = 4
obj.maxcool = 4
obj.smart = 2
obj.maxsmart = 2
obj.cute = 4
obj.maxcute = 4
obj.trainerpoke = false
obj.faint = false
obj.selectweapon => {
  this.weapon = GetObject(PickOneString("Struggle;Quick Attack;Scratch"))
}
obj.selectattack => {
  this.weapon = GetObject(PickOneString("Struggle;Quick Attack;Scratch"))
}
this.firearmdamage = 4
this.firearmattack = 2
this.ammo = 20
this.ammomax = 20

This is the link to my game.
http://textadventures.co.uk/games/view/5jllte-m4e2e2whw4gf5jq/pokemon-type-harley-johto-and-sinnoh


Okay, I can't play my game right now for some odd reason. I will get the error later.
From memory, it said something like: Cannot modify list. Clone list first before modifying its contents.


This is actually in the docs, on this page, almost at the bottom:
http://docs.textadventures.co.uk/quest/problems.html

The problem is that a list attribute is defined in the type, not the object itself. When you add or remove an item from the list, Quest objects because the change would affect every object of the type, which would probably be a bug.

If you add this to the end of your spawn script, it should solve it.

object.inventoryverbs = Split("Look at;Drop;Wield")

By the way, I would guess the last four lines of the spawn script should say "obj" rather than "this".


as Pixie already explained in his post and the link in it:

that's the one issue with using the: Object Types / Types

they're great, if you never alter/change their Attributes' Values

unfortunately, adding/removing items/options/etc in a List Attribute, is altering/changing its Values (as the items/options/etc are its Values)


the reason is that the 'Object Types / Types', are Inherited Attributes, and Inherited Attributes are locked/blocked/prevented from being changed/altered


so, since you can't change/alter the Inherited Attributes within your Object Types / Types, what do you do?

you got to just create the same Attribute, which will over-ride/over-write the Inherited Attribute, and thus, since it is a normal Attribute, you can now change/alter its Values all you want, which generally makes the entire point of having Object Types / Types, a big waste, except in some niche cases


Object Types / Types, have a very niche use

usually, it's better just to create an Object and give it the Attributes you want, and then you can reference that Object, doing whatever you want with its Attributes, as usually you don't need every Object to have the same Attributes (and which can't be changed/altered as they're Inherited Attributes), but just a single Object with the needed Attributes, which you can just reference, for whatever use of it (the Object) and them (the Object's Attributes) that you need


Pixie got the right answer, but I think the line of code should be:

obj.inventoryverbs = Split("Look at;Drop;Equip")

I also notice that the last 4 lines of your spawn function have this instead of obj. This probably just displays an error message that you ignore, but it's always better to fix errors before they cause a problem, because when something goes wrong it will take a lot of time to find the problem.


Thank you everyone!


Log in to post a reply.

Support

Forums