Weather system added, mostly decoration. Some tweaks to residents. Moved altar to its own menu, s for sacrifice. You can no longer burn incense outside the base.
This commit is contained in:
@@ -9,6 +9,7 @@ int residents_count = 0;
|
||||
|
||||
string[] zombie_sounds = {"sounds/enemies/zombie1.ogg"};
|
||||
string[] bandit_sounds = {"sounds/enemies/bandit1.ogg", "sounds/enemies/bandit2.ogg"};
|
||||
string[] goose_sounds = {"sounds/game/goose.ogg"};
|
||||
|
||||
class Zombie {
|
||||
int position;
|
||||
@@ -82,11 +83,174 @@ class Bandit {
|
||||
}
|
||||
Bandit@[] bandits;
|
||||
|
||||
class FlyingCreatureConfig {
|
||||
string id;
|
||||
string drop_type;
|
||||
string[] sounds;
|
||||
string fall_sound;
|
||||
string impact_sound;
|
||||
int health;
|
||||
int move_interval_min;
|
||||
int move_interval_max;
|
||||
int min_height;
|
||||
int max_height;
|
||||
float sound_volume_step;
|
||||
int sound_delay_min;
|
||||
int sound_delay_max;
|
||||
int fall_speed;
|
||||
int fly_away_chance;
|
||||
int max_dist_from_water;
|
||||
int hourly_spawn_chance;
|
||||
int max_count;
|
||||
int sight_range;
|
||||
bool flee_on_sight;
|
||||
}
|
||||
FlyingCreatureConfig@[] flying_creature_configs;
|
||||
|
||||
class FlyingCreature {
|
||||
int position;
|
||||
int health;
|
||||
int height;
|
||||
string state; // "flying", "falling"
|
||||
int area_start;
|
||||
int area_end;
|
||||
string creature_type;
|
||||
int sound_handle;
|
||||
int fall_sound_handle;
|
||||
timer move_timer;
|
||||
timer sound_timer;
|
||||
timer fall_timer;
|
||||
int next_move_delay;
|
||||
int next_sound_delay;
|
||||
string voice_sound;
|
||||
bool fading_out;
|
||||
bool ready_to_remove;
|
||||
timer fade_timer;
|
||||
|
||||
FlyingCreature(string type, int pos, int home_start, int home_end, FlyingCreatureConfig@ cfg) {
|
||||
position = pos;
|
||||
health = cfg.health;
|
||||
height = random(cfg.min_height, cfg.max_height);
|
||||
state = "flying";
|
||||
area_start = home_start;
|
||||
area_end = home_end;
|
||||
creature_type = type;
|
||||
sound_handle = -1;
|
||||
fall_sound_handle = -1;
|
||||
|
||||
if (cfg.sounds.length() > 0) {
|
||||
voice_sound = cfg.sounds[random(0, cfg.sounds.length() - 1)];
|
||||
}
|
||||
|
||||
move_timer.restart();
|
||||
sound_timer.restart();
|
||||
|
||||
next_move_delay = random(cfg.move_interval_min, cfg.move_interval_max);
|
||||
next_sound_delay = random(cfg.sound_delay_min, cfg.sound_delay_max);
|
||||
fading_out = false;
|
||||
ready_to_remove = false;
|
||||
}
|
||||
}
|
||||
FlyingCreature@[] flying_creatures;
|
||||
|
||||
string get_random_small_game() {
|
||||
int index = random(0, small_game_types.length() - 1);
|
||||
return small_game_types[index];
|
||||
}
|
||||
|
||||
class WorldDrop {
|
||||
int position;
|
||||
string type;
|
||||
int sound_handle;
|
||||
|
||||
WorldDrop(int pos, string t) {
|
||||
position = pos;
|
||||
type = t;
|
||||
sound_handle = -1;
|
||||
// Start looping item sound at position
|
||||
sound_handle = p.play_1d("sounds/items/item.ogg", x, position, true);
|
||||
if (sound_handle != -1) {
|
||||
p.update_sound_positioning_values(sound_handle, -1.0, 3.0, true);
|
||||
}
|
||||
}
|
||||
|
||||
void update() {
|
||||
if (sound_handle == -1 || !p.sound_is_active(sound_handle)) {
|
||||
sound_handle = p.play_1d("sounds/items/item.ogg", x, position, true);
|
||||
if (sound_handle != -1) {
|
||||
p.update_sound_positioning_values(sound_handle, -1.0, 3.0, true);
|
||||
}
|
||||
} else {
|
||||
// Update source position for 1d sound
|
||||
p.update_sound_1d(sound_handle, position);
|
||||
}
|
||||
}
|
||||
|
||||
void destroy() {
|
||||
if (sound_handle != -1) {
|
||||
p.destroy_sound(sound_handle);
|
||||
sound_handle = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
WorldDrop@[] world_drops;
|
||||
|
||||
void add_world_drop(int pos, string type) {
|
||||
WorldDrop@ d = WorldDrop(pos, type);
|
||||
world_drops.insert_last(d);
|
||||
}
|
||||
|
||||
void update_world_drops() {
|
||||
for (uint i = 0; i < world_drops.length(); i++) {
|
||||
world_drops[i].update();
|
||||
}
|
||||
}
|
||||
|
||||
WorldDrop@ get_drop_at(int pos) {
|
||||
for (uint i = 0; i < world_drops.length(); i++) {
|
||||
if (world_drops[i].position == pos) {
|
||||
return @world_drops[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void remove_drop_at(int pos) {
|
||||
for (uint i = 0; i < world_drops.length(); i++) {
|
||||
if (world_drops[i].position == pos) {
|
||||
world_drops[i].destroy();
|
||||
world_drops.remove_at(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void clear_world_drops() {
|
||||
for (uint i = 0; i < world_drops.length(); i++) {
|
||||
world_drops[i].destroy();
|
||||
}
|
||||
world_drops.resize(0);
|
||||
}
|
||||
|
||||
bool try_pickup_small_game(string game_type) {
|
||||
if (inv_small_game >= get_personal_stack_limit()) {
|
||||
screen_reader_speak("You can't carry any more small game.", true);
|
||||
return false;
|
||||
}
|
||||
inv_small_game++;
|
||||
inv_small_game_types.insert_last(game_type);
|
||||
screen_reader_speak("Picked up " + game_type + ".", true);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool try_pickup_world_drop(WorldDrop@ drop) {
|
||||
if (get_flying_creature_config_by_drop_type(drop.type) !is null) {
|
||||
return try_pickup_small_game(drop.type);
|
||||
}
|
||||
screen_reader_speak("Picked up " + drop.type + ".", true);
|
||||
return true;
|
||||
}
|
||||
|
||||
class WorldSnare {
|
||||
int position;
|
||||
bool has_catch;
|
||||
@@ -843,9 +1007,9 @@ bool try_attack_player_bandit(Bandit@ bandit) {
|
||||
|
||||
// Play weapon swing sound based on bandit's weapon
|
||||
if (bandit.weapon_type == "spear") {
|
||||
p.play_stationary("sounds/weapons/spear_swing.ogg", false);
|
||||
play_creature_attack_sound("sounds/weapons/spear_swing.ogg", x, bandit.position, BANDIT_SOUND_VOLUME_STEP);
|
||||
} else if (bandit.weapon_type == "axe") {
|
||||
p.play_stationary("sounds/weapons/axe_swing.ogg", false);
|
||||
play_creature_attack_sound("sounds/weapons/axe_swing.ogg", x, bandit.position, BANDIT_SOUND_VOLUME_STEP);
|
||||
}
|
||||
|
||||
int damage = random(BANDIT_DAMAGE_MIN, BANDIT_DAMAGE_MAX);
|
||||
@@ -856,9 +1020,9 @@ bool try_attack_player_bandit(Bandit@ bandit) {
|
||||
|
||||
// Play hit sound
|
||||
if (bandit.weapon_type == "spear") {
|
||||
p.play_stationary("sounds/weapons/spear_hit.ogg", false);
|
||||
play_creature_attack_sound("sounds/weapons/spear_hit.ogg", x, bandit.position, BANDIT_SOUND_VOLUME_STEP);
|
||||
} else if (bandit.weapon_type == "axe") {
|
||||
p.play_stationary("sounds/weapons/axe_hit.ogg", false);
|
||||
play_creature_attack_sound("sounds/weapons/axe_hit.ogg", x, bandit.position, BANDIT_SOUND_VOLUME_STEP);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -877,11 +1041,11 @@ void try_attack_barricade_bandit(Bandit@ bandit) {
|
||||
|
||||
// Play weapon swing sound
|
||||
if (bandit.weapon_type == "spear") {
|
||||
p.play_stationary("sounds/weapons/spear_swing.ogg", false);
|
||||
p.play_stationary("sounds/weapons/spear_hit.ogg", false);
|
||||
play_creature_attack_sound("sounds/weapons/spear_swing.ogg", x, bandit.position, BANDIT_SOUND_VOLUME_STEP);
|
||||
play_creature_attack_sound("sounds/weapons/spear_hit.ogg", x, bandit.position, BANDIT_SOUND_VOLUME_STEP);
|
||||
} else if (bandit.weapon_type == "axe") {
|
||||
p.play_stationary("sounds/weapons/axe_swing.ogg", false);
|
||||
p.play_stationary("sounds/weapons/axe_hit.ogg", false);
|
||||
play_creature_attack_sound("sounds/weapons/axe_swing.ogg", x, bandit.position, BANDIT_SOUND_VOLUME_STEP);
|
||||
play_creature_attack_sound("sounds/weapons/axe_hit.ogg", x, bandit.position, BANDIT_SOUND_VOLUME_STEP);
|
||||
}
|
||||
|
||||
// Resident defense counter-attack
|
||||
@@ -1261,3 +1425,327 @@ void clear_mountains() {
|
||||
}
|
||||
world_mountains.resize(0);
|
||||
}
|
||||
|
||||
// Flying Creature Functions
|
||||
|
||||
void init_flying_creature_configs() {
|
||||
flying_creature_configs.resize(0);
|
||||
|
||||
FlyingCreatureConfig@ goose_cfg = FlyingCreatureConfig();
|
||||
goose_cfg.id = "goose";
|
||||
goose_cfg.drop_type = "goose";
|
||||
goose_cfg.sounds = goose_sounds;
|
||||
goose_cfg.fall_sound = "sounds/actions/falling.ogg";
|
||||
goose_cfg.impact_sound = "sounds/game/game_falls.ogg";
|
||||
goose_cfg.health = GOOSE_HEALTH;
|
||||
goose_cfg.move_interval_min = GOOSE_MOVE_INTERVAL_MIN;
|
||||
goose_cfg.move_interval_max = GOOSE_MOVE_INTERVAL_MAX;
|
||||
goose_cfg.min_height = GOOSE_FLYING_HEIGHT_MIN;
|
||||
goose_cfg.max_height = GOOSE_FLYING_HEIGHT_MAX;
|
||||
goose_cfg.sound_volume_step = GOOSE_SOUND_VOLUME_STEP;
|
||||
goose_cfg.sound_delay_min = GOOSE_FLIGHT_SOUND_DELAY_MIN;
|
||||
goose_cfg.sound_delay_max = GOOSE_FLIGHT_SOUND_DELAY_MAX;
|
||||
goose_cfg.fall_speed = GOOSE_FALL_SPEED;
|
||||
goose_cfg.fly_away_chance = GOOSE_FLY_AWAY_CHANCE;
|
||||
goose_cfg.max_dist_from_water = GOOSE_MAX_DIST_FROM_WATER;
|
||||
goose_cfg.hourly_spawn_chance = GOOSE_HOURLY_SPAWN_CHANCE;
|
||||
goose_cfg.max_count = GOOSE_MAX_COUNT;
|
||||
goose_cfg.sight_range = GOOSE_SIGHT_RANGE;
|
||||
goose_cfg.flee_on_sight = false;
|
||||
flying_creature_configs.insert_last(goose_cfg);
|
||||
}
|
||||
|
||||
FlyingCreatureConfig@ get_flying_creature_config(string creature_type) {
|
||||
for (uint i = 0; i < flying_creature_configs.length(); i++) {
|
||||
if (flying_creature_configs[i].id == creature_type) {
|
||||
return @flying_creature_configs[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
FlyingCreatureConfig@ get_flying_creature_config_by_drop_type(string drop_type) {
|
||||
for (uint i = 0; i < flying_creature_configs.length(); i++) {
|
||||
if (flying_creature_configs[i].drop_type == drop_type) {
|
||||
return @flying_creature_configs[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void clear_flying_creatures() {
|
||||
for (uint i = 0; i < flying_creatures.length(); i++) {
|
||||
if (flying_creatures[i].sound_handle != -1) {
|
||||
p.destroy_sound(flying_creatures[i].sound_handle);
|
||||
flying_creatures[i].sound_handle = -1;
|
||||
}
|
||||
if (flying_creatures[i].fall_sound_handle != -1) {
|
||||
p.destroy_sound(flying_creatures[i].fall_sound_handle);
|
||||
flying_creatures[i].fall_sound_handle = -1;
|
||||
}
|
||||
}
|
||||
flying_creatures.resize(0);
|
||||
}
|
||||
|
||||
FlyingCreature@ get_flying_creature_at(int pos) {
|
||||
for (uint i = 0; i < flying_creatures.length(); i++) {
|
||||
if (flying_creatures[i].position == pos) {
|
||||
return @flying_creatures[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
int get_flying_creature_count(string creature_type) {
|
||||
int count = 0;
|
||||
for (uint i = 0; i < flying_creatures.length(); i++) {
|
||||
if (flying_creatures[i].creature_type == creature_type) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
bool get_random_flying_creature_area(FlyingCreatureConfig@ cfg, int &out area_start, int &out area_end) {
|
||||
int stream_count = int(world_streams.length());
|
||||
int mountain_stream_count = 0;
|
||||
for (uint i = 0; i < world_mountains.length(); i++) {
|
||||
mountain_stream_count += int(world_mountains[i].stream_positions.length());
|
||||
}
|
||||
|
||||
int total_areas = stream_count + mountain_stream_count;
|
||||
if (total_areas <= 0) return false;
|
||||
|
||||
int pick = random(0, total_areas - 1);
|
||||
if (pick < stream_count) {
|
||||
area_start = world_streams[pick].start_position;
|
||||
area_end = world_streams[pick].end_position;
|
||||
} else {
|
||||
pick -= stream_count;
|
||||
for (uint i = 0; i < world_mountains.length(); i++) {
|
||||
int local_count = int(world_mountains[i].stream_positions.length());
|
||||
if (pick < local_count) {
|
||||
int stream_pos = world_mountains[i].start_position + world_mountains[i].stream_positions[pick];
|
||||
area_start = stream_pos;
|
||||
area_end = stream_pos;
|
||||
break;
|
||||
}
|
||||
pick -= local_count;
|
||||
}
|
||||
}
|
||||
|
||||
area_start -= cfg.max_dist_from_water;
|
||||
area_end += cfg.max_dist_from_water;
|
||||
if (area_start < 0) area_start = 0;
|
||||
if (area_end >= MAP_SIZE) area_end = MAP_SIZE - 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool find_flying_creature_spawn(FlyingCreatureConfig@ cfg, int &out spawn_x, int &out area_start, int &out area_end) {
|
||||
if (!get_random_flying_creature_area(cfg, area_start, area_end)) return false;
|
||||
|
||||
for (int attempts = 0; attempts < 20; attempts++) {
|
||||
int candidate = random(area_start, area_end);
|
||||
if (get_flying_creature_at(candidate) == null) {
|
||||
spawn_x = candidate;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void fly_away_flying_creature(FlyingCreature@ creature, FlyingCreatureConfig@ cfg) {
|
||||
creature.state = "fading";
|
||||
creature.fading_out = true;
|
||||
creature.ready_to_remove = false;
|
||||
creature.fade_timer.restart();
|
||||
creature.health = 0;
|
||||
|
||||
if (creature.sound_handle == -1 || !p.sound_is_active(creature.sound_handle)) {
|
||||
creature.ready_to_remove = true;
|
||||
}
|
||||
if (creature.fall_sound_handle != -1) {
|
||||
p.destroy_sound(creature.fall_sound_handle);
|
||||
creature.fall_sound_handle = -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool spawn_flying_creature(string creature_type) {
|
||||
FlyingCreatureConfig@ cfg = get_flying_creature_config(creature_type);
|
||||
if (cfg is null) return false;
|
||||
|
||||
int spawn_x = -1;
|
||||
int area_start = 0;
|
||||
int area_end = 0;
|
||||
|
||||
if (!find_flying_creature_spawn(cfg, spawn_x, area_start, area_end)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FlyingCreature@ c = FlyingCreature(creature_type, spawn_x, area_start, area_end, cfg);
|
||||
flying_creatures.insert_last(c);
|
||||
c.sound_handle = play_creature_voice(c.voice_sound, x, spawn_x, cfg.sound_volume_step);
|
||||
return true;
|
||||
}
|
||||
|
||||
void update_flying_creature(FlyingCreature@ creature) {
|
||||
FlyingCreatureConfig@ cfg = get_flying_creature_config(creature.creature_type);
|
||||
if (cfg is null) return;
|
||||
|
||||
if (creature.state == "fading") {
|
||||
if (!creature.fading_out) {
|
||||
creature.fading_out = true;
|
||||
creature.fade_timer.restart();
|
||||
}
|
||||
|
||||
if (creature.sound_handle != -1 && p.sound_is_active(creature.sound_handle)) {
|
||||
float progress = float(creature.fade_timer.elapsed) / float(FLYING_CREATURE_FADE_OUT_DURATION);
|
||||
if (progress < 0.0) progress = 0.0;
|
||||
if (progress > 1.0) progress = 1.0;
|
||||
float volume = 0.0 + (FLYING_CREATURE_FADE_OUT_MIN_VOLUME * progress);
|
||||
p.update_sound_start_values(creature.sound_handle, 0.0, volume, 1.0);
|
||||
}
|
||||
|
||||
if (creature.fade_timer.elapsed >= FLYING_CREATURE_FADE_OUT_DURATION) {
|
||||
if (creature.sound_handle != -1) {
|
||||
p.destroy_sound(creature.sound_handle);
|
||||
creature.sound_handle = -1;
|
||||
}
|
||||
creature.ready_to_remove = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (creature.state == "flying") {
|
||||
if (creature.position < creature.area_start || creature.position > creature.area_end) {
|
||||
fly_away_flying_creature(creature, cfg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (creature.sound_timer.elapsed > creature.next_sound_delay) {
|
||||
creature.sound_timer.restart();
|
||||
creature.next_sound_delay = random(cfg.sound_delay_min, cfg.sound_delay_max);
|
||||
creature.sound_handle = play_creature_voice(creature.voice_sound, x, creature.position, cfg.sound_volume_step);
|
||||
}
|
||||
|
||||
if (cfg.fly_away_chance > 0 && random(1, 1000) <= cfg.fly_away_chance) {
|
||||
fly_away_flying_creature(creature, cfg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (creature.move_timer.elapsed > creature.next_move_delay) {
|
||||
creature.move_timer.restart();
|
||||
creature.next_move_delay = random(cfg.move_interval_min, cfg.move_interval_max);
|
||||
|
||||
int dir = 0;
|
||||
if (cfg.flee_on_sight && cfg.sight_range > 0) {
|
||||
int distance_to_player = abs(x - creature.position);
|
||||
if (distance_to_player <= cfg.sight_range) {
|
||||
if (x > creature.position) dir = -1;
|
||||
else if (x < creature.position) dir = 1;
|
||||
}
|
||||
}
|
||||
if (dir == 0) dir = random(-1, 1);
|
||||
if (dir != 0) {
|
||||
int target_x = creature.position + dir;
|
||||
if (target_x < creature.area_start || target_x > creature.area_end) {
|
||||
fly_away_flying_creature(creature, cfg);
|
||||
return;
|
||||
}
|
||||
if (target_x >= 0 && target_x < MAP_SIZE) {
|
||||
creature.position = target_x;
|
||||
if (creature.sound_handle != -1 && p.sound_is_active(creature.sound_handle)) {
|
||||
p.update_sound_1d(creature.sound_handle, creature.position);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (creature.state == "falling") {
|
||||
if (creature.fall_timer.elapsed > cfg.fall_speed) {
|
||||
creature.fall_timer.restart();
|
||||
creature.height--;
|
||||
|
||||
if (creature.fall_sound_handle != -1) {
|
||||
p.destroy_sound(creature.fall_sound_handle);
|
||||
}
|
||||
|
||||
float pitch_percent = 50.0 + (50.0 * (float(creature.height) / float(cfg.max_height)));
|
||||
if (pitch_percent < 50.0) pitch_percent = 50.0;
|
||||
if (pitch_percent > 100.0) pitch_percent = 100.0;
|
||||
|
||||
creature.fall_sound_handle = p.play_extended_1d(cfg.fall_sound, x, creature.position, 0, 0, true, 0, 0.0, 0.0, pitch_percent);
|
||||
if (creature.fall_sound_handle != -1) {
|
||||
p.update_sound_positioning_values(creature.fall_sound_handle, -1.0, cfg.sound_volume_step, true);
|
||||
}
|
||||
|
||||
if (creature.height <= 0) {
|
||||
if (creature.fall_sound_handle != -1) {
|
||||
p.destroy_sound(creature.fall_sound_handle);
|
||||
creature.fall_sound_handle = -1;
|
||||
}
|
||||
|
||||
play_creature_death_sound(cfg.impact_sound, x, creature.position, cfg.sound_volume_step);
|
||||
notify("A " + creature.creature_type + " fell from the sky at " + creature.position + "!");
|
||||
add_world_drop(creature.position, cfg.drop_type);
|
||||
creature.health = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void update_flying_creatures() {
|
||||
for (uint i = 0; i < flying_creatures.length(); i++) {
|
||||
update_flying_creature(flying_creatures[i]);
|
||||
|
||||
if (flying_creatures[i].health <= 0) {
|
||||
if (flying_creatures[i].state == "falling" && flying_creatures[i].height <= 0) {
|
||||
flying_creatures.remove_at(i);
|
||||
i--;
|
||||
} else if (flying_creatures[i].state == "flying") {
|
||||
flying_creatures.remove_at(i);
|
||||
i--;
|
||||
} else if (flying_creatures[i].state == "fading" && flying_creatures[i].ready_to_remove) {
|
||||
flying_creatures.remove_at(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void attempt_hourly_flying_creature_spawn() {
|
||||
for (uint i = 0; i < flying_creature_configs.length(); i++) {
|
||||
FlyingCreatureConfig@ cfg = flying_creature_configs[i];
|
||||
if (get_flying_creature_count(cfg.id) >= cfg.max_count) continue;
|
||||
if (random(1, 100) <= cfg.hourly_spawn_chance) {
|
||||
spawn_flying_creature(cfg.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool damage_flying_creature_at(int pos, int damage) {
|
||||
for (uint i = 0; i < flying_creatures.length(); i++) {
|
||||
if (flying_creatures[i].position == pos && flying_creatures[i].state == "flying") {
|
||||
FlyingCreatureConfig@ cfg = get_flying_creature_config(flying_creatures[i].creature_type);
|
||||
if (cfg is null) return false;
|
||||
|
||||
flying_creatures[i].health -= damage;
|
||||
if (flying_creatures[i].health <= 0) {
|
||||
flying_creatures[i].state = "falling";
|
||||
flying_creatures[i].fall_timer.restart();
|
||||
|
||||
if (flying_creatures[i].sound_handle != -1) {
|
||||
p.destroy_sound(flying_creatures[i].sound_handle);
|
||||
flying_creatures[i].sound_handle = -1;
|
||||
}
|
||||
|
||||
float pitch_percent = 50.0 + (50.0 * (float(flying_creatures[i].height) / float(cfg.max_height)));
|
||||
flying_creatures[i].fall_sound_handle = p.play_extended_1d(cfg.fall_sound, x, pos, 0, 0, true, 0, 0.0, 0.0, pitch_percent);
|
||||
if (flying_creatures[i].fall_sound_handle != -1) {
|
||||
p.update_sound_positioning_values(flying_creatures[i].fall_sound_handle, -1.0, cfg.sound_volume_step, true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user