[Circle] [CODE] Changing the interpreter?

From: Fionn Colvin (fcolvin@metz.une.edu.au)
Date: 11/23/96


Hiya all,
         I was thinking about changing a few things with the command 
interpreter, and thought I'd swing them by the list first to see if there 
is some major problem which might arise from doing them.

What I'd like to do is change the mim position bit in the command list to 
a list of legal positions. Something like this.

The positions would be represented by a letter much like these below.

POS_DEAD       a
POS_MORTALLYW  b
POS_INCAP      c
POS_STUNNED    d
POS_SLEEPING   e
POS_RESTING    f
POS_SITTING    g
POS_CLIMBING   h
POS_RIDING     i
POS_FIGHTING   k
POS_STANDING   l
POS_ANY        z

Then in the command list id have something like this below. In this 
example if you were in POS_RIDING (i) or POS_STANDING (l) you could do 
the command kill. etc.

  { "kill"     , "il", do_kill     , 0, 0 },
  { "kick"     , "kl", do_kick     , 1, 0 },
  { "kiss"     , "fghikl", do_action   , 0, 0 },

I'd then write a little function something like this:

int correct_pos(struct char_data *ch, int cmd)
{

[Get ch's position]
[Convert it into a letter as the table above shows]
[Run through the legal positions for the command "cmd" and see if one of 
them matches the players position]
[If so return 1]
[Else return 0]

}

Then in the function command_interpreter I'd change the minimum position 
check to this:

  else if (GET_POS(ch) < cmd_info[cmd].minimum_position)  <- OLD
  else if (!correct_pos(ch, cmd))                         <- NEW
    switch (GET_POS(ch)) {
    case POS_DEAD:
      send_to_char("Lie still; you are DEAD!!! :-(\r\n", ch);
      break;
    case POS_INCAP:
    case POS_MORTALLYW:
      send_to_char("You are in a pretty bad shape, unable to do anything!\r\n", ch);
      break;

I think this would make adding new positions much easier.

So can anyone see any major problems which will arise from doing this? I 
don't want to go ahead and chage all the commands in the master command 
list and then find out that it stuff everything up.

Thanks for the help

Fionn
+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



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