Make the origin of the map configurable. The strength of mobs and such will be based on this value instead of 0,0,0

pull/26/merge
Brandon 2015-09-26 13:28:28 -05:00
parent 00624ed7ef
commit ceb3fe50e5
5 changed files with 33 additions and 5 deletions

View File

@ -1,4 +1,11 @@
-- VARIOUS MISC ADVENTURETEST RELATED STUFF
game_origin = nil
if minetest.setting_get("game_origin") ~= nil then
game_origin = minetest.string_to_pos(minetest.setting_get("game_origin"))
else
game_origin = {x=0,y=0,z=0}
end
dofile(minetest.get_modpath("adventuretest").."/register_functions.lua");
dofile(minetest.get_modpath("adventuretest").."/privs.lua")

View File

@ -1462,6 +1462,27 @@ minetest.register_node("default:dry_shrub", {
},
})
minetest.register_node("default:dry_shrub2", {
description = "Dry Shrub",
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"default_dry_shrub2.png"},
inventory_image = "default_dry_shrub2.png",
wield_image = "default_dry_shrub2.png",
paramtype = "light",
waving = 1,
walkable = false,
is_ground_content = true,
buildable_to = true,
groups = {snappy=3,flammable=3,attached_node=1},
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
},
})
minetest.register_node("default:grass_1", {
description = "Grass",
drawtype = "plantlike",

View File

@ -257,7 +257,7 @@ function mobs:register_mob(name, def)
on_activate = function(self, staticdata, dtime_s)
-- reset HP
local pos = self.object:getpos()
local distance_rating = ( ( get_distance({x=0,y=0,z=0},pos) ) / 20000 )
local distance_rating = ( ( get_distance(game_origin,pos) ) / 20000 )
local newHP = self.hp_min + math.floor( self.hp_max * distance_rating )
self.object:set_hp( newHP )
@ -323,7 +323,7 @@ function mobs:register_mob(name, def)
end
if minetest.get_modpath("skills") and minetest.get_modpath("experience") then
-- DROP experience
local distance_rating = ( ( get_distance({x=0,y=0,z=0},pos) ) / ( skills.get_player_level(hitter:get_player_name()).level * 1000 ) )
local distance_rating = ( ( get_distance(game_origin,pos) ) / ( skills.get_player_level(hitter:get_player_name()).level * 1000 ) )
local emax = math.floor( self.exp_min + ( distance_rating * self.exp_max ) )
local expGained = math.random(self.exp_min, emax)
skills.add_exp(hitter:get_player_name(),expGained)
@ -496,7 +496,7 @@ function mobs:spawn_mob(pos,name)
local mob = minetest.add_entity(pos, name)
-- setup the hp, armor, drops, etc... for this specific mob
local distance_rating = ( ( get_distance({x=0,y=0,z=0},pos) ) / 15000 )
local distance_rating = ( ( get_distance(game_origin,pos) ) / 15000 )
if mob ~= nil then
mob = mob:get_luaentity()
if mob ~= nil then

View File

@ -138,7 +138,7 @@ local numNPCs = math.random(0,1)
minetest.log("action","Spawning "..barbarian.." at "..minetest.pos_to_string(npos))
local mob = minetest.add_entity(npos, barbarian)
if mob then
local distance_rating = ( ( get_distance({x=0,y=0,z=0},npos) ) / 15000 )
local distance_rating = ( ( get_distance(game_origin,npos) ) / 15000 )
mob = mob:get_luaentity()
local newHP = mob.hp_min + math.floor( mob.hp_max * distance_rating )
mob.object:set_hp( newHP )

View File

@ -213,7 +213,7 @@ quests.treasure.place_treasure = function (pos,minp,maxp)
end
quests.treasure.set_inventory = function (pos)
local distance = default.get_distance({x=0,y=0,z=0},{x=pos.x,y=0,z=pos.z})
local distance = default.get_distance(game_origin,{x=pos.x,y=0,z=pos.z})
local treasure_level = math.floor( distance / 5000 )
if treasure_level == 0 then treasure_level = 1 end
local meta = minetest.get_meta(pos)