Exemple #1
0
/* An aggressive mobile wants to attack something.  If they're under the 
 * influence of mind altering PC, then see if their master can talk them out 
 * of it, eye them down, or otherwise intimidate the slave. */
static bool aggressive_mob_on_a_leash(struct char_data *slave, struct char_data *master, struct char_data *attack)
{
  static int snarl_cmd;
  int dieroll;

  if (!master || !AFF_FLAGGED(slave, AFF_CHARM))
    return (FALSE);

  if (!snarl_cmd)
    snarl_cmd = find_command("snarl");

  /* Sit. Down boy! HEEEEeeeel! */
  dieroll = rand_number(1, 20);
  if (dieroll != 1 && (dieroll == 20 || dieroll > 10 - GET_CHA(master) + GET_INT(slave))) {
    if (snarl_cmd > 0 && attack && !rand_number(0, 3)) {
      char victbuf[MAX_NAME_LENGTH + 1];

      strncpy(victbuf, GET_NAME(attack), sizeof(victbuf));	/* strncpy: OK */
      victbuf[sizeof(victbuf) - 1] = '\0';

      do_action(slave, victbuf, snarl_cmd, 0);
    }

    /* Success! But for how long? Hehe. */
    return (TRUE);
  }

  /* So sorry, now you're a player killer... Tsk tsk. */
  return (FALSE);
}
int main() {
  unsigned startdim = 1000, dist = 500, count = 2, end, start;
  double time;
  for(unsigned t=0;t<count;t++) {
    unsigned dim = startdim + t*dist; 
    Matrix2D<value_type> A(dim,dim),test(dim,1);
    Vector<value_type> b(dim), x(dim);
    
    for(unsigned i=0;i<dim;i++) {
      for(unsigned j=0;j<dim;j++) {
	A[i][j] = rand_number();
      }
      b[i] = rand_number();
    }
    start = clock();
    x = lin_solve_lu(A,b);
    end = clock();
    
    test = A*x;
//     std::cout << "b=\n" << b << "test=\n" << test;
    value_type sum = 0.0, max = 0.0;
    for(unsigned i=0;i<dim;i++) {
      sum += std::abs(test[i][0]-b[i]);
      if(std::abs(test[i][0]-b[i]) > max) max = std::abs(test[i][0]-b[i]);
    }
    
    std::cout << startdim+t*dist << "	" << (double)(end-start)/CLOCKS_PER_SEC << "	" << sum << "	" << max <<"\n";
  }
  return 0;
}
Exemple #3
0
/* This function controls the change to maxmove, maxmana, and maxhp for each
 * class every time they gain a level. */
void advance_level(struct char_data *ch)
{
  int add_hp, add_mana = 0, add_move = 0, i;

  add_hp = con_app[GET_CON(ch)].hitp;

  switch (GET_CLASS(ch)) {

  case CLASS_ADEPT:
    add_hp += rand_number(3, 8);
    add_mana = rand_number(GET_LEVEL(ch), (int)(1.5 * GET_LEVEL(ch)));
    add_mana = MIN(add_mana, 10);
    add_move = rand_number(0, 2);
    break;

  case CLASS_MEDIC:
    add_hp += rand_number(5, 10);
    add_mana = rand_number(GET_LEVEL(ch), (int)(1.5 * GET_LEVEL(ch)));
    add_mana = MIN(add_mana, 10);
    add_move = rand_number(0, 2);
    break;

  case CLASS_BANDIT:
    add_hp += rand_number(7, 13);
    add_mana = 0;
    add_move = rand_number(1, 3);
    break;

  case CLASS_SOLDIER:
    add_hp += rand_number(10, 15);
    add_mana = 0;
    add_move = rand_number(1, 3);
    break;
  }

  ch->points.max_hit += MAX(1, add_hp);
  ch->points.max_move += MAX(1, add_move);

  if (GET_LEVEL(ch) > 1)
    ch->points.max_mana += add_mana;

  if (IS_ADEPT(ch) || IS_MEDIC(ch))
    GET_PRACTICES(ch) += MAX(2, wis_app[GET_WIS(ch)].bonus);
  else
    GET_PRACTICES(ch) += MIN(2, MAX(1, wis_app[GET_WIS(ch)].bonus));

  if (GET_LEVEL(ch) >= LVL_IMMORT) {
    for (i = 0; i < 3; i++)
      GET_COND(ch, i) = (char) -1;
    SET_BIT_AR(PRF_FLAGS(ch), PRF_HOLYLIGHT);
  }

  snoop_check(ch);
  save_char(ch);
}
Exemple #4
0
static int do_random_write( int my_chunk_start, int my_chunk_end, int write_size ) 
{
    unsigned char *from;
    int to;

    from = &memory_data[ rand_number( MEMORY_CHUNK_SIZE - write_size ) ][ rand_number( N_MEMORY_CHUNKS ) ];
    to = rand_number( FILE_SIZE - write_size );

    return write_mirrored( to, to + my_chunk_start,
                            from, from + my_chunk_start,
                            write_size, my_chunk_end - my_chunk_start );                  
}
Exemple #5
0
/* Function: get_victim. Returns a pointer to a randomly chosen character in 
 * the same room, fighting someone in the castle staff. Used by BANZAII-ing 
 * characters and King Welmar... */
