예제 #1
0
void
cmd_shift(struct command *c)
{

  if (ilist_len(c->parse) > 1) {
/*
 *  Deleted argument need not be freed, since it's just a
 *  pointer into another string.  It was never allocated
 *  itself.
 */

    ilist_delete((ilist *) & c->parse, 1);
  }

  c->a = c->b;
  c->b = c->c;
  c->c = c->d;
  c->d = c->e;
  c->e = c->f;
  c->f = c->g;
  c->g = c->h;

  if (numargs(c) >= 8)
    c->h = parse_arg(c->who, c->parse[8]);
  else
    c->h = 0;
}
예제 #2
0
int
v_credit(struct command *c)
{
  int target = c->a;
  int amount = c->b;
  int item = c->c;
  int pl;
  extern int gold_times;

  if (amount) {
    if (kind(target) != T_char && kind(target) != T_player) {
      wout(c->who, "%s not a character or player.", c->parse[1]);
      return FALSE;
    }

    if (numargs(c) >= 3 && i_strcmp(c->parse[3], "np") == 0) {
      if (kind(target) != T_player) {
        wout(c->who, "%s not a player.", box_code(target));
        return FALSE;
      }

      add_np(target, amount);
      wout(c->who, "Credited %s %d NP.", box_name(target), amount);
      wout(target, "Received GM credit of %d NP.", amount);
      return TRUE;
    }

    if (item == 0)
      item = 1;

    gen_item(target, item, amount);
    wout(c->who, "Credited %s %s.", box_name(target),
         box_name_qty(item, amount));
    wout(target, "Received CLAIM credit of %s.", box_name_qty(item, amount));
    return TRUE;
  }

  if (kind(target) != T_char) {
    wout(c->who, "%s not a character.", c->parse[1]);
    return FALSE;
  }

  pl = player(target);

  if (times_paid(pl)) {
    wout(c->who, "Already paid faction %s.", box_name(pl));
    return FALSE;
  }

  p_player(pl)->times_paid = TRUE;

  wout(target, "The Times pays %s %s.", box_name(target), gold_s(25));

  gen_item(target, item_gold, 25);
  gold_times += 25;

  return TRUE;
}
예제 #3
0
파일: simple.c 프로젝트: 16Bitt/libcc
void identifier(){
	char* name = getname();

	if(!idexists(name))
		error("Identifier '%s' is undeclared", name);


	if(look == '('){
		if(!isfunction(name))
			error("Cannot call variable '%s'", name);
		
		int len = 0;
		match("(");
		while(look != ')'){
			expression();
			emitln("push eax");
			if(look != ')')
				match(",");
			len++;
		}
		match(")");
		
		if(len != numargs(name))
			error("Call to %s with wrong number of args", name);

		emitln("call %s", getaccessor(name));
	}

	else {
		emitln("xor eax, eax");
		current_type = gettype(name);
		STRSWITCH(current_type)
			STRCASE("char")
				emitln("mov al, byte [%s]", getaccessor(name));
			STRCASE("short")
				emitln("mov ax, word [%s]", getaccessor(name));
			STRDEFAULT
				emitln("mov eax, dword [%s]", getaccessor(name));
		STRSWITCHEND

	}
}
예제 #4
0
int
v_bird_spy(struct command *c)
{
	int targ = c->a;
	int where = subloc(c->who);
	struct exit_view *v;

	if (!has_holy_symbol(c->who)) {
	  wout(c->who, "A holy symbol is required to bird spy.");
	  return FALSE;
	};

	if (!has_piety(c->who, skill_piety(c->use_skill))) {
	  wout(c->who, "You don't have the piety required to use that prayer.");
	  return FALSE;
	};

	if (is_ship(where))
		where = loc(where);

	if (numargs(c) < 1)
	{
		wout(c->who, "Specify what location the bird should spy on.");
		return FALSE;
	}

	if (!is_loc_or_ship(c->a))
	{
		v = parse_exit_dir(c, where, sout("use %d", sk_bird_spy));

		if (v == NULL)
			return FALSE;

		targ = v->destination;
	}

	if (province(targ) != province(c->who))
	{
		struct exit_view **l;
		int i;
		int okay = FALSE;

		l = exits_from_loc(c->who, where);

		for (i = 0; i < ilist_len(l); i++)
			if (l[i]->destination == targ)
				okay = TRUE;

		if (!okay)
		{
			wout(c->who, "The location to be spied upon must be "
				"a sublocation in the same province or a "
				"neighboring location.");
			return FALSE;
		}
	}

	c->d = targ;

	return TRUE;
}
예제 #5
0
/*
 *  Wed Mar  5 12:14:55 1997 -- Scott Turner
 *
 *  Added hooks for npc_breed, which is used by the NPC chars.
 *
 */
int
v_breed(struct command *c)
{
  int i1 = c->a;
  int i2 = c->b;
  int exp;

  if (is_real_npc(c->who)) {
    c->wait += 7;
    return TRUE;
  };

  if (!has_skill(c->who, sk_breed_beasts))
    {
      wout(c->who, "Requires %s.", box_name(sk_breed_beasts));
      return FALSE;
    }
  c->use_skill = sk_breed_beasts;

  if (numargs(c) < 2)
    {
      wout(c->who, "Usage: breed <item> <item>");
      return FALSE;
    }

  if (kind(i1) != T_item)
    {
      wout(c->who, "%s is not an item.", c->parse[1]);
      return FALSE;
    }

  if (kind(i2) != T_item)
    {
      wout(c->who, "%s is not an item.", c->parse[2]);
      return FALSE;
    }

  if (has_item(c->who, i1) < 1)
    {
      wout(c->who, "Don't have any %s.", box_code(i1));
      return FALSE;
    }

  if (has_item(c->who, i2) < 1)
    {
      wout(c->who, "Don't have any %s.", box_code(i2));
      return FALSE;
    }

  if (i1 == i2 && has_item(c->who, i1) < 2)
    {
      wout(c->who, "Don't have two %s.", box_code(i1));
      return FALSE;
    }

  /*
   *  Thu Oct 10 12:15:09 1996 -- Scott Turner
   *
   *  May need a holy symbol & piety.
   *
   */
  if (!normal_union(i1, i2)) {
    if (!has_holy_symbol(c->who)) {
      wout(c->who, "A holy symbol is required for that breeding.");
      return FALSE;
    };

    if (!has_piety(c->who, skill_piety(c->use_skill))) {
      wout(c->who, "You don't have the piety required to use that prayer.");
      return FALSE;
    };
  };

  /* 
   *  Hack to fold experience_use_speedup into this skill
   *  if they use BREED instead of USE xxxx
   */

  c->wait = 7;
  exp = max(has_skill(c->who, sk_breed_beasts) - 1, 0);
  if (exp)
    c->wait--;

  return TRUE;
}