area/
/* Cyborg Class by Zaphonite */
#if defined(macintosh)
#include <types.h>
#else
#include <sys/types.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "merc.h"
#include "player.h"

void do_implant( CHAR_DATA *ch, char *argument )
{
  char arg1[MAX_INPUT_LENGTH];
  char arg2[MAX_INPUT_LENGTH];
  char buf[MAX_STRING_LENGTH];

  argument = one_argument( argument, arg1 );
  argument = one_argument( argument, arg2 );

  if (IS_NPC(ch)) return;

  if (!IS_CLASS(ch, CLASS_CYBORG))
  {
    send_to_char("Huh?\n\r",ch);
    return;
  }

  if ( arg1[0] == '\0' && arg2[0] == '\0')
  {
    sprintf(buf,"Current implant levels: #1Face: #9%d, #1Limbs: #9%d, #1Body: #9%d.\n\r",
    ch->pcdata->powers[CYBORG_FACE],
    ch->pcdata->powers[CYBORG_LIMBS],
    ch->pcdata->powers[CYBORG_BODY]);
    send_to_char(buf,ch);
    return;
  }

  if (arg2[0] == '\0')
  {
    if (!str_cmp(arg1,"face"))
    {
      send_to_char("Current Facial Implants:\n\r",ch);
      if (ch->pcdata->powers[CYBORG_FACE] < 1)
      send_to_char("None.\n\r",ch);
      if (ch->pcdata->powers[CYBORG_FACE] > 0)
      {
        if (ch->pcdata->powers[CYBORG_FACE] > 3)
        {
          send_to_char("Your infravision is level 3, you can see everything.\n\r",ch);
          send_to_char("Your head implants radiates a shield protecting you.\n\r",ch);
          send_to_char("Your sensors are improved, allowing you to see the stats\n\rand location of others.\n\r",ch);
          return;
        }
        else if ((ch->pcdata->powers[CYBORG_FACE] = 2))
        send_to_char("Your infravision allows you to see in the night and shadows.n\r",ch);
        else if ((ch->pcdata->powers[CYBORG_FACE] = 1))
        send_to_char("Your infravision allows you to see in the night.\n\r",ch);
      }
    return;
    }
    else if (!str_cmp(arg1,"limbs"))
    {
      send_to_char("Current Limb Implants:\n\r",ch);
      if (ch->pcdata->powers[CYBORG_LIMBS] < 1)
      send_to_char("None.\n\r",ch);
      if (ch->pcdata->powers[CYBORG_LIMBS] > 0)
      send_to_char("You have extra muscle implants giving you super strength.\n\r",ch);
      if (ch->pcdata->powers[CYBORG_LIMBS] > 1)
      send_to_char("Your limbs have been adjusted to move 5 x faster.\n\r",ch);
      if (ch->pcdata->powers[CYBORG_LIMBS] > 2)
      send_to_char("You have extra strength implants in, you can lift anything.\n\r",ch);
      if (ch->pcdata->powers[CYBORG_LIMBS] > 3)
      send_to_char("Your arms have been implanted with the power to have higher weaponskills.\n\r",ch);
      if (ch->pcdata->powers[CYBORG_LIMBS] > 4)
      send_to_char("You have lasers implanted into your arms.\n\r",ch);
      return;
    }
    else if (!str_cmp(arg1,"body"))
    {
      send_to_char("Current Body Implants:\n\r",ch);
      if (ch->pcdata->powers[CYBORG_BODY] < 1)
      send_to_char("None.\n\r",ch);
      if (ch->pcdata->powers[CYBORG_BODY] > 0)
      send_to_char("Your body's armor has been increased greatly.\n\r",ch);
      if (ch->pcdata->powers[CYBORG_BODY] > 1)
      send_to_char("Your body can absorb certain attacks.\n\r",ch);
      if (ch->pcdata->powers[CYBORG_BODY] > 2)
      send_to_char("You body slam your enemy when you have first attack.\n\r",ch);
      if (ch->pcdata->powers[CYBORG_BODY] > 3)
      send_to_char("You have the power to cloak yourself and become invisible.\n\r",ch);
      if (ch->pcdata->powers[CYBORG_BODY] > 4)
      send_to_char("You have poisoned stingers that shoot at your enemies from your body.\n\r",ch);
      if (ch->pcdata->powers[CYBORG_BODY] > 5)
      send_to_char("You regenerate very fast.\n\r",ch);
      return;
    }
    sprintf(buf,"Current implant levels: #1Face: #9%d, #1Limbs: #9%d, #1Body: #9%d.\n\r",
    ch->pcdata->powers[CYBORG_FACE],
    ch->pcdata->powers[CYBORG_LIMBS],
    ch->pcdata->powers[CYBORG_BODY]);
    send_to_char(buf,ch);
    return;
  }
  if (!str_cmp(arg2,"improve"))
  {
      int implant;
      int cost;
      int max;

      if (!str_cmp(arg1,"face" )) {implant = CYBORG_FACE; max = 5;}
      else if (!str_cmp(arg1,"limbs")) {implant = CYBORG_LIMBS; max = 5;}
      else if (!str_cmp(arg1,"body")) {implant = CYBORG_BODY; max = 6;}
      else
      {
        send_to_char("Implants are face, limbs, and body.\n\r",ch);
        return;
      }
      if ((ch->pcdata->powers[implant] == 1)) cost = 3000;
      else if ((ch->pcdata->powers[implant] == 2)) cost = 6000;
      else if ((ch->pcdata->powers[implant] == 3)) cost = 9000;
      else if ((ch->pcdata->powers[implant] == 4)) cost = 12000;
      else if ((ch->pcdata->powers[implant] == 5)) cost = 16000;
      else if ((ch->pcdata->powers[implant] == 6)) cost = 20000;
      else cost = 1000;
      arg1[0] = UPPER(arg1[0]);
      if (ch->pcdata->powers[implant] >= max )
      {
        sprintf(buf,"You already have all implants on your %s.\n\r",arg1);
        send_to_char(buf,ch);
        return;
      }
      if (!str_cmp(arg1,"face"))
      {
        if ((ch->pcdata->powers[CYBORG_FACE] == 4 && ch->pcdata->powers[CYBORG_BODY] < 4))
        {
          send_to_char("You need the body implant for cloaking before you can improve this.\n\r",ch);
          return;
        }
      }

      if (!str_cmp(arg1,"body"))
      {
        if (ch->pcdata->powers[CYBORG_LIMBS] < 1)
        {
          send_to_char("You need at least 1 limb implant before you can get any body implants.\n\r",ch);
          return;
        }
      }

      if ( cost > ch->pcdata->stats[CYBORG_POWER] )
      {
        sprintf(buf,"Your cyborg power must be greater than %d before you can improve your %s implants.\n\r",cost,arg1);
        send_to_char(buf,ch);
        return;
      }

      ch->pcdata->powers[implant] += 1;
      ch->pcdata->stats[CYBORG_POWER] -= cost;
      sprintf(buf,"You add an implant to your %s.\n\r",arg1);
      ADD_COLOUR(ch, buf, L_RED);
      send_to_char(buf,ch);
      return;
  }
  else send_to_char("Syntax: implant (place) improve.\n\r",ch);
  return;
}

