Trouble with Inform ATTACK - attacking non-hated factions

I’ve been using Inform Attack to handle all the combat in my project, but I run into a problem when I don’t want combat to start right away. This can happen for two reasons in my project - you’re stealthy and can’t be seen, or the monster is asleep and doesn’t know you’re there.
I tried messing with the hate rules and the ‘starting the combat round’ rules, but didn’t get very far, so I finally set ‘stealthy’ and ‘asleep’ to be factions and turned off the rule that prevent you from attacking factions you don’t hate.
The only problem was that I still couldn’t attack any factions I didn’t hate. I tracked the problem down to the ‘standard active attacking first phase’ rule only letting me attack if we were already in combat, and I modified it so I should also be able to attack outside of combat.
This worked, except it seems to break the rounds - if you’re attacking, you will always be attacking, and if you’re unlucky enough to be reacting, you will always be reacting. The only time it works properly is if you (or the monster) misses.

I’m not sure what to do to fix this so it works properly and still lets me attack.

[spoiler][code]
Include Inform Attack by Victor Gijsbers.

Asleep is a faction. Stealthy is a faction.

When play begins, now the player is stealthy.

A person has a number called a stealth bonus. The stealth bonus is usually 0.

The stealth bonus of the player is 5.

The rock is a weapon. The player carries the rock.

The do not attack neutral people rule is not listed in any rulebook.
The standard active attacking first phase rule is not listed in any rulebook.

Carry out an actor attacking when the fight consequences variable is false (this is the modified active attacking first phase rule):
if the combat state of the actor is at-Act:
now the global attacker is the actor;
now the global attacker weapon is a random readied weapon enclosed by the global attacker;
consider the attack move flavour rulebook;
choose a blank row in the Table of Stored Combat actions;
now the Combat Speed entry is 10;
now the Combat Action entry is the action of the actor attacking the noun;
now the combat state of the noun is at-React;
now the provoker of the noun is the actor;
now the provocation of the noun is the attacking action;
Otherwise:
consider the hate rules;
if rule failed:
now the combat state of the actor is at-Act;
now the global attacker is the actor;
now the global attacker weapon is a random readied weapon enclosed by the global attacker;
consider the attack move flavour rulebook;
choose a blank row in the Table of Stored Combat actions;
now the Combat Speed entry is 10;
now the Combat Action entry is the action of the actor attacking the noun;
now the combat state of the noun is at-React;
now the provoker of the noun is the actor;
now the provocation of the noun is the attacking action.

An attack modifiers rule (this is the stealth increases accuracy rule):
if the global attacker is stealthy:
increase the to-hit modifier by the stealth bonus of the global attacker;
if the numbers boolean is true:
say " + “, stealth bonus of the global attacker, " (sneak attack)[run paragraph on]”.

A damage modifiers rule (this is the sneak attack gives bonus damage rule):
if the global attacker is stealthy:
increase the damage modifier by the stealth bonus of the global attacker;
if the numbers boolean is true:
say " + “, stealth bonus of the global attacker, " (sneak attack)[run paragraph on]”.

An aftereffects rule (this is the combat breaks stealth rule):
if the player is stealthy:
now player is friendly.

The defence of a person is usually 0.

Erdeth’s Lair is a room. “Great piles of heaping treasure fill the cave, mounds of coins and baubles, tastefully scattered gems, carefully arranged heaps of armor and weapons. Oddly, most of the items here don’t seem to be very high quality.” Erdeth’s Lair is northeast from Clawed tunnel.

Erdeth is a man in Erdeth’s Lair. The description of Erdeth is “The great red dragon Erdeth, grown too large to escape his lair and having eaten everything he can reach, now spends most of his time hibernating and waiting for food to come to him. At the moment he appears to be sound asleep, fortunately.” Before printing the name of Erdeth when looking, say "the great dragon ". Understand “great dragon” or “dragon” as Erdeth.

Erdeth is asleep.

After printing the name of Erdeth when looking:
If Erdeth is asleep:
say " sleeping";
If Erdeth is hostile:
If Erdeth is killed:
do nothing;
Otherwise:
say " eyeing his surroundings hungrily".

Instead of examining a natural weapon enclosed by Erdeth (this is the Erdeth’s description of a natural weapon rule):
say “Sharp claws, buffeting wings, a spiked tail, and FAR too many teeth.”.

