From 8a08384a6cc64a3cd56fe1b9514a8edf5afa9049 Mon Sep 17 00:00:00 2001 From: Looki2000 Date: Tue, 28 Feb 2023 18:51:57 +0100 Subject: [PATCH] small sussy changes --- mods/amogus_blocks/init.lua | 71 +++++++++++------- mods/amogus_generator/init.lua | 2 +- mods/amogus_items/init.lua | 12 ++- .../textures/{water.png => water_bottle.png} | Bin 4 files changed, 51 insertions(+), 34 deletions(-) rename mods/amogus_items/textures/{water.png => water_bottle.png} (100%) diff --git a/mods/amogus_blocks/init.lua b/mods/amogus_blocks/init.lua index de5c921..a6c59d4 100644 --- a/mods/amogus_blocks/init.lua +++ b/mods/amogus_blocks/init.lua @@ -332,43 +332,56 @@ minetest.register_node("amogus_blocks:iron_ore", { --sounds = default.node_sound_stone_defaults(), }) -local loot = { - "amogus_items:amogus_items:dynamite", - "amogus_items:amogus", - "amogus_items:coke", - "amogus_items:fanta", - "amogus_items:tomato", - "amogus_items:sugar", - "amogus_items:water", - "amogus_items:lightsaber_blue", - "amogus_items:lightsaber_red", - "amogus_items:water", - "amogus_items:amogus", - "amogus_items:water", - "amogus_items:sugar", - "amogus_items:fanta", - "amogus_items:tomato", - "amogus_items:sprite", - "amogus_items:lightsaber_green", - "amogus_items:sugar", - "amogus_items:amogus_items:dynamite", - "amogus_items:amogus", - "amogus_items:sprite", - "amogus_items:coke", - "amogus_items:water", - "amogus_items:sugar", - "amogus_items:amogus", - "amogus_items:amogus_items:dynamite", +-- item name, probability (larger number = larger probability relative to numbers of other items) +local lucky_loot = { + {"amogus_items:dynamite" , 3.0}, + {"amogus_items:amogus" , 4.0}, + {"amogus_items:coke" , 2.0}, + {"amogus_items:fanta" , 2.0}, + {"amogus_items:tomato" , 2.0}, + {"amogus_items:sugar" , 4.0}, + {"amogus_items:water" , 4.0}, + {"amogus_items:sprite" , 2.0}, + {"amogus_items:lightsaber_blue" , 1.0}, + {"amogus_items:lightsaber_red" , 1.0}, + {"amogus_items:lightsaber_green" , 1.0}, } +-- sum of all numbers in second column +local lucky_loot_propability_sum = 0 + +local last_lucky_loot_propability_sum = 0 + +for _, item in ipairs(lucky_loot) do + last_lucky_loot_propability_sum = lucky_loot_propability_sum + lucky_loot_propability_sum = lucky_loot_propability_sum + item[2] + + item[2] = last_lucky_loot_propability_sum + + -- create new column element + item[3] = lucky_loot_propability_sum +end + + minetest.register_node("amogus_blocks:lucky_block", { description = "Lucky Block", tiles = {"luckyblock.png"}, groups = {cracky = 3}, on_punch = function(pos, node, puncher, pointed_thing) - local item = loot[math.random(#loot)] - minetest.add_item(pos, item) + + local random_number = math.random() * lucky_loot_propability_sum + + for _, item in ipairs(lucky_loot) do + -- if random_number is in range of current item (inclusive start, exclusive end) + if random_number >= item[2] and random_number < item[3] then + minetest.add_item(pos, item[1]) + break + end + end + + --local item = lucky_loot[math.random(#lucky_loot)] + --minetest.add_item(pos, item) minetest.add_particlespawner({ amount = 100, time = 0.1, diff --git a/mods/amogus_generator/init.lua b/mods/amogus_generator/init.lua index 813ec63..28571ef 100644 --- a/mods/amogus_generator/init.lua +++ b/mods/amogus_generator/init.lua @@ -542,7 +542,7 @@ minetest.register_abm({ -- only spawn on solid blocks AND in the dark if minetest.registered_nodes[minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z}).name].walkable and minetest.get_node_light(pos) < 10 then -- do not spawn if there is already an sussy imposter nearby - local nearby_entities = minetest.get_objects_inside_radius(pos, 20) + local nearby_entities = minetest.get_objects_inside_radius(pos, 30) local imposter_nearby = false for _, entity in pairs(nearby_entities) do diff --git a/mods/amogus_items/init.lua b/mods/amogus_items/init.lua index fefa3ea..59e63b8 100644 --- a/mods/amogus_items/init.lua +++ b/mods/amogus_items/init.lua @@ -106,8 +106,10 @@ minetest.register_craftitem("amogus_items:tomato", { inventory_image = "tomato.png", on_use = minetest.item_eat(2), }) + minetest.register_craftitem("amogus_items:water", { - inventory_image = "water.png", + description = "Water", + inventory_image = "water_bottle.png", on_use = minetest.item_eat(8), }) @@ -122,7 +124,7 @@ minetest.register_tool("amogus_items:lightsaber_blue", { }, damage_groups = {fleshy=1.01}, }, - sound = {breaks = "amogus_sound"}, + --sound = {breaks = "amogus_sound"}, }) minetest.register_tool("amogus_items:lightsaber_red", { @@ -137,7 +139,7 @@ minetest.register_tool("amogus_items:lightsaber_red", { damage_groups = {fleshy=1.01}, }, - sound = {breaks = "amogus_sound"}, + --sound = {breaks = "amogus_sound"}, }) minetest.register_tool("amogus_items:lightsaber_green", { @@ -151,8 +153,9 @@ minetest.register_tool("amogus_items:lightsaber_green", { }, damage_groups = {fleshy=1.01}, }, - sound = {breaks = "amogus_sound"}, + --sound = {breaks = "amogus_sound"}, }) + minetest.register_craftitem("amogus_items:gold_ingot", { description = "Gold Ingot", inventory_image = "gold_ingot.png", @@ -164,6 +167,7 @@ minetest.register_craftitem("amogus_items:sussium_ingot", { description = "Sussium Ingot", inventory_image = "sussium_ingot.png", }) + --add theese items goldenpickaxe, stonepickaxe and allow them slowly break nodes and destroy it after 30 uses minetest.register_tool("amogus_items:goldenplumba", { description = "Golden Plumba", diff --git a/mods/amogus_items/textures/water.png b/mods/amogus_items/textures/water_bottle.png similarity index 100% rename from mods/amogus_items/textures/water.png rename to mods/amogus_items/textures/water_bottle.png