void do_assimilate( CHAR_DATA *ch, char *argument )
{
  CHAR_DATA *victim;
  char buf[MAX_STRING_LENGTH];
  char arg[MAX_INPUT_LENGTH];

  argument = one_argument( argument, arg );

  if (IS_NPC(ch)) return;

  if (!IS_CLASS(ch, CLASS_CYBORG))
  {
    send_to_char("Huh?\n\r",ch);
    return;
  }

  if (ch->pcdata->stats[UNI_GEN] > 2)
  {
    send_to_char("Only collective leaders may assimilate others.\n\r",ch);
    return;
  }

  if (ch->pcdata->powers[CYBORG_FACE] != 5 || ch->pcdata->powers[CYBORG_LIMBS] != 5 ||
  ch->pcdata->powers[CYBORG_BODY] != 6)
  {
    send_to_char("You need all implants before you may assimilate others.\n\r",ch);
    return;
  }

  if (arg[0] == '\0' )
  {
    send_to_char("Assimilate who?\n\r",ch);
    return;
  }

  if ( (victim = get_char_room( ch, arg ) ) == NULL)
  {
    send_to_char("They are not here.\n\r",ch);
    return;
  }

  if ( IS_NPC(victim))
  {
    send_to_char("Not on NPC's.\n\r",ch);
    return;
  }

  if (IS_IMMORTAL(victim))
  {
    send_to_char("You cannot assimilate gods.\n\r",ch);
    return;
  }

  if (ch == victim )
  {
    send_to_char("You cannot assimilate yourself.\n\r",ch);
    return;
  }

  if (victim->level != LEVEL_AVATAR && !IS_IMMORTAL(victim))
  {
    send_to_char("You can only assimilate avatars.\n\r",ch);
    return;
  }

  if (ch->pcdata->stats[CYBORG_POWER] < 25000)
  {
    send_to_char("Your power level must be above 25000 before you can assimilate.\n\r",ch);
    return;
  }

  if (victim->class != 0)
  {
    send_to_char("They are already classed.\n\r",ch);
    return;
  }

  ch->pcdata->stats[CYBORG_POWER] -= 25000;
  act("Tubes fly out of your back and impale $N.",ch,NULL,victim,TO_CHAR);
  act("You begin assimilating $N.",ch,NULL,victim,TO_CHAR);
  act("You are drained of power as you complete the assimilation process.",ch,NULL,victim,TO_CHAR);
  act("Tubes fly from $n's back and impale you.",ch,NULL,victim,TO_VICT);
  act("$n begins assimilating you.",ch,NULL,victim,TO_VICT);
  act("$n staggers backwards from loss of power after assimilating you.",ch,NULL,victim,TO_VICT);
  act("Tubes fly from $n's back and impale $N.",ch,NULL,victim,TO_NOTVICT);
  act("$n begins assimilating $N.",ch,NULL,victim,TO_NOTVICT);
  act("$n staggers backwards from power drainage as $s assimilates $N.",ch,NULL,victim,TO_NOTVICT);
  victim->class = CLASS_CYBORG;
  sprintf(buf,"%n has been assimilated.",victim);
  do_info(ch,buf);
  send_to_char("You are now a cyborg.\n\r",victim);
  free_string(victim->lord);
  victim->lord = str_dup(ch->name);
  free_string(victim->clan);
  victim->clan=str_dup(ch->clan);
  victim->pcdata->stats[UNI_GEN] = ch->pcdata->stats[UNI_GEN] + 1;
  save_char_obj(ch);
  save_char_obj(victim);
  return;
}

