Ejemplo n.º 1
0
bool _do_drop(FathomData* fathom, Entity* e, int index)
{
  Item nullItem = NULL_ITEM;
  Item item = e->inventory[index];
  item.pos = e->pos;
  if(!e->inventory[index].active)
  {
    LOG("Dropping non existent item.");
    return false;
  }
  int empty = -1;
  int i;  
  for(i=0; i<MAX_ITEMS; i++)
  {
    if(!fathom->items[i].active)
    {
      empty = i;
      break;
    }
  }
  if(empty == -1)
  {
    game_addMessage(fathom, e->pos, "%s can't drop %s %s, too cluttered.", _getName(e->name), item_subtypeDescription(item.subtype), item_typeName(item.type));
    return false;
  }
  item.worn = false;
  fathom->items[empty] = item;  
  e->inventory[index] = nullItem;
  game_addMessage(fathom, e->pos, "%s dropped %s %s.", _getName(e->name), item_subtypeDescription(item.subtype), item_typeName(item.type));
  return true;
}
Ejemplo n.º 2
0
bool _do_use(FathomData* fathom, Entity* e, int index)
{
  Item* item = &e->inventory[index];
  if(!item->active)
  {
    LOG("using non existent item");
    return false;
  }
  if(item->type == IT_CHARM)
  {
    item->worn = !item->worn;
    if(item->worn)
      game_addMessage(fathom, e->pos, "%s put on %s %s.", _getName(e->name), item_subtypeDescription(item->subtype), item_typeName(item->type));
    else
      game_addMessage(fathom, e->pos, "%s took off %s %s.", _getName(e->name), item_subtypeDescription(item->subtype), item_typeName(item->type));
    return true;
  }
  if(item->type == IT_CONCH)
  {
    game_addGlobalMessage("point %s %s in which direction?", item_subtypeDescription(item->subtype), item_typeName(item->type));
    midFire = true;
    fireIndex = index;
    return false;
  }
  if(item->type == IT_DOUBLOON)
  {
    game_addGlobalMessage("only valuable on the surface.");
    return true;
  }
  return false;
}
Ejemplo n.º 3
0
void _do_pickup(FathomData* fathom, Entity* e)
{
  Item nullItem = NULL_ITEM;

  int i;
  for(i=0; i<MAX_ITEMS; i++)
  {
    Item* item = &fathom->items[i];
    if(!item->active)
      continue;
    if(item->pos.x != e->pos.x || item->pos.y != e->pos.y)
      continue;

    int j;
    for(j=0; j<MAX_INVENTORY; j++)
    {
      if(!e->inventory[j].active)
      {
        e->inventory[j] = *item;
        game_addMessage(fathom, e->pos, "%s picked up %s %s.", _getName(e->name), item_subtypeDescription(item->subtype), item_typeName(item->type));
        *item = nullItem;
        break;
      }
    }
    if(j==MAX_INVENTORY)
      game_addMessage(fathom, e->pos, "%s have no room for %s %s.", _getName(e->name), item_subtypeDescription(item->subtype), item_typeName(item->type));
  }
}
Ejemplo n.º 4
0
bool game_hurt(FathomData *fathom, Entity *e, int amount)
{
  int i;
  Entity nullEntity = NULL_ENTITY;
  e->o2 -= amount;
  if(amount > 0 && e->flags & EF_SCARES)
    e->scared = true;
  if(e->o2 <= 0)
  {    
    if(game_hasCharm(e, CHARM_RESURRECT))
    {
      e->o2 = e->maxo2-10;      
      Item nullItem = NULL_ITEM;
      for(i=0; i<MAX_INVENTORY; i++)
      {
        if(!e->inventory[i].active)
          continue;
        if(e->inventory[i].type != IT_CHARM)
          continue;
        if(e->inventory[i].charmSubtype != CHARM_RESURRECT)
          continue;
        if(!e->inventory[i].worn)
          continue;
        e->inventory[i] = nullItem;
      }
      game_addMessage(fathom, e->pos, "%s come back to life.", _getName(e->name));
      return false;
    }
    for(i=0; i<MAX_INVENTORY; i++)
    {
      if(!e->inventory[i].active)
        continue;
      _do_drop(fathom, e, i);
    }
    if(e->player)
    {
      LOG("Player died, deleting save");
      file_delete(SAVE_FILENAME); // woo, permadeath
    }
    *e = nullEntity;
    return true;
  }
  if(e->flags & EF_SPLITS && e->o2 > 5)
  {
    e->o2 = e->o2/2;
    Point nearby = pointAddPoint(e->pos, directionToPoint(sys_randint(4)));
    if(tilemap_visible(&fathom->tileMap, e->pos) && game_pointFree(fathom, nearby))
    {
      game_addMessage(fathom, nearby, "%s split.", _getName(e->name));
      game_spawnAt(fathom, *e, nearby);      
    }
  }
  return false;
}
Ejemplo n.º 5
0
    bool bind() const
        {
            if( !_testInitialized( ))
                return false;

            EQ_GL_CALL( glBindBufferARB( _getName(), pboID ));
            return true;
        }
