|
@@ -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 !");
|