Re: positions

From: Fizal (amustapa@yahoo.com)
Date: 02/06/99


---Edward J Glamkowski <eglamkowski@angelfire.com> wrote:
>
> >I don't know what your mount system looks like, but I'm assuming that
> >within your char_data struct there is a pointer to the mounted mob.
 > >The easiest way to achieve your goal is to just put a check in
your > >"mounted only" skills sorta like this:
> >
> >  if (!GET_MOUNT(ch)) {
> >    send_to_char("You can only use this skill when mounted.\r\n",
ch);
> >    return;
> >  }

Take a look at dak's mount snippet. What Xual meant was, following
dak's snippet, there should some pointers in the char_data struct that
look like these:

   struct char_data *riding      /* Points: Player -> mounted mob */
   struct char_data *ridden_by   /* Points: Mob -> mounting  player */

Why? This is because both mobs and players share the same basic
structure. So, if a player is not riding anything, both will be NULL.
However, if a player mounts a mob, let's say a horse for example, the
player's *riding pointer will points to the horse, while the horse's
*ridden_by pointer will point back to the player. This way, if given
either one of them, you can easily get the other, with some macros
like GET_MOUNT(ch) for the *riding pointer and GET_RIDER(ch) for the
*ridden_by pointer.

> That only partly works - if I want to let players charge into combat
> with a lance in order to skewer their opponents, that works ok, but if
> they don't kill their opponent and they start fighting, the lancer is
> moved from POS_MOUNTED to POS_FIGHTING and they can no longer use any
> mounted only skills for the duration of the fight. Which is not what I
> want.

True is you have POS_MOUNTED, POS_FIGHTING and POS_MOUNTED_FIGHTING.
Xual's suggestion was for you *not* to do that, but rather to stick to
the original POS_FIGHTING. Based on dak's snippet, whether the player
is riding or being ridden, he/she is actually in POS_STANDING. If you
want to make certain skills to only be used while mounting, you can
just simply add the above check into the skill function, like this:

ACMD(charge_and_skewer)
{
  /* Do some checking first before anything else */
  if (!is player mounting on something?) {
    message to tell player that he/she needs to be mounted
    return
  }
  if (!does player know the skill?) {
    message to tell player that he/she needs to learn more
    return
  }
  if (!is player using right equipment?) {
    message to player that he/she needs to think things thru first
    return
  }
  ....

  /* Identify the target. If the target is specified, check if the
     target is in the same room and can be seen. If not specified,
     check if the player is fighting, and assume the target is the
     enemy. Check also if player is drunk and targetting him/herself */
  ....

  /* Check skill vs. chance. If made it, skewer the enemy. If not, set
     player to start attacking target normally. */
  ....

}

Following the above example, if a player issue the charge_and_skewer
command, it will *first and foremost* check if the player is mounted
or not. If not, it will immediately stop with a message, else it will
continue with the rest of the function. This way, no matter whatever
the player's position is, fighting/standing/resting(on mount?), it
will check for that mounting condition. Another good thing about this
method is that you can also do another check at other places to make
sure that the player is *not* riding on something. Example: kick skill
for warrior and trip skill for thief. It will definitely be very
difficult, if not impossible, to kick/trip an enemy while mounting
something, unless you're kicking/tripping the mount itself :P

> Making fighting a state allows for both (so they'd be either
> fighting/standing or fighting/mounted, as fighting from any other
> position either leads to them standing or dying).

True, but as Xual stated at the top, this is "the easiest way to
achieve your goal". But, if you have a clear plan/way to develop the
states of fighting, go ahead and try. Who knows, maybe you'll find
more ideas and interesting things that can be developed based it! :)

> Like I said, I could do a POS_MOUNTED_FIGHTING but then I'd have a lot
> of fundamentally duplicate code with POS_FIGHTING.

As a reminder, another thing you should make sure of: the placing if
POS_MOUNTED and POS_MOUNTED_FIGHTING in the list of positions. If you
place them wrongly (ex: between POS_SLEEPING and POS_RESTING), you'll
have more probs in your hands.

G'luck!

==
Afizal Mustapa
Petaling Jaya, Malaysia
(amustapa@hotmail.com)



_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



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