ADD fire_plus mod

master
daretmavi 2021-02-19 22:56:19 +01:00
parent a3268337d3
commit 04358d5576
12 changed files with 375 additions and 1 deletions

View File

@ -38,7 +38,7 @@ MOD_PATCH=( ) #patch names
#MOD_PATCHES - all patches defined
#MOD_PATCHES - first is path and all patch names are separeted by ":"
#MOD_PATCHES=("mobs/water_life:poison.patch" "buildings/doors:doors_update.patch" "player/3d_armor:mob_damage.patch" "player/hbsprint:no_damage.patch" "player/hunger_ng:effects.patch")
MOD_PATCHES=("buildings/doors:doors_update.patch" "player/hbsprint:no_damage.patch" "environment/dynamic_liquid:bucket.patch" "mobs/mobs_mobkit/water_life:poison.patch" "mobs/mobs_mobkit/water_life:poison_hunger_ng.patch" "buildings/mg_villages:villages.patch")
MOD_PATCHES=("buildings/doors:doors_update.patch" "player/hbsprint:no_damage.patch" "environment/dynamic_liquid:bucket.patch" "mobs/mobs_mobkit/water_life:poison.patch" "mobs/mobs_mobkit/water_life:poison_hunger_ng.patch" "buildings/mg_villages:villages.patch" "player/fire_plus:extend_fire.patch")
#"mobs/mobs_mobs/goblins:goblins_nil.patch"
#MOD_PATCHES=( )

View File

@ -0,0 +1,16 @@
name: build
on: [push, pull_request]
jobs:
luacheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Luarocks
run: |
sudo apt-get update -qyy
sudo apt-get install luarocks -qyy
- name: Install Luacheck
run: luarocks install --local luacheck
- name: Run Luacheck
run: $HOME/.luarocks/bin/luacheck .

View File