struct char_data *get_victim(struct char_data *chAtChar)
{
  struct char_data *ch;
  int iNum_bad_guys = 0, iVictim;

  for (ch = world[IN_ROOM(chAtChar)].people; ch; ch = ch->next_in_room)
    if (FIGHTING(ch) && member_of_staff(FIGHTING(ch)))
      iNum_bad_guys++;

  if (!iNum_bad_guys)
    return (NULL);

  iVictim = rand_number(0, iNum_bad_guys);	/* How nice, we give them a chance */
  if (!iVictim)
    return (NULL);

  iNum_bad_guys = 0;

  for (ch = world[IN_ROOM(chAtChar)].people; ch; ch = ch->next_in_room) {
    if (FIGHTING(ch) == NULL)
      continue;

    if (!member_of_staff(FIGHTING(ch)))
      continue;

    if (++iNum_bad_guys != iVictim)
      continue;

    return (ch);
  }

  return (NULL);
}
int door_mtrigger(char_data *actor, int subcmd, int dir) {
  trig_data *t;
  char_data *ch;
  char buf[MAX_INPUT_LENGTH];

  for (ch = world[IN_ROOM(actor)].people; ch; ch = ch->next_in_room) {
    if (!SCRIPT_CHECK(ch, MTRIG_DOOR) ||
            !AWAKE(ch) || FIGHTING(ch) || (ch == actor) ||
            AFF_FLAGGED(ch, AFF_CHARM))
      continue;

    for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
      if (IS_SET(GET_TRIG_TYPE(t), MTRIG_DOOR) && CAN_SEE(ch, actor) &&
              !GET_TRIG_DEPTH(t) && (rand_number(1, 100) <= GET_TRIG_NARG(t))) {
        add_var(&GET_TRIG_VARS(t), "cmd", cmd_door[subcmd], 0);
        if (dir >= 0 && dir < DIR_COUNT)
          add_var(&GET_TRIG_VARS(t), "direction", dirs[dir], 0);
        else
          add_var(&GET_TRIG_VARS(t), "direction", "none", 0);
        ADD_UID_VAR(buf, t, actor, "actor", 0);
        return script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
      }
    }
  }
  return 1;
}
int main() {
  unsigned startdim = 100, dist = 100, count = 1, end, start;
  double time;
  for(unsigned t=0;t<count;t++) {
    unsigned dim = startdim + t*dist; 
    Matrix2D<value_type> A(dim,dim),test(dim,dim);
    std::vector<Matrix2D<value_type> > lus;
    
    for(unsigned i=0;i<dim;i++) {
      for(unsigned j=0;j<dim;j++) {
	A[i][j] = rand_number();
      }
    }
    start = clock();
    lus = lu_factors(A);
    end = clock();
    
    test = lus[0]*lus[1]*lus[2];
    value_type sum = 0.0, max = 0.0;
    for(unsigned i=0;i<dim;i++) {
      for(unsigned j=0;j<dim;j++) {
	sum += std::abs(test[i][j]-A[i][j]);
	if(std::abs(test[i][j]-A[i][j]) >max) max = std::abs(test[i][j]-A[i][j]);
      }
    }
    
    std::cout << startdim+t*dist << "	" << (double)(end-start)/CLOCKS_PER_SEC << "	" << sum << "	" << max <<"\n";
  }
  return 0;
}
int drop_wtrigger(obj_data *obj, char_data *actor) {
  struct room_data *room;
  trig_data *t;
  char buf[MAX_INPUT_LENGTH];
  int ret_val;

  if (!actor || !SCRIPT_CHECK(&world[IN_ROOM(actor)], WTRIG_DROP))
    return 1;

  room = &world[IN_ROOM(actor)];
  for (t = TRIGGERS(SCRIPT(room)); t; t = t->next)
    if (TRIGGER_CHECK(t, WTRIG_DROP) &&
            (rand_number(1, 100) <= GET_TRIG_NARG(t))) {
      ADD_UID_VAR(buf, t, actor, "actor", 0);
      ADD_UID_VAR(buf, t, obj, "object", 0);
      ret_val = script_driver(&room, t, WLD_TRIGGER, TRIG_NEW);
      if (obj->carried_by != actor)
        return 0;
      else
        return ret_val;
      break;
    }

  return 1;
}
int greet_mtrigger(char_data *actor, int dir) {
  trig_data *t = NULL;
  char_data *ch = NULL;
  char buf[MAX_INPUT_LENGTH] = {'\0'};
  int intermediate = 0, final = TRUE;

  if (!valid_dg_target(actor, DG_ALLOW_GODS))
    return TRUE;

  for (ch = world[IN_ROOM(actor)].people; ch; ch = ch->next_in_room) {
    if (!SCRIPT_CHECK(ch, MTRIG_GREET | MTRIG_GREET_ALL) ||
            !AWAKE(ch) || FIGHTING(ch) || (ch == actor) ||
            AFF_FLAGGED(ch, AFF_CHARM))
      continue;

    for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
      if (((IS_SET(GET_TRIG_TYPE(t), MTRIG_GREET) && CAN_SEE(ch, actor)) ||
              IS_SET(GET_TRIG_TYPE(t), MTRIG_GREET_ALL)) &&
              !GET_TRIG_DEPTH(t) && (rand_number(1, 100) <= GET_TRIG_NARG(t))) {
        if (dir >= 0 && dir < DIR_COUNT)
          add_var(&GET_TRIG_VARS(t), "direction", dirs[rev_dir[dir]], 0);
        else
          add_var(&GET_TRIG_VARS(t), "direction", "none", 0);
        ADD_UID_VAR(buf, t, actor, "actor", 0);
        intermediate = script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
        if (!intermediate) final = FALSE;
        continue;
      }
    }
  }
  return final;
}
Exemple #10
0
int leave_otrigger(room_data *room, char_data *actor, int dir) {
  trig_data *t;
  char buf[MAX_INPUT_LENGTH];
  int temp, final = 1;
  obj_data *obj, *obj_next;

  if (!valid_dg_target(actor, DG_ALLOW_GODS))
    return 1;

  for (obj = room->contents; obj; obj = obj_next) {
    obj_next = obj->next_content;
    if (!SCRIPT_CHECK(obj, OTRIG_LEAVE))
      continue;

    for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) {
      if (TRIGGER_CHECK(t, OTRIG_LEAVE) &&
              (rand_number(1, 100) <= GET_TRIG_NARG(t))) {
        if (dir >= 0 && dir < DIR_COUNT)
          add_var(&GET_TRIG_VARS(t), "direction", dirs[dir], 0);
        else
          add_var(&GET_TRIG_VARS(t), "direction", "none", 0);
        ADD_UID_VAR(buf, t, actor, "actor", 0);
        temp = script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW);
        if (temp == 0)
          final = 0;
      }
    }
  }

  return final;
}
Exemple #11
0
void write_screen(char **tela, int score_global) {          //Printa a tela no terminal do usuario, interface gráfica.
    int i, j;
    clear();

    init_pair(11,COLOR_WHITE, COLOR_BLUE);
    init_pair(12,COLOR_WHITE, COLOR_MAGENTA);
    init_pair(13,COLOR_WHITE, COLOR_YELLOW);
    init_pair(14,COLOR_WHITE, COLOR_GREEN);

    init_pair(4,COLOR_BLACK, COLOR_BLACK);
    init_pair(5,COLOR_RED, COLOR_RED);
    for(i = 0; i < LINHAS; i++)
        for(j = 0; j < COLUNAS; j++) {
            if(tela[i][j] == '.')
		attron(COLOR_PAIR(rand_number(11, 14)));
            if(tela[i][j] == '#' || tela[i][j] == '@' || tela[i][j] == 'S')
                attron(COLOR_PAIR(4));
            if(tela[i][j] == 'X')
                attron(COLOR_PAIR(5));
            mvprintw(i, j,"%c", tela[i][j]);
        }
    attron(COLOR_PAIR(11));
    mvprintw(LINHAS, 0, "SCORE: %d                                                                       ", score_global/2);
    refresh();
}
Exemple #12
0
int cast_wtrigger(char_data *actor, char_data *vict, obj_data *obj, int spellnum) {
  room_data *room;
  trig_data *t;
  char buf[MAX_INPUT_LENGTH];

  if (!actor || !SCRIPT_CHECK(&world[IN_ROOM(actor)], WTRIG_CAST))
    return 1;

  room = &world[IN_ROOM(actor)];
  for (t = TRIGGERS(SCRIPT(room)); t; t = t->next) {
    if (TRIGGER_CHECK(t, WTRIG_CAST) &&
            (rand_number(1, 100) <= GET_TRIG_NARG(t))) {

      ADD_UID_VAR(buf, t, actor, "actor", 0);
      if (vict)
        ADD_UID_VAR(buf, t, vict, "victim", 0);
      if (obj)
        ADD_UID_VAR(buf, t, obj, "object", 0);
      sprintf(buf, "%d", spellnum);
      add_var(&GET_TRIG_VARS(t), "spell", buf, 0);
      add_var(&GET_TRIG_VARS(t), "spellname", skill_name(spellnum), 0);
      return script_driver(&room, t, WLD_TRIGGER, TRIG_NEW);
    }
  }

  return 1;
}
Exemple #13
0
/* Fry_victim. Finds a suitabe victim, and cast some _NASTY_ spell on him. Used 
 * by King Welmar. */
