1
0
Fork 0

Made some random rolls affected by mcl_luck

* xp bottle
* bow and crossbow crits
* megacrits added for mcl_bows, achievable only by (mcl_)luck
This commit is contained in:
the-real-herowl 2024-03-21 03:10:05 +01:00
parent b28467d348
commit 42778a3a6d
5 changed files with 18 additions and 13 deletions

View File

@ -14,7 +14,7 @@ minetest.register_entity("mcl_experience:bottle",{
local n = node.name local n = node.name
if n ~= "air" and n ~= "mcl_portals:portal" and n ~= "mcl_portals:portal_end" and minetest.get_item_group(n, "liquid") == 0 then if n ~= "air" and n ~= "mcl_portals:portal" and n ~= "mcl_portals:portal_end" and minetest.get_item_group(n, "liquid") == 0 then
minetest.sound_play("mcl_potions_breaking_glass", {pos = pos, max_hear_distance = 16, gain = 1}) minetest.sound_play("mcl_potions_breaking_glass", {pos = pos, max_hear_distance = 16, gain = 1})
mcl_experience.throw_xp(pos, math.random(3, 11)) mcl_experience.throw_xp(pos, math.random(3, 11) + (self._luck or 0))
minetest.add_particlespawner({ minetest.add_particlespawner({
amount = 50, amount = 50,
time = 0.1, time = 0.1,
@ -40,13 +40,18 @@ minetest.register_entity("mcl_experience:bottle",{
end, end,
}) })
local function throw_xp_bottle(pos, dir, velocity) local function throw_xp_bottle(pos, dir, velocity, user)
minetest.sound_play("mcl_throwing_throw", {pos = pos, gain = 0.4, max_hear_distance = 16}, true) minetest.sound_play("mcl_throwing_throw", {pos = pos, gain = 0.4, max_hear_distance = 16}, true)
local obj = minetest.add_entity(pos, "mcl_experience:bottle") local obj = minetest.add_entity(pos, "mcl_experience:bottle")
obj:set_velocity(vector.multiply(dir, velocity)) obj:set_velocity(vector.multiply(dir, velocity))
local acceleration = vector.multiply(dir, -3) local acceleration = vector.multiply(dir, -3)
acceleration.y = -9.81 acceleration.y = -9.81
obj:set_acceleration(acceleration) obj:set_acceleration(acceleration)
if user then
local ent = obj:get_luaentity()
local luck = mcl_luck.get_luck(user:get_player_name())
ent._luck = luck
end
end end
minetest.register_craftitem("mcl_experience:bottle", { minetest.register_craftitem("mcl_experience:bottle", {
@ -55,7 +60,7 @@ minetest.register_craftitem("mcl_experience:bottle", {
wield_image = "mcl_experience_bottle.png", wield_image = "mcl_experience_bottle.png",
stack_max = 64, stack_max = 64,
on_use = function(itemstack, placer, pointed_thing) on_use = function(itemstack, placer, pointed_thing)
throw_xp_bottle(vector.add(placer:get_pos(), vector.new(0, 1.5, 0)), placer:get_look_dir(), 10) throw_xp_bottle(vector.add(placer:get_pos(), vector.new(0, 1.5, 0)), placer:get_look_dir(), 10, placer)
if not minetest.is_creative_enabled(placer:get_player_name()) then if not minetest.is_creative_enabled(placer:get_player_name()) then
itemstack:take_item() itemstack:take_item()
end end

View File

@ -1,4 +1,4 @@
name = mcl_experience name = mcl_experience
author = oilboi author = oilboi
description = eXPerience mod description = eXPerience mod
depends = mcl_gamemode depends = mcl_gamemode, mcl_luck

View File

@ -270,10 +270,10 @@ controls.register_on_release(function(player, key, time)
local is_critical = false local is_critical = false
if charge >= BOW_CHARGE_TIME_FULL then if charge >= BOW_CHARGE_TIME_FULL then
speed = BOW_MAX_SPEED speed = BOW_MAX_SPEED
local r = math.random(1,5) local r = math.random(1,5) + mcl_luck.get_luck(player:get_player_name())
if r == 1 then if r > 4 then
-- 20% chance for critical hit -- 20% chance for critical hit (by default)
damage = 10 damage = 10 + math.floor((r-5)/5) -- mega crit (over crit) with high luck
is_critical = true is_critical = true
else else
damage = 9 damage = 9

View File

@ -322,10 +322,10 @@ controls.register_on_press(function(player, key, time)
-- Fully charged -- Fully charged
local is_critical = false local is_critical = false
speed = BOW_MAX_SPEED speed = BOW_MAX_SPEED
local r = math.random(1,5) local r = math.random(1,5) + mcl_luck.get_luck(player:get_player_name())
if r == 1 then if r > 4 then
-- 20% chance for critical hit -- 20% chance for critical hit (by default)
damage = 10 damage = 10 + math.floor((r-5)/5) -- mega crit (over crit) with high luck
is_critical = true is_critical = true
else else
damage = 9 damage = 9

View File

@ -1,6 +1,6 @@
name = mcl_bows name = mcl_bows
author = Arcelmi author = Arcelmi
description = This mod adds bows and arrows for MineClone 2. description = This mod adds bows and arrows for MineClone 2.
depends = controls, mcl_particles, mcl_enchanting, mcl_init, mcl_util, mcl_shields, mcl_fovapi depends = controls, mcl_particles, mcl_enchanting, mcl_init, mcl_util, mcl_shields, mcl_fovapi, mcl_luck
optional_depends = awards, mcl_achievements, mcl_core, mcl_mobitems, playerphysics, doc, doc_identifier, mesecons_button optional_depends = awards, mcl_achievements, mcl_core, mcl_mobitems, playerphysics, doc, doc_identifier, mesecons_button