Every turn while Erdeth is asleep:
If the location of the player is the location of Erdeth:
say “[one of]Erdeth’s tail twitches briefly, then falls still.[or]Erdeth sighs in his sleep.[or]Erdeth’s wings twitch open briefly, then fall still.[or]Erdeth snorts and breathes a few rings of smoke.[at random]”;
If the health of Erdeth is less than the permanent health of Erdeth:
now Erdeth is hostile.

After waiting in Erdeth’s Lair, now Erdeth is hostile.
[/code][/spoiler]

In Kerkerkruip, the player can also be hidden. This is the code that I used to ensure that combat doesn’t start right away:

[code]First standard_attacker rule (this is the do nothing when all enemies hidden rule):
let p be false;
let q be false;
repeat with X running through all alive persons enclosed by the location:
if the faction of the global attacker hates the faction of X:
now p is true;
if X is not hidden:
now q is true;
if p is true and q is false:
say “[CAP-attacker] [one of]remains unaware of your presence[or]does not notice you[or]does not detect your presence[at random].”;
rule succeeds.

An aftereffects rule (this is the attacking breaks hidden rule):
if the global attacker is the player:
now the player is not hidden.[/code]
This could be easily changed to fit your game, I think. (if you use this solution, you should just have the factions hate each other as normal.)

Sorry for the late reply, real life intervened.

I saw that code previously in your example that came with the extension. The problem I have with it is it still changes the prompt to ACT> - the combat is still going, it’s just no one is attacking you.
I want there to be no combat at all, until the player is foolish enough to try and stick a dagger into a sleeping dragon’s ribs.

I messed with the code again, and I wound up modifying the ‘To handle the combat round’ to abide by the start the combat round rules instead of considering them. This way when I set up my combat blocking rules, they prevent the combat from even starting.

[spoiler][code]
Include Inform Attack by Victor Gijsbers.

A person can be loud or stealthy. A person is usually loud. The player is stealthy.
A person can be awake or asleep. A person is usually awake. Erdeth is asleep.

A person has a number called a stealth bonus. The stealth bonus is usually 0. The stealth bonus of the player is 10.

An attack modifiers rule (this is the stealth increases accuracy rule):
if the global attacker is stealthy:
increase the to-hit modifier by the stealth bonus of the global attacker;
if the numbers boolean is true:
say " + “, stealth bonus of the global attacker, " (sneak attack)[run paragraph on]”.

A damage modifiers rule (this is the sneak attack gives bonus damage rule):
if the global attacker is stealthy:
increase the damage modifier by the stealth bonus of the global attacker;
if the numbers boolean is true:
say " + “, stealth bonus of the global attacker, " (sneak attack)[run paragraph on]”.

A take away until attack circumstances rule (this is the combat breaks stealth rule):
if the global attacker is stealthy:
now global attacker is loud.

Every turn (this is the player death rule):
if the player is killed:
end the game saying “You were killed by [the global attacker].”.

a rule for starting the combat round (this is the can’t fight stealthy rule):
if the global defender is stealthy:
rule fails.

a rule for starting the combat round (this is the sleepers can’t attack rule):
if the global attacker is asleep:
rule fails.

To handle the combat round:
choose row 1 in the Table of Combat Order;
now the global attacker is the combatant entry;
now the initiative of the global attacker is 0;
now the combat state of the global attacker is at-Act;
now the main actor is the global attacker;
abide by starting the combat round rules;
if the global attacker is the player:
change the command prompt to “Act>”;
stop;
if the global attacker is alive, consider the combat AI rulebook of the global attacker;
if the combat state of the player is at-React:
change the command prompt to “React>”;
stop.

To have a reaction:
repeat with N running from 1 to the number of rows in the Table of Combat Order:
choose row N in the Table of Combat Order;
if there is combatant in row N of the Table of Combat Order:
if the combat state of the combatant entry is at-React:
now the global attacker is the combatant entry;
if the global attacker is asleep:
now the combat state of the global attacker is at-Reacted;
stop;
if the global attacker is alive, consider the combat AI rulebook of the global attacker;
now the combat state of the global attacker is at-Reacted.