void fry_victim(struct char_data *ch)
{
  struct char_data *tch;

  if (ch->points.mana < 10)
    return;

  /* Find someone suitable to fry ! */
  if (!(tch = get_victim(ch)))
    return;

  switch (rand_number(0, 8)) {
  case 1:
  case 2:
  case 3:
    send_to_char(ch, "You raise your hand in a dramatical gesture.\r\n");
    act("$n raises $s hand in a dramatical gesture.", 1, ch, 0, 0, TO_ROOM);
    cast_spell(ch, tch, 0, SPELL_COLOR_SPRAY);
    break;
  case 4:
  case 5:
    send_to_char(ch, "You concentrate and mumble to yourself.\r\n");
    act("$n concentrates, and mumbles to $mself.", 1, ch, 0, 0, TO_ROOM);
    cast_spell(ch, tch, 0, SPELL_HARM);
    break;
  case 6:
  case 7:
    act("You look deeply into the eyes of $N.", 1, ch, 0, tch, TO_CHAR);
    act("$n looks deeply into the eyes of $N.", 1, ch, 0, tch, TO_NOTVICT);
    act("You see an ill-boding flame in the eye of $n.", 1, ch, 0, tch, TO_VICT);
    cast_spell(ch, tch, 0, SPELL_FIREBALL);
    break;
  default:
    if (!rand_number(0, 1))
      cast_spell(ch, ch, 0, SPELL_HEAL);
    break;
  }

  ch->points.mana -= 10;

  return;
}
Exemple #14
0
struct obj_data *create_money(int amount)
{
  struct obj_data *obj;
  struct extra_descr_data *new_descr;
  char buf[200];
  int y;

