/**
* This is the command interpreter used by vehicless, called by script_driver.
*
* @param vehicle_data *veh The vehicle that's acting.
* @param char *argument The typed-in arg.
*/
void vehicle_command_interpreter(vehicle_data *veh, char *argument) {
	char line[MAX_INPUT_LENGTH], arg[MAX_INPUT_LENGTH];
	int cmd, length;
	
	skip_spaces(&argument);
	
	/* just drop to next line for hitting CR */
	if (!*argument) {
		return;
	}
	
	half_chop(argument, arg, line);
	
	/* find the command */
	for (length = strlen(arg), cmd = 0; *veh_cmd_info[cmd].command != '\n'; cmd++) {
		if (!strn_cmp(veh_cmd_info[cmd].command, arg, length)) {
			break;
		}
	}

	if (*veh_cmd_info[cmd].command == '\n') {
		veh_log(veh, "Unknown vehicle cmd: '%s'", argument);
	}
	else {
		((*veh_cmd_info[cmd].command_pointer) (veh, line, cmd, veh_cmd_info[cmd].subcmd));
	}
}
Exemple #2
0
void
perform_net_write(struct descriptor_data *d, char *arg)
{
    char targ[MAX_INPUT_LENGTH];
    char msg[MAX_INPUT_LENGTH];
    struct creature *vict;

    half_chop(arg, targ, msg);

    if (!*targ || !*msg) {
        d_printf(d, "Usage: write <user> <message>\r\n");
        return;
    }

    vict = get_player_vis(d->creature, targ, 1);
    if (!vict)
        vict = get_player_vis(d->creature, targ, 0);

    if (!vict || STATE(vict->desc) != CXN_NETWORK) {
        d_printf(d, "Error: user not logged in\r\n");
        return;
    }

    d_printf(d, "Message sent to %s: %s\r\n", GET_NAME(vict), msg);
    d_printf(vict->desc, "Message from %s: %s\r\n", GET_NAME(d->creature), msg);
}
Exemple #3
0
void do_tell (struct char_data *ch, char *argument, int cmd)
{
  struct char_data *vict;
  char name[100], message[MAX_STRING_LENGTH], buf[MAX_STRING_LENGTH];

  if (IS_SET (ch->specials.act, PLR_NOTELL)) {
    send_to_char ("Your message didn't get through!!\n\r", ch);
    return;
  }

  half_chop (argument, name, message);

  if (!*name || !*message)
    send_to_char ("Who do you wish to tell what??\n\r", ch);
  else if (!(vict = get_char_vis (ch, name)))
    send_to_char ("No-one by that name here..\n\r", ch);
  else if (ch == vict)
    send_to_char ("You try to tell yourself something.\n\r", ch);
  else if ((GET_POS (vict) == POSITION_SLEEPING) ||
    IS_SET (vict->specials.act, PLR_NOTELL)) {
    act ("$E can't hear you.", FALSE, ch, 0, vict, TO_CHAR);
  } else {
    sprintf (buf, "%s tells you '%s'\n\r",
      (IS_NPC (ch) ? ch->player.short_descr : GET_NAME (ch)), message);
    send_to_char (buf, vict);
    send_to_char ("Ok.\n\r", ch);
  }
}
Exemple #4
0
void do_ask(struct char_data *ch, char *argument, int cmd)
{
	struct char_data *vict;
	char name[100], message[MAX_STRING_LENGTH],
		buf[MAX_STRING_LENGTH];

	half_chop(argument,name,message);

	if(!*name || !*message)
		send_to_char("Who do you want to ask something.. and what??\n\r", ch);
	else if (!(vict = get_char_room_vis(ch, name)))
		send_to_char("No-one by that name here..\n\r", ch);
	else if (vict == ch)
	{
		act("$n quietly asks $mself a question.",FALSE,ch,0,0,TO_ROOM);
		send_to_char("You think about it for a while...\n\r", ch);
	}
	else
	{
		sprintf(buf,"$n asks you '%s'",message);
		act(buf, FALSE, ch, 0, vict, TO_VICT);
		send_to_char("Ok.\n\r", ch);
		act("$n asks $N a question.",FALSE,ch,0,vict,TO_NOTVICT);
	}
}
Exemple #5
0
void do_whisper(struct char_data *ch, char *argument, int cmd)
{
	struct char_data *vict;
	char name[100], message[MAX_STRING_LENGTH],
		buf[MAX_STRING_LENGTH];

	half_chop(argument,name,message);

	if(!*name || !*message)
		send_to_char("Who do you want to whisper to.. and what??\n\r", ch);
	else if (!(vict = get_char_room_vis(ch, name)))
		send_to_char("No-one by that name here..\n\r", ch);
	else if (vict == ch)
	{
		act("$n whispers quietly to $mself.",FALSE,ch,0,0,TO_ROOM);
		send_to_char(
			"You can't seem to get your mouth close enough to your ear...\n\r",
			 ch);
	}
	else
	{
		sprintf(buf,"$n whispers to you, '%s'",message);
		act(buf, FALSE, ch, 0, vict, TO_VICT);
		send_to_char("Ok.\n\r", ch);
		act("$n whispers something to $N.", FALSE, ch, 0, vict, TO_NOTVICT);
	}
}
/*
*  This is the command interpreter used by objects, called by script_driver.
*/
void obj_command_interpreter(obj_data *obj, char *argument) {
	int cmd, length;
	char line[MAX_INPUT_LENGTH], arg[MAX_INPUT_LENGTH];

	skip_spaces(&argument);

	/* just drop to next line for hitting CR */
	if (!*argument)
		return;

	half_chop(argument, arg, line);

	/* find the command */
	for (length = strlen(arg), cmd = 0; *obj_cmd_info[cmd].command != '\n'; cmd++)
		if (!strn_cmp(obj_cmd_info[cmd].command, arg, length))
			break;

	if (*obj_cmd_info[cmd].command == '\n')
		obj_log(obj, "Unknown object cmd: '%s'", argument);
	else
		((*obj_cmd_info[cmd].command_pointer) (obj, line, cmd, obj_cmd_info[cmd].subcmd));
}
Exemple #7
0
void do_dg_affect(void *go, struct script_data *sc, trig_data *trig,
		  int script_type, char *cmd)
{
  struct char_data *ch = NULL;
  int value=0, duration=0;
  char junk[MAX_INPUT_LENGTH]; /* will be set to "dg_affect" */
  char charname[MAX_INPUT_LENGTH], property[MAX_INPUT_LENGTH];
  char value_p[MAX_INPUT_LENGTH], duration_p[MAX_INPUT_LENGTH];
  int index=0, type=0;
  struct affected_type af;

  
  half_chop(cmd, junk, cmd);
  half_chop(cmd, charname, cmd);
  half_chop(cmd, property, cmd);
  half_chop(cmd, value_p, duration_p);

  /* make sure all parameters are present */
  if (!charname || !*charname || !property || !*property ||
      !value_p || !*value_p || !duration_p || !*duration_p) {
    sprintf(buf2, "Trigger: %s, VNum %d. dg_affect usage: <target> <property> <value> <duration>",
      GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig));
    script_log(buf2);
    return;
  }

  value = atoi(value_p);
  duration = atoi(duration_p);
  if (duration <= 0) {
    sprintf(buf2, "Trigger: %s, VNum %d. dg_affect: need positive duration!",
      GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig));
    script_log(buf2);
    return;
  }

  /* find the property -- first search apply_types */
  index = 0;
  while (str_cmp(apply_types[index], "\n")) {
    if (!str_cmp(apply_types[index], property)) {
      type=APPLY_TYPE;
      break;
    }
    index++;
  }

  if (!type) { /* search affect_types now */
    index = 0;
    while (str_cmp(affected_bits[index], "\n")) {
      if (!str_cmp(affected_bits[index], property)) {
        type=AFFECT_TYPE;
        break;
      }
      index++;
    }
  }

  if (!type) { /* property not found */
    sprintf(buf2, "Trigger: %s, VNum %d. dg_affect: unknown property '%s'!",
      GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig), property);
    script_log(buf2);
    return;
  }


  /* locate the target */
  ch = get_char(charname);
  if (!ch) {
    sprintf(buf2, "Trigger: %s, VNum %d. dg_affect: cannot locate target!",
      GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig));
    script_log(buf2);
    return;
  }

  /* add the affect */
  af.type = 0;
  af.duration = duration;
  af.modifier = value;
  af.location = 0;
  af.bitvector = (1<<type);
  affect_to_char(ch, &af);
}
Exemple #8
0
/* OLC interpreter command; called by do_olc */
void olc_interpreter(void *targ, int mode, char *arg)
{
  int error = 0, command;
  char command_string[MAX_INPUT_LENGTH];
  struct char_data *olc_mob = NULL;
  struct room_data *olc_room = NULL;
  struct obj_data *olc_obj = NULL;

  half_chop(arg, command_string, arg);
  if ((command = search_block(command_string, olc_commands, FALSE)) < 0) {
    sprintf(buf, "Invalid OLC command '%s'.\r\n", command_string);
    send_to_char(buf, olc_ch);
    return;
  }
  switch (mode) {
  case OLC_ROOM:
    olc_room = (struct room_data *) targ;
    break;
  case OLC_MOB:
    olc_mob = (struct char_data *) targ;
    break;
  case OLC_OBJ:
    olc_obj = (struct obj_data *) targ;
    break;
  default:
    log("SYSERR: Invalid OLC mode %d passed to interp.", mode);
    return;
  }


  switch (command) {
  case OLC_COPY:
    switch (mode) {
    case OLC_ROOM:
      break;
    case OLC_MOB:
      break;
    case OLC_OBJ:
      break;
    default:
      error = 1;
      break;
    }
    break;
  case OLC_NAME:
    switch (mode) {
    case OLC_ROOM:
      olc_string(&(olc_room->name), MAX_ROOM_NAME, arg);
      break;
    case OLC_MOB:
      olc_string(&olc_mob->player.short_descr, MAX_MOB_NAME, arg);
      break;
    case OLC_OBJ:
      olc_string(&olc_obj->short_description, MAX_OBJ_NAME, arg);
      break;
    default:
      error = 1;
      break;
    }
    break;

  case OLC_DESC:
    switch (mode) {
    case OLC_ROOM:
      olc_string(&olc_room->description, MAX_ROOM_DESC, arg);
      break;
    case OLC_MOB:
      olc_string(&olc_mob->player.long_descr, MAX_MOB_DESC, arg);
      break;
    case OLC_OBJ:
      olc_string(&olc_obj->description, MAX_OBJ_DESC, arg);
      break;
    default:
      error = 1;
      break;
    }
    break;

  case OLC_ALIASES:
    switch (mode) {
    case OLC_ROOM:
      break;
    case OLC_MOB:
      break;
    case OLC_OBJ:
      break;
    default:
      error = 1;
      break;
    }

  }
}
Exemple #9
0
void assemblyBootAssemblies( void )
{
    char         szLine[ MAX_STRING_LENGTH ] = { '\0' };
    char         szTag[ MAX_STRING_LENGTH ] = { '\0' };
    char         szType[ MAX_STRING_LENGTH ] = { '\0' };
    int          iExtract = 0;
    int          iInRoom = 0;
    int          iType = 0;
    long         lLineCount = 0;
    long         lPartVnum = NOTHING;
    long         lVnum = NOTHING;
    FILE         *pFile = NULL;

    if( (pFile = fopen( ASSEMBLIES_FILE, "rt" )) == NULL )
    {
        log( "SYSERR: assemblyBootAssemblies(): Couldn't open file '%s' for "
             "reading.", ASSEMBLIES_FILE );
        return;
    }

    while( !feof( pFile ) )
    {
        lLineCount += get_line( pFile, szLine );
        half_chop( szLine, szTag, szLine );

        if( *szTag == '\0' )
            continue;

        if( str_cmp( szTag, "Component" ) == 0 )
        {
            if( sscanf( szLine, "#%ld %d %d", &lPartVnum, &iExtract, &iInRoom ) != 3
              )
            {
                log( "SYSERR: bootAssemblies(): Invalid format in file %s, line %ld: "
                     "szTag=%s, szLine=%s.", ASSEMBLIES_FILE, lLineCount, szTag, szLine );
            }
            else if( !assemblyAddComponent( lVnum, lPartVnum, iExtract, iInRoom ) )
            {
                log( "SYSERR: bootAssemblies(): Could not add component #%ld to "
                     "assembly #%ld.", lPartVnum, lVnum );
            }
        }
        else if( str_cmp( szTag, "Vnum" ) == 0 )
        {
            if( sscanf( szLine, "#%ld %s", &lVnum, szType ) != 2 )
            {
                log( "SYSERR: bootAssemblies(): Invalid format in file %s, "
                     "line %ld.", ASSEMBLIES_FILE, lLineCount );
                lVnum = NOTHING;
            }
            else if( (iType = search_block( szType, AssemblyTypes, TRUE )) < 0 )
            {
                log( "SYSERR: bootAssemblies(): Invalid type '%s' for assembly "
                     "vnum #%ld at line %ld.", szType, lVnum, lLineCount );
                lVnum = NOTHING;
            }
            else if( !assemblyCreate( lVnum, iType ) )
            {
                log( "SYSERR: bootAssemblies(): Could not create assembly for vnum "
                     "#%ld, type %s.", lVnum, szType );
                lVnum = NOTHING;
            }
        }
        else
        {
            log( "SYSERR: Invalid tag '%s' in file %s, line #%ld.", szTag,
                 ASSEMBLIES_FILE, lLineCount );
        }

        *szLine = '\0';
        *szTag = '\0';
    }

    fclose( pFile );
}