void do_collective( CHAR_DATA *ch, char *argument )
{
    char buf[MAX_STRING_LENGTH];
    CHAR_DATA *gch;

    if (IS_NPC(ch)) return;
    if (!IS_CLASS(ch, CLASS_CYBORG) )
    {
        send_to_char("Huh?\n\r",ch);
        return;
    }

    if (strlen(ch->clan) < 2)
    {
        send_to_char("You aren't a member of any collective.\n\r",ch);
        return;
    }

    sprintf( buf, "Members of the %s collective:\n\r", ch->clan );
    send_to_char( buf, ch );
    send_to_char("[      Name      ] [ Gen ] [ Hits  % ] [ Mana  % ] [ Move  % ]\n\r", ch );
    for ( gch = char_list; gch != NULL; gch = gch->next )
    {
        if ( IS_NPC(gch) ) continue;
        if ( !IS_CLASS(gch, CLASS_CYBORG) ) continue;
        if ( IS_CLASS(gch,CLASS_CYBORG) )
        {
            send_to_char("[Name] [Hp/Maxhp] [Mana/Max] [Move/Max] [Power] [Face] [Limbs] [Body]\n\r",ch);
            sprintf( buf,
            "[%-16s] [%-6d%3d] [%-6d%3d] [%-6d%3d] [%-7d] [%d] [%d] [%d]\n\r",
                capitalize( gch->name ),
                gch->hit,  gch->max_hit ,
                gch->mana, gch->max_mana,
                gch->move, gch->max_move,
                gch->pcdata->stats[CYBORG_POWER],
                gch->pcdata->powers[CYBORG_FACE],
                gch->pcdata->powers[CYBORG_LIMBS],
                gch->pcdata->powers[CYBORG_BODY] );
                send_to_char( buf, ch );
        }
    }
    return;
}

