示例#1
0
文件: world.cpp 项目: noctare/Caligo
bool is_monster_alive(world_data* world, int32 id) {
	monster_entity* monster = find_monster(world, id);
	if (!monster) {
		return false;
	}
	return monster->stats.health > 0;
}
示例#2
0
// attacks the first monster of monster type argv[1]
int attack(int argc, char **argv) {
    if(argc == 1) {
        printf("Please specify a monster to attack.\n");
        return 0;
    }

    // find the monster
    monster_t *target = find_monster(&the_player.current_room->mob, argv[1]);
    
    // give up if we can't find it
    if(target == NULL) {
        printf("There's no %s here...\n", argv[1]);
        return 0;
    }

    // inflict damage
    int damage_amount = the_player.level;
    printf("You attack the %s for %d damage...\n", target->name, damage_amount);
    damage(target, damage_amount);
    return ATTACK_TIME;
}