/*


 ---  ---  ---  ---  ---  ---          ---  ---  ---  --- 
 |S|  |P|  |I|  |R|  |A|  |L|          |V|  |O|  |I|  |D| 
 ---  ---  ---  ---  ---  ---          ---  ---  ---  ---
 
 
 Add this command in act_wiz.c
 
 You will of course need to add this command to your mud 
 using whatever method you use
 (stock uses tables.c and mud.h)

 
 
*/







/*
Make Imm
 Recieves:
  Pointer to CHAR_DATA - struct that holds the player data
  pointer to an argument supplied by the user at function call
    function call being when the user types the command
 Function:
  the argument is split into 2 commands arg and arg2
  arg is sent to the function get_char_world
  and a pointer to the char_data struct is returned
  arg2 is sent to the function atoi wich takes a character
  and converts it to an int
  then if both of those are supplied by the user
  the playername arg is set to trust and level arg2
  if the player meets all the conditions then the player
  is set to the level and set to the trust
  then several enhancements are done to the character


  - command written by cirus
  */
void do_makeimm( CHAR_DATA *ch, char *argument )
{
 char arg[MAX_INPUT_LENGTH];
 char arg2[MAX_INPUT_LENGTH];
 char buf[MAX_STRING_LENGTH];
 int level=0;
 CHAR_DATA *victim=0;
 int i=0;
 
 if( !IS_IMMORTAL(ch) )
 {
  send_to_char("\n\r&RERROR &Wonly an Immortal can use this command.",ch);
  return; // only immortals should use this command
 }
 if( IS_NPC(ch) ) 
 {
 send_to_char("\n\r&RERROR &Wnpc cannot use this command.",ch);
 return; // npc's should not be using this command
 }
 
 argument = one_argument( argument, arg);
 argument = one_argument ( argument, arg2 );

 if( !IS_IMMORTAL(ch) ) return;

 if ( arg[0] == '\0' )
 {
	 send_to_char( " \r\n&CSyntax is:                \r\n"
		           " &c makeimm playername level \r\n",ch );
	 return;
 }
 else
 {
	 victim=get_char_world( ch,arg );
   if( victim == 0 )
   {
    send_to_char("\n\r &RVictim ",ch);
    ch_printf(ch,"&g%s",arg);
    send_to_char(" &RNot found.",ch);
    return;
   }	 

     if( IS_NPC(victim) )
     {
      send_to_char("\n\r&RERROR &Wcannot perform command on npc.",ch);
      return; // cannot perform command on a npc
     }   

 }

 if ( arg2[0] == '\0' )
 {
     send_to_char(" \r\n&RSpecify the level you want your new immortal to be. \r\n",ch);
	 return;
 }
 else
 {	
	 level = atoi( arg2 );
	 if ( level > ch->top_level )
	 {
	  send_to_char(" \r\n&RYou can only make an imm that is your level or lower.\r\n",ch);
	  return;
	 }
	 if ( level == victim->top_level )
	 {
	  send_to_char(" \r\n&RThe character is allready that level.\r\n",ch);
	  return;
	 }
	 
	 /*
	 Authorizing the Player
	 */
	 victim->pcdata->auth_state = 3;
	REMOVE_BIT(victim->pcdata->flags, PCFLAG_UNAUTHED);
	if ( victim->pcdata->authed_by )
	   STRFREE( victim->pcdata->authed_by );
	victim->pcdata->authed_by = QUICKLINK( ch->name );
	sprintf( buf, "%s authorized %s", ch->name,
					  victim->name );
	to_channel( buf, CHANNEL_MONITOR, "Monitor", ch->top_level );
	ch_printf( ch, "You have authorized %s.\n\r", victim->name);
	
	 send_to_char("\n\r&BYou are now Authorized \n\r",victim);
	 send_to_char("\n\r&RMakeing victim immortal ... ",ch);
	 send_to_char("\n\r&BYou are now immortal\n\r",victim);
	 victim->top_level = level;
	 // see room vnum when using do_look
	 SET_BIT( victim->act, PLR_ROOMVNUM );
	 send_to_char("\n\r&YPlayer->ROOMVNUM flag set.",victim);
	 // see room flags when using do_look
	 SET_BIT( victim->pcdata->flags, PCFLAG_ROOM );
	 send_to_char("\n\r&GPlayer->ROOMFLAGS flag set.",victim);
	 do_holylight( victim," ");
	 victim->gold = 1000000;
	 send_to_char("\n\r&GCredits set to 1000000 ...",victim);
	 victim->armor = -300;
	 send_to_char("\n\r&YArmor Condition set to -300 ...",victim);
     
     	 /*
     for loop sets all abilitys of the new
	 immortal to 200 and if the ability
	 is combat it gives the imm 4000 hp
	 and move points if the ability is
	 force it gives the imm 4000 mana
	 points
	 */
     for(i=0; i < MAX_ABILITY; ++i)
     {
        victim->skill_level[i] = 200;
        if(i==COMBAT_ABILITY)
        {
        victim->max_hit = 4000;
		send_to_char("\r\n&GHealth set to 4000 ...",victim);
        victim->max_move = 4000;
        send_to_char("\r\n&YMove set to 4000 ...",victim);
        }
        if(i==FORCE_ABILITY)
		{
		 send_to_char("\r\n&GMana set to 4000 ...",victim);
		 victim->max_mana = 4000;
		}
	 }
	 send_to_char("\r\n&YLevels set to 200 ...",victim);
	 
	 /* Sets Skill Percentages */
	 int sn;
	 for ( sn = 0; sn < top_sn; sn++ )
         {
         victim->pcdata->learned[sn] = 100;
         }
	 
	 send_to_char("\r\n&GSkills set to 100 ...\r\n",victim);
	 victim->trust = level;
	 make_wizlist();
 }
 return;
}