NPC Actions

I’m having some difficulty with the programming of actions that both the player and the NPCs will take.

The game is a survival-horror, like a Friday the 13th style game, where you and 3 NPCs try to survive against the zombie monster killer.

There are various attacks the killer (or anyone) could use, such as hitting with a weapon, biting, kicking, grabbing, etc.

I want to write the code so that the check/carry out is irrelevant to the actor- so any actor can bite any other character.

This is the code I’ve tried:

Every Turn:
   if the player can see Josh and the hostility of josh > 70:
      try josh punching the player.

I’ve verified that the hostility is > 70 and I can certainly see Josh, but josh does not seem to be attacking me. I’ve also verified my own status (with SHOWME) to verify that I haven’t been taking wounds or anything, and it seems like he’s just sitting there. What could the issue be?

Also- is there a way to allow you to take something from another NPC (so it does’t say THAT SEEMS TO BELONG TO JOSH), in certain circumstances (such as if the NPC is unconscious or dead?). You can knock people out or kill them, and when the killer is knocked out, it would be nice if you could steal his axe…

Hard to tell exactly what’s wrong without seeing the punching code, but it seems like it must be one of the following:

  1. the trigger doesn’t really work
  2. the action isn’t really generalized for NPCs
  3. the NPC is trying the action but failing to complete it

To test these:

  1. You could test the trigger by adding a say phrase (“say “JOSH SHOULD HIT YOU NOW”;”). Does the text line show up when you expect Josh to punch you? If so, your trigger is good.

  2. is a little harder to test for directly, so I’d try

  3. Type ACTIONS and then wait a turn or two. This will print debugging information about all the actions attempted by any character, and if the action is silently failing for an NPC, it may list the reason why. (If for instance you’ve written a check rule that prevents him from acting but prints nothing, that should be visible.)

If the action isn’t firing at all, then I’d go back and look at the code you’ve written for characters to punch with. Do the rules start with things like “Check an actor punching: …” and “Carry out an actor punching: …”, or are they just “Carry out punching…:”? If the latter, they’re written for the player only.

If none of that helps, perhaps post the code you’re using for the action.

Missed this bit:

There are several ways you could approach this:

– replace the check taking rule that prevents taking something from an NPC, and provide a new check rule that doesn’t fire if the NPC is disabled
– when an NPC is killed or knocked out, replace the person with a dummy object (“Josh’s corpse”) that is not of the person kind, and move all Josh’s possessions to this object. This has the additional advantage that the corpse won’t answer questions or do another things that you might have coded for the live person. Disadvantage: you’ll probably want a bit of custom code so that if Josh’s body is internally, say, a supporter, Inform nonetheless reports their possessions in a way that sounds plausible and not like the ax is just sitting on a table.
– have the NPC drop all their possessions into the location when they die or are knocked out. This has the advantage that those objects will more obviously appear in a room description, which may be relevant if you want players to go around scouting for weapons et al.

Yeah, I was using carry out punching rather than carry out an actor punching.

The problem with the dummy object (which I think might be what i have to do) is that characters get over being knocked out, but don’t get over being dead. While knocked out or dead, you can take their held objects, when alive you can’t.

I’m also kind of worried that a dummy object would react as an object in ways you don’t want to (such as my check rules regarding grappling or biting an object rather than a person), though this might be an easy walkaround. If the killer is knocked out, I would like the PC to be able to take his axe and then kill him with it if they desire.

Each person has a state (which will be either awake, unconscious, or dead) and any coded NPC actions are intended to work only when the NPC is awake.

In any case, the actor punching is certainly the issue, thanks! I will have to get that corrected.