Ejemplo n.º 6
0
void _do_turn(FathomData* fathom, Entity* e)
{
  bool waterBreath = game_hasCharm(e, CHARM_WATERBREATH);
  if(waterBreath && e->o2 > e->maxo2/3)
    e->o2 = e->maxo2/3;
  if(e->flags & EF_O2DEPLETES && !waterBreath)
  {
    e->o2timer++;
    if(e->o2timer >= 5)
    {
      Entity copy = *e;
      if(game_hurt(fathom, e, 1))
        game_addMessage(fathom, copy.pos, "%s drowned.", _getName(copy.name));
      e->o2timer = 0;
    }
  }

  if(e->player)
  {
    int i;
    for(i=0; i<MAX_ITEMS; i++)
    {
      Item* item = &fathom->items[i];
      if(!item->active)
        continue;
      if(e->pos.x != item->pos.x || e->pos.y != item->pos.y)
        continue;
      game_addMessage(fathom, item->pos, "%s see a %s %s.", _getName(e->name), item_subtypeDescription(item->subtype), item_typeName(item->type));
    }
  }

  int turnAdd = e->speed+sys_randint(e->speed);
  if(game_hasCharm(e, CHARM_HASTE))
    turnAdd = (turnAdd*2)/3;

  if(e->blindTimer > 0)
    e->blindTimer--;

  e->turn += turnAdd;
  //LOG("%s turn plus %d now %d", _getName(e->name), turnAdd, e->turn);
}
Ejemplo n.º 7
0
bool WindowSystem::operator != ( const WindowSystemEnum other ) const
{
    EQASSERT( _impl );
    return _impl->getName() != _getName( other );
}
Ejemplo n.º 8
0
WindowSystem::WindowSystem( const WindowSystemEnum type )
{
    _chooseImpl( _getName( type ));
}
Ejemplo n.º 9
0
 void unbind() const
     {
         _testInitialized();
         EQ_GL_CALL( glBindBufferARB( _getName(), 0 ));
     }
Ejemplo n.º 10
0
 void unmap() const
     {
         _testInitialized();
         EQ_GL_CALL( glUnmapBufferARB( _getName( )));
         unbind();
     }
