X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=mods%2Fmob%2Finit.lua;h=73df7a3399e573f2f47dd0c1d5d99ad4eeee8adc;hb=ff19c141c9f93d5dec4a92f128cf4d1efb8e31b5;hp=a2265bcc57ef3c9f5d7f32625e394fc5511f5a95;hpb=eeb9de2cb5cad5c93b1707242e240c72af796ede;p=Crafter.git diff --git a/mods/mob/init.lua b/mods/mob/init.lua index a2265bc..73df7a3 100644 --- a/mods/mob/init.lua +++ b/mods/mob/init.lua @@ -1,380 +1,912 @@ --this is where mobs are defined -global_mob_table = {} - +--this is going to be used to set an active mob limit +global_mob_amount = 0 +mob_limit = 100 local path = minetest.get_modpath(minetest.get_current_modname()) dofile(path.."/spawning.lua") +dofile(path.."/api/api_hook.lua") dofile(path.."/items.lua") +dofile(path.."/chatcommands.lua") ---these are helpers to create entities -local mob = {} -mob.initial_properties = { - hp_max = 1, - physical = true, - collide_with_objects = false, - collisionbox = {-0.37, -0.37, -0.37, 0.37, 0.865, 0.37}, - visual = "mesh", - visual_size = {x = 3, y = 3}, - mesh = "pig.x", - textures = { - "body.png","leg.png","leg.png","leg.png","leg.png" - }, - is_visible = true, - pointable = true, - automatic_face_movement_dir = 0.0, - automatic_face_movement_max_rotation_per_sec = 600, -} -mob.hp = 5 -mob.mob = true -mob.hostile = false -mob.timer = 0 +mobs.register_mob( + { + mobname = "pig", + physical = true, + collide_with_objects = false, + collisionbox = {-0.37, 0, -0.37, 0.37, 0.85, 0.37}, + visual = "mesh", + visual_size = {x = 3, y = 3}, + mesh = "pig.b3d", + textures = { + --blank out the first two to create adult pig + "pig.png" + }, + + --these are used to anchor a point to the head position -mob.get_staticdata = function(self) - return minetest.serialize({ - --range = self.range, - hp = self.hp, - }) -end + ----- + head_bone = "head", + debug_head_pos = false, + head_directional_offset = 0.5, --used in vector.multiply(minetest.yaw_to_dir(body_yaw),head_offset) + head_height_offset = 0.8, --added to the base y position + --use this to correct the head position initially because it becomes severly offset - look at your blender model to get this perfect + head_position_correction = vector.new(0,3,-0.5), + --this is used to tell the game the orientation of the bone (swaps x to and y, then z and y) + head_coord = "horizontal", + ----- + + is_visible = true, + pointable = true, + automatic_face_movement_dir = 0, + automatic_face_movement_max_rotation_per_sec = 300, + makes_footstep_sound = false, + hp = 10, + gravity = {x = 0, y = -9.81, z = 0}, + movement_type = "walk", + max_speed = 5, + state = 0, + view_distance = 15, + + item_drop = "mob:raw_porkchop", + standing_frame = {x=0,y=0}, + moving_frame = {x=0,y=40}, + animation_multiplier = 20, + ---- + ---- + death_rotation = "x", + + hurt_sound = "pig", + die_sound = "pig_die", + + + hostile = false, + attacked_hostile = false, + attack_type = "punch", + group_attack = true, + --explosion_radius = 4, -- how far away the mob has to be to initialize the explosion + --explosion_power = 7, -- how big the explosion has to be + --explosion_time = 3, -- how long it takes for a mob to explode + } +) -mob.on_activate = function(self, staticdata, dtime_s) - self.object:set_armor_groups({immortal = 1}) - --self.object:set_velocity({x = math.random(-5,5), y = 5, z = math.random(-5,5)}) - self.object:set_acceleration({x = 0, y = -9.81, z = 0}) - if string.sub(staticdata, 1, string.len("return")) == "return" then - local data = minetest.deserialize(staticdata) - if data and type(data) == "table" then - --self.range = data.range - self.hp = data.hp - end - end - self.object:set_animation({x=5,y=15}, 1, 0, true) - self.object:set_hp(self.hp) - self.direction = vector.new(math.random()*math.random(-1,1),0,math.random()*math.random(-1,1)) - - --set the head up - local head = minetest.add_entity(self.object:get_pos(), "mob:head") - if head then - self.child = head - self.child:get_luaentity().parent = self.object - self.child:set_attach(self.object, "", vector.new(2.4,1.2,0), vector.new(180,0,180)) - self.head_rotation = vector.new(180,180,90) - self.child:set_animation({x=90,y=90}, 15, 0, true) - end - - --self.object:set_yaw(math.pi*math.random(-1,1)*math.random()) -end -mob.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir) - local hurt = tool_capabilities.damage_groups.fleshy - if not hurt then - hurt = 1 - end - local hp = self.object:get_hp() - self.object:set_hp(hp-hurt) - if hp > 1 then - minetest.sound_play("hurt", {object=self.object, gain = 1.0, max_hear_distance = 60,pitch = math.random(80,100)/100}) - end - self.hp = hp-hurt -end -mob.on_death = function(self, killer) - local pos = self.object:getpos() - pos.y = pos.y + 0.4 - minetest.sound_play("mob_die", {pos = pos, gain = 1.0}) - minetest.add_particlespawner({ - amount = 40, - time = 0.001, - minpos = pos, - maxpos = pos, - minvel = vector.new(-5,-5,-5), - maxvel = vector.new(5,5,5), - minacc = {x=0, y=0, z=0}, - maxacc = {x=0, y=0, z=0}, - minexptime = 1.1, - maxexptime = 1.5, - minsize = 1, - maxsize = 2, - collisiondetection = false, - vertical = false, - texture = "smoke.png", - }) - local obj = minetest.add_item(pos,"mob:raw_porkchop") - self.child:get_luaentity().parent = nil -end ---repel from players -mob.push = function(self) - local pos = self.object:getpos() - local radius = 1 - for _,object in ipairs(minetest.get_objects_inside_radius(pos, radius)) do - if object:is_player() or object:get_luaentity().mob == true then - local player_pos = object:getpos() - pos.y = 0 - player_pos.y = 0 - - local currentvel = self.object:getvelocity() - local vel = vector.subtract(pos, player_pos) - vel = vector.normalize(vel) - local distance = vector.distance(pos,player_pos) - distance = (radius-distance)*10 - vel = vector.multiply(vel,distance) - local acceleration = vector.new(vel.x-currentvel.x,0,vel.z-currentvel.z) - - - self.object:add_velocity(acceleration) - - acceleration = vector.multiply(acceleration, 5) - object:add_player_velocity(acceleration) - end - end -end ---This makes the mob walk at a certain speed and jump -mob.move = function(self,dtime) - self.timer = self.timer - dtime - if self.timer <= 0 then - self.timer = math.random(1,3) - self.direction = vector.new(math.random()*math.random(-1,1),0,math.random()*math.random(-1,1)) - --local yaw = self.object:get_yaw() + dtime - - --self.object:set_yaw(yaw) - end - - local pos1 = self.object:getpos() - pos1.y = pos1.y + 0.37 - local currentvel = self.object:getvelocity() - local goal = vector.multiply(self.direction,5) - local acceleration = vector.new(goal.x-currentvel.x,0,goal.z-currentvel.z) - acceleration = vector.multiply(acceleration, 0.05) - self.object:add_velocity(acceleration) - - --try to jump - if currentvel.y <= 0 then - local in_front = minetest.raycast(pos1, vector.add(pos1,vector.multiply(self.direction,3)), false, false):next() - local below = minetest.raycast(pos1, vector.add(pos1, vector.new(0,-0.02,0)), false, false):next() - if in_front then - in_front = minetest.registered_nodes[minetest.get_node(in_front.under).name].walkable - end - if below then - below = minetest.registered_nodes[minetest.get_node(below.under).name].walkable +mobs.register_mob( + { + mobname = "sheep", + physical = true, + collide_with_objects = false, + collisionbox = {-0.37, 0, -0.37, 0.37, 0.85, 0.37}, + visual = "mesh", + visual_size = {x = 3, y = 3}, + mesh = "sheep.b3d", + textures = { + "sheep_head_wool.png","sheep_wool.png","sheep.png" + --"sheep_head_shaved.png","nothing.png","sheep.png" + }, + + --these are used to anchor a point to the head position + + + ----- + head_bone = "head", + debug_head_pos = false, + head_directional_offset = 0.571, --used in vector.multiply(minetest.yaw_to_dir(body_yaw),head_offset) + head_height_offset = 1.15, --added to the base y position + --use this to correct the head position initially because it becomes severly offset - look at your blender model to get this perfect + head_position_correction = vector.new(0,4.1,-0.86), + --this is used to tell the game the orientation of the bone (swaps x to and y, then z and y) + head_coord = "horizontal", + ----- + + is_visible = true, + pointable = true, + automatic_face_movement_dir = 0, + automatic_face_movement_max_rotation_per_sec = 300, + makes_footstep_sound = false, + hp = 10, + gravity = {x = 0, y = -9.81, z = 0}, + movement_type = "walk", + max_speed = 5, + state = 0, + view_distance = 15, + + item_drop = "mob:raw_porkchop", + standing_frame = {x=0,y=0}, + moving_frame = {x=0,y=40}, + animation_multiplier = 20, + ---- + ---- + death_rotation = "x", + + hurt_sound = "sheep", + die_sound = "sheep", + + + hostile = false, + attacked_hostile = false, + attack_type = "punch", + group_attack = true, + + c_mob_data = {sheared = false}, + + custom_on_activate = function(self) + --print(dump(self.c_mob_data)) + if self.c_mob_data.sheared == true then + self.object:set_properties({textures = {"sheep_head_shaved.png","nothing.png","sheep.png"}}) end - - if in_front and below then - self.object:add_velocity(vector.new(0,5,0)) + end, + + custom_on_punch = function(self) + if self.c_mob_data.sheared == false then + self.object:set_properties({textures = {"sheep_head_shaved.png","nothing.png","sheep.png"}}) + self.c_mob_data = {sheared=true} + local pos = self.object:get_pos() + pos.y = pos.y + 0.5 + minetest.throw_item(pos,{name="weather:snow_block"}) end end -end ---makes the mob swim -mob.swim = function(self) - local pos = self.object:getpos() - pos.y = pos.y + 0.7 - local node = minetest.get_node(pos).name - local vel = self.object:getvelocity() - local goal = 3 - local acceleration = vector.new(0,goal-vel.y,0) - self.swimming = false - - if node == "main:water" or node =="main:waterflow" then - self.swimming = true - self.object:add_velocity(acceleration) - end -end ---sets the mob animation and speed -mob.set_animation = function(self) - local distance = vector.distance(vector.new(0,0,0), self.object:getvelocity()) - self.object:set_animation_frame_speed(distance*5) -end + } +) ---converts yaw to degrees -local degrees = function(yaw) - yaw = yaw + math.pi - return(yaw*180.0/math.pi) -end +mobs.register_mob( + { + mobname = "chicken", + physical = true, + collide_with_objects = false, + collisionbox = {-0.225, 0, -0.225, 0.225, 0.675, 0.225}, + visual = "mesh", + visual_size = {x = 3, y = 3}, + mesh = "chicken.b3d", + textures = { + --blank out the first two to create adult pig + "chicken.png" + }, + + --these are used to anchor a point to the head position -local degree_round = function(degree) - return(degree + 0.5 - (degree + 0.5) % 1) -end -local radians_to_degrees = function(radians) - return(radians*180.0/math.pi) -end + ----- + head_bone = "head", + debug_head_pos = false, + rotational_correction = -math.pi/2, + head_directional_offset = 0.2, --used in vector.multiply(minetest.yaw_to_dir(body_yaw),head_offset) + head_height_offset = 0.82, --added to the base y position + --use this to correct the head position initially because it becomes severly offset - look at your blender model to get this perfect + head_position_correction = vector.new(0,1.8,-0.89), + --this is used to tell the game the orientation of the bone (swaps x to and y, then z and y) + head_coord = "vertical", + flip_pitch = true, + ----- + + is_visible = true, + pointable = true, + automatic_face_movement_dir = 90, + automatic_face_movement_max_rotation_per_sec = 300, + makes_footstep_sound = false, + hp = 10, + gravity = {x = 0, y = -9.81, z = 0}, + movement_type = "walk", + max_speed = 5, + state = 0, + view_distance = 15, + + item_drop = {"mob:egg","mob:feather"}, + standing_frame = {x=20,y=20}, + moving_frame = {x=0,y=20}, + animation_multiplier = 15, + ---- + ---- + death_rotation = "z", + + hurt_sound = "chicken_hurt", + die_sound = "chicken_die", + + + hostile = false, + attacked_hostile = false, + attack_type = "punch", + group_attack = true, + --explosion_radius = 4, -- how far away the mob has to be to initialize the explosion + --explosion_power = 7, -- how big the explosion has to be + --explosion_time = 3, -- how long it takes for a mob to explode + } +) ---a movement test to move the head -mob.move_head = function(self,pos2) - if self.child then - --print(self.head_rotation.y) - --if passed a direction to look - if pos2 then - local pos = self.object:get_pos() - local body_yaw = self.object:get_yaw() - (math.pi/2) - local dir = vector.multiply(minetest.yaw_to_dir(body_yaw),0.72) - local real_dir = minetest.yaw_to_dir(body_yaw) - local body_yaw = degree_round(degrees(minetest.dir_to_yaw(dir))) - - --pos is where the head actually is - pos = vector.add(pos,dir) - pos.y = pos.y + 0.36 - - - local head_yaw = degree_round(degrees(minetest.dir_to_yaw(vector.direction(pos,pos2)))) - - local new_yaw = (body_yaw-head_yaw) - - local pitch = 0 - local roll = 0 - - --print(self.head_rotation.y) - if math.abs(new_yaw) <= 90 or math.abs(new_yaw) >= 270 then - --do other calculations on pitch and roll - - local triangle = vector.new(vector.distance(pos,pos2),0,pos2.y-pos.y) - - local tri_yaw = minetest.dir_to_yaw(triangle)+(math.pi/2) - - pitch = radians_to_degrees(tri_yaw) - - pitch = math.floor(pitch+90 + 0.5) - - - local goal_yaw = 180-new_yaw - - if goal_yaw < 0 then - goal_yaw = goal_yaw + 360 - end - - local current_yaw = self.head_rotation.y - - if goal_yaw > current_yaw then - current_yaw = current_yaw + 4 - elseif goal_yaw < current_yaw then - current_yaw = current_yaw - 4 - end - - --stop jittering - if math.abs(math.abs(goal_yaw) - math.abs(current_yaw)) <= 4 then - --print("skipping:") - --print(math.abs(goal_yaw) - math.abs(current_yaw)) - current_yaw = goal_yaw - else - --print(" NOT SKIPPING") - --print(math.abs(goal_yaw) - math.abs(current_yaw)) - end - - - local goal_pitch = pitch - - local current_pitch = self.head_rotation.z - - if goal_pitch > current_pitch then - current_pitch = current_pitch + 1 - elseif goal_pitch < current_pitch then - current_pitch = current_pitch - 1 +mobs.register_mob( + { + mobname = "snowman", + physical = true, + collide_with_objects = false, + collisionbox = {-0.37, 0, -0.37, 0.37, 1.75, 0.37}, + visual = "mesh", + visual_size = {x = 3, y = 3}, + mesh = "snowman.b3d", + textures = { + "snowman.png","snowman.png","snowman.png","snowman.png","snowman.png","snowman.png", + }, + + --these are used to anchor a point to the head position + + + ----- + --head_bone = "Bone", + debug_head_pos = false, + head_directional_offset = 0, --used in vector.multiply(minetest.yaw_to_dir(body_yaw),head_offset) + head_height_offset = 1.625, --added to the base y position + --use this to correct the head position initially because it becomes severly offset - look at your blender model to get this perfect + head_position_correction = vector.new(0,4.6,0), + --this is used to tell the game the orientation of the bone (swaps x to and y, then z and y) + head_coord = "vertical", + --rotational_correction = math.pi/2, + ----- + + is_visible = true, + pointable = true, + automatic_face_movement_dir = -90, + automatic_face_movement_max_rotation_per_sec = 300, + makes_footstep_sound = false, + hp = 10, + gravity = {x = 0, y = -9.81, z = 0}, + movement_type = "walk", + max_speed = 5, + state = 0, + view_distance = 15, + + item_drop = {"weather:snowball","main:coal","mob:carrot","main:stick"}, + standing_frame = {x=0,y=0}, + moving_frame = {x=0,y=0}, + animation_multiplier = 10, + ---- + ---- + death_rotation = "z", + + hurt_sound = "wool", + die_sound = "wool", + + + hostile = true, + attack_type = "projectile", + projectile_type = "weather:snowball", + projectile_timer_cooldown = 1, + + custom_function = function(self,dtime,moveresult) + if moveresult and moveresult.touching_ground then + local pos = vector.floor(vector.add(self.object:get_pos(),0.5)) + + if self.custom_old_pos and not vector.equals(pos,self.custom_old_pos) then + if minetest.get_nodedef(minetest.get_node(pos).name,"buildable_to") == true and minetest.get_nodedef(minetest.get_node(vector.new(pos.x,pos.y-1,pos.z)).name,"buildable_to") == false then + minetest.set_node(pos,{name="weather:snow"}) end - - self.child:set_attach(self.object, "", vector.new(2.4,1.2,0), vector.new(180, current_yaw, 180)) - self.child:set_animation({x=current_pitch,y=current_pitch}, 15, 0, true) - self.head_rotation = vector.new(180, current_yaw, current_pitch) - --nothing to look at - else - self.return_head_to_origin(self) end - -- roll newyaw pitch - - --if nothing to look at - else - --print("not looking") - self.return_head_to_origin(self) - end - end -end ---this sets the mob to move it's head back to pointing forwards -mob.return_head_to_origin = function(self) - --print("setting back to origin") - local rotation = self.head_rotation - - --make the head yaw move back twice as fast - if rotation.y > 180 then - if rotation.y > 360 then - rotation.y = rotation.y - 360 - end - rotation.y = rotation.y - 2 - elseif rotation.y < 180 then - if rotation.y < 0 then - rotation.y = rotation.y + 360 + self.custom_old_pos = pos end - rotation.y = rotation.y + 2 - end - --finish rotation - if math.abs(rotation.y)+1 == 180 then - rotation.y = 180 - end - --move up down (pitch) back to center - if rotation.z > 90 then - rotation.z = rotation.z - 1 - elseif rotation.z < 90 then - rotation.z = rotation.z + 1 - end - - - rotation.z = math.floor(rotation.z + 0.5) - rotation.y = math.floor(rotation.y + 0.5) - --print(rotation.y) - self.child:set_attach(self.object, "", vector.new(2.4,1.2,0), vector.new(180, rotation.y, 180)) - self.child:set_animation({x=rotation.z,y=rotation.z}, 15, 0, true) - self.head_rotation = rotation -end + end, -mob.look_around = function(self) - local pos = self.object:get_pos() - --STARE O_O - local player_found = false - for _,object in ipairs(minetest.get_objects_inside_radius(pos, 6)) do - if object:is_player() and player_found == false then - --print("test") - player_found = true - --look at player's camera - local pos2 = object:get_pos() - pos2.y = pos2.y + 1.625 - self.move_head(self,pos2) + custom_timer = 0.75, + custom_timer_function = function(self,dtime) + if weather_type and weather_type ~= 1 then + self.object:punch(self.object, 2, + { + full_punch_interval=1.5, + damage_groups = {damage=2}, + }) end - end - --stare straight if not found - if player_found == false then - self.move_head(self,nil) - end -end + end, + } +) -mob.on_step = function(self, dtime) - self.move(self,dtime) - self.set_animation(self) - self.look_around(self) -end +mobs.register_mob( + { + mobname = "phyg", + physical = true, + collide_with_objects = false, + collisionbox = {-0.37, 0, -0.37, 0.37, 0.85, 0.37}, + visual = "mesh", + visual_size = {x = 3, y = 3}, + mesh = "phyg.b3d", + textures = { + --blank out the first two to create adult pig + "phyg.png","wings.png" + }, + + --these are used to anchor a point to the head position -minetest.register_entity("mob:pig", mob) + ----- + head_bone = "head", + debug_head_pos = false, + head_directional_offset = 0.5, --used in vector.multiply(minetest.yaw_to_dir(body_yaw),head_offset) + head_height_offset = 0.8, --added to the base y position + --use this to correct the head position initially because it becomes severly offset - look at your blender model to get this perfect + head_position_correction = vector.new(0,3,-0.5), + --this is used to tell the game the orientation of the bone (swaps x to and y, then z and y) + head_coord = "horizontal", + ----- + + is_visible = true, + pointable = true, + automatic_face_movement_dir = 0, + automatic_face_movement_max_rotation_per_sec = 300, + makes_footstep_sound = false, + takes_fall_damage = false, + make_jump_noise = false, + hp = 10, + gravity = {x = 0, y = -1, z = 0}, + movement_type = "walk", + max_speed = 5, + state = 0, + view_distance = 15, + + item_drop = "main:gold", + item_minimum = 4, + item_max = 5, -local head = {} -head.initial_properties = { - hp_max = 1, - physical = false, - collide_with_objects = false, - collisionbox = {0, 0, 0, 0, 0, 0}, - visual = "mesh", - visual_size = {x = 1.1, y = 1.1}, - mesh = "pig_head.x", + standing_frame = {x=0,y=0}, + moving_frame = {x=0,y=40}, + animation_multiplier = 20, + ---- + ---- + death_rotation = "x", + + hurt_sound = "pig", + die_sound = "pig_die", + + + hostile = false, + attacked_hostile = false, + attack_type = "punch", + group_attack = true, + --explosion_radius = 4, -- how far away the mob has to be to initialize the explosion + --explosion_power = 7, -- how big the explosion has to be + --explosion_time = 3, -- how long it takes for a mob to explode + } +) + + +mobs.register_mob( + { + mobname = "big_slime", + physical = true, + collide_with_objects = false, + collisionbox = {-1.25, 0, -1.25, 1.25, 2.5, 1.25}, + visual = "mesh", + visual_size = {x = 15, y = 15}, + mesh = "slime.b3d", textures = { - "head.png","nose.png" + "slime.png" }, + collision_boundary = 2.5, is_visible = true, + pointable = true, + automatic_face_movement_dir = 90, + automatic_face_movement_max_rotation_per_sec = 300, + makes_footstep_sound = false, + hp = 32, + gravity = {x = 0, y = -9.81, z = 0}, + movement_type = "jump", + make_jump_noise = true, + max_speed = 5, + hostile = true, + state = 0, + view_distance = 20, + death_rotation = "z", + hurt_sound = "slime_die", + die_sound = "slime_die", + attack_type = "punch", + attack_damage = 6, + custom_on_death = function(self) + local pos = self.object:get_pos() + for i = 1,4 do + minetest.add_entity(pos,"mob:medium_slime") + end + end, + } +) + +mobs.register_mob( + { + mobname = "medium_slime", + physical = true, + collide_with_objects = false, + collisionbox = {-0.625, 0, -0.625, 0.625, 1.25, 0.625}, + visual = "mesh", + visual_size = {x = 7.5, y = 7.5}, + mesh = "slime.b3d", + textures = { + "slime.png" + }, + is_visible = true, + pointable = true, + automatic_face_movement_dir = 90, + automatic_face_movement_max_rotation_per_sec = 300, + makes_footstep_sound = false, + hp = 10, + gravity = {x = 0, y = -9.81, z = 0}, + movement_type = "jump", + make_jump_noise = true, + max_speed = 5, + hostile = true, + state = 0, + view_distance = 20, + death_rotation = "z", + hurt_sound = "slime_die", + die_sound = "slime_die", + attack_damage = 2, + attack_type = "punch", + custom_on_death = function(self) + local pos = self.object:get_pos() + pos.y = pos.y + 0.2 + for i = 1,4 do + minetest.add_entity(pos,"mob:small_slime") + end + end, + } +) + +mobs.register_mob( + { + mobname = "small_slime", + physical = true, + collide_with_objects = false, + collisionbox = {-0.3, 0, -0.3, 0.3, 0.6, 0.3}, + visual = "mesh", + visual_size = {x = 3.7, y = 3.7}, + mesh = "slime.b3d", + textures = { + "slime.png" + }, + is_visible = true, + pointable = true, + automatic_face_movement_dir = 90, + automatic_face_movement_max_rotation_per_sec = 300, + makes_footstep_sound = false, + hp = 4, + gravity = {x = 0, y = -9.81, z = 0}, + movement_type = "jump", + make_jump_noise = true, + max_speed = 5, + hostile = true, + state = 0, + view_distance = 20, + death_rotation = "z", + hurt_sound = "slime_die", + die_sound = "slime_die", + attack_damage = 1, + attack_type = "punch", + item_drop = "mob:slimeball" + } +) + +--[[ + + +mobs.register_mob( + { + mobname = "creepig", + physical = true, + collide_with_objects = false, + collisionbox = {-0.37, -0.4, -0.37, 0.37, 0.5, 0.37}, + visual = "mesh", + visual_size = {x = 3, y = 3}, + mesh = "pig.x", + textures = { + "creepig_body.png","creepig_leg.png","creepig_leg.png","creepig_leg.png","creepig_leg.png" + }, + is_visible = true, + pointable = true, + automatic_face_movement_dir = -90.0, + automatic_face_movement_max_rotation_per_sec = 300, + makes_footstep_sound = false, + hp = 10, + gravity = {x = 0, y = -9.81, z = 0}, + movement_type = "walk", + max_speed = 4, + hostile = true, + state = 0, + view_distance = 20, + item_drop = "mob:cooked_porkchop", + + standing_frame = {x=0,y=0}, + moving_frame = {x=5,y=15}, + animation_multiplier = 5, + ---- + + has_head = true, --remove this when mesh based head rotation is implemented + head_visual = "mesh", + head_visual_size = {x = 1.1, y = 1.1}, + head_mesh = "pig_head.x", + head_textures ={"creepig_head.png","creepig_nose.png"}, + head_mount = vector.new(0,1.2,1.9), + + death_rotation = "z", + + hurt_sound = "pig", + die_sound = "pig_die", + + attack_type = "explode", + --projectile_timer_cooldown = 5, + --projectile_type = "tnt:tnt", + + explosion_radius = 2, -- how far away the mob has to be to initialize the explosion + explosion_power = 7, -- how big the explosion has to be + explosion_time = 5, -- how long it takes for a mob to explode + + die_in_light = true, + die_in_light_level = 12, + } +) + +]]-- + +mobs.register_mob( + { + mobname = "creeper", + physical = true, + collide_with_objects = false, + collisionbox = {-0.37,0, -0.37, 0.37, 1.5, 0.37}, + visual = "mesh", + visual_size = {x = 3.2, y = 3.2}, + mesh = "creeper.b3d", + textures = { + "creeper.png" + }, + is_visible = true, + pointable = true, + automatic_face_movement_max_rotation_per_sec = 300, + makes_footstep_sound = false, + hp = 27, + gravity = {x = 0, y = -9.81, z = 0}, + movement_type = "walk", + max_speed = 5.5, + hostile = true, + hostile_cooldown = false, + state = 0, + view_distance = 32, + item_drop = "mob:gunpowder", + + standing_frame = {x=0,y=0}, + moving_frame = {x=0,y=40}, + animation_multiplier = 20, + ---- + pathfinds = true, + + --these are used to anchor a point to the head position + ----- + automatic_face_movement_dir = 0, + head_bone = "head", + debug_head_pos = false, + --this always has to be slightly positive + head_directional_offset = 0.01, + head_height_offset = 1.45, --added to the base y position + --use this to correct the head position initially because it becomes severly offset - look at your blender model to get this perfect + head_position_correction = vector.new(0,2.4,0), + head_coord = "vertical", + ----- + + + death_rotation = "x", + + hurt_sound = "creeper_hurt", + die_sound = "creeper_hurt", + + attack_type = "explode", + --projectile_timer_cooldown = 5, + --projectile_type = "tnt:tnt", + + explosion_radius = 4, -- how far away the mob has to be to initialize the explosion + explosion_power = 4, -- how big the explosion has to be + explosion_time = 3, -- how long it takes for a mob to explode + + die_in_light = false, + --die_in_light_level = 12, + } +) + +mobs.register_mob( + { + mobname = "sneeper", + physical = true, + collide_with_objects = false, + collisionbox = {-0.37,0, -0.37, 0.37, 1.5, 0.37}, + visual = "mesh", + visual_size = {x = 3.2, y = 3.2}, + mesh = "creeper.b3d", + textures = { + "sneeper.png" + }, + is_visible = true, + pointable = true, + automatic_face_movement_max_rotation_per_sec = 300, + makes_footstep_sound = false, + hp = 27, + gravity = {x = 0, y = -9.81, z = 0}, + movement_type = "walk", + max_speed = 5.5, + hostile = true, + hostile_cooldown = false, + state = 0, + view_distance = 32, + item_drop = "mob:gunpowder", + + standing_frame = {x=0,y=0}, + moving_frame = {x=0,y=40}, + animation_multiplier = 20, + ---- + pathfinds = true, + + --these are used to anchor a point to the head position + ----- + automatic_face_movement_dir = 0, + head_bone = "head", + debug_head_pos = false, + --this always has to be slightly positive + head_directional_offset = 0.01, + head_height_offset = 1.45, --added to the base y position + --use this to correct the head position initially because it becomes severly offset - look at your blender model to get this perfect + head_position_correction = vector.new(0,2.4,0), + head_coord = "vertical", + ----- + + damage_color = "blue", + + death_rotation = "x", + + hurt_sound = "creeper_hurt", + die_sound = "creeper_hurt", + + attack_type = "explode", + explosion_type = "weather:snow_block", + --projectile_timer_cooldown = 5, + --projectile_type = "tnt:tnt", + + explosion_radius = 4, -- how far away the mob has to be to initialize the explosion + explosion_power = 4, -- how big the explosion has to be + explosion_time = 3, -- how long it takes for a mob to explode + + die_in_light = false, + --die_in_light_level = 12, + } +) + + +mobs.register_mob( + { + mobname = "nitro_creeper", + physical = true, + collide_with_objects = false, + collisionbox = {-0.37,0, -0.37, 0.37, 1.5, 0.37}, + visual = "mesh", + visual_size = {x = 3.2, y = 3.2}, + mesh = "creeper.b3d", + textures = { + "nitro_creeper.png" + }, + is_visible = true, + pointable = true, + automatic_face_movement_max_rotation_per_sec = 300, + makes_footstep_sound = false, + hp = 40, + gravity = {x = 0, y = -9.81, z = 0}, + movement_type = "walk", + max_speed = 9, + hostile = true, + hostile_cooldown = false, + state = 0, + view_distance = 40, + item_drop = "mob:gunpowder", + + damage_color = "blue", + + standing_frame = {x=0,y=0}, + moving_frame = {x=0,y=40}, + animation_multiplier = 20, + ---- + pathfinds = true, + + --these are used to anchor a point to the head position + ----- + automatic_face_movement_dir = 0, + head_bone = "head", + debug_head_pos = false, + --this always has to be slightly positive + head_directional_offset = 0.01, + head_height_offset = 1.45, --added to the base y position + --use this to correct the head position initially because it becomes severly offset - look at your blender model to get this perfect + head_position_correction = vector.new(0,2.4,0), + head_coord = "vertical", + ----- + + + death_rotation = "x", + + hurt_sound = "creeper_hurt", + die_sound = "creeper_hurt", + + attack_type = "explode", + --projectile_timer_cooldown = 5, + --projectile_type = "tnt:tnt", + + explosion_radius = 6, -- how far away the mob has to be to initialize the explosion + explosion_power = 14, -- how big the explosion is (radius) + explosion_time = 3, -- how long it takes for a mob to explode + explosion_blink_timer = 0.1, -- how fast the blinking happens + + die_in_light = false, + --die_in_light_level = 12, + } +) + +local spider_eyes = {} + +spider_eyes.initial_properties = { + visual = "mesh", + mesh = "spider_eyes.b3d", + textures = {"spider_eyes.png"}, pointable = false, - --automatic_face_movement_dir = 0.0, - --automatic_face_movement_max_rotation_per_sec = 600, + collisionbox = {0, 0, 0, 0, 0, 0} } - ---remove the head if no body -head.on_step = function(self, dtime) - if self.parent == nil then +spider_eyes.glow = -1 +spider_eyes.on_step = function(self) + if not self.owner or not self.owner:get_luaentity() then self.object:remove() + else + local owner_head_bone = self.owner:get_luaentity().head_bone + local position,rotation = self.owner:get_bone_position(owner_head_bone) + self.object:set_attach(self.owner, owner_head_bone, vector.new(0,0,0), rotation) end end -minetest.register_entity("mob:head", head) +minetest.register_entity("mob:spider_eyes",spider_eyes) + +mobs.register_mob( + { + mobname = "spider", + physical = true, + collide_with_objects = false, + collisionbox = {-0.37, 0, -0.37, 0.37, 0.85, 0.37}, + visual = "mesh", + visual_size = {x = 3, y = 3}, + mesh = "spider.b3d", + textures = { + "spider.png" + }, + + --these are used to anchor a point to the head position + ----- + head_bone = "body.head", + debug_head_pos = false, + rotational_correction = -math.pi/2, + head_directional_offset = 0.3, --used in vector.multiply(minetest.yaw_to_dir(body_yaw),head_offset) + head_height_offset = 0.63, --added to the base y position + --use this to correct the head position initially because it becomes severly offset - look at your blender model to get this perfect + head_position_correction = vector.new(0,1.24,0), + --this is used to tell the game the orientation of the bone (swaps x to and y, then z and y) + head_coord = "horizontal", + ----- + + is_visible = true, + pointable = true, + automatic_face_movement_dir = 90, + automatic_face_movement_max_rotation_per_sec = 300, + makes_footstep_sound = false, + hp = 30, + gravity = {x = 0, y = -9.81, z = 0}, + movement_type = "walk", + max_speed = 6, + state = 0, + view_distance = 32, + + item_drop = "mob:string", + standing_frame = {x=21,y=21}, + moving_frame = {x=0,y=20}, + animation_multiplier = 20, + ---- + ---- + death_rotation = "z", + + hurt_sound = "spider", + die_sound = "spider_die", + + + pathfinds = true, + + hostile = true, + friendly_in_daylight = true, + attacked_hostile = true, + attack_damage = 3, + attack_type = "punch", + group_attack = true, + + custom_on_activate = function(self) + local eyes = minetest.add_entity(self.object:get_pos(), "mob:spider_eyes") + eyes:set_attach(self.object, "body.head", vector.new(0,0,0), vector.new(0,0,0)) + eyes:get_luaentity().owner = self.object + if math.random() > 0.998 then + local obj = minetest.add_entity(self.object:get_pos(),"mob:pig") + local obj2 = minetest.add_entity(self.object:get_pos(),"tnt:tnt") + local obj3 = minetest.add_entity(self.object:get_pos(),"boat:boat") + + obj2:get_luaentity().timer = 7 + obj2:get_luaentity().radius = 7 + + obj:set_attach(self.object,"",vector.new(0,3,0),vector.new(0,90,0)) + obj2:set_attach(obj,"",vector.new(0,4.5,0),vector.new(0,90,0)) + obj3:set_attach(obj2,"",vector.new(0,6.5,0),vector.new(0,0,0)) + + obj:set_properties({visual_size={x=1,y=1}}) + obj2:set_properties({visual_size={x=1/3,y=1/3}}) + end + end + --explosion_radius = 4, -- how far away the mob has to be to initialize the explosion + --explosion_power = 7, -- how big the explosion has to be + --explosion_time = 3, -- how long it takes for a mob to explode + } +) + +mobs.register_mob( + { + mobname = "snoider", + physical = true, + collide_with_objects = false, + collisionbox = {-0.37, 0, -0.37, 0.37, 0.85, 0.37}, + visual = "mesh", + visual_size = {x = 3, y = 3}, + mesh = "spider.b3d", + textures = { + "snoider.png" + }, + + --these are used to anchor a point to the head position + ----- + head_bone = "body.head", + debug_head_pos = false, + rotational_correction = -math.pi/2, + head_directional_offset = 0.3, --used in vector.multiply(minetest.yaw_to_dir(body_yaw),head_offset) + head_height_offset = 0.63, --added to the base y position + --use this to correct the head position initially because it becomes severly offset - look at your blender model to get this perfect + head_position_correction = vector.new(0,1.24,0), + --this is used to tell the game the orientation of the bone (swaps x to and y, then z and y) + head_coord = "horizontal", + ----- + + is_visible = true, + pointable = true, + automatic_face_movement_dir = 90, + automatic_face_movement_max_rotation_per_sec = 300, + makes_footstep_sound = false, + hp = 30, + gravity = {x = 0, y = -9.81, z = 0}, + movement_type = "walk", + max_speed = 6, + state = 0, + view_distance = 32, + + item_drop = "mob:string", + standing_frame = {x=21,y=21}, + moving_frame = {x=0,y=20}, + animation_multiplier = 20, + ---- + ---- + death_rotation = "z", + + hurt_sound = "spider", + die_sound = "spider_die", + + + pathfinds = true, + + hostile = true, + friendly_in_daylight = true, + attacked_hostile = true, + attack_damage = 3, + attack_type = "punch", + group_attack = true, + + --explosion_radius = 4, -- how far away the mob has to be to initialize the explosion + --explosion_power = 7, -- how big the explosion has to be + --explosion_time = 3, -- how long it takes for a mob to explode + } +)