void do_stuntubes( CHAR_DATA *ch, char *argument )
{
    CHAR_DATA *victim;
    int dam = number_range(250,750) + char_damroll(ch);
  
    if (dam < 500) dam = 750;
        
    if ( IS_NPC(ch) ) return;

    if ( !IS_CLASS(ch, CLASS_CYBORG) )   
    {
    send_to_char("Huh?\n\r", ch);
    return;
    }
        
    if (ch->pcdata->powers[CYBORG_BODY] < 5 || ch->pcdata->powers[CYBORG_LIMBS] < 5 )
    {
      send_to_char("You need level 5 implants on your limbs and body to use this.\n\r",ch);
      return;
    }
        
    if ( ( victim = ch->fighting ) == NULL )
    {
        send_to_char( "You aren't fighting anyone.\n\r", ch );
        return;
    }
    WAIT_STATE( ch,     1 * PULSE_VIOLENCE );
    WAIT_STATE( victim, 3 * PULSE_VIOLENCE );
    act("You fire a laser at $N.",ch,NULL,victim,TO_CHAR);
    act("$n fires a laser at you .",ch,NULL,victim,TO_VICT);
    act("$n fires a laser at $N.",ch,NULL,victim,TO_NOTVICT);
    damage(ch,victim,dam,gsn_laser);
    if (victim == NULL || victim->position == POS_DEAD) return;
    act("You launch your stun tubes at $N.",ch,NULL,victim,TO_CHAR);
    act("$n launches $s stun tubes at you.",ch,NULL,victim,TO_VICT);
    act("$n launches $s stun tubes at $N .",ch,NULL,victim,TO_NOTVICT);
    damage(ch,victim,dam,gsn_stuntubes);
    if (victim == NULL || victim->position == POS_DEAD) return;
    act("You fire multiple lasers at $N.",ch,NULL,victim,TO_CHAR);
    act("$n fires multiple lasers at you.",ch,NULL,victim,TO_VICT);
    act("$n fires multiple lasers at $N.",ch,NULL,victim,TO_NOTVICT);
    damage(ch,victim,dam*1.5,gsn_laser);
    if (victim == NULL || victim->position == POS_DEAD) return;
    act("You launch another volley of stun tubes at $N.",ch,NULL,victim,TO_CHAR);
    act("$n launches another volley of stun tubes at you.",ch,NULL,victim,TO_VICT);
    act("$n launches another volly of stun tubes at $N.",ch,NULL,victim,TO_NOTVICT);
    damage(ch,victim,dam*3,gsn_stuntubes);
    if (victim == NULL || victim->position == POS_DEAD) return;
    act("You charge up your lasers and fire at $N.",ch,NULL,victim,TO_CHAR);
    act("$n charges up $s lasers and fires at you.",ch,NULL,victim,TO_VICT);
    act("$n charges up $s lasers and fires at $N.",ch,NULL,victim,TO_NOTVICT);
    damage(ch,victim,dam*3.5,gsn_laser);
    if (victim == NULL || victim->position == POS_DEAD) return;
    act("You sting $N with your stun tubes, injecting poison.",ch,NULL,victim,TO_CHAR);
    act("$n stings you with $s stun tubes, injecting you with poison.",ch,NULL,victim,TO_VICT);
    act("$n stings $N with $s stun tubes, injecting $S with poison.",ch,NULL,victim,TO_NOTVICT);
    damage(ch,victim,dam*2,gsn_stuntubes);
    if (!IS_AFFECTED(victim, AFF_POISON)) SET_BIT(victim->affected_by, AFF_POISON);
    if (!IS_AFFECTED(victim, AFF_FLAMING)) SET_BIT(victim->affected_by, AFF_FLAMING);
    if (victim == NULL || victim->position == POS_DEAD) return;
    return;
}

void do_cybercloak( CHAR_DATA *ch, char *argument )
{
  if (IS_NPC(ch)) return;

  if (!IS_CLASS(ch, CLASS_CYBORG) )
  {
    send_to_char("Huh?\n\r",ch);
    return;
  }

  if (ch->pcdata->powers[CYBORG_BODY] < 4)
  {
    send_to_char("Your body must have at least 4 implants to cloak.\n\r",ch);
    return;
  }

  if (ch->move < 1000 || ch->mana < 1000)
  {
    send_to_char("You need 1000 mana and 1000 move to cloak.\n\r",ch);
    return;
  }

  if ( IS_SET(ch->itemaffect, ITEMA_VANISH))
  {
    REMOVE_BIT(ch->itemaffect, ITEMA_VANISH);
    act( "$n turns off his cloaking device.",ch,NULL,NULL,TO_ROOM);
    send_to_char("You turn off your cloaking device.\n\r",ch);
    return;
  }
  else
  {
    act( "$n turns on his cloaking device and disappears.",ch,NULL,NULL,TO_ROOM);
    send_to_char("You turn on your cloaking device.\n\r",ch);
    SET_BIT(ch->itemaffect, ITEMA_VANISH);
    return;
  }
  return;
}

