Disable actions when in battle

Good day,

I am new to Inform 7, however I have been able to play around and write a small IF adventure basically testing some of the options and instructions.

I have implemented a very basic fighting script, based on an example from the Inform website.

What I am trying to do now, is to create a “battle state”.

Basically, if you attack an enemy, you engage in battle (thus changing you into a battle state).

While in battle state, I want to be able to give the player just the following verbs:

Attack (physical)
Cast Spell
Dodge
Run

All other verbs should be disabled until one of this things happens:

  1. You kill the enemy
  2. You are killed
  3. You escape successfully.

Also, I am changing the prompt from “>” to “(In Battle Mode) >” while in this state. (with the “Now change command prompt”).

Any idea would be appreciated.

Thanks
Max

You probably want to do this with scenes and kinds of action. See Ex 160: Bowler Hats and Baby Geese and 7.15: Kinds of action.

A scene can be violent or peaceful.

Millicent Battles The Giant Swamp Possum is a violent scene.

Attacking something is tactical behaviour. Dodging is tactical behaviour. [etc]

Instead of doing something that is not tactical behaviour during a violent scene: say "That can wait until after the fight."

(You might also want to use an extension like Variable Time Control to prevent the player from getting attacked after this.)

Excellent. That is exactly what I was looking for.

My guess would be also that I would need to define Casting magic and Escaping as a tactical behavior.

Also for the message saying that it cannot do that action while in battle I can use the [no-time] as indicated by the variable time control (and as you pointed out).

Again, thanks for your help
Max

Now I’ve got “Yoshimi Battles the Pink Robots” by The Flaming Lips stuck in my head…

1 Like

Ok, so I went ahead and tried implementing that code. It makes perfect sense to me, but I am getting an error when compiling. Here is the code:

A scene can be violent or peaceful.
The player battles a person is a violent scene.
The player battles an animal is a violent scene. 
Attacking something is tactical behaviour.
Instead of doing something that is not tactical behaviour during a violent scene: say "I can wait until after the fight."

However i get the following error:

You wrote ‘Instead of doing something that is not tactical behaviour during a violent scene’ , which seems to introduce a rule taking effect only if the action is ‘doing something that is not tactical behaviour’. But that did not make sense as a description of an action. I am unable to place this rule into any rulebook.

I guess Inform doesn’t like the way is phrased. Any info that can help me?

Thanks
Max

Inform 7 is such a large fragment of natural English that it’s easy to lose sight of its syntactical limits. It treats “doing something” as primitive unit, a set phrase (with “doing anything” as a synonym)—you can’t substitute an arbitraryr indefinite description of an action for the word “something” (or “anything”) here, as you could in real English.

This syntax works:

Attacking or singing is tactical behaviour.

Instead of doing something when the current action is not tactical behaviour during a violent scene: say "It can wait."

as does this:

Doing anything except attacking or singing is untactical behaviour.

Instead of untactical behaviour during a violent scene: say "I can wait until after the fight."

Ok, I guess I am not getting it because is the end of the day and my mind is already tired.

I read through the Scenes information on the manual and this is what I get:

  1. Define a scene.
  2. Define when a scene starts
  3. Define when a scene ends
  4. Define what happens when a scene starts
  5. Could define what happens when a scene ends

I fixed the wording on the “Instead of doing something…” part but even when I compiled it and it didn’t show any error, it wouldn’t restrict the movement when in battle.

I understand that I have not defined the Scene properly. I can even see on the Scene Index that the scene never starts. So I am trying to write the beginning and the end, but it won’t take it. Here is the code:

Battle is a violent scene. Battle begins when the player attacks someone. Battle ends when the current hit point of Mage Guard is less than 0.

And the errors:

Problem. In the sentence ‘Battle begins when the player attacks someone’ , I was expecting to read a condition, but instead found some text that I couldn’t understand - ‘the player attacks someone’.

Problem. You wrote ‘Battle begins when the player attacks someone’ : again, ‘begins when’ and ‘ends when’ must be followed by a condition.

The examples on Inform’s manual are somehow confusion on this subject. IF somebody could clarify how to define this it would be very helpful.

Thanks

“When the player attacks someone” is not a condition, is the problem.

Here’s how scenes work: every turn, Inform checks to see whether the scene should start. If that condition is true, the scene begins. So it’s not about something that happens, it’s about something that is currently true.

The important concept being that you don’t start a scene directly, as it were; you have to give it a cue that it can recognise. (I’ve always found this a little weird, honestly.)

You might say the scene begins “when the current action is attacking something”, which picks out the last action that the player tried. But that might trigger in situations that you don’t want (if the player attacks a tree, for instance). So you probably want to set a value that changes to true when combat is initiated in a valid way, then is changed back to false again when you’re done with combat.