7 コミット 7c812fb42b ... 9d96c17d8d

作者 SHA1 メッセージ 日付
  BlueBird51 9d96c17d8d Dump icecubes down their shirt. That'll get 'em. 11 ヶ月 前
  BlueBird51 f28ea7e3e1 Annoy the 'equality of outcome' crowd 11 ヶ月 前
  BlueBird51 e60b5fd7a2 Dunno why you don't see this more often in games. Could it have something to do with academia? 11 ヶ月 前
  BlueBird51 c960f1c3e9 Simplify 11 ヶ月 前
  BlueBird51 a581baa183 I would have liked to use SecureRandom() but I don't feel like doing the skunkwork to convert a byte string into a random seed. I've done it before, in C++. It wasn't fun. 11 ヶ月 前
  BlueBird51 95830ca0c2 Yes we scan. 11 ヶ月 前
  BlueBird51 4fe7bddead Too intense, maybe? 11 ヶ月 前
4 ファイル変更147 行追加51 行削除
  1. 60 47
      mods/player/init.lua
  2. 21 4
      mods/pova/init.lua
  3. BIN
      mods/rc/outback_small_farm.mts
  4. 66 0
      mods/serveressentials/outback.lua

+ 60 - 47
mods/player/init.lua

@@ -21,28 +21,6 @@ end
 
 
 
---[[
-default.player_register_model("character_musttest.b3d", {
-	animation_speed = 30,
-	textures = {"character.png", },
-	animations = {
-		-- Standard animations.
-		stand     = { x=  0, y= 79, },
-		lay       = { x=162, y=166, },
-		walk      = { x=168, y=187, },
-		mine      = { x=189, y=198, },
-		walk_mine = { x=200, y=219, },
-		-- Extra animations (not currently used by the game).
-		sit       = { x= 81, y=160, },
-        nod       = { x=221, y=251, },
-	},
-})
---]]
-
-
-
 -- Player stats and animations
 local player_model = {}
 local player_textures = {}
@@ -68,23 +46,19 @@ end
 function default.player_set_model(player, model_name)
 	local name = player:get_player_name()
 	local model = models[model_name]
-	if model then
-		if player_model[name] == model_name then
-			return
-		end
-		pova.set_override(player, "properties", {
-			mesh = model_name,
-			textures = player_textures[name] or model.textures,
-			visual = "mesh",
-			visual_size = model.visual_size or {x=1, y=1},
-		})
-		default.player_set_animation(player, "stand")
-	else
-		pova.set_override(player, "properties", {
-			textures = { "player.png", "player_back.png", },
-			visual = "upright_sprite",
-		})
+
+	if player_model[name] == model_name then
+		return
 	end
+
+	pova.set_override(player, "properties", {
+		mesh = model_name,
+		textures = player_textures[name] or model.textures,
+		visual = "mesh",
+		visual_size = model.visual_size or {x=1, y=1, z=1},
+	})
+
+	default.player_set_animation(player, "stand")
 	player_model[name] = model_name
 end
 
