added config setting for vertical rotation factor, and fixed mag wear initialization

This commit is contained in:
FatalErr42O 2024-03-17 21:59:03 -07:00
parent 1930beb338
commit be0f5317d1
3 changed files with 12 additions and 6 deletions

View File

@ -25,13 +25,18 @@ end
function Guns4d.ammo.initialize_mag_data(itemstack, meta)
meta = meta or itemstack:get_meta()
meta:set_string("guns4d_loaded_bullets", minetest.serialize({}))
if meta:get_int("guns4d_spawn_with_ammo") > 0 then
bullets = {
[def.accepted_bullets[1]]=meta:get_int("guns4d_spawn_with_ammo")
local loaded
local spawn = meta:get_int("guns4d_spawn_with_ammo")
if (spawn > 0) or Guns4d.config.interpret_initial_wear_as_ammo then
local def = Guns4d.ammo.registered_magazines[itemstack:get_name()]
loaded = {
[def.accepted_bullets[1]]=(spawn > 0 and spawn) or math.floor(def.capacity*(1-(itemstack:get_wear()/65535)))
}
meta:set_int("guns4d_spawn_with_ammo", 0)
meta:set_string("guns4d_loaded_bullets", minetest.serialize(loaded))
itemstack:set_wear(0)
else
bullets = minetest.deserialize(meta:get_string("guns4d_loaded_bullets"))
loaded = minetest.deserialize(meta:get_string("guns4d_loaded_bullets"))
end
Guns4d.ammo.update_mag(nil, itemstack, meta)
return itemstack

View File

@ -296,7 +296,7 @@ function gun_default:update(dt)
local look_rotation = handler.look_rotation --remember that this is in counterclock-wise rotation. For 4dguns we use clockwise so it makes a bit more sense for recoil. So it needs to be inverted.
local total_rot = self.total_offset_rotation
local player_rot = self.player_rotation
local constant = 5 --make this a config setting
local constant = Guns4d.config.vertical_rotation_factor
--player look rotation. I'm going to keep it real, I don't remember what this math does. Player handler just stores the player's rotation from MT in degrees, which is for some reason inverted
player_rot.y = -handler.look_rotation.y

View File

@ -13,7 +13,8 @@ Guns4d.config = {
control_held_toggle_threshold = 0,
empty_symbol = "0e",
infinite_ammo_priv = "guns4d_infinite_ammo",
interpret_initial_wear_as_ammo = false
interpret_initial_wear_as_ammo = false,
vertical_rotation_factor = 10
--`["official_content.replace_ads_with_bloom"] = false,
--`["official_content.uses_magazines"] = true
}