Exemplo n.º 1
0
void configure() {
    ::configure();
    set_culture("Losthavener");
    set_race("orc");
    set_sex(Sex_Male);
    set_level(60);
    add_friend("SINBYEN_GUARD");
    add_friend("SINBYEN_CITIZEN");
    add_enemy("SINBYEN_UNDEAD");
    add_enemy("SINBYEN_DEMON");
    set_culture_name("Shanks", False, "Headmaster");
    set_alignment(({ 0, 0 }));
Exemplo n.º 2
0
    void Offline_Survival::update(unsigned int ticks)
    {
        if (end_game()) return;

        while (need_add())
            add_enemy();

        clean();

        al.mov(ticks);

        if (player&&need_rev())
        {
            //Revive the player only if it has any lifes left
            if (--now_lif)
                player->revive_at(arrow::Vct(0,0));

            sf::Text new_text;
            new_text.setString(fdx::menu::Language::getText(fdx::menu::Language::YOU_DIED));
            new_text.setColor(teams.get_enemy());
            texts.push_back(new_text);
        }

        for (auto it=ais.begin();it!=ais.end();++it)
        {
            it->think();
            it->play();
            it->mov(ticks);
        }
    }
Exemplo n.º 3
0
/* create_formation_enemies()
 * Fills a newly created formation with actual enemies
 */
void create_formation_enemies(
	game_state_t* GS,
	formation_t* formation,
	int top_tier,
	int amount
	)
{
	int i, new_tier;
	formation_t* f = formation;

	// Create enemies to fill the formation
	for( i = 0 ; i < amount ; i++ ) {

		// Adjust tier according to rank, decreasing with rank
		new_tier = max(
			TIER_1,
			top_tier - (f->ranks[i].coordinate.y - 1)
		);
//((i+1)/2) )
		f->ranks[i].occupied_by
			= add_enemy(
				GS,
				new_tier,
				add_vector(
					f->position,
					f->ranks[i].position
				),
				f->velocity,
				f
			)
		;
	}

}
Exemplo n.º 4
0
int main()
{
	auto a = relations::node::make("a");	
	auto b = relations::node::make("b");	
	auto c = relations::node::make("c");	
	auto d = relations::node::make("d");	

	auto e = relations::node::make("e");	
	auto f = relations::node::make("f");

	auto g = relations::node::make("g");
	auto h = relations::node::make("h");
	auto i = relations::node::make("i");

	a->add_enemy(b);
	b->add_enemy(c);
	b->add_enemy(d);
	c->add_enemy(b);
	c->add_enemy(d);

	c->add_enemy(e);
	e->add_enemy(f);
	f->add_enemy(g);
	f->add_enemy(h);
	h->add_enemy(i);

	auto friends = a->list_friends();

	pretty(friends.begin(), friends.end(), 4, 10);

	return 0; 
}
Exemplo n.º 5
0
Enemy::Enemy(Game &game_)
{
	ID = staticID;
	staticID++;
	add_enemy(this);

	game = &game_;
	Canvas &canvas = game_.get_canvas();
	PhysicsContext pc = game_.get_pc();
	ResourceManager &resources = game_.get_resources();

//________________________________________________________________________
//														   G A M E P L A Y
	type = go_enemy;
	eType = T_HOVERBOT;
	
	missile.set_game(*game);
	missile.set_speed(90.0f);
	missile.set_type(MissileDesc::mt_energy);
	missile.should_hurt_player(true);
	missile.should_hurt_enemy(false);
	turret_angle = Angle(0,angle_degrees);
	time_since_last_shoot = 0.0f;

//________________________________________________________________________
//															   R E N D E R
	enemy = Sprite::resource(canvas,"Enemy1", resources);
	enemy.set_play_loop(true);
	
	//int x,y;
	//Origin origin;
	//enemy->get_alignment(origin,x,y);

	update_callback = std::function<void(int)>(std::bind(&Enemy::update, this, std::placeholders::_1));
	cc.connect(game_.get_draw_sig(), clan::bind_member(this, &Enemy::draw));
    cc.connect(game_.get_update_sig(), update_callback);

//__________________________________________________________________________
//															   P H Y S I C S

	BodyDescription body_desc(pc);
	body_desc.set_position(0, game->get_height()-40);
	body_desc.set_type(body_dynamic);
	body_desc.set_angular_damping(100.0f);

	PolygonShape shape(pc);
	shape.set_as_box(enemy.get_width()/2.5f, enemy.get_height()/2.5f);

	FixtureDescription fixture_desc(pc);
	fixture_desc.set_density(1000.0f);
	fixture_desc.set_shape(shape);
	
	body = Body(pc, body_desc);
	body.set_data(this);
	Fixture(pc, body, fixture_desc);

	pos.x = 50;
	pos.y = 50;
	life = 100;
	is_dead = false;

	body.set_position(pos);

	speed = -35;

	body.set_linear_velocity(Vec2f(speed,0));

	target = Player::getPlayer1();
}
Exemplo n.º 6
0
void init()
{
	g_car = Car(MAP_WD / 2 - 1, 1, -1, 0);
	add_enemy();
	init_map();
}
Exemplo n.º 7
0
static DskJsonValue *
create_user_update (User *user)
{
  Game *game = user->base.game;

  /* width/height in various units, rounded up */
  unsigned tile_width = (user->width + TILE_SIZE - 1) / TILE_SIZE;
  unsigned tile_height = (user->height + TILE_SIZE - 1) / TILE_SIZE;
  unsigned cell_width = (tile_width + CELL_SIZE * 2 - 2) / CELL_SIZE;
  unsigned cell_height = (tile_height + CELL_SIZE * 2 - 2) / CELL_SIZE;

  /* left/upper corner, rounded down */
  int min_tile_x = user->base.x - (tile_width+1) / 2;
  int min_tile_y = user->base.y - (tile_height+1) / 2;
  int min_cell_x = int_div (min_tile_x, CELL_SIZE);
  int min_cell_y = int_div (min_tile_y, CELL_SIZE);

  unsigned alloced = 16;
  DskJsonValue **elements = dsk_malloc (sizeof (DskJsonValue *) * alloced);
  unsigned n_elements = 0;

  unsigned x, y;

  for (x = 0; x < cell_width; x++)
    for (y = 0; y < cell_height; y++)
      {
        int ucx = x + min_cell_x;               /* un-wrapped x, y */
        int ucy = y + min_cell_y;
        int px = (ucx * CELL_SIZE - user->base.x) * TILE_SIZE + user->width / 2 - TILE_SIZE / 2;
        int py = (ucy * CELL_SIZE - user->base.y) * TILE_SIZE + user->height / 2 - TILE_SIZE / 2;
        unsigned cx, cy;
        Cell *cell;

        /* deal with wrapping (or not) */
        if (ucx < 0)
          {
            if (!game->wrap)
              continue;
            cx = ucx + game->universe_width;
          }
        else if ((unsigned) ucx >= game->universe_width)
          {
            cx = ucx;
            if (game->wrap)
              cx -= game->universe_width;
          }
        else
          cx = ucx;
        if (ucy < 0)
          {
            if (!game->wrap)
              continue;
            cy = ucy + game->universe_height;
          }
        else if ((unsigned) ucy >= game->universe_height)
          {
            cy = ucy;
            if (game->wrap)
              cy -= game->universe_height;
          }
        else
          cy = ucy;

        /* render walls */
        if (cy < game->universe_height && cx <= game->universe_width
            && game->v_walls[cx + cy * game->universe_width])
          {
            /* render vertical wall */
            add_wall (&n_elements, &elements, &alloced,
                      px, py, TILE_SIZE, TILE_SIZE * (CELL_SIZE+1));
          }
        if (cy <= game->universe_height && cx < game->universe_width
            && game->h_walls[cx + cy * game->universe_width])
          {
            /* render horizontal wall */
            add_wall (&n_elements, &elements, &alloced,
                      px, py, TILE_SIZE * (CELL_SIZE+1), TILE_SIZE);
          }
        if (cx >= game->universe_width || cy >= game->universe_height)
          continue;

        cell = game->cells + (game->universe_width * cy + cx);

        /* render bullets */
        Object *object;
        for (object = cell->objects[OBJECT_TYPE_BULLET]; object; object = object->next_in_cell)
          {
            int bx = px + (object->x - cx * CELL_SIZE) * TILE_SIZE + TILE_SIZE / 2;
            int by = py + (object->y - cy * CELL_SIZE) * TILE_SIZE + TILE_SIZE / 2;
            add_bullet (&n_elements, &elements, &alloced,
                        bx, by);
          }

        /* render dudes */
        for (object = cell->objects[OBJECT_TYPE_USER]; object; object = object->next_in_cell)
          {
            int bx = px + (object->x - cx * CELL_SIZE) * TILE_SIZE + TILE_SIZE / 2;
            int by = py + (object->y - cy * CELL_SIZE) * TILE_SIZE + TILE_SIZE / 2;
            add_user (&n_elements, &elements, &alloced,
                      bx, by, user == (User*) object);
          }

        /* render bad guys */
        for (object = cell->objects[OBJECT_TYPE_ENEMY]; object; object = object->next_in_cell)
          {
            int bx = px + (object->x - cx * CELL_SIZE) * TILE_SIZE + TILE_SIZE / 2;
            int by = py + (object->y - cy * CELL_SIZE) * TILE_SIZE + TILE_SIZE / 2;
            add_enemy (&n_elements, &elements, &alloced, bx, by);
          }

        /* render generators */
        if (cell->generator)
          {
            int bx = px + (cell->generator->x - cx * CELL_SIZE) * TILE_SIZE + TILE_SIZE;
            int by = py + (cell->generator->y - cy * CELL_SIZE) * TILE_SIZE + TILE_SIZE;
            add_generator (&n_elements, &elements, &alloced, bx, by, user->base.game->latest_update);
          }
      }
  DskJsonValue *rv;
  rv = dsk_json_value_new_array (n_elements, elements);
  dsk_free (elements);

  user->last_update = game->latest_update;
  return rv;
}
Exemplo n.º 8
0
Arquivo: main.c Projeto: z88dk/z88dk
void
update_script(void)
{
   unsigned char mod;

   // there's a wave already
   if (horde_count)
      return;

   // wait between waves
   if (wave_delay--)
      return;

   // only if the player killed all aliens in the wave
   if (!not_clean)
   {
      ++wave;
      update_score();
      wait();
      sp1_UpdateNow();
   }
   not_clean = 0;

   // don't play the sound for the first wave
   if (wave > 1)
      playfx(FX_SELECT);

   wave_delay = 16;

   horde_move_x = 0;
   horde_inc_x = 1;
   horde_ix = 4;
   horde_iy = 0;
   horde_move_y = 0;
   horde_delay = 0;
   horde_delay_base = 6;
   horde_count = 0;

   mod = wave & 0x7;  // 0-7
   switch(mod)
   {
      case 1:
         for (j = 0; j < 2; ++j)
            for (i = 0; i < 5; ++i)
            {
               add_enemy(24 * i, j * 20, flyer);
               ++horde_count;
            }
         break;
      case 2:
         horde_move_x = HORDE_MOVE + 1;
         horde_inc_x = -1;
         horde_ix = -4;
         for (j = 0; j < 3; ++j)
            for (i = 0; i < 3 - j; ++i)
            {
               add_enemy(236 - 24 * i, j * 20, !i && !j ? bomber : flyer);
               ++horde_count;
               add_enemy(236 - 120 + 24 * i, j * 20, !i && !j ? bomber : flyer);
               ++horde_count;
            }
         break;
      case 3:
         horde_delay_base = 3;
         for (j = 0; j < 3; ++j)
            for (i = 0; i < 5; ++i)
            {
               add_enemy(24 * i, j * 20, !j ? bomber : flyer);
               ++horde_count;
            }
         break;
      case 4:
         horde_delay_base = 3;
         horde_move_x = HORDE_MOVE + 1;
         horde_inc_x = -1;
         horde_ix = -4;
         k = 1;
         for (j = 0; j < 4; ++j)
            for (i = 0; i < 5; ++i)
            {
               if (i & 1)
                  continue;

               if (k)
                  add_enemy(220 - 24 * i, j * 20, bomber);
               else
                  add_enemy(220 - 24 * i, j * 20, flyer);
               k = !k;

               ++horde_count;
            }
         break;
      case 5:
         horde_delay_base = 3;

         for (i = 0; i < 6; ++i)
         {
            add_enemy(- 8 + 24 * i, 0, bomber);
            ++horde_count;
         }

         for (j = 0; j < 2; ++j)
            for (i = 0; i < 4; ++i)
            {
               add_enemy(-8 + 24 + 24 * i, 20 + j * 20, flyer);
               ++horde_count;
            }

            add_enemy(-8 + 24 + 24 + 12, 60, flyer);
            ++horde_count;
         break;
      case 6:
         horde_delay_base = 2;

         for (i = 0; i < 5; ++i)
         {
            add_enemy(24 * i, 0, bomber);
            ++horde_count;
         }
         for (i = 0; i < 4; ++i)
         {
            add_enemy(12 + 24 * i, 20, flyer);
            ++horde_count;
         }
         for (i = 0; i < 5; ++i)
         {
            add_enemy(24 * i, 40, flyer);
            ++horde_count;
         }
         break;
      case 7:
         horde_move_x = HORDE_MOVE + 1;
         horde_inc_x = -1;
         horde_ix = -4;
         horde_delay_base = 2;

         for (i = 0; i < 5; ++i)
         {
            add_enemy(220 - 24 * i, 0, bomber);
            ++horde_count;
         }
         for (i = 0; i < 5; ++i)
         {
            add_enemy(220 - 24 * i, 40, flyer);
            ++horde_count;
         }
         for (i = 0; i < 4; ++i)
         {
            add_enemy(220 - 12 - 24 * i, 80, bomber);
            ++horde_count;
         }
         break;
      // this is 8
      case 0:
         horde_delay_base = 1;

         for (i = 0; i < 3; ++i)
         {
            add_enemy(24 + 24 * i, 0, flyer);
            ++horde_count;
         }
         for (i = 0; i < 5; ++i)
         {
            add_enemy(24 * i, 40, bomber);
            ++horde_count;
         }
         for (i = 0; i < 4; ++i)
         {
            add_enemy(12 + 24 * i, 80, flyer);
            ++horde_count;
         }
         break;
   }

   if (wave > 8)
      horde_delay_base = 0;
}
Exemplo n.º 9
0
void CMonsterEnemyMemory::update() 
{
	VERIFY		(monster->g_Alive());

	CMonsterHitMemory& monster_hit_memory = monster->HitMemory;

	typedef CObjectManager<const CEntityAlive>::OBJECTS	objects_list;

	objects_list const& objects	=	monster->memory().enemy().objects();

	if ( monster_hit_memory.is_hit() && time() < monster_hit_memory.get_last_hit_time() + 1000 )
	{
		if ( CEntityAlive* enemy = smart_cast<CEntityAlive*>(monster->HitMemory.get_last_hit_object()) )
		{
			if ( monster->CCustomMonster::useful(&monster->memory().enemy(), enemy) && 
				 monster->Position().distance_to(enemy->Position()) 
				                        < 
				 monster->get_feel_enemy_who_just_hit_max_distance() )
			{
				add_enemy					(enemy);

				bool const self_is_dog	=	!!smart_cast<const CAI_Dog*>(monster);
				if ( self_is_dog )
				{
					CMonsterSquad* const squad	=	monster_squad().get_squad(monster);
					squad->set_home_in_danger	();
				}
			}			
		}
	}

	if ( monster->SoundMemory.IsRememberSound() )
	{
		SoundElem sound;
		bool dangerous;
		monster->SoundMemory.GetSound(sound, dangerous);
		if ( dangerous && Device.dwTimeGlobal < sound.time + 2000 )
		{
			if ( CEntityAlive const* enemy = smart_cast<CEntityAlive const*>(sound.who) )
			{
				float const xz_dist	=	monster->Position().distance_to_xz(g_actor->Position());
				float const y_dist	=	_abs(monster->Position().y - g_actor->Position().y);

				if ( monster->CCustomMonster::useful(&monster->memory().enemy(), enemy) && 
					 y_dist < 10 &&
					 xz_dist < monster->get_feel_enemy_who_made_sound_max_distance() &&
					 g_actor->memory().visual().visible_now(monster)	)
				{
					add_enemy					(enemy);

					bool const self_is_dog	=	!!smart_cast<const CAI_Dog*>(monster);
					if ( self_is_dog )
					{
						CMonsterSquad* const squad	=	monster_squad().get_squad(monster);
						squad->set_home_in_danger	();
					}
				}
			}
		}
	}

	for ( objects_list::const_iterator	I	=	objects.begin();
										I	!=	objects.end(); 
									  ++I	) 
	{
		const CEntityAlive* enemy = *I;
		const bool feel_enemy	  = monster->Position().distance_to(enemy->Position()) 
													< 
									monster->get_feel_enemy_max_distance();

		if ( feel_enemy || monster->memory().visual().visible_now(*I) )
			add_enemy(*I);
	}

	float const feel_enemy_max_distance	=	monster->get_feel_enemy_max_distance();
	if ( g_actor )
	{
		float const xz_dist	=	monster->Position().distance_to_xz(g_actor->Position());
		float const y_dist	=	_abs(monster->Position().y - g_actor->Position().y);

		if ( xz_dist < feel_enemy_max_distance && 
			 y_dist < 10 &&
			 monster->memory().enemy().is_useful(g_actor) &&
			 g_actor->memory().visual().visible_now(monster) )
		{
			add_enemy(g_actor);
		}
	}
	
	// удалить устаревших врагов
	remove_non_actual();

	// обновить опасность 
	for (ENEMIES_MAP_IT it = m_objects.begin(); it != m_objects.end(); it++) {
		u8		relation_value = u8(monster->tfGetRelationType(it->first));
		float	dist = monster->Position().distance_to(it->second.position);
		it->second.danger = (1 + relation_value*relation_value*relation_value) / (1 + dist);
	}
}