Compare commits

...

5 Commits

Author SHA1 Message Date
AntumDeluge 433eadf00a Make more variables local 2017-05-28 22:36:45 -07:00
AntumDeluge 30e8cf4a12 Remove unneeded 'visual' variable 2017-05-28 22:34:10 -07:00
AntumDeluge 3ae9c9e963 Change line file line endings 2017-05-28 22:27:40 -07:00
AntumDeluge a2ae1e59b6 Make some variables local 2017-05-28 22:26:00 -07:00
AntumDeluge 1f8c30820d Change registered entity name to 'herobrine:npc' 2017-05-28 22:12:20 -07:00
1 changed files with 486 additions and 488 deletions

View File

@ -1,16 +1,16 @@
-- NPC max walk speed
walk_limit = 2
local walk_limit = 2
-- Player animation speed
animation_speed = 30
local animation_speed = 30
-- Player animation blending
-- Note: This is currently broken due to a bug in Irrlicht, leave at 0
animation_blend = 0
local animation_blend = 0
-- Default player appearance
default_model = "character.x"
available_npc_textures = {
local default_model = "character.x"
local available_npc_textures = {
texture_1 = {"jordan4ibanez.png", },
texture_2 = {"zombie.png", },
texture_3 = {"celeron55.png", },
@ -19,7 +19,7 @@ available_npc_textures = {
-- Frame ranges for each player model
function player_get_animations(model)
local function player_get_animations(model)
if model == "character.x" then
return {
stand_START = 0,
@ -51,19 +51,17 @@ 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
prop = {
local 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
NPC_ENTITY = {
local NPC_ENTITY = {
physical = true,
collisionbox = {-0.3,-1.0,-0.3, 0.3,0.8,0.3},
visual = "mesh",
@ -84,7 +82,7 @@ NPC_ENTITY = {
NPC_ENTITY.on_activate = function(self)
player_update_visuals(self)
self.anim = player_get_animations(visual)
self.anim = player_get_animations(default_model)
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})
@ -94,7 +92,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 == "npc:npc" then
if object:get_luaentity().name == "herobrine:npc" then
object:get_luaentity().state = 3
object:get_luaentity().attacker = puncher:get_player_name()
end
@ -125,7 +123,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 == "npc:npc" then
if object:get_luaentity().name == "herobrine:npc" then
print("moo")
end
end
@ -150,8 +148,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
NPC = self.object:getpos()
PLAYER = object:getpos()
local NPC = self.object:getpos()
local 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
@ -169,7 +167,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(visual)
self.anim = player_get_animations(default_model)
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
@ -188,7 +186,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(visual)
self.anim = player_get_animations(default_model)
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
@ -243,7 +241,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(visual)
self.anim = player_get_animations(default_model)
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
@ -295,7 +293,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(visual)
self.anim = player_get_animations(default_model)
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
@ -371,7 +369,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(visual)
self.anim = player_get_animations(default_model)
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
@ -404,9 +402,9 @@ NPC_ENTITY.on_step = function(self, dtime)
end
end
minetest.register_entity("npc:npc", NPC_ENTITY)
minetest.register_entity("herobrine:npc", NPC_ENTITY)
minetest.register_node("npc:spawnegg", {
minetest.register_node("herobrine:spawnegg", {
description = "spawnegg",
image = "mobspawnegg.png",
inventory_image = "mobspawnegg.png",
@ -424,7 +422,7 @@ minetest.register_node("npc:spawnegg", {
on_place = function(itemstack, placer, pointed)
pos = pointed.above
pos.y = pos.y + 1
minetest.env:add_entity(pointed.above,"npc:npc")
minetest.env:add_entity(pointed.above,"herobrine:npc")
end
})
--[[
@ -484,5 +482,5 @@ npcs.spawning_mobs = {}
})
end
npcs:register_spawn("npc:npc", {"default:dirt_with_grass"}, 16, -1, 500, 10, 31000)
npcs:register_spawn("herobrine:npc", {"default:dirt_with_grass"}, 16, -1, 500, 10, 31000)
]]--