add spider, move weapon sounds and wear to process_weapon function
This commit is contained in:
parent
440cdbf593
commit
019f237927
81
api.lua
81
api.lua
@ -507,12 +507,6 @@ function mobs:register_mob(name, def)
|
||||
full_punch_interval=1.0,
|
||||
damage_groups = {fleshy=self.damage}
|
||||
}, vec)
|
||||
if math.random(0,3) == 3 and self.attack.player:is_player() then
|
||||
local snum = math.random(1,4)
|
||||
minetest.sound_play("default_hurt"..tostring(snum),{
|
||||
object = self.attack.player,
|
||||
})
|
||||
end
|
||||
if self.attack.player:get_hp() <= 0 then
|
||||
self.state = "stand"
|
||||
self:set_animation("stand")
|
||||
@ -624,23 +618,7 @@ function mobs:register_mob(name, def)
|
||||
|
||||
on_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
||||
|
||||
local weapon = hitter:get_wielded_item()
|
||||
if tool_capabilities ~= nil then
|
||||
local wear = ( tool_capabilities.full_punch_interval / 75 ) * 65535
|
||||
weapon:add_wear(wear)
|
||||
hitter:set_wielded_item(weapon)
|
||||
end
|
||||
|
||||
if weapon:get_definition().sounds ~= nil then
|
||||
local s = math.random(0,#weapon:get_definition().sounds)
|
||||
minetest.sound_play(weapon:get_definition().sounds[s], {
|
||||
object=hitter,
|
||||
})
|
||||
else
|
||||
minetest.sound_play("default_sword_wood", {
|
||||
object = hitter,
|
||||
})
|
||||
end
|
||||
process_weapon(hitter,tflp,tool_capabilities)
|
||||
|
||||
local pos = self.object:getpos()
|
||||
if self.object:get_hp() <= 0 then
|
||||
@ -715,7 +693,7 @@ function mobs:register_mob(name, def)
|
||||
end
|
||||
|
||||
mobs.spawning_mobs = {}
|
||||
function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_object_count, max_height, spawn_func)
|
||||
function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_object_count, max_height, min_dist, max_dist, spawn_func)
|
||||
mobs.spawning_mobs[name] = true
|
||||
minetest.register_abm({
|
||||
nodenames = nodes,
|
||||
@ -723,7 +701,9 @@ function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_o
|
||||
interval = 30,
|
||||
chance = chance,
|
||||
action = function(pos, node, _, active_object_count_wider)
|
||||
print("Spawning mob "..name.." at "..minetest.pos_to_string(pos))
|
||||
if active_object_count_wider > active_object_count then
|
||||
print("Too many "..tostring(active_object_count_wider))
|
||||
return
|
||||
end
|
||||
if not mobs.spawning_mobs[name] then
|
||||
@ -741,28 +721,52 @@ function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_o
|
||||
|
||||
pos.y = pos.y+1
|
||||
if not minetest.get_node_light(pos) then
|
||||
print("Too much light 1")
|
||||
return
|
||||
end
|
||||
if minetest.get_node_light(pos) > max_light then
|
||||
print("Too much light 2")
|
||||
return
|
||||
end
|
||||
if minetest.get_node_light(pos) < min_light then
|
||||
print("Too much light 3")
|
||||
return
|
||||
end
|
||||
if pos.y > max_height then
|
||||
print("Too high")
|
||||
return
|
||||
end
|
||||
|
||||
if minetest.registered_nodes[minetest.get_node(pos).name].walkable == true or minetest.registered_nodes[minetest.get_node(pos).name].walkable == nil then
|
||||
print("In node")
|
||||
return
|
||||
end
|
||||
|
||||
pos.y = pos.y+1
|
||||
if minetest.registered_nodes[minetest.get_node(pos).name].walkable == true or minetest.registered_nodes[minetest.get_node(pos).name].walkable == nil then
|
||||
print("in node")
|
||||
return
|
||||
end
|
||||
|
||||
if min_dist == nil then
|
||||
min_dist = {x=-1,z=-1}
|
||||
end
|
||||
if max_dist == nil then
|
||||
max_dist = {x=33000,z=33000}
|
||||
end
|
||||
|
||||
if math.abs(pos.x) < min_dist.x or math.abs(pos.z) < min_dist.z then
|
||||
print("Too close")
|
||||
return
|
||||
end
|
||||
|
||||
if math.abs(pos.x) > max_dist.x or math.abs(pos.z) > max_dist.z then
|
||||
print("Too far")
|
||||
return
|
||||
end
|
||||
|
||||
if spawn_func and not spawn_func(pos, node) then
|
||||
print("Exec spawn function")
|
||||
return
|
||||
end
|
||||
|
||||
@ -802,11 +806,9 @@ function mobs:register_arrow(name, def)
|
||||
end
|
||||
pos.y = pos.y-1
|
||||
for _,player in pairs(minetest.get_objects_inside_radius(pos, 1)) do
|
||||
if player:is_player() then
|
||||
self.hit_player(self, player)
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
self.hit_player(self, player)
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
end
|
||||
})
|
||||
@ -842,3 +844,24 @@ blood_particles = function(pos,offset,amount,texture)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
function process_weapon(player, time_from_last_punch, tool_capabilities)
|
||||
local weapon = player:get_wielded_item()
|
||||
if tool_capabilities ~= nil then
|
||||
local wear = ( tool_capabilities.full_punch_interval / 75 ) * 65535
|
||||
weapon:add_wear(wear)
|
||||
player:set_wielded_item(weapon)
|
||||
end
|
||||
|
||||
if weapon:get_definition().sounds ~= nil then
|
||||
local s = math.random(0,#weapon:get_definition().sounds)
|
||||
minetest.sound_play(weapon:get_definition().sounds[s], {
|
||||
object=player,
|
||||
})
|
||||
else
|
||||
minetest.sound_play("default_sword_wood", {
|
||||
object = player,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
|
64
init.lua
64
init.lua
@ -61,6 +61,9 @@ mobs:register_mob("mobs:dirt_monster", {
|
||||
death = "mob_death",
|
||||
},
|
||||
step = 0.5,
|
||||
blood_amount=30,
|
||||
blood_offset=.25,
|
||||
blood_texture = "default_dirt.png",
|
||||
})
|
||||
|
||||
mobs:register_mob("mobs:dirt_monster2", {
|
||||
@ -110,6 +113,9 @@ mobs:register_mob("mobs:dirt_monster2", {
|
||||
death = "mob_death1",
|
||||
},
|
||||
step = 0.5,
|
||||
blood_amount=30,
|
||||
blood_offset=.25,
|
||||
blood_texture = "default_dirt.png",
|
||||
})
|
||||
|
||||
mobs:register_spawn("mobs:dirt_monster", {"default:dirt_with_grass"}, 3, -1, 5000, 3, 31000)
|
||||
@ -599,13 +605,6 @@ mobs:register_arrow("mobs:fireball", {
|
||||
damage_groups = {fleshy=4},
|
||||
}, vec)
|
||||
|
||||
local snum = math.random(1,4)
|
||||
minetest.sound_play("default_hurt"..tostring(snum),{
|
||||
pos = p,
|
||||
max_hear_distance = 50,
|
||||
gain = 10,
|
||||
})
|
||||
|
||||
local pos = self.object:getpos()
|
||||
for dx=-1,1 do
|
||||
for dy=-1,1 do
|
||||
@ -867,3 +866,54 @@ mobs:register_mob("mobs:male3_npc", male3)
|
||||
if minetest.setting_get("log_mods") then
|
||||
minetest.log("action", "mobs loaded")
|
||||
end
|
||||
|
||||
mobs:register_mob("mobs:spider",{
|
||||
type = "monster",
|
||||
hp_min = 15,
|
||||
hp_max = 40,
|
||||
exp_min = 3,
|
||||
exp_max = 20,
|
||||
collisionbox = {-0.9, -0.01, -0.7, 0.7, 0.6, 0.7},
|
||||
textures = {"mobs_spider.png"},
|
||||
visual_size = {x=7,y=7},
|
||||
visual = "mesh",
|
||||
mesh = "mobs_spider.x",
|
||||
makes_footstep_sound = true,
|
||||
view_range = 15,
|
||||
walk_velocity = 1,
|
||||
run_velocity = 3,
|
||||
armor = 200,
|
||||
damage = 3,
|
||||
drops = {
|
||||
{name = "farming:string",
|
||||
chance = 70,
|
||||
min = 3,
|
||||
max = 6,},
|
||||
},
|
||||
light_resistant = false,
|
||||
drawtype = "front",
|
||||
water_damage = 5,
|
||||
lava_damage = 5,
|
||||
light_damage = 0,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
speed_normal = 15,
|
||||
speed_run = 15,
|
||||
stand_start = 1,
|
||||
stand_end = 1,
|
||||
walk_start = 20,
|
||||
walk_end = 40,
|
||||
run_start = 20,
|
||||
run_end = 40,
|
||||
punch_start = 50,
|
||||
punch_end = 90,
|
||||
},
|
||||
jump = true,
|
||||
sounds = {},
|
||||
step = 1,
|
||||
blood_amount = 22,
|
||||
blood_offset = 0.1,
|
||||
})
|
||||
mobs:register_spawn("mobs:spider", {"default:leaves", "default:jungleleaves", "mg:savannaleaves"}, 22, -1, 7000, 4, 31000)
|
||||
mobs:register_spawn("mobs:spider", {"default:leaves", "default:jungleleaves", "mg:savannaleaves"}, 7, -1, 3000, 6, 31000)
|
||||
|
6110
models/mobs_spider.x
Normal file
6110
models/mobs_spider.x
Normal file
File diff suppressed because it is too large
Load Diff
BIN
textures/mobs_spider.png
Normal file
BIN
textures/mobs_spider.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.2 KiB |
Loading…
x
Reference in New Issue
Block a user