  if (amount <= 0) {
    log("SYSERR: Try to create negative or 0 money. (%d)", amount);
    return (NULL);
  }
  obj = create_obj();
  CREATE(new_descr, struct extra_descr_data, 1);

  if (amount == 1) {
    obj->name = strdup("coin gold");
    obj->short_description = strdup("a gold coin");
    obj->description = strdup("One miserable gold coin is lying here.");
    new_descr->keyword = strdup("coin gold");
    new_descr->description = strdup("It's just one miserable little gold coin.");
  } else {
    obj->name = strdup("coins gold");
    obj->short_description = strdup(money_desc(amount));
    snprintf(buf, sizeof(buf), "%s is lying here.", money_desc(amount));
    obj->description = strdup(CAP(buf));

    new_descr->keyword = strdup("coins gold");
    if (amount < 10)
      snprintf(buf, sizeof(buf), "There are %d coins.", amount);
    else if (amount < 100)
      snprintf(buf, sizeof(buf), "There are about %d coins.", 10 * (amount / 10));
    else if (amount < 1000)
      snprintf(buf, sizeof(buf), "It looks to be about %d coins.", 100 * (amount / 100));
    else if (amount < 100000)
      snprintf(buf, sizeof(buf), "You guess there are, maybe, %d coins.",
	      1000 * ((amount / 1000) + rand_number(0, (amount / 1000))));
    else
      strcpy(buf, "There are a LOT of coins.");	/* strcpy: OK (is < 200) */
    new_descr->description = strdup(buf);
  }

