How to make a stealth action?

Hi everybody,

I have another question. I would like to make a stealth function in my game that you could activate by saying something like “activate stealth” or “go stealthy”. However, I don’t know if I should make a new action called “activate stealth” or if I should use some other method to make a stealth function.

I don’t know exactly how I would use this stealth function, but maybe you guys could make it so that it would last for a few turns and then it would take a number of turns to regen?

Thanks,

Superjax

Ultimately you’ll want a flag that says whether or not the player is in stealth mode. This could be a property (A person is either stealthy or loud. Yourself is loud.) Or, I think less elegantly, a truth state (Stealth is a truth state that varies. Stealth is false.) Or depending on how you achieve stealth in the game, it might already be incorporated in the action. (if the invisibility cloak is worn by the player… If the phase generator is switched on…)

You’ll want some way for the player to become stealthy. If they’re just sneaking about, you’ll want it to be a new action. Something like:

Sneaking is an action applying to nothing. Understand "activate stealth" and "sneak" as sneaking. Check sneaking: if the player is stealthy, say "You're already sneaking!" instead. Carry out sneaking: now the player is stealthy. Report sneaking: say "You step into the sneaking position."

Then you’d want a stop sneaking action and there to be conditions (like being spotted) that end sneaking.

Alternately, this may be one case where going the adverb route might actually be warranted. In any case, you’ll want it to activate JJ’s stealthiness flag.

See example 361, from WI 17.31 for one implementation idea:

[code]An approach is a kind of value. Stealthily is an approach. Understand “quietly/silently/soundlessly” as stealthily.

A person can be stealthy.

After reading a command:
now the player is not stealthy;
if the player’s command includes “[approach]”:
cut the matched text;
if the approach understood is stealthily, now the player is stealthy;

Before going when the player is stealthy: say “You move as quietly as a mouse.”[/code]

K thx JoeyJones :slight_smile:
Thx Chris,

So, this is my code for the stealth mode:

[code]A person is either stealthy or unstealthy.
The player is unstealthy.

Activating stealth is an action applying to nothing. Understand “activate stealth” as activating stealth.
Check activating stealth:
if the player is stealthy, say “You’re already stealthy!” instead.
Carry out activating stealth:
now the player is stealthy.
Report activating stealth:
say “You feel a vibration in your spine as the stealth generator activates.”

Deactivating stealth is an action applying to nothing. Understand “deactivate stealth” as deactivating stealth.
Check deactivating stealth:
if the player is unstealthy, say "You have to be in stealth to deactivate stealth " instead.
Carry out deactivating stealth:
now the player is unstealthy.
Report deactivating stealth:
say "You hear several clicks and a bit of smoke pours out the stealth generator. You are no longer stealthy.

Before going when the player is stealthy:
say “You move as quietly as a mouse.”"[/code]

However, I would like to make it so that you would only be able to stealth for say, 3 turns, and then you would automatically unstealth.

So how would I do that?

Looking good. You’ll want a future events rule, like this:

[code]Carry out activating stealth:
now the player is stealthy;
stealth ends in three turns from now.

At the time when stealth ends:
try deactivating stealth.[/code]

I guess you’re going to want some kind of mechanism to prevent the player from constantly stealthing- a number of charges, maybe? That can be done with a number that goes down after every use of stealth (and could be replenished in-game).

Chris: If it weren’t a cloaking device but rather a way of performing actions, then I would suggest considering implementing the ‘stealthily’ adverb, but as it’s more something that is turned on or off it wouldn’t be as appropriate.

Two alternatives:

Every turn when yourself has been stealthy for at least two turns: say "You bump into something in a totally unstealthy way. Enough of this sneaking around."; now yourself is loud;

[code]The player has a number called stealthiness.
Definition: Yourself is stealthy rather than loud if the stealthiness of yourself is at least 1.

Carry out sneaking: Now the stealthiness of the player is 3.

Every turn when the player is stealthy:
Decrement the stealthiness of the player;
if the player is loud, say “You bump into something in a totally unstealthy way. Enough of this sneaking around.”;
[/code]

Note that these have different results - the second one allows you to refresh your stealthiness, while the first one times out no matter what you do.

Thx cptmikee! I used your method.

K guys, everything works perfectly, but I think it would be cool if I had a “stealth charges” system where you could convert stealth charges(which would be objects or things that would go in your inventory) into batteries(which would be a number) for your stealth generator. Basically, every time you used the “activate stealth” ability, it would consume a battery, and you would have to put another stealth charge into the stealth generator(turning the stealth charge into a number). You can only have 1 battery at a time in the stealth generator.

I don’t know if this would be possible, but if someone could tell me how to do this, that would be awesome.

