Ejemplo n.º 1
0
NPC::NPC(Subsystem& subsystem, const std::string& filename, ZipReader *zip)
    throw (KeyValueException, MovableException)
    : Properties(filename + ".npc", zip), Movable(subsystem)
{
    try {
        read_base_informations(*this);

        move_init = atoi(get_value("move_init").c_str());
        if (move_init == 0) {
            move_init = 50;
        }

        jump_x_impulse = atof(get_value("jump_x_impulse").c_str());
        if (jump_x_impulse < Epsilon) {
            jump_x_impulse = 1.5f;
        }

        jump_y_impulse = atof(get_value("jump_y_impulse").c_str());
        if (jump_y_impulse < Epsilon) {
            jump_y_impulse = 1.5f;
        }

        max_accel_x = atof(get_value("max_accel_x").c_str());
        if (max_accel_x < Epsilon) {
            max_accel_x = 2.5f;
        }

        springiness_x = atof(get_value("springiness_x").c_str());
        springiness_y = atof(get_value("springiness_y").c_str());

        friction_factor = atof(get_value("friction_factor").c_str());
        if (friction_factor < Epsilon) {
            friction_factor = 1.0f;
        }

        idle1_counter = static_cast<double>(atoi(get_value("idle1_counter").c_str()));
        idle2_counter = static_cast<double>(atoi(get_value("idle2_counter").c_str()));

        impact = atof(get_value("impact").c_str());

        ignore_owner_counter = atof(get_value("ignore_owner_counter").c_str());
        if (ignore_owner_counter < 100.0f) {
            ignore_owner_counter = 100.0f;
        }

        create_npc(NPCAnimationStanding, filename + "_standing.png", get_speed(*this, "standing", 30), get_one_shot(*this, "standing", false), zip);
        create_npc(NPCAnimationIdle1, filename + "_idle1.png", get_speed(*this, "idle1", 30), get_one_shot(*this, "idle1", false), zip);
        create_npc(NPCAnimationIdle2, filename + "_idle2.png", get_speed(*this, "idle2", 30), get_one_shot(*this, "idle2", false), zip);
        create_npc(NPCAnimationJumping, filename + "_jumping.png", get_speed(*this, "jumping", 30), get_one_shot(*this, "jumping", false), zip);
    } catch (const Exception& e) {
        throw MovableException(std::string(e.what()) + ": " + filename);
    }
}
Ejemplo n.º 2
0
dungeon* generate_dungeon(int w, int h) {
	dungeon* ret = calloc(1, sizeof(dungeon));
	ret->player = *create_npc(1);
	ret->width = w;
	ret->height = h;
	ret->spawn_room = get_rand(w*h);
	ret->end_room = get_rand(w*h);
	ret->location = ret->spawn_room;
	generate_dungeon_rooms(ret);
	return ret;
}
Ejemplo n.º 3
0
nomask void
create_creature()
{
    if (!random(5))
	add_leftover("/std/leftover", "tooth", random(5) + 1, 0, 1, 0);
    if (!random(5))
	add_leftover("/std/leftover", "skull", 1, 0, 1, 1);
    if (!random(5))
	add_leftover("/std/leftover", "thighbone", 2, 0, 1, 1);
    if (!random(5))
        add_leftover("/std/leftover", "kneecap", 2, 0, 0, 1);
    if (!random(5))
	add_leftover("/std/leftover", "rib", 2, 0, 1, 1);

    if (query_prop(LIVE_I_UNDEAD))
    {
	create_npc();
        MONEY_CONDENSE(this_object());
	return;
    }

    if (!random(5))
        add_leftover("/std/leftover", "ear", 2, 0, 0, 0);
    if (!random(5))
        add_leftover("/std/leftover", "scalp", 1, 0, 0, 1);
    if (!random(5))
        add_leftover("/std/leftover", "nail", random(5) + 1, 0, 0, 0);
    if (!random(5))
	add_leftover("/std/leftover", "heart", 1, 0, 0, 1);
    if (!random(5))
	add_leftover("/std/leftover", "nose", 1, 0, 0, 0);
    if (!random(5))
	add_leftover("/std/leftover", "eye", 2, 0, 0, 0);
    if (!random(5))
	add_leftover("/std/leftover", "kidney", 2, 0, 0, 1);
    if (!random(5))
	add_leftover("/std/leftover", "intestine", 2, 0, 0, 1);

    MONEY_CONDENSE(this_object());
    create_npc();
}
Ejemplo n.º 4
0
void set_stage(dungeon* d) {
	d->player.level = (unsigned char) get_level(d);
	d->cur_room = &(d->rooms[d->location]);
	d->player_buff = 0;
	d->npc_buff = 0;
	d->room_chest = NULL;
	d->room_npc	= NULL;

	if(d->cur_room->chest) {
		d->room_chest = container_init((d->height + d->width)/2);
		container_fill(d->room_chest);
	}

	if(d->cur_room->boss_room) {
		d->room_npc = create_npc(get_rand(d->height + d->width));
	}

	if(d->cur_room->cold) {
		d->player_buff -= 1;
	}

	if(d->cur_room->dark) {
		d->npc_buff += 1;
	}

	if(d->cur_room->sky_view) {
		d->player_buff += 2;
	}

	if(d->cur_room->visited) {
		d->player_buff += 1;
	} else {
		d->player.xp += 1;
	}

	d->player_buff += (alignment(d->player.trait, d->player.weapon.trait)-1);
	d->npc_buff += (alignment(d->player.trait, d->player.armor.trait)-1);
	d->player_buff += (alignment(d->player.trait, (unsigned char)d->cur_room->trait)-1);
}