  new_descr->next = NULL;
  obj->ex_description = new_descr;

  GET_OBJ_TYPE(obj) = ITEM_MONEY;
  for(y = 0; y < TW_ARRAY_MAX; y++)
    obj->obj_flags.wear_flags[y] = 0;
  SET_BIT_AR(GET_OBJ_WEAR(obj), ITEM_WEAR_TAKE);
  GET_OBJ_VAL(obj, 0) = amount;
  GET_OBJ_COST(obj) = amount;
  obj->item_number = NOTHING;

  return (obj);
}
Exemple #15
0
static int test_float(void)
{
	int i;
	avro_schema_t schema = avro_schema_double();
	for (i = 0; i < 100; i++) {
		avro_datum_t datum = avro_double(rand_number(-1.0E10, 1.0E10));
		write_read_check(schema, NULL, datum, "float");
		avro_datum_decref(datum);
	}
	avro_schema_decref(schema);
	return 0;
}
Exemple #16
0
static void generate_memory_data(void)
{
    int i_chunk, i_byte;

    for ( i_chunk = 0; i_chunk < N_MEMORY_CHUNKS; i_chunk++ ) {
        printf( "Generating random data chunk #%d...\n", i_chunk + 1 );
        for ( i_byte = 0; i_byte < MEMORY_CHUNK_SIZE; i_byte++ )
            memory_data[ i_byte ][ i_chunk ] = rand_number( BYTE_MAX );
    }

    printf( "Random data generation complete!\n\n" );
}
Exemple #17
0
//
// run the reset data
bool resetRun(RESET_DATA *reset, void *initiator, int initiator_type,
	      const char *locale) {
  //
  // possible problem: how do we know what to return if we're
  // running the reset data multiple times?
  bool ret_val = FALSE;

  // go through for however many times we need to
  int i;
  for(i = 0; i < resetGetTimes(reset); i++) {
    // If we don't make our reset chance, continue onto the next check
    if(rand_number(1, 100) > resetGetChance(reset))
      continue;
    switch(resetGetType(reset)) {
    case RESET_LOAD_OBJECT:
      ret_val = try_reset_load_object(reset, initiator, initiator_type, locale);
      break;
    case RESET_LOAD_MOBILE:
      ret_val = try_reset_load_mobile(reset, initiator, initiator_type, locale);
      break;
    case RESET_FIND_OBJECT:
      ret_val = try_reset_find_object(reset, initiator, initiator_type, locale);
      break;
    case RESET_FIND_MOBILE:
      ret_val = try_reset_find_mobile(reset, initiator, initiator_type, locale);
      break;
    case RESET_PURGE_OBJECT:
      ret_val = try_reset_purge_object(reset, initiator, initiator_type,locale);
      break;
    case RESET_PURGE_MOBILE:
      ret_val = try_reset_purge_mobile(reset, initiator, initiator_type,locale);
      break;
    case RESET_OPEN:
      ret_val = try_reset_open(reset, initiator, initiator_type);
      break;
    case RESET_CLOSE:
      ret_val = try_reset_close(reset, initiator, initiator_type);
      break;
    case RESET_LOCK:
      ret_val = try_reset_lock(reset, initiator, initiator_type);
      break;
    case RESET_POSITION:
      ret_val = try_reset_position(reset, initiator, initiator_type);
      break;
    case RESET_SCRIPT:
      ret_val = try_reset_script(reset, initiator, initiator_type, locale);
      break;
    default:
      return FALSE;
    }
  }
  return ret_val;
}
Exemple #18
0
void greet_memory_mtrigger(char_data *actor) {
  trig_data *t;
  char_data *ch;
  struct script_memory *mem;
  char buf[MAX_INPUT_LENGTH];
  int command_performed = 0;

  if (!valid_dg_target(actor, DG_ALLOW_GODS))
    return;

  for (ch = world[IN_ROOM(actor)].people; ch; ch = ch->next_in_room) {
    if (!SCRIPT_MEM(ch) || !AWAKE(ch) || FIGHTING(ch) || (ch == actor) ||
            AFF_FLAGGED(ch, AFF_CHARM))
      continue;
    /* find memory line with command only */
    for (mem = SCRIPT_MEM(ch); mem && SCRIPT_MEM(ch); mem = mem->next) {
      if (GET_ID(actor) != mem->id) continue;
      if (mem->cmd) {
        command_interpreter(ch, mem->cmd); /* no script */
        command_performed = 1;
        break;
      }
      /* if a command was not performed execute the memory script */
      if (mem && !command_performed) {
        for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
          if (IS_SET(GET_TRIG_TYPE(t), MTRIG_MEMORY) &&
                  CAN_SEE(ch, actor) &&
                  !GET_TRIG_DEPTH(t) &&
                  rand_number(1, 100) <= GET_TRIG_NARG(t)) {
            ADD_UID_VAR(buf, t, actor, "actor", 0);
            script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
            break;
          }
        }
      }
      /* delete the memory */
      if (mem) {
        if (SCRIPT_MEM(ch) == mem) {
          SCRIPT_MEM(ch) = mem->next;
        } else {
          struct script_memory *prev;
          prev = SCRIPT_MEM(ch);
          while (prev->next != mem) prev = prev->next;
          prev->next = mem->next;
        }
        if (mem->cmd) free(mem->cmd);
        free(mem);
      }
    }
  }
}
Exemple #19
0
/* Object triggers. */
void random_otrigger(obj_data *obj) {
  trig_data *t;

  if (!SCRIPT_CHECK(obj, OTRIG_RANDOM))
    return;

  for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) {
    if (TRIGGER_CHECK(t, OTRIG_RANDOM) &&
            (rand_number(1, 100) <= GET_TRIG_NARG(t))) {
      script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW);
      break;
    }
  }
}
Exemple #20
0
static void npc_steal(struct char_data *ch, struct char_data *victim)
{
  int gold;

  if (IS_NPC(victim))
    return;
  if (GET_LEVEL(victim) >= LVL_IMMORT)
    return;
  if (!CAN_SEE(ch, victim))
    return;

  if (AWAKE(victim) && (rand_number(0, GET_LEVEL(ch)) == 0)) {
    act("You discover that $n has $s hands in your wallet.", FALSE, ch, 0, victim, TO_VICT);
    act("$n tries to steal gold from $N.", TRUE, ch, 0, victim, TO_NOTVICT);
  } else {
    /* Steal some gold coins */
    gold = (GET_GOLD(victim) * rand_number(1, 10)) / 100;
    if (gold > 0) {
      increase_gold(ch, gold);
	  decrease_gold(victim, gold);
    }
  }
}
Exemple #21
0
void random_wtrigger(struct room_data *room) {
  trig_data *t;

  if (!SCRIPT_CHECK(room, WTRIG_RANDOM))
    return;

  for (t = TRIGGERS(SCRIPT(room)); t; t = t->next) {
    if (TRIGGER_CHECK(t, WTRIG_RANDOM) &&
            (rand_number(1, 100) <= GET_TRIG_NARG(t))) {
      script_driver(&room, t, WLD_TRIGGER, TRIG_NEW);
      break;
    }
  }
}
Exemple #22
0
int entry_mtrigger(char_data *ch) {
  trig_data *t;

  if (!SCRIPT_CHECK(ch, MTRIG_ENTRY) || AFF_FLAGGED(ch, AFF_CHARM))
    return 1;

  for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
    if (TRIGGER_CHECK(t, MTRIG_ENTRY) && (rand_number(1, 100) <= GET_TRIG_NARG(t))) {
      return script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
      break;
    }
  }

  return 1;
}
Exemple #23
0
/*Mob triggers. */
void random_mtrigger(char_data *ch) {
  trig_data *t;

  /* This trigger is only called if a char is in the zone without nohassle. */
  if (!SCRIPT_CHECK(ch, MTRIG_RANDOM) || AFF_FLAGGED(ch, AFF_CHARM))
    return;

  for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
    if (TRIGGER_CHECK(t, MTRIG_RANDOM) &&
            (rand_number(1, 100) <= GET_TRIG_NARG(t))) {
      script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
      break;
    }
  }
}
Exemple #24
0
/*
 *  mag_materials:
 *  Checks for up to 3 vnums (spell reagents) in the player's inventory.
 *
 * No spells implemented in Circle use mag_materials, but you can use
 * it to implement your own spells which require ingredients (i.e., some
 * heal spell which requires a rare herb or some such.)
 */