Erdeth is a man. The description of Erdeth is “The great red dragon Erdeth, grown too large to escape his lair and having eaten everything he can reach, now spends most of his time hibernating and waiting for food to come to him. At the moment he appears to be sound asleep, fortunately.” Before printing the name of Erdeth when looking, say "the great dragon ". Understand “great dragon” or “dragon” as Erdeth.
Erdeth is asleep. The health of Erdeth is 200. The defence of Erdeth is 10.

Erdeth is hostile.

Erdeth’s Lair is a room. Erdeth is in Erdeth’s Lair.

The damage die of Erdeth’s natural weapon is 20. The weapon damage bonus of Erdeth’s natural weapon is 10. The dodgability of Erdeth’s natural weapon is 5. The passive parry max of Erdeth’s natural weapon is 3. The active parry max of Erdeth’s natural weapon is 1. The weapon attack bonus of Erdeth’s natural weapon is 5.

After printing the name of Erdeth when looking:
If Erdeth is asleep:
say " sleeping";
If Erdeth is awake:
say " eyeing his surroundings hungrily".

Every turn while Erdeth is asleep:
If the health of Erdeth is less than the permanent health of Erdeth:
now Erdeth is awake;
stop;
If the location of the player is the location of Erdeth:
say “[one of]Erdeth’s tail twitches briefly, then falls still.[or]Erdeth sighs in his sleep.[or]Erdeth’s wings twitch open briefly, then fall still.[or]Erdeth snorts and breathes a few rings of smoke.[at random]”.

After waiting in Erdeth’s Lair, now Erdeth is awake.

Awake Erdeth is a scene. Awake Erdeth begins when Erdeth is awake.

When Awake Erdeth begins:
now the description of Erdeth is “The great red dragon Erdeth looks around him with hungry eyes, ready to pounce on any morsel that reveals itself.”;
say “Erdeth’s nostrils twitch suddenly, and he scrambles to his feet, roaring with rage… and hunger.”.

Every turn during Awake Erdeth (this is the hungry dragon rule):
If the location of Erdeth is the location of the player:
If the player is stealthy:
say “[one of]Erdeth snuffles around, trying to find where the delicious scent of food is coming from.[or]Erdeth turns over a nearby rock, hoping to find something - or someone - to eat.[or]Erdeth lashes his tail angrily, narrowly missing your head.[then at random]”;
[/code][/spoiler]

Now I just need to figure out why Erdeth’s ‘every turn’ rule seems to be firing twice…

It proably runs once in the player’s turn and once in Erdeth’s turn. Add a clause like “if the main actor is Erdeth” to have it run only during Erdeth’s turns. (This works in ATTACK version 2 or later.)

The best place for these types of rules is the hate rules. If a rule decides on false then ATTACK will keep the regular peaceful prompt.

I’m trying to wrap my head around how the hate rules work - I remember trying them first, and them not working the way I wanted them to, but I’m giving them another shot.
I just ran into a different problem with the extension, trying to set up new factions, and I am really stumped. I looked at ATTACK’s source code and the manual, and there is no reason why this should not work.

Include Inform Attack by Victor Gijsbers.

Testing is a room. "The ogres are to your north." Den is north from Testing.

RedFaction is a faction. BlueFaction is a faction. RedFaction hates BlueFaction. BlueFaction hates RedFaction.

Red Ogre is a man. Red Ogre is in Den. Red Ogre is RedFaction.
Blue Ogre is a man. Blue Ogre is in Den. Blue Ogre is BlueFaction.

I get the following error:

Problem. You wrote 'RedFaction hates BlueFaction'  : but this seems to give a worldly relationship to something intangible, like saying that 'in the box is a text'. Perhaps it came to this because you gave something physical a name which was accidentally something meaningful to me in another context? If so, you may be able to get around it by rewording ('In the box is a medieval text') or in extremis by using 'called' ('In the box is a thing called text').

--------------------------------------------------------------------------------

Problem. You wrote 'BlueFaction hates RedFaction'  : again, this seems to give a worldly relationship to something intangible.

Yeah I don’t know what that happens. It seems to be a Inform bug.

It might be this bug. It’s similar at least.

inform7.com/mantis/view.php?id=523

I decided it was worth a new bug: inform7.com/mantis/view.php?id=994

Sorry for the fourth post in a row! If you need to get around the bug, you can set up the hating relationship with a when play begins rule instead of specifying it for compile time.