forked from epCode/extra_mobs
trading for piglin update
This commit is contained in:
parent
34cb3aa0da
commit
b815502b66
Binary file not shown.
41
piglin.lua
41
piglin.lua
|
@ -7,6 +7,15 @@ local trading_items = {
|
||||||
{ itemstring = "mcl_core:obsidian", amount_min = 1, amount_max = 1 },
|
{ itemstring = "mcl_core:obsidian", amount_min = 1, amount_max = 1 },
|
||||||
{ itemstring = "mcl_core:gravel", amount_min = 8, amount_max = 16 },
|
{ itemstring = "mcl_core:gravel", amount_min = 8, amount_max = 16 },
|
||||||
{ itemstring = "mcl_mobitems:leather", amount_min = 4, amount_max = 10 },
|
{ itemstring = "mcl_mobitems:leather", amount_min = 4, amount_max = 10 },
|
||||||
|
{ itemstring = "mcl_nether:soul_sand", amount_min = 4, amount_max = 16 },
|
||||||
|
{ itemstring = "mcl_nether:nether_brick", amount_min = 4, amount_max = 16 },
|
||||||
|
{ itemstring = "mcl_mobitems:string", amount_min = 3, amount_max = 9 },
|
||||||
|
{ itemstring = "mcl_nether:quartz", amount_min = 4, amount_max = 10 },
|
||||||
|
{ itemstring = "mcl_potions:water", amount_min = 1, amount_max = 1 },
|
||||||
|
{ itemstring = "mcl_core:iron_nugget", amount_min = 10, amount_max = 36 },
|
||||||
|
{ itemstring = "mcl_throwing:ender_pearl", amount_min = 2, amount_max = 6 },
|
||||||
|
{ itemstring = "mcl_potions:fire_resistance", amount_min = 1, amount_max = 1 },
|
||||||
|
{ itemstring = "mcl_potions:fire_resistance_splash", amount_min = 1, amount_max = 1 },
|
||||||
}
|
}
|
||||||
|
|
||||||
local S = minetest.get_translator("extra_mobs")
|
local S = minetest.get_translator("extra_mobs")
|
||||||
|
@ -65,7 +74,6 @@ local piglin = {
|
||||||
on_spawn = function(self)
|
on_spawn = function(self)
|
||||||
self.gold_items = 0
|
self.gold_items = 0
|
||||||
self.weapon = self.base_texture[2]
|
self.weapon = self.base_texture[2]
|
||||||
self.object:set_bone_position("Wield_Item", vector.new(-1.5,7,1.5), vector.new(170,90,90))
|
|
||||||
end,
|
end,
|
||||||
do_custom = function(self)
|
do_custom = function(self)
|
||||||
if self.trading == true then
|
if self.trading == true then
|
||||||
|
@ -75,6 +83,7 @@ local piglin = {
|
||||||
self.base_texture[2] = "default_gold_ingot.png"
|
self.base_texture[2] = "default_gold_ingot.png"
|
||||||
self.object:set_properties({textures = self.base_texture})
|
self.object:set_properties({textures = self.base_texture})
|
||||||
else
|
else
|
||||||
|
self.object:set_bone_position("Wield_Item", vector.new(-1.5,7,1.5), vector.new(170,90,90))
|
||||||
self.base_texture[2] = self.weapon
|
self.base_texture[2] = self.weapon
|
||||||
self.object:set_properties({textures = self.base_texture})
|
self.object:set_properties({textures = self.base_texture})
|
||||||
self.object:set_bone_position("Head", vector.new(0,6.3,0), vector.new(0,0,0))
|
self.object:set_bone_position("Head", vector.new(0,6.3,0), vector.new(0,0,0))
|
||||||
|
@ -97,20 +106,22 @@ local piglin = {
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_rightclick = function(self, clicker)
|
on_rightclick = function(self, clicker)
|
||||||
if clicker:is_player() and clicker:get_wielded_item():get_name() == "mcl_core:gold_ingot" and self.state ~= "attack" then
|
if clicker:is_player() and clicker:get_wielded_item():get_name() == "mcl_core:gold_ingot" and self.state ~= "attack" and self.gold_items < 3 then
|
||||||
local item_gold = clicker:get_wielded_item()
|
local item_gold = clicker:get_wielded_item()
|
||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
mobs:set_animation(self, "stand")
|
self.object:set_animation({x=0,y=79})
|
||||||
item_gold:take_item()
|
item_gold:take_item(1)
|
||||||
|
clicker:set_wielded_item(item)
|
||||||
self.trading = true
|
self.trading = true
|
||||||
self.gold_items = self.gold_items + 1
|
self.gold_items = self.gold_items + 1
|
||||||
|
self.object:set_bone_position("Wield_Item", vector.new(-1.5,4.9,1.8), vector.new(135,0,90))
|
||||||
minetest.after(5, function()
|
minetest.after(5, function()
|
||||||
self.gold_items = self.gold_items - 1
|
self.gold_items = self.gold_items - 1
|
||||||
if self.gold_items == 0 then
|
if self.gold_items == 0 then
|
||||||
self.trading = false
|
self.trading = false
|
||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
end
|
end
|
||||||
self.object:get_pos() = clicker:get_pos()
|
local c_pos = self.object:get_pos()
|
||||||
self.what_traded = trading_items[math.random(#trading_items)]
|
self.what_traded = trading_items[math.random(#trading_items)]
|
||||||
for x = 1, math.random(self.what_traded.amount_min, self.what_traded.amount_max) do
|
for x = 1, math.random(self.what_traded.amount_min, self.what_traded.amount_max) do
|
||||||
minetest.add_item({x=math.random(c_pos.x - 1, c_pos.x + 1), y=math.random(c_pos.y - 1, c_pos.y + 1), z= math.random(c_pos.z - 1, c_pos.z + 1)}, self.what_traded.itemstring)
|
minetest.add_item({x=math.random(c_pos.x - 1, c_pos.x + 1), y=math.random(c_pos.y - 1, c_pos.y + 1), z= math.random(c_pos.z - 1, c_pos.z + 1)}, self.what_traded.itemstring)
|
||||||
|
@ -142,10 +153,12 @@ mobs:register_mob("extra_mobs:piglin", piglin)
|
||||||
|
|
||||||
|
|
||||||
local sword_piglin = table.copy(piglin)
|
local sword_piglin = table.copy(piglin)
|
||||||
sword_piglin.mesh = "mcl_armor_character.b3d"
|
sword_piglin.mesh = "extra_mobs_sword_piglin.b3d"
|
||||||
sword_piglin.textures = {"extra_mobs_sword_piglin.png", "default_tool_goldsword.png", "extra_mobs_trans.png"}
|
sword_piglin.textures = {"extra_mobs_piglin.png", "default_tool_goldsword.png"}
|
||||||
sword_piglin.on_spawn = function()
|
sword_piglin.on_spawn = function(self)
|
||||||
return
|
self.gold_items = 0
|
||||||
|
self.weapon = self.base_texture[2]
|
||||||
|
self.object:set_bone_position("Wield_Item", vector.new(0,3.9,1.3), vector.new(90,0,0))
|
||||||
end
|
end
|
||||||
sword_piglin.attack_type = "dogfight"
|
sword_piglin.attack_type = "dogfight"
|
||||||
sword_piglin.animation = {
|
sword_piglin.animation = {
|
||||||
|
@ -173,13 +186,13 @@ zombified_piglin.attacks_monsters = true
|
||||||
zombified_piglin.lava_damage = 0
|
zombified_piglin.lava_damage = 0
|
||||||
zombified_piglin.fire_damage = 0
|
zombified_piglin.fire_damage = 0
|
||||||
zombified_piglin.attack_animals = true
|
zombified_piglin.attack_animals = true
|
||||||
sword_piglin.mesh = "mcl_armor_character.b3d"
|
zombified_piglin.mesh = "extra_mobs_sword_piglin.b3d"
|
||||||
sword_piglin.textures = {"extra_mobs_zombified_piglin.png", "default_tool_goldsword.png", "extra_mobs_trans.png"}
|
zombified_piglin.textures = {"extra_mobs_zombified_piglin.png", "default_tool_goldsword.png", "extra_mobs_trans.png"}
|
||||||
sword_piglin.on_spawn = function()
|
zombified_piglin.on_spawn = function()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
sword_piglin.attack_type = "dogfight"
|
zombified_piglin.attack_type = "dogfight"
|
||||||
sword_piglin.animation = {
|
zombified_piglin.animation = {
|
||||||
stand_speed = 30,
|
stand_speed = 30,
|
||||||
walk_speed = 30,
|
walk_speed = 30,
|
||||||
punch_speed = 45,
|
punch_speed = 45,
|
||||||
|
|
Loading…
Reference in New Issue