Beispiel #1
0
void game_reset_gamedata(GameData* game)
{
  game->current = 0;
  game->magic = SAVE_MAGIC;
  game->version = 0;

  item_shuffleTypes((int*)game->charmTypes, CHARM_MAX);
  item_shuffleTypes((int*)game->conchTypes, CONCH_MAX);

  int i;
  for(i=0; i<MAX_FATHOMS; i++)
  {
    int j;
    game->fathoms[i] = game_null_fathomdata();
    feature_process(game, &game->fathoms[i], i);
    int threat = 7+i*4;
    if(i==MAX_FATHOMS-1)
      threat *= 2;
    while(threat > 0)
    {
      int type = ET_MAX_ENEMY;
      while(type >= ET_MAX_ENEMY)
      {
        type = 0;
        for(j=0; j<(i*2)/3+2; j++)
          type += sys_randint(2);
      }
      Entity e = spawn_entity(type);
      if(e.flags & EF_TOOLED)
      {
        Item i = spawn_item(game, sys_randint(IT_MAX-1));
        i.active = true;
        if(i.type == IT_CHARM)
          i.worn = true;
        if(i.type != IT_CONCH || i.conchSubtype != CONCH_DEATH) // death isn't fair
          e.inventory[0] = i;
      }
      game_spawn(&game->fathoms[i], e);
      threat -= type+1;
    }    
    for(j=0; j<(MAX_FATHOMS-i)/4+4; j++)
      game_spawn(&game->fathoms[i], spawn_entity(ET_BUBBLE));
    int numSpawns;
    if(sys_randint(3)==0)
      game_place(&game->fathoms[i], spawn_item(game, IT_CONCH));
    if(sys_randint(5)==0)
      game_place(&game->fathoms[i], spawn_item(game, IT_CHARM));
    numSpawns = (i == MAX_FATHOMS-1) ? 5 : 0;
    for(j=0; j<numSpawns; j++)
      game_place(&game->fathoms[i], spawn_item(game, IT_DOUBLOON));
  }
  game_spawn(&game->fathoms[0], spawn_entity(ET_SCUBA));    

}
Beispiel #2
0
/*Fonction generation_level
*Initialise la map, genere les pieces, fait spawn les items, affiche la matrice de jeu
*Tout cela pour un niveau donne
*Permet l'affichage de la matrice de jeu avec une difficulte differente
*/
void generation_level(t_case matrice[N][M], int level){
	//declaration
	int nb_piece;

	//traitement
	init_matrice(matrice);
	nb_piece=generer_matrice_tot(matrice,level);
	spawn_item(matrice,nb_piece,level);
	init_carac_mob(matrice);
	afficher_ecran(matrice,level);
}
Beispiel #3
0
void init_game()
{
    WINDOW* map_win = newwin(24, 80, 0, 0);
    WINDOW* area_win = newwin(6, 10, 0, 80);
    WINDOW* stats_win = newwin(8, 10, 6, 80);
    WINDOW* examine_win = newwin(10, 10, 14, 80);
    WINDOW* hp_win = newwin(1, 90, 24, 0);
    WINDOW* log_win = newwin(10, 90, 25, 0);

    dead = false;

    init_log(log_win);
    init_map(map_win);
    init_items();
    world = calloc(LEVEL_COUNT, sizeof(map*));
    world[0] = load_map("data/maps/farm.map", 78, 22, false, true);
    for(int i = 1; i < 3; ++i)
        world[i] = load_map("data/maps/easy_cave.map", 80 + 10 * (i - 1), 24 + 4 * (i - 1), true, true);
    for(int i = 3; i < 5; ++i)
        world[i] = load_map("data/maps/mid_cave.map", 80 + 10 * (i - 1), 24 + 4 * (i - 1), true, true);
    for(int i = 5; i < 7; ++i)
        world[i] = load_map("data/maps/hard_cave.map", 80 + 15 * (i - 1), 24 + 6 * (i - 1), true, true);
    for(int i =7; i < 9; ++i)
        world[i] = load_map("data/maps/crazy_cave.map", 80 + 18 * (i - 1), 24 + 8 * (i - 1), true, true);
    world[LEVEL_COUNT - 1] = load_map("data/maps/final.map", 78, 22, true, false);
    init_player(map_win, stats_win, hp_win, area_win, examine_win, world[0]);
    int x, y;
    get_random_empty_tile(&x, &y, world[LEVEL_COUNT - 1]);
    spawn_item(x, y, "data/items/cat.item", world[LEVEL_COUNT - 1]);

    get_random_empty_tile(&x, &y, world[0]);
    player_set_position(x, y);
    draw_map(x, y, world[0]);
    add_message(COLOR_DEFAULT, "@ symbol, a brave young farmer, was out for a stroll on his farm when his cat Cuddles ran down into the gaping starcase to the deadly Caves of Consternation! @ symbol had been meaning to patch that up for a while, but hadn't gotten a chance yet. Don't judge.");
    if(ask_question(COLOR_SELECTION, "Will you help @ symbol retrieve his cat, Cuddles?"))
        add_message(COLOR_HP_GOOD, "Excellent! Get to it, then!");
    else {
        add_message(COLOR_HP_CRIT, "Well that was unexpected. Okay then, press q to quit to the main menu.");
        dead = true;
    }
    draw_log();
}
Beispiel #4
0
void _do_fire(GameData* game, Entity* e, int index, Direction direction)
{
  FathomData* fathom = &game->fathoms[game->current];
  Item* item = &e->inventory[index];
  Point vector = directionToPoint(direction);
  Point pos = pointAddPoint(e->pos, vector);
  int distance = 3 + sys_randint(3);
  int i;

  Entity nullEntity = NULL_ENTITY;

  switch(item->conchSubtype)
  {
    case CONCH_BUBBLE:
    {
      int spawnType = sys_randint(ET_MAX_ENEMY);
      for(i=0; i<distance; i++)
      {
        if(sys_randint(4)==0)
          game_spawnAt(fathom, spawn_entity(spawnType), pos);
        else
          game_spawnAt(fathom, spawn_entity(ET_BUBBLE), pos);
        pos = pointAddPoint(pos, vector);
      }
      break;
    }
    case CONCH_DIG:
    {
      Tile nullTile = NULL_TILE;
      for(i=0; i<distance; i++)
      {
        int index = tilemap_indexFromTilePosition(&fathom->tileMap, pos);
        if(index != -1)
          fathom->tileMap.tiles[index] = nullTile;
        pos = pointAddPoint(pos, vector);
      }
      break;
    }
    case CONCH_JUMP:
    {
      pos = pointAddPoint(pos, pointMultiply(vector, distance));
      Point invert = pointInverse(vector);
      for(i=distance-1; i>0; i--)
      {          
        if(game_pointFree(fathom, pos))
        {
          e->pos = pos;
          break;
        }
        pos = pointAddPoint(pos, invert);
      }
      break;
    }
    case CONCH_DEATH:
    {
      if(e->o2 > 4)
        e->o2 = e->o2/4;
      for(i=0; i<distance; i++)
      {
        int index = game_pointEntityIndex(fathom, pos);
        if(index != -1)
          fathom->entities[index] = nullEntity;
        pos = pointAddPoint(pos, vector);          
      }
      break;
    }
    case CONCH_POLYMORPH:
    {
      for(i=0; i<distance; i++)
      {
        int index = game_pointEntityIndex(fathom, pos);
        if(index != -1)
        {
          bool player = fathom->entities[index].player;
          fathom->entities[index] = nullEntity;
          Entity e = spawn_entity(sys_randint(ET_MAX_ENEMY));
          e.player = player;
          game_spawnAt(fathom, e, pos);
        }
        int j;
        for(j=0; j<MAX_ITEMS; j++)
        {
          Item* item = &fathom->items[j];
          if(!item->active)
            continue;
          if(pos.x != item->pos.x || pos.y != item->pos.y)
            continue;
          *item = spawn_item(game, item->type);
          item->pos = pos;
          item->active = true;
        }
        pos = pointAddPoint(pos, vector);
      }
      break;
    }
    case CONCH_MAPPING:
    {
      for(i=0; i<fathom->tileMap.size.x*fathom->tileMap.size.y; i++)
        fathom->tileMap.tiles[i].seen = true;
      break;
    }
    default:
      LOG("Trying to cast invalid conch.");
      break;
  }
  game_addMessage(fathom, e->pos, "%s fired %s %s.", _getName(e->name), item_subtypeDescription(item->subtype), item_typeName(item->type));
  if(sys_randint(5)==0)
  {
    Item nullItem = NULL_ITEM;
    game_addMessage(fathom, e->pos, "the %s %s falls apart.", item_subtypeDescription(item->subtype), item_typeName(item->type));
    *item = nullItem;
  }
}