Help with scenes and stuff

Hey, I’m trying to create a battle system, to do this I’m using a scene called battle-time. I’ve said ‘Battle-time is a recurring scene. Battle-time begins when the player is attacked.’

I tried to use a decide saying:

To decide whether the player is attacked:
if the player is in a active room;
if a random chance of 1 in 5 suceeds, yes;
no.

This came up with the error: Problem. You wrote ‘if in a active room’ : but this is a phrase which I don’t recognise, even though it starts with ‘if’. ‘If’ phrases normally have one of two forms: ‘if (condition), (do something)’ and ‘if (condition) begin; … ; end if’.

I have already said a room can be active or inactive. Also I have a problem with the ‘if a random chance…’ that came up with this:

Problem. In the sentence ‘if a random chance of 1 in 5 suceeds, yes’ , I was expecting to read a condition, but instead found some text that I couldn’t understand - ‘a random chance of 1 in 5 suceeds’.

I don’t have much experience with scenes or to decide rules I tend to avoid them, so if you could help come up with code that would avoid them both I would also appreciate it. If you nedd the full code just say so and I’ll post it.

This has nothing in particular to do with combat or with scenes. Here’s the crucial issue;

You’re using a semicolon where you need to use a colon. Or the other way around. There are two kinds of syntax you can use to structure I7 arguments, but you’re not allowed to mix them in the same code.

or this, except with a tab where I’ve put a bullet-point to indent:

“Succeeds” has two Cs in it. Inform (like every coding language ever) is unforgiving of spelling errors.

More generally, putting a random chance in a ‘to decide whether’ phrase is risky, because it’ll check whether the player’s being attacked, not every turn, but every time the game needs to check the player’s attacked-or-not status, i.e. every time you check ‘if the player is attacked’. This might be all right if there’s only one piece of code that ever checks whether the player’s attacked, but in any moderately complicated piece of code, that status is going to be flickering on and off like a lightbulb in a brownout.

I’m trying to create a waqy for the player to be attacked randomly, when he’s in certain rooms, while the scene will be used to initiate the battle. Could you suggest another way to make the player get attacked randomly and activate a scene?

Scenes are not my strong point; they’re designed so that they have to be triggered by conditions, rather than switched on directly by phrases.

[code]A room can be dangerous or safe. A room is usually safe.

current-attack is a truth-state that varies. current-attack is false.

Every turn (this is the wandering monster rule):
if the location is dangerous and a 1 in 5 chance succeeds begin;
now current-attack is true;
end if;

Unexpected Attack is a recurring scene. Unexpected Attack begins when current-attack is true.
When Unexpected Attack ends: now current-attack is false.
[/code]

Thanks thats just what I needed :mrgreen:

Ok I used your idea and it came up with this:

Problem. In the sentence ‘if the location is dangerous and a 1 in 5 chance succeeds begin’ , I was expecting that ‘location is dangerous and a 1 in 5 chance succeeds’ would be a condition. It didn’t make sense as one long phrase, but because it was divided up by ‘and’/‘or’, I tried breaking it down into smaller conditions, but that didn’t work either. ‘location is dangerous’ was okay; ‘a 1 in 5 chance succeeds’ did not make sense; so I ran out of ideas.

Ok I fixed it by trying ‘and a random chance of 1 in 3 succeeds begin’ instead of ‘and a 1 in 5 chance succeeds begin’

Ok now I’m having a new problem. When the scene starts I want to move the player to a special battle room, also I want to move a wolf there heres my code:

'A monster is a kind of person. A wolf is a kind of monster. A forest wolf is a wolf. 2 forest wolves are in the Creature vault.

A region has a thing called default monsters. The default monsters of forest is forest wolf.

When attacked begins:
now the default monsters of the map region of the location is in the forest battle.’

This compiles with the rest of my code, but after I move around and the attack activates a get this message:

P31 - Attempt to use a property of nothing

Most problems are detected when Inform translates the source text, but this is one of the exceptions, a “run-time problem” which emerges only during play.

The special value nothing is used to mean no object at all, and sometimes appears where an object might be expected if it was impossible to find a genuine object, or no genuine object was specified.

Nothing is not an object in its own right, and so it makes no sense to look at its properties.

Why would this happen.

Ok I also fixed this problem I forgot to include the battle room in the forest room :blush: :blush: