Skip to content

Commit

Permalink
Add NPCs and make way for quest system
Browse files Browse the repository at this point in the history
  • Loading branch information
LoneWolfHT committed Sep 13, 2020
1 parent 63b0774 commit b493844
Show file tree
Hide file tree
Showing 12 changed files with 597 additions and 0 deletions.
1 change: 1 addition & 0 deletions mods/vk_enemies/mobkit_custom/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function mobkit.hq_die(self)
if puncher then
players.set_gold(puncher, players.get_gold(puncher) + math.random(self.gold or 0, self.gold_max or self.gold or 0))
players.add_xp(puncher, math.random(self.xp or 0, self.xp_max or self.xp or 0))
vk_quests.on_enemy_death(self.name, puncher)
end
end

Expand Down
Binary file modified mods/vk_mapgen/schems/structures/town1.mts
Binary file not shown.
94 changes: 94 additions & 0 deletions mods/vk_npcs/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
local modname = minetest.get_current_modname()

local default_hit_replies = {
"Keep your weapons to yourself",
"Stop that",
"Do I need to call a guard?",
"Are you done or are you going to wear yourself out doing that?",
"Didn't your parents tell you not to attack strangers?",
"I can hit back too you know",
"Enough!",
"Go practice that somewhere else",
}

local function prettify(npcname)
local output = npcname:gsub("_", " ")

return output:gsub("^(.)", string.upper)
end

local function register_npc(name, def)
minetest.register_node(modname..":"..name, {
description = "NPC "..prettify(name),
drawtype = "mesh",
mesh = "player.obj",
visual_scale = 0.093,
wield_scale = vector.new(0.093, 0.093, 0.093),
tiles = {def.texture},
paramtype = "light",
paramtype2 = "facedir",
selection_box = {
type = "fixed",
fixed = {
{-0.45, -0.5, -0.25, 0.45, 1.45, 0.25},
}
},
collision_box = {
type = "fixed",
fixed = {
{-0.45, -0.5, -0.25, 0.45, 1.45, 0.25},
}
},
groups = {unbreakable = 1, loadme = 1, overrides_pointable = 1},
on_construct = function(pos)

end,
on_punch = function(pos, node, puncher, ...)
if def.on_punch and def.on_punch(pos, node, puncher, ...) then
return
end

if def.hit_replies and puncher and puncher:is_player() then
minetest.chat_send_player(puncher:get_player_name(), ("<%s> "):format(prettify(name))..def.hit_replies[math.random(1, #def.hit_replies)])
end
end,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
if not clicker or not clicker:is_player() then return end

local formspec = ([[
size[8,6]
real_coordinates[true]
label[0.2,0.3;%s]
]]):format(
prettify(name)
)

if not def.convos then
minetest.chat_send_player(clicker:get_player_name(), ("<%s> "):format(prettify(name)).."I have nothing to say")
return
end

minetest.show_formspec(clicker:get_player_name(), "npcform", formspec)
end
})
end

register_npc("blacksmith", {
texture = "vk_npcs_blacksmith.png",
hit_replies = default_hit_replies,
})

register_npc("stable_man", {
texture = "vk_npcs_stable_man.png",
hit_replies = default_hit_replies,
})

register_npc("guard", {
texture = "vk_npcs_guard.png",
hit_replies = default_hit_replies,
})

register_npc("tavern_keeper", {
texture = "vk_npcs_tavern_keeper.png",
hit_replies = default_hit_replies,
})
2 changes: 2 additions & 0 deletions mods/vk_npcs/mod.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name = vk_npcs
depends = vk_mapgen
12 changes: 12 additions & 0 deletions mods/vk_npcs/models/player.mtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Blender MTL File: 'player.blend'
# Material Count: 1

newmtl Material
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
Loading

0 comments on commit b493844

Please sign in to comment.