Similar Rules Giving Different Outcomes?

I am working on a set of rules that will run if certain conditions are met. As it is written here I am testing with unarmed weapons but the problem exists whether the weapon is armed, unarmed or not in the player’s possession. The “FRIEND” rule works fine but the “ENEMY” rule returns a “can’t see any such thing” message at the end.

[spoiler][code]enemyfighting is a kind of value. The enemyfightings are attack Balak Guard, attack some Balak Guard, fight Balak Guard, fight some Balak Guard, attack enemy, attack enemy person, fight enemy, fight enemy person.

friendfighting is a kind of value. The friendfightings are attack Vulnetas, attack some Vulnetas, fight Vulnetas, fight some Vulnetas, attack friend, attack neutral person, fight neutral, fight neutral person, attack Nderim Drore, fight Nderim Drore, attack Nderim, fight Nderim.

After reading a command:
if the player’s command includes “[enemyfighting]”:
now the reiver blade is unarmed;
now the flag in row three of the Table of Target Flags is 1;
follow the attack enemy with no weapon rule;
if the player’s command includes “[friendfighting]”:
now the reiver blade is unarmed;
now the flag in row four of the Table of Target Flags is 1;
follow the attack friendly with no weapon rule.

This is the attack enemy with no weapon rule:
if the flag in row three of the Table of Target Flags is 1:
if an enemy is in location:
if the player has a weapon:
if the reiver blade is armed:
say “[line break]You are armed with a reiver blade which is not designed for ranged attacks, you risk losing the weapon while causing little or no damage to your foe. Do you wish to continue the action?[paragraph break][link]ABSOLUTELY[end link][line break][link]MAYBE NOT[end link]”;
now the flag in row one of the Table of Yes No Tracking is 1;
now the flag in row three of the Table of Target Flags is 0;
if the cold hammered iron dagger is armed:
say “[line break]You carry a pair of cold hammered iron daggers originally designed for close quarters combat. The daggers can be useful as ranged weapons over short distances though the downside to this attack is the loss of the weapon until it can be retrieved from the ground or from the corpse of your foe. Do you wish to continue the action?[paragraph break][link]ABSOLUTELY[end link][line break][link]MAYBE NOT[end link]”;
now the flag in row two of the Table of Yes No Tracking is 1;
now the flag in row three of the Table of Target Flags is 0;
if no weapon is armed:
say “[line break]Your weapon is not armed.”;
now the flag in row three of the Table of Target Flags is 0;
now player is in location;
otherwise:
say “[line break]You do not possess a weapon with which to attack anyone.”;
now the flag in row three of the Table of Target Flags is 0;
now player is in location;
otherwise:
if the player has a weapon:
if the reiver blade is armed:
place Balak Guard in scope;[AS ENEMIES ARE CREATED THEY SHOULD BE ADDED TO THIS LIST]
say “[line break]No enemy is present in your current location, surely you do not wish to attack the good folk of [location].[paragraph break][link]SURELY[end link][line break][link]SURELY NOT[end link][line break]”;
now the flag in row one of the Table of Target Flags is 1;
now the flag in row three of the Table of Target Flags is 0;
if the cold hammered iron dagger is armed:
place Balak Guard in scope;[AS ENEMIES ARE CREATED THEY SHOULD BE ADDED TO THIS LIST]
say “[line break]No enemy is present in your current location, surely you do not wish to attack the good folk of [location].[paragraph break][link]SURELY[end link][line break][link]SURELY NOT[end link][line break]”;
now the flag in row one of the Table of Target Flags is 1;
now the flag in row three of the Table of Target Flags is 0;
if no weapon is armed:
place Balak Guard in scope;[AS ENEMIES ARE CREATED THEY SHOULD BE ADDED TO THIS LIST]
say “[line break]Your weapon is not armed.”;
now the flag in row three of the Table of Target Flags is 0;
now player is in location;
otherwise:
place Balak Guard in scope;[AS ENEMIES ARE CREATED THEY SHOULD BE ADDED TO THIS LIST]
say “[line break]You do not possess a weapon with which to attack anyone.”;
now the flag in row three of the Table of Target Flags is 0;
now player is in location.

