Ammunition and food.

How do i make consumables and ammunition diminish in my story.

I'll do my best to answer this since no one has yet. This definitely works, but... Others would likely do this much more efficiently than I so... maybe wait for their response? Anyway, here's how I would do it in my hacky, poor-coding sort of way:

  1. Create an object called "ammunition". Make sure it is in the players inventory AND make sure the box next to 'can be dropped' (on the inventory tab) is NOT ticked. If the player doesn't start the game with ammo or a weapon, you can also tick it as invisible to start the game and run a script to make it visible once weapon and ammo are found.
  2. Click on the attributes tab of the ammunition object.
  3. Click 'Add' next to 'Attributes'. Name it something like 'AmmoCount'
  4. Select integer attribute and set it to 0 (zero).
  5. Create ammo objects. In my sample, I made a 'twenty pack ammo' and a 'fifty pack ammo'.
  6. On the inventory tab for those objects, I clicked 'run a script' under the take section.
  7. Select 'Set variable or attribute' from the options.
  8. In the first box, type 'ammunition.AmmoCount' and in the second box, type 'ammunition.AmmoCount + 20'. The plus 20 is for the twenty pack. For the fifty pack, I changed it to 50. If you are doing one ammo per pick up, it would be + 1.
  9. For ME, I also added a script here to remove an object. I removed the ammo pack that I picked up because it prevents the player from dropping it and picking it up over and over again, racking up their ammo count.
  10. Make a gun object.
  11. Click on verbs tab for the gun object. Type in 'fire'.
  12. Choose Run a script.
  13. Select an 'If' script.
  14. Click on the 'expression' box and select 'object attribute equals'.
  15. In the object box, select object. In the box just to the right of that, type 'ammunition' and in the attribute box type 'AmmoCount'. In the box to the right of the equal sign (=), type in '0'
  16. In the Then part of this If script, run a print message script and type a message like "You pull the trigger, but nothing happens! You're empty!"
  17. In the else part of this If script, add a print message script and type a message like "You fire the gun." Also add a Set a variable or attribute script and, in the first box, type in 'ammunition.AmmoCount'. In the second box, select expression, and in the third box, type in 'ammunition.AmmoCount - 1'
  18. Go back to your ammunition object and choose to run a script under the "look at" section under the Set Up tab.
  19. Select the print a message script and make sure 'expression' is in the first box.
  20. In the second box next to expression, type the following
    "You have " + ammunition.AmmoCount + " ammo remaining."
    exactly as is. Or, change the "You have " or the " ammo remaining." parts to whatever you want.

Bingo. Done. You can do the same thing for your food items.

I don't think I missed any steps.

If you use this method and need help, please ask.

EDIT: If you fire the gun at certain things, like you would likely do, you can copy paste the code for the fire verb, on the thing you want it fired at. For example... if there is a zombie you want to shoot, maybe add a 'shoot' verb on the zombie and run scripts for killing or wounding the zombie IF the player is carrying the gun/weapon.

Log in to post a reply.