Money System: MI2 Style

Started by , Sat 07/10/2006 23:56:58

Previous topic - Next topic

Glockenspiel

Okay, I've searched and searched, but all threads I've found either use the game score for money or an inventory item that, upon being looked at, displays a message along the lines of "I have <variable> dollars."

In Monkey Island 2, the inventory item's name changes to affect the number (such as, if you had 54 pieces of eight, the inventory item's name would be "54 Pieces of Eight"). Also, after passing certain amounts, the image would change from one coin to a small pile to a stack, and so on.

How can this be done in AGS? I'd be VERY greatful if you can tell me how.

Akumayo

I'm fairly certain this can be done in AGS.

I could be wrong, of course, but if you had an int "money", you could check it in repeatedly_excecute to change the image/name of the item.

Code: ags

repeatedly_excecute() {

if (money > 0) {

Ã,  if (player.InventoryQuantity[iMoneyItem.ID] == 0) player.AddInventory(iMoneyItem);

Ã,  String moneyname = String.Format("%d dollars", money);
Ã,  iMoneyItem.Name = moneyname;

Ã,  if (money > 0 && money < 50) iMoneyItem.Graphic = 1; //Change to small pile graphic
Ã,  else if (money > 49 && < 200) iMoneyItem.Graphic = 2;Ã,  //Change to large pile graphic
Ã,  else if (money > 199 && < 1000) iMoneyItem.Graphic = 3;Ã,  //Change to huge pile graphic
Ã,  else iMoneyItem.Graphic = 4;Ã,  //Change to massive pile graphic

}

else player.LoseInventory(iMoneyItem);



This would make it so that if you had money, you'd have an item for it, and if not, you wouldn't.Ã,  The item's graphic would change based on how much money you had, and it's name would also.

-Regards, Akumayo
"Power is not a means - it is an end."

Glockenspiel

I see how this is to work, but at the string "if (money > 0) {", what is "money"? An integer, or what? AGS marks "money" as an unidentified symbol. I'm still fairly new to scripting (though I have gotten most aspects of GUI and dialog down).

Akumayo

Understandable, I wasn't aware that you were new to scripting.

'money' is an integer.  At the very top of your global script, before any functions, you'll need to put this code:

Code: ags

int money = 10;  //Will give the player 10 dollars to start with
export money;


Then, in your script header, put the code:

Code: ags

import int money;


This will make the integer variable money available to use in your global script and in your room scripts, so you can give and take money with simple things like:

Code: ags

money += 5;


Hope that helps ^_^

-Regards, Akumayo
"Power is not a means - it is an end."

Glockenspiel

This gets the script going without a hitch, but it doesn't seem to actually update the item name or appearance.

Steel Drummer

You could always make there be 500 inventory items (or whatever amount of max money you're going to have) and remove or add an inventory item for however many you have. :)
I'm composing the music for this game:



Glockenspiel

That might be crazy enough to work, as I don't intend to use money as often as in Monkey Island 2 itself. Speaking of which, what is the item limit in AGS?

Candle

#7
There are maximum...

   20  objects per room
  100  messages per room
  500  global messages
  299  rooms per game
  300  inventory items
15000  imported sprites
  240  sprites per folder
  600  views
   16  loops per view
   20  frames in each loop
  300  characters
   50  GUIs
   30  controls on each GUI
  500  dialog topics
3000  dialog-script messages
   30  options per topic
   20  screen overlays at a time
  500  script GlobalInts
   50  script GlobalStrings
  100  interaction editor global variables
    5  background frames per room
   20  mouse cursors


Akumayo

Hrm... that's strange, that they aren't updated.  Maybe try adding the line
Code: ags

UpdateInventory();

in your repeatedly excecute.  (Though I think the graphics should be updating on their own.)  If that doesn't work, perhaps you could let us know exactly what you're doing to test this?
"Power is not a means - it is an end."

SMF spam blocked by CleanTalk