If and otherwise statements when hold multiple solution items

Okay so I made a game where you have multiple ways of killing a hag. One of them is a silvered knife, the other is lightning in a bottle. If you go upstairs to the Hag’s room and you have both, if you try and attack her, it’ll automatically do the first one.

Can someone explain to me how to make it so that when you attack the hag, the program will ask “With what?” some other way to make the player have to specify which thing they’re using so that it doesn’t automatically do the first one.

Here’s what I have so far (it’s causing errors):

Instead of attacking the Hag:
	if the player is in the Hag Room and the player carriesthe silvered knife:
		say "You attack the hag with the knife.";
	otherwise if the player is in the Hag Room and the player carries the flickering bottle:
			say "You attack the hag with the lightning in a bottle.";
	otherwise:
		say "You get got.";

I’m kinda stuck because if you have both on you, it just does the silvered knife if you attack her. Any help would be appreciated.

Do you want the command “ATTACK ” to work elsewhere in the game, or do you want to insist globally that all attacks must be made with a weapon?

Maybe something like:

Lab is a room

A hag is a person.
A hag is in lab.

A knife is in the lab.
A flickering bottle is in the lab.

Check attacking a hag:
	say "With what?" instead;

Check attacking a hag when the player has a knife (this is the knife rule):
	say "You attack the hag with the knife." instead;
	
Check attacking a hag when the player has a flickering bottle (this is the bottle rule):
	say "You attack the hag with the lightning in a bottle." instead;
	
The bottle rule is listed before the knife rule in the check attacking rulebook.
Lab
You can see a hag, a knife and a flickering bottle here.

>take all
knife: Taken.
flickering bottle: Taken.

>attack hag
You attack the hag with the lightning in a bottle.

Another version, in which each text is displayed when the player is carrying several weapons:

Lab is a room

A hag is a person.
A hag is in lab.

A weapon is a kind of thing.

A knife is a weapon in the lab.
A flickering bottle is a weapon in the lab.

Check attacking a hag when the number of weapons carried by the player is 0:
	say "With what?" instead;

Check attacking a hag when the player has a knife (this is the knife rule):
	say "You attack the hag with the knife. ";
	
Check attacking a hag when the player has a flickering bottle (this is the bottle rule):
	say "You attack the hag with the lightning in a bottle. ";
	
The block attacking rule does nothing.
	
The bottle rule is listed before the knife rule in the check attacking rulebook.

Lab
You can see a hag, a knife and a flickering bottle here.

>attack hag
With what?

>take all
knife: Taken.
flickering bottle: Taken.

>attack hag
You attack the hag with the lightning in a bottle. 
You attack the hag with the knife. 
>drop bottle
Dropped.

>attack hag
You attack the hag with the knife. 
>

I understood from the original request that you’d like the player to specifically say what they want to attack the hag with, so here’s a version which does that:

"Hagmurder"

Hagboratory is a room.

A person called a hag is here.
A silvered knife is here.
A flickering bottle is here.
A rubber mallet is here.

Understand the command "attack" as something new.

Attacking it with is an action applying to one thing and one carried thing. Understand "attack [something] with [something]" as attacking it with.

Check attacking it with:
	If the noun is the hag:
		Continue the action;
	Otherwise:
		Say "Violence isn't the answer to this one."

Carry out attacking the hag with something:
	If the second noun is the silvered knife or the second noun is the flickering bottle:
		Say "You kill the hag with [the second noun]!";
	Otherwise:
		Say "That doesn't work as well as you hoped."

Note that you should probably also redefine all of Inform’s other synonyms for “attack” (of which there are lots) - I’m not sure if there’s a quick way to redefine all of them at once.

There is a way.

Recently, I had a discussion with @Zed about action processing rules.
I’m not saying he would approve 100% of my proposal, but wouldn’t you prefer?:

Check attacking it with when the noun is not the hag:
		Say "Violence isn't the answer to this one." instead;
>attack Mister HUT with the knife
(first taking the silvered knife)
Violence isn't the answer to this one.

I think actually the better option is probably:

Definition: a person is victimisable if it is the hag.

Check attacking it with when the noun is not victimisable:
	Say "Violence isn't the answer to this one."

That way, if you want to add more enemies who can be attacked later, you can just add another “is victimisable” line rather than having to modify any existing conditions.

Yes, why not.

Perhaps, add the final “instead” which stops the action, otherwise the carry out action will try to fire. In complex cases with overlapping filters, this habbit is very useful. (“instead” stops the action, for sure).

1 Like