Adventure Game Studio

AGS Support => Modules, Plugins & Tools => Topic started by: Kennedy on Wed 27/08/2003 02:12:38

Title: Dropping inventory items
Post by: Kennedy on Wed 27/08/2003 02:12:38
Are there any plans to increase the number of objects allowed for each room?
Also I noticed that the objects in the room use the same properties as the rooms themselves rather than having thier own.

Has anybody made a script allowing the player to drop inventory items?
I suppose this could be done by creating an inventory property that stores the item's location.
Title: Re:Objects in Rooms and dropping inventory items
Post by: on Wed 27/08/2003 13:28:06
If you want to have the number of object increased, make a suggestion in the technical forum and call it "Suggestion: Increase number of objects" ...
If you're lucky the inventor of this engine will work on that then, I think there are lots of people who would find it quite useful.

Well, the second point is difficult, too.
You cannot drop inventory, you cannot pick it up either, because they are "objects" in a room.
So you're not able to drop inventory, but you can make a loseinventory function and place an object instead on the screen that has same graphics as the inventory.
But for there's an limitation you cannot "drop" more than the maximum number of objects.

I've got another idea, why don't you put a box, bag, etc. in the room, where you can put all the stuff in that you don't want to carry around?
Title: Re:Objects in Rooms and dropping inventory items
Post by: GarageGothic on Wed 27/08/2003 13:32:35
Maybe this is a really dumb suggestion, but couldn't you use characters instead of objects for droppable items?
Title: Re:Objects in Rooms and dropping inventory items
Post by: Ishmael on Wed 27/08/2003 16:55:47
Yes, you could, and that wouldn't be so hard I think. :P
Title: Re:Objects in Rooms and dropping inventory items
Post by: Pumaman on Wed 27/08/2003 20:44:05
Why do you need more objects in the room? Yes, there's an artifical limit and could be increased, but in general there are better ways of accomplishing the game thing, for example using hotspots.

