Using Inform ATTACK

I.e.:Instead of drinking a minor health potion: if the health of the player is the permanent health of the player: say "You are at full health already."; otherwise: heal the player for 6 health; say "You drink the health potion, [if the healed amount is 0]but you were already at full health[otherwise if the health of the player is less than the permanent health of the player]partially restoring your health[otherwise]restoring your health[end if]."; if the combat state of the player is at-React: now the player is adrinking.

Thanks, the table works now, but I’m not sure what you mean about two spaces before the last say. No matter how I indent the potion script it doesn’t work.

Instead of drinking a minor health potion: if the health of the player is the permanent health of the player: say "You are at full health already."; otherwise: heal the player for 6 health; say "You drink the health potion, [if the healed amount is 0]but you were already at full health[otherwise if the health of the player is less than the permanent health of the player]partially restoring your health[otherwise]restoring your health[end if]."; if the combat state of the player is at-React: now the player is adrinking.

Oops, I missed that one.
The problem is that in your code there is a line that begins thus:

[tab][space][space]say "You drink the health potion, [etc.]"; That should be:[tab][tab]say "You drink the health potion, [etc.]";

Ah right. 0k I’ve fixed that but now it is saying:

Currently the “if the combat state of the player is at-React:” seems to be the problem, but no matter how I move the tabs on that line it gives me an error.

Instead of drinking a minor health potion: if the health of the player is the permanent health of the player: say "You are at full health already."; otherwise: heal the player for 6 health; say "You drink the health potion, [if the healed amount is 0]but you were already at full health[otherwise if the health of the player is less than the permanent health of the player]partially restoring your health[otherwise]restoring your health[end if]."; if the combat state of the player is at-React: now the player is adrinking.

I’m really starting to wonder if it might not be something else doing this because I copy-pasted your code right into the window and it still didn’t work… :confused:

By the way, does anyone know if it’s possible to have random encounters in certain areas? Say, if you go down a specific alleyway you have a 10% chance of being mugged. I’d have to put in some code to clear the bodies out so we don’t get a pile, but with some kind of random naming & description script it could add some interesting action.

Are you copying the code from the PDF file? The ATTACK zip also contains a file called story.inf which contains all the code for the example dungeon, and which should allow you to get all the indentation automatically right.

Random encounters are obviously possible – you’ve just named the two important things to do (remove bodies and than resurrect and re-randomise opponents when they are needed again).

What about the line that defines the minor health potion kind? If you have misspelt anything there, you’d get that error message.

facepalm I had it there, I swear I did, I put that line in…and then I went and quoted it out by mistake. Basically what I did was I had the original potion text from Attack, but I wanted to stop the player form using the potion if their health was full, so I copied the original potion script and modified it, but I left out the part that defined what a potion was. Arrrgh. Sorry guys. :laughing: It would be easyer if Inform had just said ‘what is this potion thing you speak of?’ :stuck_out_tongue:

But in any case, it seems to work now and I’ve now made it so that if you are at full health you take no time and don’t use up the potion, but I can’t work out how to make it so that drinking a potion removes it from play. I tried adding the line ‘remove item from play;’ but it wants to know which item and I’m thinking that if I write ‘minor health potion’ it will remove all of them or one at random. Can anyone help?

In an action rule for drinking, “the noun” is the object being drunk.

Or you could write:

Instead of drinking a minor health potion (called P): …

I am currently using the ‘instead of drinking’ version, but at the moment it doesn’t vanish when drunk. What I would really like to do, now that I think about it, is replace the potion with an empty potion bottle that can be filled with another potion via crafting, but I’m not sure how to do it since it is kind of object and so not unique, and I have never successfully removed an item from play before (though I have tried).

By the way, I have the retreating code installed, but there doesn’t seem to be anything stopping you from just typing a direction and going there without any penalties at all, is there a way to fix this? Or to set the base defence and attack bonus for the player in game for levelling up? :mrgreen:

You’d have to create as many empty bottles as might be maximally needed. They would begin off-stage, of course.

An empty bottle is a kind of thing. There are 5 empty bottles.

To move an unspecified empty bottle to the player, you need to refer to it as a RANDOM off-stage empty bottle:

Instead of drinking a minor health potion: remove the noun from play; move a random off-stage empty bottle to the player; if the health of the player is the permanent health of the player: [etc....]

What about if you changed the printed name of the drunk potion to ‘empty bottle’, and tag it as ‘empty’. Each potion would start off ‘full’, and would have to still be full for it to be allowed to be drunk.

Instead of drinking a full minor health potion: now the printed name of the noun is 'empty bottle'; now the noun is empty; [etc....]

Or something similar.

I’m a bit worried about what Felix said about having to pre-create them since this is the kind of game where you get random thugs dropping money and items, the player could end up causing a runtime error by buying or collecting too much of one thing. Is there a way to just create and destroy items as they are needed or do I need to script it so the player can’t try to take more items than the game has? I’d rather not have to put a hard limit on the number if possible…

You might want to take a look at Dynamic Objects by Jesse McGrew. It allows you to clone objects on the fly.

Hope this helps.

Not properly (although see Dynamic Objects, as climbingstars mentioned), but dynamic item creation may be made simpler in a future I7 version.

0k, that works, thanks a lot! Are objects basically deleted when they are removed or should I set up a system where I only clone when the reserve runs out?

Objects are never created or destroyed (unless you’re using the aforementioned Dynamic Objects extension). They’re just moved around or moved off-stage. You can move them back on-stage as needed.

EDIT-ADD: Or are you asking about that extension? I’m not sure what the terminology is, but when you use the extension to destroy them, they’re destroyed. If you just move something off-stage, it is still allocated in memory.

If I use the extension would it be better to create a reserve and use it up before making more (and then add created items back into the reserve as they are used) or to just make items and destroy them with the extension?

Dynamic Objects doesn’t let you destroy objects, so you should keep a cache whether you create them dynamically or not.