Update npcf and npc_villager
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 5.8 KiB |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 784 B After Width: | Height: | Size: 784 B |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
|
@ -1,385 +0,0 @@
|
|||
mobs = {}
|
||||
mobs.mobs = {}
|
||||
function mobs.get_velocity(v, yaw, y)
|
||||
local x = -math.sin(yaw) * v
|
||||
local z = math.cos(yaw) * v
|
||||
return {x = x, y = y, z = z}
|
||||
end
|
||||
|
||||
function mobs.register_mob(name, def)
|
||||
mobs.mobs[#mobs.mobs+1] = {name, def.lvl}
|
||||
|
||||
if not def.hp then
|
||||
if def.lvl and def.hits then
|
||||
def.hp = skills.get_dmg(def.lvl)*def.hits
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_entity(name, {
|
||||
hp_max = def.hp,
|
||||
physical = true,
|
||||
collisionbox = def.collisionbox,
|
||||
visual = "upright_sprite",
|
||||
visual_size = def.visual_size or {x=1, y=1},
|
||||
textures = def.textures,
|
||||
spritediv = {x=1, y=1},
|
||||
initial_sprite_basepos = {x=0, y=0},
|
||||
is_visible = true,
|
||||
makes_footstep_sound = false,
|
||||
automatic_rotate = true,
|
||||
speed = 0,
|
||||
anim = "",
|
||||
t = 0.0,
|
||||
|
||||
on_punch = function(self, player)
|
||||
if self.object:get_hp() <= 0 then
|
||||
if player and player:is_player() then
|
||||
xp.add_xp(player, def.xp or xp.get_xp(def.lvl, 10))
|
||||
if def.drops then
|
||||
minetest.spawn_item(self.object:getpos(), def.drops[math.random(1, #def.drops)])
|
||||
else
|
||||
minetest.spawn_item(self.object:getpos(), "money:silver_coin")
|
||||
end
|
||||
self.object:remove()
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
on_step = function(self, dtime)
|
||||
self.t = self.t + dtime
|
||||
if self.t > 1 then
|
||||
local all_objects = minetest.get_objects_inside_radius(self.object:getpos(), def.range)
|
||||
local found = false
|
||||
local _,obj
|
||||
for _,obj in ipairs(all_objects) do
|
||||
if obj:is_player() then
|
||||
print("[mob] punch player")
|
||||
local v = vector.direction(self.object:getpos(), obj:getpos())
|
||||
v.y = (def.gravity or -9.2)
|
||||
self.object:setvelocity(v)
|
||||
self.object:setyaw(math.atan(v.x, v.z))
|
||||
|
||||
local yaw = math.atan(v.z/v.x)+math.pi/2
|
||||
--yaw = yaw+(math.pi/2)
|
||||
if v.x + self.object:getpos().x > self.object:getpos().x then
|
||||
yaw = yaw+math.pi
|
||||
end
|
||||
self.object:setyaw(yaw)
|
||||
|
||||
|
||||
if minetest.line_of_sight(vector.add(self.object:getpos(), vector.new(0, 0.5, 0)), vector.add(obj:getpos(), vector.new(0, 0.5, 0)), 1) then
|
||||
obj:punch(self.object, 10, def.dmg, nil)
|
||||
found = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not found then
|
||||
all_objects = minetest.get_objects_inside_radius(self.object:getpos(), 10)
|
||||
for _,obj in ipairs(all_objects) do
|
||||
if obj:is_player() then
|
||||
local obj_p = obj:getpos()
|
||||
local p = self.object:getpos()
|
||||
local v = vector.multiply(vector.direction(p, obj_p), 4)
|
||||
local d = obj_p.y - p.y
|
||||
if d > 0 and d < 2 then
|
||||
v.y = 2
|
||||
else
|
||||
v.y = (def.gravity or -9.2)
|
||||
end
|
||||
self.object:setvelocity(v)
|
||||
|
||||
local yaw = math.atan(v.z/v.x)+math.pi/2
|
||||
--yaw = yaw+(math.pi/2)
|
||||
if v.x + self.object:getpos().x > self.object:getpos().x then
|
||||
yaw = yaw+math.pi
|
||||
end
|
||||
|
||||
self.object:setyaw(yaw)
|
||||
found = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not found then
|
||||
local v = {x=math.random(-2, 2), y=(def.gravity or -9.2), z=math.random(-2, 2)}
|
||||
self.object:setvelocity(v)
|
||||
|
||||
local yaw = math.atan(v.z/v.x)+math.pi/2
|
||||
--yaw = yaw+(math.pi/2)
|
||||
if v.x + self.object:getpos().x > self.object:getpos().x then
|
||||
yaw = yaw+math.pi
|
||||
end
|
||||
self.object:setyaw(yaw)
|
||||
end
|
||||
self.t = 0
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craftitem(name, {
|
||||
description = def.description,
|
||||
inventory_image = "mobs_spawn.png",
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then
|
||||
return
|
||||
end
|
||||
local p = {x=pointed_thing.above.x, y=pointed_thing.above.y+2, z=pointed_thing.above.z}
|
||||
minetest.add_entity(p, name)
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
function mobs.get_mob(lvl)
|
||||
local a = {}
|
||||
local found_mob = false
|
||||
for i,n in ipairs(mobs.mobs) do
|
||||
if n[2] < lvl +5 and n[2] > lvl-5 then
|
||||
found_mob = true
|
||||
a[#a+1] = n[1]
|
||||
end
|
||||
end
|
||||
|
||||
if found_mob then
|
||||
return a[math.random(1, #a)]
|
||||
end
|
||||
|
||||
a = {}
|
||||
found_mob = false
|
||||
for i,n in ipairs(mobs.mobs) do
|
||||
if n[2] < lvl +5 then
|
||||
found_mob = true
|
||||
a[#a+1] = n[1]
|
||||
end
|
||||
end
|
||||
|
||||
if found_mob then
|
||||
return a[math.random(1, #a)]
|
||||
end
|
||||
|
||||
return mobs.mobs[math.random(1, #mobs.mobs)][1]
|
||||
end
|
||||
|
||||
local timer = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
timer = timer + dtime;
|
||||
if timer >= 5 then
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
local p = player:getpos()
|
||||
local a = {-1, 1}
|
||||
local x = math.random(20, 40)*a[math.random(1,2)] + p.x
|
||||
local z = math.random(20, 40)*a[math.random(1,2)] + p.z
|
||||
if minetest.get_node(vector.new(x, p.y+2, z)).name == "air" then
|
||||
local n = mobs.get_mob(xp.player_levels[player:get_player_name()])
|
||||
minetest.add_entity(vector.new(x, p.y+2, z), n)
|
||||
end
|
||||
end
|
||||
timer = 0
|
||||
end
|
||||
end)
|
||||
|
||||
--mobs
|
||||
mobs.register_mob("mobs:slime", {
|
||||
textures = {"mobs_slime.png",},
|
||||
lvl = 3,
|
||||
hits = 6,
|
||||
dmg = {
|
||||
full_punch_interval = 0.9,
|
||||
max_drop_level = 0,
|
||||
groupcaps = {
|
||||
},
|
||||
damage_groups = {friendly=3},
|
||||
},
|
||||
collisionbox = {-0.4, -0.5, -0.4, 0.4, 0.5, 0.4},
|
||||
description = "Slime",
|
||||
range = 3,
|
||||
})
|
||||
|
||||
mobs.register_mob("mobs:big_slime", {
|
||||
textures = {"mobs_slime.png",},
|
||||
lvl = 7,
|
||||
hits = 6,
|
||||
visual_size = {x=2,y=2},
|
||||
dmg = {
|
||||
full_punch_interval = 0.9,
|
||||
max_drop_level = 0,
|
||||
groupcaps = {
|
||||
},
|
||||
damage_groups = {friendly=3},
|
||||
},
|
||||
collisionbox = {-0.9, -1, -0.9, 0.9, 1, 0.9},
|
||||
description = "Big Slime",
|
||||
range = 3,
|
||||
|
||||
})
|
||||
|
||||
mobs.register_mob("mobs:dungeon_guardian", {
|
||||
textures = {"mobs_dungeon_guardian.png",},
|
||||
lvl = 15,
|
||||
hits = 6,
|
||||
visual_size = {x=2,y=2},
|
||||
dmg = {
|
||||
full_punch_interval = 0.9,
|
||||
max_drop_level = 0,
|
||||
groupcaps = {
|
||||
},
|
||||
damage_groups = {friendly=3},
|
||||
},
|
||||
collisionbox = {-0.8, -1, -0.8, 0.8, 1, 0.8},
|
||||
description = "Dungeon Guardian",
|
||||
range = 4,
|
||||
|
||||
})
|
||||
|
||||
mobs.register_mob("mobs:blue_cube", {
|
||||
textures = {"mobs_blue_cube.png",},
|
||||
lvl = 20,
|
||||
hits = 6,
|
||||
visual_size = {x=1.5,y=1.5},
|
||||
dmg = {
|
||||
full_punch_interval = 0.9,
|
||||
max_drop_level = 0,
|
||||
groupcaps = {
|
||||
},
|
||||
damage_groups = {friendly=3},
|
||||
},
|
||||
collisionbox = {-0.6, -0.75, -0.6, 0.6, 0.75, 0.6},
|
||||
description = "Blue Cube",
|
||||
range = 4,
|
||||
|
||||
})
|
||||
|
||||
mobs.register_mob("mobs:small_grass_monster", {
|
||||
textures = {"mobs_grass_monster.png",},
|
||||
lvl = 7,
|
||||
hits = 3,
|
||||
visual_size = {x=0.5,y=0.5},
|
||||
dmg = {
|
||||
full_punch_interval = 0.9,
|
||||
max_drop_level = 0,
|
||||
groupcaps = {
|
||||
},
|
||||
damage_groups = {friendly=3},
|
||||
},
|
||||
drops = {"default:grass 5"},
|
||||
collisionbox = {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25},
|
||||
description = "Small Grass Monster",
|
||||
range = 4,
|
||||
|
||||
})
|
||||
|
||||
mobs.register_mob("mobs:grass_monster", {
|
||||
textures = {"mobs_grass_monster.png",},
|
||||
lvl = 22,
|
||||
hits = 6,
|
||||
visual_size = {x=1.5,y=1.5},
|
||||
dmg = {
|
||||
full_punch_interval = 0.9,
|
||||
max_drop_level = 0,
|
||||
groupcaps = {
|
||||
},
|
||||
damage_groups = {friendly=3},
|
||||
},
|
||||
drops = {"default:grass 10"},
|
||||
collisionbox = {-0.6, -0.75, -0.6, 0.6, 0.6, 0.6},
|
||||
description = "Grass Monster",
|
||||
range = 4,
|
||||
|
||||
})
|
||||
|
||||
mobs.register_mob("mobs:angry_cloud", {
|
||||
textures = {"mobs_angry_cloud.png",},
|
||||
lvl = 25,
|
||||
hits = 4,
|
||||
visual_size = {x=1.5,y=1.5},
|
||||
dmg = {
|
||||
full_punch_interval = 0.9,
|
||||
max_drop_level = 0,
|
||||
groupcaps = {
|
||||
},
|
||||
damage_groups = {friendly=4},
|
||||
},
|
||||
collisionbox = {-0.6, -0.25, -0.6, 0.6, 0.25, 0.6},
|
||||
description = "Angry Cloud",
|
||||
range = 5,
|
||||
|
||||
})
|
||||
|
||||
mobs.register_mob("mobs:hedgehog", {
|
||||
textures = {"mobs_hedgehog.png",},
|
||||
lvl = 30,
|
||||
hits = 7,
|
||||
visual_size = {x=1,y=1},
|
||||
dmg = {
|
||||
full_punch_interval = 0.9,
|
||||
max_drop_level = 0,
|
||||
groupcaps = {
|
||||
},
|
||||
damage_groups = {friendly=1},
|
||||
},
|
||||
collisionbox = {-0.3, -0.5, -0.3, 0.3, -0.25, 0.3},
|
||||
description = "Hedgehog",
|
||||
range = 8,
|
||||
|
||||
})
|
||||
|
||||
mobs.register_mob("mobs:book", {
|
||||
textures = {"mobs_book.png",},
|
||||
lvl = 35,
|
||||
hits = 7,
|
||||
visual_size = {x=1,y=1},
|
||||
dmg = {
|
||||
full_punch_interval = 0.9,
|
||||
max_drop_level = 0,
|
||||
groupcaps = {
|
||||
},
|
||||
damage_groups = {friendly=5},
|
||||
},
|
||||
collisionbox = {-0.3, -0.5, -0.3, 0.3, 0.4, 0.3},
|
||||
description = "Book",
|
||||
range = 3,
|
||||
drops = {"money:coin"}
|
||||
})
|
||||
|
||||
mobs.register_mob("mobs:coal_monster", {
|
||||
textures = {"mobs_coal_monster.png",},
|
||||
lvl = 40,
|
||||
hits = 4,
|
||||
visual_size = {x=1,y=1},
|
||||
dmg = {
|
||||
full_punch_interval = 0.9,
|
||||
max_drop_level = 0,
|
||||
groupcaps = {
|
||||
},
|
||||
damage_groups = {friendly=5},
|
||||
},
|
||||
collisionbox = {-0.3, -0.5, -0.3, 0.3, 0.3, 0.3},
|
||||
description = "Coal Monster",
|
||||
range = 6,
|
||||
drops = {"money:coin"}
|
||||
})
|
||||
|
||||
mobs.register_mob("mobs:lava_flower", {
|
||||
textures = {"mobs_lava_flower.png",},
|
||||
lvl = 37,
|
||||
hits = 10,
|
||||
visual_size = {x=1,y=1},
|
||||
dmg = {
|
||||
full_punch_interval = 0.9,
|
||||
max_drop_level = 0,
|
||||
groupcaps = {
|
||||
},
|
||||
damage_groups = {friendly=6},
|
||||
},
|
||||
collisionbox = {-0.3, -0.5, -0.3, 0.3, 0.3, 0.3},
|
||||
description = "Lava Flower",
|
||||
range = 2,
|
||||
drops = {"money:coin 2"}
|
||||
})
|
|
@ -0,0 +1,502 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library 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 library 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 library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
|
@ -0,0 +1 @@
|
|||
npcf
|
|
@ -0,0 +1,101 @@
|
|||
-- Copyright (C) 2016 rubenwardy
|
||||
--
|
||||
-- This library 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 library 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 library; if not, write to the Free Software
|
||||
-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
npc_villager = {
|
||||
INNKEEPER = "INNKEEPER",
|
||||
FARMER = "FARMER",
|
||||
}
|
||||
|
||||
dofile(minetest.get_modpath("npc_villager") .. "/npcf_statemachine.lua")
|
||||
dofile(minetest.get_modpath("npc_villager") .. "/states.lua")
|
||||
|
||||
npcf:register_npc("npc_villager:villager", {
|
||||
description = "Villager",
|
||||
textures = {"npcf_info_skin.png"},
|
||||
metadata = {
|
||||
infotext = "Infotext."
|
||||
},
|
||||
title = {
|
||||
text = "Villager",
|
||||
color = "#00aaff",
|
||||
},
|
||||
inventory_image = "npcf_info_inv.png",
|
||||
on_rightclick = function(self, clicker)
|
||||
print("[npc_villager] on_rightclick!")
|
||||
local npc = npcf.npcs[self.npc_id]
|
||||
local state = npc.npc_state
|
||||
return state and state.on_rightclick and state:on_rightclick(npc, clicker)
|
||||
end,
|
||||
on_punch = function(self, hitter)
|
||||
print("[npc_villager] on_punch!")
|
||||
local npc = npcf.npcs[self.npc_id]
|
||||
local state = npc.npc_state
|
||||
return state and state.on_punch and state:on_punch(npc, hitter)
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
print("[npc_villager] on_step!")
|
||||
local npc = npcf.npcs[self.npc_id]
|
||||
local state = npc.npc_state
|
||||
return state and state.on_step and state:on_step(npc, dtime)
|
||||
end,
|
||||
on_activate = function(self)
|
||||
print("[npc_villager] on_activate!")
|
||||
if not self.set_state then
|
||||
print(" - no self.set_state")
|
||||
end
|
||||
local npc = npcf.npcs[self.npc_id]
|
||||
local state = npc.npc_state
|
||||
return state and state.on_activate and state:on_activate(npc)
|
||||
end,
|
||||
on_construct = function(npc)
|
||||
if not npc.set_state then
|
||||
error("[npc_villager] npc.set_state does not exist!")
|
||||
end
|
||||
npc:set_state(npc_villager.create_idle_state())
|
||||
|
||||
-- TODO: implement auto spawning and remove this
|
||||
npc.role = npc_villager.INNKEEPER
|
||||
|
||||
local state = npc.npc_state
|
||||
return state and state.on_construct and state:on_construct(npc)
|
||||
end,
|
||||
on_destruct = function(npc)
|
||||
print("[npc_villager] on_destruct!")
|
||||
local state = npc.npc_state
|
||||
return state and state.on_destruct and state:on_destruct(npc)
|
||||
end,
|
||||
on_save = function(npc, to_save)
|
||||
print("[npc_villager] on_save!")
|
||||
local state = npc.npc_state
|
||||
return state and state.on_save and state:on_save(npc, to_save)
|
||||
end,
|
||||
on_update = function(npc)
|
||||
print("[npc_villager] on_update")
|
||||
local state = npc.npc_state
|
||||
return state and state.on_update and state:on_update(npc)
|
||||
end,
|
||||
on_tell = function(npc, sender, message)
|
||||
print("[npc_villager] on_tell")
|
||||
local state = npc.npc_state
|
||||
return state and state.on_tell and state:on_tell(npc, sender, message)
|
||||
end,
|
||||
on_receive_fields = function(self, fields, sender)
|
||||
print("[npc_villager] on_receive_fields")
|
||||
local npc = npcf.npcs[self.npc_id]
|
||||
local state = npc.npc_state
|
||||
return state and state.on_receive_fields and state:on_receive_fields(npc, fields, sender)
|
||||
end
|
||||
})
|
|
@ -0,0 +1,36 @@
|
|||
if not npcf.create_state then
|
||||
function npcf:create_state(name)
|
||||
if not name then
|
||||
error("[npcf] States must have a name, even if it's an empty name")
|
||||
end
|
||||
return {
|
||||
name = name,
|
||||
|
||||
-- now in this state
|
||||
load = function(self) end,
|
||||
|
||||
-- moving to another state
|
||||
unload = function(self) return true end,
|
||||
|
||||
-- callbacks
|
||||
on_rightclick = function(self, npc, clicker) end,
|
||||
on_punch = function(self, npc, hitter) end,
|
||||
on_step = function(self, npc, dtime) end,
|
||||
on_activate = function(self, npc) end,
|
||||
on_destruct = function(self, npc) end,
|
||||
on_save = function(self, npc, to_save) end,
|
||||
on_update = function(self, npc) end,
|
||||
on_tell = function(self, npc, sender, message) end,
|
||||
on_receive_fields = function(self, npc, fields, sender) end,
|
||||
}
|
||||
end
|
||||
|
||||
npcf.npc.npc_state = npcf:create_state("")
|
||||
|
||||
function npcf.npc:set_state(state)
|
||||
if not self.npc_state or self.npc_state.unload(self) then
|
||||
self.npc_state = state
|
||||
self.npc_state.load(self)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,26 @@
|
|||
-- Copyright (C) 2016 rubenwardy
|
||||
--
|
||||
-- This library 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 library 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 library; if not, write to the Free Software
|
||||
-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
function npc_villager.create_idle_state()
|
||||
local state = npcf.create_state("npc_villager:idle")
|
||||
return state
|
||||
end
|
||||
|
||||
function npc_villager.create_wander_state()
|
||||
local state = npc_villager.create_idle_state()
|
||||
state.name = "npc_villager:wander"
|
||||
return state
|
||||
end
|
|
@ -0,0 +1,50 @@
|
|||
Mod - NPC Framework [npcf]
|
||||
-------------------------------
|
||||
|
||||
License Source Code: 2013 Stuart Jones - LGPL v2.1
|
||||
|
||||
License Textures: WTFPL
|
||||
|
||||
Depends: default
|
||||
|
||||
This mod adds some, hopefully useful, non-player characters to the minetest game.
|
||||
The mod also provides a framework for others to create and manage their own custom NPCs.
|
||||
|
||||
Features currently include overhead titles, formspec handling, ownership, chat command management
|
||||
and file based back-ups. Some example NPC mods have been included as part of the modpack.
|
||||
|
||||
The example NPC's are not craftable although by default will be available in the creative mode menu.
|
||||
Server operators would be advised to override this default behaviour and allocate the NPCs on /give basis.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Place an NPC spawner node on the ground at a chosen location, right-click on the spawner and
|
||||
give the NPC a unique ID, maximum 16 alpha-numeric characters with no spaces. (underscore and/or hyphen permitted)
|
||||
This ID will be used to address the NPC using chat command interface and as the NPC's back-up file name.
|
||||
NPC owner's and server admins can view the ID of any loaded NPC by right-clicking on the NPC entity
|
||||
|
||||
Chat Commands
|
||||
-------------
|
||||
|
||||
NPC chat commands are issued as follows.
|
||||
|
||||
/npcf <command> [id] [args]
|
||||
|
||||
* setpos <npc_id> <pos>
|
||||
* setlook <npc_id> <angle> (0-360)
|
||||
* titletext <npc_id> <text>
|
||||
* titlecolor <npc_id> <color> (#RRGGBB)
|
||||
* tell <npc_id> <args>
|
||||
* setskin <npc_id> <filename>
|
||||
* delete <npc_id>
|
||||
* unload <npc_id>
|
||||
* load <npc_id>
|
||||
* save <npc_id>
|
||||
getpos <npc_id>
|
||||
* clearobjects (admin only)
|
||||
list
|
||||
help (show this message)
|
||||
|
||||
* Ownership or server priv required
|
||||
|
|
@ -0,0 +1,374 @@
|
|||
Modpack - NPC Framework [0.2.0]
|
||||
-------------------------------
|
||||
This mod adds some, hopefully useful, non-player characters to the minetest game.
|
||||
The mod also provides a framework for others to create and manage their own custom NPCs.
|
||||
|
||||
Features currently include overhead titles, formspec handling, ownership, chat command management
|
||||
and file based back-ups. Some example NPC mods have been included as part of the modpack.
|
||||
|
||||
The example NPC's are not craftable although by default will be available in the creative mode menu.
|
||||
Server operators would be advised to override this default behaviour and allocate the NPCs on /give basis.
|
||||
|
||||
### Info NPC [npcf_info]
|
||||
|
||||
The Info NPC is a simple information serving character. You could think of them as a
|
||||
human book providing information about a particular server location, or whatever else you like.
|
||||
Supports multiple pages of text. 12 lines per page, ~50 chars per line.
|
||||
|
||||
### Deco NPC [npcf_deco]
|
||||
|
||||
A purely decorative NPC, can be set to roam freely and/or follow random players it encounters.
|
||||
|
||||
### Guard NPC [npcf_guard]
|
||||
|
||||
Protect yourself and your property against other players and mobs. Features 3d weapon and armor.
|
||||
Can be left to guard a certain area or set to follow their owner.
|
||||
|
||||
### Trader NPC [npcf_trader]
|
||||
|
||||
Provides a quantity based exchange system. The owner can set a given number of exchanges.
|
||||
This would likely be best used in conjunction with one of the physical currency mods.
|
||||
|
||||
Buy [default:mese] Qty [1] - Sell [default:gold_ingot] Qty [10]
|
||||
Buy [default:gold_ingot] Qty [20] - Sell [default:mese] Qty [1]
|
||||
|
||||
Note that the NPC's owner cannot trade with their own NPC, that would be rather pointless anyway.
|
||||
|
||||
### Builder NPC [npcf_builder]
|
||||
|
||||
Not really much point to this atm other than it's really fun to watch. By default, it be can only
|
||||
build a basic hut, however this is compatible (or so it seems) with all the schematics provided by
|
||||
Dan Duncombe's instabuild mod. These should be automatically available for selection if you have
|
||||
the instabuild mod installed.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Place an NPC spawner node on the ground at a chosen location, right-click on the spawner and
|
||||
give the NPC a unique ID, maximum 16 alpha-numeric characters with no spaces. (underscore and/or hyphen permitted)
|
||||
This ID will be used to address the NPC using chat command interface and as the NPC's back-up file name.
|
||||
NPC owner's and server admins can view the ID of any loaded NPC by right-clicking on the NPC entity
|
||||
|
||||
Chat Commands
|
||||
-------------
|
||||
|
||||
NPC chat commands are issued as follows.
|
||||
|
||||
/npcf <command> [id] [args]
|
||||
|
||||
### list
|
||||
|
||||
List all registered NPCs and display online status.
|
||||
|
||||
### clearobjects
|
||||
|
||||
Clear all loaded NPCs. (requires server priv)
|
||||
|
||||
### getpos id
|
||||
|
||||
Display the position of the NPC.
|
||||
|
||||
### save id
|
||||
|
||||
Save current NPC state to file. (requires ownership or server priv)
|
||||
|
||||
### unload id
|
||||
|
||||
Unload a loaded NPC. (requires ownership or server priv)
|
||||
|
||||
### delete id
|
||||
|
||||
Permanently unload and delete the NPC. (requires ownership or server priv)
|
||||
|
||||
### load id
|
||||
|
||||
Loads the NPC at the origin position. (requires ownership or server priv)
|
||||
|
||||
### setpos id pos | here
|
||||
|
||||
Set NPC location. (requires ownership or server priv)
|
||||
Position x y z
|
||||
|
||||
/npcf setpos npc_1 0, 1.5, 0
|
||||
|
||||
Use 'here' to locate the NPC at the player's current position.
|
||||
|
||||
/npcf setpos npc_1 here
|
||||
|
||||
### setlook id direction | here
|
||||
|
||||
Set NPC face direction. (requires ownership or server priv)
|
||||
Direction 0-360 degrees (0 = North)
|
||||
|
||||
/npcf setlook npc_1 0
|
||||
|
||||
Use 'here' to face the NPC towards the player.
|
||||
|
||||
/npcf setlook npc_1 here
|
||||
|
||||
### tell id message
|
||||
|
||||
Send message to NPC (requires ownership or server priv)
|
||||
|
||||
Customizable chat command callback for additional NPC interaction.
|
||||
Has no effect unless overridden by the NPC's registration.
|
||||
|
||||
### setskin id skin_filename
|
||||
|
||||
Set the skin texture of the NPC. (requires ownership or server priv)
|
||||
|
||||
/npcf setskin npc_1 character.png
|
||||
|
||||
### titletext id string
|
||||
|
||||
Set the NPC title string. (requires ownership or server priv)
|
||||
maximum 12 alpha-numeric characters (may contain spaces underscore and hyphen)
|
||||
Use an empty string or only spaces to remove a title.
|
||||
|
||||
### titlecolor id color
|
||||
|
||||
Set the NPC title color #RRGGBB format. (requires ownership or server priv)
|
||||
|
||||
/npcf titlecolor npc_1 #FF0000
|
||||
|
||||
Also supports simple color names. (black, white, red, green, blue, cyan, yellow, magenta)
|
||||
Not case sensitive.
|
||||
|
||||
/npcf titlecolor npc_1 Red
|
||||
|
||||
API Reference
|
||||
-------------
|
||||
Use the global npcf api to create your own NPC.
|
||||
|
||||
npcf:register_npc("my_mod:my_cool_npc" ,{
|
||||
description = "My Cool NPC",
|
||||
})
|
||||
|
||||
This is a minimal example, see the NPCs included for more elaborate usage examples.
|
||||
|
||||
Properties
|
||||
----------
|
||||
Additional properties included by the framework. (defaults)
|
||||
|
||||
on_construct = function(self),
|
||||
on_destruct = function(self, hitter),
|
||||
on_save = function(npc, to_save),
|
||||
on_update = function(npc),
|
||||
on_tell = function(npc, sender, message),
|
||||
on_receive_fields = function(self, fields, sender),
|
||||
register_spawner = true,
|
||||
armor_groups = {immortal=1},
|
||||
animation = {
|
||||
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,
|
||||
},
|
||||
animation_state = 0,
|
||||
animation_speed = 30,
|
||||
description = "Default NPC",
|
||||
inventory_image = "npcf_inv_top.png",
|
||||
title = {},
|
||||
metadata = {},
|
||||
var = {},
|
||||
timer = 0,
|
||||
|
||||
Special Properties
|
||||
------------------
|
||||
Properties used internally by the framework.
|
||||
|
||||
initialized = false,
|
||||
activated = false,
|
||||
properties = {textures=textures},
|
||||
npcf_id = id,
|
||||
owner = owner,
|
||||
origin = {pos=pos, yaw=yaw},
|
||||
|
||||
These should be considered read-only, with the exception of origin
|
||||
where it may be desireable update the statically saved position.
|
||||
|
||||
self.origin.pos = self.object:getpos()
|
||||
self.origin.yaw = self.object:getyaw()
|
||||
|
||||
Callbacks
|
||||
---------
|
||||
Additional callbacks provided by the framework.
|
||||
Note that 'npc' is a NPC object reference, not a LuaEntitySAO reference. The latter can be obtained from
|
||||
npc.object but only when the LuaEntitySAO is loaded.
|
||||
|
||||
### on_construct = function(npc)
|
||||
Called when the NPC object is first created, or loaded from save.
|
||||
You should read things from npc.
|
||||
|
||||
### on_save = function(npc, to_save)
|
||||
Called when the NPC is being saved to file. to_save is the table that is going to be serialized.
|
||||
|
||||
### on_destruct = function(self, hitter)
|
||||
Called when an NPC is destroyed by punching. Can be used to unload the NPC when defeated by a player.
|
||||
See the Guard NPC for an example.
|
||||
|
||||
### on_update = function(npc)
|
||||
Called every time an NPC object is updated (NPCF_UPDATE_TIME) even when the LuaEntitySAO is not loaded.
|
||||
|
||||
### on_tell = function(npc, sender, message)
|
||||
Called when the 'tell' chat command is issued. Note that this Behavior diverges from version 0.1.0,
|
||||
however, it does now allow for interaction even when the associated LuaEntitySAO not loaded.
|
||||
|
||||
### on_receive_fields = function(self, fields, sender)
|
||||
Called when a button is pressed in the NPC's formspec. text fields, dropdown,
|
||||
list and checkbox selections are automatically stored in the metadata table.
|
||||
|
||||
npcf
|
||||
----
|
||||
The global NPC framework namespace.
|
||||
|
||||
### Global Constants
|
||||
|
||||
NPCF_UPDATE_TIME = 4
|
||||
NPCF_RELOAD_DISTANCE = 32
|
||||
NPCF_ANIM_STAND = 1
|
||||
NPCF_ANIM_SIT = 2
|
||||
NPCF_ANIM_LAY = 3
|
||||
NPCF_ANIM_WALK = 4
|
||||
NPCF_ANIM_WALK_MINE = 5
|
||||
NPCF_ANIM_MINE = 6
|
||||
|
||||
All of the above can be overridden by including a npcf.conf file in the npcf directory.
|
||||
See: npcf.conf.example
|
||||
|
||||
### npcf.index
|
||||
|
||||
Ownership table of all spawned NPCs (loaded or unloaded)
|
||||
|
||||
npcf.index[id] = owner -- owner's name
|
||||
|
||||
### npcf.npcs
|
||||
|
||||
Table of loaded NPC object references.
|
||||
|
||||
### npcf.npc
|
||||
|
||||
NPC object prototype.
|
||||
|
||||
autoload = true,
|
||||
timer = 0,
|
||||
object = nil -- LuaEntitySAO added as required
|
||||
|
||||
### npcf.npc:new(ref)
|
||||
|
||||
Create a new NPC object instance.
|
||||
|
||||
local npc = npcf.npc:new({
|
||||
id = id,
|
||||
pos = pos,
|
||||
yaw = yaw,
|
||||
name = name,
|
||||
owner = owner,
|
||||
title = {},
|
||||
properties = {textures = textures},
|
||||
metadata = {},
|
||||
var = {},
|
||||
origin = {
|
||||
pos = pos,
|
||||
yaw = yaw,
|
||||
}
|
||||
})
|
||||
|
||||
If used directly then it is the caller's resposibilty to store the reference and update the index.
|
||||
Use: npcf:add_npc(ref) instead to have this done automatically by the framework.
|
||||
|
||||
### npc:update()
|
||||
|
||||
Update the NPC object. Adds a LuaEntitySAO when in range of players (NPCF_RELOAD_DISTANCE)
|
||||
Called automatically on global step (NPCF_UPDATE_TIME) for all loaded NPC objects.
|
||||
|
||||
### npcf:add_title(ref)
|
||||
|
||||
Adds a floating title above the NPC entity
|
||||
|
||||
### npcf:add_entity(ref)
|
||||
|
||||
Adds a LuaEntitySAO based on the NPC reference, returns a minetest ObjectRef on success.
|
||||
Care should be taken to avoid entity duplication when called externally.
|
||||
|
||||
### npcf:add_npc(ref)
|
||||
|
||||
Adds a new NPC based on the reference.
|
||||
|
||||
local ref = {
|
||||
id = id,
|
||||
pos = pos,
|
||||
yaw = yaw,
|
||||
name = "my_mod_name:npc",
|
||||
owner = "owner_name", --optional
|
||||
}
|
||||
local npc = npcf:add_npc(ref)
|
||||
|
||||
If owner is nil then the NPC will be omitted from npcf.index.
|
||||
Chat commands for such NPCs will only be available to admins (server priv).
|
||||
|
||||
### npcf:register_npc(name, def)
|
||||
|
||||
Register a non-player character. Used as a wrapper for minetest.register_entity, it includes
|
||||
all the callbacks and properties available there with the exception of get_staticdata which is used internally. The framework provides 'metadata' and 'var' tables for data storage, where the metadata table is persistent following a reload and automatically stores submitted form data.
|
||||
The var table should be used for semi-persistent data storage only. Note that self.timer is
|
||||
automatically incremented by the framework but should be reset externally.
|
||||
|
||||
### npcf:unload(id)
|
||||
|
||||
Remove the NPC object instance and all associated entities.
|
||||
|
||||
### npcf:delete(id)
|
||||
|
||||
Permanently erase thw NPC object and associated back-up file.
|
||||
|
||||
### npcf:load(id)
|
||||
|
||||
Loads the NPC at the origin position.
|
||||
|
||||
### npcf:save(id)
|
||||
|
||||
Save current NPC state to file.
|
||||
|
||||
on_receive_fields = function(self, fields, sender)
|
||||
if fields.save then
|
||||
npcf:save(self.npc_id)
|
||||
end
|
||||
end,
|
||||
|
||||
### npcf:set_animation(luaentity, state)
|
||||
|
||||
Sets the NPC's animation state.
|
||||
|
||||
on_activate = function(self, staticdata, dtime_s)
|
||||
npcf:set_animation(self, NPCF_ANIM_STAND)
|
||||
end,
|
||||
|
||||
### npcf:get_luaentity(id)
|
||||
|
||||
Returns a LuaEntitySAO if the NPC object is loaded.
|
||||
|
||||
### npcf:get_face_direction(p1, p2)
|
||||
|
||||
Helper routine used internally and by some of the example NPCs.
|
||||
Returns a yaw value in radians for position p1 facing position p2.
|
||||
|
||||
### npcf:get_walk_velocity(speed, y, yaw)
|
||||
|
||||
Returns a velocity vector for the given speed, y velocity and yaw.
|
||||
|
||||
### npcf:show_formspec(player_name, id, formspec)
|
||||
|
||||
Shows a formspec, similar to minetest.show_formspec() but with the NPC's id included.
|
||||
Submitted data can then be captured in the NPC's own 'on_receive_fields' callback.
|
||||
|
||||
Note that form text fields, dropdown, list and checkbox selections are automatically
|
||||
stored in the NPC's metadata table. Image/Button clicks, however, are not.
|
|
@ -0,0 +1,270 @@
|
|||
local params = "<cmd> [id] [args]"
|
||||
local help = {
|
||||
"Useage: /npcf "..params,
|
||||
" ",
|
||||
"* setpos <npc_id> <pos> ",
|
||||
"* setlook <npc_id> <angle> (0-360) ",
|
||||
"* titletext <npc_id> <text> ",
|
||||
"* titlecolor <npc_id> <color> (#RRGGBB) ",
|
||||
"* tell <npc_id> <args> ",
|
||||
"* setskin <npc_id> <filename> ",
|
||||
"* delete <npc_id> ",
|
||||
"* unload <npc_id> ",
|
||||
"* load <npc_id> ",
|
||||
"* save <npc_id> ",
|
||||
" getpos <npc_id> ",
|
||||
"* clearobjects (admin only) ",
|
||||
" list ",
|
||||
" help (show this message) ",
|
||||
" ",
|
||||
"* Ownership or server priv required ",
|
||||
}
|
||||
|
||||
local palette = {
|
||||
["black"] = "#000000",
|
||||
["white"] = "#FFFFFF",
|
||||
["red"] = "#FF0000",
|
||||
["green"] = "#00FF00",
|
||||
["blue"] = "#0000FF",
|
||||
["cyan"] = "#00FFFF",
|
||||
["yellow"] = "FFFF00",
|
||||
["magenta"] = "#FF00FF",
|
||||
}
|
||||
|
||||
local function update_title(npc)
|
||||
if npc.title.object then
|
||||
npc.title.object:remove()
|
||||
npc.title.object = nil
|
||||
end
|
||||
if npc.title.text then
|
||||
npcf:add_title(npc)
|
||||
end
|
||||
npcf:save(npc.id)
|
||||
end
|
||||
|
||||
local function get_permission(name, id)
|
||||
local perm = minetest.check_player_privs(name, {server=true})
|
||||
if perm or name == npcf.index[id] then
|
||||
return true
|
||||
end
|
||||
minetest.chat_send_player(name, "Permission denied!")
|
||||
return false
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("npcf", {
|
||||
params = params,
|
||||
description = "NPC Management",
|
||||
func = function(name, param)
|
||||
local npc = nil
|
||||
local admin = minetest.check_player_privs(name, {server=true})
|
||||
local cmd, npc_id, args = string.match(param, "^([^ ]+) (.-) (.+)$")
|
||||
if not args then
|
||||
cmd, npc_id = string.match(param, "([^ ]+) (.+)")
|
||||
end
|
||||
if npc_id then
|
||||
if not npcf.index[npc_id] then
|
||||
minetest.chat_send_player(name, "Invalid NPC ID "..npc_id)
|
||||
return
|
||||
end
|
||||
npc = npcf.npcs[npc_id]
|
||||
if not npc and cmd ~= "load" then
|
||||
minetest.chat_send_player(name, "NPC "..npc_id.." is not currently loaded")
|
||||
return
|
||||
end
|
||||
admin = name == npcf.index[npc_id] or admin
|
||||
else
|
||||
cmd = string.match(param, "([^ ]+)")
|
||||
end
|
||||
if cmd and npc_id and args then
|
||||
if cmd == "setpos" then
|
||||
if not get_permission(name, npc_id) then
|
||||
return
|
||||
end
|
||||
local pos = minetest.string_to_pos(args)
|
||||
if args == "here" then
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if player then
|
||||
pos = player:getpos()
|
||||
end
|
||||
end
|
||||
if pos then
|
||||
pos.y = pos.y + 1
|
||||
npc.pos = pos
|
||||
npc.origin.pos = pos
|
||||
npcf:save(npc_id)
|
||||
if npc.object then
|
||||
npc.object:setpos(pos)
|
||||
end
|
||||
pos = minetest.pos_to_string(pos)
|
||||
minetest.log("action", name.." moves NPC "..npc_id.." to "..pos)
|
||||
else
|
||||
minetest.chat_send_player(name, "Invalid position "..args)
|
||||
end
|
||||
elseif cmd == "setlook" then
|
||||
if not get_permission(name, npc_id) then
|
||||
return
|
||||
end
|
||||
local yaw = nil
|
||||
if args == "here" then
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if player then
|
||||
pos = player:getpos()
|
||||
if pos then
|
||||
yaw = npcf:get_face_direction(npc.pos, pos)
|
||||
end
|
||||
end
|
||||
else
|
||||
local deg = tonumber(args)
|
||||
if deg then
|
||||
deg = 360 - deg % 360
|
||||
yaw = math.rad(deg)
|
||||
end
|
||||
end
|
||||
if yaw then
|
||||
npc.yaw = yaw
|
||||
npc.origin.yaw = yaw
|
||||
npcf:save(npc_id)
|
||||
if npc.object then
|
||||
npc.object:setyaw(yaw)
|
||||
end
|
||||
end
|
||||
elseif cmd == "titletext" then
|
||||
if not get_permission(name, npc_id) then
|
||||
return
|
||||
end
|
||||
if string.len(args) > 12 then
|
||||
minetest.chat_send_player(name, "Title too long, max 12 characters")
|
||||
return
|
||||
elseif string.match(args, "^ +$") then
|
||||
npc.title.text = nil
|
||||
elseif string.match(args, "^[A-Za-z0-9%_%- ]+$") then
|
||||
npc.title.text = args
|
||||
else
|
||||
minetest.chat_send_player(name, "Invalid title string "..args)
|
||||
return
|
||||
end
|
||||
update_title(npc)
|
||||
elseif cmd == "titlecolor" then
|
||||
if not get_permission(name, npc_id) then
|
||||
return
|
||||
end
|
||||
local color = palette[string.lower(args)] or args
|
||||
if string.len(color) == 7 and string.match(color, "^#[A-Fa-f0-9]") then
|
||||
npc.title.color = color
|
||||
else
|
||||
minetest.chat_send_player(name, "Invalid color string "..color)
|
||||
return
|
||||
end
|
||||
update_title(npc)
|
||||
elseif cmd == "tell" then
|
||||
if not get_permission(name, npc_id) then
|
||||
return
|
||||
end
|
||||
if npc.name then
|
||||
local def = minetest.registered_entities[npc.name]
|
||||
if type(def.on_tell) == "function" then
|
||||
def.on_tell(npc, name, args)
|
||||
end
|
||||
end
|
||||
elseif cmd == "setskin" then
|
||||
if not get_permission(name, npc_id) then
|
||||
return
|
||||
end
|
||||
npc.properties.textures[1] = args
|
||||
npcf:save(npc_id)
|
||||
if npc.object then
|
||||
npc.object:set_properties(npc.properties)
|
||||
end
|
||||
minetest.log("action", name.." changes NPC "..npc_id.." skin to "..args)
|
||||
else
|
||||
minetest.chat_send_player(name, "Invalid command "..cmd)
|
||||
end
|
||||
return
|
||||
elseif cmd and npc_id then
|
||||
if cmd == "titletext" then
|
||||
if not get_permission(name, npc_id) then
|
||||
return
|
||||
end
|
||||
npc.title.text = nil
|
||||
update_title(npc)
|
||||
elseif cmd == "delete" then
|
||||
if not get_permission(name, npc_id) then
|
||||
return
|
||||
end
|
||||
npcf:delete(npc_id)
|
||||
minetest.log("action", name.." deletes NPC "..npc_id)
|
||||
elseif cmd == "unload" then
|
||||
if not get_permission(name, npc_id) then
|
||||
return
|
||||
end
|
||||
npcf:unload(npc_id)
|
||||
minetest.log("action", name.." unloads NPC "..npc_id)
|
||||
elseif cmd == "load" then
|
||||
if not get_permission(name, npc_id) then
|
||||
return
|
||||
end
|
||||
local npc = npcf:load(npc_id)
|
||||
if npc then
|
||||
npc.autoload = true
|
||||
npc:update()
|
||||
npcf:save(npc_id)
|
||||
minetest.log("action", name.." loads NPC "..npc_id)
|
||||
end
|
||||
elseif cmd == "save" then
|
||||
if not get_permission(name, npc_id) then
|
||||
return
|
||||
end
|
||||
if npc then
|
||||
npcf:save(npc_id)
|
||||
minetest.chat_send_player(name, "NPC "..npc_id.." has been saved")
|
||||
end
|
||||
elseif cmd == "getpos" then
|
||||
local msg = "NPC "..npc_id
|
||||
if npc and npcf.index[npc_id] then
|
||||
local pos = {
|
||||
x = math.floor(npc.pos.x * 10) * 0.1,
|
||||
y = math.floor(npc.pos.y * 10) * 0.1 - 1,
|
||||
z = math.floor(npc.pos.z * 10) * 0.1
|
||||
}
|
||||
msg = msg.." located at "..minetest.pos_to_string(pos)
|
||||
else
|
||||
msg = msg.." position unavilable"
|
||||
end
|
||||
minetest.chat_send_player(name, msg)
|
||||
else
|
||||
minetest.chat_send_player(name, "Invalid command "..cmd)
|
||||
end
|
||||
return
|
||||
elseif cmd then
|
||||
if cmd == "help" then
|
||||
minetest.chat_send_player(name, table.concat(help, "\n"))
|
||||
elseif cmd == "list" then
|
||||
local msg = "None"
|
||||
local npclist = {}
|
||||
for id, _ in pairs(npcf.index) do
|
||||
local loaded = id
|
||||
if npcf.npcs[id] then
|
||||
loaded = loaded.." [loaded]"
|
||||
end
|
||||
table.insert(npclist, loaded)
|
||||
end
|
||||
if #npclist > 0 then
|
||||
msg = table.concat(npclist, "\n")
|
||||
end
|
||||
minetest.chat_send_player(name, "NPC List: \n\n"..msg)
|
||||
elseif cmd == "clearobjects" then
|
||||
if admin then
|
||||
for id, npc in pairs(npcf.npcs) do
|
||||
npcf:unload(id)
|
||||
end
|
||||
end
|
||||
else
|
||||
minetest.chat_send_player(name, "Invalid command "..cmd)
|
||||
end
|
||||
return
|
||||
end
|
||||
local msg = "Usage: /npcf "..params.."\n\nenter /npcf help for available commands"
|
||||
minetest.chat_send_player(name, msg)
|
||||
end,
|
||||
})
|
||||
|
|
@ -0,0 +1 @@
|
|||
default
|
|
@ -0,0 +1,112 @@
|
|||
NPCF_MODPATH = minetest.get_modpath(minetest.get_current_modname())
|
||||
NPCF_DATADIR = minetest.get_worldpath().."/npc_data"
|
||||
NPCF_UPDATE_TIME = 4
|
||||
NPCF_RELOAD_DISTANCE = 32
|
||||
NPCF_ANIM_STAND = 1
|
||||
NPCF_ANIM_SIT = 2
|
||||
NPCF_ANIM_LAY = 3
|
||||
NPCF_ANIM_WALK = 4
|
||||
NPCF_ANIM_WALK_MINE = 5
|
||||
NPCF_ANIM_MINE = 6
|
||||
|
||||
NPCF_ALIAS = {
|
||||
["npcf:info_npc"] = "npcf_info:npc",
|
||||
["npcf:deco_npc"] = "npcf_deco:npc",
|
||||
["npcf:builder_npc"] = "npcf_builder:npc",
|
||||
["npcf:guard_npc"] = "npcf_guard:npc",
|
||||
["npcf:trade_npc"] = "npcf_trader:npc",
|
||||
}
|
||||
|
||||
local input = io.open(NPCF_MODPATH.."/npcf.conf", "r")
|
||||
if input then
|
||||
dofile(NPCF_MODPATH.."/npcf.conf")
|
||||
io.close(input)
|
||||
end
|
||||
|
||||
if not minetest.mkdir(NPCF_DATADIR) then
|
||||
minetest.log("error", "Unable to create the npc_data directory.\n"
|
||||
.."All NPC data will be lost on server shutdowm!")
|
||||
return
|
||||
end
|
||||
|
||||
dofile(NPCF_MODPATH.."/npcf.lua")
|
||||
dofile(NPCF_MODPATH.."/chatcommands.lua")
|
||||
|
||||
minetest.after(0, function()
|
||||
local dirlist = minetest.get_dir_list(NPCF_DATADIR) or {}
|
||||
for _, fn in pairs(dirlist) do
|
||||
local id = string.match(fn, "^(.+)%.npc$")
|
||||
if id then
|
||||
local input = io.open(NPCF_DATADIR.."/"..fn, "r")
|
||||
if input then
|
||||
local ref = minetest.deserialize(input:read('*all'))
|
||||
if ref then
|
||||
if ref.name then
|
||||
npcf.index[id] = ref.owner
|
||||
if ref.autoload == nil or ref.autoload == true then
|
||||
npcf:load(id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname then
|
||||
local id = formname:gsub("npcf_", "")
|
||||
if id == formname then
|
||||
return
|
||||
end
|
||||
local npc = npcf.npcs[id]
|
||||
if npc then
|
||||
local entity = npcf:get_luaentity(id)
|
||||
if entity then
|
||||
for k, v in pairs(fields) do
|
||||
if k ~= "" then
|
||||
v = string.gsub(v, "^CHG:", "")
|
||||
npc.metadata[k] = v
|
||||
end
|
||||
end
|
||||
if type(entity.on_receive_fields) == "function" then
|
||||
entity:on_receive_fields(fields, player)
|
||||
end
|
||||
npcf:save(id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_entity("npcf:title", {
|
||||
physical = false,
|
||||
collisionbox = {x=0, y=0, z=0},
|
||||
visual = "sprite",
|
||||
textures = {"npcf_tag_bg.png"},
|
||||
visual_size = {x=0.72, y=0.12, z=0.72},
|
||||
on_activate = function(self, staticdata, dtime_s)
|
||||
if staticdata == "expired" then
|
||||
self.object:remove()
|
||||
end
|
||||
end,
|
||||
get_staticdata = function(self)
|
||||
return "expired"
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
for _, npc in pairs(npcf.npcs) do
|
||||
npc.timer = npc.timer + dtime
|
||||
if npc.timer > NPCF_UPDATE_TIME then
|
||||
npc:update()
|
||||
npc.timer = 0
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_shutdown(function()
|
||||
for id, npc in pairs(npcf.npcs) do
|
||||
npcf:save(id)
|
||||
end
|
||||
end)
|
||||
|
|
@ -0,0 +1,453 @@
|
|||
local function deepcopy(obj, seen)
|
||||
if type(obj) ~= 'table' then
|
||||
return obj
|
||||
end
|
||||
if seen and seen[obj] then
|
||||
return seen[obj]
|
||||
end
|
||||
local s = seen or {}
|
||||
local copy = setmetatable({}, getmetatable(obj))
|
||||
s[obj] = copy
|
||||
for k, v in pairs(obj) do
|
||||
copy[deepcopy(k, s)] = deepcopy(v, s)
|
||||
end
|
||||
return copy
|
||||
end
|
||||
|
||||
npcf = {
|
||||
-- prototype for NPC objects
|
||||
npc = {
|
||||
autoload = true,
|
||||
timer = 0,
|
||||
},
|
||||
|
||||
-- table of npc.id -> npc
|
||||
npcs = {},
|
||||
|
||||
-- table of npc.id -> npc.owner
|
||||
index = {},
|
||||
|
||||
default_npc = {
|
||||
-- conform to mob standards
|
||||
is_mob = true,
|
||||
is_npc = true,
|
||||
is_adult = function(self)
|
||||
return true
|
||||
end,
|
||||
get_owner = function(self)
|
||||
return npcf.index[self.npc_id]
|
||||
end,
|
||||
|
||||
-- NPC framework specifics
|
||||
description = "Default NPC",
|
||||
inventory_image = "npcf_inv.png",
|
||||
title = {},
|
||||
properties = {},
|
||||
metadata = {},
|
||||
var = {},
|
||||
timer = 0,
|
||||
|
||||
-- Lua Entity properties
|
||||
physical = true,
|
||||
collisionbox = {-0.35,-1.0,-0.35, 0.35,0.8,0.35},
|
||||
visual = "mesh",
|
||||
mesh = "character.b3d",
|
||||
textures = {"character.png"},
|
||||
makes_footstep_sound = true,
|
||||
register_spawner = true,
|
||||
armor_groups = {immortal=1},
|
||||
animation = {
|
||||
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,
|
||||
},
|
||||
animation_state = 0,
|
||||
animation_speed = 30,
|
||||
}
|
||||
}
|
||||
|
||||
-- Create NPC object instance
|
||||
-- when the NPC's entity is loaded, it is stored in self.object
|
||||
-- otherwise self.object will be nil
|
||||
function npcf.npc:new(ref)
|
||||
ref = ref or {}
|
||||
setmetatable(ref, self)
|
||||
self.__index = self
|
||||
return ref
|
||||
end
|
||||
|
||||
-- Called every NPCF_UPDATE_TIME interval, even on unloaded NPCs
|
||||
function npcf.npc:update()
|
||||
local def = minetest.registered_entities[self.name] or {}
|
||||
if type(def.on_update) == "function" then
|
||||
def.on_update(self)
|
||||
end
|
||||
|
||||
local pos = self.object and self.object:getpos()
|
||||
local yaw = self.object and self.object:getyaw()
|
||||
if pos and yaw then
|
||||
self.pos = pos
|
||||
self.yaw = yaw
|
||||
else
|
||||
-- Object has been deactivated or deleted
|
||||
self.object = nil
|
||||
local objects = minetest.get_objects_inside_radius(self.pos, NPCF_RELOAD_DISTANCE)
|
||||
for _, object in pairs(objects) do
|
||||
if object:is_player() then
|
||||
local npc_object = npcf:add_entity(self)
|
||||
if npc_object then
|
||||
self.object = npc_object
|
||||
npcf:add_title(self)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Helper: creates the nametag for a NPC
|
||||
function npcf:add_title(ref)
|
||||
if not ref.object then
|
||||
return
|
||||
end
|
||||
|
||||
if ref.title.text then
|
||||
ref.object:set_nametag_attributes({
|
||||
color = ref.title.color or "white",
|
||||
text = ref.title.text
|
||||
})
|
||||
else
|
||||
ref.object:set_nametag_attributes({
|
||||
text = ""
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-- Recreates the NPC's entity
|
||||
-- Called from npcf.npc:update() when the entity is deleted
|
||||
function npcf:add_entity(ref)
|
||||
local object = minetest.add_entity(ref.pos, ref.name)
|
||||
if object then
|
||||
local entity = object:get_luaentity()
|
||||
if entity then
|
||||
object:setyaw(ref.yaw)
|
||||
object:set_properties(ref.properties)
|
||||
entity.npc_id = ref.id
|
||||
entity.properties = ref.properties
|
||||
entity.metadata = ref.metadata
|
||||
entity.var = ref.var
|
||||
entity.owner = ref.owner
|
||||
entity.origin = ref.origin
|
||||
entity.initialized = true
|
||||
return object
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Creates an NPC object instance
|
||||
function npcf:add_npc(ref)
|
||||
if ref.id and ref.pos and ref.name then
|
||||
ref.name = NPCF_ALIAS[ref.name] or ref.name
|
||||
local def = deepcopy(minetest.registered_entities[ref.name])
|
||||
if def then
|
||||
ref.metadata = ref.metadata or {}
|
||||
if type(def.metadata) == "table" then
|
||||
for k, v in pairs(def.metadata) do
|
||||
if ref.metadata[k] == nil then
|
||||
ref.metadata[k] = v
|
||||
end
|
||||
end
|
||||
end
|
||||
ref.yaw = ref.yaw or {x=0, y=0, z=0}
|
||||
ref.title = ref.title or def.title
|
||||
ref.properties = {textures=ref.textures or def.textures}
|
||||
ref.var = ref.var or def.var
|
||||
if not ref.origin then
|
||||
ref.origin = {
|
||||
pos = deepcopy(ref.pos),
|
||||
yaw = deepcopy(ref.yaw),
|
||||
}
|
||||
end
|
||||
local npc = npcf.npc:new(ref)
|
||||
if type(def.on_construct) == "function" then
|
||||
def.on_construct(npc)
|
||||
end
|
||||
npcf.npcs[ref.id] = npc
|
||||
npcf.index[ref.id] = ref.owner
|
||||
return npc
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Registers an NPC
|
||||
function npcf:register_npc(name, def)
|
||||
local ref = deepcopy(def) or {}
|
||||
local default_npc = deepcopy(self.default_npc)
|
||||
for k, v in pairs(default_npc) do
|
||||
if ref[k] == nil then
|
||||
ref[k] = v
|
||||
end
|
||||
end
|
||||
ref.initialized = false
|
||||
ref.activated = false
|
||||
ref.on_activate = function(self, staticdata)
|
||||
if staticdata == "expired" then
|
||||
self.object:remove()
|
||||
elseif self.object then
|
||||
self.object:set_armor_groups(def.armor_groups)
|
||||
end
|
||||
end
|
||||
ref.on_rightclick = function(self, clicker)
|
||||
local id = self.npc_id
|
||||
local name = clicker:get_player_name()
|
||||
if id and name then
|
||||
local admin = minetest.check_player_privs(name, {server=true})
|
||||
if admin or name == npcf.index[id] then
|
||||
minetest.chat_send_player(name, "NPC ID: "..id)
|
||||
end
|
||||
end
|
||||
if type(def.on_rightclick) == "function" then
|
||||
def.on_rightclick(self, clicker)
|
||||
end
|
||||
end
|
||||
ref.on_punch = function(self, hitter)
|
||||
local hp = self.object:get_hp() or 0
|
||||
if hp <= 0 then
|
||||
local id = self.npc_id
|
||||
if id then
|
||||
npcf.npcs[id].title.object = nil
|
||||
end
|
||||
if type(ref.on_destruct) == "function" then
|
||||
ref.on_destruct(self, hitter)
|
||||
end
|
||||
end
|
||||
if type(def.on_punch) == "function" then
|
||||
def.on_punch(self, hitter)
|
||||
end
|
||||
end
|
||||
ref.on_step = function(self, dtime)
|
||||
if self.initialized == true then
|
||||
if self.activated == true then
|
||||
if type(def.on_step) == "function" then
|
||||
self.timer = self.timer + dtime
|
||||
def.on_step(self, dtime)
|
||||
end
|
||||
else
|
||||
if type(def.on_activate) == "function" then
|
||||
def.on_activate(self)
|
||||
end
|
||||
self.activated = true
|
||||
end
|
||||
end
|
||||
end
|
||||
ref.get_staticdata = function(self)
|
||||
return "expired"
|
||||
end
|
||||
minetest.register_entity(name, ref)
|
||||
if not ref.register_spawner then
|
||||
return
|
||||
end
|
||||
minetest.register_node(name.."_spawner", {
|
||||
description = ref.description,
|
||||
inventory_image = minetest.inventorycube("npcf_inv.png", ref.inventory_image, ref.inventory_image),
|
||||
tiles = {"npcf_inv.png", ref.inventory_image, ref.inventory_image},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=3, oddly_breakable_by_hand=3},
|
||||
sounds = default.node_sound_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec", "size[8,3]"
|
||||
.."label[0,0;NPC ID, max 16 characters (A-Za-z0-9_-)]"
|
||||
.."field[0.5,1.5;7.5,0.5;id;ID;]"
|
||||
.."button_exit[5,2.5;2,0.5;cancel;Cancel]"
|
||||
.."button_exit[7,2.5;1,0.5;submit;Ok]"
|
||||
)
|
||||
meta:set_string("infotext", ref.description.." spawner")
|
||||
end,
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("owner", placer:get_player_name())
|
||||
if minetest.setting_getbool("creative_mode") == false then
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
if fields.cancel then
|
||||
return
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
local owner = meta:get_string("owner")
|
||||
local sender_name = sender:get_player_name()
|
||||
local id = fields.id
|
||||
if id and sender_name == owner then
|
||||
if id:len() <= 16 and id:match("^[A-Za-z0-9%_%-]+$") then
|
||||
if npcf.index[id] then
|
||||
minetest.chat_send_player(sender_name, "Error: ID Already Taken!")
|
||||
return
|
||||
end
|
||||
else
|
||||
minetest.chat_send_player(sender_name, "Error: Invalid ID!")
|
||||
return
|
||||
end
|
||||
npcf.index[id] = owner
|
||||
local npc_pos = {x=pos.x, y=pos.y + 0.5, z=pos.z}
|
||||
local yaw = sender:get_look_yaw() + math.pi * 0.5
|
||||
local ref = {
|
||||
id = id,
|
||||
pos = npc_pos,
|
||||
yaw = yaw,
|
||||
name = name,
|
||||
owner = owner,
|
||||
}
|
||||
local npc = npcf:add_npc(ref)
|
||||
npcf:save(ref.id)
|
||||
if npc then
|
||||
npc:update()
|
||||
end
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- Deactivate an NPC but don't delete it
|
||||
function npcf:unload(id)
|
||||
local npc = self.npcs[id]
|
||||
if npc then
|
||||
if npc.object then
|
||||
npc.object:remove()
|
||||
end
|
||||
npc.autoload = false
|
||||
npcf:save(id)
|
||||
self.npcs[id] = nil
|
||||
end
|
||||
end
|
||||
|
||||
-- Delete an NPC
|
||||
function npcf:delete(id)
|
||||
npcf:unload(id)
|
||||
local output = io.open(NPCF_DATADIR.."/"..id..".npc", "w")
|
||||
if input then
|
||||
output:write("")
|
||||
io.close(output)
|
||||
end
|
||||
npcf.index[id] = nil
|
||||
end
|
||||
|
||||
-- Load saved NPCs
|
||||
function npcf:load(id)
|
||||
local input = io.open(NPCF_DATADIR.."/"..id..".npc", 'r')
|
||||
if input then
|
||||
local ref = minetest.deserialize(input:read('*all'))
|
||||
io.close(input)
|
||||
ref.id = id
|
||||
ref.pos = ref.pos or deepcopy(ref.origin.pos)
|
||||
ref.yaw = ref.yaw or deepcopy(ref.origin.yaw)
|
||||
return npcf:add_npc(ref)
|
||||
end
|
||||
minetest.log("error", "Failed to laod NPC: "..id)
|
||||
end
|
||||
|
||||
-- Save NPC
|
||||
function npcf:save(id)
|
||||
local npc = self.npcs[id]
|
||||
if npc then
|
||||
local ref = {
|
||||
pos = npc.pos,
|
||||
yaw = npc.yaw,
|
||||
name = npc.name,
|
||||
owner = npc.owner,
|
||||
title = {
|
||||
text = npc.title.text,
|
||||
color = npc.title.color,
|
||||
},
|
||||
origin = npc.origin,
|
||||
metadata = npc.metadata,
|
||||
properties = npc.properties,
|
||||
autoload = npc.autoload,
|
||||
}
|
||||
|
||||
local def = minetest.registered_entities[ref.name] or {}
|
||||
if type(def.on_save) == "function" then
|
||||
def.on_save(npc, ref)
|
||||
end
|
||||
|
||||
local output = io.open(NPCF_DATADIR.."/"..id..".npc", 'w')
|
||||
if output then
|
||||
output:write(minetest.serialize(ref))
|
||||
io.close(output)
|
||||
return
|
||||
end
|
||||
end
|
||||
minetest.log("error", "Failed to save NPC: "..id)
|
||||
end
|
||||
|
||||
-- Helper: set the animation for an NPC from its state
|
||||
function npcf:set_animation(entity, state)
|
||||
if entity and state and state ~= entity.animation_state then
|
||||
local speed = entity.animation_speed
|
||||
local anim = entity.animation
|
||||
if speed and anim then
|
||||
if state == NPCF_ANIM_STAND and anim.stand_START and anim.stand_END then
|
||||
entity.object:set_animation({x=anim.stand_START, y=anim.stand_END}, speed)
|
||||
elseif state == NPCF_ANIM_SIT and anim.sit_START and anim.sit_END then
|
||||
entity.object:set_animation({x=anim.sit_START, y=anim.sit_END}, speed)
|
||||
elseif state == NPCF_ANIM_LAY and anim.lay_START and anim.lay_END then
|
||||
entity.object:set_animation({x=anim.lay_START, y=anim.lay_END}, speed)
|
||||
elseif state == NPCF_ANIM_WALK and anim.walk_START and anim.walk_END then
|
||||
entity.object:set_animation({x=anim.walk_START, y=anim.walk_END}, speed)
|
||||
elseif state == NPCF_ANIM_WALK_MINE and anim.walk_mine_START and anim.walk_mine_END then
|
||||
entity.object:set_animation({x=anim.walk_mine_START, y=anim.walk_mine_END}, speed)
|
||||
elseif state == NPCF_ANIM_MINE and anim.mine_START and anim.mine_END then
|
||||
entity.object:set_animation({x=anim.mine_START, y=anim.mine_END}, speed)
|
||||
end
|
||||
entity.animation_state = state
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Helper: get luaentity for an NPC or nil
|
||||
function npcf:get_luaentity(id)
|
||||
local npc = self.npcs[id] or {}
|
||||
if npc.object then
|
||||
return npc.object:get_luaentity()
|
||||
end
|
||||
end
|
||||
|
||||
-- Helper: get angle between positions
|
||||
function npcf:get_face_direction(p1, p2)
|
||||
if p1 and p2 and p1.x and p2.x and p1.z and p2.z then
|
||||
local px = p1.x - p2.x
|
||||
local pz = p2.z - p1.z
|
||||
return math.atan2(px, pz)
|
||||
end
|
||||
end
|
||||
|
||||
-- Helper: walk `speed` in direction `yaw` with vertical velocity `y`
|
||||
function npcf:get_walk_velocity(speed, y, yaw)
|
||||
if speed and y and yaw then
|
||||
if speed > 0 then
|
||||
yaw = yaw + math.pi * 0.5
|
||||
local x = math.cos(yaw) * speed
|
||||
local z = math.sin(yaw) * speed
|
||||
return {x=x, y=y, z=z}
|
||||
end
|
||||
return {x=0, y=y, z=0}
|
||||
end
|
||||
end
|
||||
|
||||
-- Helper: calls minetest.show_formspec with a formname of "npcf_" .. id
|
||||
function npcf:show_formspec(name, id, formspec)
|
||||
if name and id and formspec then
|
||||
minetest.show_formspec(name, "npcf_"..id, formspec)
|
||||
end
|
||||
end
|
Before Width: | Height: | Size: 78 B After Width: | Height: | Size: 78 B |
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 107 B |
Before Width: | Height: | Size: 93 B After Width: | Height: | Size: 93 B |
Before Width: | Height: | Size: 101 B After Width: | Height: | Size: 101 B |
Before Width: | Height: | Size: 105 B After Width: | Height: | Size: 105 B |
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 110 B |
Before Width: | Height: | Size: 103 B After Width: | Height: | Size: 103 B |
Before Width: | Height: | Size: 114 B After Width: | Height: | Size: 114 B |
Before Width: | Height: | Size: 87 B After Width: | Height: | Size: 87 B |
Before Width: | Height: | Size: 105 B After Width: | Height: | Size: 105 B |
Before Width: | Height: | Size: 111 B After Width: | Height: | Size: 111 B |
Before Width: | Height: | Size: 109 B After Width: | Height: | Size: 109 B |
Before Width: | Height: | Size: 95 B After Width: | Height: | Size: 95 B |
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 108 B |
Before Width: | Height: | Size: 99 B After Width: | Height: | Size: 99 B |
Before Width: | Height: | Size: 89 B After Width: | Height: | Size: 89 B |
Before Width: | Height: | Size: 88 B After Width: | Height: | Size: 88 B |
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 108 B |
Before Width: | Height: | Size: 87 B After Width: | Height: | Size: 87 B |
Before Width: | Height: | Size: 88 B After Width: | Height: | Size: 88 B |
Before Width: | Height: | Size: 94 B After Width: | Height: | Size: 94 B |
Before Width: | Height: | Size: 118 B After Width: | Height: | Size: 118 B |
Before Width: | Height: | Size: 83 B After Width: | Height: | Size: 83 B |
Before Width: | Height: | Size: 105 B After Width: | Height: | Size: 105 B |
Before Width: | Height: | Size: 113 B After Width: | Height: | Size: 113 B |
Before Width: | Height: | Size: 100 B After Width: | Height: | Size: 100 B |
Before Width: | Height: | Size: 97 B After Width: | Height: | Size: 97 B |
Before Width: | Height: | Size: 106 B After Width: | Height: | Size: 106 B |
Before Width: | Height: | Size: 109 B After Width: | Height: | Size: 109 B |
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 110 B |
Before Width: | Height: | Size: 85 B After Width: | Height: | Size: 85 B |
Before Width: | Height: | Size: 91 B After Width: | Height: | Size: 91 B |
Before Width: | Height: | Size: 109 B After Width: | Height: | Size: 109 B |
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 110 B |
Before Width: | Height: | Size: 104 B After Width: | Height: | Size: 104 B |
Before Width: | Height: | Size: 102 B After Width: | Height: | Size: 102 B |
Before Width: | Height: | Size: 86 B After Width: | Height: | Size: 86 B |
Before Width: | Height: | Size: 78 B After Width: | Height: | Size: 78 B |
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 107 B |
Before Width: | Height: | Size: 99 B After Width: | Height: | Size: 99 B |
Before Width: | Height: | Size: 100 B After Width: | Height: | Size: 100 B |
Before Width: | Height: | Size: 99 B After Width: | Height: | Size: 99 B |
Before Width: | Height: | Size: 104 B After Width: | Height: | Size: 104 B |
Before Width: | Height: | Size: 90 B After Width: | Height: | Size: 90 B |
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 107 B |
Before Width: | Height: | Size: 94 B After Width: | Height: | Size: 94 B |
Before Width: | Height: | Size: 91 B After Width: | Height: | Size: 91 B |
Before Width: | Height: | Size: 93 B After Width: | Height: | Size: 93 B |
Before Width: | Height: | Size: 111 B After Width: | Height: | Size: 111 B |
Before Width: | Height: | Size: 86 B After Width: | Height: | Size: 86 B |
Before Width: | Height: | Size: 93 B After Width: | Height: | Size: 93 B |
Before Width: | Height: | Size: 92 B After Width: | Height: | Size: 92 B |
Before Width: | Height: | Size: 93 B After Width: | Height: | Size: 93 B |
Before Width: | Height: | Size: 100 B After Width: | Height: | Size: 100 B |
Before Width: | Height: | Size: 100 B After Width: | Height: | Size: 100 B |
Before Width: | Height: | Size: 90 B After Width: | Height: | Size: 90 B |
Before Width: | Height: | Size: 102 B After Width: | Height: | Size: 102 B |
Before Width: | Height: | Size: 93 B After Width: | Height: | Size: 93 B |
Before Width: | Height: | Size: 92 B After Width: | Height: | Size: 92 B |
Before Width: | Height: | Size: 102 B After Width: | Height: | Size: 102 B |
Before Width: | Height: | Size: 111 B After Width: | Height: | Size: 111 B |