diff --git a/mods/amogus_entities/entities/amogus_entity.lua b/mods/amogus_entities/entities/amogus_entity.lua index f04957e..c8437b3 100644 --- a/mods/amogus_entities/entities/amogus_entity.lua +++ b/mods/amogus_entities/entities/amogus_entity.lua @@ -3,8 +3,8 @@ local textures_b = { "amogus_entity_b.png", "amogus_entity_g.png", "amogus_entity_br.png" - } - +} + local entity = { physical = true, collisionbox = {-0.5, 0, -0.5, 0.5, 1, 0.5}, @@ -44,9 +44,6 @@ local entity = { self.object:set_yaw(math.random() * 2 * math.pi) self.rotation_direction = math.random(-1, 1) self.min_max_jump_force_diff = self.max_jump_force - self.min_jump_force - - -- kill itself (debugging) - --self.object:remove() end, @@ -54,16 +51,22 @@ local entity = { -- play amogus sound randomly if math.random(400) == 1 then - minetest.sound_play("amogus_sound", { - pos = self.object:get_pos(), - gain = 1.0, - max_hear_distance = 50 - }) + --minetest.sound_play("amogus_sound", { + -- pos = self.object:get_pos(), + -- gain = 1.0, + -- max_hear_distance = 50 + --}) + + amogus_general.play_random_sound( + "amogus_sound", + self.object:get_pos(), + 1.0, -- gain + 40, -- max_hear_distance + 1.0 -- pitch + ) end - - -- random changing between walking and standing still if math.random(200) == 1 then self.is_going_forward = not self.is_going_forward @@ -96,7 +99,6 @@ local entity = { else self.rotation_direction = 0 end - end -- update rotation_velocity @@ -148,4 +150,5 @@ local entity = { self.last_y_velocity = vel.y end } + minetest.register_entity("amogus_entities:amogus", entity) \ No newline at end of file diff --git a/mods/amogus_entities/entities/mini_crewmate_entity.lua b/mods/amogus_entities/entities/mini_crewmate_entity.lua index 8a3ca2e..aeba0ff 100644 --- a/mods/amogus_entities/entities/mini_crewmate_entity.lua +++ b/mods/amogus_entities/entities/mini_crewmate_entity.lua @@ -12,12 +12,19 @@ local entity = { on_rightclick = function(self, clicker) minetest.chat_send_player(clicker:get_player_name(), "SO SUSSY!") - minetest.sound_play("amogus_sound", { - pos = self.object:get_pos(), - gain = 1.0, - max_hear_distance = 5, - pitch = 2 - }) + --minetest.sound_play("amogus_sound", { + -- pos = self.object:get_pos(), + -- gain = 1.0, + -- max_hear_distance = 5, + -- pitch = 2 + --}) + amogus_general.play_random_sound( + "amogus_sound", + self.object:get_pos(), + 1.0, -- gain + 40, -- max_hear_distance + 2 -- pitch + ) end, -- mini crewmate config -- @@ -35,8 +42,8 @@ local entity = { rotation_friction = 0.9, -- the same but for rotation - largest_distance_to_find_player = 6, -- largest distance to find player - smallest_distance_to_lost_player = 10, -- smallest distance to lost player + largest_distance_to_find_player = 8, -- largest distance to find player + smallest_distance_to_lost_player = 12, -- smallest distance to lost player largest_distance_to_stand_still = 3, -- largest distance to stand still next to the player @@ -97,20 +104,26 @@ local entity = { if math.random(sound_propability) == 1 then - minetest.sound_play("amogus_sound", { - pos = self.object:get_pos(), - gain = 1.0, - max_hear_distance = 50, - pitch = sound_pitch - }) + --minetest.sound_play("amogus_sound", { + -- pos = self.object:get_pos(), + -- gain = 1.0, + -- max_hear_distance = 50, + -- pitch = sound_pitch + --}) + + amogus_general.play_random_sound( + "amogus_sound", + self.object:get_pos(), + 1.0, -- gain + 40, -- max_hear_distance + sound_pitch -- pitch + ) end -- if on singpleplayer mode or only one player is connected, calculate distance between player and mini crewmate if minetest.is_singleplayer() or #minetest.get_connected_players() == 1 then - minetest.chat_send_all("singleplayer or multiplayer with only one player") - -- get first player self.player = minetest.get_connected_players()[1] @@ -120,7 +133,6 @@ local entity = { self.distance = vector.length(self.crewmate_player_vector) -- if on multiplayer mode, calculate distance between nearest player and mini crewmate else - minetest.chat_send_all("multiplayer") self.player = minetest.get_connected_players() self.distance = nil diff --git a/mods/amogus_general/init.lua b/mods/amogus_general/init.lua index b576f4f..4775e13 100644 --- a/mods/amogus_general/init.lua +++ b/mods/amogus_general/init.lua @@ -1,4 +1,35 @@ minetest.register_on_joinplayer(function(player) - player:set_physics_override({speed = 2}) - --player:set_sky({r=0, g=0, b=0}, "plain", {}) -end) \ No newline at end of file + player:set_physics_override({speed = 2}) + --player:set_sky({r=0, g=0, b=0}, "plain", {}) +end) + +amogus_general = { } + +---- SOUNDS CONFIGURATION ---- +sounds_config = { + -- format: {sound name, number of sounds to ramdomly choose from} + -- so for example if sound name is "test" and the number of sounds is 3, file names that will be randomly chosen are: "test1", "test2", "test3" + {"amogus_sound", 3}, +} + + +-- randomized amogus sounds +function amogus_general.play_random_sound(sound_name, pos, gain, max_hear_distance, pitch) + -- get number of sounds from config + local number_of_sounds = nil + for i = 1, #sounds_config do + if sounds_config[i][1] == sound_name then + number_of_sounds = sounds_config[i][2] + break + end + end + + assert(number_of_sounds ~= nil, "amogus_general.play_random_sound: sound with name '"..sound_name.."' is not found in sounds_config in mod amogus_general in init.lua") + + minetest.sound_play(sound_name..math.random(number_of_sounds), { + pos = pos, + gain = gain, + max_hear_distance = max_hear_distance, + pitch = pitch + }) +end \ No newline at end of file diff --git a/mods/amogus_general/sounds/amogus_sound1.ogg b/mods/amogus_general/sounds/amogus_sound1.ogg new file mode 100644 index 0000000..d843fe7 Binary files /dev/null and b/mods/amogus_general/sounds/amogus_sound1.ogg differ diff --git a/mods/amogus_general/sounds/amogus_sound2.ogg b/mods/amogus_general/sounds/amogus_sound2.ogg new file mode 100644 index 0000000..8ed9a2c Binary files /dev/null and b/mods/amogus_general/sounds/amogus_sound2.ogg differ diff --git a/mods/amogus_general/sounds/amogus_sound3.ogg b/mods/amogus_general/sounds/amogus_sound3.ogg new file mode 100644 index 0000000..6851739 Binary files /dev/null and b/mods/amogus_general/sounds/amogus_sound3.ogg differ diff --git a/mods/amogus_items/sounds/amogus_sound.ogg b/mods/amogus_general/sounds/amogus_sound_old.ogg similarity index 100% rename from mods/amogus_items/sounds/amogus_sound.ogg rename to mods/amogus_general/sounds/amogus_sound_old.ogg diff --git a/mods/amogus_items/init.lua b/mods/amogus_items/init.lua index 23f3c0c..8610b71 100644 --- a/mods/amogus_items/init.lua +++ b/mods/amogus_items/init.lua @@ -41,11 +41,18 @@ minetest.register_craftitem("amogus_items:amogus", { if pointed_thing.type == "node" then local pos = pointed_thing.above minetest.add_entity(pos, "amogus_entities:mini_crewmate") - minetest.sound_play("amogus_sound", { - pos = pos, - gain = 1.0, - max_hear_distance = 5 - }) + --minetest.sound_play("amogus_sound", { + -- pos = pos, + -- gain = 1.0, + -- max_hear_distance = 5 + --}) + amogus_general.play_random_sound( + "amogus_sound", + pos, + 1.0, -- gain + 5, -- max_hear_distance + 2.0 -- pitch + ) end return itemstack end