Move most of the game to the new API

This commit is contained in:
the-real-herowl 2024-04-27 04:28:21 +02:00
parent bdaff930e0
commit dc7b1869b7
8 changed files with 32 additions and 30 deletions

View File

@ -684,7 +684,7 @@ function mob_class:do_env_damage()
self.object:set_velocity({x = 0, y = 0, z = 0}) self.object:set_velocity({x = 0, y = 0, z = 0})
-- wither rose effect -- wither rose effect
elseif self.standing_in == "mcl_flowers:wither_rose" then elseif self.standing_in == "mcl_flowers:wither_rose" then
mcl_potions.withering_func(self.object, 1, 2) mcl_potions.give_effect_by_level("withering", self.object, 2, 2)
end end
local nodef = minetest.registered_nodes[self.standing_in] local nodef = minetest.registered_nodes[self.standing_in]

View File

@ -104,11 +104,11 @@ function mcl_raids.promote_to_raidcaptain(c) -- object
mcl_raids.drop_obanner(pos) mcl_raids.drop_obanner(pos)
if cmi_cause and cmi_cause.type == "punch" and cmi_cause.puncher:is_player() then if cmi_cause and cmi_cause.type == "punch" and cmi_cause.puncher:is_player() then
awards.unlock(cmi_cause.puncher:get_player_name(), "mcl:voluntary_exile") awards.unlock(cmi_cause.puncher:get_player_name(), "mcl:voluntary_exile")
local lv = mcl_potions.get_effect(cmi_cause.puncher, "bad_omen") local lv = mcl_potions.get_effect_level(cmi_cause.puncher, "bad_omen")
if not lv then lv = 0 if not lv then lv = 0
else lv = lv.factor end else lv = lv.factor end
lv = math.max(5,lv + 1) lv = math.max(5,lv + 1)
mcl_potions.bad_omen_func(cmi_cause.puncher,lv,6000) mcl_potions.give_effect_by_level("bad_omen", cmi_cause.puncher, lv, 6000)
end end
end end
if old_ondie then return old_ondie(self,pos,cmi_cause) end if old_ondie then return old_ondie(self,pos,cmi_cause) end
@ -310,7 +310,7 @@ mcl_events.register_event("raid",{
self.mobs = {} self.mobs = {}
self.health_max = 1 self.health_max = 1
self.health = 0 self.health = 0
local lv = mcl_potions.get_effect(minetest.get_player_by_name(self.player), "bad_omen") local lv = mcl_potions.get_effect_level(minetest.get_player_by_name(self.player), "bad_omen")
if lv and lv.factor and lv.factor > 1 then self.max_stage = 6 end if lv and lv.factor and lv.factor > 1 then self.max_stage = 6 end
end, end,
cond_progress = function(self) cond_progress = function(self)

View File

@ -167,17 +167,17 @@ local function eat_gapple(itemstack, placer, pointed_thing)
return itemstack return itemstack
end end
local regen_duration, absorbtion_factor = 5, 1 local regen_duration, absorption = 5, 1
if itemstack:get_name() == "mcl_core:apple_gold_enchanted" then if itemstack:get_name() == "mcl_core:apple_gold_enchanted" then
regen_duration, absorbtion_factor = 20, 4 regen_duration, absorption = 20, 4
mcl_potions.fire_resistance_func(placer, 1, 300) mcl_potions.give_effect("fire_resistance", placer, 1, 300)
mcl_potions.leaping_func(placer, 1, 300) mcl_potions.give_effect_by_level("leaping", placer, 1, 300)
if enable_fapples then if enable_fapples then
mcl_potions.swiftness_func(placer, absorbtion_factor, 120) mcl_potions.give_effect_by_level("swiftness", placer, absorption, 120)
end end
end end
-- TODO: Absorbtion mcl_potions.give_effect_by_level("absorption", placer, absorption, 120)
mcl_potions.regeneration_func(placer, 2, regen_duration) mcl_potions.give_effect_by_level("regeneration", placer, 2, regen_duration)
return gapple_hunger_restore(itemstack, placer, pointed_thing) return gapple_hunger_restore(itemstack, placer, pointed_thing)
end end
@ -206,17 +206,17 @@ local function eat_gapple_delayed(itemstack, placer, pointed_thing)
return itemstack return itemstack
end end
local regen_duration, absorbtion_factor = 5, 1 local regen_duration, absorption = 5, 1
if itemstack:get_name() == "mcl_core:apple_gold_enchanted" then if itemstack:get_name() == "mcl_core:apple_gold_enchanted" then
regen_duration, absorbtion_factor = 20, 4 regen_duration, absorption = 20, 4
mcl_potions.fire_resistance_func(placer, 1, 300) mcl_potions.give_effect("fire_resistance", placer, 1, 300)
mcl_potions.leaping_func(placer, 1, 300) mcl_potions.give_effect_by_level("leaping", placer, 1, 300)
if enable_fapples then if enable_fapples then
mcl_potions.swiftness_func(placer, absorbtion_factor, 120) mcl_potions.give_effect_by_level("swiftness", placer, absorption, 120)
end end
end end
-- TODO: Absorbtion mcl_potions.give_effect_by_level("absorption", placer, absorption, 120)
mcl_potions.regeneration_func(placer, 2, regen_duration) mcl_potions.give_effect_by_level("regeneration", placer, 2, regen_duration)
--return gapple_hunger_restore(itemstack, placer, pointed_thing) --return gapple_hunger_restore(itemstack, placer, pointed_thing)
end end

View File

@ -142,7 +142,7 @@ minetest.register_on_item_eat(function (hp_change, replace_with_item, itemstack,
-- 60% chance of poisoning with poisonous potato -- 60% chance of poisoning with poisonous potato
if itemstack:get_name() == "mcl_farming:potato_item_poison" then if itemstack:get_name() == "mcl_farming:potato_item_poison" then
if math.random(1,10) >= 6 then if math.random(1,10) >= 6 then
mcl_potions.poison_func(user, 1, 5) mcl_potions.give_effect_by_level("poison", user, 1, 5)
end end
end end

View File

@ -519,7 +519,8 @@ minetest.register_craftitem("mcl_fishing:pufferfish_raw", {
minetest.register_on_item_eat(function (hp_change, replace_with_item, itemstack, user, pointed_thing) minetest.register_on_item_eat(function (hp_change, replace_with_item, itemstack, user, pointed_thing)
if itemstack:get_name() == "mcl_fishing:pufferfish_raw" then if itemstack:get_name() == "mcl_fishing:pufferfish_raw" then
mcl_potions.poison_func(user, 1/3, 60) mcl_potions.give_effect_by_level("poison", user, 3, 60)
mcl_potions.give_effect_by_level("nausea", user, 2, 20)
end end
end ) end )

View File

@ -580,6 +580,6 @@ minetest.register_craft({
minetest.register_on_item_eat(function (hp_change, replace_with_item, itemstack, user, pointed_thing) -- poisoning with spider eye minetest.register_on_item_eat(function (hp_change, replace_with_item, itemstack, user, pointed_thing) -- poisoning with spider eye
if itemstack:get_name() == "mcl_mobitems:spider_eye" then if itemstack:get_name() == "mcl_mobitems:spider_eye" then
mcl_potions.poison_func(user, 1, 4) mcl_potions.give_effect_by_level("poison", user, 1, 4)
end end
end) end)

View File

@ -717,6 +717,7 @@ mcl_potions.register_effect({
return S("danger is imminent") return S("danger is imminent")
end, end,
particle_color = "#472331", particle_color = "#472331",
uses_factor = true,
}) })
mcl_potions.register_effect({ mcl_potions.register_effect({

View File

@ -8,8 +8,8 @@ local eat = minetest.item_eat(6, "mcl_core:bowl") --6 hunger points, player rece
local flower_effect = { local flower_effect = {
[ "mcl_flowers:allium" ] = "fire_resistance", [ "mcl_flowers:allium" ] = "fire_resistance",
[ "mcl_flowers:lily_of_the_valley" ] = "poison", [ "mcl_flowers:lily_of_the_valley" ] = "poison",
[ "mcl_flowers:blue_orchid" ] = "hunger", [ "mcl_flowers:blue_orchid" ] = "food_poisoning",
[ "mcl_flowers:dandelion" ] = "hunger", [ "mcl_flowers:dandelion" ] = "food_poisoning",
[ "mcl_flowers:cornflower" ] = "jump", [ "mcl_flowers:cornflower" ] = "jump",
[ "mcl_flowers:oxeye_daisy" ] = "regeneration", [ "mcl_flowers:oxeye_daisy" ] = "regeneration",
[ "mcl_flowers:poppy" ] = "night_vision" [ "mcl_flowers:poppy" ] = "night_vision"
@ -17,31 +17,31 @@ local flower_effect = {
local effects = { local effects = {
[ "fire_resistance" ] = function(itemstack, placer, pointed_thing) [ "fire_resistance" ] = function(itemstack, placer, pointed_thing)
mcl_potions.fire_resistance_func(placer, 1, 4) mcl_potions.give_effect("fire_resistance", placer, 1, 4)
return eat(itemstack, placer, pointed_thing) return eat(itemstack, placer, pointed_thing)
end, end,
[ "poison" ] = function(itemstack, placer, pointed_thing) [ "poison" ] = function(itemstack, placer, pointed_thing)
mcl_potions.poison_func(placer, 1, 12) mcl_potions.give_effect_by_level("poison", placer, 1, 12)
return eat(itemstack, placer, pointed_thing) return eat(itemstack, placer, pointed_thing)
end, end,
[ "hunger" ] = function(itemstack, placer, pointed_thing, player) [ "food_poisoning" ] = function(itemstack, placer, pointed_thing, player)
mcl_hunger.item_eat(6, "mcl_core:bowl", 3.5, 0, 100) mcl_potions.give_effect_by_level("food_poisoning", placer, 10, 12)
return eat(itemstack, placer, pointed_thing) return eat(itemstack, placer, pointed_thing)
end, end,
["jump"] = function(itemstack, placer, pointed_thing) ["jump"] = function(itemstack, placer, pointed_thing)
mcl_potions.leaping_func(placer, 1, 6) mcl_potions.give_effect_by_level("leaping", placer, 1, 6)
return eat(itemstack, placer, pointed_thing) return eat(itemstack, placer, pointed_thing)
end, end,
["regeneration"] = function(itemstack, placer, pointed_thing) ["regeneration"] = function(itemstack, placer, pointed_thing)
mcl_potions.regeneration_func(placer, 1, 8) mcl_potions.give_effect_by_level("regeneration", placer, 1, 8)
return eat(itemstack, placer, pointed_thing) return eat(itemstack, placer, pointed_thing)
end, end,
["night_vision"] = function(itemstack, placer, pointed_thing) ["night_vision"] = function(itemstack, placer, pointed_thing)
mcl_potions.night_vision_func(placer, 1, 5) mcl_potions.give_effect("night_vision", placer, 1, 5)
return eat(itemstack, placer, pointed_thing) return eat(itemstack, placer, pointed_thing)
end, end,
} }