void do_infravision( CHAR_DATA *ch, char *argument )
{
  if (IS_NPC(ch)) return;

  if (!IS_CLASS(ch, CLASS_CYBORG))
  {
    send_to_char("Huh?\n\r",ch);
    return;
  }

  if (ch->pcdata->powers[CYBORG_FACE] < 1)
  {
    send_to_char("You need at least 1 implant on your face to use infravision.\n\r",ch);
    return;
  }


  if (ch->pcdata->powers[CYBORG_FACE] > 2)
  {
  if (IS_SET(ch->act, PLR_HOLYLIGHT))
  {
    REMOVE_BIT(ch->act, PLR_HOLYLIGHT);
    send_to_char("You turn off your infravision.\n\r",ch);
  }
  else
  {
    SET_BIT(ch->act, PLR_HOLYLIGHT);
    send_to_char("You turn on your infravision.\n\r",ch);
  }
  }
  else if ((ch->pcdata->powers[CYBORG_FACE] = 2))
  {
    if (IS_SET(ch->affected_by, AFF_SHADOWSIGHT) && IS_SET(ch->pcdata->stats[UNI_AFF], VAM_NIGHTSIGHT))
    {
      REMOVE_BIT(ch->affected_by, AFF_SHADOWSIGHT);
      REMOVE_BIT(ch->pcdata->stats[UNI_AFF], VAM_NIGHTSIGHT);
      send_to_char("You turn off your infravision.\n\r",ch);
    }
    else
    {
      SET_BIT(ch->affected_by, AFF_SHADOWSIGHT);
      SET_BIT(ch->pcdata->stats[UNI_AFF], VAM_NIGHTSIGHT);
      send_to_char("You turn on your infravision.\n\r",ch);
    }
  }
  else if ((ch->pcdata->powers[CYBORG_FACE] = 1))
  {
    if (IS_SET(ch->pcdata->stats[UNI_AFF], VAM_NIGHTSIGHT))
    {
      REMOVE_BIT(ch->pcdata->stats[UNI_AFF], VAM_NIGHTSIGHT);
      send_to_char("You turn off your infravision.\n\r",ch);
    }
    else
    {
      SET_BIT(ch->pcdata->stats[UNI_AFF], VAM_NIGHTSIGHT);
      send_to_char("You turn on your infravision.\n\r",ch);
    }
  }
  return;
}

void do_linkregenerate( CHAR_DATA *ch, char *argument )
{
    if ( !IS_CLASS(ch, CLASS_CYBORG))
    {
        send_to_char("Huh?.\n\r",ch);
        return;
    }

    send_to_char("Not right now\n\r",ch);
    return;

    if ( ch->in_room != NULL && ch->in_room->vnum == 0 )
    {
      send_to_char("You must be in the regeneration chamber to link up.\n\r",ch);
      return;
    }

    switch ( ch->position )
    {
    case POS_SLEEPING:
        send_to_char( "You are already sleeping.\n\r", ch );
        break;

    case POS_RESTING:
        send_to_char( "You are already resting.\n\r", ch );
        break;

    case POS_MEDITATING:
        send_to_char( "You are already meditating.\n\r", ch );
        break;

    case POS_SITTING:
        send_to_char( "You stand up and plug yourself into one of the regeneration pods.\n\r", ch );
        act( "$n stands up and links into a regeneration pod.", ch, NULL, NULL, TO_ROOM );
        break;

    case POS_STANDING:
        send_to_char( "You link yourself into a regeneration pod.\n\r", ch );
        act( "$n links into a regeneration pod.", ch, NULL, NULL, TO_ROOM );
        break;
/*
    case POS_LINKREGEN:
        send_to_char("You are already linked into a regeneration pod.\n\r",ch);
        break;
*/
    case POS_FIGHTING:
        send_to_char( "You are already fighting!\n\r", ch );
        break;
    }

    return;
}