mirror of
https://git.minetest.land/Mineclonia/Mineclonia.git
synced 2024-11-28 06:22:59 +00:00
Add potion sprite effects when drinking
This commit is contained in:
parent
70fd9db0c3
commit
bd9fd780eb
3 changed files with 71 additions and 54 deletions
|
@ -26,9 +26,27 @@ function mcl_potions.invisible(player, toggle)
|
|||
|
||||
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")
|
||||
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
|
||||
|
||||
local is_zombie = {}
|
||||
|
|
|
@ -23,6 +23,7 @@ minetest.register_craftitem("mcl_potions:awkward", {
|
|||
on_place = 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", {
|
||||
description = S("Mundane Potion"),
|
||||
_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"),
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craftitem("mcl_potions:thick", {
|
||||
description = S("Thick Potion"),
|
||||
_tt_help = S("No effect"),
|
||||
|
@ -73,13 +73,13 @@ minetest.register_craftitem("mcl_potions:healing", {
|
|||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.healing_func(user, 4)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#CC0000")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.healing_func(user, 4)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#CC0000")
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
@ -94,13 +94,13 @@ minetest.register_craftitem("mcl_potions:healing_2", {
|
|||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.healing_func(user, 8)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#DD0000")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.healing_func(user, 8)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#DD0000")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
|
@ -116,13 +116,13 @@ minetest.register_craftitem("mcl_potions:harming", {
|
|||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.healing_func(user, -6)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#660099")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.healing_func(user, -6)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#660099")
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
@ -137,13 +137,13 @@ minetest.register_craftitem("mcl_potions:harming_2", {
|
|||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.healing_func(user, -12)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#330066")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.healing_func(user, -12)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#330066")
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
@ -169,13 +169,13 @@ minetest.register_craftitem("mcl_potions:swiftness", {
|
|||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.swiftness_func(user, 1.2, 180)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#009999")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.swiftness_func(user, 1.2, 180)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#009999")
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
@ -190,13 +190,13 @@ minetest.register_craftitem("mcl_potions:swiftness_2", {
|
|||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.swiftness_func(user, 1.4, 90)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#00BBBB")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.swiftness_func(user, 1.4, 90)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#00BBBB")
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
@ -211,13 +211,13 @@ minetest.register_craftitem("mcl_potions:swiftness_plus", {
|
|||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.swiftness_func(user, 1.2, 480)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#00AAAA")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.swiftness_func(user, 1.2, 480)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#00AAAA")
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
@ -232,13 +232,13 @@ minetest.register_craftitem("mcl_potions:slowness", {
|
|||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.swiftness_func(user, 0.85, 90)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#000080")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.swiftness_func(user, 0.85, 90)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#000080")
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
@ -253,13 +253,13 @@ minetest.register_craftitem("mcl_potions:slowness_plus", {
|
|||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.swiftness_func(user, 0.85, 240)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#000066")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.swiftness_func(user, 0.85, 240)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#000066")
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
@ -275,13 +275,13 @@ minetest.register_craftitem("mcl_potions:leaping", {
|
|||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.leaping_func(user, 1.2, 180)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#00CC33")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.leaping_func(user, 1.2, 180)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#00CC33")
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
@ -296,13 +296,13 @@ minetest.register_craftitem("mcl_potions:leaping_2", {
|
|||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.leaping_func(user, 1.4, 90)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#00EE33")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.leaping_func(user, 1.4, 90)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#00EE33")
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
@ -317,13 +317,13 @@ minetest.register_craftitem("mcl_potions:leaping_plus", {
|
|||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.leaping_func(user, 1.2, 480)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#00DD33")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.leaping_func(user, 1.2, 480)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#00DD33")
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
@ -339,13 +339,13 @@ minetest.register_craftitem("mcl_potions:weakness", {
|
|||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.weakness_func(user, 1.2, 90)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#6600AA")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.weakness_func(user, 1.2, 90)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#6600AA")
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
@ -360,13 +360,13 @@ minetest.register_craftitem("mcl_potions:weakness_plus", {
|
|||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.weakness_func(user, 1.4, 240)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#7700BB")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.weakness_func(user, 1.4, 240)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#7700BB")
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
@ -382,13 +382,13 @@ minetest.register_craftitem("mcl_potions:poison", {
|
|||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.poison_func(user, 2.5, 45)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#225533")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.poison_func(user, 2.5, 45)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#225533")
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
@ -403,13 +403,13 @@ minetest.register_craftitem("mcl_potions:poison_2", {
|
|||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.poison_func(user, 1.2, 21)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#447755")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.poison_func(user, 1.2, 21)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#447755")
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
@ -424,13 +424,13 @@ minetest.register_craftitem("mcl_potions:poison_plus", {
|
|||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.poison_func(user, 2.5, 90)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#336644")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.poison_func(user, 2.5, 90)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#336644")
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
@ -446,13 +446,13 @@ minetest.register_craftitem("mcl_potions:regeneration", {
|
|||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.regeneration_func(user, 2.5, 45)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#A52BB2")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.regeneration_func(user, 2.5, 45)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#A52BB2")
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
@ -467,13 +467,13 @@ minetest.register_craftitem("mcl_potions:regeneration_2", {
|
|||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.regeneration_func(user, 1.2, 22)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#B52CC2")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.regeneration_func(user, 1.2, 22)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#B52CC2")
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
@ -488,13 +488,13 @@ minetest.register_craftitem("mcl_potions:regeneration_plus", {
|
|||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.regeneration_func(user, 2.5, 90)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#C53DD3")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.regeneration_func(user, 2.5, 90)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#C53DD3")
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
@ -510,13 +510,13 @@ minetest.register_craftitem("mcl_potions:invisibility", {
|
|||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.invisiblility_func(user, 180)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#B0B0B0")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.invisiblility_func(user, 180)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#B0B0B0")
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
@ -531,13 +531,13 @@ minetest.register_craftitem("mcl_potions:invisibility_plus", {
|
|||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.invisiblility_func(user, 480)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#A0A0A0")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.invisiblility_func(user, 480)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#A0A0A0")
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
@ -560,13 +560,13 @@ minetest.register_craftitem("mcl_potions:water_breathing", {
|
|||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.water_breathing_func(user, 180)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#0000AA")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.water_breathing_func(user, 180)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#0000AA")
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
@ -581,13 +581,13 @@ minetest.register_craftitem("mcl_potions:water_breathing_plus", {
|
|||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.water_breathing_func(user, 480)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#0000CC")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.water_breathing_func(user, 480)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
mcl_potions._use_potion(itemstack, user:get_pos(), "#0000CC")
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
|
|
@ -12,13 +12,12 @@ local function register_splash(name, descr, color, def)
|
|||
description = descr,
|
||||
inventory_image = splash_image(color),
|
||||
on_use = function(item, placer, pointed_thing)
|
||||
--weapons_shot(itemstack, placer, pointed_thing, def.velocity, name)
|
||||
local velocity = 10
|
||||
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")
|
||||
obj:setvelocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity})
|
||||
obj:setacceleration({x=0, y=-9.8, z=0})
|
||||
obj:set_velocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity})
|
||||
obj:set_acceleration({x=0, y=-9.8, z=0})
|
||||
item:take_item()
|
||||
return item
|
||||
end,
|
||||
|
|
Loading…
Reference in a new issue