goblins update
parent
bb13aa1dce
commit
6a8d66e8c5
|
@ -38,7 +38,7 @@ MOD_PATCH=( ) #patch names
|
||||||
#MOD_PATCHES - all patches defined
|
#MOD_PATCHES - all patches defined
|
||||||
#MOD_PATCHES - first is path and all patch names are separeted by ":"
|
#MOD_PATCHES - first is path and all patch names are separeted by ":"
|
||||||
#MOD_PATCHES=("mobs/water_life:poison.patch" "buildings/doors:doors_update.patch" "player/3d_armor:mob_damage.patch" "player/hbsprint:no_damage.patch" "player/hunger_ng:effects.patch")
|
#MOD_PATCHES=("mobs/water_life:poison.patch" "buildings/doors:doors_update.patch" "player/3d_armor:mob_damage.patch" "player/hbsprint:no_damage.patch" "player/hunger_ng:effects.patch")
|
||||||
MOD_PATCHES=("buildings/doors:doors_update.patch" "player/hbsprint:no_damage.patch" "environment/dynamic_liquid:bucket.patch" "mobs/water_life:poison.patch" "mobs/water_life:poison_hunger_ng.patch" "mobs/goblins:mod_conf.patch")
|
MOD_PATCHES=("buildings/doors:doors_update.patch" "player/hbsprint:no_damage.patch" "environment/dynamic_liquid:bucket.patch" "mobs/water_life:poison.patch" "mobs/water_life:poison_hunger_ng.patch")
|
||||||
#MOD_PATCHES=( )
|
#MOD_PATCHES=( )
|
||||||
|
|
||||||
echo "---------------------------------------------------------------"
|
echo "---------------------------------------------------------------"
|
||||||
|
|
|
@ -131,8 +131,8 @@ origin https://github.com/berengma/aerotest (fetch)
|
||||||
* master c60a500 [origin/master] lagfree
|
* master c60a500 [origin/master] lagfree
|
||||||
Mod: mobs/aerotest
|
Mod: mobs/aerotest
|
||||||
|
|
||||||
origin git@gitlab.com:daretmavi/pa-sources.git (fetch)
|
origin https://github.com/FreeLikeGNU/goblins.git (fetch)
|
||||||
* master f1d1350 [origin/master: ahead 1] New dynamic liquid patch
|
* master dd48144 [origin/master] fix #13
|
||||||
Mod: mobs/goblins
|
Mod: mobs/goblins
|
||||||
|
|
||||||
origin https://codeberg.org/Hamlet/mobs_ghost_redo (fetch)
|
origin https://codeberg.org/Hamlet/mobs_ghost_redo (fetch)
|
||||||
|
|
|
@ -119,7 +119,7 @@ goblins.gobdog_template = {
|
||||||
self.secret_name = goblins.generate_name(gob_name_parts, name_rules)
|
self.secret_name = goblins.generate_name(gob_name_parts, name_rules)
|
||||||
end
|
end
|
||||||
--print (dump(self.secret_name))
|
--print (dump(self.secret_name))
|
||||||
local pos = vector.round(self.object:getpos())
|
local pos = vector.round(self.object:get_pos())
|
||||||
if not pos then return end
|
if not pos then return end
|
||||||
if not self.secret_territory then
|
if not self.secret_territory then
|
||||||
local territory = {goblins.territory(pos)}
|
local territory = {goblins.territory(pos)}
|
||||||
|
|
|
@ -68,105 +68,107 @@ function goblins.attack(self, target, type)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local pos = vector.round(self.object:getpos())
|
local pos = vector.round(self.object:get_pos())
|
||||||
local s = self.object:get_pos()
|
if pos then
|
||||||
local objs = minetest.get_objects_inside_radius(s, self.view_range)
|
local s = self.object:get_pos()
|
||||||
local aggro_wielded = {}
|
local objs = minetest.get_objects_inside_radius(s, self.view_range)
|
||||||
if goblins_aggro_on_wield then
|
local aggro_wielded = {}
|
||||||
aggro_wielded = self.aggro_wielded
|
if goblins_aggro_on_wield then
|
||||||
end
|
aggro_wielded = self.aggro_wielded
|
||||||
local defend_groups = goblins_defend_groups
|
end
|
||||||
--print_s(S(dump(aggro_wielded)))
|
local defend_groups = goblins_defend_groups
|
||||||
-- remove entities we aren't interested in
|
--print_s(S(dump(aggro_wielded)))
|
||||||
for n = 1, #objs do
|
-- remove entities we aren't interested in
|
||||||
local ent = objs[n]:get_luaentity()
|
for n = 1, #objs do
|
||||||
-- are we a player?
|
local ent = objs[n]:get_luaentity()
|
||||||
if objs[n]:is_player() then
|
-- are we a player?
|
||||||
local pname = objs[n]:get_player_name()
|
if objs[n]:is_player() then
|
||||||
local relations_self = {}
|
local pname = objs[n]:get_player_name()
|
||||||
local relations = {}
|
local relations_self = {}
|
||||||
local relations_adj = 0
|
local relations = {}
|
||||||
--do we know this player?
|
local relations_adj = 0
|
||||||
local relations_self = goblins.relations(self, pname)
|
--do we know this player?
|
||||||
if not relations_self.trade then goblins.relations(self, pname,{trade = 0}) end
|
local relations_self = goblins.relations(self, pname)
|
||||||
if not relations_self.aggro then goblins.relations(self, pname,{aggro = 0}) end
|
if not relations_self.trade then goblins.relations(self, pname,{trade = 0}) end
|
||||||
|
if not relations_self.aggro then goblins.relations(self, pname,{aggro = 0}) end
|
||||||
|
|
||||||
--tally the territorial scores
|
--tally the territorial scores
|
||||||
relations.aggro = goblins.relations_territory(self, pname, "aggro")
|
relations.aggro = goblins.relations_territory(self, pname, "aggro")
|
||||||
relations.trade = goblins.relations_territory(self, pname, "trade")
|
relations.trade = goblins.relations_territory(self, pname, "trade")
|
||||||
if debug_goblins_attack then
|
if debug_goblins_attack then
|
||||||
print_s(S("@1 of @2: ", self.secret_name, self.secret_territory.name))
|
print_s(S("@1 of @2: ", self.secret_name, self.secret_territory.name))
|
||||||
print_s(S("mob relations = @1",dump(goblins.relations(self, pname))))
|
print_s(S("mob relations = @1",dump(goblins.relations(self, pname))))
|
||||||
print_s(S("comparing territory trade @1 and aggro @2",dump(relations.trade),dump(relations.aggro)))
|
print_s(S("comparing territory trade @1 and aggro @2",dump(relations.trade),dump(relations.aggro)))
|
||||||
end
|
end
|
||||||
|
|
||||||
if relations.trade >= relations.aggro then
|
if relations.trade >= relations.aggro then
|
||||||
relations_adj = relations.trade - relations.aggro
|
relations_adj = relations.trade - relations.aggro
|
||||||
end
|
end
|
||||||
if debug_goblins_attack then print_s(S("relations = @1",dump(relations))) end
|
if debug_goblins_attack then print_s(S("relations = @1",dump(relations))) end
|
||||||
if mobs.invis[pname]
|
if mobs.invis[pname]
|
||||||
or self.owner == pname then
|
or self.owner == pname then
|
||||||
local name = ""
|
local name = ""
|
||||||
else
|
else
|
||||||
local player = objs[n]
|
local player = objs[n]
|
||||||
local name = "player"
|
local name = "player"
|
||||||
end
|
end
|
||||||
-- if player invisible or mob not setup to attack then remove from list
|
-- if player invisible or mob not setup to attack then remove from list
|
||||||
local wielded = objs[n]:get_wielded_item():to_string()
|
local wielded = objs[n]:get_wielded_item():to_string()
|
||||||
--print(self.secret_name.." is loyal to " ..self.owner)
|
--print(self.secret_name.." is loyal to " ..self.owner)
|
||||||
if debug_goblins_attack then print_s( S("player has @1 in hand",dump(objs[n]:get_wielded_item():to_string())))end
|
if debug_goblins_attack then print_s( S("player has @1 in hand",dump(objs[n]:get_wielded_item():to_string())))end
|
||||||
if self.attack_players == false
|
if self.attack_players == false
|
||||||
or relations_adj >= 100
|
or relations_adj >= 100
|
||||||
or not self.owner == pname
|
or not self.owner == pname
|
||||||
--or not self.tamed
|
--or not self.tamed
|
||||||
or mobs.invis[pname]
|
or mobs.invis[pname]
|
||||||
or self.specific_attack == "player" then
|
or self.specific_attack == "player" then
|
||||||
if debug_goblins_attack then print_s(S("found exempt player with score of @1 holding @2",relations_adj,dump(objs[n]:get_wielded_item():to_string()))) end
|
if debug_goblins_attack then print_s(S("found exempt player with score of @1 holding @2",relations_adj,dump(objs[n]:get_wielded_item():to_string()))) end
|
||||||
objs[n] = nil
|
objs[n] = nil
|
||||||
--print("- pla", n)
|
--print("- pla", n)
|
||||||
else
|
else
|
||||||
if debug_goblins_attack then print_s(S("attackable player, @1 holding @2",pname,wielded)) end
|
if debug_goblins_attack then print_s(S("attackable player, @1 holding @2",pname,wielded)) end
|
||||||
--lets check if our friends in a fight with the player!
|
--lets check if our friends in a fight with the player!
|
||||||
for n = 1, #objs do
|
for n = 1, #objs do
|
||||||
local ent_other = objs[n]:get_luaentity()
|
local ent_other = objs[n]:get_luaentity()
|
||||||
if defend_groups and ent_other and ent_other.groups and self.groups_defend then
|
if defend_groups and ent_other and ent_other.groups and self.groups_defend then
|
||||||
for k,v in pairs(self.groups_defend) do
|
for k,v in pairs(self.groups_defend) do
|
||||||
if match_only_list(v, ent_other.groups) and
|
if match_only_list(v, ent_other.groups) and
|
||||||
ent_other.state == "attack" and
|
ent_other.state == "attack" and
|
||||||
ent_other.attack:is_player() and
|
ent_other.attack:is_player() and
|
||||||
ent_other.attack:get_player_name() == pname then
|
ent_other.attack:get_player_name() == pname then
|
||||||
local xname = ent_other.attack:get_player_name()
|
local xname = ent_other.attack:get_player_name()
|
||||||
if debug_goblins_attack then print_s( S(" ****Defending @1 from @2!",v,xname)) end
|
if debug_goblins_attack then print_s( S(" ****Defending @1 from @2!",v,xname)) end
|
||||||
minetest.sound_play("goblins_goblin_war_cry", {
|
minetest.sound_play("goblins_goblin_war_cry", {
|
||||||
pos = pos,
|
pos = pos,
|
||||||
gain = 1.0,
|
gain = 1.0,
|
||||||
max_hear_distance = self.sounds.distance or 10
|
max_hear_distance = self.sounds.distance or 10
|
||||||
})
|
})
|
||||||
self:set_animation("run")
|
self:set_animation("run")
|
||||||
self:set_velocity(self.run_velocity)
|
self:set_velocity(self.run_velocity)
|
||||||
self.state = "attack"
|
self.state = "attack"
|
||||||
self.attack = ent_other.attack
|
self.attack = ent_other.attack
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if aggro_wielded and match_item_list(wielded, aggro_wielded)
|
||||||
|
then
|
||||||
|
if debug_goblins_attack then print_s(S("*** aggro triggered by @1 at @2 !! ***",wielded,minetest.pos_to_string(pos))) end
|
||||||
|
minetest.sound_play("goblins_goblin_war_cry", {
|
||||||
|
pos = pos,
|
||||||
|
gain = 1.0,
|
||||||
|
max_hear_distance = self.sounds.distance or 10
|
||||||
|
})
|
||||||
|
self:set_animation("run")
|
||||||
|
self:set_velocity(self.run_velocity)
|
||||||
|
self.state = "attack"
|
||||||
|
self.attack = (objs[n])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if aggro_wielded and match_item_list(wielded, aggro_wielded)
|
end --end of player eval
|
||||||
then
|
--what else do we care about?
|
||||||
if debug_goblins_attack then print_s(S("*** aggro triggered by @1 at @2 !! ***",wielded,minetest.pos_to_string(pos))) end
|
--group_attack mobs nearby
|
||||||
minetest.sound_play("goblins_goblin_war_cry", {
|
end
|
||||||
pos = pos,
|
|
||||||
gain = 1.0,
|
|
||||||
max_hear_distance = self.sounds.distance or 10
|
|
||||||
})
|
|
||||||
self:set_animation("run")
|
|
||||||
self:set_velocity(self.run_velocity)
|
|
||||||
self.state = "attack"
|
|
||||||
self.attack = (objs[n])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end --end of player eval
|
|
||||||
--what else do we care about?
|
|
||||||
--group_attack mobs nearby
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -185,32 +187,34 @@ function goblins.special_gifts(self, pname, drop_chance, max_drops)
|
||||||
end
|
end
|
||||||
if #rares > 0 then
|
if #rares > 0 then
|
||||||
--print_s("rares = "..dump(rares))
|
--print_s("rares = "..dump(rares))
|
||||||
local pos = self.object:getpos()
|
local pos = self.object:get_pos()
|
||||||
pos.y = pos.y + 0.5
|
if pos then
|
||||||
goblins.mixitup(pos)
|
pos.y = pos.y + 0.5
|
||||||
if #rares > max_drops then
|
goblins.mixitup(pos)
|
||||||
rares = rares[math.random(max_drops, #rares)]
|
if #rares > max_drops then
|
||||||
if type(rares) ~= table then rares = {rares} end --
|
rares = rares[math.random(max_drops, #rares)]
|
||||||
end
|
if type(rares) ~= table then rares = {rares} end --
|
||||||
for k,v in pairs(rares) do
|
end
|
||||||
minetest.sound_play("goblins_goblin_cackle", {
|
for k,v in pairs(rares) do
|
||||||
pos = pos,
|
minetest.sound_play("goblins_goblin_cackle", {
|
||||||
gain = 1.0,
|
pos = pos,
|
||||||
max_hear_distance = self.sounds.distance or 10
|
gain = 1.0,
|
||||||
})
|
max_hear_distance = self.sounds.distance or 10
|
||||||
local item_wear = math.random(5000,10000)
|
})
|
||||||
local stack = ItemStack({name = v, wear = item_wear })
|
local item_wear = math.random(5000,10000)
|
||||||
local org_desc = minetest.registered_items[v].description
|
local stack = ItemStack({name = v, wear = item_wear })
|
||||||
local meta = stack:get_meta()
|
local org_desc = minetest.registered_items[v].description
|
||||||
local tool_adj = goblins.generate_name(goblins.words_desc, {"tool_adj"})
|
local meta = stack:get_meta()
|
||||||
-- special thanks here to rubenwardy for showing me how translation works!
|
local tool_adj = goblins.generate_name(goblins.words_desc, {"tool_adj"})
|
||||||
meta:set_string(
|
-- special thanks here to rubenwardy for showing me how translation works!
|
||||||
"description", S("@1's @2 @3", self.secret_name, tool_adj, org_desc)
|
meta:set_string(
|
||||||
)
|
"description", S("@1's @2 @3", self.secret_name, tool_adj, org_desc)
|
||||||
local obj = minetest.add_item(pos, stack)
|
)
|
||||||
minetest.chat_send_player(
|
local obj = minetest.add_item(pos, stack)
|
||||||
pname,S("@1 drops @2",self.secret_name, meta:get_string("description"))
|
minetest.chat_send_player(
|
||||||
)
|
pname,S("@1 drops @2",self.secret_name, meta:get_string("description"))
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -284,10 +288,10 @@ end
|
||||||
function goblins.give_gift(self,clicker)
|
function goblins.give_gift(self,clicker)
|
||||||
--if mobs:feed_tame(self, clicker, 14, false, false) then
|
--if mobs:feed_tame(self, clicker, 14, false, false) then
|
||||||
local item = clicker:get_wielded_item()
|
local item = clicker:get_wielded_item()
|
||||||
local name = clicker:get_player_name()
|
local pname = clicker:get_player_name()
|
||||||
local gift_accepted = nil
|
local gift_accepted = nil
|
||||||
local gift_declined = nil
|
local gift_declined = nil
|
||||||
local pname = clicker:get_player_name()
|
|
||||||
local name_told = goblins.secret_name(self, pname)
|
local name_told = goblins.secret_name(self, pname)
|
||||||
local territory_told = goblins.secret_territory(self, pname)
|
local territory_told = goblins.secret_territory(self, pname)
|
||||||
local trade_shrewdness = goblins_trade_shrewdness
|
local trade_shrewdness = goblins_trade_shrewdness
|
||||||
|
@ -332,7 +336,7 @@ function goblins.give_gift(self,clicker)
|
||||||
self.path.way = nil
|
self.path.way = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--print_s(dump(self.object:get_luaentity()).. " at " ..dump(self.object:getpos()).. " takes: " ..dump(item:get_name()))
|
--print_s(dump(self.object:get_luaentity()).. " at " ..dump(self.object:get_pos()).. " takes: " ..dump(item:get_name()))
|
||||||
if self.drops then
|
if self.drops then
|
||||||
if debug_goblins_trade then
|
if debug_goblins_trade then
|
||||||
print_s("you may get some of "..dump(#self.drops).. " things such as: ")
|
print_s("you may get some of "..dump(#self.drops).. " things such as: ")
|
||||||
|
@ -342,30 +346,32 @@ function goblins.give_gift(self,clicker)
|
||||||
end
|
end
|
||||||
-- we can make some mobs extra stingy despite trade relations
|
-- we can make some mobs extra stingy despite trade relations
|
||||||
if not self.shrewdness then self.shrewdness = 1 end
|
if not self.shrewdness then self.shrewdness = 1 end
|
||||||
local pos = self.object:getpos()
|
local pos = self.object:get_pos()
|
||||||
pos.y = pos.y + 0.5
|
if pos then
|
||||||
for _,v in pairs(self.drops) do
|
pos.y = pos.y + 0.5
|
||||||
--@d_chance takes all the factors of trade into account for each item in drop list
|
for _,v in pairs(self.drops) do
|
||||||
local d_chance = 0
|
--@d_chance takes all the factors of trade into account for each item in drop list
|
||||||
d_chance = ((gift_value + v.chance) * (self.shrewdness + trade_shrewdness)) / (gr_trade + 1)
|
local d_chance = 0
|
||||||
--print(v.name.." d_chance = " ..d_chance)
|
d_chance = ((gift_value + v.chance) * (self.shrewdness + trade_shrewdness)) / (gr_trade + 1)
|
||||||
--more likely to get something really rare , less likely to get something common
|
--print(v.name.." d_chance = " ..d_chance)
|
||||||
if gift == self.follow[1] then d_chance = self.shrewdness + trade_shrewdness end
|
--more likely to get something really rare , less likely to get something common
|
||||||
d_chance = math.ceil(d_chance)
|
if gift == self.follow[1] then d_chance = self.shrewdness + trade_shrewdness end
|
||||||
if math.random(d_chance) == 1 then
|
d_chance = math.ceil(d_chance)
|
||||||
if debug_goblins_trade == true then
|
if math.random(d_chance) == 1 then
|
||||||
print_s(S("\n @1 dropped by @2 at an adjusted chance of 1 in @3", dump(v.name),dump(self.name),dump(d_chance)))
|
if debug_goblins_trade == true then
|
||||||
|
print_s(S("\n @1 dropped by @2 at an adjusted chance of 1 in @3", dump(v.name),dump(self.name),dump(d_chance)))
|
||||||
|
end
|
||||||
|
minetest.sound_play("goblins_goblin_cackle", {
|
||||||
|
pos = pos,
|
||||||
|
gain = 0.2,
|
||||||
|
max_hear_distance = self.sounds.distance or 10
|
||||||
|
})
|
||||||
|
--let it go already!
|
||||||
|
goblins.mixitup(pos)
|
||||||
|
minetest.add_item(pos, {
|
||||||
|
name = v.name
|
||||||
|
})
|
||||||
end
|
end
|
||||||
minetest.sound_play("goblins_goblin_cackle", {
|
|
||||||
pos = pos,
|
|
||||||
gain = 0.2,
|
|
||||||
max_hear_distance = self.sounds.distance or 10
|
|
||||||
})
|
|
||||||
--let it go already!
|
|
||||||
goblins.mixitup(pos)
|
|
||||||
minetest.add_item(pos, {
|
|
||||||
name = v.name
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -382,12 +388,14 @@ function goblins.give_gift(self,clicker)
|
||||||
if debug_goblins_trade == true then print_s("You did not offer " .. dump(string.split(v,":")[2]) ) end
|
if debug_goblins_trade == true then print_s("You did not offer " .. dump(string.split(v,":")[2]) ) end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local pos = self.object:getpos()
|
local pos = self.object:get_pos()
|
||||||
minetest.sound_play("goblins_goblin_damage", {
|
if pos then
|
||||||
pos = pos,
|
minetest.sound_play("goblins_goblin_damage", {
|
||||||
gain = 0.2,
|
pos = pos,
|
||||||
max_hear_distance = self.sounds.distance or 10
|
gain = 0.2,
|
||||||
})
|
max_hear_distance = self.sounds.distance or 10
|
||||||
|
})
|
||||||
|
end
|
||||||
if name_told and territory_told then
|
if name_told and territory_told then
|
||||||
minetest.chat_send_player(
|
minetest.chat_send_player(
|
||||||
pname,S("@1 of @2 does not want your @3",
|
pname,S("@1 of @2 does not want your @3",
|
||||||
|
@ -417,28 +425,28 @@ function goblins.search_replace(
|
||||||
decorate, --this is for placing attached nodes like goblin mushrooms and torches
|
decorate, --this is for placing attached nodes like goblin mushrooms and torches
|
||||||
debug_me,
|
debug_me,
|
||||||
tools) -- {primary, secondary} based on index# of self.goblin_tools
|
tools) -- {primary, secondary} based on index# of self.goblin_tools
|
||||||
local pos = self.object:getpos()
|
local pos = self.object:get_pos()
|
||||||
if mobs_griefing and not minetest.is_protected(pos, "") and math.random(1, search_rate) == 1 then
|
if pos and mobs_griefing and not minetest.is_protected(pos, "") and math.random(1, search_rate) == 1 then
|
||||||
-- look for nodes
|
-- look for nodes
|
||||||
local pos = self.object:getpos()
|
local pos = self.object:get_pos()
|
||||||
local pos1 = self.object:getpos()
|
local pos1 = self.object:get_pos()
|
||||||
local pos2 = self.object:getpos()
|
local pos2 = self.object:get_pos()
|
||||||
|
|
||||||
--local pos = vector.round(self.object:getpos()) --will have to investigate these further
|
--local pos = vector.round(self.object:get_pos()) --will have to investigate these further
|
||||||
--local pos1 = vector.round(self.object:getpos())
|
--local pos1 = vector.round(self.object:get_pos())
|
||||||
--local pos2 = vector.round(self.object:getpos())
|
--local pos2 = vector.round(self.object:get_pos())
|
||||||
local tool_set = {}
|
local tool_set = {}
|
||||||
if tools then
|
if tools then
|
||||||
tool_set = tools
|
tool_set = tools
|
||||||
end
|
end
|
||||||
|
|
||||||
-- if we are looking, will we look below and by how much?
|
-- if we are looking, will we look below and by how much?
|
||||||
if math.random(1, search_rate_below) == 1 then
|
if pos1 and math.random(1, search_rate_below) == 1 then
|
||||||
pos1.y = pos1.y - search_offset_below
|
pos1.y = pos1.y - search_offset_below
|
||||||
end
|
end
|
||||||
|
|
||||||
-- if we are looking, will we look above and by how much?
|
-- if we are looking, will we look above and by how much?
|
||||||
if math.random(1, search_rate_above) == 1 then
|
if pos2 and math.random(1, search_rate_above) == 1 then
|
||||||
pos2.y = pos2.y + search_offset_above
|
pos2.y = pos2.y + search_offset_above
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -547,8 +555,8 @@ function goblins.tunneling(self, type)
|
||||||
type = "digger"
|
type = "digger"
|
||||||
end
|
end
|
||||||
|
|
||||||
local pos = self.object:getpos()
|
local pos = self.object:get_pos()
|
||||||
if mobs_griefing and not minetest.is_protected(pos, "") then
|
if pos and mobs_griefing and not minetest.is_protected(pos, "") then
|
||||||
if self.state == "tunnel" then
|
if self.state == "tunnel" then
|
||||||
self:set_animation("walk")
|
self:set_animation("walk")
|
||||||
self:set_velocity(self.walk_velocity)
|
self:set_velocity(self.walk_velocity)
|
||||||
|
@ -655,152 +663,156 @@ function goblins.tunneling(self, type)
|
||||||
if debug_goblins_tunneling then print_s("goblineer is now making a room") end
|
if debug_goblins_tunneling then print_s("goblineer is now making a room") end
|
||||||
elseif self.state == "tunnel" and math.random() < 0.1 then
|
elseif self.state == "tunnel" and math.random() < 0.1 then
|
||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
if debug_goblins_tunneling then print_s(dump(vector.round(self.object:getpos())).. "goblineer is thinking...") end
|
if debug_goblins_tunneling then print_s(dump(vector.round(self.object:get_pos())).. "goblineer is thinking...") end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function goblins.danger_dig(self,freq,depth)
|
function goblins.danger_dig(self,freq,depth)
|
||||||
local pos = vector.round(self.object:getpos())
|
local pos = vector.round(self.object:get_pos())
|
||||||
local lol = minetest.get_node_light(pos) or 0
|
if pos then
|
||||||
local freq = freq or 0.1
|
local lol = minetest.get_node_light(pos) or 0
|
||||||
local depth = depth or 1
|
local freq = freq or 0.1
|
||||||
local target = table.copy(pos)
|
local depth = depth or 1
|
||||||
target.y = target.y - depth
|
local target = table.copy(pos)
|
||||||
|
target.y = target.y - depth
|
||||||
|
|
||||||
if self.light_damage_min and
|
if self.light_damage_min and
|
||||||
lol >= self.light_damage_min and
|
lol >= self.light_damage_min and
|
||||||
mobs_griefing and
|
mobs_griefing and
|
||||||
not minetest.is_protected(target, "") and
|
not minetest.is_protected(target, "") and
|
||||||
math.random() <= freq and
|
math.random() <= freq and
|
||||||
minetest.get_node(target).name ~="air" then
|
minetest.get_node(target).name ~="air" then
|
||||||
local target_node = minetest.get_node(target)
|
local target_node = minetest.get_node(target)
|
||||||
|
|
||||||
if self.state ~= "stand" then self.state = "stand" end
|
if self.state ~= "stand" then self.state = "stand" end
|
||||||
|
|
||||||
--find a pick among goblin tools if we can
|
--find a pick among goblin tools if we can
|
||||||
if self.goblin_tools and type(self.goblin_tools) == "table" then
|
if self.goblin_tools and type(self.goblin_tools) == "table" then
|
||||||
local tool = match_item_list("pick",self.goblin_tools)
|
local tool = match_item_list("pick",self.goblin_tools)
|
||||||
if tool then
|
if tool then
|
||||||
goblins.tool_attach(self,self.goblin_tools[tool])
|
goblins.tool_attach(self,self.goblin_tools[tool])
|
||||||
--print("changing tool: "..self.goblin_tools[replace])
|
--print("changing tool: "..self.goblin_tools[replace])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
self:set_velocity(0)
|
self:set_velocity(0)
|
||||||
self:set_animation("punch")
|
self:set_animation("punch")
|
||||||
minetest.remove_node(target)
|
minetest.remove_node(target)
|
||||||
local node_above = vector.round(self.object:getpos())
|
local node_above = vector.round(self.object:get_pos())
|
||||||
node_above.y = node_above.y + 2
|
node_above.y = node_above.y + 2
|
||||||
local nb_node1 = vector.round(self.object:getpos())
|
local nb_node1 = vector.round(self.object:get_pos())
|
||||||
local nb_node2 = vector.round(self.object:getpos())
|
local nb_node2 = vector.round(self.object:get_pos())
|
||||||
nb_node1.y = node_above.y
|
nb_node1.y = node_above.y
|
||||||
nb_node2.y = node_above.y
|
nb_node2.y = node_above.y
|
||||||
nb_node1.x = nb_node1.x - 1
|
nb_node1.x = nb_node1.x - 1
|
||||||
nb_node1.z = nb_node1.z - 1
|
nb_node1.z = nb_node1.z - 1
|
||||||
nb_node2.x = nb_node1.x + 1
|
nb_node2.x = nb_node1.x + 1
|
||||||
nb_node2.z = nb_node1.z + 1
|
nb_node2.z = nb_node1.z + 1
|
||||||
local air_nodes = minetest.find_nodes_in_area(nb_node1,nb_node2, "air")
|
local air_nodes = minetest.find_nodes_in_area(nb_node1,nb_node2, "air")
|
||||||
--print(#nodes)
|
--print(#nodes)
|
||||||
if #air_nodes == 1 then
|
if #air_nodes == 1 then
|
||||||
minetest.set_node(node_above, {name = target_node.name})
|
minetest.set_node(node_above, {name = target_node.name})
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function goblins.goblin_dog_behaviors(self)
|
function goblins.goblin_dog_behaviors(self)
|
||||||
local pos = self.object:getpos()
|
local pos = self.object:get_pos()
|
||||||
if math.random() < 0.1 then
|
if pos then
|
||||||
goblins.attack(self)
|
if math.random() < 0.1 then
|
||||||
--print("looking for a reason to fight")
|
goblins.attack(self)
|
||||||
end
|
--print("looking for a reason to fight")
|
||||||
if mobs_griefing and not minetest.is_protected(pos, "") then
|
|
||||||
if math.random() < 0.5 then
|
|
||||||
--consume meaty bones"
|
|
||||||
goblins.search_replace(
|
|
||||||
self,
|
|
||||||
100, --search_rate
|
|
||||||
100000, --search_rate_above
|
|
||||||
100000, --search_rate_below
|
|
||||||
1, --search_offset
|
|
||||||
1, --search_offset_above
|
|
||||||
1, --search_offset_below
|
|
||||||
5, --replace_rate
|
|
||||||
{"group:meat","group:food_meat","group:food_meat_raw"}, --replace_what
|
|
||||||
"goblins:goblins_goblin_bone", --replace_with
|
|
||||||
10, --replace_rate_secondary
|
|
||||||
"air", --replace_with_secondary --very hungry
|
|
||||||
nil, --decorate
|
|
||||||
false --debug_me if debugging also enabled in behaviors.lua
|
|
||||||
)
|
|
||||||
elseif math.random() < 0.5 then
|
|
||||||
--consume dry bones"
|
|
||||||
goblins.search_replace(
|
|
||||||
self,
|
|
||||||
100, --search_rate
|
|
||||||
100000, --search_rate_above
|
|
||||||
100000, --search_rate_below
|
|
||||||
1, --search_offset
|
|
||||||
1, --search_offset_above
|
|
||||||
1, --search_offset_below
|
|
||||||
5, --replace_rate
|
|
||||||
"goblins:goblins_goblin_bone", --replace_what
|
|
||||||
"air", --replace_with
|
|
||||||
nil, --replace_rate_secondary
|
|
||||||
nil, --replace_with_secondary
|
|
||||||
nil, --decorate
|
|
||||||
false--debug_me if debugging also enabled in behaviors.lua
|
|
||||||
)
|
|
||||||
elseif math.random() < 0.8 then
|
|
||||||
--dig and maybe bury bones if theres suitable terrain around
|
|
||||||
goblins.search_replace(
|
|
||||||
self,
|
|
||||||
100, --search_rate
|
|
||||||
100000, --search_rate_above
|
|
||||||
100, --search_rate_below
|
|
||||||
1, --search_offset
|
|
||||||
1, --search_offset_above
|
|
||||||
2, --search_offset_below
|
|
||||||
10, --replace_rate
|
|
||||||
{"group:soil",
|
|
||||||
"group:sand",
|
|
||||||
"default:gravel"}, --replace_what
|
|
||||||
"goblins:dirt_with_bone",
|
|
||||||
2, --replace_rate_secondary
|
|
||||||
"default:dirt", --replace_with_secondary
|
|
||||||
nil, --decorate
|
|
||||||
false --debug_me if debugging also enabled in behaviors.lua
|
|
||||||
)
|
|
||||||
else
|
|
||||||
--or maybe bury something more useful
|
|
||||||
goblins.search_replace(
|
|
||||||
self,
|
|
||||||
100, --search_rate
|
|
||||||
100000, --search_rate_above
|
|
||||||
100, --search_rate_below
|
|
||||||
1, --search_offset
|
|
||||||
1, --search_offset_above
|
|
||||||
2, --search_offset_below
|
|
||||||
10, --replace_rate
|
|
||||||
{"group:soil",
|
|
||||||
"group:sand",
|
|
||||||
"default:gravel"}, --replace_what
|
|
||||||
"goblins:dirt_with_stuff",
|
|
||||||
2, --replace_rate_secondary
|
|
||||||
"default:dirt", --replace_with_secondary
|
|
||||||
nil, --decorate
|
|
||||||
false --debug_me if debugging also enabled in behaviors.lua
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
if mobs_griefing and not minetest.is_protected(pos, "") then
|
||||||
|
if math.random() < 0.5 then
|
||||||
|
--consume meaty bones"
|
||||||
|
goblins.search_replace(
|
||||||
|
self,
|
||||||
|
100, --search_rate
|
||||||
|
100000, --search_rate_above
|
||||||
|
100000, --search_rate_below
|
||||||
|
1, --search_offset
|
||||||
|
1, --search_offset_above
|
||||||
|
1, --search_offset_below
|
||||||
|
5, --replace_rate
|
||||||
|
{"group:meat","group:food_meat","group:food_meat_raw"}, --replace_what
|
||||||
|
"goblins:goblins_goblin_bone", --replace_with
|
||||||
|
10, --replace_rate_secondary
|
||||||
|
"air", --replace_with_secondary --very hungry
|
||||||
|
nil, --decorate
|
||||||
|
false --debug_me if debugging also enabled in behaviors.lua
|
||||||
|
)
|
||||||
|
elseif math.random() < 0.5 then
|
||||||
|
--consume dry bones"
|
||||||
|
goblins.search_replace(
|
||||||
|
self,
|
||||||
|
100, --search_rate
|
||||||
|
100000, --search_rate_above
|
||||||
|
100000, --search_rate_below
|
||||||
|
1, --search_offset
|
||||||
|
1, --search_offset_above
|
||||||
|
1, --search_offset_below
|
||||||
|
5, --replace_rate
|
||||||
|
"goblins:goblins_goblin_bone", --replace_what
|
||||||
|
"air", --replace_with
|
||||||
|
nil, --replace_rate_secondary
|
||||||
|
nil, --replace_with_secondary
|
||||||
|
nil, --decorate
|
||||||
|
false--debug_me if debugging also enabled in behaviors.lua
|
||||||
|
)
|
||||||
|
elseif math.random() < 0.8 then
|
||||||
|
--dig and maybe bury bones if theres suitable terrain around
|
||||||
|
goblins.search_replace(
|
||||||
|
self,
|
||||||
|
100, --search_rate
|
||||||
|
100000, --search_rate_above
|
||||||
|
100, --search_rate_below
|
||||||
|
1, --search_offset
|
||||||
|
1, --search_offset_above
|
||||||
|
2, --search_offset_below
|
||||||
|
10, --replace_rate
|
||||||
|
{"group:soil",
|
||||||
|
"group:sand",
|
||||||
|
"default:gravel"}, --replace_what
|
||||||
|
"goblins:dirt_with_bone",
|
||||||
|
2, --replace_rate_secondary
|
||||||
|
"default:dirt", --replace_with_secondary
|
||||||
|
nil, --decorate
|
||||||
|
false --debug_me if debugging also enabled in behaviors.lua
|
||||||
|
)
|
||||||
|
else
|
||||||
|
--or maybe bury something more useful
|
||||||
|
goblins.search_replace(
|
||||||
|
self,
|
||||||
|
100, --search_rate
|
||||||
|
100000, --search_rate_above
|
||||||
|
100, --search_rate_below
|
||||||
|
1, --search_offset
|
||||||
|
1, --search_offset_above
|
||||||
|
2, --search_offset_below
|
||||||
|
10, --replace_rate
|
||||||
|
{"group:soil",
|
||||||
|
"group:sand",
|
||||||
|
"default:gravel"}, --replace_what
|
||||||
|
"goblins:dirt_with_stuff",
|
||||||
|
2, --replace_rate_secondary
|
||||||
|
"default:dirt", --replace_with_secondary
|
||||||
|
nil, --decorate
|
||||||
|
false --debug_me if debugging also enabled in behaviors.lua
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
--[[not quite ready yet...
|
||||||
|
if math.random() < 0.01 then
|
||||||
|
goblins.do_taunt_at(self)
|
||||||
|
print_s("are " ..dump(self.name).. " barking?" )
|
||||||
|
end
|
||||||
|
--]]
|
||||||
end
|
end
|
||||||
--[[not quite ready yet...
|
|
||||||
if math.random() < 0.01 then
|
|
||||||
goblins.do_taunt_at(self)
|
|
||||||
print_s("are " ..dump(self.name).. " barking?" )
|
|
||||||
end
|
|
||||||
--]]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ goblins.gob_types = {
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
elseif math.random() < 0.5 then
|
elseif math.random() < 0.5 then
|
||||||
--and self.object:getpos().y < 0 then
|
--and self.object:get_pos().y < 0 then
|
||||||
goblins.search_replace(
|
goblins.search_replace(
|
||||||
self,
|
self,
|
||||||
50, --search_rate how often do we search?
|
50, --search_rate how often do we search?
|
||||||
|
@ -782,7 +782,7 @@ goblins.goblin_template = { --your average goblin,
|
||||||
end
|
end
|
||||||
--print (dump(self.secret_name))
|
--print (dump(self.secret_name))
|
||||||
--print (dump(self.special_gifts).. " are precious to "..dump(self.secret_name).. "!")
|
--print (dump(self.special_gifts).. " are precious to "..dump(self.secret_name).. "!")
|
||||||
local pos = vector.round(self.object:getpos())
|
local pos = vector.round(self.object:get_pos())
|
||||||
if not pos then print(dump(self).."\n **position error!** \n") return end --something went wrong!
|
if not pos then print(dump(self).."\n **position error!** \n") return end --something went wrong!
|
||||||
if not self.secret_territory then
|
if not self.secret_territory then
|
||||||
local opt_data = {}
|
local opt_data = {}
|
||||||
|
|
|
@ -2,7 +2,3 @@ name = goblins
|
||||||
descriptions = add goblins that dig tunnels, set traps and create lairs.
|
descriptions = add goblins that dig tunnels, set traps and create lairs.
|
||||||
depends = default, mobs
|
depends = default, mobs
|
||||||
optional_depends = ambience, hunger_ng
|
optional_depends = ambience, hunger_ng
|
||||||
|
|
||||||
author = FreeLikeGNU
|
|
||||||
description = (Respectfully) Destructive! Goblin NPCs burrow underground, build lairs, set traps and cultivate foodstuffs. They like to steal torches! This is a Work In Progress, but quite playable!
|
|
||||||
title = Goblins
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
name = goblins
|
||||||
|
descriptions = add goblins that dig tunnels, set traps and create lairs.
|
||||||
|
depends = default, mobs
|
||||||
|
optional_depends = ambience, hunger_ng
|
|
@ -0,0 +1,11 @@
|
||||||
|
--- mod.conf
|
||||||
|
+++ mod.conf
|
||||||
|
@@ -2,7 +2,7 @@ name = goblins
|
||||||
|
descriptions = add goblins that dig tunnels, set traps and create lairs.
|
||||||
|
depends = default, mobs
|
||||||
|
optional_depends = ambience, hunger_ng
|
||||||
|
-release = 4547
|
||||||
|
+
|
||||||
|
author = FreeLikeGNU
|
||||||
|
description = (Respectfully) Destructive! Goblin NPCs burrow underground, build lairs, set traps and cultivate foodstuffs. They like to steal torches! This is a Work In Progress, but quite playable!
|
||||||
|
title = Goblins
|
|
@ -173,7 +173,7 @@ function goblins.moss_spread(pos, node)
|
||||||
--print("moss spread abm"..minetest.pos_to_string(pos))
|
--print("moss spread abm"..minetest.pos_to_string(pos))
|
||||||
if math.random() < 0.1 then
|
if math.random() < 0.1 then
|
||||||
|
|
||||||
minetest.place_node(pos,{name = "goblins:mushroom_goblin"})
|
minetest.set_node(pos,{name = "goblins:mushroom_goblin"})
|
||||||
else
|
else
|
||||||
local positions = minetest.find_nodes_in_area_under_air(
|
local positions = minetest.find_nodes_in_area_under_air(
|
||||||
{x = pos.x - 1, y = pos.y - 2, z = pos.z - 1},
|
{x = pos.x - 1, y = pos.y - 2, z = pos.z - 1},
|
||||||
|
|
|
@ -195,7 +195,7 @@ end
|
||||||
-- Purely for debugging or curiosity it can be enabled at the top of this page
|
-- Purely for debugging or curiosity it can be enabled at the top of this page
|
||||||
function goblins.announce_spawn(self)
|
function goblins.announce_spawn(self)
|
||||||
if announce_spawning == true then
|
if announce_spawning == true then
|
||||||
local pos = vector.round(self.object:getpos())
|
local pos = vector.round(self.object:get_pos())
|
||||||
if not pos then return end
|
if not pos then return end
|
||||||
if self.secret_name then
|
if self.secret_name then
|
||||||
print_s( self.name:split(":")[2].. ", "..self.secret_name.." spawned at: " .. minetest.pos_to_string(pos))
|
print_s( self.name:split(":")[2].. ", "..self.secret_name.." spawned at: " .. minetest.pos_to_string(pos))
|
||||||
|
|
Loading…
Reference in New Issue