Ejemplo n.º 11
0
bool _game_dive(GameData* game, int entityIndex, int depth)
{ 
  int i;
  Entity nullEntity = NULL_ENTITY; 
  FathomData* currentFathom = &game->fathoms[game->current];
  int newFathomIndex = game->current + depth;
  Entity e = currentFathom->entities[entityIndex];
  if(newFathomIndex < 0)
  {
    if(midEscape)
    {
      int numGoldenDoubloons = 0;
      for(i=0; i<MAX_INVENTORY; i++)
      {
        if(!e.inventory[i].active)
          continue;
        if(e.inventory[i].type != IT_DOUBLOON)
          continue;
        if(e.inventory[i].subtype != IST_GOLDEN)
          continue;
        numGoldenDoubloons++;
      }
      game_addGlobalMessage("%s escaped with %d golden doubloons.", _getName(e.name), numGoldenDoubloons);
      switch(numGoldenDoubloons)
      {
        case 0: game_addGlobalMessage("%s remain poor till your dying day."); break;
        case 1: game_addGlobalMessage("%s can pay off your mortgage."); break;
        case 2: game_addGlobalMessage("%s can consider early retirement."); break;
        case 3: game_addGlobalMessage("%s are independently wealthy."); break;
        case 4: game_addGlobalMessage("%s can buy a small island somewhere."); break;
        case 5: game_addGlobalMessage("%s are rich beyond your wildest dreams."); break;
      }
      currentFathom->entities[entityIndex].active = false;
      file_delete(SAVE_FILENAME);
      return true;
    } else
    {
      game_addGlobalMessage("%s are just under the surface.", _getName(e.name));
      game_addGlobalMessage("Press 'R'ise again to escape.", _getName(e.name));
      midEscape = true;
      return false;
    }
  }
  if(newFathomIndex >= MAX_FATHOMS)
  {
    game_addGlobalMessage("%s are on the bottom of the ocean.", _getName(e.name));
    return false;
  }
  currentFathom->entities[entityIndex] = nullEntity;
  int newDepth = game->current+depth;
  if(e.flags & EF_O2DEPLETES && !game_hasCharm(&e, CHARM_WATERBREATH))
  {
    Entity copy = e;
    if(game_hurt(currentFathom, &e, 10))
    {
      game_addGlobalMessage("%s drowned while %s.", _getName(copy.name), depth > 0 ? "diving" : "rising");
      return true;
    }
  }
  game_spawnAt(&game->fathoms[newDepth], e, e.pos);

  if(e.player)
  {
    file_save(SAVE_FILENAME, sizeof(GameData), game);
    for(i=0; i<MAX_ENTITIES; i++)
    {
      Entity *other = &currentFathom->entities[i];
      if(!other->active)
        continue;
      if(other->player)
        continue;
      if(!(other->flags & EF_SENTIENT))
        continue;
      if(other->flags & EF_STATIONARY)
        continue;
      if(!tilemap_visible(&currentFathom->tileMap, other->pos))
        continue;
      game_addGlobalMessage("%s follows %s %s.", _getName(other->name), _getName(e.name), depth > 0 ? "down" : "up");
      _game_dive(game, i, depth); // join in      
    }
    game->current += depth;
  }
  return true;
}
Ejemplo n.º 12
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;
  }
}
Ejemplo n.º 13
0
void _do_move(FathomData* fathom, Entity* e, Point move)
{
  if(game_hasCharm(e, CHARM_HASTE))
  {
    if(sys_randint(15)==0)
    {
      Direction d = sys_randint(4);
      move = directionToPoint(d);
    }
  }
  Point newPoint = pointAddPoint(e->pos, move);
  bool isWall = tilemap_collides(&fathom->tileMap, newPoint);
  bool isEntity = false;
  int i;
  for(i=0; i<MAX_ENTITIES; i++)
  {
    if(i==0)
      continue;
    Entity* victim = &fathom->entities[i];
    if(!victim->active)
      continue;
    if(newPoint.x != victim->pos.x)
      continue;
    if(newPoint.y != victim->pos.y)
      continue;
    
    int strength = e->strength;
    if(game_hasCharm(e, CHARM_BRUTE))
      strength += 4;    

    int amount = sys_randint(strength);
    if(amount > 0 && e->flags & EF_STEALS)
    {
      int space = -1;
      int j;
      for(j=0; j<MAX_INVENTORY; j++)
      {
        if(!e->inventory[j].active)
          space = j;
      }
      int slot = sys_randint(MAX_INVENTORY);
      if(victim->inventory[slot].active && space != -1)
      {
        e->inventory[space] = victim->inventory[slot];
        e->inventory[space].worn = false;
        Item nullItem = NULL_ITEM;
        victim->inventory[slot] = nullItem;
        amount = 0;
        game_addMessage(fathom, newPoint, "%s stole %s %s from %s.", _getName(e->name), item_subtypeDescription(e->inventory[space].subtype), item_typeName(e->inventory[space].type), _getName(victim->name));
        e->scared = true;
        return;
      }      
    }

    int damage = amount*10;
    bool killed = amount*10 >= victim->o2;
    if(amount == 0)
      game_addMessage(fathom, newPoint, "%s missed %s.", _getName(e->name), _getName(victim->name));
    else if (killed)
      game_addMessage(fathom, newPoint, "%s killed %s.", _getName(e->name), _getName(victim->name));
    else
    {
      if(victim->player)
        game_addMessage(fathom, newPoint, "%s hit %s for %d damage.", _getName(e->name), _getName(victim->name), damage);
      else
        game_addMessage(fathom, newPoint, "%s hit %s.", _getName(e->name), _getName(victim->name));
    }

    if(amount > 2 && victim->flags & EF_INKY && !killed)
    {
      e->blindTimer += sys_randint(8)+5;
      game_addMessage(fathom, e->pos, "%s squirted %s with ink.",  _getName(victim->name), _getName(e->name));
      victim->flags &= ~EF_INKY;
    }

    if(killed)
    {
      if(!game_hasCharm(victim, CHARM_RESURRECT))
        e->xp += victim->xp;
      if(e->xp >= game_nextLevel(e->level))
      {
        e->level++;
        e->maxo2 += 10;
        e->o2 += 10;
        e->strength += 1;
        game_addMessage(fathom, e->pos, "%s leveled up.", _getName(e->name));
      }
      if(victim->flags & EF_CONTAINSO2 && e->flags & EF_O2DEPLETES)
      {
        int boost = (sys_randint(5)+4)*5;
        int newo2 = min(e->o2 + boost, e->maxo2);
        game_addMessage(fathom, e->pos, "%s sucked down %d o2.", _getName(e->name), newo2 - e->o2);
        e->o2 = newo2;
      }
    }

    game_hurt(fathom, victim, amount*10);

    isEntity = true;
    break;
  }

  if(!isWall && !isEntity && !(e->flags & EF_STATIONARY))
  {
    e->pos = newPoint;
    if(game_hasCharm(e, CHARM_BRUTE))
    {
      // stomp on seaweed
      Tile nullTile = NULL_TILE;
      int index = tilemap_indexFromTilePosition(&fathom->tileMap, e->pos);

      if(fathom->tileMap.tiles[index].type == TILE_HIDE)
        fathom->tileMap.tiles[index] = nullTile;
    }
  }
}
Ejemplo n.º 14
0
/// <summary>Get name of the class</summary>
///
/// <returns>The name</returns>
///
/// <exception cref="runtime_error">Thrown if an internal error occurs</exception>
///
wstring PdbTypeClass::getName() {
  return _getName(symbol);
}
Ejemplo n.º 15
0
/// <summary>Get name of the union</summary>
///
/// <returns>The name</returns>
///
/// <exception cref="runtime_error">Thrown if an internal error occurs</exception>
///
wstring PdbTypeUnion::getName() {
  return _getName(symbol);
}