1
0
Fork 0

Add potion sprite effects when drinking

This commit is contained in:
Brandon 2020-06-18 21:04:31 -04:00
parent 70fd9db0c3
commit bd9fd780eb
3 changed files with 71 additions and 54 deletions

View File

@ -26,9 +26,27 @@ function mcl_potions.invisible(player, toggle)
end end
function mcl_potions._use_potion(item) function mcl_potions._use_potion(item, pos, color)
local d = 0.1
item:replace("mcl_potions:glass_bottle") item:replace("mcl_potions:glass_bottle")
minetest.sound_play("mcl_potions_drinking") minetest.sound_play("mcl_potions_drinking")
minetest.add_particlespawner({
amount = 25,
time = 1,
minpos = {x=pos.x-d, y=pos.y+1, z=pos.z-d},
maxpos = {x=pos.x+d, y=pos.y+2, z=pos.z+d},
minvel = {x=-0.1, y=0, z=-0.1},
maxvel = {x=0.1, y=0.1, z=0.1},
minacc = {x=-0.1, y=0, z=-0.1},
maxacc = {x=0.1, y=.1, z=0.1},
minexptime = 1,
maxexptime = 5,
minsize = 0.5,
maxsize = 2,
collisiondetection = true,
vertical = false,
texture = "mcl_potions_sprite.png^[colorize:"..color..":127",
})
end end
local is_zombie = {} local is_zombie = {}

View File