@@ -118,7 +92,7 @@ end
 minetest.register_on_joinplayer(function(player)
 	local pname = player:get_player_name()
 	default.player_attached[pname] = false
-	--default.player_set_model(player, "character_musttest.b3d")
+
 	player:set_local_animation({x=0, y=79}, {x=168, y=187}, {x=189, y=198}, {x=200, y=219}, 30)
 
 	-- Big hot-bar is revoked for cheaters.
@@ -176,15 +150,11 @@ minetest.register_globalstep(function(dtime)
 			-- Determine if the player is sneaking, and reduce animation speed if so
 			if controls.sneak then
 				animation_speed_mod = animation_speed_mod / 2
-				pova.set_override(player, "properties", {
-					makes_footstep_sound = false,
-				})
+
+				pova.set_modifier(player, "properties",
+					{makes_footstep_sound = false}, "footstep_sneaking")
 			else
-				if not gdac_invis.is_invisible(pname) then
-					pova.set_override(player, "properties", {
-						makes_footstep_sound = true,
-					})
-				end
+				pova.remove_modifier(player, "properties", "footstep_sneaking")
 			end
 
 			-- Apply animations based on what the player is doing
@@ -211,9 +181,28 @@ end)
 
 
 
+-- Each player gets assigned a unique random seed. Once set, this seed number
+-- shall never change.
+local function set_prng(pref)
+	local pmeta = pref:get_meta()
+	local s = "random_seed"
+	local rand = pmeta:get_int(s)
+
+	-- I would have liked to use SecureRandom() but I don't feel like doing the
+	-- skunkwork to convert a byte string into a random seed. I've done it before,
+	-- in C++. It wasn't fun.
+	if rand == 0 then
+		pmeta:set_int(s, math.random(1000, 10000))
+	end
+end
+
+
+
 -- Disable the "sneak glitch" for all players.
 -- Note: 'sneak=false' interferes with footstep sounds when walking on snow.
 minetest.register_on_joinplayer(function(player)
+	set_prng(player)
+
 	pova.set_override(player, "properties", {
 		infotext = rename.gpn(player:get_player_name()),
 	})
@@ -222,7 +211,29 @@ minetest.register_on_joinplayer(function(player)
 		text = rename.gpn(player:get_player_name()),
 		bgcolor = false,
 	})
-	
+
+	local pmeta = player:get_meta()
+	local random_seed = pmeta:get_int("random_seed")
+	local prng = PseudoRandom(random_seed)
+
+	-- The max diff in either direction should be 0.1, otherwise players will
+	-- be too oversized or undersized.
+	local nsize = 1+(prng:next(-10, 10)/100)
+
+	-- Adjust base speed. Max range diff is 0.05 either direction.
+	local nspeed = 1+(prng:next(-10, 10)/200)
+
+	-- Adjust base jump. Max range diff is 0.05 either direction.
+	local njump = 1+(prng:next(-10, 10)/100)
+
+	pova.set_modifier(player, "properties",
+		{visual_size={x=nsize, y=nsize}},
+	"notbornequal", {priority=-999})
+
+	pova.set_modifier(player, "physics",
+		{speed=nspeed, jump=njump},
+	"notbornequal", {priority=-999})
+
 	-- Disable the minimap. Cheaters will of course be able to enable it.
 	-- Can be reenabled via item in-game.
 	player:hud_set_flags({
@@ -237,7 +248,7 @@ minetest.register_on_joinplayer(function(player)
 	-- check if function is supported by server (old versions 5.5.0)
 	if player["set_lighting"] ~= nil then
 		player:set_lighting({
-			shadows = {intensity=0.5},
+			shadows = {intensity=0.3},
 		})
 	else
 		minetest.log("WARNING", "This server does not support player:lighting !");

+ 21 - 4
mods/pova/init.lua

@@ -179,10 +179,17 @@ end
 
 
 
+local function mult_visual_size(o, n)
+	return {x=o.x * n.x, y=o.y * n.y, z=o.z * (n.z or n.x)}
+end
+
+
+
 -- Combine all modifiers in named stack to a single table. Numbers are
 -- multiplied together if meaningful to do so. Boolean flags and other data
 -- simply overwrite, with the data at the top of the player's stack taking
 -- precedence.
+local def_visual_size = {x=1, y=1, z=1}
 local function combine_data(data, stack)
 	local o = {}
 
@@ -208,14 +215,24 @@ local function combine_data(data, stack)
 		for k, v in ipairs(do_sort(data.properties)) do
 			if not v.mode.op then
 				for i, j in pairs(v.data) do
-					o[i] = j
+					if i == "visual_size" then
+						-- Visual size is *always* multiplied.
+						o[i] = mult_visual_size(o[i] or def_visual_size, j)
+					else
+						o[i] = j
+					end
 				end
 			elseif v.mode.op == "add" then
 				for i, j in pairs(v.data) do
-					if type(j) == "number" then
-						o[i] = (o[i] or 0.0) + j
+					if i == "visual_size" then
+						-- Visual size is *always* multiplied.
+						o[i] = mult_visual_size(o[i] or def_visual_size, j)
 					else
-						o[i] = j
+						if type(j) == "number" then
+							o[i] = (o[i] or 0.0) + j
+						else
+							o[i] = j
+						end
 					end
 				end
 			end

BIN
mods/rc/outback_small_farm.mts


+ 66 - 0
mods/serveressentials/outback.lua

@@ -263,6 +263,71 @@ local function restart_timers()
 	end
 end
 
+
+
+-- Find outback surface under sunlight.
+local function find_ground(pos)
+	local n1 = minetest.get_node(pos)
+	local p2 = vector.offset(pos, 0, -1, 0)
+	local n2 = minetest.get_node(p2)
+	local count = 0
+	while n2.name == "air" and count < 32 do
+		pos = p2
+		n1 = minetest.get_node(pos)
+		p2 = vector.offset(pos, 0, -1, 0)
+		n2 = minetest.get_node(p2)
+		count = count + 1
+	end
+	if n2.name == "rackstone:cobble" and n1.name == "air" then
+		if (minetest.get_node_light(pos, 0.5)) or 0 == 15 then
+			return pos
+		end
+	end
+end
+
+
+
+local function place_random_farms(minp, maxp)
+	for count = 1, 50 do
+		local p = {
+			x = math.random(minp.x + 10, maxp.x - 10),
+			y = maxp.y,
+			z = math.random(minp.z + 10, maxp.z - 10),
+		}
+		local g = find_ground(p)
+		if g then
+			-- Check corners.
+			local c1 = find_ground(vector.offset(g, -2, 16, -2))
+			local c2 = find_ground(vector.offset(g, 2, 16, -2))
+			local c3 = find_ground(vector.offset(g, -2, 16, 2))
+			local c4 = find_ground(vector.offset(g, 2, 16, 2))
+
+			local b1, b2, b3, b4 = false, false, false, false
+
+			-- Make sure ground is mostly flat.
+			if c1 and math.abs(c1.y - g.y) < 2 then b1 = true end
+			if c2 and math.abs(c2.y - g.y) < 2 then b2 = true end
+			if c3 and math.abs(c3.y - g.y) < 2 then b3 = true end
+			if c4 and math.abs(c4.y - g.y) < 2 then b4 = true end
+
+			-- Can't be protected. This relies on protectors and protector meta being
+			-- set *before* we place the farms!
+			if minetest.test_protection(c1, "") then b1 = false end
+			if minetest.test_protection(c2, "") then b2 = false end
+			if minetest.test_protection(c3, "") then b3 = false end
+			if minetest.test_protection(c4, "") then b4 = false end
+
+			if b1 and b2 and b3 and b4 then
+				local schematic = rc.modpath .. "/outback_small_farm.mts"
+				local d = vector.offset(g, -2, -2, -2)
+				minetest.place_schematic(d, schematic, "random", {}, true, "")
+			end
+		end
+	end
+end
+
+
+
 local function callback(blockpos, action, calls_remaining, param)
 	-- We don't do anything until the last callback.
 	if calls_remaining ~= 0 then
@@ -332,6 +397,7 @@ local function callback(blockpos, action, calls_remaining, param)
 	rebuild_nodes()
 	rebuild_metadata()
 	restart_timers()
+	place_random_farms(minp, maxp)
 end
 
 -- This API may be called to completely reset the Outback realm.