/
roa/
roa/lib/boards/
roa/lib/config/
roa/lib/edits/
roa/lib/help/
roa/lib/misc/
roa/lib/plrobjs/
roa/lib/quests/
roa/lib/socials/
roa/lib/www/
roa/lib/www/LEDSign/
roa/lib/www/LEDSign/fonts/
roa/lib/www/LEDSign/scripts/
roa/src/s_inc/
roa/src/sclient/
roa/src/sclient/binary/
roa/src/sclient/text/
roa/src/util/
/************************************************************************
	Realms of Aurealis 		James Rhone aka Vall of RoA

mount.c 				Various commands/functions that
					relate to mounts, mounting and
					dismounting...

		******** 100% Completely Original Code ********
		*** BE AWARE OF ALL RIGHTS AND RESERVATIONS ***
		******** 100% Completely Original Code ********
		        All rights reserved henceforth. 

    Please note that no guarantees are associated with any code from
Realms of Aurealis.  All code which has been released to the general
public has been done so with an 'as is' pretense.  RoA is based on both
Diku and CircleMUD and ALL licenses from both *MUST* be adhered to as well
as the RoA license.   *** Read, Learn, Understand, Improve ***
*************************************************************************/
#include "conf.h"
#include "sysdep.h"

#include "structures.h"
#include "utils.h"
#include "comm.h"
#include "interpreter.h"
#include "acmd.h"
#include "handler.h"
#include "db.h"
#include "mudlimits.h"
#include "lists.h"

chdata *get_mounter(chdata *ch)
{
  chdata *vict = NULL;

  if (IS_PC(ch)) return NULL;

  for (vict = world[ch->in_room].people; vict; vict = vict->next_in_room)
    if (IS_PC(vict) && PC_MOUNTING(vict) &&
        ch->npc_specials.mounter_id == GET_IDNUM(vict))
      break;

  return vict;      
}

chdata *get_mount_in_room(chdata *ch)
{
  chdata *vict;

  for (vict = world[ch->in_room].people; vict; vict = vict->next_in_room)
    if (IS_NPC(vict) && IS_MOUNTED(vict) && 
        vict->npc_specials.mounter_id == GET_IDNUM(ch))
      break;
  return vict;      
}

ACMD(do_mount)
{
  chdata *vict;
  int percent, chance;  /* for rebellion */

  if (IS_NPC(ch)) return; /* for now */

  if (strlen(argument) > MAX_POOFIN_LENGTH)
  {
    send_to_char("Argument too long, try again...\n\r",ch);
    return;
  }

  if (PC_MOUNTING(ch))
  {
    send_to_char("You are already mounted!\n\r",ch);
    return;
  }

  if (!*argument)
  {
    send_to_char("Mount what?\n\r",ch);
    return;
  }
  
  one_argument(argument, arg);

  if (!(vict = get_char_room_vis(ch, arg)))
  {
    send_to_char("That mount is not here....\n\r",ch);
    return;
  }

  if (ch == vict)
  {
     send_to_char("You wish to mount yourself eh?\n\r",ch);
     return;
  }

  if (IS_PC(vict))
  {
    send_to_char("You cannot mount other players... well not here anyways.\n\r",ch);
    act("$n just tried to mount you!", TRUE, ch, 0, vict, TO_VICT);
    return;
  }
  
  if (!MOB_FLAGGED(vict, MOB_MOUNTABLE))
  {
    act("$N refuses to be your mount!", FALSE, ch, 0, vict, TO_CHAR);
    return;
  }

  if (IS_MOUNTED(vict) || vict->npc_specials.mounter_id > 0)
  {
    act("$N is already currently mounted!", FALSE, ch, 0, vict, TO_CHAR);
    return;
  }

  if (GET_SIZE(vict) > SIZE_LARGE) 
  {
    act("$N is too small to be mounted.", FALSE, ch, 0, vict, TO_CHAR);
    return;
  }

  if (GET_LEVEL(vict) > GET_LEVEL(ch))  /* chance of rebellion */
  {
    percent = GET_LEVEL(vict) - GET_LEVEL(ch);
    percent = percent * 10;
    chance = number (1, 100);
    if (percent > chance)
    {
      act("$N is enraged at yor attempt to mount $M!", FALSE, ch, 0, vict, TO_CHAR);
      do_kill(vict, GET_NAME(ch), 0, 0);
      return;
    }
  }

  vict->npc_specials.mounter_id = GET_IDNUM(ch);
  SET_BIT(CHAR_FLAGS(vict), CH_MOUNTED);
  GET_POS(ch) = POS_MOUNTED;
  act("You climb atop $N.", FALSE, ch, 0, vict, TO_CHAR);
  act("$n climbs atop you!", FALSE, ch, 0, vict, TO_VICT);
  act("$n climbs atop $N.", TRUE, ch, 0, vict, TO_ROOM);
}

ACMD(do_dismount)
{
  chdata *vict;

  if (IS_NPC(ch)) return;  /* for now */

  if (!PC_MOUNTING(ch))
  {
    send_to_char("You are not mounted on anything!\n\r",ch);
    return;
  }

  if (!(vict = get_mount_in_room(ch)))
  {
    send_to_char("Your mount is not around.\n\r",ch);
    GET_POS(ch) = POS_STANDING;  /* reset in case of errors */
    return;
  }

  GET_POS(ch) = POS_STANDING;
  REMOVE_BIT(CHAR_FLAGS(vict), CH_MOUNTED);
  vict->npc_specials.mounter_id = -1;
  act("You dismount $N.", FALSE, ch, 0, vict, TO_CHAR);
  act("$n dismounts you!", FALSE, ch, 0, vict, TO_VICT);
  act("$n dismounts $N.", TRUE, ch, 0, vict, TO_ROOM);
}

ACMD(do_mforce)
{
   chdata *vict;

   if (IS_NPC(ch)) {
      send_to_char("Umm.... no.\n\r", ch );
      return;
   }

   if (!PC_MOUNTING(ch))
   {
     send_to_char("You are not mounted on anything!\n\r",ch);
     return;
   }

   if (!*argument)
   {
     send_to_char("Force your mount to do what?\n\r", ch);
     return;
   }

   if (strlen(argument) > MAX_POOFIN_LENGTH)
   {
     send_to_char("Argument length too long, nice try...\n\r", ch);
     return;
   }

   if (GET_LEVEL(ch) >= LEV_IMM && GET_LEVEL(ch) < LEV_IMPL)
   {
     send_to_char("Immortals may not force NPCs with this command.\n\r",ch);
     return;
   }
   
   if (!(vict = get_mount_in_room(ch))) 
   {
     send_to_char("Your mount is not around!!\n\r",ch);
     GET_POS(ch) = POS_STANDING;  /* reset in case of errors */
     return;
   }

   if (GET_LEVEL(ch) > GET_LEVEL(vict)) 
     command_interpreter(vict, argument);
   else
   {
     send_to_char("You are unable to force this mount...\n\r",ch);
     return;   /* riding skill goes here... */
   }
}