diff --git a/mods/mobs/textures/mobs_slime.png b/mods/mobs/textures/mobs_slime.png index 5b59585..44d372e 100644 Binary files a/mods/mobs/textures/mobs_slime.png and b/mods/mobs/textures/mobs_slime.png differ diff --git a/mods/npcs/LICENSE.txt b/mods/npcs/LICENSE.txt new file mode 100644 index 0000000..19baca3 --- /dev/null +++ b/mods/npcs/LICENSE.txt @@ -0,0 +1,25 @@ +License for Code +---------------- + +Copyright (C) 2017 cd2 (cdqwertz) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +http://www.gnu.org/licenses/lgpl-2.1.html + +License for Media +----------------- + +CC-BY-SA 3.0 UNPORTED. Created by cd2 (cdqwertz) diff --git a/mods/npcs/depends.txt b/mods/npcs/depends.txt new file mode 100644 index 0000000..01e8a73 --- /dev/null +++ b/mods/npcs/depends.txt @@ -0,0 +1,2 @@ +default +quests diff --git a/mods/npcs/init.lua b/mods/npcs/init.lua new file mode 100644 index 0000000..cb0f8bd --- /dev/null +++ b/mods/npcs/init.lua @@ -0,0 +1,49 @@ +npcs = {} +npcs.npcs = {} + +function npcs.register_npc(name, def) + npcs.npcs[name] = true + + def.description = def.description or "NPC" + def.groups = def.groups or "" + + def.drawtype = def.drawtype or "mesh" + if def.drawtype == "mesh" then + def.mesh = def.mesh or "npc.x" + def.paramtype = def.paramtype or "light" + def.paramtype2 = def.paramtype2 or "facedir" + def.visual_scale = def.visual_scale or 1.0 + end + + def.tiles = def.tiles or {"character.png"} + + if def.npc_type == "quest" then + def.on_rightclick = function(pos, node, player, itemstack, pt) + local name = player:get_player_name() + if not(quests.has_quest(name, def.npc_quest_title)) then + quests.add_quest(name, def.npc_get_quest(pos, player)) + else + --TODO + end + end + elseif def.npc_type == "text" then + def.on_rightclick = function(pos, node, player, itemstack, pt) + local name = player:get_player_name() + quests.show_text(def.npc_text, name) + end + end + + minetest.register_node(name, def) +end + +--TEST +npcs.register_npc("npcs:farmer", { + npc_type = "text", + npc_text = "Hi!", + npc_quest_title = "Test", + npc_get_quest = function(pos, player) + local quest = quests.new(nil, "Test", "Test") + local goal_1 = quests.add_place_goal(quest, "Place dirt", {"default:dirt"}, 10, "Place some dirt!") + return quest + end, +}) diff --git a/mods/npcs/models/npc.x b/mods/npcs/models/npc.x new file mode 100644 index 0000000..af71dbe --- /dev/null +++ b/mods/npcs/models/npc.x @@ -0,0 +1,507 @@ +xof 0303txt 0032 + +Frame Root { + FrameTransformMatrix { + 1.000000, 0.000000, 0.000000, 0.000000, + 0.000000,-0.000000, 1.000000, 0.000000, + 0.000000, 1.000000, 0.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 1.000000;; + } + Frame Cube_001 { + FrameTransformMatrix { + 2.000000, 0.000000, 0.000000, 0.000000, + 0.000000, 2.000000, 0.000000, 0.000000, + 0.000000, 0.000000, 2.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 1.000000;; + } + Mesh { // Cube_001 mesh + 144; + -0.200000; 1.108333; 0.200000;, + -0.200000; 1.108333;-0.200000;, + -0.200000; 0.708333;-0.200000;, + -0.200000; 0.708333; 0.200000;, + -0.200000; 1.108333;-0.200000;, + 0.200000; 1.108333;-0.200000;, + 0.200000; 0.708333;-0.200000;, + -0.200000; 0.708333;-0.200000;, + 0.200000; 1.108333;-0.200000;, + 0.200000; 1.108333; 0.200000;, + 0.200000; 0.708333; 0.200000;, + 0.200000; 0.708333;-0.200000;, + 0.200000; 1.108333; 0.200000;, + -0.200000; 1.108333; 0.200000;, + -0.200000; 0.708333; 0.200000;, + 0.200000; 0.708333; 0.200000;, + -0.200000; 0.708333; 0.200000;, + -0.200000; 0.708333;-0.200000;, + 0.200000; 0.708333;-0.200000;, + 0.200000; 0.708333; 0.200000;, + 0.200000; 1.108333; 0.200000;, + 0.200000; 1.108333;-0.200000;, + -0.200000; 1.108333;-0.200000;, + -0.200000; 1.108333; 0.200000;, + -0.200000; 0.108333;-0.100000;, + -0.200000; 0.108333; 0.100000;, + -0.400000; 0.108333; 0.100000;, + -0.400000; 0.108333;-0.100000;, + -0.200000; 0.708333;-0.100000;, + -0.400000; 0.708333;-0.100000;, + -0.400000; 0.708333; 0.100000;, + -0.200000; 0.708333; 0.100000;, + -0.200000; 0.108333;-0.100000;, + -0.200000; 0.708333;-0.100000;, + -0.200000; 0.708333; 0.100000;, + -0.200000; 0.108333; 0.100000;, + -0.200000; 0.108333; 0.100000;, + -0.200000; 0.708333; 0.100000;, + -0.400000; 0.708333; 0.100000;, + -0.400000; 0.108333; 0.100000;, + -0.400000; 0.108333; 0.100000;, + -0.400000; 0.708333; 0.100000;, + -0.400000; 0.708333;-0.100000;, + -0.400000; 0.108333;-0.100000;, + -0.200000; 0.708333;-0.100000;, + -0.200000; 0.108333;-0.100000;, + -0.400000; 0.108333;-0.100000;, + -0.400000; 0.708333;-0.100000;, + 0.400000; 0.108333;-0.100000;, + 0.400000; 0.108333; 0.100000;, + 0.200000; 0.108333; 0.100000;, + 0.200000; 0.108333;-0.100000;, + 0.400000; 0.708333;-0.100000;, + 0.200000; 0.708333;-0.100000;, + 0.200000; 0.708333; 0.100000;, + 0.400000; 0.708333; 0.100000;, + 0.400000; 0.108333;-0.100000;, + 0.400000; 0.708333;-0.100000;, + 0.400000; 0.708333; 0.100000;, + 0.400000; 0.108333; 0.100000;, + 0.400000; 0.108333; 0.100000;, + 0.400000; 0.708333; 0.100000;, + 0.200000; 0.708333; 0.100000;, + 0.200000; 0.108333; 0.100000;, + 0.200000; 0.108333; 0.100000;, + 0.200000; 0.708333; 0.100000;, + 0.200000; 0.708333;-0.100000;, + 0.200000; 0.108333;-0.100000;, + 0.400000; 0.708333;-0.100000;, + 0.400000; 0.108333;-0.100000;, + 0.200000; 0.108333;-0.100000;, + 0.200000; 0.708333;-0.100000;, + -0.200000; 0.708333; 0.100000;, + -0.200000; 0.708333;-0.100000;, + -0.200000; 0.108333;-0.100000;, + -0.200000; 0.108333; 0.100000;, + -0.200000; 0.708333;-0.100000;, + 0.200000; 0.708333;-0.100000;, + 0.200000; 0.108333;-0.100000;, + -0.200000; 0.108333;-0.100000;, + 0.200000; 0.708333;-0.100000;, + 0.200000; 0.708333; 0.100000;, + 0.200000; 0.108333; 0.100000;, + 0.200000; 0.108333;-0.100000;, + 0.200000; 0.708333; 0.100000;, + -0.200000; 0.708333; 0.100000;, + -0.200000; 0.108333; 0.100000;, + 0.200000; 0.108333; 0.100000;, + -0.200000; 0.108333; 0.100000;, + -0.200000; 0.108333;-0.100000;, + 0.200000; 0.108333;-0.100000;, + 0.200000; 0.108333; 0.100000;, + 0.200000; 0.708333; 0.100000;, + 0.200000; 0.708333;-0.100000;, + -0.200000; 0.708333;-0.100000;, + -0.200000; 0.708333; 0.100000;, + -0.000000;-0.491667;-0.100000;, + -0.000000;-0.491667; 0.100000;, + -0.200000;-0.491667; 0.100000;, + -0.200000;-0.491667;-0.100000;, + 0.000000; 0.108333;-0.100000;, + -0.200000; 0.108333;-0.100000;, + -0.200000; 0.108333; 0.100000;, + -0.000000; 0.108333; 0.100000;, + -0.000000;-0.491667;-0.100000;, + 0.000000; 0.108333;-0.100000;, + -0.000000; 0.108333; 0.100000;, + -0.000000;-0.491667; 0.100000;, + -0.000000;-0.491667; 0.100000;, + -0.000000; 0.108333; 0.100000;, + -0.200000; 0.108333; 0.100000;, + -0.200000;-0.491667; 0.100000;, + -0.200000;-0.491667; 0.100000;, + -0.200000; 0.108333; 0.100000;, + -0.200000; 0.108333;-0.100000;, + -0.200000;-0.491667;-0.100000;, + 0.000000; 0.108333;-0.100000;, + -0.000000;-0.491667;-0.100000;, + -0.200000;-0.491667;-0.100000;, + -0.200000; 0.108333;-0.100000;, + 0.200000;-0.491667;-0.100000;, + 0.200000;-0.491667; 0.100000;, + -0.000000;-0.491667; 0.100000;, + 0.000000;-0.491667;-0.100000;, + 0.200000; 0.108333;-0.100000;, + -0.000000; 0.108333;-0.100000;, + -0.000000; 0.108333; 0.100000;, + 0.200000; 0.108333; 0.100000;, + 0.200000;-0.491667;-0.100000;, + 0.200000; 0.108333;-0.100000;, + 0.200000; 0.108333; 0.100000;, + 0.200000;-0.491667; 0.100000;, + 0.200000;-0.491667; 0.100000;, + 0.200000; 0.108333; 0.100000;, + -0.000000; 0.108333; 0.100000;, + -0.000000;-0.491667; 0.100000;, + -0.000000;-0.491667; 0.100000;, + -0.000000; 0.108333; 0.100000;, + -0.000000; 0.108333;-0.100000;, + 0.000000;-0.491667;-0.100000;, + 0.200000; 0.108333;-0.100000;, + 0.200000;-0.491667;-0.100000;, + 0.000000;-0.491667;-0.100000;, + -0.000000; 0.108333;-0.100000;; + 36; + 4;3,2,1,0;, + 4;7,6,5,4;, + 4;11,10,9,8;, + 4;15,14,13,12;, + 4;19,18,17,16;, + 4;23,22,21,20;, + 4;27,26,25,24;, + 4;31,30,29,28;, + 4;35,34,33,32;, + 4;39,38,37,36;, + 4;43,42,41,40;, + 4;47,46,45,44;, + 4;51,50,49,48;, + 4;55,54,53,52;, + 4;59,58,57,56;, + 4;63,62,61,60;, + 4;67,66,65,64;, + 4;71,70,69,68;, + 4;75,74,73,72;, + 4;79,78,77,76;, + 4;83,82,81,80;, + 4;87,86,85,84;, + 4;91,90,89,88;, + 4;95,94,93,92;, + 4;99,98,97,96;, + 4;103,102,101,100;, + 4;107,106,105,104;, + 4;111,110,109,108;, + 4;115,114,113,112;, + 4;119,118,117,116;, + 4;123,122,121,120;, + 4;127,126,125,124;, + 4;131,130,129,128;, + 4;135,134,133,132;, + 4;139,138,137,136;, + 4;143,142,141,140;; + MeshNormals { // Cube_001 normals + 36; + -1.000000; 0.000000; 0.000000;, + 0.000000;-0.000000;-1.000000;, + 1.000000;-0.000000; 0.000000;, + 0.000000; 0.000000; 1.000000;, + -0.000000;-1.000000; 0.000000;, + -0.000000; 1.000000; 0.000000;, + 0.000000;-1.000000; 0.000000;, + 0.000000; 1.000000; 0.000000;, + 1.000000;-0.000000; 0.000000;, + -0.000000;-0.000000; 1.000000;, + -1.000000;-0.000000;-0.000000;, + 0.000000; 0.000000;-1.000000;, + 0.000000;-1.000000; 0.000000;, + 0.000000; 1.000000; 0.000000;, + 1.000000;-0.000000; 0.000000;, + -0.000000; 0.000000; 1.000000;, + -1.000000;-0.000000;-0.000000;, + 0.000000; 0.000000;-1.000000;, + -1.000000; 0.000000; 0.000000;, + 0.000000;-0.000000;-1.000000;, + 1.000000;-0.000000; 0.000000;, + 0.000000; 0.000000; 1.000000;, + -0.000000;-1.000000; 0.000000;, + -0.000000; 1.000000; 0.000000;, + 0.000000;-1.000000; 0.000000;, + 0.000000; 1.000000; 0.000000;, + 1.000000; 0.000000; 0.000000;, + -0.000000;-0.000000; 1.000000;, + -1.000000;-0.000000;-0.000000;, + 0.000000; 0.000000;-1.000000;, + 0.000000;-1.000000; 0.000000;, + 0.000000; 1.000000; 0.000000;, + 1.000000;-0.000000; 0.000000;, + -0.000000;-0.000000; 1.000000;, + -1.000000;-0.000000;-0.000000;, + 0.000000; 0.000000;-1.000000;; + 36; + 4;0,0,0,0;, + 4;1,1,1,1;, + 4;2,2,2,2;, + 4;3,3,3,3;, + 4;4,4,4,4;, + 4;5,5,5,5;, + 4;6,6,6,6;, + 4;7,7,7,7;, + 4;8,8,8,8;, + 4;9,9,9,9;, + 4;10,10,10,10;, + 4;11,11,11,11;, + 4;12,12,12,12;, + 4;13,13,13,13;, + 4;14,14,14,14;, + 4;15,15,15,15;, + 4;16,16,16,16;, + 4;17,17,17,17;, + 4;18,18,18,18;, + 4;19,19,19,19;, + 4;20,20,20,20;, + 4;21,21,21,21;, + 4;22,22,22,22;, + 4;23,23,23,23;, + 4;24,24,24,24;, + 4;25,25,25,25;, + 4;26,26,26,26;, + 4;27,27,27,27;, + 4;28,28,28,28;, + 4;29,29,29,29;, + 4;30,30,30,30;, + 4;31,31,31,31;, + 4;32,32,32,32;, + 4;33,33,33,33;, + 4;34,34,34,34;, + 4;35,35,35,35;; + } // End of Cube_001 normals + MeshTextureCoords { // Cube_001 UV coordinates + 144; + 0.428571; 0.000000;, + 0.285714; 0.000000;, + 0.285714; 0.500000;, + 0.428571; 0.500000;, + 0.571429; 0.500000;, + 0.428571; 0.500000;, + 0.428571; 1.000000;, + 0.571429; 1.000000;, + 0.571429; 0.000000;, + 0.428571; 0.000000;, + 0.428571; 0.500000;, + 0.571429; 0.500000;, + 0.285714; 0.500000;, + 0.142857; 0.500000;, + 0.142857; 1.000000;, + 0.285714; 1.000000;, + 0.428571; 0.500000;, + 0.285714; 0.500000;, + 0.285714; 1.000000;, + 0.428571; 1.000000;, + 0.142857; 0.500000;, + 0.285714; 0.500000;, + 0.285714; 0.000000;, + 0.142857; 0.000000;, + 0.000000; 1.000000;, + 0.071429; 1.000000;, + 0.071429; 0.750000;, + 0.000000; 0.750000;, + 0.571429; 0.750000;, + 0.571429; 1.000000;, + 0.642857; 1.000000;, + 0.642857; 0.750000;, + 0.857143; 0.750000;, + 0.857143; 0.000000;, + 0.785714; 0.000000;, + 0.785714; 0.750000;, + 0.071429; 0.750000;, + 0.071429; 0.000000;, + 0.000000; 0.000000;, + 0.000000; 0.750000;, + 0.071429; 0.750000;, + 0.071429; 0.000000;, + 0.000000; 0.000000;, + 0.000000; 0.750000;, + 0.000000; 0.000000;, + 0.000000; 0.750000;, + 0.071429; 0.750000;, + 0.071429; 0.000000;, + 0.000000; 1.000000;, + 0.071429; 1.000000;, + 0.071429; 0.750000;, + 0.000000; 0.750000;, + 0.642857; 1.000000;, + 0.642857; 0.750000;, + 0.571429; 0.750000;, + 0.571429; 1.000000;, + 0.071429; 0.750000;, + 0.071429; 0.000000;, + 0.000000; 0.000000;, + 0.000000; 0.750000;, + 0.071429; 0.750000;, + 0.071429; 0.000000;, + 0.000000; 0.000000;, + 0.000000; 0.750000;, + 0.000000; 0.750000;, + 0.071429; 0.750000;, + 0.071429; 0.000000;, + 0.000000; 0.000000;, + 0.000000; 0.000000;, + 0.000000; 0.750000;, + 0.071429; 0.750000;, + 0.071429; 0.000000;, + 0.071429; 0.750000;, + 0.071429; 0.000000;, + 0.000000; 0.000000;, + 0.000000; 0.750000;, + 1.000000; 0.000000;, + 0.857143; 0.000000;, + 0.857143; 0.750000;, + 1.000000; 0.750000;, + 0.642857; 0.000000;, + 0.571429; 0.000000;, + 0.571429; 0.750000;, + 0.642857; 0.750000;, + 0.785714; 0.000000;, + 0.642857; 0.000000;, + 0.642857; 0.750000;, + 0.785714; 0.750000;, + 1.000000; 0.750000;, + 0.857143; 0.750000;, + 0.857143; 1.000000;, + 1.000000; 1.000000;, + 0.642857; 1.000000;, + 0.785714; 1.000000;, + 0.785714; 0.750000;, + 0.642857; 0.750000;, + 0.071429; 1.000000;, + 0.142857; 1.000000;, + 0.142857; 0.750000;, + 0.071429; 0.750000;, + 0.857143; 1.000000;, + 0.857143; 0.750000;, + 0.785714; 0.750000;, + 0.785714; 1.000000;, + 0.142857; 0.750000;, + 0.142857; 0.000000;, + 0.071429; 0.000000;, + 0.071429; 0.750000;, + 0.142857; 0.750000;, + 0.142857; 0.000000;, + 0.071429; 0.000000;, + 0.071429; 0.750000;, + 0.142857; 0.750000;, + 0.142857; 0.000000;, + 0.071429; 0.000000;, + 0.071429; 0.750000;, + 0.071429; 0.000000;, + 0.071429; 0.750000;, + 0.142857; 0.750000;, + 0.142857; 0.000000;, + 0.071429; 1.000000;, + 0.142857; 1.000000;, + 0.142857; 0.750000;, + 0.071429; 0.750000;, + 0.857143; 0.750000;, + 0.785714; 0.750000;, + 0.785714; 1.000000;, + 0.857143; 1.000000;, + 0.142857; 0.750000;, + 0.142857; 0.000000;, + 0.071429; 0.000000;, + 0.071429; 0.750000;, + 0.142857; 0.750000;, + 0.142857; 0.000000;, + 0.071429; 0.000000;, + 0.071429; 0.750000;, + 0.142857; 0.750000;, + 0.142857; 0.000000;, + 0.071429; 0.000000;, + 0.071429; 0.750000;, + 0.071429; 0.000000;, + 0.071429; 0.750000;, + 0.142857; 0.750000;, + 0.142857; 0.000000;; + } // End of Cube_001 UV coordinates + MeshMaterialList { // Cube_001 material list + 6; + 36; + 1, + 1, + 1, + 1, + 1, + 1, + 2, + 2, + 2, + 2, + 2, + 2, + 3, + 3, + 3, + 3, + 3, + 3, + 4, + 4, + 4, + 4, + 4, + 4, + 0, + 0, + 0, + 0, + 0, + 0, + 5, + 5, + 5, + 5, + 5, + 5;; + Material leg_2 { + 0.640000; 0.640000; 0.640000; 1.000000;; + 96.078431; + 0.500000; 0.500000; 0.500000;; + 0.000000; 0.000000; 0.000000;; + TextureFilename {"character.png";} + } + Material head { + 0.800000; 0.800000; 0.800000; 1.000000;; + 96.078431; + 0.500000; 0.500000; 0.500000;; + 0.000000; 0.000000; 0.000000;; + TextureFilename {"character.png";} + } + Material arm_2 { + 0.640000; 0.640000; 0.640000; 1.000000;; + 96.078431; + 0.500000; 0.500000; 0.500000;; + 0.000000; 0.000000; 0.000000;; + TextureFilename {"character.png";} + } + Material arm_1 { + 0.640000; 0.640000; 0.640000; 1.000000;; + 96.078431; + 0.500000; 0.500000; 0.500000;; + 0.000000; 0.000000; 0.000000;; + TextureFilename {"character.png";} + } + Material body { + 0.640000; 0.640000; 0.640000; 1.000000;; + 96.078431; + 0.500000; 0.500000; 0.500000;; + 0.000000; 0.000000; 0.000000;; + TextureFilename {"character.png";} + } + Material leg_1 { + 0.640000; 0.640000; 0.640000; 1.000000;; + 96.078431; + 0.500000; 0.500000; 0.500000;; + 0.000000; 0.000000; 0.000000;; + TextureFilename {"character.png";} + } + } // End of Cube_001 material list + } // End of Cube_001 mesh + } // End of Cube_001 +} // End of Root diff --git a/mods/quests/init.lua b/mods/quests/init.lua index 760af19..0db2fb6 100644 --- a/mods/quests/init.lua +++ b/mods/quests/init.lua @@ -35,7 +35,7 @@ end function quests.show_text(text, player) local parts = text:split("\n") for i,txt in ipairs(parts) do - minetest.after(2.9*i, function (txt, player) + minetest.after(2.9*(i-1), function (txt, player) if not(minetest.get_player_by_name(player)) then return end cmsg.push_message_player(minetest.get_player_by_name(player), txt) end, txt, player) @@ -61,6 +61,16 @@ function quests.add_quest(player, quest) return #quests.player_quests[player] end +function quests.has_quest(name, title) + for i,def in ipairs(quests.player_quests[name]) do + if def.title == title then + return true + end + end + + return false +end + function quests.finish_quest(player, quest) if not(quest.done) then cmsg.push_message_player(minetest.get_player_by_name(player), "[quest] You completed " .. quest.title)