@ -0,0 +1,42 @@
globals = {
"fire_plus",
"armor",
}
read_globals = {
"DIR_DELIM",
"minetest", "core",
"dump", "dump2",
"vector",
"VoxelManip", "VoxelArea",
"PseudoRandom", "PcgRandom",
"ItemStack",
"Settings",
"unpack",
"tnt",
table = {
fields = {
"copy",
"indexof",
"insert_all",
"key_value_swap",
}
},
string = {
fields = {
"split",
"trim",
}
},
math = {
fields = {
"hypot",
"sign",
"factorial"
}
},
}

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019-2021 LoneWolfHT
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,29 @@
# Fire Plus
[![Build status](https://github.com/Dumpster-Studios/fire_plus/workflows/build/badge.svg)](https://github.com/Dumpster-Studios/fire_plus/actions)
[![ContentDB](https://content.minetest.net/packages/Lone_Wolf/fire_plus/shields/downloads/)](https://content.minetest.net/packages/Lone_Wolf/fire_plus/)
![GitHub](https://img.shields.io/github/license/Dumpster-Studios/fire_plus?color=blue)
Allows players to be lit on fire by various fire-related things.
Visuals include HUD effect and fire particles around player.
You can put yourself out by jumping into water/snow.
![Screenshot](screenshot.png)
## Credits
* Thanks to **TenPlus1** for 3d_armor support and some other things
## API
* `fire_plus.burn_player(player, burns, damage)`
* Sets `player` on fire and burns them `burns` times with `damage` damage every second
* `fire_plus.tnt_explode_radius`
* How close to a TNT node a player has to be to detonate it
* `fire_plus.ignition_nodes`
* Nodes that set players on fire. See the init.lua for examples
* `fire_plus.extinguishers`
* Nodes that put out burning players. See the init.lua for examples
* **Fire tools**
* You can allow modders to make tools light punched players on fire
* Just set `tool_capabilities.damage_groups.burns = <How much damage to do each burn>`
* There's also `tool_capabilities.damage_groups.burn_time = <How many times to burn the player>`

View File

@ -0,0 +1,145 @@
local armor_mod = minetest.get_modpath("3d_armor")
-- Replace min/max table with random value from min to max
local function get_val(val)
if type(val) == "table" then
val = math.random(val.min or 1, val.max or 5)
end
return val
end
function fire_plus.burn_player(player, burns, damage, not_initial)
if not player then
minetest.log("warning", "[Fire Plus] (burn_player): player is nil")
end
local name = player
if type(player) == "string" then
player = minetest.get_player_by_name(player)
end
if not player or player:get_hp() <= 0 then
fire_plus.extinguish_player(name)
return
end
name = player:get_player_name()
-- 3d_armor fire protection puts out flames
if armor_mod and armor.def[name].fire > 1 then
fire_plus.extinguish_player(name)
end
-- Fire was extinguished
if not fire_plus.burning[name] and not_initial then
return
end
if not fire_plus.burning[name] then
burns = get_val(burns)
fire_plus.burning[name] = {
burns_left = burns,
hud_id = player:hud_add({
hud_elem_type = "image",
position = {x = 0.5, y = 0.95},
offset = {x = 0, y = 0},
text = "fire_basic_flame.png",
alignment = -1,
scale = {x = 100, y = 32},
number = 0xFFFFFF,
}),
sound_id = minetest.sound_play("fire_fire", {
to_player = name,
gain = 1.0,
loop = true,
}),
particlespawner_id = minetest.add_particlespawner({
amount = 10,
time = 0,
minpos = vector.new(-0.3, 0.5, -0.3),
maxpos = vector.new( 0.3, 2, 0.3),
minvel = {x = -1, y = 0, z = -1},
maxvel = {x = 1, y = 1, z = 1},
minacc = {x = 0, y = 2, z = 0},
maxacc = {x = 0, y = 3, z = 0},
minexptime = 0.5,
maxexptime = 1,
minsize = 3,
maxsize = 3,
texture = "smoke_puff.png",
collisiondetection = true,
glow = 0,
attached = player,
}),
particlespawner_id2 = minetest.add_particlespawner({
amount = 5,
time = 0,
minpos = vector.new(0, 0.5, -0.3),
maxpos = vector.new( 0, 0.5, 0.3),
minvel = {x = 0, y = 0, z = 0},
maxvel = {x = 0, y = 0, z = 0},
minacc = {x = 0, y = 0, z = 0},
maxacc = {x = 0, y = 0, z = 0},
minexptime = 0.5,
maxexptime = 1,
minsize = 10,
maxsize = 10,
texture = "fire_basic_flame_animated.png",
animation = {type="vertical_frames", aspect_w=16, aspect_h=16, length = 1,},
collisiondetection = false,
glow = minetest.LIGHT_MAX,
attached = player,
})
}
else
player:set_hp(player:get_hp() - get_val(damage), {type = "set_hp", fire_plus = true})
if minetest.get_modpath("tnt") then
local tntpos = minetest.find_node_near(player:get_pos(), fire_plus.tnt_explode_radius, {"tnt:tnt"}, true)
if tntpos then
tnt.boom(tntpos, {radius = fire_plus.tnt_explode_radius, damage_radius = fire_plus.tnt_explode_radius})
end
end
if not_initial then
fire_plus.burning[name].burns_left = fire_plus.burning[name].burns_left - 1
else
fire_plus.burning[name].burns_left = burns
end
end
if fire_plus.burning[name].burns_left > 0 then
minetest.after(fire_plus.burn_interval, function()
fire_plus.burn_player(name, burns, damage, true)
end)
else
fire_plus.extinguish_player(name)
end
end
function fire_plus.extinguish_player(player)
local name = player
if player then
if type(name) ~= "string" then
name = player:get_player_name()
else
player = minetest.get_player_by_name(name)
end
end
if not fire_plus.burning[name] then return end
if player then
player:hud_remove(fire_plus.burning[name].hud_id)
minetest.sound_fade(fire_plus.burning[name].sound_id, 1, 0)
end
minetest.delete_particlespawner(fire_plus.burning[name].particlespawner_id)
minetest.delete_particlespawner(fire_plus.burning[name].particlespawner_id2)
fire_plus.burning[name] = nil
end

View File

@ -0,0 +1,4 @@
default?
fire
tnt?
3d_armor?

View File

@ -0,0 +1,113 @@
fire_plus = {
burn_interval = 1,
tnt_explode_radius = 1.5,
burning = {--[[
["playername"] = {
burns_left = <number>,
hud_id = <hud id>,
sound_id = <sound id>,
particlespawner_id = <particlespawner id>
}
]]},
ignition_nodes = {
--["nodename"] = {burns = <table with min/max or number>, damage = <table with min/max or number>}
["default:lava"] = {burns = 2, damage = 4},
["fire:"] = {burns = 4, damage = 2},
},
extinguishers = {
"default:water",
"default:river_water",
"default:snow"
}
}
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/api.lua")
local time = 0
local img_num = 1
local img_num_max = 8
minetest.register_globalstep(function(dtime)
time = time + dtime
if time < 0.1 then
return
else
time = 0
end
-- Put out players in extinguisher nodes
for _, player in pairs(minetest.get_connected_players()) do
local name = player:get_player_name()
if fire_plus.burning[name] then
-- change HUD to next image to simulate animation
--local img_name = "fire_basic_flame_"..img_num..".png"
img_name = "fire_basic_flame_animated.png".."^[verticalframe:"..img_num_max..":"..img_num
--minetest.log(dump(img_name))
player:hud_remove(fire_plus.burning[name].hud_id)
fire_plus.burning[name].hud_id = player:hud_add({
hud_elem_type = "image",
position = {x = 0.5, y = 0.95},
offset = {x = 0, y = 0},
text = img_name,
alignment = -1,
scale = {x = 100, y = 32},
number = 0xFFFFFF,
})
if img_num >= img_num_max then
img_num = 1
else
img_num = img_num + 1
end
local nodename = minetest.get_node(player:get_pos()).name
local nodename_head = minetest.get_node(vector.add(player:get_pos(),
vector.new(0, 1, 0))).name
for _, extinguisher in pairs(fire_plus.extinguishers) do
if nodename:find(extinguisher) or nodename_head:find(extinguisher) then
minetest.sound_play("fire_extinguish_flame", {
to_player = name,
gain = 1.0,
})
fire_plus.extinguish_player(name)
return
end
end
end
end
end)
-- Ignite players in ignition nodes
minetest.register_on_player_hpchange(function(player, _, reason)
if reason.type == "node_damage" and reason.node then
for igniter, def in pairs(fire_plus.ignition_nodes) do
if reason.node:find(igniter) then
fire_plus.burn_player(player, def.burns or 4, def.damage or 2)
break
end
end
end
end)
minetest.register_on_punchplayer(function(player, hitter, _, toolcaps, _, dmg)
if hitter and hitter:is_player() and toolcaps.damage_groups.burns and player and player:get_hp() - dmg > 0 then
fire_plus.burn_player(player, toolcaps.damage_groups.burn_time or 4, toolcaps.damage_groups.burns)
end
return false
end)
minetest.register_on_respawnplayer(function(player)
local name = player:get_player_name()
if fire_plus.burning[name] then
fire_plus.extinguish_player(name)
end
end)

View File

@ -0,0 +1,3 @@
name = fire_plus
depends = fire
optional_depends = default, tnt, 3d_armor

Binary file not shown.

After

Width:  |  Height:  |  Size: 721 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 997 KiB

View File

@ -3,6 +3,7 @@ Player related mods
3d_armor - Armor for Players with Model
emote - enables model to sit, ...
fire_plus - player can get on fire
hbsprint - enable sprinting
hunger_ng - enables eating and extends hunger
character_anim - Model animations: head rotate, ...