diff options
author | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2017-08-12 20:37:50 -0400 |
---|---|---|
committer | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2017-08-12 20:37:50 -0400 |
commit | 4aab7d0dbd782cf6741bdbba94440faf0c5c2e61 (patch) | |
tree | f5a13374fb176c21e381a2ae6ab53ac2ff282057 /peaceful_npc | |
parent | 047a770ad04fc264039fa5b6109c803bd3d2d258 (diff) | |
download | dreambuilder_modpack-4aab7d0dbd782cf6741bdbba94440faf0c5c2e61.tar dreambuilder_modpack-4aab7d0dbd782cf6741bdbba94440faf0c5c2e61.tar.gz dreambuilder_modpack-4aab7d0dbd782cf6741bdbba94440faf0c5c2e61.tar.bz2 dreambuilder_modpack-4aab7d0dbd782cf6741bdbba94440faf0c5c2e61.tar.xz dreambuilder_modpack-4aab7d0dbd782cf6741bdbba94440faf0c5c2e61.zip |
updated several mods
biome_lib, boost cart, homedecor modpack, plantlife modpack, cottages,
currency, farming redo, gloopblocks, ilights, moreores, moretrees,
pipeworks, plasticbox, replacer, signs_lib, streets, travelnet, unified
dyes, and vines, and maybe one or two others that I didn't see in the
list. :-)
I fixed the misc_overrides component (it broke when I switched over to
farming redo a while back), and also I've added the classic peaceful_npc
mod back into the modpack, since it seems to work now.
Be sure when you run a world for the first time after this update, that
you "Configure" the world, *disable* all of Dreambuilder Modpack, then
re-enable the whole thing. If you don't, a few mods will fail to load
due to recent changes in their dependencies.
Diffstat (limited to 'peaceful_npc')
50 files changed, 1980 insertions, 0 deletions
diff --git a/peaceful_npc/README.txt.md b/peaceful_npc/README.txt.md new file mode 100644 index 0000000..f42f051 --- /dev/null +++ b/peaceful_npc/README.txt.md @@ -0,0 +1,4 @@ +peaceful_npc +============ + +Adds peaceful npcs. They do not attack you. They can jump and open doors unles the doors are locked. There is an automatic spawner. diff --git a/peaceful_npc/changelog.txt b/peaceful_npc/changelog.txt new file mode 100644 index 0000000..215429e --- /dev/null +++ b/peaceful_npc/changelog.txt @@ -0,0 +1,27 @@ +===Changelog=== +1.8.5.2 plants_lib was renamed to biome_lib +1.8.5.1 fixed some bugs +1.8.5 adds a bunch. i have been editing this so much i forgot +1.8 idk +1.7.4 almost a complete rewrite +1.7.3 code reverted to 1.7.1 aka bug fix, singleplayer gets privs +1.7.2 singleplayer gets peacefulnpc privs by default, added config stuff +1.7.1 added textures, added aliases +1.7 fixed bug, spawner max=10 range=50, changed spawn method, added to spawn command can't spawn if 30 npc are within a 50 node radius +1.6.4 cant spawn > 20 with spawn command, index fix +1.6.3 need priv to use summoner +1.6.2 bug fix +1.6.1 added npc fence, spawn command, npc priv, they spawn rarer naturally +1.6 Fixed bug in post 62, added 4 textures, changed hp to 50, changed kill drop from mese crystal to mese block (so it is compatable with older games), added a compatable recipe for summoner and spawner (mese instead of crystals), changed mobspawnegg to npc summoner and it has a new texture +1.5.6 Added textures. +1.5.5 Made Tron purple, die in lava and water after 10 seconds, set hp to 40 +1.5 Added spawning and they die in water after a set amount of time. +1.4 Fixed bugs, added spawning, changed health to 25, made drop mese crystals, changed spawn limit to 10 +1.3 Added textures, Fixed a bug +1.2 Set limit for how many can be spawned around a spawner. +1.1 Added textures,changed recipes,made npcs drop a mese crystal fragment when killed, set npc health to 20 +1.0 The NPC Portal is now clear and does not look dark. +0.4 I added npc skins, changed the name Box O' NPCs to NPC Portal, changed the picture for NPC Portal, and fixed the spawn egg recipe +0.3 I don't know exactly but i did change something +0.2 The npc's don't attack anymore at night and i added a different texture for the npc spawner. +0.1 Initial release diff --git a/peaceful_npc/commands.lua b/peaceful_npc/commands.lua new file mode 100644 index 0000000..ca3b7d3 --- /dev/null +++ b/peaceful_npc/commands.lua @@ -0,0 +1,39 @@ +--Spawn Command Function +function npc_command( command_name, npc_command_type, command_desc) + local function spawn_for_command(name, param) + local npcs_to_spawn = tonumber(param) or 1 + local player = minetest.get_player_by_name(name) + local pos = player:getpos() + local max_spawn = 20 + local max_surround_npc = 30 + local active_npc_count = table.getn(minetest.get_objects_inside_radius(pos, 50)) + if active_npc_count == nil then + active_npc_count = 0 + end + if npcs_to_spawn + active_npc_count > max_surround_npc then + minetest.chat_send_player(name, "There are too many NPCs around you.") + elseif npcs_to_spawn >= max_spawn + 1 then + minetest.chat_send_player(name, "The spawn limit is"..max_spawn) + else + for n = 1, npcs_to_spawn do + offsetx = math.random(-5,5) + offsety = math.random(2,4) + offsetz = math.random(-5,5) + minetest.add_entity({ x=pos.x+offsetx, y=pos.y+offsety, z=pos.z+offsetz }, ("peaceful_npc:npc_"..npc_command_type)) + end + end + end + + --Spawn command + minetest.register_chatcommand(command_name, { + description = command_desc, + privs = {peacefulnpc=true}, + func = spawn_for_command + }) +end + +npc_command( "summonnpc_fast", "fast", "Summons Fast NPCs") +npc_command( "summonnpc_def", "def", "Summon Default NPCs") +npc_command( "summonnpc_dwarf", "dwarf", "Summon Dwarf NPCs") + +print("Peaceful NPC commands.lua loaded! By jojoa1997!")
\ No newline at end of file diff --git a/peaceful_npc/depends.txt b/peaceful_npc/depends.txt new file mode 100644 index 0000000..3e3d281 --- /dev/null +++ b/peaceful_npc/depends.txt @@ -0,0 +1,2 @@ +default +biome_lib diff --git a/peaceful_npc/init.lua b/peaceful_npc/init.lua new file mode 100644 index 0000000..6f81405 --- /dev/null +++ b/peaceful_npc/init.lua @@ -0,0 +1,21 @@ +--Config +instakill_sword = false +mode_debug = false + +--Loads other files +dofile(minetest.get_modpath("peaceful_npc").."/npc/npc_def.lua") +dofile(minetest.get_modpath("peaceful_npc").."/npc/npc_fast.lua") +dofile(minetest.get_modpath("peaceful_npc").."/npc/npc_dwarf.lua") +dofile(minetest.get_modpath("peaceful_npc").."/commands.lua") +dofile(minetest.get_modpath("peaceful_npc").."/items.lua") +dofile(minetest.get_modpath("peaceful_npc").."/spawning.lua") +dofile(minetest.get_modpath("peaceful_npc").."/recipes.lua") + +--NPC Privilege +minetest.register_privilege("peacefulnpc", { description = "allows to use spawn command", give_to_singleplayer = true}) + +--Aliases +minetest.register_alias("peaceful_npc:npc", "peaceful_npc:npc_def") + + +print("Peaceful NPC loaded! By jojoa1997!") diff --git a/peaceful_npc/items.lua b/peaceful_npc/items.lua new file mode 100644 index 0000000..f3a6828 --- /dev/null +++ b/peaceful_npc/items.lua @@ -0,0 +1,184 @@ +--Spawn code +function npc_spawner(pos, SPAWN_TYPE) + local MAX_NPC = 5 + local count = table.getn(minetest.get_objects_inside_radius(pos, 50)) + if count == nil then + count = 0 + end + + if count <= MAX_NPC then + minetest.add_entity({x=pos.x+math.random(-1,1),y=pos.y+math.random(2,3),z=pos.z+math.random(-1,1)}, SPAWN_TYPE) + end +end + +--Item Code for default npcs +minetest.register_node("peaceful_npc:summoner_npc_def", { + description = "Default NPC Summoner", + image = "peaceful_npc_npc_summoner_def.png", + inventory_image = "peaceful_npc_npc_summoner_def.png", + wield_image = "peaceful_npc_npc_summoner_def.png", + paramtype = "light", + tiles = {"peaceful_npc_spawnegg.png"}, + is_ground_content = true, + drawtype = "glasslike", + groups = {crumbly=3}, + selection_box = { + type = "fixed", + fixed = {0,0,0,0,0,0} + }, + sounds = default.node_sound_dirt_defaults(), + on_place = function(itemstack, placer, pointed) + local name = placer:get_player_name() + if (minetest.check_player_privs(name, {peacefulnpc=true})) then + pos = pointed.above + pos.y = pos.y + 1 + minetest.add_entity(pointed.above,"peaceful_npc:npc_def") + itemstack:take_item(1) + else + minetest.chat_send_player(name, "Nope! You need to have the peacefulnpc priv!") + end + return itemstack +end +}) + +minetest.register_node("peaceful_npc:spawner_npc_def", { + description = "Default NPC Portal", + drawtype = "glasslike", + groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1}, + sounds = default.node_sound_glass_defaults(), + tiles = {"peaceful_npc_spawner_def.png"}, + sunlight_propagates = true, + paramtype = "light", + mesecons = {effector = { + action_on = function(pos) npc_spawner(pos, "peaceful_npc:npc_def") end, + }} +}) +minetest.register_abm({ + nodenames = {"peaceful_npc:spawner_npc_def"}, + interval = 20, + chance = 10, + action = function(pos) + npc_spawner(pos, "peaceful_npc:npc_def") + end, +}) + +--Item Code for fast npcs +minetest.register_node("peaceful_npc:summoner_npc_fast", { + description = "Fast NPC Summoner", + image = "peaceful_npc_npc_summoner_fast.png", + inventory_image = "peaceful_npc_npc_summoner_fast.png", + wield_image = "peaceful_npc_npc_summoner_fast.png", + paramtype = "light", + tiles = {"peaceful_npc_spawnegg.png"}, + is_ground_content = true, + drawtype = "glasslike", + groups = {crumbly=3}, + selection_box = { + type = "fixed", + fixed = {0,0,0,0,0,0} + }, + sounds = default.node_sound_dirt_defaults(), + on_place = function(itemstack, placer, pointed) + local name = placer:get_player_name() + if (minetest.check_player_privs(name, {peacefulnpc=true})) then + pos = pointed.above + pos.y = pos.y + 1 + minetest.add_entity(pointed.above,"peaceful_npc:npc_fast") + itemstack:take_item(1) + else + minetest.chat_send_player(name, "Nope! You need to have the peacefulnpc priv!") + end + return itemstack +end +}) + +minetest.register_node("peaceful_npc:spawner_npc_fast", { + description = "Fast NPC Portal", + drawtype = "glasslike", + groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1}, + sounds = default.node_sound_glass_defaults(), + tiles = {"peaceful_npc_spawner_fast.png"}, + sunlight_propagates = true, + paramtype = "light", + mesecons = {effector = { + action_on = function(pos) npc_spawner(pos, "peaceful_npc:npc_fast") end, + }} +}) +minetest.register_abm({ + nodenames = {"peaceful_npc:spawner_npc_fast"}, + interval = 30, + chance = 10, + action = function(pos) + npc_spawner(pos, "peaceful_npc:npc_fast") + end, +}) + +--Item Code for dwarf npcs +minetest.register_node("peaceful_npc:summoner_npc_dwarf", { + description = "Dwarf NPC Summoner", + image = "peaceful_npc_npc_summoner_dwarf.png", + inventory_image = "peaceful_npc_npc_summoner_dwarf.png", + wield_image = "peaceful_npc_npc_summoner_dwarf.png", + paramtype = "light", + tiles = {"peaceful_npc_spawnegg.png"}, + is_ground_content = true, + drawtype = "glasslike", + groups = {crumbly=3}, + selection_box = { + type = "fixed", + fixed = {0,0,0,0,0,0} + }, + sounds = default.node_sound_dirt_defaults(), + on_place = function(itemstack, placer, pointed) + local name = placer:get_player_name() + if (minetest.check_player_privs(name, {peacefulnpc=true})) then + pos = pointed.above + pos.y = pos.y + 1 + minetest.add_entity(pointed.above,"peaceful_npc:npc_dwarf") + itemstack:take_item(1) + else + minetest.chat_send_player(name, "Nope! You need to have the peacefulnpc priv!") + end + return itemstack +end +}) + +minetest.register_node("peaceful_npc:spawner_npc_dwarf", { + description = "Dwarf NPC Portal", + drawtype = "glasslike", + groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1}, + sounds = default.node_sound_glass_defaults(), + tiles = {"peaceful_npc_spawner_dwarf.png"}, + sunlight_propagates = true, + paramtype = "light", + mesecons = {effector = { + action_on = function(pos) npc_spawner(pos, "peaceful_npc:npc_dwarf") end, + }} +}) +minetest.register_abm({ + nodenames = {"peaceful_npc:spawner_npc_dwarf"}, + interval = 60, + chance = 10, + action = function(pos) + npc_spawner(pos, "peaceful_npc:npc_dwarf") + end, +}) + +if instakill_sword == true then + --Adds instakill sword + minetest.register_tool("peaceful_npc:sword_instakill", { + description = "Instakill Sword", + inventory_image = "default_tool_steelsword.png", + tool_capabilities = { + full_punch_interval = 0.1, + max_drop_level = 1, + groupcaps={ + fleshy={times={[1]=0.005, [2]=0.005, [3]=0.005}, uses=0, maxlevel=3}, + snappy={times={[2]=0.005, [3]=0.005}, uses=0, maxlevel=2}, + choppy={times={[3]=0.005}, uses=0, maxlevel=1} + }, + } + }) +end + +print("Peaceful NPC items.lua loaded! By jojoa1997!") diff --git a/peaceful_npc/models/archer.png b/peaceful_npc/models/archer.png Binary files differnew file mode 100644 index 0000000..756924e --- /dev/null +++ b/peaceful_npc/models/archer.png diff --git a/peaceful_npc/models/builder.png b/peaceful_npc/models/builder.png Binary files differnew file mode 100644 index 0000000..c6cf485 --- /dev/null +++ b/peaceful_npc/models/builder.png diff --git a/peaceful_npc/models/charmander.png b/peaceful_npc/models/charmander.png Binary files differnew file mode 100644 index 0000000..1bc123e --- /dev/null +++ b/peaceful_npc/models/charmander.png diff --git a/peaceful_npc/models/clonetrooper.png b/peaceful_npc/models/clonetrooper.png Binary files differnew file mode 100644 index 0000000..c5a261b --- /dev/null +++ b/peaceful_npc/models/clonetrooper.png diff --git a/peaceful_npc/models/cool_girl.png b/peaceful_npc/models/cool_girl.png Binary files differnew file mode 100644 index 0000000..72c9153 --- /dev/null +++ b/peaceful_npc/models/cool_girl.png diff --git a/peaceful_npc/models/diamond_ninja.png b/peaceful_npc/models/diamond_ninja.png Binary files differnew file mode 100644 index 0000000..a4d1e47 --- /dev/null +++ b/peaceful_npc/models/diamond_ninja.png diff --git a/peaceful_npc/models/dragon.png b/peaceful_npc/models/dragon.png Binary files differnew file mode 100644 index 0000000..259c0eb --- /dev/null +++ b/peaceful_npc/models/dragon.png diff --git a/peaceful_npc/models/dwarf_commoner.png b/peaceful_npc/models/dwarf_commoner.png Binary files differnew file mode 100644 index 0000000..054bb00 --- /dev/null +++ b/peaceful_npc/models/dwarf_commoner.png diff --git a/peaceful_npc/models/dwarf_girl.png b/peaceful_npc/models/dwarf_girl.png Binary files differnew file mode 100644 index 0000000..4376d4e --- /dev/null +++ b/peaceful_npc/models/dwarf_girl.png diff --git a/peaceful_npc/models/dwarf_king.png b/peaceful_npc/models/dwarf_king.png Binary files differnew file mode 100644 index 0000000..15502d9 --- /dev/null +++ b/peaceful_npc/models/dwarf_king.png diff --git a/peaceful_npc/models/dwarf_warrior.png b/peaceful_npc/models/dwarf_warrior.png Binary files differnew file mode 100644 index 0000000..e588e98 --- /dev/null +++ b/peaceful_npc/models/dwarf_warrior.png diff --git a/peaceful_npc/models/gangnam_dude.png b/peaceful_npc/models/gangnam_dude.png Binary files differnew file mode 100644 index 0000000..761b56b --- /dev/null +++ b/peaceful_npc/models/gangnam_dude.png diff --git a/peaceful_npc/models/golem.png b/peaceful_npc/models/golem.png Binary files differnew file mode 100644 index 0000000..badfc00 --- /dev/null +++ b/peaceful_npc/models/golem.png diff --git a/peaceful_npc/models/hunter.png b/peaceful_npc/models/hunter.png Binary files differnew file mode 100644 index 0000000..8ec41ca --- /dev/null +++ b/peaceful_npc/models/hunter.png diff --git a/peaceful_npc/models/ironknight.png b/peaceful_npc/models/ironknight.png Binary files differnew file mode 100644 index 0000000..77ca055 --- /dev/null +++ b/peaceful_npc/models/ironknight.png diff --git a/peaceful_npc/models/katniss.png b/peaceful_npc/models/katniss.png Binary files differnew file mode 100644 index 0000000..1b2d096 --- /dev/null +++ b/peaceful_npc/models/katniss.png diff --git a/peaceful_npc/models/kitty.png b/peaceful_npc/models/kitty.png Binary files differnew file mode 100644 index 0000000..1a4c864 --- /dev/null +++ b/peaceful_npc/models/kitty.png diff --git a/peaceful_npc/models/knightking.png b/peaceful_npc/models/knightking.png Binary files differnew file mode 100644 index 0000000..22b197b --- /dev/null +++ b/peaceful_npc/models/knightking.png diff --git a/peaceful_npc/models/miner.png b/peaceful_npc/models/miner.png Binary files differnew file mode 100644 index 0000000..3892edb --- /dev/null +++ b/peaceful_npc/models/miner.png diff --git a/peaceful_npc/models/ninja.png b/peaceful_npc/models/ninja.png Binary files differnew file mode 100644 index 0000000..957c290 --- /dev/null +++ b/peaceful_npc/models/ninja.png diff --git a/peaceful_npc/models/panda_girl.png b/peaceful_npc/models/panda_girl.png Binary files differnew file mode 100644 index 0000000..cbb518f --- /dev/null +++ b/peaceful_npc/models/panda_girl.png diff --git a/peaceful_npc/models/penguin_knight.png b/peaceful_npc/models/penguin_knight.png Binary files differnew file mode 100644 index 0000000..cdd8da1 --- /dev/null +++ b/peaceful_npc/models/penguin_knight.png diff --git a/peaceful_npc/models/pikachu.png b/peaceful_npc/models/pikachu.png Binary files differnew file mode 100644 index 0000000..d96526d --- /dev/null +++ b/peaceful_npc/models/pikachu.png diff --git a/peaceful_npc/models/santa_bikini_girl.png b/peaceful_npc/models/santa_bikini_girl.png Binary files differnew file mode 100644 index 0000000..a688f43 --- /dev/null +++ b/peaceful_npc/models/santa_bikini_girl.png diff --git a/peaceful_npc/models/squirtle.png b/peaceful_npc/models/squirtle.png Binary files differnew file mode 100644 index 0000000..edc1781 --- /dev/null +++ b/peaceful_npc/models/squirtle.png diff --git a/peaceful_npc/models/tron.png b/peaceful_npc/models/tron.png Binary files differnew file mode 100644 index 0000000..dd41ed2 --- /dev/null +++ b/peaceful_npc/models/tron.png diff --git a/peaceful_npc/models/warrior_panda.png b/peaceful_npc/models/warrior_panda.png Binary files differnew file mode 100644 index 0000000..799fd6e --- /dev/null +++ b/peaceful_npc/models/warrior_panda.png diff --git a/peaceful_npc/models/witch.png b/peaceful_npc/models/witch.png Binary files differnew file mode 100644 index 0000000..6308eb5 --- /dev/null +++ b/peaceful_npc/models/witch.png diff --git a/peaceful_npc/models/wizard.png b/peaceful_npc/models/wizard.png Binary files differnew file mode 100644 index 0000000..603022b --- /dev/null +++ b/peaceful_npc/models/wizard.png diff --git a/peaceful_npc/npc/npc_def.lua b/peaceful_npc/npc/npc_def.lua new file mode 100644 index 0000000..554911e --- /dev/null +++ b/peaceful_npc/npc/npc_def.lua @@ -0,0 +1,345 @@ +-- NPC max walk speed +walk_limit = 2 +--npc just walking around +chillaxin_speed = 1.5 +-- Player animation speed +animation_speed = 30 + +-- Player animation blending +-- Note: This is currently broken due to a bug in Irrlicht, leave at 0 +animation_blend = 0 + +-- Default player appearance +default_model_def = "character.b3d" +available_npc_textures_def = { + def_texture_1 = {"miner.png"}, + def_texture_2 = {"archer.png"}, + def_texture_3 = {"cool_girl.png"}, + def_texture_4 = {"builder.png"}, + def_texture_5 = {"panda_girl.png"} +} + +-- Frame ranges for each player model +function npc_get_animations_def(model) + if model == "character.b3d" then + return { + stand_START = 0, + stand_END = 79, + sit_START = 81, + sit_END = 160, + lay_START = 162, + lay_END = 166, + walk_START = 168, + walk_END = 187, + mine_START = 189, + mine_END = 198, + walk_mine_START = 200, + walk_mine_END = 219 + } + end +end + +local npc_model = {} +local npc_anim = {} +local npc_sneak = {} +local ANIM_STAND = 1 +local ANIM_SIT = 2 +local ANIM_LAY = 3 +local ANIM_WALK = 4 +local ANIM_WALK_MINE = 5 +local ANIM_MINE = 6 + +function npc_update_visuals_def(self) + --local name = get_player_name() + visual = default_model_def + npc_anim = 0 -- Animation will be set further below immediately + --npc_sneak[name] = false + prop = { + mesh = default_model_def, + textures = default_textures, + textures = available_npc_textures_def["def_texture_"..math.random(1,5)], + visual_size = {x=1, y=1, z=1}, + } + self.object:set_properties(prop) +end + +NPC_ENTITY_DEF = { + physical = true, + collisionbox = {-0.3,-1.0,-0.3, 0.3,0.8,0.3}, + visual = "mesh", + mesh = "character.b3d", + textures = {"character.png"}, + npc_anim = 0, + timer = 0, + turn_timer = 0, + vec = 0, + yaw = 0, + yawwer = 0, + state = 1, + jump_timer = 0, + door_timer = 0, + attacker = "", + attacking_timer = 0 +} + +NPC_ENTITY_DEF.on_activate = function(self) + npc_update_visuals_def(self) + self.anim = npc_get_animations_def(visual) + self.object:set_animation({x=self.anim.stand_START,y=self.anim.stand_END}, animation_speed_mod, animation_blend) + self.npc_anim = ANIM_STAND + self.object:setacceleration({x=0,y=-10,z=0}) + self.state = 1 + self.object:set_hp(50) +end + +NPC_ENTITY_DEF.on_punch = function(self, puncher) + for _,object in ipairs(minetest.get_objects_inside_radius(self.object:getpos(), 5)) do + if not object:is_player() then + if object:get_luaentity().name == "peaceful_npc:npc_def" then + object:get_luaentity().state = 3 + object:get_luaentity().attacker = puncher:get_player_name() + end + end + end + + if self.state ~= 3 then + self.state = 3 + self.attacker = puncher:get_player_name() + end + + if self.object:get_hp() == 0 then + local obj = minetest.add_item(self.object:getpos(), "default:stone_with_iron 10") + end +end + +NPC_ENTITY_DEF.on_step = function(self, dtime) + self.timer = self.timer + 0.01 + self.turn_timer = self.turn_timer + 0.01 + self.jump_timer = self.jump_timer + 0.01 + self.door_timer = self.door_timer + 0.01 + self.attacking_timer = self.attacking_timer + 0.01 + + local current_pos = self.object:getpos() + local current_node = minetest.get_node(current_pos) + if self.time_passed == nil then + self.time_passed = 0 + end + + self.time_passed = self.time_passed + dtime + + if self.time_passed >= 5 then + self.object:remove() + else + if current_node.name == "default:water_source" or + current_node.name == "default:water_flowing" or + current_node.name == "default:lava_source" or + current_node.name == "default:lava_flowing" + then + self.time_passed = self.time_passed + dtime + else + self.time_passed = 0 + end +end + + --collision detection prealpha + --[[ + for _,object in ipairs(minetest.get_objects_inside_radius(self.object:getpos(), 2)) do + if object:is_player() then + compare1 = object:getpos() + compare2 = self.object:getpos() + newx = compare2.x - compare1.x + newz = compare2.z - compare1.z + print(newx) + 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 == "peaceful_npc:npc" then + print("moo") + end + end + end + ]]-- + + --set npc to hostile in night, and revert npc back to peaceful in daylight + if minetest.get_timeofday() >= 0 and minetest.get_timeofday() < 0.25 and self.state ~= 4 then + self.state = 4 + elseif minetest.get_timeofday() > 0.25 and self.state == 4 then + self.state = 1 + end + --if mob is not in attack or hostile mode, set mob to walking or standing + if self.state < 3 then + if self.timer > math.random(1,20) then + self.state = math.random(1,2) + self.timer = 0 + end + end + --STANDING + if self.state == 1 then + self.yawwer = true + for _,object in ipairs(minetest.get_objects_inside_radius(self.object:getpos(), 3)) do + if object:is_player() then + self.yawwer = false + 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 + self.yaw = self.yaw + math.pi + end + self.yaw = self.yaw - 2 + self.object:setyaw(self.yaw) + end + end + + if self.turn_timer > math.random(1,4) and yawwer == true then + self.yaw = 360 * math.random() + self.object:setyaw(self.yaw) + self.turn_timer = 0 + end + self.object:setvelocity({x=0,y=self.object:getvelocity().y,z=0}) + if self.npc_anim ~= ANIM_STAND then + self.anim = npc_get_animations_def(visual) + self.object:set_animation({x=self.anim.stand_START,y=self.anim.stand_END}, animation_speed_mod, animation_blend) + self.npc_anim = ANIM_STAND + end + end + --WALKING + if self.state == 2 then + if self.present_timer == 1 then + minetest.add_item(self.object:getpos(),"default:coal_lump") + self.present_timer = 0 + end + if self.direction ~= nil then + self.object:setvelocity({x=self.direction.x*chillaxin_speed,y=self.object:getvelocity().y,z=self.direction.z*chillaxin_speed}) + end + if self.turn_timer > math.random(1,4) then + self.yaw = 360 * math.random() + self.object:setyaw(self.yaw) + self.turn_timer = 0 + self.direction = {x = math.sin(self.yaw)*-1, y = -10, z = math.cos(self.yaw)} + --self.object:setvelocity({x=self.direction.x,y=self.object:getvelocity().y,z=direction.z}) + --self.object:setacceleration(self.direction) + end + if self.npc_anim ~= ANIM_WALK then + self.anim = npc_get_animations_def(visual) + self.object:set_animation({x=self.anim.walk_START,y=self.anim.walk_END}, animation_speed_mod, animation_blend) + self.npc_anim = ANIM_WALK + end + --open a door [alpha] + if self.direction ~= nil then + if self.door_timer > 2 then + local is_a_door = minetest.get_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y,z=self.object:getpos().z + self.direction.z}).name + if is_a_door == "doors:door_wood_t_1" then + minetest.punch_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y-1,z=self.object:getpos().z + self.direction.z}) + self.door_timer = 0 + end + local is_in_door = minetest.get_node(self.object:getpos()).name + if is_in_door == "doors:door_wood_t_1" then + minetest.punch_node(self.object:getpos()) + end + end + end + --jump + if self.direction ~= nil then + if self.jump_timer > 0.3 then + if minetest.get_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y-1,z=self.object:getpos().z + self.direction.z}).name ~= "air" then + self.object:setvelocity({x=self.object:getvelocity().x,y=5,z=self.object:getvelocity().z}) + self.jump_timer = 0 + end + end + end + end + --WANDERING CONSTANTLY AT NIGHT + if self.state == 4 then + if self.npc_anim ~= ANIM_WALK then + self.anim = npc_get_animations_def(visual) + self.object:set_animation({x=self.anim.walk_START,y=self.anim.walk_END}, animation_speed_mod, animation_blend) + self.npc_anim = ANIM_WALK + end + for _,object in ipairs(minetest.get_objects_inside_radius(self.object:getpos(), 12)) do + if object:is_player() then + if object:get_hp() > 0 then + 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 + self.yaw = self.yaw + math.pi + end + self.yaw = self.yaw - 2 + self.object:setyaw(self.yaw) + self.direction = {x = math.sin(self.yaw)*-1, y = 0, z = math.cos(self.yaw)} + if self.direction ~= nil then + self.object:setvelocity({x=self.direction.x*2.5,y=self.object:getvelocity().y,z=self.direction.z*2.5}) + end + --jump over obstacles + if self.jump_timer > 0.3 then + if minetest.get_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y-1,z=self.object:getpos().z + self.direction.z}).name ~= "air" then + self.object:setvelocity({x=self.object:getvelocity().x,y=5,z=self.object:getvelocity().z}) + self.jump_timer = 0 + end + end + if self.direction ~= nil then + if self.door_timer > 2 then + local is_a_door = minetest.get_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y,z=self.object:getpos().z + self.direction.z}).name + if is_a_door == "doors:door_wood_t_1" then + minetest.punch_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y-1,z=self.object:getpos().z + self.direction.z}) + self.door_timer = 0 + end + local is_in_door = minetest.get_node(self.object:getpos()).name + if is_in_door == "doors:door_wood_t_1" then + minetest.punch_node(self.object:getpos()) + end + end + end + --return + end + elseif not object:is_player() then + self.state = 1 + self.attacker = "" + end + end + if self.direction ~= nil then + self.object:setvelocity({x=self.direction.x,y=self.object:getvelocity().y,z=self.direction.z}) + end + if self.turn_timer > math.random(1,4) then + self.yaw = 360 * math.random() + self.object:setyaw(self.yaw) + self.turn_timer = 0 + self.direction = {x = math.sin(self.yaw)*-1, y = -10, z = math.cos(self.yaw)} + end + if self.npc_anim ~= ANIM_WALK then + self.anim = npc_get_animations_def(visual) + self.object:set_animation({x=self.anim.walk_START,y=self.anim.walk_END}, animation_speed_mod, animation_blend) + self.npc_anim = ANIM_WALK + end + --open a door [alpha] + if self.direction ~= nil then + if self.door_timer > 2 then + local is_a_door = minetest.get_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y,z=self.object:getpos().z + self.direction.z}).name + if is_a_door == "doors:door_wood_t_1" then + --print("door") + minetest.punch_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y-1,z=self.object:getpos().z + self.direction.z}) + self.door_timer = 0 + end + local is_in_door = minetest.get_node(self.object:getpos()).name + --print(dump(is_in_door)) + if is_in_door == "doors:door_wood_t_1" then + minetest.punch_node(self.object:getpos()) + end + end + end + --jump + if self.direction ~= nil then + if self.jump_timer > 0.3 then + --print(dump(minetest.get_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y-1,z=self.object:getpos().z + self.direction.z}))) + if minetest.get_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y-1,z=self.object:getpos().z + self.direction.z}).name ~= "air" then + self.object:setvelocity({x=self.object:getvelocity().x,y=2.5,z=self.object:getvelocity().z}) + self.jump_timer = 0 + end + end + end + end +end + +minetest.register_entity("peaceful_npc:npc_def", NPC_ENTITY_DEF) diff --git a/peaceful_npc/npc/npc_dwarf.lua b/peaceful_npc/npc/npc_dwarf.lua new file mode 100644 index 0000000..c3841a1 --- /dev/null +++ b/peaceful_npc/npc/npc_dwarf.lua @@ -0,0 +1,345 @@ +-- NPC max walk speed +walk_limit = 1 +--npc just walking around +chillaxin_speed = .5 +-- Player animation speed +animation_speed = 15 + +-- Player animation blending +-- Note: This is currently broken due to a bug in Irrlicht, leave at 0 +animation_blend = 0 + +-- Default player appearance +default_model_dwarf = "character.b3d" +available_npc_textures_dwarf = { + dwarf_texture_1 = {"dwarf_commoner.png"}, + dwarf_texture_2 = {"dwarf_girl.png"}, + dwarf_texture_3 = {"dwarf_king.png"}, + dwarf_texture_4 = {"dwarf_warrior.png"} +} + +-- Frame ranges for each player model +function npc_get_animations_dwarf(model) + if model == "character.b3d" then + return { + stand_START = 0, + stand_END = 79, + sit_START = 81, + sit_END = 160, + lay_START = 162, + lay_END = 166, + walk_START = 168, + walk_END = 187, + mine_START = 189, + mine_END = 198, + walk_mine_START = 200, + walk_mine_END = 219 + } + end +end + +local npc_model = {} +local npc_anim = {} +local npc_sneak = {} +local ANIM_STAND = 1 +local ANIM_SIT = 2 +local ANIM_LAY = 3 +local ANIM_WALK = 4 +local ANIM_WALK_MINE = 5 +local ANIM_MINE = 6 + +function npc_update_visuals_dwarf(self) + --local name = get_player_name() + visual = default_model_dwarf + npc_anim = 0 -- Animation will be set further below immediately + --npc_sneak[name] = false + prop = { + mesh = default_model_dwarf, + textures = default_textures, + textures = available_npc_textures_dwarf["dwarf_texture_"..math.random(1,4)], + visual_size = {x=.5, y=.5, z=.5}, + } + self.object:set_properties(prop) +end + +NPC_ENTITY_DWARF = { + physical = true, + lightsource = 5, + collisionbox = {-0.15,-0.5,-0.15, 0.15,0.4,0.15}, + visual = "mesh", + mesh = "character.b3d", + textures = {"character.png"}, + npc_anim = 0, + timer = 0, + turn_timer = 0, + vec = 0, + yaw = 0, + yawwer = 0, + state = 1, + jump_timer = 0, + door_timer = 0, + attacker = "", + attacking_timer = 0 +} + +NPC_ENTITY_DWARF.on_activate = function(self) + npc_update_visuals_dwarf(self) + self.anim = npc_get_animations_dwarf(visual) + self.object:set_animation({x=self.anim.stand_START,y=self.anim.stand_END}, animation_speed_mod, animation_blend) + self.npc_anim = ANIM_STAND + self.object:setacceleration({x=0,y=-10,z=0}) + self.state = 1 + self.object:set_hp(75) +end + +NPC_ENTITY_DWARF.on_punch = function(self, puncher) + for _,object in ipairs(minetest.get_objects_inside_radius(self.object:getpos(), 5)) do + if not object:is_player() then + if object:get_luaentity().name == "peaceful_npc:npc_dwarf" then + object:get_luaentity().state = 3 + object:get_luaentity().attacker = puncher:get_player_name() + end + end + end + + if self.state ~= 3 then + self.state = 3 + self.attacker = puncher:get_player_name() + end + + if self.object:get_hp() == 0 then + local obj = minetest.add_item(self.object:getpos(), "default:stone_with_mese 12") + end +end + +NPC_ENTITY_DWARF.on_step = function(self, dtime) + self.timer = self.timer + 0.01 + self.turn_timer = self.turn_timer + 0.01 + self.jump_timer = self.jump_timer + 0.01 + self.door_timer = self.door_timer + 0.01 + self.attacking_timer = self.attacking_timer + 0.01 + + local current_pos = self.object:getpos() + local current_node = minetest.get_node(current_pos) + if self.time_passed == nil then + self.time_passed = 0 + end + + self.time_passed = self.time_passed + dtime + + if self.time_passed >= 15 then + self.object:remove() + else + if current_node.name == "default:water_source" or + current_node.name == "default:water_flowing" or + current_node.name == "default:lava_source" or + current_node.name == "default:lava_flowing" + then + self.time_passed = self.time_passed + dtime + else + self.time_passed = 0 + end +end + + --collision detection prealpha + --[[ + for _,object in ipairs(minetest.get_objects_inside_radius(self.object:getpos(), 2)) do + if object:is_player() then + compare1 = object:getpos() + compare2 = self.object:getpos() + newx = compare2.x - compare1.x + newz = compare2.z - compare1.z + print(newx) + 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 == "peaceful_npc:npc" then + print("moo") + end + end + end + ]]-- + + --set npc to hostile in night, and revert npc back to peaceful in daylight + if minetest.get_timeofday() >= 0 and minetest.get_timeofday() < 0.25 and self.state ~= 4 then + self.state = 4 + elseif minetest.get_timeofday() > 0.25 and self.state == 4 then + self.state = 1 + end + --if mob is not in attack or hostile mode, set mob to walking or standing + if self.state < 3 then + if self.timer > math.random(1,20) then + self.state = math.random(1,2) + self.timer = 0 + end + end + --STANDING + if self.state == 1 then + self.yawwer = true + for _,object in ipairs(minetest.get_objects_inside_radius(self.object:getpos(), 3)) do + if object:is_player() then + self.yawwer = false + 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 + self.yaw = self.yaw + math.pi + end + self.yaw = self.yaw - 2 + self.object:setyaw(self.yaw) + end + end + + if self.turn_timer > math.random(1,4) and yawwer == true then + self.yaw = 360 * math.random() + self.object:setyaw(self.yaw) + self.turn_timer = 0 + end + self.object:setvelocity({x=0,y=self.object:getvelocity().y,z=0}) + if self.npc_anim ~= ANIM_STAND then + self.anim = npc_get_animations_dwarf(visual) + self.object:set_animation({x=self.anim.stand_START,y=self.anim.stand_END}, animation_speed_mod, animation_blend) + self.npc_anim = ANIM_STAND + end + end + --WALKING + if self.state == 2 then + if self.present_timer == 1 then + minetest.add_item(self.object:getpos(),"default:coal_lump") + self.present_timer = 0 + end + if self.direction ~= nil then + self.object:setvelocity({x=self.direction.x*chillaxin_speed,y=self.object:getvelocity().y,z=self.direction.z*chillaxin_speed}) + end + if self.turn_timer > math.random(1,4) then + self.yaw = 360 * math.random() + self.object:setyaw(self.yaw) + self.turn_timer = 0 + self.direction = {x = math.sin(self.yaw)*-1, y = -10, z = math.cos(self.yaw)} + --self.object:setvelocity({x=self.direction.x,y=self.object:getvelocity().y,z=direction.z}) + --self.object:setacceleration(self.direction) + end + if self.npc_anim ~= ANIM_WALK then + self.anim = npc_get_animations_dwarf(visual) + self.object:set_animation({x=self.anim.walk_START,y=self.anim.walk_END}, animation_speed_mod, animation_blend) + self.npc_anim = ANIM_WALK + end + --open a door [alpha] + if self.direction ~= nil then + if self.door_timer > 2 then + local is_a_door = minetest.get_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y,z=self.object:getpos().z + self.direction.z}).name + if is_a_door == "doors:door_wood_t_1" then + minetest.punch_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y-1,z=self.object:getpos().z + self.direction.z}) + self.door_timer = 0 + end + local is_in_door = minetest.get_node(self.object:getpos()).name + if is_in_door == "doors:door_wood_t_1" then + minetest.punch_node(self.object:getpos()) + end + end + end + --jump + if self.direction ~= nil then + if self.jump_timer > 0.3 then + if minetest.get_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y-1,z=self.object:getpos().z + self.direction.z}).name ~= "air" then + self.object:setvelocity({x=self.object:getvelocity().x,y=2.5,z=self.object:getvelocity().z}) + self.jump_timer = 0 + end + end + end + end + --WANDERING CONSTANTLY AT NIGHT + if self.state == 4 then + if self.npc_anim ~= ANIM_WALK then + self.anim = npc_get_animations_dwarf(visual) + self.object:set_animation({x=self.anim.walk_START,y=self.anim.walk_END}, animation_speed_mod, animation_blend) + self.npc_anim = ANIM_WALK + end + for _,object in ipairs(minetest.get_objects_inside_radius(self.object:getpos(), 12)) do + if object:is_player() then + if object:get_hp() > 0 then + 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 + self.yaw = self.yaw + math.pi + end + self.yaw = self.yaw - 2 + self.object:setyaw(self.yaw) + self.direction = {x = math.sin(self.yaw)*-1, y = 0, z = math.cos(self.yaw)} + if self.direction ~= nil then + self.object:setvelocity({x=self.direction.x*2.5,y=self.object:getvelocity().y,z=self.direction.z*2.5}) + end + --jump over obstacles + if self.jump_timer > 0.3 then + if minetest.get_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y-1,z=self.object:getpos().z + self.direction.z}).name ~= "air" then + self.object:setvelocity({x=self.object:getvelocity().x,y=5,z=self.object:getvelocity().z}) + self.jump_timer = 0 + end + end + if self.direction ~= nil then + if self.door_timer > 2 then + local is_a_door = minetest.get_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y,z=self.object:getpos().z + self.direction.z}).name + if is_a_door == "doors:door_wood_t_1" then + minetest.punch_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y-1,z=self.object:getpos().z + self.direction.z}) + self.door_timer = 0 + end + local is_in_door = minetest.get_node(self.object:getpos()).name + if is_in_door == "doors:door_wood_t_1" then + minetest.punch_node(self.object:getpos()) + end + end + end + --return + end + elseif not object:is_player() then + self.state = 1 + self.attacker = "" + end + end + if self.direction ~= nil then + self.object:setvelocity({x=self.direction.x,y=self.object:getvelocity().y,z=self.direction.z}) + end + if self.turn_timer > math.random(1,4) then + self.yaw = 360 * math.random() + self.object:setyaw(self.yaw) + self.turn_timer = 0 + self.direction = {x = math.sin(self.yaw)*-1, y = -10, z = math.cos(self.yaw)} + end + if self.npc_anim ~= ANIM_WALK then + self.anim = npc_get_animations_dwarf(visual) + self.object:set_animation({x=self.anim.walk_START,y=self.anim.walk_END}, animation_speed_mod, animation_blend) + self.npc_anim = ANIM_WALK + end + --open a door [alpha] + if self.direction ~= nil then + if self.door_timer > 2 then + local is_a_door = minetest.get_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y,z=self.object:getpos().z + self.direction.z}).name + if is_a_door == "doors:door_wood_t_1" then + --print("door") + minetest.punch_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y-1,z=self.object:getpos().z + self.direction.z}) + self.door_timer = 0 + end + local is_in_door = minetest.get_node(self.object:getpos()).name + --print(dump(is_in_door)) + if is_in_door == "doors:door_wood_t_1" then + minetest.punch_node(self.object:getpos()) + end + end + end + --jump + if self.direction ~= nil then + if self.jump_timer > 0.3 then + --print(dump(minetest.get_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y-1,z=self.object:getpos().z + self.direction.z}))) + if minetest.get_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y-1,z=self.object:getpos().z + self.direction.z}).name ~= "air" then + self.object:setvelocity({x=self.object:getvelocity().x,y=5,z=self.object:getvelocity().z}) + self.jump_timer = 0 + end + end + end + end +end + +minetest.register_entity("peaceful_npc:npc_dwarf", NPC_ENTITY_DWARF) diff --git a/peaceful_npc/npc/npc_fast.lua b/peaceful_npc/npc/npc_fast.lua new file mode 100644 index 0000000..00e2141 --- /dev/null +++ b/peaceful_npc/npc/npc_fast.lua @@ -0,0 +1,346 @@ +-- NPC max walk speed +walk_limit = 4 +--npc just walking around +chillaxin_speed = 3 +-- Player animation speed +animation_speed = 40 + +-- Player animation blending +-- Note: This is currently broken due to a bug in Irrlicht, leave at 0 +animation_blend = 0 + +-- Default player appearance +default_model = "character.b3d" +available_npc_textures_fast = { + fast_texture_1 = {"diamond_ninja.png"}, + fast_texture_2 = {"tron.png"}, + fast_texture_3 = {"ninja.png"}, + fast_texture_4 = {"hunter.png"}, + fast_texture_5 = {"dragon.png"} +} + +-- Frame ranges for each player model +function npc_get_animations_fast(model) + if model == "character.b3d" then + return { + stand_START = 0, + stand_END = 79, + sit_START = 81, + sit_END = 160, + lay_START = 162, + lay_END = 166, + walk_START = 168, + walk_END = 187, + mine_START = 189, + mine_END = 198, + walk_mine_START = 200, + walk_mine_END = 219 + } + end +end + +local npc_model = {} +local npc_anim = {} +local npc_sneak = {} +local ANIM_STAND = 1 +local ANIM_SIT = 2 +local ANIM_LAY = 3 +local ANIM_WALK = 4 +local ANIM_WALK_MINE = 5 +local ANIM_MINE = 6 + +function npc_update_visuals_fast(self) + --local name = get_player_name() + visual = default_model + npc_anim = 0 -- Animation will be set further below immediately + --npc_sneak[name] = false + prop = { + mesh = default_model, + textures = default_textures, + textures = available_npc_textures_fast["fast_texture_"..math.random(1,5)], + visual_size = {x=.75, y=.75, z=.75}, + } + self.object:set_properties(prop) +end + +NPC_ENTITY_FAST = { + physical = true, + collisionbox = {-0.3,-0.8,-0.3, 0.3,0.6,0.3}, + visual = "mesh", + mesh = "character.b3d", + textures = {"character.png"}, + npc_anim = 0, + timer = 0, + turn_timer = 0, + vec = 0, + yaw = 0, + yawwer = 0, + state = 1, + jump_timer = 0, + door_timer = 0, + attacker = "", + attacking_timer = 0 +} + +NPC_ENTITY_FAST.on_activate = function(self) + npc_update_visuals_fast(self) + self.anim = npc_get_animations_fast(visual) + self.object:set_animation({x=self.anim.stand_START,y=self.anim.stand_END}, animation_speed_mod, animation_blend) + self.npc_anim = ANIM_STAND + self.object:setacceleration({x=0,y=-10,z=0}) + self.state = 1 + self.object:set_hp(40) +end + +NPC_ENTITY_FAST.on_punch = function(self, puncher) + for _,object in ipairs(minetest.get_objects_inside_radius(self.object:getpos(), 5)) do + if not object:is_player() then + if object:get_luaentity().name == "peaceful_npc:npc_fast" then + object:get_luaentity().state = 3 + object:get_luaentity().attacker = puncher:get_player_name() + end + end + end + + if self.state ~= 3 then + self.state = 3 + self.attacker = puncher:get_player_name() + end + + if self.object:get_hp() == 0 then + local obj = minetest.add_item(self.object:getpos(), "default:stone_with_coal 5") + end +end + +NPC_ENTITY_FAST.on_step = function(self, dtime) + self.timer = self.timer + 0.01 + self.turn_timer = self.turn_timer + 0.01 + self.jump_timer = self.jump_timer + 0.01 + self.door_timer = self.door_timer + 0.01 + self.attacking_timer = self.attacking_timer + 0.01 + + local current_pos = self.object:getpos() + local current_node = minetest.get_node(current_pos) + if self.time_passed == nil then + self.time_passed = 0 + end + + self.time_passed = self.time_passed + dtime + + if self.time_passed >= 15 then + self.object:remove() + else + if current_node.name == "default:water_source" or + current_node.name == "default:water_flowing" or + current_node.name == "default:lava_source" or + current_node.name == "default:lava_flowing" + then + self.time_passed = self.time_passed + dtime + else + self.time_passed = 2 + end +end + + --collision detection prealpha + --[[ + for _,object in ipairs(minetest.get_objects_inside_radius(self.object:getpos(), 2)) do + if object:is_player() then + compare1 = object:getpos() + compare2 = self.object:getpos() + newx = compare2.x - compare1.x + newz = compare2.z - compare1.z + print(newx) + 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 == "peaceful_npc:npc" then + print("moo") + end + end + end + ]]-- + + --set npc to hostile in night, and revert npc back to peaceful in daylight + if minetest.get_timeofday() >= 0 and minetest.get_timeofday() < 0.25 and self.state ~= 4 then + self.state = 4 + elseif minetest.get_timeofday() > 0.25 and self.state == 4 then + self.state = 1 + end + --if mob is not in attack or hostile mode, set mob to walking or standing + if self.state < 3 then + if self.timer > math.random(1,20) then + self.state = math.random(1,2) + self.timer = 0 + end + end + --STANDING + if self.state == 1 then + self.yawwer = true + for _,object in ipairs(minetest.get_objects_inside_radius(self.object:getpos(), 3)) do + if object:is_player() then + self.yawwer = false + 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 + self.yaw = self.yaw + math.pi + end + self.yaw = self.yaw - 2 + self.object:setyaw(self.yaw) + end + end + + if self.turn_timer > math.random(1,4) and yawwer == true then + self.yaw = 360 * math.random() + self.object:setyaw(self.yaw) + self.turn_timer = 0 + end + self.object:setvelocity({x=0,y=self.object:getvelocity().y,z=0}) + if self.npc_anim ~= ANIM_STAND then + self.anim = npc_get_animations_def(visual) + self.object:set_animation({x=self.anim.stand_START,y=self.anim.stand_END}, animation_speed_mod, animation_blend) + self.npc_anim = ANIM_STAND + end + end + --WALKING + if self.state == 2 then + if self.present_timer == 1 then + minetest.add_item(self.object:getpos(),"default:coal_lump") + self.present_timer = 0 + end + if self.direction ~= nil then + self.object:setvelocity({x=self.direction.x*chillaxin_speed,y=self.object:getvelocity().y,z=self.direction.z*chillaxin_speed}) + end + if self.turn_timer > math.random(1,4) then + self.yaw = 360 * math.random() + self.object:setyaw(self.yaw) + self.turn_timer = 0 + self.direction = {x = math.sin(self.yaw)*-1, y = -10, z = math.cos(self.yaw)} + --self.object:setvelocity({x=self.direction.x,y=self.object:getvelocity().y,z=direction.z}) + --self.object:setacceleration(self.direction) + end + if self.npc_anim ~= ANIM_WALK then + self.anim = npc_get_animations_fast(visual) + self.object:set_animation({x=self.anim.walk_START,y=self.anim.walk_END}, animation_speed_mod, animation_blend) + self.npc_anim = ANIM_WALK + end + --open a door [alpha] + if self.direction ~= nil then + if self.door_timer > 2 then + local is_a_door = minetest.get_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y,z=self.object:getpos().z + self.direction.z}).name + if is_a_door == "doors:door_wood_t_1" then + minetest.punch_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y-1,z=self.object:getpos().z + self.direction.z}) + self.door_timer = 0 + end + local is_in_door = minetest.get_node(self.object:getpos()).name + if is_in_door == "doors:door_wood_t_1" then + minetest.punch_node(self.object:getpos()) + end + end + end + --jump + if self.direction ~= nil then + if self.jump_timer > 0.3 then + if minetest.get_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y-1,z=self.object:getpos().z + self.direction.z}).name ~= "air" then + self.object:setvelocity({x=self.object:getvelocity().x,y=2.5,z=self.object:getvelocity().z}) + self.jump_timer = 0 + end + end + end + end + --WANDERING CONSTANTLY AT NIGHT + if self.state == 4 then + if self.npc_anim ~= ANIM_WALK then + self.anim = npc_get_animations_fast(visual) + self.object:set_animation({x=self.anim.walk_START,y=self.anim.walk_END}, animation_speed_mod, animation_blend) + self.npc_anim = ANIM_WALK + end + for _,object in ipairs(minetest.get_objects_inside_radius(self.object:getpos(), 12)) do + if object:is_player() then + if object:get_hp() > 0 then + 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 + self.yaw = self.yaw + math.pi + end + self.yaw = self.yaw - 2 + self.object:setyaw(self.yaw) + self.direction = {x = math.sin(self.yaw)*-1, y = 0, z = math.cos(self.yaw)} + if self.direction ~= nil then + self.object:setvelocity({x=self.direction.x*2.5,y=self.object:getvelocity().y,z=self.direction.z*2.5}) + end + --jump over obstacles + if self.jump_timer > 0.3 then + if minetest.get_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y-1,z=self.object:getpos().z + self.direction.z}).name ~= "air" then + self.object:setvelocity({x=self.object:getvelocity().x,y=5,z=self.object:getvelocity().z}) + self.jump_timer = 0 + end + end + if self.direction ~= nil then + if self.door_timer > 2 then + local is_a_door = minetest.get_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y,z=self.object:getpos().z + self.direction.z}).name + if is_a_door == "doors:door_wood_t_1" then + minetest.punch_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y-1,z=self.object:getpos().z + self.direction.z}) + self.door_timer = 0 + end + local is_in_door = minetest.get_node(self.object:getpos()).name + if is_in_door == "doors:door_wood_t_1" then + minetest.punch_node(self.object:getpos()) + end + end + end + --return + end + elseif not object:is_player() then + self.state = 1 + self.attacker = "" + end + end + if self.direction ~= nil then + self.object:setvelocity({x=self.direction.x,y=self.object:getvelocity().y,z=self.direction.z}) + end + if self.turn_timer > math.random(1,4) then + self.yaw = 360 * math.random() + self.object:setyaw(self.yaw) + self.turn_timer = 0 + self.direction = {x = math.sin(self.yaw)*-1, y = -10, z = math.cos(self.yaw)} + end + if self.npc_anim ~= ANIM_WALK then + self.anim = npc_get_animations_fast(visual) + self.object:set_animation({x=self.anim.walk_START,y=self.anim.walk_END}, animation_speed_mod, animation_blend) + self.npc_anim = ANIM_WALK + end + --open a door [alpha] + if self.direction ~= nil then + if self.door_timer > 2 then + local is_a_door = minetest.get_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y,z=self.object:getpos().z + self.direction.z}).name + if is_a_door == "doors:door_wood_t_1" then + --print("door") + minetest.punch_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y-1,z=self.object:getpos().z + self.direction.z}) + self.door_timer = 0 + end + local is_in_door = minetest.get_node(self.object:getpos()).name + --print(dump(is_in_door)) + if is_in_door == "doors:door_wood_t_1" then + minetest.punch_node(self.object:getpos()) + end + end + end + --jump + if self.direction ~= nil then + if self.jump_timer > 0.3 then + --print(dump(minetest.get_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y-1,z=self.object:getpos().z + self.direction.z}))) + if minetest.get_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y-1,z=self.object:getpos().z + self.direction.z}).name ~= "air" then + self.object:setvelocity({x=self.object:getvelocity().x,y=5,z=self.object:getvelocity().z}) + self.jump_timer = 0 + end + end + end + end +end + +minetest.register_entity("peaceful_npc:npc_fast", NPC_ENTITY_FAST) + diff --git a/peaceful_npc/recipes.lua b/peaceful_npc/recipes.lua new file mode 100644 index 0000000..72707d3 --- /dev/null +++ b/peaceful_npc/recipes.lua @@ -0,0 +1,37 @@ +-- +--Crafts +-- +function npc_recipes(spawn_type, summon_core) + minetest.register_craft({ + output = 'peaceful_npc:spawner_npc_'..spawn_type, + recipe = { + {'default:mese_block', 'default:glass', 'default:mese_block'}, + {'default:glass', 'peaceful_npc:summoner_npc_'..spawn_type, 'default:glass'}, + {'default:mese_block', 'default:glass', 'default:mese_block'}, + } + }) + + minetest.register_craft({ + output = 'peaceful_npc:summoner_npc_'..spawn_type, + recipe = { + {'default:mese_crystal', 'default:glass', 'default:mese_crystal'}, + {'default:glass', summon_core, 'default:glass'}, + {'default:mese_crystal', 'default:glass', 'default:mese_crystal'}, + } + }) + + minetest.register_craft({ + output = 'peaceful_npc:summoner_npc_'..spawn_type, + recipe = { + {'default:mese', 'default:glass', 'default:mese'}, + {'default:glass', summon_core, 'default:glass'}, + {'default:mese', 'default:glass', 'default:mese'}, + } + }) +end + +npc_recipes('def', 'default:steel_ingot') +npc_recipes('fast', 'default:cactus') +npc_recipes('dwarf', 'bucket:bucket_lava') + +print("Peaceful NPC recipes.lua loaded! By jojoa1997!")
\ No newline at end of file diff --git a/peaceful_npc/schematics/Gambit_village_house.we b/peaceful_npc/schematics/Gambit_village_house.we new file mode 100644 index 0000000..3e18402 --- /dev/null +++ b/peaceful_npc/schematics/Gambit_village_house.we @@ -0,0 +1,268 @@ +0 0 6 default:cobble 0 0 +0 0 7 stairs:stair_cobble 13 1 +0 0 8 default:cobble 0 0 +0 1 6 default:cobble 0 0 +0 1 8 default:cobble 0 0 +0 2 6 default:fence_wood 13 0 +0 2 8 default:fence_wood 13 0 +0 3 0 stairs:stair_wood 13 1 +0 3 1 stairs:stair_wood 13 1 +0 3 2 stairs:stair_wood 13 1 +0 3 3 stairs:stair_wood 13 1 +0 3 4 stairs:stair_wood 13 1 +0 3 5 stairs:stair_wood 13 1 +0 3 6 stairs:stair_wood 13 1 +0 3 7 stairs:stair_wood 13 1 +0 3 8 stairs:stair_wood 13 1 +0 3 9 stairs:stair_wood 13 1 +0 3 10 stairs:stair_wood 13 1 +1 0 1 default:tree 0 0 +1 0 2 default:fence_wood 12 0 +1 0 3 default:fence_wood 12 0 +1 0 4 default:fence_wood 12 0 +1 0 5 default:fence_wood 12 0 +1 0 6 default:tree 0 0 +1 0 7 default:cobble 0 0 +1 0 8 default:tree 0 0 +1 0 9 default:tree 0 0 +1 1 1 default:tree 0 0 +1 1 2 default:cobble 0 0 +1 1 3 default:cobble 0 0 +1 1 4 default:cobble 0 0 +1 1 5 default:cobble 0 0 +1 1 6 default:tree 0 0 +1 1 7 doors:door_wood_b_2 12 2 +1 1 8 default:tree 0 0 +1 1 9 default:tree 0 0 +1 2 1 default:tree 0 0 +1 2 2 default:wood 0 0 +1 2 3 default:glass 12 0 +1 2 4 default:wood 0 0 +1 2 5 default:wood 0 0 +1 2 6 default:tree 0 0 +1 2 7 doors:door_wood_t_2 12 2 +1 2 8 default:tree 0 0 +1 2 9 default:tree 0 0 +1 3 1 default:tree 0 0 +1 3 2 default:wood 0 0 +1 3 3 default:wood 0 0 +1 3 4 default:wood 0 0 +1 3 5 default:wood 0 0 +1 3 6 default:wood 0 0 +1 3 7 default:wood 0 0 +1 3 8 default:wood 0 0 +1 3 9 default:tree 0 0 +1 4 0 stairs:stair_wood 13 1 +1 4 1 stairs:stair_wood 13 1 +1 4 2 stairs:stair_wood 13 1 +1 4 3 stairs:stair_wood 13 1 +1 4 4 stairs:stair_wood 13 1 +1 4 5 stairs:stair_wood 13 1 +1 4 6 stairs:stair_wood 13 1 +1 4 7 stairs:stair_wood 13 1 +1 4 8 stairs:stair_wood 13 1 +1 4 9 stairs:stair_wood 13 1 +1 4 10 stairs:stair_wood 13 1 +2 0 1 default:fence_wood 12 0 +2 0 2 default:tree 0 0 +2 0 3 default:tree 0 0 +2 0 4 default:tree 0 0 +2 0 5 default:tree 0 0 +2 0 6 default:tree 0 0 +2 0 7 default:tree 0 0 +2 0 8 default:tree 0 0 +2 0 9 default:fence_wood 12 0 +2 1 1 default:cobble 0 0 +2 1 2 default:cobble 0 0 +2 1 3 default:furnace 0 3 +2 1 4 default:cobble 0 0 +2 1 5 default:cobble 0 0 +2 1 8 default:fence_wood 10 0 +2 1 9 default:cobble 0 0 +2 2 1 default:wood 0 0 +2 2 2 default:fence_wood 10 0 +2 2 4 default:fence_wood 10 0 +2 2 5 default:papyrus 9 0 +2 2 8 default:fence_wood 10 0 +2 2 9 default:wood 0 0 +2 3 1 default:wood 0 0 +2 3 2 stairs:slab_wood 9 0 +2 3 3 stairs:slab_wood 10 0 +2 3 4 stairs:slab_wood 9 0 +2 3 5 stairs:slab_wood 8 0 +2 3 6 stairs:slab_wood 9 0 +2 3 7 stairs:slab_wood 10 0 +2 3 8 stairs:slab_wood 9 0 +2 3 9 default:wood 0 0 +2 4 1 default:wood 0 0 +2 4 2 default:chest 0 3 +2 4 3 default:chest 0 3 +2 4 4 default:chest 0 3 +2 4 5 default:bookshelf 0 0 +2 4 6 default:bookshelf 0 0 +2 4 7 default:bookshelf 0 0 +2 4 8 default:bookshelf 0 0 +2 4 9 default:wood 0 0 +2 5 0 stairs:stair_wood 13 1 +2 5 1 stairs:stair_wood 13 1 +2 5 2 stairs:stair_wood 13 1 +2 5 3 stairs:stair_wood 13 1 +2 5 4 stairs:stair_wood 13 1 +2 5 5 stairs:stair_wood 13 1 +2 5 6 stairs:stair_wood 13 1 +2 5 7 stairs:stair_wood 13 1 +2 5 8 stairs:stair_wood 13 1 +2 5 9 stairs:stair_wood 13 1 +2 5 10 stairs:stair_wood 13 1 +3 0 1 default:fence_wood 12 0 +3 0 2 default:tree 0 0 +3 0 3 default:tree 0 0 +3 0 4 default:tree 0 0 +3 0 5 default:tree 0 0 +3 0 6 default:tree 0 0 +3 0 7 default:tree 0 0 +3 0 8 default:tree 0 0 +3 0 9 default:fence_wood 12 0 +3 1 1 default:cobble 0 0 +3 1 5 default:cobble 0 0 +3 1 9 default:cobble 0 0 +3 2 1 default:glass 12 0 +3 2 5 default:papyrus 9 0 +3 2 9 default:glass 12 0 +3 3 1 default:wood 0 0 +3 3 8 stairs:slab_wood 10 0 +3 3 9 default:wood 0 0 +3 4 1 default:wood 0 0 +3 4 8 default:bookshelf 0 0 +3 4 9 default:wood 0 0 +3 5 0 default:wood 0 0 +3 5 1 default:wood 0 0 +3 5 2 default:wood 0 0 +3 5 3 default:wood 0 0 +3 5 4 default:wood 0 0 +3 5 5 default:wood 0 0 +3 5 6 default:wood 0 0 +3 5 7 default:wood 0 0 +3 5 8 default:wood 0 0 +3 5 9 default:wood 0 0 +3 5 10 default:wood 0 0 +4 0 1 default:fence_wood 12 0 +4 0 2 default:tree 0 0 +4 0 3 default:tree 0 0 +4 0 4 default:tree 0 0 +4 0 5 default:tree 0 0 +4 0 6 default:tree 0 0 +4 0 7 default:tree 0 0 +4 0 8 default:tree 0 0 +4 0 9 default:fence_wood 12 0 +4 1 1 default:cobble 0 0 +4 1 9 default:cobble 0 0 +4 2 1 default:glass 12 0 +4 2 9 default:glass 12 0 +4 3 1 default:wood 0 0 +4 3 8 stairs:slab_wood 10 0 +4 3 9 default:wood 0 0 +4 4 1 default:wood 0 0 +4 4 8 default:bookshelf 0 0 +4 4 9 default:wood 0 0 +4 5 0 default:wood 0 0 +4 5 1 default:wood 0 0 +4 5 2 default:wood 0 0 +4 5 3 default:wood 0 0 +4 5 4 default:wood 0 0 +4 5 5 default:wood 0 0 +4 5 6 default:wood 0 0 +4 5 7 default:wood 0 0 +4 5 8 default:wood 0 0 +4 5 9 default:wood 0 0 +4 5 10 default:wood 0 0 +5 0 1 default:fence_wood 12 0 +5 0 2 default:tree 0 0 +5 0 3 default:tree 0 0 +5 0 4 default:tree 0 0 +5 0 5 default:tree 0 0 +5 0 6 default:tree 0 0 +5 0 7 default:tree 0 0 +5 0 8 default:tree 0 0 +5 0 9 default:fence_wood 12 0 +5 1 1 default:cobble 0 0 +5 1 8 default:fence_wood 9 0 +5 1 9 default:cobble 0 0 +5 2 1 default:wood 0 0 +5 2 8 default:fence_wood 10 0 +5 2 9 default:wood 0 0 +5 3 1 default:wood 0 0 +5 3 8 stairs:slab_wood 10 0 +5 3 9 default:wood 0 0 +5 4 1 default:wood 0 0 +5 4 8 default:bookshelf 0 0 +5 4 9 default:wood 0 0 +5 5 0 stairs:stair_wood 13 3 +5 5 1 stairs:stair_wood 13 3 +5 5 2 stairs:stair_wood 13 3 +5 5 3 stairs:stair_wood 13 3 +5 5 4 stairs:stair_wood 13 3 +5 5 5 stairs:stair_wood 13 3 +5 5 6 stairs:stair_wood 13 3 +5 5 7 stairs:stair_wood 13 3 +5 5 8 stairs:stair_wood 13 3 +5 5 9 stairs:stair_wood 13 3 +5 5 10 stairs:stair_wood 13 3 +6 0 1 default:tree 0 0 +6 0 2 default:fence_wood 12 0 +6 0 3 default:fence_wood 12 0 +6 0 4 default:fence_wood 12 0 +6 0 5 default:fence_wood 12 0 +6 0 6 default:fence_wood 12 0 +6 0 7 default:fence_wood 12 0 +6 0 8 default:fence_wood 12 0 +6 0 9 default:tree 0 0 +6 1 1 default:tree 0 0 +6 1 2 default:cobble 0 0 +6 1 3 default:cobble 0 0 +6 1 4 default:cobble 0 0 +6 1 5 default:cobble 0 0 +6 1 6 default:cobble 0 0 +6 1 7 default:cobble 0 0 +6 1 8 default:cobble 0 0 +6 1 9 default:tree 0 0 +6 2 1 default:tree 0 0 +6 2 2 default:wood 0 0 +6 2 3 default:glass 12 0 +6 2 4 default:wood 0 0 +6 2 5 default:glass 12 0 +6 2 6 default:wood 0 0 +6 2 7 default:glass 12 0 +6 2 8 default:wood 0 0 +6 2 9 default:tree 0 0 +6 3 1 default:tree 0 0 +6 3 2 default:wood 0 0 +6 3 3 default:wood 0 0 +6 3 4 default:wood 0 0 +6 3 5 default:wood 0 0 +6 3 6 default:wood 0 0 +6 3 7 default:wood 0 0 +6 3 8 default:wood 0 0 +6 3 9 default:tree 0 0 +6 4 0 stairs:stair_wood 13 3 +6 4 1 stairs:stair_wood 13 3 +6 4 2 stairs:stair_wood 13 3 +6 4 3 stairs:stair_wood 13 3 +6 4 4 stairs:stair_wood 13 3 +6 4 5 stairs:stair_wood 13 3 +6 4 6 stairs:stair_wood 13 3 +6 4 7 stairs:stair_wood 13 3 +6 4 8 stairs:stair_wood 13 3 +6 4 9 stairs:stair_wood 13 3 +6 4 10 stairs:stair_wood 13 3 +7 3 0 stairs:stair_wood 13 3 +7 3 1 stairs:stair_wood 13 3 +7 3 2 stairs:stair_wood 13 3 +7 3 3 stairs:stair_wood 13 3 +7 3 4 stairs:stair_wood 13 3 +7 3 5 stairs:stair_wood 13 3 +7 3 6 stairs:stair_wood 13 3 +7 3 7 stairs:stair_wood 13 3 +7 3 8 stairs:stair_wood 13 3 +7 3 9 stairs:stair_wood 13 3 +7 3 10 stairs:stair_wood 13 3
\ No newline at end of file diff --git a/peaceful_npc/schematics/npc_blacksmith.we b/peaceful_npc/schematics/npc_blacksmith.we new file mode 100644 index 0000000..27daeb1 --- /dev/null +++ b/peaceful_npc/schematics/npc_blacksmith.we @@ -0,0 +1,275 @@ +0 0 0 default:cobble 0 0 +0 0 1 default:cobble 0 0 +0 0 2 default:cobble 0 0 +0 0 3 default:cobble 0 0 +0 0 4 default:cobble 0 0 +0 0 5 default:cobble 0 0 +0 0 6 default:cobble 0 0 +0 0 7 default:cobble 0 0 +0 0 8 default:cobble 0 0 +0 0 9 default:cobble 0 0 +0 1 0 default:cobble 0 0 +0 1 1 default:cobble 0 0 +0 1 2 default:cobble 0 0 +0 1 3 default:cobble 0 0 +0 1 4 default:wood 0 0 +0 1 5 default:wood 0 0 +0 1 6 default:wood 0 0 +0 1 7 default:wood 0 0 +0 1 8 default:wood 0 0 +0 1 9 default:tree 0 0 +0 2 0 default:cobble 0 0 +0 2 1 default:cobble 0 0 +0 2 2 default:cobble 0 0 +0 2 3 default:cobble 0 0 +0 2 4 default:wood 0 0 +0 2 5 default:glass 29 0 +0 2 6 default:wood 0 0 +0 2 7 default:glass 13 0 +0 2 8 default:wood 0 0 +0 2 9 default:tree 0 0 +0 3 0 default:cobble 0 0 +0 3 1 default:cobble 0 0 +0 3 2 default:cobble 0 0 +0 3 3 default:cobble 0 0 +0 3 4 default:wood 0 0 +0 3 5 default:wood 0 0 +0 3 6 default:wood 0 0 +0 3 7 default:wood 0 0 +0 3 8 default:wood 0 0 +0 3 9 default:tree 0 0 +0 4 0 default:cobble 0 0 +0 4 1 default:cobble 0 0 +0 4 2 default:cobble 0 0 +0 4 3 default:cobble 0 0 +0 4 4 default:cobble 0 0 +0 4 5 default:cobble 0 0 +0 4 6 default:cobble 0 0 +0 4 7 default:cobble 0 0 +0 4 8 default:cobble 0 0 +0 4 9 default:tree 0 0 +0 5 0 stairs:slab_stone 93 0 +0 5 1 stairs:slab_stone 77 0 +0 5 2 stairs:slab_stone 61 0 +0 5 3 stairs:slab_stone 45 0 +0 5 4 stairs:slab_stone 29 0 +0 5 5 stairs:slab_stone 13 0 +0 5 6 stairs:slab_stone 13 0 +0 5 7 stairs:slab_stone 13 0 +0 5 8 stairs:slab_stone 13 0 +0 5 9 stairs:slab_stone 13 0 +1 0 0 default:cobble 0 0 +1 0 1 default:cobble 0 0 +1 0 2 default:cobble 0 0 +1 0 3 default:cobble 0 0 +1 0 4 default:cobble 0 0 +1 0 5 default:cobble 0 0 +1 0 6 default:cobble 0 0 +1 0 7 default:cobble 0 0 +1 0 8 default:cobble 0 0 +1 0 9 default:cobble 0 0 +1 1 0 default:cobble 0 0 +1 1 1 default:lava_source 0 0 +1 1 2 default:lava_source 0 0 +1 1 3 default:cobble 0 0 +1 1 4 default:chest 0 2 +1 1 7 stairs:stair_wood 11 0 +1 1 8 default:wood 0 0 +1 1 9 default:wood 0 0 +1 2 0 default:glass 189 0 +1 2 3 default:cobble 0 0 +1 2 9 default:wood 0 0 +1 3 0 default:cobble 0 0 +1 3 1 default:cobble 0 0 +1 3 2 default:cobble 0 0 +1 3 3 default:cobble 0 0 +1 3 9 default:wood 0 0 +1 4 0 default:cobble 0 0 +1 4 1 default:cobble 0 0 +1 4 2 default:cobble 0 0 +1 4 3 default:cobble 0 0 +1 4 4 default:cobble 0 0 +1 4 5 default:cobble 0 0 +1 4 6 default:cobble 0 0 +1 4 7 default:cobble 0 0 +1 4 8 default:cobble 0 0 +1 4 9 default:cobble 0 0 +1 5 0 stairs:slab_stone 109 0 +1 5 9 stairs:slab_stone 13 0 +2 0 0 default:cobble 0 0 +2 0 1 default:cobble 0 0 +2 0 2 default:cobble 0 0 +2 0 3 default:cobble 0 0 +2 0 4 default:cobble 0 0 +2 0 5 default:cobble 0 0 +2 0 6 default:cobble 0 0 +2 0 7 default:cobble 0 0 +2 0 8 default:cobble 0 0 +2 0 9 default:cobble 0 0 +2 1 0 default:cobble 0 0 +2 1 1 default:cobble 0 0 +2 1 2 default:cobble 0 0 +2 1 3 default:cobble 0 0 +2 1 7 default:fence_wood 10 0 +2 1 8 stairs:stair_wood 11 3 +2 1 9 default:wood 0 0 +2 2 0 default:glass 173 0 +2 2 3 default:cobble 0 0 +2 2 9 default:glass 13 0 +2 3 0 default:cobble 0 0 +2 3 1 default:cobble 0 0 +2 3 2 default:cobble 0 0 +2 3 3 default:cobble 0 0 +2 3 9 default:wood 0 0 +2 4 0 default:cobble 0 0 +2 4 1 default:cobble 0 0 +2 4 2 default:cobble 0 0 +2 4 3 default:cobble 0 0 +2 4 4 default:cobble 0 0 +2 4 5 default:cobble 0 0 +2 4 6 default:cobble 0 0 +2 4 7 default:cobble 0 0 +2 4 8 default:cobble 0 0 +2 4 9 default:cobble 0 0 +2 5 0 stairs:slab_stone 93 0 +2 5 9 stairs:slab_stone 13 0 +3 0 0 default:cobble 0 0 +3 0 1 default:cobble 0 0 +3 0 2 default:cobble 0 0 +3 0 3 default:cobble 0 0 +3 0 4 default:cobble 0 0 +3 0 5 default:cobble 0 0 +3 0 6 default:cobble 0 0 +3 0 7 default:cobble 0 0 +3 0 8 default:cobble 0 0 +3 0 9 default:cobble 0 0 +3 1 3 default:cobble 0 0 +3 1 4 default:wood 0 0 +3 1 5 default:wood 0 0 +3 1 9 default:wood 0 0 +3 2 3 default:furnace 0 0 +3 2 4 default:wood 0 0 +3 2 5 default:wood 0 0 +3 2 9 default:wood 0 0 +3 3 3 default:furnace 0 0 +3 3 4 default:wood 0 0 +3 3 5 default:wood 0 0 +3 3 9 default:wood 0 0 +3 4 0 default:cobble 0 0 +3 4 1 default:cobble 0 0 +3 4 2 default:cobble 0 0 +3 4 3 default:cobble 0 0 +3 4 4 default:cobble 0 0 +3 4 5 default:cobble 0 0 +3 4 6 default:cobble 0 0 +3 4 7 default:cobble 0 0 +3 4 8 default:cobble 0 0 +3 4 9 default:cobble 0 0 +3 5 0 stairs:slab_stone 77 0 +3 5 9 stairs:slab_stone 13 0 +4 0 0 default:cobble 0 0 +4 0 1 default:cobble 0 0 +4 0 2 default:cobble 0 0 +4 0 3 default:cobble 0 0 +4 0 4 default:cobble 0 0 +4 0 5 default:cobble 0 0 +4 0 6 default:cobble 0 0 +4 0 7 default:cobble 0 0 +4 0 8 default:cobble 0 0 +4 0 9 default:cobble 0 0 +4 1 6 default:wood 0 0 +4 1 9 default:wood 0 0 +4 2 6 default:wood 0 0 +4 2 9 default:glass 13 0 +4 3 6 default:wood 0 0 +4 3 9 default:wood 0 0 +4 4 0 default:cobble 0 0 +4 4 1 default:cobble 0 0 +4 4 2 default:cobble 0 0 +4 4 3 default:cobble 0 0 +4 4 4 default:cobble 0 0 +4 4 5 default:cobble 0 0 +4 4 6 default:cobble 0 0 +4 4 7 default:cobble 0 0 +4 4 8 default:cobble 0 0 +4 4 9 default:cobble 0 0 +4 5 0 stairs:slab_stone 61 0 +4 5 9 stairs:slab_stone 13 0 +5 0 0 default:cobble 0 0 +5 0 1 default:cobble 0 0 +5 0 2 default:cobble 0 0 +5 0 3 default:cobble 0 0 +5 0 4 default:cobble 0 0 +5 0 5 default:cobble 0 0 +5 0 6 default:cobble 0 0 +5 0 7 default:cobble 0 0 +5 0 8 default:cobble 0 0 +5 0 9 default:cobble 0 0 +5 1 1 default:stone 0 0 +5 1 9 default:wood 0 0 +5 2 9 default:wood 0 0 +5 3 6 default:wood 0 0 +5 3 9 default:wood 0 0 +5 4 0 default:cobble 0 0 +5 4 1 default:cobble 0 0 +5 4 2 default:cobble 0 0 +5 4 3 default:cobble 0 0 +5 4 4 default:cobble 0 0 +5 4 5 default:cobble 0 0 +5 4 6 default:cobble 0 0 +5 4 7 default:cobble 0 0 +5 4 8 default:cobble 0 0 +5 4 9 default:cobble 0 0 +5 5 0 stairs:slab_stone 45 0 +5 5 9 stairs:slab_stone 13 0 +6 0 0 default:cobble 0 0 +6 0 1 default:cobble 0 0 +6 0 2 default:cobble 0 0 +6 0 3 default:cobble 0 0 +6 0 4 default:cobble 0 0 +6 0 5 default:cobble 0 0 +6 0 6 default:cobble 0 0 +6 0 7 default:cobble 0 0 +6 0 8 default:cobble 0 0 +6 0 9 default:cobble 0 0 +6 1 0 default:fence_wood 93 0 +6 1 4 default:fence_wood 77 0 +6 1 6 default:tree 0 0 +6 1 7 default:wood 0 0 +6 1 8 default:wood 0 0 +6 1 9 default:tree 0 0 +6 2 0 default:fence_wood 109 0 +6 2 4 default:fence_wood 93 0 +6 2 6 default:tree 0 0 +6 2 7 default:wood 0 0 +6 2 8 default:wood 0 0 +6 2 9 default:tree 0 0 +6 3 0 default:fence_wood 93 0 +6 3 4 default:fence_wood 77 0 +6 3 6 default:tree 0 0 +6 3 7 default:wood 0 0 +6 3 8 default:wood 0 0 +6 3 9 default:tree 0 0 +6 4 0 default:cobble 0 0 +6 4 1 default:cobble 0 0 +6 4 2 default:cobble 0 0 +6 4 3 default:cobble 0 0 +6 4 4 default:cobble 0 0 +6 4 5 default:cobble 0 0 +6 4 6 default:tree 0 0 +6 4 7 default:cobble 0 0 +6 4 8 default:cobble 0 0 +6 4 9 default:tree 0 0 +6 5 0 stairs:slab_stone 29 0 +6 5 1 stairs:slab_stone 45 0 +6 5 2 stairs:slab_stone 45 0 +6 5 3 stairs:slab_stone 29 0 +6 5 4 stairs:slab_stone 13 0 +6 5 5 stairs:slab_stone 13 0 +6 5 6 stairs:slab_stone 13 0 +6 5 7 stairs:slab_stone 13 0 +6 5 8 stairs:slab_stone 13 0 +6 5 9 stairs:slab_stone 13 0 +7 0 1 stairs:stair_cobble 77 3 +7 0 2 stairs:stair_cobble 77 3 +7 0 3 stairs:stair_cobble 61 3
\ No newline at end of file diff --git a/peaceful_npc/spawning.lua b/peaceful_npc/spawning.lua new file mode 100644 index 0000000..8ce8f6f --- /dev/null +++ b/peaceful_npc/spawning.lua @@ -0,0 +1,86 @@ +--Spawn function +function def_spawn(pos) + minetest.add_entity(pos, "peaceful_npc:npc_def") + print("want to spawn npc_def at "..dump(pos)) + if mode_debug == true then + minetest.chat_send_all("want to spawn npc_def at "..dump(pos)) + end +end + +function fast_spawn(pos) + minetest.add_entity(pos, "peaceful_npc:npc_fast") + print("want to spawn npc_fast at "..dump(pos)) + if mode_debug == true then + minetest.chat_send_all("want to spawn npc_fast at "..dump(pos)) + end +end + +function dwarf_spawn(pos) + minetest.add_entity(pos, "peaceful_npc:npc_dwarf") + print("want to spawn npc_dwarf at "..dump(pos)) + if mode_debug == true then + minetest.chat_send_all("want to spawn npc_dwarf at "..dump(pos)) + end +end + +--Mapgen biomes +plaingen_biome = { + surface = "default:dirt_with_grass", + avoid_nodes = {"group:liquid", "group:tree"}, + avoid_radius = 20, + rarity = 93, + max_count = 1, + min_elevation = -10, + max_elevation = 30, +} + +forestgen_biome = { + surface = {"group:tree", "default:leaves"}, + avoid_nodes = {"group:liquid"}, + avoid_radius = 10, + rarity = 96, + max_count = 1, + min_elevation = 20, + max_elevation = 50, +} + +beachgen_biome = { + surface = "default:sand", + avoid_nodes = {"group:liquid"}, + avoid_radius = 1, + rarity = 90, + max_count = 1, + min_elevation = 0, + max_elevation = 10, +} + +desertgen_biome = { + surface = { "default:desert_sand", "default:desert_stone"}, + avoid_nodes = {"group:liquid"}, + avoid_radius = 100, + rarity = 95, + max_count = 1, + min_elevation = 0, + max_elevation = 150, +} + +cavegen_biome = { + surface = { "default:stone_with_iron", "default:stone_with_coal", "default:stone_with_mese"}, + avoid_nodes = {"group:liquid"}, + avoid_radius = 5, + rarity = 98, + max_count = 1, + min_elevation = -500, + max_elevation = -50, + check_air = true, + spawn_replace_node = true, +} + +--spawn definers +biome_lib:register_generate_plant(plaingen_biome, "def_spawn") +biome_lib:register_generate_plant(forestgen_biome, "def_spawn") +biome_lib:register_generate_plant(beachgen_biome, "fast_spawn") +biome_lib:register_generate_plant(desertgen_biome, "fast_spawn") +biome_lib:register_generate_plant(cavegen_biome, "dwarf_spawn") + +print("Peaceful NPC spawning.lua loaded! By jojoa1997!")
\ No newline at end of file diff --git a/peaceful_npc/textures/peaceful_npc_npc_summoner_def.png b/peaceful_npc/textures/peaceful_npc_npc_summoner_def.png Binary files differnew file mode 100644 index 0000000..76932a9 --- /dev/null +++ b/peaceful_npc/textures/peaceful_npc_npc_summoner_def.png diff --git a/peaceful_npc/textures/peaceful_npc_npc_summoner_dwarf.png b/peaceful_npc/textures/peaceful_npc_npc_summoner_dwarf.png Binary files differnew file mode 100644 index 0000000..5ef7c3e --- /dev/null +++ b/peaceful_npc/textures/peaceful_npc_npc_summoner_dwarf.png diff --git a/peaceful_npc/textures/peaceful_npc_npc_summoner_fast.png b/peaceful_npc/textures/peaceful_npc_npc_summoner_fast.png Binary files differnew file mode 100644 index 0000000..9034d90 --- /dev/null +++ b/peaceful_npc/textures/peaceful_npc_npc_summoner_fast.png diff --git a/peaceful_npc/textures/peaceful_npc_spawnegg.png b/peaceful_npc/textures/peaceful_npc_spawnegg.png Binary files differnew file mode 100644 index 0000000..c2e8752 --- /dev/null +++ b/peaceful_npc/textures/peaceful_npc_spawnegg.png diff --git a/peaceful_npc/textures/peaceful_npc_spawner_def.png b/peaceful_npc/textures/peaceful_npc_spawner_def.png Binary files differnew file mode 100644 index 0000000..3be53b0 --- /dev/null +++ b/peaceful_npc/textures/peaceful_npc_spawner_def.png diff --git a/peaceful_npc/textures/peaceful_npc_spawner_dwarf.png b/peaceful_npc/textures/peaceful_npc_spawner_dwarf.png Binary files differnew file mode 100644 index 0000000..3a03bd4 --- /dev/null +++ b/peaceful_npc/textures/peaceful_npc_spawner_dwarf.png diff --git a/peaceful_npc/textures/peaceful_npc_spawner_fast.png b/peaceful_npc/textures/peaceful_npc_spawner_fast.png Binary files differnew file mode 100644 index 0000000..7fbc342 --- /dev/null +++ b/peaceful_npc/textures/peaceful_npc_spawner_fast.png diff --git a/peaceful_npc/todo.txt b/peaceful_npc/todo.txt new file mode 100644 index 0000000..9ce9868 --- /dev/null +++ b/peaceful_npc/todo.txt @@ -0,0 +1 @@ +i will be changeing the recipes to obsidian since it was added to minetest_game
\ No newline at end of file |