Mod source update

master
daret 2020-11-10 16:46:25 +01:00
parent 90e56a50a6
commit 29f3a14ea2
13 changed files with 249 additions and 14 deletions

View File

@ -24,7 +24,7 @@ local function gecko_brain(self)
if mobkit.timer(self,60) then
local time = water_life.get_game_time()
if time == 4 and random(100) < 50 then
if time == 4 and random(100) < 15 then
mobkit.make_sound(self,"idle")
end
end
@ -130,7 +130,7 @@ minetest.register_entity("water_life:gecko",{
max_hp = 20,
timeout=300,
drops = {
{name = "default:diamond", chance = 5, min = 1, max = 5,},
{name = "default:diamond", chance = 5, min = 1, max = 1,},
{name = "water_life:meat_raw", chance = 2, min = 1, max = 5,},
},
attack={range=0.8,damage_groups={fleshy=7}},

View File

@ -0,0 +1,120 @@
local random = water_life.random
local abs = math.abs
local pi = math.pi
local floor = math.floor
local sqrt = math.sqrt
local max = math.max
local min = math.min
local pow = math.pow
local sign = math.sign
local rad = math.rad
minetest.register_on_player_hpchange(function(player, hp_change, reason)
if not player then return hp_change end
if hp_change > 0 then return hp_change end
local meta = player:get_meta()
local repel = meta:get_int("repellant")
local name = player:get_player_name()
if reason then
--minetest.chat_send_all(dump(repel).." : "..dump(water_life.repeltime))
if reason.type == "node_damage" and reason.node == "water_life:moskito" and repel == 0 then
minetest.sound_play("water_life_moskito", {
to_player = player:get_player_name(),
gain = 1.0,
})
return hp_change
elseif reason.type == "node_damage" and reason.node == "water_life:moskito" and repel ~= 0 then
--minetest.chat_send_player(name,"repellant working for another "..dump(math.floor(os.clock())-meta:get_int("repellant")).." seconds")
meta:set_int("repellant",0)
return 0
else
return hp_change
end
end
end, true)
minetest.register_on_leaveplayer(function(player)
local meta=player:get_meta()
meta:set_int("repellant",0)
end)
minetest.register_node("water_life:moskito", {
description = ("Moskito"),
drawtype = "plantlike",
tiles = {{
name = "water_life_moskito_animated.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 1.5
},
}},
inventory_image = "water_life_moskito.png",
wield_image = "water_life_moskito.png",
waving = 1,
paramtype = "light",
sunlight_propagates = true,
buildable_to = true,
walkable = false,
groups = {catchable = 1},
damage_per_second = 1,
selection_box = {
type = "fixed",
fixed = {-0.1, -0.1, -0.1, 0.1, 0.1, 0.1},
},
floodable = true,
on_place = function(itemstack, placer, pointed_thing)
local player_name = placer:get_player_name()
local pos = pointed_thing.above
if not minetest.is_protected(pos, player_name) and
not minetest.is_protected(pointed_thing.under, player_name) and
minetest.get_node(pos).name == "air" then
minetest.set_node(pos, {name = "water_life:moskito"})
minetest.get_node_timer(pos):start(1)
local pmeta = minetest.get_meta(pos)
pmeta:set_int("mlife",math.floor(os.clock()))
itemstack:take_item()
end
return itemstack
end,
on_timer = function(pos, elapsed)
local ptime = water_life.get_game_time()
local level = minetest.get_node_light(pos)
local mmeta = minetest.get_meta(pos)
local killer = math.floor(os.clock()) - mmeta:get_int("mlife")
--minetest.chat_send_all("liftime : "..dump(killer).." seconds")
if (ptime and ptime < 3 and level and level > 7) or killer > water_life.moskitolifetime then
minetest.set_node(pos, {name = "air"})
else
local bdata = water_life_get_biome_data(pos)
local nodes = minetest.find_nodes_in_area({x=pos.x-4, y=pos.y-2, z=pos.z-4}, {x=pos.x+4, y=pos.y+1, z=pos.z+4}, {"air"})
if nodes and #nodes > 0 then
local spos = nodes[random(#nodes)]
local rnd = random (200)
--minetest.chat_send_all(dump(bdata.temp).." : "..dump(bdata.humid).." : "..dump(rnd).." : "..dump(spos))
if bdata.temp > 16 and spos then
if rnd < bdata.humid then
minetest.set_node(spos, {name = "water_life:moskito"})
minetest.get_node_timer(spos):start(random(15,45))
local pmeta = minetest.get_meta(spos)
pmeta:set_int("mlife",math.floor(os.clock()))
end
end
end
minetest.get_node_timer(pos):start(random(15,45))
end
end
})

View File

@ -18,8 +18,7 @@ local atan=math.atan
water_life.hud_poison = {
hud_elem_type = "image", -- See HUD element types
-- Type of element, can be "image", "text", "statbar", or "inventory"
hud_elem_type = "image",
position = {x=0.5, y=0.8},
-- Left corner position of element
@ -29,9 +28,20 @@ water_life.hud_poison = {
scale = {x = 0.1, y = 0.1},
text = "water_life_poison.png",
}
-- size = { x=16, y=16 },
-- Size of element in pixels
water_life.hud_repellant = {
hud_elem_type = "image",
position = {x=0.55, y=0.8},
-- Left corner position of element
name = "water_life_repellanthud.png",
scale = {x = 0.1, y = 0.1},
text = "water_life_repellanthud.png",
}
@ -57,6 +67,8 @@ function water_life.random(min,max)
min = 1
end
if max and not min then min = 1 end
if max < min then return water_life.randomtable:next(max,min) end
return water_life.randomtable:next(min,max)
end
@ -501,8 +513,8 @@ function water_life.find_node_under_air(pos,radius,name)
if not radius then radius = 3 end
if not name then name={"group:crumbly","group:stone","group:tree"} end
local pos1 = mobkit.pos_shift(pos,{x=radius*-1,y=radius*-1,z=radius*-1})
local pos2 = mobkit.pos_shift(pos,{x=radius,y=radius,z=radius})
local pos1 = {x=pos.x-radius, y=pos.y-radius, z=pos.z-radius} --mobkit.pos_shift(pos,{x=radius*-1,y=radius*-1,z=radius*-1})
local pos2 = {x=pos.x+radius, y=pos.y+radius, z=pos.z+radius} --mobkit.pos_shift(pos,{x=radius,y=radius,z=radius})
local spawner = minetest.find_nodes_in_area_under_air(pos1, pos2, name)
if not spawner or #spawner < 1 then
return nil

View File

@ -333,6 +333,30 @@ if not water_life.apionly then
groups = {vessel = 1},
})
--[[
minetest.register_craftitem("water_life:repellant", {
description = ("No moskitos for half a day"),
inventory_image = "water_life_repell.png",
wield_scale = {x = 0.4, y = 0.4, z = 0.4},
liquids_pointable = false,
on_use = function(itemstack, user, pointed_thing)
if not user or not user:is_player() then return itemstack end
local name = user:get_player_name()
local meta = user:get_meta()
meta:set_int("repellant",math.floor(os.clock()))
itemstack:take_item()
if not water_life.repellant[name] then
water_life.repellant[name] = user:hud_add(water_life.hud_repellant)
end
return itemstack
end,
groups = {vessel = 1},
})]]
minetest.register_craft({
type = "shapeless",
output = "water_life:antiserum",

View File

@ -0,0 +1,45 @@
IMPORTANT NOTICE: This license only applies if you downloaded this content as
an unsubscribed user. If you are a premium user (ie, you pay a subscription)
you are bound to the license terms described in the accompanying file
"License premium.txt".
---------------------
You must attribute the image to its author:
In order to use a content or a part of it, you must attribute it to Freepik,
so we will be able to continue creating new graphic resources every day.
How to attribute it?
For websites:
Please, copy this code on your website to accredit the author:
<a href="http://www.freepik.com">Designed by Freepik</a>
For printing:
Paste this text on the final work so the authorship is known.
- For example, in the acknowledgements chapter of a book:
"Designed by Freepik"
You are free to use this image:
- For both personal and commercial projects and to modify it.
- In a website or presentation template or application or as part of your design.
You are not allowed to:
- Sub-license, resell or rent it.
- Include it in any online or offline archive or database.
The full terms of the license are described in section 7 of the Freepik
terms of use, available online in the following link:
http://www.freepik.com/terms_of_use
The terms described in the above link have precedence over the terms described
in the present document. In case of disagreement, the Freepik Terms of Use
will prevail.

View File

@ -6,8 +6,9 @@
-----------------------------------------------------------
water_life = {}
water_life.version = "171020"
water_life.version = "081120"
water_life.shark_food = {}
water_life.repellant = {}
water_life.petz = minetest.get_modpath("petz")
water_life.mobsredo = minetest.get_modpath("mobs")
water_life.abr = tonumber(minetest.settings:get('active_block_range')) or 2
@ -25,8 +26,10 @@ water_life.maxmobs = tonumber(minetest.settings:get("water_life_maxmobs")) or 60
water_life.apionly = minetest.settings:get_bool("water_life_apionly") or false
water_life.dangerous = minetest.settings:get_bool("water_life_dangerous") or false
water_life.soundadjust = tonumber(minetest.settings:get("water_life_soundadjust")) or 1.0
water_life.moskitolifetime = tonumber(minetest.settings:get("water_life_moskitolifetime")) or 300
water_life.radar_debug = minetest.settings:get_bool("water_life_radar_debug") or false
water_life.muddy_water = minetest.settings:get_bool("water_life_muddy_water") or false
water_life.repeltime = math.floor (720 / (tonumber(minetest.settings:get("time_speed")) or 72)*60) -- the repellent lasts half a minetest day
local path = minetest.get_modpath(minetest.get_current_modname())
@ -58,6 +61,7 @@ if not water_life.apionly then
dofile(path.."/animals/piranha.lua") -- load piranha
dofile(path.."/animals/shark.lua") -- load sharks
dofile(path.."/animals/crocodile.lua") -- load crocodile
dofile(path.."/animals/moskito.lua") -- load moskitos
end
end

View File

@ -39,6 +39,11 @@ water_life_maxwhales (Max possible whales in aktive area) int 1
# total max number of sharks spawning in aktive area
water_life_maxsharks (Max possible sharks in aktive area) int 5
# -
# max lifetime of a moskito (default 300 = 5 minutes)
water_life_moskitolifetime (Max lifetime of a moskito in seconds) int 300
# -
# total max number of animals in an aktive area
# other mods might not care about this setting

Binary file not shown.

View File

@ -39,7 +39,14 @@ local function spawnstep(dtime)
local score = plyr:get_hp()
plyr:set_hp(score-1)
end
if meta:get_int("repellant") > 0 then
if math.floor(os.clock()) - meta:get_int("repellant") > water_life.repeltime then
--plyr:hud_remove(water_life.repellant[name])
meta:set_int("repellant",0)
end
end
if animal.all > water_life.maxmobs then toomuch = true end
-- find a pos randomly in look direction of player
@ -49,21 +56,37 @@ local function spawnstep(dtime)
if water_life.leftorright() then yaw = yaw + angel else yaw = yaw - angel end -- add or substract to/from yaw
local pos2 = mobkit.pos_translate2d(pos,yaw,radius) -- calculate position
local depth, stype, surface = water_life.water_depth(pos2,25) -- get surface pos and water depth
local bdata = water_life_get_biome_data(pos2) -- get biome data at spaen position
local depth, stype, surface = water_life.water_depth(pos2,25) -- get surface pos and water depth
local bdata = water_life_get_biome_data(pos2) -- get biome data at spawn position
local ground = {}
local dalam = depth
local landpos = nil
local geckopos = nil
local moskitopos = nil
-- no need of so many postions on land
if landtimer > landinterval then
landpos = water_life.find_node_under_air(pos2)
geckopos = water_life.find_node_under_air(pos2,5,{"group:tree","group:leaves","default:junglegrass"})
moskitopos = water_life.find_node_under_air(pos2,5,{"default:river_water_source","water_life:muddy_river_water_source","group:flora","default:dirt_with_rainforest_litter"})
end
if moskitopos and not water_life.dangerous then
local mlevel = minetest.get_node_light(moskitopos)
local ptime = water_life.get_game_time()
local mdata = water_life_get_biome_data(moskitopos)
--minetest.chat_send_all("MOSKITO: "..dump(moskitopos).." : "..dump(mdata.temp).." : "..dump(ptime).." : "..dump(mlevel))
if ((ptime and ptime > 2) or mlevel < 8) and mdata.temp > 16 then --from 3pm to 5am or in shadows all day long
minetest.set_node(moskitopos, {name = "water_life:moskito"})
minetest.get_node_timer(moskitopos):start(random(15,45))
local pmeta = minetest.get_meta(moskitopos)
pmeta:set_int("mlife",math.floor(os.clock()))
end
end
--some spawn on land, too
@ -74,7 +97,7 @@ local function spawnstep(dtime)
if not water_life.dangerous then
-- the snake
local mobname = 'water_life:snake'
local faktor = (100 - getcount(animal[mobname]) * 50) + 25
local faktor = (100 - getcount(animal[mobname]) * 50)
if random(100) < faktor then
local fits = minetest.is_protected(landpos,mobname)
--minetest.chat_send_all(dump(fits))
@ -85,6 +108,8 @@ local function spawnstep(dtime)
local obj=minetest.add_entity(landpos,mobname) -- ok spawn it already damnit
end
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 568 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB