Ejemplo n.º 1
0
HeroPtr::HeroPtr(const CGHeroInstance *H)
{
	if(!H)
	{
		//init from nullptr should equal to default init
		*this = HeroPtr();
		return;
	}

	h = H;
	name = h->name;

	hid = H->id;
//	infosCount[ai->playerID][hid]++;
}
Ejemplo n.º 2
0
HeroPtr find_hero(MonsterPtr monster) {
    auto stats = monster->get_stats();
    int sight = stats->area_of_sight;

    TilePtr my_pos = monster->get_pos();
    Coord my_coord = my_pos->get_coord();

    for (int x = my_coord.x - sight; x < my_coord.x + sight; ++x) {
        for (int y = my_coord.y - sight; y < my_coord.y + sight; ++y) {
            TilePtr tile = main_core->get_tile(Coord(x, y));
            UnitPtr unit = tile->get_unit();
            if (unit == main_core->get_hero()) {
                return Hero::to_Ptr(unit);
            }
        }
    }
    return HeroPtr();
}