However, I accept that there are cases where more objects are required so I'll look into increasing it further.
Title: Re:Objects in Rooms and dropping inventory items
Post by: Crash on Fri 29/08/2003 10:31:40
Here is part of the code in my game that lets you drop inv items.
There are 30 characters put aside to be inventory items and they re-initialise whenever you change rooms (ie. you can drop 30 inv. items in each room.


struct roomobj { int x; int y; int nmbr; int on; } ;
roomobj current[30]; roomobj room1[30]; roomobj room2[30]; roomobj room3[30];

//////////////////////////////
// Update Objects           // put in When Player Enters Room (Before Fadein) script
//////////////////////////////

function UpdateObjects() { // 1
int I;  I = 1;
  if (character[EGO].room == 1) { while (I<30) { if (room1[I].on == 1) { character[I+3].room = 1; character[I+3].x = room1[I].x; character[I+3].y = room1[I].y; current[I].nmbr = room1[I].nmbr; } I++; } }
  if (character[EGO].room == 2) { while (I<30) { if (room2[I].on == 1) { character[I+3].room = 2; character[I+3].x = room2[I].x; character[I+3].y = room2[I].y; current[I].nmbr = room2[I].nmbr; } I++; } }
  if (character[EGO].room == 3) { while (I<30) { if (room3[I].on == 1) { character[I+3].room = 3; character[I+3].x = room3[I].x; character[I+3].y = room3[I].y; current[I].nmbr = room3[I].nmbr; } I++; } }
   
  int T; T = 1;
   while (T<30) {
   if (current[T].nmbr == 1) { SetCharacterView(T+3,2); }
   if (current[T].nmbr == 2) { SetCharacterView(T+3,8); }
   if (current[T].nmbr == 3) { SetCharacterView(T+3,9); }
   if (current[T].nmbr == 4) { SetCharacterView(T+3,87); }
    T++;
   } //2
  } //1 
 
//////////////////////////////
// Drop Objects             //
//////////////////////////////
function DropObject (int num, int x, int y, int room) { //1
int I;  int done;  I = 1;
  if (character[EGO].room == 1) { while (I<30) { if (room1[I].on == 0) { room1[I].nmbr = num; room1[I].x = x; room1[I].y = y; room1[I].on = 1; I= 30; done = 1; } I++; } }
  if (character[EGO].room == 2) { while (I<30) { if (room2[I].on == 0) { room2[I].nmbr = num; room2[I].x = x; room2[I].y = y; room2[I].on = 1; I= 30; done = 1; } I++; } }
  if (character[EGO].room == 3) { while (I<30) { if (room3[I].on == 0) { room3[I].nmbr = num; room3[I].x = x; room3[I].y = y; room3[I].on = 1; I= 30; done = 1; } I++; } }
if (done == 0) { Display("There is no room left."); }
UpdateObjects();
} // 0

//////////////////////////////
// Pick Up Objects          //
//////////////////////////////
function GetObject(int num) { // 1

if (GetGlobalInt(105)-GetGlobalInt(104) >= 1) { //2 
  if (character[EGO].room == 1) { AddInventory(room1[num-3].nmbr); character[num].room = -1; room1[num-3].on = 0; SetGlobalInt(104,GetGlobalInt(104)+1); }
  if (character[EGO].room == 2) { AddInventory(room2[num-3].nmbr); character[num].room = -1; room2[num-3].on = 0; SetGlobalInt(104,GetGlobalInt(104)+1); }
  if (character[EGO].room == 3) { AddInventory(room3[num-3].nmbr); character[num].room = -1; room3[num-3].on = 0; SetGlobalInt(104,GetGlobalInt(104)+1); }
} else { Display("The inventory is full."); }
  UpdateObjects(); } //0


That's just the functions, I've probably left some vital part of the script out that was in the repeatedly execute part, but my script is so messy I can't be bothered looking for it...
Title: Re:Objects in Rooms and dropping inventory items
Post by: Kennedy on Sun 07/09/2003 11:01:31
Maybe you could implement objects in rooms in a way similar to characters or inventory items where they get there own category called "static objects".
Then you could have the same object appear in multiple rooms.
also you could have commands for the objects like:

AddObjectRoom(object# room# xpos# ypos#)
RemoveObjectRoom(object# room# xpos# ypos#)

Also maybe adding an ability for inventory items to be placed in the rooms like objects:
AddInvRoom(InventoryItem# room# xpos# ypos#)
RemoveInvRoom(InventoryItem# room# xpos# ypos#)
And you could also make new use of the GetInvAt function.

Then dropping inventory items would be possible and you could also have an inventoryitem appear at various locations.
Title: Re:Objects in Rooms and dropping inventory items
Post by: Pumaman on Sun 07/09/2003 17:00:11
I could definately add some sort of AddObjectToRoom function (http://www.adventuregamestudio.co.uk/tracker.php?action=detail&id=155), to allow you to add new ones.

However, in terms of droppable object functionality overall, I'm not really sure whether to go down that route or not. Being able to drop things and then pick them up later is really suited to RPG's more than adventure games. It would be possible for me to add, but I'm not sure if it's the sort of thing I should be spending time on.
Title: Re:Objects in Rooms and dropping inventory items
Post by: Kennedy on Mon 08/09/2003 02:07:09
Well, the reason for droppable items is to put a limit on how much the player can carry.
Most of the old text adventures like the Infocom games and Collosal Cave put a limit on how much can be carried at a time.
Dropping items was part of how players were expected to be able to map that "maze of twisty passages, all alike".
Title: Re:Objects in Rooms and dropping inventory items
Post by: on Tue 20/01/2004 06:27:43
Another reason for adding in the ability for players to drop innventory items would be that then you could have events trigured if the character ISN'T carrying a certain inventory item.
For example they wouldn't be allowed into the hotel if they are carrying a weapon. If they can drop items though then they put certain objects down and pick them up again later.

Probably the best way to implement a system to allow dropping of inventory objects would be for each room to have its own inventory the way characters do.
Title: Re: Objects in Rooms and dropping inventory items
Post by: Skio on Tue 25/05/2004 21:57:17
As for the "bag" option, this is a piece of code I devised recently.

*** GUIS ***

Create a GUI containing a LISTBOX and an EXIT button.
Script it to appear when the bag is searched. (It is Gui 6 in this example)

*** GUI SCRIPT ***


    if (interface == BAG) {
    // They clicked a button on the bag
   
    if (button==0) {   // the retrieve code
     int count=0;
     int item=1;
      string retrieve;
      string additem;
      ListBoxGetItemText (6,0,ListBoxGetSelected(6,0),retrieve);
      Display ("You retrieve the %s from the trashcan.", retrieve);
      ListBoxRemove (6, 0, ListBoxGetSelected(6,0));

      // AddInventory check
        while (count==0) {
          GetInvName (item, additem);
          if (StrComp(additem, retrieve)==0) {
            count=1;
            }
          else item++;
          }
        AddInventory(item);
      }

    if (button == 1) {   // exit bag
     GUIOff(BAG);
     SetCursorMode(MODE_WALK);
     }
  }  // end if interface BAG


*** BAG INTERACTIONS ***


// deposit items (use inv on the bag)
  string bag;
  GetInvName (player.activeinv, bag);
  Display("You deposit the %s in the bag.", bag);
  LoseInventory(character[EGO].activeinv);
  ListBoxAdd (6, 0, bag);



// look bag
  Display ("A bag."); 
  GUIOn (BAG);
  SetCursorMode(6);
Title: Re: Dropping inventory items
Post by: A�rendyll (formerly Yurina) on Fri 17/02/2006 09:09:51
Are you sure these objects are all destined to get removed or re-activated?

If you only need interaction, but no serious remove or re-activate stuff you should use hotspots.