1
0
Fork 0

Further (mcl_)luck functionality

* XP from mob breeding impacted by luck
* eye of ender explosion chance impacted by luck
* fishing loot impacted by luck
* melee critical damage impacted by luck
* also fixed 2 scripts marked as "executable"
potions_api_redo
the-real-herowl 2024-03-24 05:46:01 +01:00 committed by the-real-herowl
parent c844157e3d
commit b68dc03f88
10 changed files with 40 additions and 11 deletions

View File

@ -78,6 +78,7 @@ function mob_class:feed_tame(clicker, feed_count, breed, tame, notake)
self.food = 0
self.horny = true
self.persistent = true
self._luck = mcl_luck.get_luck(clicker:get_player_name())
end
end
@ -273,7 +274,7 @@ function mob_class:check_breeding()
return
end
mcl_experience.throw_xp(pos, math.random(1, 7))
mcl_experience.throw_xp(pos, math.random(1, 7) + (parent1._luck or 0) + (parent2._luck or 0))
-- custom breed function
if parent1.on_breed then

View File

@ -1,5 +1,5 @@
name = mcl_mobs
author = PilzAdam
description = Adds a mob API for mods to add animals or monsters, etc.
depends = mcl_particles
depends = mcl_particles, mcl_luck
optional_depends = mcl_weather, mcl_explosions, mcl_hunger, mcl_worlds, invisibility, lucky_block, cmi, doc_identifier, mcl_armor, mcl_portals, mcl_experience, mcl_sculk

0
mods/ENTITIES/mcl_mobs/spawning.lua Executable file → Normal file
View File

0
mods/HUD/mcl_achievements/init.lua Executable file → Normal file
View File

View File

@ -28,8 +28,8 @@ minetest.register_entity("mcl_end:ender_eye", {
self._age = self._age + dtime
if self._age >= 3 then
-- End of life
local r = math.random(1,5)
if r == 1 then
local r = math.random(1,15) + self._luck
if r <= 3 then
-- 20% chance to get destroyed completely.
-- 100% if in Creative Mode
self.object:remove()
@ -85,11 +85,12 @@ minetest.register_craftitem("mcl_end:ender_eye", {
if user == nil then
return
end
local player_name = user:get_player_name()
local origin = user:get_pos()
origin.y = origin.y + 1.5
local strongholds = mcl_structures.registered_structures["end_shrine"].static_pos
local dim = mcl_worlds.pos_to_dimension(origin)
local is_creative = minetest.is_creative_enabled(user:get_player_name())
local is_creative = minetest.is_creative_enabled(player_name)
-- Just drop the eye of ender if there are no strongholds
if #strongholds <= 0 or dim ~= "overworld" then
@ -124,6 +125,8 @@ minetest.register_craftitem("mcl_end:ender_eye", {
-- Throw it!
local obj = minetest.add_entity(origin, "mcl_end:ender_eye")
local dir
local ent = obj:get_luaentity()
ent._luck = mcl_luck.get_luck(player_name)
if lowest_dist <= 25 then
local velocity = 4

View File

@ -1,2 +1,2 @@
name = mcl_end
depends = screwdriver, mcl_sounds, mcl_util, doc_items, mcl_worlds, mcl_structures, mcl_stonecutter
depends = screwdriver, mcl_sounds, mcl_util, doc_items, mcl_worlds, mcl_structures, mcl_stonecutter, mcl_luck

View File

@ -61,8 +61,8 @@ local fish = function(itemstack, player, pointed_thing)
local junk_values = {10, 8.1, 6.1, 4.2}
local luck_of_the_sea = math.min(mcl_enchanting.get_enchantment(itemstack, "luck_of_the_sea"), 3)
local index = luck_of_the_sea + 1
local fish_value = fish_values[index]
local junk_value = junk_values[index] + fish_value
local fish_value = fish_values[index] - mcl_luck.get_luck(ent.player)
local junk_value = junk_values[index] + fish_value - mcl_luck.get_luck(ent.player)
if r <= fish_value then
-- Fish
items = mcl_loot.get_loot({

View File

@ -1,3 +1,3 @@
name = mcl_fishing
description = Adds fish and fishing poles to go fishing.
depends = mcl_core, mcl_sounds, mcl_loot, mcl_mobs, mcl_enchanting, mcl_throwing, mcl_colors, mcl_buckets
depends = mcl_core, mcl_sounds, mcl_loot, mcl_mobs, mcl_enchanting, mcl_throwing, mcl_colors, mcl_buckets, mcl_luck

View File

@ -23,7 +23,32 @@ mcl_damage.register_modifier(function(obj, damage, reason)
texture = "mcl_particles_crit.png^[colorize:#bc7a57:127",
})
minetest.sound_play("mcl_criticals_hit", {object = obj})
return damage * math.random(1.5, 2.5)
local crit_mod
local CRIT_MIN = 1.5
local CRIT_DIFF = 1
if hitter:is_player() then
local luck = mcl_luck.get_luck(hitter:get_player_name())
if luck ~= 0 then
local a, d
if luck > 0 then
d = -0.5
a = d - math.abs(luck)
elseif luck < 0 then
a = -0.5
d = a - math.abs(luck)
else
minetest.log("warning", "[mcl_criticals] luck is not a number") -- this technically can't happen, but want to catch such cases
end
if a then
local x = math.random()
crit_mod = CRIT_DIFF * (a * x) / (d - luck * x) + CRIT_MIN
end
end
end
if not crit_mod then
crit_mod = math.random(CRIT_MIN, CRIT_MIN + CRIT_DIFF)
end
return damage * crit_mod
end
end
end, -100)

View File

@ -1,2 +1,2 @@
name = mcl_criticals
depends = mcl_damage
depends = mcl_damage, mcl_luck