Exemplo n.º 1
0
void cUFO::checkCollission(CObject* other) {
	Uint32 timeBuffer;
	CObject::checkCollission(other);
	if  (other->getType() == PLAYER && other->getShape()->collision(this->beamZone)){
		timeBuffer = SDL_GetTicks();
		if (timeBuffer - animation.getLastAnimationTime() >= UFO_BEAM_TIME_DIFFERENCE){
			animation.setLastAnimationTime(timeBuffer);
			Beam();
		}
	}
}
Exemplo n.º 2
0
//-----------------------------------------------------------------------------
void mglGraph::Beam(const mglData &tr, const mglData &g1, const mglData &g2, const mglData &a, mreal r,
		const char *stl, int flag, int num)
{
	mreal v;
	num = num<=0 ? 1 : num;
	for(long i=0;i<num;i++)
	{
		v = Cmax + (Cmin-Cmax)*(i+1.)/(num+1);
		Beam(v,tr,g1,g2,a,r,stl,flag);
	}
}
Exemplo n.º 3
0
void silva::PrayGoodEffect()
{
  if(PLAYER->GetNP() < HUNGER_LEVEL)
  {
    ADD_MESSAGE("Your stomach feels full again.");
    PLAYER->SetNP(SATIATED_LEVEL);
  }

  if(PLAYER->IsBurning() || PLAYER->PossessesItem(&item::IsOnFire))
  {
    beamdata Beam
      (
        0,
        CONST_S("drowned by the showers of ") + GetName(),
        YOURSELF,
        0
      );

    lsquare* Square = PLAYER->GetLSquareUnder();

    Square->WaterRain(Beam);
    ADD_MESSAGE("Silva allows a little spell of gentle rain to pour down from above.");
  }
  else if(!game::GetCurrentLevel()->IsOnGround())
  {
    ADD_MESSAGE("Suddenly a horrible earthquake shakes the level.");
    int c, Tunnels = 2 + RAND() % 3;
    if(!game::GetCurrentLevel()->EarthquakesAffectTunnels())
      Tunnels = 0;

    for(c = 0; c < Tunnels; ++c)
      game::GetCurrentLevel()->AttachPos(game::GetCurrentLevel()->GetRandomSquare(0, NOT_WALKABLE|ATTACHABLE));

    int ToEmpty = 10 + RAND() % 11;

    for(c = 0; c < ToEmpty; ++c)
      for(int i = 0; i < 50; ++i)
      {
        v2 Pos = game::GetCurrentLevel()->GetRandomSquare(0, NOT_WALKABLE);
        truth Correct = false;

        for(int d = 0; d < 8; ++d)
        {
          lsquare* Square = game::GetCurrentLevel()->GetLSquare(Pos)->GetNeighbourLSquare(d);

          if(Square && Square->IsFlyable())
          {
            Correct = true;
            break;
          }
        }

        if(Correct)
        {
          game::GetCurrentLevel()->GetLSquare(Pos)->ChangeOLTerrainAndUpdateLights(0);
          break;
        }
      }

    int ToGround = 20 + RAND() % 21;

    for(c = 0; c < ToGround; ++c)
      for(int i = 0; i < 50; ++i)
      {
        v2 Pos = game::GetCurrentLevel()->GetRandomSquare(0, RAND() & 1 ? 0 : HAS_CHARACTER);

        if(Pos == ERROR_V2)
          continue;

        lsquare* Square = game::GetCurrentLevel()->GetLSquare(Pos);
        character* Char = Square->GetCharacter();

        if(Square->GetOLTerrain() || (Char && (Char->IsPlayer() || PLAYER->GetRelation(Char) != HOSTILE)))
          continue;

        int Walkables = 0;

        for(int d = 0; d < 8; ++d)
        {
          lsquare* NearSquare = game::GetCurrentLevel()->GetLSquare(Pos)->GetNeighbourLSquare(d);

          if(NearSquare && NearSquare->IsFlyable())
            ++Walkables;
        }

        if(Walkables > 6)
        {
          Square->ChangeOLTerrainAndUpdateLights(earth::Spawn());

          if(Char)
          {
            if(Char->CanBeSeenByPlayer())
              ADD_MESSAGE("%s is hit by a brick of earth falling from the roof!", Char->CHAR_NAME(DEFINITE));

            Char->ReceiveDamage(0, 20 + RAND() % 21, PHYSICAL_DAMAGE, HEAD|TORSO, 8, true);
            Char->CheckDeath(CONST_S("killed by an earthquake"), 0);
          }

          Square->KickAnyoneStandingHereAway();
          Square->GetStack()->ReceiveDamage(0, 10 + RAND() % 41, PHYSICAL_DAMAGE);
          break;
        }
      }

    // Generate a few boulders in the level

    int BoulderNumber = 10 + RAND() % 10;

    for(c = 0; c < BoulderNumber; ++c)
    {
      v2 Pos = game::GetCurrentLevel()->GetRandomSquare();
      lsquare* Square = game::GetCurrentLevel()->GetLSquare(Pos);
      character* MonsterHere = Square->GetCharacter();

      if(!Square->GetOLTerrain() && (!MonsterHere || MonsterHere->GetRelation(PLAYER) == HOSTILE))
      {
        Square->ChangeOLTerrainAndUpdateLights(boulder::Spawn(1 + (RAND() & 1)));

        if(MonsterHere)
          MonsterHere->ReceiveDamage(0, 10 + RAND() % 10, PHYSICAL_DAMAGE, HEAD|TORSO, 8, true);

        Square->GetStack()->ReceiveDamage(0, 10 + RAND() % 10, PHYSICAL_DAMAGE);
      }
    }

    // Damage to items in the level

    for(int x = 0; x < game::GetCurrentLevel()->GetXSize(); ++x)
      for(int y = 0; y < game::GetCurrentLevel()->GetYSize(); ++y)
        game::GetCurrentLevel()->GetLSquare(x, y)->ReceiveEarthQuakeDamage();
  }
  else
  {
    int TryToCreate = 1 + RAND() % 7;
    int Created = 0;

    for(; Created < TryToCreate; ++Created)
    {
      wolf* Wolf = wolf::Spawn();
      v2 Pos = game::GetCurrentLevel()->GetNearestFreeSquare(Wolf, PLAYER->GetPos());

      if(Pos == ERROR_V2)
      {
        delete Wolf;
        break;
      }

      Wolf->SetTeam(PLAYER->GetTeam());
      Wolf->PutTo(Pos);
    }

    if(!Created && PLAYER->CanHear())
      ADD_MESSAGE("You hear a sad howling of a wolf imprisoned in the earth.");

    if(Created == 1)
      ADD_MESSAGE("Suddenly a tame wolf materializes beside you.");

    if(Created > 1)
      ADD_MESSAGE("Suddenly some tame wolves materialize around you.");
  }
}