Compare commits
No commits in common. "433eadf00a69a4cb42cd90e9f7f1a7de095e5b6e" and "867cec65719cab4f7a3034217d2b35fb140acd2e" have entirely different histories.
433eadf00a
...
867cec6571
46
init.lua
46
init.lua
|
@ -1,16 +1,16 @@
|
|||
-- NPC max walk speed
|
||||
local walk_limit = 2
|
||||
walk_limit = 2
|
||||
|
||||
-- Player animation speed
|
||||
local animation_speed = 30
|
||||
animation_speed = 30
|
||||
|
||||
-- Player animation blending
|
||||
-- Note: This is currently broken due to a bug in Irrlicht, leave at 0
|
||||
local animation_blend = 0
|
||||
animation_blend = 0
|
||||
|
||||
-- Default player appearance
|
||||
local default_model = "character.x"
|
||||
local available_npc_textures = {
|
||||
default_model = "character.x"
|
||||
available_npc_textures = {
|
||||
texture_1 = {"jordan4ibanez.png", },
|
||||
texture_2 = {"zombie.png", },
|
||||
texture_3 = {"celeron55.png", },
|
||||
|
@ -19,7 +19,7 @@ local available_npc_textures = {
|
|||
|
||||
|
||||
-- Frame ranges for each player model
|
||||
local function player_get_animations(model)
|
||||
function player_get_animations(model)
|
||||
if model == "character.x" then
|
||||
return {
|
||||
stand_START = 0,
|
||||
|
@ -51,17 +51,19 @@ local ANIM_MINE = 6
|
|||
function player_update_visuals(self)
|
||||
--local name = get_player_name()
|
||||
|
||||
visual = default_model
|
||||
player_anim = 0 -- Animation will be set further below immediately
|
||||
--player_sneak[name] = false
|
||||
local prop = {
|
||||
prop = {
|
||||
mesh = default_model,
|
||||
textures = default_textures,
|
||||
textures = available_npc_textures["texture_"..math.random(1,4)],
|
||||
visual_size = {x=1, y=1},
|
||||
}
|
||||
self.object:set_properties(prop)
|
||||
end
|
||||
|
||||
local NPC_ENTITY = {
|
||||
NPC_ENTITY = {
|
||||
physical = true,
|
||||
collisionbox = {-0.3,-1.0,-0.3, 0.3,0.8,0.3},
|
||||
visual = "mesh",
|
||||
|
@ -82,7 +84,7 @@ local NPC_ENTITY = {
|
|||
|
||||
NPC_ENTITY.on_activate = function(self)
|
||||
player_update_visuals(self)
|
||||
self.anim = player_get_animations(default_model)
|
||||
self.anim = player_get_animations(visual)
|
||||
self.object:set_animation({x=self.anim.stand_START,y=self.anim.stand_END}, animation_speed_mod, animation_blend)
|
||||
self.player_anim = ANIM_STAND
|
||||
self.object:setacceleration({x=0,y=-10,z=0})
|
||||
|
@ -92,7 +94,7 @@ end
|
|||
NPC_ENTITY.on_punch = function(self, puncher)
|
||||
for _,object in ipairs(minetest.env:get_objects_inside_radius(self.object:getpos(), 5)) do
|
||||
if not object:is_player() then
|
||||
if object:get_luaentity().name == "herobrine:npc" then
|
||||
if object:get_luaentity().name == "npc:npc" then
|
||||
object:get_luaentity().state = 3
|
||||
object:get_luaentity().attacker = puncher:get_player_name()
|
||||
end
|
||||
|
@ -123,7 +125,7 @@ NPC_ENTITY.on_step = function(self, dtime)
|
|||
print(newz)
|
||||
self.object:setacceleration({x=newx,y=self.object:getacceleration().y,z=newz})
|
||||
elseif not object:is_player() then
|
||||
if object:get_luaentity().name == "herobrine:npc" then
|
||||
if object:get_luaentity().name == "npc:npc" then
|
||||
print("moo")
|
||||
end
|
||||
end
|
||||
|
@ -148,8 +150,8 @@ NPC_ENTITY.on_step = function(self, dtime)
|
|||
for _,object in ipairs(minetest.env:get_objects_inside_radius(self.object:getpos(), 3)) do
|
||||
if object:is_player() then
|
||||
self.yawwer = false
|
||||
local NPC = self.object:getpos()
|
||||
local PLAYER = object:getpos()
|
||||
NPC = self.object:getpos()
|
||||
PLAYER = object:getpos()
|
||||
self.vec = {x=PLAYER.x-NPC.x, y=PLAYER.y-NPC.y, z=PLAYER.z-NPC.z}
|
||||
self.yaw = math.atan(self.vec.z/self.vec.x)+math.pi^2
|
||||
if PLAYER.x > NPC.x then
|
||||
|
@ -167,7 +169,7 @@ NPC_ENTITY.on_step = function(self, dtime)
|
|||
end
|
||||
self.object:setvelocity({x=0,y=self.object:getvelocity().y,z=0})
|
||||
if self.player_anim ~= ANIM_STAND then
|
||||
self.anim = player_get_animations(default_model)
|
||||
self.anim = player_get_animations(visual)
|
||||
self.object:set_animation({x=self.anim.stand_START,y=self.anim.stand_END}, animation_speed_mod, animation_blend)
|
||||
self.player_anim = ANIM_STAND
|
||||
end
|
||||
|
@ -186,7 +188,7 @@ NPC_ENTITY.on_step = function(self, dtime)
|
|||
--self.object:setacceleration(self.direction)
|
||||
end
|
||||
if self.player_anim ~= ANIM_WALK then
|
||||
self.anim = player_get_animations(default_model)
|
||||
self.anim = player_get_animations(visual)
|
||||
self.object:set_animation({x=self.anim.walk_START,y=self.anim.walk_END}, animation_speed_mod, animation_blend)
|
||||
self.player_anim = ANIM_WALK
|
||||
end
|
||||
|
@ -241,7 +243,7 @@ NPC_ENTITY.on_step = function(self, dtime)
|
|||
if object:is_player() then
|
||||
if object:get_player_name() == self.attacker then
|
||||
if self.player_anim ~= ANIM_WALK then
|
||||
self.anim = player_get_animations(default_model)
|
||||
self.anim = player_get_animations(visual)
|
||||
self.object:set_animation({x=self.anim.walk_START,y=self.anim.walk_END}, animation_speed_mod, animation_blend)
|
||||
self.player_anim = ANIM_WALK
|
||||
end
|
||||
|
@ -293,7 +295,7 @@ NPC_ENTITY.on_step = function(self, dtime)
|
|||
--WANDERING CONSTANTLY AT NIGHT
|
||||
if self.state == 4 then
|
||||
if self.player_anim ~= ANIM_WALK then
|
||||
self.anim = player_get_animations(default_model)
|
||||
self.anim = player_get_animations(visual)
|
||||
self.object:set_animation({x=self.anim.walk_START,y=self.anim.walk_END}, animation_speed_mod, animation_blend)
|
||||
self.player_anim = ANIM_WALK
|
||||
end
|
||||
|
@ -369,7 +371,7 @@ NPC_ENTITY.on_step = function(self, dtime)
|
|||
self.direction = {x = math.sin(self.yaw)*-1, y = -10, z = math.cos(self.yaw)}
|
||||
end
|
||||
if self.player_anim ~= ANIM_WALK then
|
||||
self.anim = player_get_animations(default_model)
|
||||
self.anim = player_get_animations(visual)
|
||||
self.object:set_animation({x=self.anim.walk_START,y=self.anim.walk_END}, animation_speed_mod, animation_blend)
|
||||
self.player_anim = ANIM_WALK
|
||||
end
|
||||
|
@ -402,9 +404,9 @@ NPC_ENTITY.on_step = function(self, dtime)
|
|||
end
|
||||
end
|
||||
|
||||
minetest.register_entity("herobrine:npc", NPC_ENTITY)
|
||||
minetest.register_entity("npc:npc", NPC_ENTITY)
|
||||
|
||||
minetest.register_node("herobrine:spawnegg", {
|
||||
minetest.register_node("npc:spawnegg", {
|
||||
description = "spawnegg",
|
||||
image = "mobspawnegg.png",
|
||||
inventory_image = "mobspawnegg.png",
|
||||
|
@ -422,7 +424,7 @@ minetest.register_node("herobrine:spawnegg", {
|
|||
on_place = function(itemstack, placer, pointed)
|
||||
pos = pointed.above
|
||||
pos.y = pos.y + 1
|
||||
minetest.env:add_entity(pointed.above,"herobrine:npc")
|
||||
minetest.env:add_entity(pointed.above,"npc:npc")
|
||||
end
|
||||
})
|
||||
--[[
|
||||
|
@ -482,5 +484,5 @@ npcs.spawning_mobs = {}
|
|||
})
|
||||
end
|
||||
|
||||
npcs:register_spawn("herobrine:npc", {"default:dirt_with_grass"}, 16, -1, 500, 10, 31000)
|
||||
npcs:register_spawn("npc:npc", {"default:dirt_with_grass"}, 16, -1, 500, 10, 31000)
|
||||
]]--
|
||||
|
|
Loading…
Reference in New Issue