Sounds pretty straightforward.

[code]A stealth battery is a kind of thing.

Stealth-activating with is an action applying to one thing.

Check stealth-activating with something that is not a stealth battery:
say “You can only use stealth batteries to activate stealth.”;
stop the action.

Check stealth-activating with when the player is stealthy:
say “You are already using a stealth battery.”;
stop the action.

Carry out stealth-activating with:
Increase the stealth of the player by 3;
remove the noun from play;

Report stealth-activating:
say “You charge up your stealth with [the noun].”;[/code]

You can implement a stealth-cloak which can contain a battery if you want, and keep track of which batteries are used or fresh. You could also create a separate action (or a supplying a missing noun rule) for when the player doesn’t say which battery to use. That’s all details.

Thx capmikee, I kind of combined your code with the code that was already there.
This is the result:

[code]The stealth charge is carried by the player.
A stealth charge is a battery.

A battery is a kind of thing.

A person is either stealthy or unstealthy.
The player is unstealthy.

Activating stealth with is an action applying to one thing.
Understand “charge with [battery]” and “activate stealth with [battery]” as activating stealth with.
Check activating stealth with:
if the player is stealthy, say “You’re already stealthy!” instead;
if the battery is not a stealth charge, say “You can only use stealth charges to activate stealth.” instead;
Carry out activating stealth with:
Now the stealthiness of the player is 6;
Now the player is stealthy;
remove the noun from play.

Report activating stealth with:
say “You insert a stealth charge into a slot in the stealth generator. You feel a vibration in your spine as the stealth generator activates.”

Deactivating stealth is an action applying to nothing. Understand “deactivate stealth” as deactivating stealth.
Check deactivating stealth:
if the player is unstealthy, say "You have to be in stealth to deactivate stealth " instead.
Carry out deactivating stealth:
now the player is unstealthy.
Report deactivating stealth:
say “You hear several clicks and a bit of steam pours out the stealth generator. You are no longer stealthy.”

Before going when the player is stealthy:
say “You move without a sound to your destination.”

The player has a number called stealthiness.
Definition: Yourself is stealthy rather than unstealthy if the stealthiness of yourself is at least 1.

Every turn when the player is stealthy:
Decrement the stealthiness of the player;
if the player is unstealthy, say “You bump into something in a totally unstealthy way. Enough of this sneaking around.”;
[/code]

I’m pretty sure that I’ve finished the stealth code.

Kthxbaifornow

You are setting yourself up for the dreaded “that noun did not make sense in that context” error here. Grammar lines should be as open-ended as possible - you can narrow them down with Does the Player Mean and block them off with Check rules. But once the parser fails, it’s out of your hands. That’s why my suggestion was of the form “charge with [something]” and then adding a check rule for non-batteries.

K I fixed it :wink:

Hi everbody,

I have another problem. I’ve added in a combat system and changed the stealth system a bit, and I want to make it so that you/enemies/allies can’t attack something that is stealthy:

Check attacking a stealthy thing with something: if the actor is an enemy: say "The thug doesn't see a thing. You are completely invisble to him." instead. if the actor is the player: say "You think you see a shimmer, but you are unable to effectively attack it. Try using an EMP Blast." instead. if the actor is an ally: say "[the actor] thinks he sees something, and grows tense." instead.

For some reason, the code doesn’t work. If you need the combat system code to solve the problem, I can post it.

Here’s the stealth code:

[code]The stealth generator is a device.
The stealth generator is part of the Advanced Espionage Suit.
The stealth generator has a number called battery.
The battery of the stealth generator is 10.
Definition: Yourself is stealthy rather than unstealthy if the battery of the stealth generator is at least 1.

Every turn when the player is stealthy:
Decrement the battery of the stealth generator;
if the player is unstealthy, say “You bump into something in a totally unstealthy way. Enough of this sneaking around.”.

Check switching on the stealth generator:
if the battery of the stealth generator is 0:
say “Your stealth generator has run out of energy. Recharge at the nearest allied power station.” instead;
if the stealth generator is switched on:
say “Your stealth generator is already switched on!” instead;

Carry out switching on the stealth generator:
Now the player is stealthy;
say “You feel a vibration in your spine as the stealth generator activates.”.

Check switching off the stealth generator:
if the stealth generator is switched off:
say “Your stealth generator is already switched off!” instead.

Carry out switching off the stealth generator:
Now the player is unstealthy;
say “You hear several clicks and a bit of steam pours out the stealth generator. You are no longer stealthy.”.[/code]

“Check attacking” rules will only fire if the actor is the player. You need:

Check an actor attacking a stealthy thing with something:

See chs. 12.11 - 12.14