Organize mods into modpacks for better overview
97
mods/PLAYER/hbhunger/README.md
Normal file
|
@ -0,0 +1,97 @@
|
|||
# Hunger with HUD bar [`hbhunger`]
|
||||
|
||||
* Version: 0.5.2
|
||||
|
||||
## Using the mod
|
||||
|
||||
This mod adds a mechanic for hunger.
|
||||
This mod depends on the HUD bars mod [`hudbars`], version 1.4.1 or any later version
|
||||
starting with “1.”.
|
||||
|
||||
## About hunger
|
||||
This mod adds a hunger mechanic to the game. Players get a new attribute called “satiation”:
|
||||
|
||||
* A new player starts with 20 satiation points out of 30
|
||||
* Actions like digging, placing and walking cause exhaustion, which lower the satiation
|
||||
* Every 800 seconds you lose 1 satiation point without doing anything
|
||||
* At 1 or 0 satiation you will suffer damage and die in case you don't eat something
|
||||
* If your satiation is 16 or higher, you will slowly regenerate health points
|
||||
* Eating food will increase your satiation (Duh!)
|
||||
|
||||
Important: Eating food will not directly increase your health anymore, as long as the food
|
||||
item is supported by this mod (see below).
|
||||
|
||||
Careful! Some foods may be poisoned. If you eat a poisoned item, you may still get a satiation
|
||||
boost, but for a brief period you lose health points because of food poisoning. However,
|
||||
food poisoning can never kill you.
|
||||
|
||||
## Statbar mode
|
||||
If you use the statbar mode of the HUD Bars mod, these things are important to know:
|
||||
As with all mods using HUD Bars, the bread statbar symbols represent the rough percentage
|
||||
out of 30 satiation points, in steps of 5%, so the symbols give you an estimate of your
|
||||
satiation. This is different from the hunger mod by BlockMen.
|
||||
|
||||
You gain health at 5.5 symbols or more, as 5.5 symbols correspond to 16 satiation points.
|
||||
You *may* lose health at exactly 0.5 symbols, as 0.5 symbols correspond to 1-2 satiation points.
|
||||
|
||||
## Supported food
|
||||
All mods which add food through standard measures (`minetest.item_eat`) are already
|
||||
supported automatically. Poisoned food needs special support.
|
||||
|
||||
### Known supported food mods
|
||||
* Apple from Minetest Game [`default`]
|
||||
* Red and brown mushroom from Minetest Game [`flowers`]
|
||||
* Bread from Minetest Game [`farming`]
|
||||
* [`animalmaterials`] (Mob Framework (`mobf` modpack))
|
||||
* Bushes [`bushes`]
|
||||
* [`bushes_classic`]
|
||||
* Creatures [`creatures`]
|
||||
* [`dwarves`] (beer and such)
|
||||
* Docfarming [`docfarming`]
|
||||
* Ethereal / Ethereal NG [`ethereal`]
|
||||
* Farming Redo [`farming`] by TenPlus1
|
||||
* Farming plus [`farming_plus`]
|
||||
* Ferns [`ferns`]
|
||||
* Fishing [`fishing`]
|
||||
* [`fruit`]
|
||||
* Glooptest [`glooptest`]
|
||||
* JKMod ([`jkanimals`], [`jkfarming`], [`jkwine`])
|
||||
* [`kpgmobs`]
|
||||
* [`mobfcooking`]
|
||||
* [`mooretrees`]
|
||||
* [`mtfoods`]
|
||||
* [`mushroom`]
|
||||
* [`mush45`]
|
||||
* Seaplants [`sea`]
|
||||
* Simple mobs [`mobs`]
|
||||
* Pizza [`pizza`]
|
||||
* Not So Simple Mobs [`nssm`]
|
||||
|
||||
### Supported mods without optional dependency (mods provide their own support)
|
||||
|
||||
* Food ([`food`], [`food_basic`])
|
||||
* Sweet Foods [`food_sweet`]
|
||||
|
||||
### Examples
|
||||
|
||||
* Eating an apple (from Minetest Game) increases your satiation by 2;
|
||||
* eating a bread (from Minetest Game) increases your satiation by 4.
|
||||
|
||||
## Licensing
|
||||
This mod is free software.
|
||||
|
||||
### Source code
|
||||
|
||||
* License: [LGPL v2.1](https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html)
|
||||
* Author: by Wuzzy (2015-2016)
|
||||
* Forked from the “Better HUD (and hunger)” mod by BlockMen (2013-2015),
|
||||
most code comes from this mod.
|
||||
|
||||
### Textures
|
||||
|
||||
* `hbhunger_icon.png`—PilzAdam ([WTFPL](http://www.wtfpl.net/txt/copying/)), modified by BlockMen
|
||||
* `hbhunger_bgicon.png`—PilzAdam (WTFPL), modified by BlockMen
|
||||
* `hbhunger_bar.png—Wuzzy` (WTFPL)
|
||||
* `hbhunger_icon_health_poison.png`—celeron55 ([CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/)), modified by BlockMen, modified again by Wuzzy
|
||||
* Everything else: WTFPL, by BlockMen and Wuzzy
|
||||
|
51
mods/PLAYER/hbhunger/changelog.txt
Normal file
|
@ -0,0 +1,51 @@
|
|||
0.1.0
|
||||
-----
|
||||
Initial release
|
||||
|
||||
0.2.0
|
||||
-----
|
||||
- Change “saturation” to “satiation”
|
||||
- Rename global table to “hbhunger” to avoid collisions
|
||||
- General cleanup
|
||||
|
||||
0.3.0
|
||||
-----
|
||||
- Play simple eating sound when something is eaten
|
||||
|
||||
0.3.1
|
||||
-----
|
||||
- Add Ethereal orange
|
||||
- Fix exhaus variable
|
||||
|
||||
0.3.2
|
||||
-----
|
||||
- Fix another crash
|
||||
|
||||
0.4.0
|
||||
-----
|
||||
- Generic eating functionality, items using the minetest.item_eat are automatically supported
|
||||
- Change health bar and icon when poisoned
|
||||
- Special support for red and brown mushroom from Minetest Game [flowers]
|
||||
- Special support for [pizza]
|
||||
- Special support for beans from Farming Redo [farming]
|
||||
- Fix crash when poisoned player leaves server
|
||||
- Changed license to LGPL v2.1
|
||||
|
||||
0.4.1
|
||||
-----
|
||||
- Add foods from Not So Simple Mobs [nssm]
|
||||
|
||||
0.5.0
|
||||
-----
|
||||
- Fix custom sound not working
|
||||
- Add Portuguese translation
|
||||
|
||||
0.5.1
|
||||
-----
|
||||
- Fix incompability problem with pipeworks mod
|
||||
|
||||
0.5.2
|
||||
-----
|
||||
- Fix mod not working with both intllib and mod security enabled
|
||||
- Add missing screenshot
|
||||
- Rewrite README and use Markdown format
|
32
mods/PLAYER/hbhunger/depends.txt
Normal file
|
@ -0,0 +1,32 @@
|
|||
hudbars
|
||||
intllib?
|
||||
mlc_core?
|
||||
flowers?
|
||||
animalmaterials?
|
||||
bucket?
|
||||
bushes?
|
||||
bushes_classic?
|
||||
cooking?
|
||||
creatures?
|
||||
docfarming?
|
||||
dwarves?
|
||||
ethereal?
|
||||
farming?
|
||||
farming_plus?
|
||||
ferns?
|
||||
fishing?
|
||||
fruit?
|
||||
glooptest?
|
||||
jkanimals?
|
||||
jkfarming?
|
||||
jkwine?
|
||||
kpgmobs?
|
||||
mobfcooking?
|
||||
mobs?
|
||||
moretrees?
|
||||
mtfoods?
|
||||
mush45?
|
||||
mushroom?
|
||||
seaplants?
|
||||
pizza?
|
||||
nssm?
|
1
mods/PLAYER/hbhunger/description.txt
Normal file
|
@ -0,0 +1 @@
|
|||
Adds a simple hunger meachanic with satiation, food poisoning and different healing.
|
470
mods/PLAYER/hbhunger/hunger.lua
Normal file
|
@ -0,0 +1,470 @@
|
|||
-- Keep these for backwards compatibility
|
||||
function hbhunger.save_hunger(player)
|
||||
hbhunger.set_hunger_raw(player)
|
||||
end
|
||||
function hbhunger.load_hunger(player)
|
||||
hbhunger.get_hunger_raw(player)
|
||||
end
|
||||
|
||||
-- wrapper for minetest.item_eat (this way we make sure other mods can't break this one)
|
||||
local org_eat = core.do_item_eat
|
||||
core.do_item_eat = function(hp_change, replace_with_item, itemstack, user, pointed_thing)
|
||||
local old_itemstack = itemstack
|
||||
itemstack = hbhunger.eat(hp_change, replace_with_item, itemstack, user, pointed_thing)
|
||||
for _, callback in pairs(core.registered_on_item_eats) do
|
||||
local result = callback(hp_change, replace_with_item, itemstack, user, pointed_thing, old_itemstack)
|
||||
if result then
|
||||
return result
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
|
||||
-- food functions
|
||||
local food = hbhunger.food
|
||||
|
||||
function hbhunger.register_food(name, hunger_change, replace_with_item, poisen, heal, sound)
|
||||
food[name] = {}
|
||||
food[name].saturation = hunger_change -- hunger points added
|
||||
food[name].replace = replace_with_item -- what item is given back after eating
|
||||
food[name].poisen = poisen -- time its poisening
|
||||
food[name].healing = heal -- amount of HP
|
||||
food[name].sound = sound -- special sound that is played when eating
|
||||
end
|
||||
|
||||
function hbhunger.eat(hp_change, replace_with_item, itemstack, user, pointed_thing)
|
||||
local item = itemstack:get_name()
|
||||
local def = food[item]
|
||||
if not def then
|
||||
def = {}
|
||||
if type(hp_change) ~= "number" then
|
||||
hp_change = 1
|
||||
core.log("error", "Wrong on_use() definition for item '" .. item .. "'")
|
||||
end
|
||||
def.saturation = hp_change
|
||||
def.replace = replace_with_item
|
||||
end
|
||||
local func = hbhunger.item_eat(def.saturation, def.replace, def.poisen, def.healing, def.sound)
|
||||
return func(itemstack, user, pointed_thing)
|
||||
end
|
||||
|
||||
-- Poison player
|
||||
local function poisenp(tick, time, time_left, player)
|
||||
-- First check if player is still there
|
||||
if not player:is_player() then
|
||||
return
|
||||
end
|
||||
time_left = time_left + tick
|
||||
if time_left < time then
|
||||
minetest.after(tick, poisenp, tick, time, time_left, player)
|
||||
else
|
||||
hbhunger.poisonings[player:get_player_name()] = hbhunger.poisonings[player:get_player_name()] - 1
|
||||
if hbhunger.poisonings[player:get_player_name()] <= 0 then
|
||||
-- Reset HUD bar color
|
||||
hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png")
|
||||
end
|
||||
end
|
||||
if player:get_hp()-1 > 0 then
|
||||
player:set_hp(player:get_hp()-1)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function hbhunger.item_eat(hunger_change, replace_with_item, poisen, heal, sound)
|
||||
return function(itemstack, user, pointed_thing)
|
||||
if itemstack:take_item() ~= nil and user ~= nil then
|
||||
local name = user:get_player_name()
|
||||
local h = tonumber(hbhunger.hunger[name])
|
||||
local hp = user:get_hp()
|
||||
minetest.sound_play({name = sound or "hbhunger_eat_generic", gain = 1}, {pos=user:getpos(), max_hear_distance = 16})
|
||||
|
||||
-- Saturation
|
||||
if h < 20 and hunger_change then
|
||||
h = h + hunger_change
|
||||
if h > 20 then h = 20 end
|
||||
hbhunger.hunger[name] = h
|
||||
hbhunger.set_hunger_raw(user)
|
||||
end
|
||||
-- Healing
|
||||
if hp < 20 and heal then
|
||||
hp = hp + heal
|
||||
if hp > 20 then hp = 20 end
|
||||
user:set_hp(hp)
|
||||
end
|
||||
-- Poison
|
||||
if poisen then
|
||||
-- Set poison bar
|
||||
hb.change_hudbar(user, "health", nil, nil, "hbhunger_icon_health_poison.png", nil, "hbhunger_bar_health_poison.png")
|
||||
hbhunger.poisonings[name] = hbhunger.poisonings[name] + 1
|
||||
poisenp(1, poisen, 0, user)
|
||||
end
|
||||
|
||||
--sound:eat
|
||||
itemstack:add_item(replace_with_item)
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.get_modpath("default") ~= nil then
|
||||
hbhunger.register_food("default:apple", 2)
|
||||
end
|
||||
if minetest.get_modpath("flowers") ~= nil then
|
||||
hbhunger.register_food("flowers:mushroom_brown", 1)
|
||||
hbhunger.register_food("flowers:mushroom_red", 1, "", 3)
|
||||
end
|
||||
if minetest.get_modpath("farming") ~= nil then
|
||||
hbhunger.register_food("farming:bread", 4)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("mobs") ~= nil then
|
||||
if mobs.mod ~= nil and mobs.mod == "redo" then
|
||||
hbhunger.register_food("mobs:cheese", 4)
|
||||
hbhunger.register_food("mobs:meat", 8)
|
||||
hbhunger.register_food("mobs:meat_raw", 4)
|
||||
hbhunger.register_food("mobs:rat_cooked", 4)
|
||||
hbhunger.register_food("mobs:honey", 2)
|
||||
hbhunger.register_food("mobs:pork_raw", 3, "", 3)
|
||||
hbhunger.register_food("mobs:pork_cooked", 8)
|
||||
hbhunger.register_food("mobs:chicken_cooked", 6)
|
||||
hbhunger.register_food("mobs:chicken_raw", 2, "", 3)
|
||||
hbhunger.register_food("mobs:chicken_egg_fried", 2)
|
||||
if minetest.get_modpath("bucket") then
|
||||
hbhunger.register_food("mobs:bucket_milk", 3, "bucket:bucket_empty")
|
||||
end
|
||||
else
|
||||
hbhunger.register_food("mobs:meat", 6)
|
||||
hbhunger.register_food("mobs:meat_raw", 3)
|
||||
hbhunger.register_food("mobs:rat_cooked", 5)
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.get_modpath("moretrees") ~= nil then
|
||||
hbhunger.register_food("moretrees:coconut_milk", 1)
|
||||
hbhunger.register_food("moretrees:raw_coconut", 2)
|
||||
hbhunger.register_food("moretrees:acorn_muffin", 3)
|
||||
hbhunger.register_food("moretrees:spruce_nuts", 1)
|
||||
hbhunger.register_food("moretrees:pine_nuts", 1)
|
||||
hbhunger.register_food("moretrees:fir_nuts", 1)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("dwarves") ~= nil then
|
||||
hbhunger.register_food("dwarves:beer", 2)
|
||||
hbhunger.register_food("dwarves:apple_cider", 1)
|
||||
hbhunger.register_food("dwarves:midus", 2)
|
||||
hbhunger.register_food("dwarves:tequila", 2)
|
||||
hbhunger.register_food("dwarves:tequila_with_lime", 2)
|
||||
hbhunger.register_food("dwarves:sake", 2)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("animalmaterials") ~= nil then
|
||||
hbhunger.register_food("animalmaterials:milk", 2)
|
||||
hbhunger.register_food("animalmaterials:meat_raw", 3)
|
||||
hbhunger.register_food("animalmaterials:meat_pork", 3)
|
||||
hbhunger.register_food("animalmaterials:meat_beef", 3)
|
||||
hbhunger.register_food("animalmaterials:meat_chicken", 3)
|
||||
hbhunger.register_food("animalmaterials:meat_lamb", 3)
|
||||
hbhunger.register_food("animalmaterials:meat_venison", 3)
|
||||
hbhunger.register_food("animalmaterials:meat_undead", 3, "", 3)
|
||||
hbhunger.register_food("animalmaterials:meat_toxic", 3, "", 5)
|
||||
hbhunger.register_food("animalmaterials:meat_ostrich", 3)
|
||||
hbhunger.register_food("animalmaterials:fish_bluewhite", 2)
|
||||
hbhunger.register_food("animalmaterials:fish_clownfish", 2)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("fishing") ~= nil then
|
||||
hbhunger.register_food("fishing:fish_raw", 2)
|
||||
hbhunger.register_food("fishing:fish_cooked", 5)
|
||||
hbhunger.register_food("fishing:sushi", 6)
|
||||
hbhunger.register_food("fishing:shark", 4)
|
||||
hbhunger.register_food("fishing:shark_cooked", 8)
|
||||
hbhunger.register_food("fishing:pike", 4)
|
||||
hbhunger.register_food("fishing:pike_cooked", 8)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("glooptest") ~= nil then
|
||||
hbhunger.register_food("glooptest:kalite_lump", 1)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("bushes") ~= nil then
|
||||
hbhunger.register_food("bushes:sugar", 1)
|
||||
hbhunger.register_food("bushes:strawberry", 2)
|
||||
hbhunger.register_food("bushes:berry_pie_raw", 3)
|
||||
hbhunger.register_food("bushes:berry_pie_cooked", 4)
|
||||
hbhunger.register_food("bushes:basket_pies", 15)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("bushes_classic") then
|
||||
-- bushes_classic mod, as found in the plantlife modpack
|
||||
local berries = {
|
||||
"strawberry",
|
||||
"blackberry",
|
||||
"blueberry",
|
||||
"raspberry",
|
||||
"gooseberry",
|
||||
"mixed_berry"}
|
||||
for _, berry in ipairs(berries) do
|
||||
if berry ~= "mixed_berry" then
|
||||
hbhunger.register_food("bushes:"..berry, 1)
|
||||
end
|
||||
hbhunger.register_food("bushes:"..berry.."_pie_raw", 2)
|
||||
hbhunger.register_food("bushes:"..berry.."_pie_cooked", 5)
|
||||
hbhunger.register_food("bushes:basket_"..berry, 15)
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.get_modpath("mushroom") ~= nil then
|
||||
hbhunger.register_food("mushroom:brown", 1)
|
||||
hbhunger.register_food("mushroom:red", 1, "", 3)
|
||||
-- mushroom potions: red = strong poison, brown = light restorative
|
||||
if minetest.get_modpath("vessels") then
|
||||
hbhunger.register_food("mushroom:brown_essence", 1, "vessels:glass_bottle", nil, 4)
|
||||
hbhunger.register_food("mushroom:poison", 1, "vessels:glass_bottle", 10)
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.get_modpath("docfarming") ~= nil then
|
||||
hbhunger.register_food("docfarming:carrot", 3)
|
||||
hbhunger.register_food("docfarming:cucumber", 2)
|
||||
hbhunger.register_food("docfarming:corn", 3)
|
||||
hbhunger.register_food("docfarming:potato", 4)
|
||||
hbhunger.register_food("docfarming:bakedpotato", 5)
|
||||
hbhunger.register_food("docfarming:raspberry", 3)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("farming_plus") ~= nil then
|
||||
hbhunger.register_food("farming_plus:carrot_item", 3)
|
||||
hbhunger.register_food("farming_plus:banana", 2)
|
||||
hbhunger.register_food("farming_plus:orange_item", 2)
|
||||
hbhunger.register_food("farming:pumpkin_bread", 4)
|
||||
hbhunger.register_food("farming_plus:strawberry_item", 2)
|
||||
hbhunger.register_food("farming_plus:tomato_item", 2)
|
||||
hbhunger.register_food("farming_plus:potato_item", 4)
|
||||
hbhunger.register_food("farming_plus:rhubarb_item", 2)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("mtfoods") ~= nil then
|
||||
hbhunger.register_food("mtfoods:dandelion_milk", 1)
|
||||
hbhunger.register_food("mtfoods:sugar", 1)
|
||||
hbhunger.register_food("mtfoods:short_bread", 4)
|
||||
hbhunger.register_food("mtfoods:cream", 1)
|
||||
hbhunger.register_food("mtfoods:chocolate", 2)
|
||||
hbhunger.register_food("mtfoods:cupcake", 2)
|
||||
hbhunger.register_food("mtfoods:strawberry_shortcake", 2)
|
||||
hbhunger.register_food("mtfoods:cake", 3)
|
||||
hbhunger.register_food("mtfoods:chocolate_cake", 3)
|
||||
hbhunger.register_food("mtfoods:carrot_cake", 3)
|
||||
hbhunger.register_food("mtfoods:pie_crust", 3)
|
||||
hbhunger.register_food("mtfoods:apple_pie", 3)
|
||||
hbhunger.register_food("mtfoods:rhubarb_pie", 2)
|
||||
hbhunger.register_food("mtfoods:banana_pie", 3)
|
||||
hbhunger.register_food("mtfoods:pumpkin_pie", 3)
|
||||
hbhunger.register_food("mtfoods:cookies", 2)
|
||||
hbhunger.register_food("mtfoods:mlt_burger", 5)
|
||||
hbhunger.register_food("mtfoods:potato_slices", 2)
|
||||
hbhunger.register_food("mtfoods:potato_chips", 3)
|
||||
--mtfoods:medicine
|
||||
hbhunger.register_food("mtfoods:casserole", 3)
|
||||
hbhunger.register_food("mtfoods:glass_flute", 2)
|
||||
hbhunger.register_food("mtfoods:orange_juice", 2)
|
||||
hbhunger.register_food("mtfoods:apple_juice", 2)
|
||||
hbhunger.register_food("mtfoods:apple_cider", 2)
|
||||
hbhunger.register_food("mtfoods:cider_rack", 2)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("fruit") ~= nil then
|
||||
hbhunger.register_food("fruit:apple", 2)
|
||||
hbhunger.register_food("fruit:pear", 2)
|
||||
hbhunger.register_food("fruit:bananna", 3)
|
||||
hbhunger.register_food("fruit:orange", 2)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("mush45") ~= nil then
|
||||
hbhunger.register_food("mush45:meal", 4)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("seaplants") ~= nil then
|
||||
hbhunger.register_food("seaplants:kelpgreen", 1)
|
||||
hbhunger.register_food("seaplants:kelpbrown", 1)
|
||||
hbhunger.register_food("seaplants:seagrassgreen", 1)
|
||||
hbhunger.register_food("seaplants:seagrassred", 1)
|
||||
hbhunger.register_food("seaplants:seasaladmix", 6)
|
||||
hbhunger.register_food("seaplants:kelpgreensalad", 1)
|
||||
hbhunger.register_food("seaplants:kelpbrownsalad", 1)
|
||||
hbhunger.register_food("seaplants:seagrassgreensalad", 1)
|
||||
hbhunger.register_food("seaplants:seagrassgreensalad", 1)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("mobfcooking") ~= nil then
|
||||
hbhunger.register_food("mobfcooking:cooked_pork", 6)
|
||||
hbhunger.register_food("mobfcooking:cooked_ostrich", 6)
|
||||
hbhunger.register_food("mobfcooking:cooked_beef", 6)
|
||||
hbhunger.register_food("mobfcooking:cooked_chicken", 6)
|
||||
hbhunger.register_food("mobfcooking:cooked_lamb", 6)
|
||||
hbhunger.register_food("mobfcooking:cooked_venison", 6)
|
||||
hbhunger.register_food("mobfcooking:cooked_fish", 6)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("creatures") ~= nil then
|
||||
hbhunger.register_food("creatures:meat", 6)
|
||||
hbhunger.register_food("creatures:flesh", 3)
|
||||
hbhunger.register_food("creatures:rotten_flesh", 3, "", 3)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("ethereal") then
|
||||
hbhunger.register_food("ethereal:strawberry", 1)
|
||||
hbhunger.register_food("ethereal:banana", 4)
|
||||
hbhunger.register_food("ethereal:pine_nuts", 1)
|
||||
hbhunger.register_food("ethereal:bamboo_sprout", 0, "", 3)
|
||||
hbhunger.register_food("ethereal:fern_tubers", 1)
|
||||
hbhunger.register_food("ethereal:banana_bread", 7)
|
||||
hbhunger.register_food("ethereal:mushroom_plant", 2)
|
||||
hbhunger.register_food("ethereal:coconut_slice", 2)
|
||||
hbhunger.register_food("ethereal:golden_apple", 4, "", nil, 10)
|
||||
hbhunger.register_food("ethereal:wild_onion_plant", 2)
|
||||
hbhunger.register_food("ethereal:mushroom_soup", 4, "ethereal:bowl")
|
||||
hbhunger.register_food("ethereal:mushroom_soup_cooked", 6, "ethereal:bowl")
|
||||
hbhunger.register_food("ethereal:hearty_stew", 6, "ethereal:bowl", 3)
|
||||
hbhunger.register_food("ethereal:hearty_stew_cooked", 10, "ethereal:bowl")
|
||||
if minetest.get_modpath("bucket") then
|
||||
hbhunger.register_food("ethereal:bucket_cactus", 2, "bucket:bucket_empty")
|
||||
end
|
||||
hbhunger.register_food("ethereal:fish_raw", 2)
|
||||
hbhunger.register_food("ethereal:fish_cooked", 5)
|
||||
hbhunger.register_food("ethereal:seaweed", 1)
|
||||
hbhunger.register_food("ethereal:yellowleaves", 1, "", nil, 1)
|
||||
hbhunger.register_food("ethereal:sashimi", 4)
|
||||
hbhunger.register_food("ethereal:orange", 2)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("farming") and farming.mod == "redo" then
|
||||
hbhunger.register_food("farming:bread", 6)
|
||||
hbhunger.register_food("farming:potato", 1)
|
||||
hbhunger.register_food("farming:baked_potato", 6)
|
||||
hbhunger.register_food("farming:cucumber", 4)
|
||||
hbhunger.register_food("farming:tomato", 4)
|
||||
hbhunger.register_food("farming:carrot", 3)
|
||||
hbhunger.register_food("farming:carrot_gold", 6, "", nil, 8)
|
||||
hbhunger.register_food("farming:corn", 3)
|
||||
hbhunger.register_food("farming:corn_cob", 5)
|
||||
hbhunger.register_food("farming:melon_slice", 2)
|
||||
hbhunger.register_food("farming:pumpkin_slice", 1)
|
||||
hbhunger.register_food("farming:pumpkin_bread", 9)
|
||||
hbhunger.register_food("farming:coffee_cup", 2, "farming:drinking_cup")
|
||||
hbhunger.register_food("farming:coffee_cup_hot", 3, "farming:drinking_cup", nil, 2)
|
||||
hbhunger.register_food("farming:cookie", 2)
|
||||
hbhunger.register_food("farming:chocolate_dark", 3)
|
||||
hbhunger.register_food("farming:donut", 4)
|
||||
hbhunger.register_food("farming:donut_chocolate", 6)
|
||||
hbhunger.register_food("farming:donut_apple", 6)
|
||||
hbhunger.register_food("farming:raspberries", 1)
|
||||
hbhunger.register_food("farming:blueberries", 1)
|
||||
hbhunger.register_food("farming:muffin_blueberry", 4)
|
||||
if minetest.get_modpath("vessels") then
|
||||
hbhunger.register_food("farming:smoothie_raspberry", 2, "vessels:drinking_glass")
|
||||
end
|
||||
hbhunger.register_food("farming:rhubarb", 1)
|
||||
hbhunger.register_food("farming:rhubarb_pie", 6)
|
||||
hbhunger.register_food("farming:beans", 1)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("kpgmobs") ~= nil then
|
||||
hbhunger.register_food("kpgmobs:uley", 3)
|
||||
hbhunger.register_food("kpgmobs:meat", 6)
|
||||
hbhunger.register_food("kpgmobs:rat_cooked", 5)
|
||||
hbhunger.register_food("kpgmobs:med_cooked", 4)
|
||||
if minetest.get_modpath("bucket") then
|
||||
hbhunger.register_food("kpgmobs:bucket_milk", 4, "bucket:bucket_empty")
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.get_modpath("jkfarming") ~= nil then
|
||||
hbhunger.register_food("jkfarming:carrot", 3)
|
||||
hbhunger.register_food("jkfarming:corn", 3)
|
||||
hbhunger.register_food("jkfarming:melon_part", 2)
|
||||
hbhunger.register_food("jkfarming:cake", 3)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("jkanimals") ~= nil then
|
||||
hbhunger.register_food("jkanimals:meat", 6)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("jkwine") ~= nil then
|
||||
hbhunger.register_food("jkwine:grapes", 2)
|
||||
hbhunger.register_food("jkwine:winebottle", 1)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("cooking") ~= nil then
|
||||
hbhunger.register_food("cooking:meat_beef_cooked", 4)
|
||||
hbhunger.register_food("cooking:fish_bluewhite_cooked", 3)
|
||||
hbhunger.register_food("cooking:fish_clownfish_cooked", 1)
|
||||
hbhunger.register_food("cooking:meat_chicken_cooked", 2)
|
||||
hbhunger.register_food("cooking:meat_cooked", 2)
|
||||
hbhunger.register_food("cooking:meat_pork_cooked", 3)
|
||||
hbhunger.register_food("cooking:meat_toxic_cooked", -3)
|
||||
hbhunger.register_food("cooking:meat_venison_cooked", 3)
|
||||
hbhunger.register_food("cooking:meat_undead_cooked", 1)
|
||||
end
|
||||
|
||||
-- ferns mod of plantlife_modpack
|
||||
if minetest.get_modpath("ferns") ~= nil then
|
||||
hbhunger.register_food("ferns:fiddlehead", 1, "", 1)
|
||||
hbhunger.register_food("ferns:fiddlehead_roasted", 3)
|
||||
hbhunger.register_food("ferns:ferntuber_roasted", 3)
|
||||
hbhunger.register_food("ferns:horsetail_01", 1)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("pizza") ~= nil then
|
||||
hbhunger.register_food("pizza:pizza", 30, "", nil, 30)
|
||||
hbhunger.register_food("pizza:pizzaslice", 5, "", nil, 5)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("nssm") then
|
||||
hbhunger.register_food("nssm:werewolf_leg", 3)
|
||||
hbhunger.register_food("nssm:heron_leg", 2)
|
||||
hbhunger.register_food("nssm:chichibios_heron_leg", 4)
|
||||
hbhunger.register_food("nssm:crocodile_tail", 3)
|
||||
hbhunger.register_food("nssm:duck_legs", 1)
|
||||
hbhunger.register_food("nssm:ant_leg", 1)
|
||||
hbhunger.register_food("nssm:spider_leg", 1)
|
||||
hbhunger.register_food("nssm:tentacle", 2)
|
||||
hbhunger.register_food("nssm:worm_flesh", 2, "", 2) -- poisonous
|
||||
hbhunger.register_food("nssm:amphibian_heart", 1)
|
||||
hbhunger.register_food("nssm:raw_scrausics_wing", 1)
|
||||
-- superfoods
|
||||
hbhunger.register_food("nssm:phoenix_nuggets", 20, "", nil, 20)
|
||||
hbhunger.register_food("nssm:phoenix_tear", 20, "", nil, 20)
|
||||
end
|
||||
|
||||
-- player-action based hunger changes
|
||||
function hbhunger.handle_node_actions(pos, oldnode, player, ext)
|
||||
-- is_fake_player comes from the pipeworks, we are not interested in those
|
||||
if not player or not player:is_player() or player.is_fake_player == true then
|
||||
return
|
||||
end
|
||||
local name = player:get_player_name()
|
||||
local exhaus = hbhunger.exhaustion[name]
|
||||
if exhaus == nil then return end
|
||||
local new = hbhunger.EXHAUST_PLACE
|
||||
-- placenode event
|
||||
if not ext then
|
||||
new = hbhunger.EXHAUST_DIG
|
||||
end
|
||||
-- assume its send by main timer when movement detected
|
||||
if not pos and not oldnode then
|
||||
new = hbhunger.EXHAUST_MOVE
|
||||
end
|
||||
exhaus = exhaus + new
|
||||
if exhaus > hbhunger.EXHAUST_LVL then
|
||||
exhaus = 0
|
||||
local h = tonumber(hbhunger.hunger[name])
|
||||
h = h - 1
|
||||
if h < 0 then h = 0 end
|
||||
hbhunger.hunger[name] = h
|
||||
hbhunger.set_hunger_raw(player)
|
||||
end
|
||||
hbhunger.exhaustion[name] = exhaus
|
||||
end
|
||||
|
||||
minetest.register_on_placenode(hbhunger.handle_node_actions)
|
||||
minetest.register_on_dignode(hbhunger.handle_node_actions)
|
169
mods/PLAYER/hbhunger/init.lua
Normal file
|
@ -0,0 +1,169 @@
|
|||
local S
|
||||
if (minetest.get_modpath("intllib")) then
|
||||
S = intllib.Getter()
|
||||
else
|
||||
S = function ( s ) return s end
|
||||
end
|
||||
|
||||
if minetest.setting_getbool("enable_damage") then
|
||||
|
||||
hbhunger = {}
|
||||
hbhunger.food = {}
|
||||
|
||||
-- HUD statbar values
|
||||
hbhunger.hunger = {}
|
||||
hbhunger.hunger_out = {}
|
||||
|
||||
-- Count number of poisonings a player has at once
|
||||
hbhunger.poisonings = {}
|
||||
|
||||
-- HUD item ids
|
||||
local hunger_hud = {}
|
||||
|
||||
hbhunger.HUD_TICK = 0.1
|
||||
|
||||
--Some hunger settings
|
||||
hbhunger.exhaustion = {} -- Exhaustion is experimental!
|
||||
|
||||
hbhunger.HUNGER_TICK = 800 -- time in seconds after that 1 hunger point is taken
|
||||
hbhunger.EXHAUST_DIG = 3 -- exhaustion increased this value after digged node
|
||||
hbhunger.EXHAUST_PLACE = 1 -- exhaustion increased this value after placed
|
||||
hbhunger.EXHAUST_MOVE = 0.3 -- exhaustion increased this value if player movement detected
|
||||
hbhunger.EXHAUST_LVL = 160 -- at what exhaustion player satiation gets lowerd
|
||||
|
||||
|
||||
--load custom settings
|
||||
local set = io.open(minetest.get_modpath("hbhunger").."/hbhunger.conf", "r")
|
||||
if set then
|
||||
dofile(minetest.get_modpath("hbhunger").."/hbhunger.conf")
|
||||
set:close()
|
||||
end
|
||||
|
||||
local function custom_hud(player)
|
||||
hb.init_hudbar(player, "satiation", hbhunger.get_hunger_raw(player))
|
||||
end
|
||||
|
||||
dofile(minetest.get_modpath("hbhunger").."/hunger.lua")
|
||||
|
||||
-- register satiation hudbar
|
||||
hb.register_hudbar("satiation", 0xFFFFFF, S("Satiation"), { icon = "hbhunger_icon.png", bgicon = "hbhunger_bgicon.png", bar = "hbhunger_bar.png" }, 20, 20, false)
|
||||
|
||||
-- update hud elemtens if value has changed
|
||||
local function update_hud(player)
|
||||
local name = player:get_player_name()
|
||||
--hunger
|
||||
local h_out = tonumber(hbhunger.hunger_out[name])
|
||||
local h = tonumber(hbhunger.hunger[name])
|
||||
if h_out ~= h then
|
||||
hbhunger.hunger_out[name] = h
|
||||
hb.change_hudbar(player, "satiation", h)
|
||||
end
|
||||
end
|
||||
|
||||
hbhunger.get_hunger_raw = function(player)
|
||||
local inv = player:get_inventory()
|
||||
if not inv then return nil end
|
||||
local hgp = inv:get_stack("hunger", 1):get_count()
|
||||
if hgp == 0 then
|
||||
hgp = 21
|
||||
inv:set_stack("hunger", 1, ItemStack({name=":", count=hgp}))
|
||||
else
|
||||
hgp = hgp
|
||||
end
|
||||
return hgp-1
|
||||
end
|
||||
|
||||
hbhunger.set_hunger_raw = function(player)
|
||||
local inv = player:get_inventory()
|
||||
local name = player:get_player_name()
|
||||
local value = hbhunger.hunger[name]
|
||||
if not inv or not value then return nil end
|
||||
if value > 20 then value = 20 end
|
||||
if value < 0 then value = 0 end
|
||||
|
||||
inv:set_stack("hunger", 1, ItemStack({name=":", count=value+1}))
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
local inv = player:get_inventory()
|
||||
inv:set_size("hunger",1)
|
||||
hbhunger.hunger[name] = hbhunger.get_hunger_raw(player)
|
||||
hbhunger.hunger_out[name] = hbhunger.hunger[name]
|
||||
hbhunger.exhaustion[name] = 0
|
||||
hbhunger.poisonings[name] = 0
|
||||
custom_hud(player)
|
||||
hbhunger.set_hunger_raw(player)
|
||||
end)
|
||||
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
-- reset hunger (and save)
|
||||
local name = player:get_player_name()
|
||||
hbhunger.hunger[name] = 20
|
||||
hbhunger.set_hunger_raw(player)
|
||||
hbhunger.exhaustion[name] = 0
|
||||
end)
|
||||
|
||||
local main_timer = 0
|
||||
local timer = 0 -- Half second timer
|
||||
local timer2 = 0
|
||||
local timerMult = 1 -- Cycles from 0 to 7, each time when timer hits half a second
|
||||
minetest.register_globalstep(function(dtime)
|
||||
main_timer = main_timer + dtime
|
||||
timer = timer + dtime
|
||||
timer2 = timer2 + dtime
|
||||
if main_timer > hbhunger.HUD_TICK or timer > 0.5 or timer2 > hbhunger.HUNGER_TICK then
|
||||
if main_timer > hbhunger.HUD_TICK then main_timer = 0 end
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
local name = player:get_player_name()
|
||||
|
||||
local h = tonumber(hbhunger.hunger[name])
|
||||
local hp = player:get_hp()
|
||||
if timer > 0.5 then
|
||||
-- Quick heal (every 0.5s)
|
||||
if h >= 20 and hp > 0 then
|
||||
player:set_hp(hp+1)
|
||||
-- Slow heal, and hunger damage (every 4s)
|
||||
elseif timerMult == 0 then
|
||||
if h >= 18 and hp > 0 then
|
||||
player:set_hp(hp+1)
|
||||
elseif h == 0 then
|
||||
-- Damage hungry player down to 1 HP
|
||||
if hp-1 >= 0 then
|
||||
player:set_hp(hp-1)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- lower satiation by 1 point after xx seconds
|
||||
if timer2 > hbhunger.HUNGER_TICK then
|
||||
if h > 0 then
|
||||
h = h-1
|
||||
hbhunger.hunger[name] = h
|
||||
hbhunger.set_hunger_raw(player)
|
||||
end
|
||||
end
|
||||
|
||||
-- update all hud elements
|
||||
update_hud(player)
|
||||
|
||||
local controls = player:get_player_control()
|
||||
-- Determine if the player is walking
|
||||
if controls.up or controls.down or controls.left or controls.right then
|
||||
hbhunger.handle_node_actions(nil, nil, player)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if timer > 0.5 then
|
||||
timer = 0
|
||||
timerMult = timerMult + 1
|
||||
if timerMult > 7 then
|
||||
timerMult = 0
|
||||
end
|
||||
end
|
||||
if timer2 > hbhunger.HUNGER_TICK then timer2 = 0 end
|
||||
end)
|
||||
|
||||
end
|
1
mods/PLAYER/hbhunger/locale/de.txt
Normal file
|
@ -0,0 +1 @@
|
|||
Satiation = Sättigung
|
1
mods/PLAYER/hbhunger/locale/pt.txt
Normal file
|
@ -0,0 +1 @@
|
|||
Satiation = Saciedade
|
1
mods/PLAYER/hbhunger/locale/template.txt
Normal file
|
@ -0,0 +1 @@
|
|||
Satiation
|
1
mods/PLAYER/hbhunger/mod.conf
Normal file
|
@ -0,0 +1 @@
|
|||
name = hbhunger
|
BIN
mods/PLAYER/hbhunger/screenshot.png
Normal file
After Width: | Height: | Size: 8.3 KiB |
BIN
mods/PLAYER/hbhunger/sounds/hbhunger_eat_generic.ogg
Normal file
BIN
mods/PLAYER/hbhunger/textures/hbhunger_bar.png
Normal file
After Width: | Height: | Size: 80 B |
BIN
mods/PLAYER/hbhunger/textures/hbhunger_bar_health_poison.png
Normal file
After Width: | Height: | Size: 151 B |
BIN
mods/PLAYER/hbhunger/textures/hbhunger_bgicon.png
Normal file
After Width: | Height: | Size: 267 B |
BIN
mods/PLAYER/hbhunger/textures/hbhunger_icon.png
Normal file
After Width: | Height: | Size: 409 B |
BIN
mods/PLAYER/hbhunger/textures/hbhunger_icon_health_poison.png
Normal file
After Width: | Height: | Size: 526 B |
1
mods/PLAYER/mcl_death/description.txt
Normal file
|
@ -0,0 +1 @@
|
|||
Makes all items in inventory drop after player death.
|
17
mods/PLAYER/mcl_death/init.lua
Normal file
|
@ -0,0 +1,17 @@
|
|||
--if minetest.setting_get("keepInventory") == false then
|
||||
minetest.register_on_dieplayer(function(player)
|
||||
local inv = player:get_inventory()
|
||||
local pos = player:getpos()
|
||||
for i,stack in ipairs(inv:get_list("main")) do
|
||||
local x = math.random(0, 9)/3
|
||||
local z = math.random(0, 9)/3
|
||||
pos.x = pos.x + x
|
||||
pos.z = pos.z + z
|
||||
minetest.add_item(pos, stack)
|
||||
stack:clear()
|
||||
inv:set_stack("main", i, stack)
|
||||
pos.x = pos.x - x
|
||||
pos.z = pos.z - z
|
||||
end
|
||||
end)
|
||||
--end
|
1
mods/PLAYER/mcl_death/mod.conf
Normal file
|
@ -0,0 +1 @@
|
|||
name = mcl_death
|
20
mods/PLAYER/mcl_player/README.txt
Normal file
|
@ -0,0 +1,20 @@
|
|||
MineClone 2 mod: mcl_player
|
||||
==========================
|
||||
|
||||
License of source code:
|
||||
-----------------------
|
||||
Copyright (C) 2011-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
|
||||
Authors of media files
|
||||
-----------------------
|
||||
MirceaKitsune (WTFPL):
|
||||
character.x
|
||||
|
||||
Textures from Faithful 1.11 resource pack (see main readme file)
|
207
mods/PLAYER/mcl_player/init.lua
Normal file
|
@ -0,0 +1,207 @@
|
|||
-- MineClone 2 mod: mcl_player
|
||||
-- See README.txt for licensing and other information.
|
||||
|
||||
--[[
|
||||
|
||||
API
|
||||
---
|
||||
|
||||
mcl_player.player_register_model(name, def)
|
||||
^ Register a new model to be used by players.
|
||||
^ <name> is the model filename such as "character.x", "foo.b3d", etc.
|
||||
^ See Model Definition below for format of <def>.
|
||||
|
||||
mcl_player.registered_player_models[name]
|
||||
^ See Model Definition below for format.
|
||||
|
||||
mcl_player.player_set_model(player, model_name)
|
||||
^ <player> is a PlayerRef.
|
||||
^ <model_name> is a model registered with player_register_model.
|
||||
|
||||
mcl_player.player_set_animation(player, anim_name [, speed])
|
||||
^ <player> is a PlayerRef.
|
||||
^ <anim_name> is the name of the animation.
|
||||
^ <speed> is in frames per second. If nil, default from the model is used
|
||||
|
||||
mcl_player.player_set_textures(player, textures)
|
||||
^ <player> is a PlayerRef.
|
||||
^ <textures> is an array of textures
|
||||
^ If <textures> is nil, the default textures from the model def are used
|
||||
|
||||
mcl_player.player_get_animation(player)
|
||||
^ <player> is a PlayerRef.
|
||||
^ Returns a table containing fields "model", "textures" and "animation".
|
||||
^ Any of the fields of the returned table may be nil.
|
||||
|
||||
Model Definition
|
||||
----------------
|
||||
|
||||
model_def = {
|
||||
animation_speed = 30, -- Default animation speed, in FPS.
|
||||
textures = {"character.png", }, -- Default array of textures.
|
||||
visual_size = {x=1, y=1,}, -- Used to scale the model.
|
||||
animations = {
|
||||
-- <anim_name> = { x=<start_frame>, y=<end_frame>, },
|
||||
foo = { x= 0, y=19, },
|
||||
bar = { x=20, y=39, },
|
||||
-- ...
|
||||
},
|
||||
}
|
||||
|
||||
]]
|
||||
|
||||
mcl_player = {}
|
||||
|
||||
-- Player animation blending
|
||||
-- Note: This is currently broken due to a bug in Irrlicht, leave at 0
|
||||
local animation_blend = 0
|
||||
|
||||
mcl_player.registered_player_models = { }
|
||||
|
||||
-- Local for speed.
|
||||
local models = mcl_player.registered_player_models
|
||||
|
||||
function mcl_player.player_register_model(name, def)
|
||||
models[name] = def
|
||||
end
|
||||
|
||||
-- Default player appearance
|
||||
mcl_player.player_register_model("character.x", {
|
||||
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, },
|
||||
},
|
||||
})
|
||||
|
||||
-- Player stats and animations
|
||||
local player_model = {}
|
||||
local player_textures = {}
|
||||
local player_anim = {}
|
||||
local player_sneak = {}
|
||||
mcl_player.player_attached = {}
|
||||
|
||||
function mcl_player.player_get_animation(player)
|
||||
local name = player:get_player_name()
|
||||
return {
|
||||
model = player_model[name],
|
||||
textures = player_textures[name],
|
||||
animation = player_anim[name],
|
||||
}
|
||||
end
|
||||
|
||||
-- Called when a player's appearance needs to be updated
|
||||
function mcl_player.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
|
||||
player:set_properties({
|
||||
mesh = model_name,
|
||||
textures = player_textures[name] or model.textures,
|
||||
visual = "mesh",
|
||||
visual_size = model.visual_size or {x=1, y=1},
|
||||
})
|
||||
mcl_player.player_set_animation(player, "stand")
|
||||
else
|
||||
player:set_properties({
|
||||
textures = { "player.png", "player_back.png", },
|
||||
visual = "upright_sprite",
|
||||
})
|
||||
end
|
||||
player_model[name] = model_name
|
||||
end
|
||||
|
||||
function mcl_player.player_set_textures(player, textures)
|
||||
local name = player:get_player_name()
|
||||
player_textures[name] = textures
|
||||
player:set_properties({textures = textures,})
|
||||
end
|
||||
|
||||
function mcl_player.player_set_animation(player, anim_name, speed)
|
||||
local name = player:get_player_name()
|
||||
if player_anim[name] == anim_name then
|
||||
return
|
||||
end
|
||||
local model = player_model[name] and models[player_model[name]]
|
||||
if not (model and model.animations[anim_name]) then
|
||||
return
|
||||
end
|
||||
local anim = model.animations[anim_name]
|
||||
player_anim[name] = anim_name
|
||||
player:set_animation(anim, speed or model.animation_speed, animation_blend)
|
||||
end
|
||||
|
||||
-- Update appearance when the player joins
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
mcl_player.player_attached[player:get_player_name()] = false
|
||||
mcl_player.player_set_model(player, "character.x")
|
||||
-- Minecraft has no sneak glitch
|
||||
-- sneak is also disabled because it is buggy in Minetest (can be used to negate fall damage)
|
||||
player:set_physics_override({sneak_glitch=false})
|
||||
-- Minecraft also offers no minimap for free
|
||||
player:hud_set_flags({minimap=false})
|
||||
player:set_local_animation({x=0, y=79}, {x=168, y=187}, {x=189, y=198}, {x=200, y=219}, 30)
|
||||
end)
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
player_model[name] = nil
|
||||
player_anim[name] = nil
|
||||
player_textures[name] = nil
|
||||
end)
|
||||
|
||||
-- Localize for better performance.
|
||||
local player_set_animation = mcl_player.player_set_animation
|
||||
|
||||
-- Check each player and apply animations
|
||||
minetest.register_globalstep(function(dtime)
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
local name = player:get_player_name()
|
||||
local model_name = player_model[name]
|
||||
local model = model_name and models[model_name]
|
||||
if model and not mcl_player.player_attached[name] then
|
||||
local controls = player:get_player_control()
|
||||
local walking = false
|
||||
local animation_speed_mod = model.animation_speed or 30
|
||||
|
||||
-- Determine if the player is walking
|
||||
if controls.up or controls.down or controls.left or controls.right then
|
||||
walking = true
|
||||
end
|
||||
|
||||
-- Determine if the player is sneaking, and reduce animation speed if so
|
||||
if controls.sneak then
|
||||
animation_speed_mod = animation_speed_mod / 2
|
||||
end
|
||||
|
||||
-- Apply animations based on what the player is doing
|
||||
if player:get_hp() == 0 then
|
||||
player_set_animation(player, "lay")
|
||||
elseif walking then
|
||||
if player_sneak[name] ~= controls.sneak then
|
||||
player_anim[name] = nil
|
||||
player_sneak[name] = controls.sneak
|
||||
end
|
||||
if controls.LMB then
|
||||
player_set_animation(player, "walk_mine", animation_speed_mod)
|
||||
else
|
||||
player_set_animation(player, "walk", animation_speed_mod)
|
||||
end
|
||||
elseif controls.LMB then
|
||||
player_set_animation(player, "mine")
|
||||
else
|
||||
player_set_animation(player, "stand", animation_speed_mod)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
BIN
mods/PLAYER/mcl_player/models/character.blend
Normal file
BIN
mods/PLAYER/mcl_player/models/character.png
Normal file
After Width: | Height: | Size: 5.4 KiB |
6556
mods/PLAYER/mcl_player/models/character.x
Normal file
BIN
mods/PLAYER/mcl_player/textures/player.png
Normal file
After Width: | Height: | Size: 996 B |
BIN
mods/PLAYER/mcl_player/textures/player_back.png
Normal file
After Width: | Height: | Size: 681 B |
0
mods/PLAYER/modpack.txt
Normal file
28
mods/PLAYER/playerplus/README.md
Normal file
|
@ -0,0 +1,28 @@
|
|||
# PlayerPlus mod for MineClone 2
|
||||
|
||||
## Features
|
||||
|
||||
- Hurt players touching cacti (0.5 hearts / 0.5s)
|
||||
- Suffocation: Hurt players who have their head inside a solid block (0.5 hearts / 0.5s)
|
||||
|
||||
Suffocation *not* dealt to player with the `noclip` privilege.
|
||||
|
||||
## Notes
|
||||
This mod is based on PlayerPlus [`playerplus`] by TenPlus1. It behaves a bit
|
||||
differently than the original, but the API is fully compatible.
|
||||
|
||||
## API
|
||||
|
||||
Every half second the mod checks which node the player is standing on, which
|
||||
node is at foot and head level and stores inside a global table to be used by mods:
|
||||
|
||||
- `playerplus[name].nod_stand`
|
||||
- `playerplus[name].nod_foot`
|
||||
- `playerplus[name].nod_head`
|
||||
|
||||
Setting the group `disable_suffocation=1` disables suffocation for nodes which
|
||||
would otherwise deal suffocation damage.
|
||||
|
||||
## License
|
||||
WTFPL.
|
||||
|
2
mods/PLAYER/playerplus/depends.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
mcl_core
|
||||
3d_armor?
|
1
mods/PLAYER/playerplus/description.txt
Normal file
|
@ -0,0 +1 @@
|
|||
Hurts players touching a cactus and when with the head inside solid blocks.
|
136
mods/PLAYER/playerplus/init.lua
Normal file
|
@ -0,0 +1,136 @@
|
|||
--[[
|
||||
PlayerPlus by TenPlus1
|
||||
]]
|
||||
|
||||
playerplus = {}
|
||||
|
||||
-- get node but use fallback for nil or unknown
|
||||
local function node_ok(pos, fallback)
|
||||
|
||||
fallback = fallback or "air"
|
||||
|
||||
local node = minetest.get_node_or_nil(pos)
|
||||
|
||||
if not node then
|
||||
return fallback
|
||||
end
|
||||
|
||||
if minetest.registered_nodes[node.name] then
|
||||
return node.name
|
||||
end
|
||||
|
||||
return fallback
|
||||
end
|
||||
|
||||
local armor_mod = minetest.get_modpath("3d_armor")
|
||||
local def = {}
|
||||
local time = 0
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
|
||||
time = time + dtime
|
||||
|
||||
-- every 0.5 seconds
|
||||
if time < 0.5 then
|
||||
return
|
||||
end
|
||||
|
||||
-- reset time for next check
|
||||
-- FIXME: Make sure a regular check interval applies
|
||||
time = 0
|
||||
|
||||
-- check players
|
||||
for _,player in pairs(minetest.get_connected_players()) do
|
||||
|
||||
-- who am I?
|
||||
local name = player:get_player_name()
|
||||
|
||||
-- where am I?
|
||||
local pos = player:getpos()
|
||||
|
||||
-- what is around me?
|
||||
pos.y = pos.y - 0.1 -- standing on
|
||||
playerplus[name].nod_stand = node_ok(pos)
|
||||
|
||||
pos.y = pos.y + 1.5 -- head level
|
||||
playerplus[name].nod_head = node_ok(pos)
|
||||
|
||||
pos.y = pos.y - 1.2 -- feet level
|
||||
playerplus[name].nod_feet = node_ok(pos)
|
||||
|
||||
pos.y = pos.y - 0.2 -- reset pos
|
||||
|
||||
-- set defaults
|
||||
def.speed = 1
|
||||
def.jump = 1
|
||||
def.gravity = 1
|
||||
|
||||
-- is 3d_armor mod active? if so make armor physics default
|
||||
if armor_mod and armor and armor.def then
|
||||
-- get player physics from armor
|
||||
def.speed = armor.def[name].speed or 1
|
||||
def.jump = armor.def[name].jump or 1
|
||||
def.gravity = armor.def[name].gravity or 1
|
||||
end
|
||||
|
||||
-- standing on soul sand? if so walk slower
|
||||
if playerplus[name].nod_stand == "mcl_nether:soul_sand" then
|
||||
-- TODO: Fix walk speed
|
||||
-- TODO: Also check other blocks
|
||||
-- TODO: Also slow down mobs
|
||||
def.speed = def.speed - 0.4
|
||||
end
|
||||
|
||||
-- set player physics
|
||||
-- TODO: Resolve conflict
|
||||
player:set_physics_override(def.speed, def.jump, def.gravity)
|
||||
|
||||
-- Is player suffocating inside node? (Only for solid full cube type nodes without damage
|
||||
-- and without group disable_suffocation=1.)
|
||||
local ndef = minetest.registered_nodes[playerplus[name].nod_head]
|
||||
|
||||
if (ndef.walkable == nil or ndef.walkable == true)
|
||||
and (ndef.drowning == nil or ndef.drowning == 0)
|
||||
and (ndef.damage_per_second == nil or ndef.damage_per_second <= 0)
|
||||
and (ndef.collision_box == nil or ndef.collision_box.type == "regular")
|
||||
and (ndef.node_box == nil or ndef.node_box.type == "regular")
|
||||
and (ndef.groups.disable_suffocation ~= 1)
|
||||
-- Check privilege, too
|
||||
and (not minetest.check_player_privs(name, {noclip = true})) then
|
||||
if player:get_hp() > 0 then
|
||||
player:set_hp(player:get_hp() - 1)
|
||||
end
|
||||
end
|
||||
|
||||
-- am I near a cactus?
|
||||
local near = minetest.find_node_near(pos, 1, "mcl_core:cactus")
|
||||
|
||||
if near then
|
||||
-- am I touching the cactus? if so it hurts
|
||||
for _,object in pairs(minetest.get_objects_inside_radius(near, 1.1)) do
|
||||
if object:get_hp() > 0 then
|
||||
object:set_hp(object:get_hp() - 1)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
-- set to blank on join (for 3rd party mods)
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
|
||||
playerplus[name] = {}
|
||||
playerplus[name].nod_head = ""
|
||||
playerplus[name].nod_feet = ""
|
||||
playerplus[name].nod_stand = ""
|
||||
end)
|
||||
|
||||
-- clear when player leaves
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
|
||||
playerplus[ player:get_player_name() ] = nil
|
||||
end)
|
21
mods/PLAYER/playerplus/license.txt
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 TenPlus1
|
||||
|
||||
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.
|
29
mods/PLAYER/sprint/init.lua
Normal file
|
@ -0,0 +1,29 @@
|
|||
local player_running_physics = {}
|
||||
minetest.register_globalstep(function(dtime)
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
--local pos = player:getpos()
|
||||
--print(dump(player:get_player_control().up))
|
||||
if player:get_player_control().up == true and player_running_physics[player:get_player_name()] == nil then
|
||||
minetest.after(0.05, function()
|
||||
if player:get_player_control().up == false then
|
||||
minetest.after(0.05, function()
|
||||
if player:get_player_control().up == true then
|
||||
player:set_physics_override(1.5, 1, 1)
|
||||
player_running_physics[player:get_player_name()] = true
|
||||
--print("test1")
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
elseif player:get_player_control().up == false and player_running_physics[player:get_player_name()] == true then
|
||||
--minetest.after(0.2, function()
|
||||
if player:get_player_control().up == false then
|
||||
player_running_physics[player:get_player_name()] = nil
|
||||
player:set_physics_override(1, 1, 1)
|
||||
--print("test2")
|
||||
end
|
||||
--end)
|
||||
end
|
||||
|
||||
end
|
||||
end)
|