/****************************************************
* Ok Here it is my 3rd Snip, this one is called     *
* Buildvance v1.0                                   *
* Created by David Walker (aka. Azrail)             *
* telnet://mudsite.dyndns.org:3801                  *
* Submitted -> 10-28-2002                           *
****************************************************/
/* 
 * OK i have a few small things to ask, being this is my 3rd snip it took me
 * A little to get it down right, so all im asking is you at lease email me
 * Saying that you are using it -> email is  dwalker@mudsite.dyndns.org
 * thanks
 */

 /* Instructions
 
 THIS IS MADE FOR ROM2.4b6 BUT WILL WORK ON OTHER BASES
      
       !OLC IS A REQUIREMENT, HENCE FOR BUILDERS!
 
 1. In merc.h or mud.h what ever base you using
    add
    
    PLR_IS_BUILDER     ##
    
    somewhere in the PLR_ flags, and ## means givt it a free bit
    
 2. in interps add these 2 lines
    
    *interp.c*
    {"buildvance", do_buildvance, POS_DEAD, L1, LOG_NORMAL, 1},
    
    *interp.h*
    DECLARE_DO_FUN( do_buildvance )

 3. Add the code below to act_wiz.c or whatever.
    
    MAKE SURE TO change **head builder name** to your head builders name.
    
*/
    
/* buildvance created by Azrail of Equanox */        
void do_buildvance (CHAR_DATA * ch, char *argument)
{
    CHAR_DATA *victim;
    char arg1[MIL];
    char arg2[MIL];
    char arg3[MIL];
    int  stat;
    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );
    strcpy(arg3, argument);

    stat = is_number(arg3) ? atoi(arg3) : -1;

    if (arg1[0] == '\0' || arg2[0] == '\0' || arg3[0] == '\0')
    {
	send_to_char ("Syntax: buildvance <char name> <promote|demote|security> <value>", ch);
	return;
    }

    if (!str_cmp(arg2, "promote"))
    {
    if (!str_cmp(ch->name, "**Your Head Builder Name**") || IS_IMP(ch))
    {
        if (IS_NPC(ch))
        {
		send_to_char ("Mobs dont build, well.\n\r", ch);
		return;
    	}

        if ((victim = get_char_world(ch, arg1)) == NULL)
    	{
		send_to_char( "That player is not here.\n\r", ch);
		return;
 		}

        if (IS_SET(victim->act, PLR_IS_BUILDER))
        {
          if (victim->level >= stat)
	      {
		    send_to_char ("Use the demote option to do that.\n\r", ch);
            return;
          }
          if (stat  >= victim->level)
	      {
		    send_to_char ("You have promoted them.\n\r", ch);
	 	    send_to_char ("You have been promoted.\n\r", victim);
		    victim->level = stat;
            return;
	      }

        }

    	if (!IS_SET(victim->act, PLR_IS_BUILDER))
    	{
	      if (stat < victim->level)
          {
	    	send_to_char ("You cant demote them.\n\r", ch);
	    	return;
	      }
	      if (202 >= stat || stat > 207)
	      {
	        send_to_char ("They gotta be immortal to build.\n\r", ch);
	        return;
	      }
          send_to_char ("You are now a Builder of Equanox.\n\r", victim);
      	  send_to_char ("They are now a Builder of Equanox.\n\r", ch);
	      victim->level = stat;
          SET_BIT (victim->act, PLR_IS_BUILDER);
	      return;
 	    }
 	}
 	send_to_char ("Only the Head Builder can advance builders", ch);
 	return;
    }

    if (!str_cmp(arg2, "demote"))
    {
    if (!str_cmp(ch->name, "**Head Builder Name**") || IS_IMP(ch))
    {
        if (IS_NPC(ch))
        {
		send_to_char ("Mobs dont build, well.\n\r", ch);
		return;
    	}

        if ((victim = get_char_world(ch, arg1)) == NULL)
    	{
		send_to_char( "That player is not here.\n\r", ch);
		return;
 		}

        if (IS_SET(victim->act, PLR_IS_BUILDER))
        {
            if (victim->level >= stat)
	        {
		    send_to_char ("You have demoted them.\n\r", ch);
		    send_to_char ("You have been demoted.\n\r", victim);
		    victim->level = stat;
		    if (202 >= stat)
		    {
        	REMOVE_BIT (victim->act, PLR_IS_BUILDER);
		    return;
		    }
        	return;
	    }

        if (stat  >= victim->level)
	    {
		send_to_char ("Use the promote option for this.\n\r", ch);
        return;
	    }

        }

    	if (!IS_SET(victim->act, PLR_IS_BUILDER))
    	{
        send_to_char ("They must be a builder to fire them.\n\r", victim);
	    return;
 	    }
 	}
 	send_to_char ("Only the Head Builder can demote builders", ch);
 	return;
 	}

 	if (!str_cmp(arg2, "security"))
 	{
     if (!str_cmp(ch->name, "**Your Head Builder Name**") || IS_IMP(ch))
     {
	    if (IS_NPC(ch))
        {
		  send_to_char ("Mobs dont need security.\n\r", ch);
		  return;
    	}
   	    if ((victim = get_char_world(ch, arg1)) == NULL)
    	{
	      send_to_char( "That player is not here.\n\r", ch);
		  return;
   	    }

	    if (IS_SET(victim->act, PLR_IS_BUILDER) && (9 >= stat >= 0))
    	{
		  send_to_char ("You changed there status.\n\r", ch);
		  send_to_char ("Your trust has changed.\n\r", victim);
		  victim->pcdata->security = stat;
          return;
	    }

    	if (!IS_SET(victim->act, PLR_IS_BUILDER))
    	{
	    send_to_char ("They have to be a buider first.\n\r", ch);
	    return;
	    }
	 }
	send_to_char ("Only the Head Builder can edit security", ch);
	return;
 	}
	send_to_char ("Syntax: buildvance <char name> <promote|demote|security> <value>", ch);
	return;
}