This is the attack friendly with no weapon rule:
if the flag in row four of the Table of Target Flags is 1:
if a neutral person is in location:
if the player has a weapon:
if the reiver blade is armed:
say “[line break]No one in your current location represents a threat to you. Do you really intend to harm the good folk of [location]?[paragraph break][link]SURELY[end link][line break][link]SURELY NOT[end link][line break]”;
now the flag in row one of the Table of Target Flags is 1;
now the flag in row four of the Table of Target Flags is 0;
if the cold hammered iron dagger is armed:
say “[line break]No one in your current location represents a threat to you. Do you really intend to harm the good folk of [location]?[paragraph break][link]SURELY[end link][line break][link]SURELY NOT[end link][line break]”;
now the flag in row one of the Table of Target Flags is 1;
now the flag in row four of the Table of Target Flags is 0;
if no weapon is armed:
say “[line break]Your weapon is not armed.”;
now the flag in row four of the Table of Target Flags is 0;
now player is in location;
otherwise:
say “[line break]You do not possess a weapon with which to attack anyone.”;
now the flag in row four of the Table of Target Flags is 0;
now player is in location;
otherwise:
if the player has a weapon:
if the reiver blade is armed:
place Nderim Drore in scope;[AS NEUTRALS ARE CREATED THEY SHOULD BE ADDED TO THIS LIST]
say “[line break]You should learn to relax a bit, there is no one here.”;
now the flag in row four of the Table of Target Flags is 0;
now player is in location;
if the cold hammered iron dagger is armed:
place Nderim Drore in scope;[AS NEUTRALS ARE CREATED THEY SHOULD BE ADDED TO THIS LIST]
say “[line break]You should learn to relax a bit, there is no one here.”;
now the flag in row four of the Table of Target Flags is 0;
now player is in location;
if no weapon is armed:
place Nderim Drore in scope;
say “[line break]Your weapon is not armed.”;
now the flag in row four of the Table of Target Flags is 0;
now player is in location;
otherwise:
place Nderim Drore in scope;
say “[line break]You do not possess a weapon with which to attack anyone.”;
now the flag in row four of the Table of Target Flags is 0;
now player is in location.[/code][/spoiler]

These are the last set of rules listed when running the enemy rule

[Rule "other people looking rule" applies.] [Rule "last specific action-processing rule" applies.] [Rule "After deciding the scope of the player" applies.] [Rule "After deciding the scope of the player" applies.] [Rule "After deciding the scope of the player" applies.] [Rule "After deciding the scope of the player" applies.] [Rule "After deciding the scope of the player" applies.] [Rule "After deciding the scope of the player" applies.] [Rule "After deciding the scope of the player" applies.] [Rule "new can't see any such thing rule" applies.] You can't see any such thing.

and the friend rule

[Rule "report stage rule" applies.] [Rule "last specific action-processing rule" applies.] [Rule "A first turn sequence rule" applies.] [Rule "every turn stage rule" applies.] [Rule "carry out patrolling rule" applies.] [Rule "fighting back rule" applies.] [Rule "Every turn" applies.] [Rule "Every turn" applies.] [Rule "Every turn" applies.] [Rule "Every turn" applies.]

There is quite a bit of code written to accommodate various conditions with the weapons and how the player actually enters combat mode but I cannot find a single situation anywhere that tells me what the darn thing is looking for that it cannot see. I don’t know if this is enough info to help but I can post more later. I have searched every way I know until now I am just running in circles with debug and trying to write rules to override the issue. Help.

Since your “After reading a command” rules don’t end with “reject the player’s command,” after the friend/enemy rules run Inform tries to process what the player has typed as a command. Probably you typed something to trigger enemyfighting that couldn’t be processed as a command, and you typed something to trigger the friendfighting command that could. Like if you type “attack balak guard” and there isn’t anything visible called “balak guard” you’ll get that message.