@ -23,6 +23,7 @@ minetest.register_craftitem("mcl_potions:awkward", {
on_place = minetest.item_eat(0, "mcl_potions:glass_bottle"), on_place = minetest.item_eat(0, "mcl_potions:glass_bottle"),
on_secondary_use = minetest.item_eat(0, "mcl_potions:glass_bottle"), on_secondary_use = minetest.item_eat(0, "mcl_potions:glass_bottle"),
}) })
minetest.register_craftitem("mcl_potions:mundane", { minetest.register_craftitem("mcl_potions:mundane", {
description = S("Mundane Potion"), description = S("Mundane Potion"),
_tt_help = S("No effect"), _tt_help = S("No effect"),
@ -37,7 +38,6 @@ minetest.register_craftitem("mcl_potions:mundane", {
on_secondary_use = minetest.item_eat(0, "mcl_potions:glass_bottle"), on_secondary_use = minetest.item_eat(0, "mcl_potions:glass_bottle"),
}) })
minetest.register_craftitem("mcl_potions:thick", { minetest.register_craftitem("mcl_potions:thick", {
description = S("Thick Potion"), description = S("Thick Potion"),
_tt_help = S("No effect"), _tt_help = S("No effect"),
@ -73,13 +73,13 @@ minetest.register_craftitem("mcl_potions:healing", {
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
mcl_potions.healing_func(user, 4) mcl_potions.healing_func(user, 4)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#CC0000")
return itemstack return itemstack
end, end,
on_secondary_use = function(itemstack, user, pointed_thing) on_secondary_use = function(itemstack, user, pointed_thing)
mcl_potions.healing_func(user, 4) mcl_potions.healing_func(user, 4)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#CC0000")
return itemstack return itemstack
end, end,
}) })
@ -94,13 +94,13 @@ minetest.register_craftitem("mcl_potions:healing_2", {
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
mcl_potions.healing_func(user, 8) mcl_potions.healing_func(user, 8)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#DD0000")
return itemstack return itemstack
end, end,
on_secondary_use = function(itemstack, user, pointed_thing) on_secondary_use = function(itemstack, user, pointed_thing)
mcl_potions.healing_func(user, 8) mcl_potions.healing_func(user, 8)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#DD0000")
return itemstack return itemstack
end, end,
@ -116,13 +116,13 @@ minetest.register_craftitem("mcl_potions:harming", {
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
mcl_potions.healing_func(user, -6) mcl_potions.healing_func(user, -6)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#660099")
return itemstack return itemstack
end, end,
on_secondary_use = function(itemstack, user, pointed_thing) on_secondary_use = function(itemstack, user, pointed_thing)
mcl_potions.healing_func(user, -6) mcl_potions.healing_func(user, -6)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#660099")
return itemstack return itemstack
end, end,
}) })
@ -137,13 +137,13 @@ minetest.register_craftitem("mcl_potions:harming_2", {
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
mcl_potions.healing_func(user, -12) mcl_potions.healing_func(user, -12)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#330066")
return itemstack return itemstack
end, end,
on_secondary_use = function(itemstack, user, pointed_thing) on_secondary_use = function(itemstack, user, pointed_thing)
mcl_potions.healing_func(user, -12) mcl_potions.healing_func(user, -12)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#330066")
return itemstack return itemstack
end, end,
}) })
@ -169,13 +169,13 @@ minetest.register_craftitem("mcl_potions:swiftness", {
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
mcl_potions.swiftness_func(user, 1.2, 180) mcl_potions.swiftness_func(user, 1.2, 180)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#009999")
return itemstack return itemstack
end, end,
on_secondary_use = function(itemstack, user, pointed_thing) on_secondary_use = function(itemstack, user, pointed_thing)
mcl_potions.swiftness_func(user, 1.2, 180) mcl_potions.swiftness_func(user, 1.2, 180)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#009999")
return itemstack return itemstack
end, end,
}) })
@ -190,13 +190,13 @@ minetest.register_craftitem("mcl_potions:swiftness_2", {
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
mcl_potions.swiftness_func(user, 1.4, 90) mcl_potions.swiftness_func(user, 1.4, 90)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#00BBBB")
return itemstack return itemstack
end, end,
on_secondary_use = function(itemstack, user, pointed_thing) on_secondary_use = function(itemstack, user, pointed_thing)
mcl_potions.swiftness_func(user, 1.4, 90) mcl_potions.swiftness_func(user, 1.4, 90)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#00BBBB")
return itemstack return itemstack
end, end,
}) })
@ -211,13 +211,13 @@ minetest.register_craftitem("mcl_potions:swiftness_plus", {
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
mcl_potions.swiftness_func(user, 1.2, 480) mcl_potions.swiftness_func(user, 1.2, 480)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#00AAAA")
return itemstack return itemstack
end, end,
on_secondary_use = function(itemstack, user, pointed_thing) on_secondary_use = function(itemstack, user, pointed_thing)
mcl_potions.swiftness_func(user, 1.2, 480) mcl_potions.swiftness_func(user, 1.2, 480)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#00AAAA")
return itemstack return itemstack
end, end,
}) })
@ -232,13 +232,13 @@ minetest.register_craftitem("mcl_potions:slowness", {
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
mcl_potions.swiftness_func(user, 0.85, 90) mcl_potions.swiftness_func(user, 0.85, 90)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#000080")
return itemstack return itemstack
end, end,
on_secondary_use = function(itemstack, user, pointed_thing) on_secondary_use = function(itemstack, user, pointed_thing)
mcl_potions.swiftness_func(user, 0.85, 90) mcl_potions.swiftness_func(user, 0.85, 90)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#000080")
return itemstack return itemstack
end, end,
}) })
@ -253,13 +253,13 @@ minetest.register_craftitem("mcl_potions:slowness_plus", {
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
mcl_potions.swiftness_func(user, 0.85, 240) mcl_potions.swiftness_func(user, 0.85, 240)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#000066")
return itemstack return itemstack
end, end,
on_secondary_use = function(itemstack, user, pointed_thing) on_secondary_use = function(itemstack, user, pointed_thing)
mcl_potions.swiftness_func(user, 0.85, 240) mcl_potions.swiftness_func(user, 0.85, 240)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#000066")
return itemstack return itemstack
end, end,
}) })
@ -275,13 +275,13 @@ minetest.register_craftitem("mcl_potions:leaping", {
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
mcl_potions.leaping_func(user, 1.2, 180) mcl_potions.leaping_func(user, 1.2, 180)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#00CC33")
return itemstack return itemstack
end, end,
on_secondary_use = function(itemstack, user, pointed_thing) on_secondary_use = function(itemstack, user, pointed_thing)
mcl_potions.leaping_func(user, 1.2, 180) mcl_potions.leaping_func(user, 1.2, 180)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#00CC33")
return itemstack return itemstack
end, end,
}) })
@ -296,13 +296,13 @@ minetest.register_craftitem("mcl_potions:leaping_2", {
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
mcl_potions.leaping_func(user, 1.4, 90) mcl_potions.leaping_func(user, 1.4, 90)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#00EE33")
return itemstack return itemstack
end, end,
on_secondary_use = function(itemstack, user, pointed_thing) on_secondary_use = function(itemstack, user, pointed_thing)
mcl_potions.leaping_func(user, 1.4, 90) mcl_potions.leaping_func(user, 1.4, 90)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#00EE33")
return itemstack return itemstack
end, end,
}) })
@ -317,13 +317,13 @@ minetest.register_craftitem("mcl_potions:leaping_plus", {
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
mcl_potions.leaping_func(user, 1.2, 480) mcl_potions.leaping_func(user, 1.2, 480)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#00DD33")
return itemstack return itemstack
end, end,
on_secondary_use = function(itemstack, user, pointed_thing) on_secondary_use = function(itemstack, user, pointed_thing)
mcl_potions.leaping_func(user, 1.2, 480) mcl_potions.leaping_func(user, 1.2, 480)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#00DD33")
return itemstack return itemstack
end, end,
}) })
@ -339,13 +339,13 @@ minetest.register_craftitem("mcl_potions:weakness", {
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
mcl_potions.weakness_func(user, 1.2, 90) mcl_potions.weakness_func(user, 1.2, 90)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#6600AA")
return itemstack return itemstack
end, end,
on_secondary_use = function(itemstack, user, pointed_thing) on_secondary_use = function(itemstack, user, pointed_thing)
mcl_potions.weakness_func(user, 1.2, 90) mcl_potions.weakness_func(user, 1.2, 90)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#6600AA")
return itemstack return itemstack
end end
}) })
@ -360,13 +360,13 @@ minetest.register_craftitem("mcl_potions:weakness_plus", {
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
mcl_potions.weakness_func(user, 1.4, 240) mcl_potions.weakness_func(user, 1.4, 240)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#7700BB")
return itemstack return itemstack
end, end,
on_secondary_use = function(itemstack, user, pointed_thing) on_secondary_use = function(itemstack, user, pointed_thing)
mcl_potions.weakness_func(user, 1.4, 240) mcl_potions.weakness_func(user, 1.4, 240)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#7700BB")
return itemstack return itemstack
end end
}) })
@ -382,13 +382,13 @@ minetest.register_craftitem("mcl_potions:poison", {
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
mcl_potions.poison_func(user, 2.5, 45) mcl_potions.poison_func(user, 2.5, 45)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#225533")
return itemstack return itemstack
end, end,
on_secondary_use = function(itemstack, user, pointed_thing) on_secondary_use = function(itemstack, user, pointed_thing)
mcl_potions.poison_func(user, 2.5, 45) mcl_potions.poison_func(user, 2.5, 45)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#225533")
return itemstack return itemstack
end end
}) })
@ -403,13 +403,13 @@ minetest.register_craftitem("mcl_potions:poison_2", {
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
mcl_potions.poison_func(user, 1.2, 21) mcl_potions.poison_func(user, 1.2, 21)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#447755")
return itemstack return itemstack
end, end,
on_secondary_use = function(itemstack, user, pointed_thing) on_secondary_use = function(itemstack, user, pointed_thing)
mcl_potions.poison_func(user, 1.2, 21) mcl_potions.poison_func(user, 1.2, 21)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#447755")
return itemstack return itemstack
end end
}) })
@ -424,13 +424,13 @@ minetest.register_craftitem("mcl_potions:poison_plus", {
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
mcl_potions.poison_func(user, 2.5, 90) mcl_potions.poison_func(user, 2.5, 90)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#336644")
return itemstack return itemstack
end, end,
on_secondary_use = function(itemstack, user, pointed_thing) on_secondary_use = function(itemstack, user, pointed_thing)
mcl_potions.poison_func(user, 2.5, 90) mcl_potions.poison_func(user, 2.5, 90)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#336644")
return itemstack return itemstack
end end
}) })
@ -446,13 +446,13 @@ minetest.register_craftitem("mcl_potions:regeneration", {
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
mcl_potions.regeneration_func(user, 2.5, 45) mcl_potions.regeneration_func(user, 2.5, 45)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#A52BB2")
return itemstack return itemstack
end, end,
on_secondary_use = function(itemstack, user, pointed_thing) on_secondary_use = function(itemstack, user, pointed_thing)
mcl_potions.regeneration_func(user, 2.5, 45) mcl_potions.regeneration_func(user, 2.5, 45)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#A52BB2")
return itemstack return itemstack
end end
}) })
@ -467,13 +467,13 @@ minetest.register_craftitem("mcl_potions:regeneration_2", {
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
mcl_potions.regeneration_func(user, 1.2, 22) mcl_potions.regeneration_func(user, 1.2, 22)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#B52CC2")
return itemstack return itemstack
end, end,
on_secondary_use = function(itemstack, user, pointed_thing) on_secondary_use = function(itemstack, user, pointed_thing)
mcl_potions.regeneration_func(user, 1.2, 22) mcl_potions.regeneration_func(user, 1.2, 22)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#B52CC2")
return itemstack return itemstack
end end
}) })
@ -488,13 +488,13 @@ minetest.register_craftitem("mcl_potions:regeneration_plus", {
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
mcl_potions.regeneration_func(user, 2.5, 90) mcl_potions.regeneration_func(user, 2.5, 90)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#C53DD3")
return itemstack return itemstack
end, end,
on_secondary_use = function(itemstack, user, pointed_thing) on_secondary_use = function(itemstack, user, pointed_thing)
mcl_potions.regeneration_func(user, 2.5, 90) mcl_potions.regeneration_func(user, 2.5, 90)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#C53DD3")
return itemstack return itemstack
end end
}) })
@ -510,13 +510,13 @@ minetest.register_craftitem("mcl_potions:invisibility", {
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
mcl_potions.invisiblility_func(user, 180) mcl_potions.invisiblility_func(user, 180)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#B0B0B0")
return itemstack return itemstack
end, end,
on_secondary_use = function(itemstack, user, pointed_thing) on_secondary_use = function(itemstack, user, pointed_thing)
mcl_potions.invisiblility_func(user, 180) mcl_potions.invisiblility_func(user, 180)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#B0B0B0")
return itemstack return itemstack
end end
}) })
@ -531,13 +531,13 @@ minetest.register_craftitem("mcl_potions:invisibility_plus", {
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
mcl_potions.invisiblility_func(user, 480) mcl_potions.invisiblility_func(user, 480)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#A0A0A0")
return itemstack return itemstack
end, end,
on_secondary_use = function(itemstack, user, pointed_thing) on_secondary_use = function(itemstack, user, pointed_thing)
mcl_potions.invisiblility_func(user, 480) mcl_potions.invisiblility_func(user, 480)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#A0A0A0")
return itemstack return itemstack
end end
}) })
@ -560,13 +560,13 @@ minetest.register_craftitem("mcl_potions:water_breathing", {
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
mcl_potions.water_breathing_func(user, 180) mcl_potions.water_breathing_func(user, 180)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#0000AA")
return itemstack return itemstack
end, end,
on_secondary_use = function(itemstack, user, pointed_thing) on_secondary_use = function(itemstack, user, pointed_thing)
mcl_potions.water_breathing_func(user, 180) mcl_potions.water_breathing_func(user, 180)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#0000AA")
return itemstack return itemstack
end end
}) })
@ -581,13 +581,13 @@ minetest.register_craftitem("mcl_potions:water_breathing_plus", {
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
mcl_potions.water_breathing_func(user, 480) mcl_potions.water_breathing_func(user, 480)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#0000CC")
return itemstack return itemstack
end, end,
on_secondary_use = function(itemstack, user, pointed_thing) on_secondary_use = function(itemstack, user, pointed_thing)
mcl_potions.water_breathing_func(user, 480) mcl_potions.water_breathing_func(user, 480)
mcl_potions._use_potion(itemstack) mcl_potions._use_potion(itemstack, user:get_pos(), "#0000CC")
return itemstack return itemstack
end end
}) })

View File

@ -12,13 +12,12 @@ local function register_splash(name, descr, color, def)
description = descr, description = descr,
inventory_image = splash_image(color), inventory_image = splash_image(color),
on_use = function(item, placer, pointed_thing) on_use = function(item, placer, pointed_thing)
--weapons_shot(itemstack, placer, pointed_thing, def.velocity, name)
local velocity = 10 local velocity = 10
local dir = placer:get_look_dir(); local dir = placer:get_look_dir();
local pos = placer:getpos(); local pos = placer:get_pos();
local obj = minetest.env:add_entity({x=pos.x+dir.x,y=pos.y+2+dir.y,z=pos.z+dir.z}, id.."_flying") local obj = minetest.env:add_entity({x=pos.x+dir.x,y=pos.y+2+dir.y,z=pos.z+dir.z}, id.."_flying")
obj:setvelocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity}) obj:set_velocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity})
obj:setacceleration({x=0, y=-9.8, z=0}) obj:set_acceleration({x=0, y=-9.8, z=0})
item:take_item() item:take_item()
return item return item
end, end,