Re: Guard [LONG]

From: Fizal (
Date: 04/20/99

--- Albert Brauneis <> wrote:
> I need a little help here, I am tring to make a guard skill. What it
> does is you type guard <name> and that makes you guard <name> Then if
> anyone attacks <name> The person who is guarding automaticly rescues
> them. How would I go about this. Please no flames, just help. :)

Actually, someone sent some codes on this a week or so ago to the
mailing list, asking for help. Maybe you can look thru the archive for
it. Anyway, basically it's supposed to be something like this:

1. Add these into the char_data structure (struct.h), something like
below, into... maybe struct char_special_data or something. The
GUARDING will point to the person who player is guarding, and the
GUARDED_BY will point to the person who is guarding the player.
       struct char_data *guarding
       struct char_data *guarded_by

2. Create some shortcuts for easy reference (utils.h). Look at
FIGHTING(ch) as an example.

3. Create a ACMD(guard) function that will be called when someone type
"guard <name>". Where to put? Anywhere you think is suitable. In the

ACMD(guard) {
  if (no argument)
    give error message to player
  else if (anyone around with name)
    /* found someone with specified name in room */
    if (person specified is player)
      if (player is guarding someone right now) {
        /* make player stop guarding */
        set person being guarded by player to null
        set player guarding to null
      } else
        give error message to player
    else {
      set player to guard person
      set person to be guarded by player
    /* no one is around with specified name */
    give error message to player

4. Place "guard" into the command_info table (interpreter.c), with all
relevent info.

5. If you're making this as a skill, then you need to:
- define it's skill number in spells.h
- set up the skill info under skillo() in spell_parser.c
- specify the skill's class and level in init_spell_level in class.c

Hmm... did I missed anything? Hopefully not. Better check out the WTFAQ
and FAQ for more detail info. This is just a simple outline...

G'luck! :)

Afizal Mustapa
Petaling Jaya, Malaysia

Do You Yahoo!?
Get your free address at

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  |

This archive was generated by hypermail 2b30 : 12/15/00 PST