But more importantly: Why are you doing things this way? It seems like you’re trying to hand-roll your own parser with the “If the player’s command includes [some value]” rule, and this is going to create a lot of headaches. Just have “enemy” be understood as the Balak and “neutral” understood as neutrals and it should be a lot easier to do what you want using the ordinary action machinery–you could use a Before attacking rule to take care of the business about “now the reiver blade is unarmed.”

I am trying to account for the different ways a player can enter combat. The form here is the direct method. There are others that are based on a certain action with a weapon such as arbitrarily throwing one while a person (enemy or friend) is in the room.

I will look at trying to implement the understood deal. Maybe I can find a way to include all of the possibilities in this way but so far the current form is the only one that allows all of the given scenarios to run correctly. Rejecting the player’s command is more what I am looking for right now. Will play around some more and see what happens.

Categorizing actions might be something to look into, as well.

I had not looked at that possibility BG. Maybe I can group all of the action triggers in this way to prevent the ghost firing of “looking” that I am getting. Thanks.

Is it absolutely necessary to include “reject the player’s command” at the end of an “after reading a command” rule? I have used the rule five separate times so far and this is the first time I have had to use it to get things to run right and here I only have to use it on the ENEMY side as the FRIEND side runs just fine without it.

After reading a command: if the player's command includes "[enemyfighting]": now the reiver blade is unarmed; now the flag in row three of the Table of Target Flags is 1; follow the attack enemy with no weapon rule; reject the player's command; if the player's command includes "[friendfighting]": now the reiver blade is unarmed; now the flag in row four of the Table of Target Flags is 1; follow the attack friendly with no weapon rule. [reject the player's command.]

All of the other times I have used the rule I have ended it with “rule succeeds” and in one case “continue the action” and these instances work just fine.

After reading a command: if the player's command includes "throw the satchel": follow the throwing satchel rule; rule succeeds[this sequence goes on to cover several possible actions]

After reading a command: if the player's command includes "[flakeswapping]": continue the action; if the player's command includes "[pouchdropping]": continue the action; otherwise: if the player carries the nderimpouch: choose row 1 in the Table of Pouches; if the flag entry is 0: say "[line break]You must transfer the nickel flakes before moving on."; rule succeeds; if the flag entry is 1: say "[line break]You must discard the pouch before continuing."; rule succeeds.

Matt commented on this above, but it bears repeating:

Why are you trying to build your own parser? The one build into Inform has grown and grown over the decades, and is far more sophisticated than you might realize.

Consider the first example you showed us, for “[enemyfighting]”. What if I say “attack the enemy”? “Attack the guard”? “Kill the Balak Guard”? “Fight an enemy person”? “Examine the first Balak Guard then attack her”? “Attack Balak Guard. Again. Again.”? Just “attack” on its own? There are so many possible cases you’d need to account for. And that’s only when there’s one type of enemy in the location. What if there’s also a guard captain in the location, and you need to parse out that “attack the captain” should only select that one, “attack a guard” should probably go for a different person, and “attack the enemy” could be either one?

Also, because you’re circumventing the normal action system, you lose a lot of the elegant conveniences Inform offers for working with actions. Instead rules, for example. Or testing for success and failure. Or the persuasion system. Or even the turn counter and “every turn” rules.

In short, I’d recommend not messing with the parser unless you’re REALLY sure of what you’re doing.

I strongly agree with this comment. A few years ago we had a fellow who was trying to write a TADS 3 game (I don’t believe he ever finished it) who was fond of going in and trying to interpret the player’s typed commands by hand rather than using the many built-in procedures for doing this. If you want to write your own parser as an intellectual exercise, fine – nothing wrong with that! But tying yourself in knots while ignoring the tools that can already do the heavy lifting for you is not going to be fun. Even if you can trap all of the possible variations in the typed command – and that’s unlikely – you’ll be doing days of unnecessary extra work.

Addressing just this question… no, it’s not. “reject the player’s command” does exactly the same thing as “rule fails”; it’s a convenience synonym. “Rule succeeds” sets a different rulebook outcome, but for this case, the outcome is ignored – the library only cares whether command-reading was interrupted or not. (Obviously, “continue the action” signals not interrupted.)