int mag_materials(struct char_data *ch, int item0, int item1, int item2,
		      int extract, int verbose)
{
  struct obj_data *tobj;
  struct obj_data *obj0 = NULL, *obj1 = NULL, *obj2 = NULL;

  for (tobj = ch->carrying; tobj; tobj = tobj->next_content) {
    if ((item0 > 0) && (GET_OBJ_VNUM(tobj) == item0)) {
      obj0 = tobj;
      item0 = -1;
    } else if ((item1 > 0) && (GET_OBJ_VNUM(tobj) == item1)) {
      obj1 = tobj;
      item1 = -1;
    } else if ((item2 > 0) && (GET_OBJ_VNUM(tobj) == item2)) {
      obj2 = tobj;
      item2 = -1;
    }
  }
  if ((item0 > 0) || (item1 > 0) || (item2 > 0)) {
    if (verbose) {
      switch (rand_number(0, 2)) {
      case 0:
	send_to_char(ch, "A wart sprouts on your nose.\r\n");
	break;
      case 1:
	send_to_char(ch, "Your hair falls out in clumps.\r\n");
	break;
      case 2:
	send_to_char(ch, "A huge corn develops on your big toe.\r\n");
	break;
      }
    }
    return (FALSE);
  }
  if (extract) {
    if (item0 < 0)
      extract_obj(obj0);
    if (item1 < 0)
      extract_obj(obj1);
    if (item2 < 0)
      extract_obj(obj2);
  }
  if (verbose) {
    send_to_char(ch, "A puff of smoke rises from your pack.\r\n");
    act("A puff of smoke rises from $n's pack.", TRUE, ch, NULL, NULL, TO_ROOM);
  }
  return (TRUE);
}
Exemple #25
0
void write_col(char **tela) {       //Printa as colunas na tela.
    int rand_col;
    int i, j;
    rand_col = rand_number(10, 35);
    for(i = rand_col; i <= LINHAS - 2; i++)
        for(j = 1; j <= SIZE_COL; j++) {
            if(j == 1 && i == rand_col)
                tela[i][COLUNAS - j] = 'S';
            else
                tela[i][COLUNAS - j] = '#';
        }
    for(i = 1; i <= rand_col - SPACEMID_COL; i++)
        for(j = 0; j<= SIZE_COL; j++) {
            tela[i][COLUNAS - j] = '#';
        }
}
static void shuffle_lst (OMX_S32 *ap_array, OMX_S32 n)
{
  OMX_S32 i = 0;
  OMX_S32 j = 0;
  OMX_S32 tmp = 0;

  assert (NULL != ap_array);

  for (i = n - 1; i > 0; --i)
    {
      j = rand_number (i + 1);
      tmp = ap_array[j];
      ap_array[j] = ap_array[i];
      ap_array[i] = tmp;
    }
}
Exemple #27
0
static int test_double(void)
{
    int i;
    avro_schema_t schema = avro_schema_double();
    for (i = 0; i < 100; i++) {
        avro_datum_t datum = avro_double(rand_number(-1.0E10, 1.0E10));
        write_read_check(schema, datum, NULL, NULL, "double");
        avro_datum_decref(datum);
    }

    avro_datum_t  datum = avro_double(2000.0);
    test_json(datum, "2000.0");
    avro_datum_decref(datum);

    avro_schema_decref(schema);
    return 0;
}
Exemple #28
0
int login_wtrigger(struct room_data *room, char_data *actor) {
  trig_data *t;
  char buf[MAX_INPUT_LENGTH];

  if (!SCRIPT_CHECK(room, WTRIG_LOGIN))
    return 1;

  for (t = TRIGGERS(SCRIPT(room)); t; t = t->next) {
    if (TRIGGER_CHECK(t, WTRIG_LOGIN) &&
            (rand_number(1, 100) <= GET_TRIG_NARG(t))) {
      ADD_UID_VAR(buf, t, actor, "actor", 0);
      return script_driver(&room, t, WLD_TRIGGER, TRIG_NEW);
    }
  }

  return 1;
}
Exemple #29
0
static int getBestOffensiveSkill(struct char_data *mob) {
  int i, skillNum = -1, skillCount = 0, offensiveSkills[NUM_SPELLS];

  /* get the offensive spells */
  for(i = 0; i < NUM_MOB_SKILLS; i++) {
    /* spells within a level range based on mob's level */
    if(spell_info[spec_mob_skill_info[i].skill_number].min_level[(int)GET_CLASS(mob)] <= GET_LEVEL(mob)) {
      offensiveSkills[skillCount++] = i;
    }
  }

  if(skillCount > 0) {
    skillNum = offensiveSkills[rand_number(0, skillCount-1)];
  }

  return skillNum;
}
Exemple #30
0
int death_mtrigger(char_data *ch, char_data *actor) {
  trig_data *t;
  char buf[MAX_INPUT_LENGTH];

  if (!SCRIPT_CHECK(ch, MTRIG_DEATH) || AFF_FLAGGED(ch, AFF_CHARM))
    return 1;

  for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
    if (TRIGGER_CHECK(t, MTRIG_DEATH) &&
            (rand_number(1, 100) <= GET_TRIG_NARG(t))) {
      if (actor)
        ADD_UID_VAR(buf, t, actor, "actor", 0);
      return script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
    }
  }

  return 1;
}