Item boxes

Hello!

I'm currently working on a game inspired in Resident Evil 1 and I'd like to make use of the limited inventory option, and since the project has many puzzle items, I'd like to create boxes where the player can deposit items.

Ideally, the player can access these items from any "item box" he finds.

The reason for the boxes is to prevent players from dropping items in a room and then not finding them again or if for any reason the path becomes blocked later in the project he won't lose the items.

I have looked around, but I still have no idea on how to do it, any suggestions are appreciated.

So I suppose I can summarize what I need:

  1. Make it so the player can't drop the items around the map;
  2. The item boxes are the only place the player can drop the items;
  3. The player should be able to access the items in the box from any item box he finds in the game.

Thanks in advance!


I'd suggest giving the item box an attribute so you can easily identify them. Probably a boolean attribute itembox set to true. If you're using the web editor, which doesn't have an 'Attributes' tab, you'd do that by giving each box an initialisation script containing the line this.itembox = true.

Then, for items that can only be put in a box and not dropped, you give the item a 'drop' script that looks like:

if (GetBoolean (destination, "itembox")) {
  this.parent = destination
  msg ("You put it in the item box.")
}
else {
  msg ("This is probably too important to leave lying around.")
}

Then you can only put the object in item boxes. (The "drop" script is used when the player tries to put an item in a box, too; the destination variable lets you know where they're trying to put it)

  1. The player should be able to access the items in the box from any item box he finds in the game.

I'd suggest something giving the boxes an openscript that looks like this (openscript is the script that is run when the box is opened, not the one that's run after it opens. It seems a lot of people pick the wrong one on the 'container' tab):

foreach (obj, AllObjects()) {
  if (GetBoolean (obj, "itembox") and not obj = this) {
    obj.isopen = false
    foreach (item, GetDirectChildern (obj)) {
      item.parent = this
    }
  }
}
OpenObject (this)

It basically means that when you open an item box, it closes all other item boxes and teleports their contents into this one. (Closing the other boxes means that the player always needs to open them before taking anything out).

If you don't want the player to have to open the box every time, you could do it using the game.roomenter script instead, which is on the Scripts tab of the game object; but that's a little less efficient:

box = null
room = game.pov.parent
items = NewObjectList()
foreach (obj, AllObjects()) {
  if (GetBoolean(obj, "itembox")) {
    if (Contains (room, obj)) {
      box = obj
    }
    else {
      items = ListCombine (items, GetDirectChildren (obj))
    }
  }
}
if (not box = null) {
  foreach (item, items) {
    item.parent = box
  }
}

This searches for all item boxes every time the player enters a room. If the box is in the current room, the variable box is set to it. Otherwise, the box's contents are added to the list items. After it's found them all, if one was in the current room, all the items on the list are moved there.

Hope that makes sense; I'm not too good at explaining these things sometimes.


I sorta understand what you are suggesting, however I can't really implement it.

I manage to make the items "undropable" with the script you presented:

if (GetBoolean (destination, "itembox")) {
  this.parent = destination
  msg ("You put it in the item box.")
}
else {
  msg ("This is probably too important to leave lying around.")
}

However I do not understand what to do at the item box. How do I set the items to be dropped IN the box? I tried to use several verbs but nothing worked, like Drop A on/in/inside box still produced the "This is too important" message.

Where am I getting this wrong?

Thanks again!


The command the player needs is "put A in B". I don't think you can do it with the 'drop' command; though it might be possible to change that.


I think I understand it a little better now.

I understand I have to create the command put #object# in #?#, but how exactly do I configure it?


No, put #object1# in #object2# is the built-in command that put an object into a container. If your item box is a container, the player should be able to put objects in it.


Log in to post a reply.

Support

Forums