Turn all settings into proper Minetest Mod-Settings

This commit is contained in:
Lars 2022-04-01 13:13:50 -07:00
parent d62d405a5f
commit 90ffde8318
6 changed files with 114 additions and 74 deletions

@ -5,9 +5,6 @@ forbidden_ents = {
minetest.register_alias("rangedweapons:726mm", "rangedweapons:762mm")
bullet_particles = bullet_particles or "rangedweapons_bullet_fly.png"
minetest.register_craftitem("rangedweapons:shot_bullet_visual", {
wield_scale = {x=1.0,y=1.0,z=1.0},
inventory_image = "rangedweapons_bulletshot.png",
@ -270,20 +267,25 @@ local skill = self.skill_value or 1
for _, dmg in pairs(actualDamage) do
damage[_] = actualDamage[_]
end
local player_dmg_multiplier = minetest.settings:get("rangedweapons_player_dmg_multiplier") or 1.0
local headshot_dmg_multiplier = minetest.settings:get("rangedweapons_headshot_dmg_multiplier") or 1.75
local mob_dmg_multiplier = minetest.settings:get("rangedweapons_mob_dmg_multiplier") or 1.0
if moveresult.collisions[1].object:is_player() then
for _, player_dmg in pairs(damage) do
damage[_] = damage[_] * rweapons_player_dmg_multiplier
damage[_] = damage[_] * player_dmg_multiplier
end
if self.object:get_pos().y - moveresult.collisions[1].object:get_pos().y > 1.5 then
for _, hs_dmg in pairs(damage) do
damage[_] = damage[_] * rweapons_headshot_dmg_multiplier
damage[_] = damage[_] * headshot_dmg_multiplier
end
end
knockback = damage.knockback or 0
projectile_kb(moveresult.collisions[1].object,self.object,knockback)
else
for _, mob_dmg in pairs(damage) do
damage[_] = damage[_] * rweapons_mob_dmg_multiplier
damage[_] = damage[_] * mob_dmg_multiplier
end
end
@ -311,7 +313,8 @@ moveresult.collisions[1].object:punch(owner, 1.0, {
damage_groups = damage,}, nil)
owner:hud_change(hit, "text", hit_texture)
for i=1,math.random(math.ceil(rweapons_bloodyness*0.66),math.ceil(rweapons_bloodyness*1.5)) do
local bloodyness = minetest.settings:get("rangedweapons_bloodyness") or 10
for i=1,math.random(math.ceil(bloodyness*0.66),math.ceil(bloodyness*1.5)) do
minetest.add_particle({
pos = self.object:get_pos(),
velocity = {x=math.random(-15.0,15.0)/10, y=math.random(2.0,5.0), z=math.random(-15.0,15.0)/10},

@ -1,6 +1,6 @@
----------------------------
----------------------------
if rweapons_gun_crafting == "true" then
if minetest.settings:get_bool("rangedweapons_gun_crafting", true) then
minetest.register_craft({
output = "rangedweapons:aa12",
@ -391,7 +391,7 @@ minetest.register_craft({
end
----------------------------------
----------------------------------
if rweapons_other_weapon_crafting == "true" then
if minetest.settings:get_bool("rangedweapons_other_weapons_crafting", true) then
minetest.register_craft({
output = "rangedweapons:barrel",
@ -479,7 +479,7 @@ minetest.register_craft({
end
------------------------------------
------------------------------------
if rweapons_ammo_crafting == "true" then
if minetest.settings:get_bool("rangedweapons_ammo_crafting", true) then
minetest.register_craft({
output = "rangedweapons:9mm 40",
@ -594,7 +594,7 @@ minetest.register_craft({
end
-------------------------------------
-------------------------------------
if rweapons_item_crafting == "true" then
if minetest.settings:get_bool("rangedweapons_item_crafting", true) then
minetest.register_craft({
output = "rangedweapons:generator",

@ -39,13 +39,14 @@ minetest.sound_play("rengedweapons_ricochet", {pos = pos, gain = 0.75})
end
end
local max_gun_efficiency = minetest.settings:get("rangedweapons_max_gun_efficiency") or 300
rangedweapons_gain_skill = function(player,skill,chance)
if math.random(1, chance) == 1 then
local p_meta = player:get_meta()
local skill_num = p_meta:get_int(skill)
if skill_num < rweapons_max_gun_efficiency then
if skill_num < max_gun_efficiency then
p_meta:set_int(skill, skill_num + 1)
minetest.chat_send_player(player:get_player_name(), "" ..core.colorize("#25c200","You've improved your skill with this type of gun!"))
end
@ -72,7 +73,6 @@ if GunCaps ~= nil then
gun_reload = GunCaps.gun_reload or 0.25
end
local inf_ammo = minetest.settings:get_bool("infinite_ammo") or false
local playerMeta = player:get_meta()
local gunMeta = itemstack:get_meta()
@ -124,7 +124,7 @@ local ammoCount = gunMeta:get_int("RW_bullets")
local ammoName = gunMeta:get_string("RW_ammo_name")
local inv = player:get_inventory()
if inf_ammo then
if minetest.settings:get_bool("rangedweapons_infinite_ammo", false) then
gunMeta:set_int("RW_bullets",clipSize)
else
inv:add_item("main",ammoName.." "..ammoCount)
@ -537,7 +537,7 @@ end
rangedweapons_launch_projectile(player,combined_projNum,combined_dmg,bullet_ent,bullet_visual,bullet_texture,gun_sound,combined_velocity,gun_accuracy,skill_value,OnCollision,combined_crit,combined_critEffc,combined_mobPen,combined_nodePen,gun_shell,bullet_shell_ent,bullet_shell_texture,bullet_shell_visual,combined_dps,combined_gravity,gun_door_breaking,bullet_glass_breaking,bullet_particles,bullet_sparks,bullet_bomb_ignite,bullet_size,gun_smokeSize,0,bullet_glow)
if rweapons_gun_durability == "true" then
if minetest.settings:get_bool("rangedweapons_gun_wear", true) then
itemstack:add_wear(65535/gun_durability)
end
itemstack:set_name(gun_cooling)
@ -646,7 +646,7 @@ end
rangedweapons_launch_projectile(player,power_projectiles,power_damage,power_ent,power_visual,power_texture,power_sound,power_velocity,power_accuracy,skill_value,OnCollision,power_crit,power_critEffc,power_mobPen,power_nodePen,0,"","","",power_dps,power_gravity,power_door_breaking,power_glass_breaking,power_particles,power_sparks,power_bomb_ignite,power_size,0,0,power_glow)
if rweapons_gun_durability == "true" then
if minetest.settings:get_bool("rangedweapons_gun_wear", true) then
itemstack:add_wear(65535/power_durability)
end
itemstack:set_name(power_cooling)
@ -770,7 +770,6 @@ obj:set_acceleration({x=dir.x*-5, y=-10, z=dir.z*-5})
dofile(modpath.."/settings.lua")
dofile(modpath.."/cooldown_stuff.lua")
dofile(modpath.."/skills.lua")
dofile(modpath.."/misc.lua")
@ -778,11 +777,11 @@ dofile(modpath.."/bullet_knockback.lua")
dofile(modpath.."/ammo.lua")
dofile(modpath.."/crafting.lua")
if rweapons_shurikens == "true" then
if minetest.settings:get_bool("rangedweapons_shurikens", true) then
dofile(modpath.."/shurikens.lua")
end
if rweapons_handguns == "true" then
if minetest.settings:get_bool("rangedweapons_handguns", true) then
dofile(modpath.."/makarov.lua")
dofile(modpath.."/luger.lua")
dofile(modpath.."/beretta.lua")
@ -791,64 +790,64 @@ if rweapons_handguns == "true" then
dofile(modpath.."/deagle.lua")
end
if rweapons_forceguns == "true" then
if minetest.settings:get_bool("rangedweapon_forceguns", true) then
dofile(modpath.."/forcegun.lua")
end
if rweapons_javelins == "true" then
if minetest.settings:get_bool("rangedweapons_javelins", true) then
dofile(modpath.."/javelin.lua")
end
if rweapons_power_weapons == "true" then
if minetest.settings:get_bool("rangedweapons_power_weapons", true) then
dofile(modpath.."/generator.lua")
dofile(modpath.."/laser_blaster.lua")
dofile(modpath.."/laser_rifle.lua")
dofile(modpath.."/laser_shotgun.lua")
end
if rweapons_machine_pistols == "true" then
if minetest.settings:get_bool("rangedweapons_machine_pistols", true) then
dofile(modpath.."/tmp.lua")
dofile(modpath.."/tec9.lua")
dofile(modpath.."/uzi.lua")
dofile(modpath.."/kriss_sv.lua")
end
if rweapons_shotguns == "true" then
if minetest.settings:get_bool("rangedweapons_shotguns", true) then
dofile(modpath.."/remington.lua")
dofile(modpath.."/spas12.lua")
dofile(modpath.."/benelli.lua")
end
if rweapons_auto_shotguns == "true" then
if minetest.settings:get_bool("rangedweapons_auto_shotguns", true) then
dofile(modpath.."/jackhammer.lua")
dofile(modpath.."/aa12.lua")
end
if rweapons_smgs == "true" then
if minetest.settings:get_bool("rangedweapons_smgs", true) then
dofile(modpath.."/mp5.lua")
dofile(modpath.."/ump.lua")
dofile(modpath.."/mp40.lua")
dofile(modpath.."/thompson.lua")
end
if rweapons_rifles == "true" then
if minetest.settings:get_bool("rangedweapons_rifles", true) then
dofile(modpath.."/awp.lua")
dofile(modpath.."/svd.lua")
dofile(modpath.."/m200.lua")
end
if rweapons_heavy_machineguns == "true" then
if minetest.settings:get_bool("rangedweapons_heavy_machineguns", true) then
dofile(modpath.."/m60.lua")
dofile(modpath.."/rpk.lua")
dofile(modpath.."/minigun.lua")
end
if rweapons_revolvers == "true" then
if minetest.settings:get_bool("rangedweapons_revolvers", true) then
dofile(modpath.."/python.lua")
dofile(modpath.."/taurus.lua")
end
if rweapons_assault_rifles == "true" then
if minetest.settings:get_bool("rangedweapons_assault_rifles", true) then
dofile(modpath.."/m16.lua")
dofile(modpath.."/g36.lua")
dofile(modpath.."/ak47.lua")
dofile(modpath.."/scar.lua")
end
if rweapons_explosives == "true" then
if minetest.settings:get_bool("rangedweapons_explosives", true) then
dofile(modpath.."/explosives.lua")
dofile(modpath.."/m79.lua")
dofile(modpath.."/milkor.lua")
@ -856,11 +855,9 @@ if rweapons_explosives == "true" then
dofile(modpath.."/hand_grenade.lua")
end
if rweapons_glass_breaking == "true" then
if minetest.settings:get_bool("rangedweapons_glass_breaking", true) then
dofile(modpath.."/glass_breaking.lua")
end
if not minetest.settings:get_bool("glass_breaking") then
--[[ What is this good for?
minetest.register_abm({
nodenames = {"rangedweapons:broken_glass"},
interval = 1,
@ -873,6 +870,8 @@ minetest.register_abm({
end
})
end
--]]
end
local rangedweapons_empty_shell = {
physical = false,

@ -1,29 +0,0 @@
rweapons_player_dmg_multiplier = 1.0
rweapons_mob_dmg_multiplier = 1.0
rweapons_headshot_dmg_multiplier = 1.75
rweapons_max_gun_efficiency = 300
rweapons_min_gun_efficiency = 40
rweapons_bloodyness = 10
rweapons_gun_crafting = "true"
rweapons_gun_durability = "true"
rweapons_shurikens = "true"
rweapons_handguns = "true"
rweapons_forceguns = "true"
rweapons_javelins = "true"
rweapons_power_weapons = "true"
rweapons_machine_pistols = "true"
rweapons_shotguns = "true"
rweapons_auto_shotguns = "true"
rweapons_smgs = "true"
rweapons_rifles = "true"
rweapons_assault_rifles = "true"
rweapons_heavy_machineguns = "true"
rweapons_revolvers = "true"
rweapons_explosives = "true"
rweapons_glass_breaking = "true"
rweapons_door_breaking = "true"
rweapons_other_weapon_crafting = "true"
rweapons_ammo_crafting = "true"
rweapons_item_crafting = "true"

@ -1,2 +1,67 @@
# If true, a guns will wear off with use
rangedweapons_gun_wear (Gun Usage-Wear) bool true
# If true, guns can be crafted
rangedweapons_gun_crafting (Gun Crafting) bool true
# If true, items can be crafted
rangedweapons_item_crafting (Item Crafting) bool true
# If true, ammonition can be crafted
rangedweapons_ammo_crafting (Ammonition Crafting) bool true
# If true, other weapons can be crafted
rangedweapons_other_weapon_crafting (Other Weapon Crafting) bool true
# If true, a gun can always be reloaded (just need at least one matching bullet in the inventory)
infinite_ammo (Inifinite Ammo) bool false
rangedweapons_infinite_ammo (Inifinite Ammo) bool false
# Damage multiplier for hits on other players
rangedweapons_player_dmg_multiplier (Player Damage Multiplier) float 1.0
# Damage multiplier for head shots
rangedweapons_headshot_dmg_multiplier (Headshot Damage Multiplier) float 1.75
# Damage multiplier for hits on mobs
rangedweapons_mob_dmg_multiplier (Mob Damage Multiplier) float 1.0
# Amount of blood
rangedweapons_bloodyness (Bloodyness) int 10
# Maximum Gun Skill (set to 100 to disable gaining skil)
rangedweapons_max_gun_efficiency (Maximum Gun Skill) int 300
# Minimum Gun Skill (set to 100 to disable loosing skil)
rangedweapons_min_gun_efficiency (Minimum Gun Skill) int 40
rangedweapons_shurikens (Enable Shurikens) bool true
rangedweapons_handguns (Enable Handgus) bool true
rangedweapons_forceguns (Enable Force-Guns) bool true
rangedweapons_javelins (Enable Javelins) bool true
rangedweapons_power_weapons (Enable Power-Weapons) bool true
rangedweapons_machine_pistols (Enable Pistols) bool true
rangedweapons_shotguns (Enable Shotguns) bool true
rangedweapons_auto_shotguns (Enable Auto-Shotguns) bool true
rangedweapons_smgs (Enable Submachine Guns) bool true
rangedweapons_rifles (Enable Rifles) bool true
rangedweapons_assault_rifles (Enable Assault-Rifles) bool true
rangedweapons_heavy_machineguns (Enable Heavy Machineguns) bool true
rangedweapons_revolvers (Enable Revolvers) bool true
rangedweapons_explosives (Enable Explosives) bool true
rangedweapons_glass_breaking (Breaking Glass) bool true
rangedweapons_door_breaking (Breaking Doors) bool true

@ -79,6 +79,8 @@ end
end
})
local min_gun_efficiency = minetest.settings:get("rangedweapons_min_gun_efficiency") or 40
local timer = 0
minetest.register_globalstep(function(dtime, player)
timer = timer + dtime;
@ -95,55 +97,55 @@ local revolver = meta:get_int("revolver_skill")
local rifle = meta:get_int("rifle_skill")
local throw = meta:get_int("throw_skill")
if math.random(1, 40) == 1 then
if handguns > rweapons_min_gun_efficiency then
if handguns > min_gun_efficiency then
meta:set_int("handgun_skill", handguns - 1)
minetest.chat_send_player(player:get_player_name(), "" ..core.colorize("#ff0000","Handgun skill degraded! "))
end
end
if math.random(1, 40) == 1 then
if mps > rweapons_min_gun_efficiency then
if mps > min_gun_efficiency then
meta:set_int("mp_skill", mps - 1)
minetest.chat_send_player(player:get_player_name(), "" ..core.colorize("#ff0000","Machine Pistol skill degraded! "))
end
end
if math.random(1, 40) == 1 then
if smgs > rweapons_min_gun_efficiency then
if smgs > min_gun_efficiency then
meta:set_int("smg_skill", smgs - 1)
minetest.chat_send_player(player:get_player_name(), "" ..core.colorize("#ff0000","S.M.G skill degraded! "))
end
end
if math.random(1, 40) == 1 then
if shotguns > rweapons_min_gun_efficiency then
if shotguns > min_gun_efficiency then
meta:set_int("shotgun_skill", shotguns - 1)
minetest.chat_send_player(player:get_player_name(), "" ..core.colorize("#ff0000","Shotgun skill degraded! "))
end
end
if math.random(1, 40) == 1 then
if heavy > rweapons_min_gun_efficiency then
if heavy > min_gun_efficiency then
meta:set_int("heavy_skill", heavy - 1)
minetest.chat_send_player(player:get_player_name(), "" ..core.colorize("#ff0000","Heavy.MG skill degraded! "))
end
end
if math.random(1, 40) == 1 then
if arifle > rweapons_min_gun_efficiency then
if arifle > min_gun_efficiency then
meta:set_int("arifle_skill", arifle - 1)
minetest.chat_send_player(player:get_player_name(), "" ..core.colorize("#ff0000","A.Rifle skill degraded! "))
end
end
if math.random(1, 40) == 1 then
if revolver > rweapons_min_gun_efficiency then
if revolver > min_gun_efficiency then
meta:set_int("revolver_skill", revolver - 1)
minetest.chat_send_player(player:get_player_name(), "" ..core.colorize("#ff0000","Revolver/magnum skill degraded! "))
end
end
if math.random(1, 40) == 1 then
if rifle > rweapons_min_gun_efficiency then
if rifle > min_gun_efficiency then
meta:set_int("rifle_skill", rifle - 1)
minetest.chat_send_player(player:get_player_name(), "" ..core.colorize("#ff0000","Rifle skill degraded! "))
end
end
if math.random(1, 40) == 1 then
if throw > rweapons_min_gun_efficiency then
if throw > min_gun_efficiency then
meta:set_int("throw_skill", throw - 1)
minetest.chat_send_player(player:get_player_name(), "" ..core.colorize("#ff0000","Throwing skill degraded! "))
end