Skip to content
This repository has been archived by the owner on Aug 20, 2020. It is now read-only.

Commit

Permalink
added 4 new fish and trophy (carp, perch, catfish, exoticfish)
Browse files Browse the repository at this point in the history
fish, carp, perch, catfish and pike only catched in rivers
clownfish, bluewhite,exoticfish and shark only catched in sea
convert sound stereo in mono
  • Loading branch information
Crabman77 committed Sep 26, 2015
1 parent d877749 commit 14bdc52
Show file tree
Hide file tree
Showing 24 changed files with 229 additions and 95 deletions.
32 changes: 22 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,45 @@
### Original by Mossmanikin https://github.com/Mossmanikin/fishing
### Rewrited by Crabman77

5 fish type
3 small fish (fish, clownfish,bluewhite fish)
2 predator fish (small shark, Northern Pike)
###9 fish type
**fish in rivers**
> - 2 small fish (fish, carp)
> - 3 predator fish (perch, catfish, Northern Pike)
**fish in sea**
>- 3 small fish (clownfish,bluewhite fish, exotic fish)
> - 1 predator fish (small shark)

3 kind of bait for small fish (corn, bread, worm)
3 kind of bait for predator fish (small fish)
4 kind of bait for predator fish (small fish)
2 poles, wood 30 uses and mithril 1500 uses
The baits have a variable luck(15% to 80%) changed between 30 minutes to 6 hours for a better gameplay
Baitball improves lucky bait of 20%

##Contest Game

###**Contest Game **
Contest game can be launched by admin, duration variable 2min to 4heures
Start/End is announced in chat and sound
A ranking appears(formspec) after contest

Adjustable settings in formspec
if the unified_inventory mod is active there is a button for classification or settings for the admin only
if the unified_inventory mod is actived there is a button for classification or settings for the admin only


[demo video youtube](https://youtu.be/8rt8g3F2Gmk)


![fishing]( http://nsm08.casimages.com/img/2015/07/01/1507010157379539613411965.png)
![fishing]( http://nsm08.casimages.com/img/2015/07/01//1507010157329539613411964.png)
![fishing]( http://nsm08.casimages.com/img/2015/07/01//1507010157319539613411963.png)

####Trophy and fish type
![fishing]( http://nsm08.casimages.com/img/2015/09/26//1509260649029539613611795.jpg)
#### Admin can look bait chance
![fishing]( http://nsm08.casimages.com/img/2015/09/26//1509260648599539613611793.jpg)
### admin menu
![fishing]( http://nsm08.casimages.com/img/2015/09/26//1509260649019539613611794.jpg)

![fishing]( http://nsm08.casimages.com/img/2015/07/01//1507010157389539613411968.png)

![fishing]( http://nsm08.casimages.com/img/2015/07/01//1507010157379539613411966.png)
![fishing]( http://nsm08.casimages.com/img/2015/07/01//1507010157389539613411967.png)
####formspec contest ranking
![fishing]( http://nsm08.casimages.com/img/2015/09/26//1509260648579539613611792.jpg)
3 changes: 3 additions & 0 deletions baits.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ fishing_setting.baits["fishing:bait_worm"] = { ["bait"] = "fishing:bait_worm", [
fishing_setting.baits["fishing:fish_raw"] = { ["bait"] = "fishing:fish_raw", ["bobber"] = "fishing:bobber_shark_entity",["texture"] = "fishing_fish_raw.png", ["hungry"] = 50 }

fishing_setting.baits["fishing:clownfish_raw"] = { ["bait"] = "fishing:clownfish_raw", ["bobber"] = "fishing:bobber_shark_entity",["texture"] = "fishing_clownfish_raw.png", ["hungry"] = 50 }

fishing_setting.baits["fishing:bluewhite_raw"] = { ["bait"] = "fishing:bluewhite_raw", ["bobber"] = "fishing:bobber_shark_entity",["texture"] = "fishing_bluewhite_raw.png", ["hungry"] = 50 }

fishing_setting.baits["fishing:exoticfish_raw"] = { ["bait"] = "fishing:exoticfish_raw", ["bobber"] = "fishing:bobber_shark_entity",["texture"] = "fishing_exoticfish_raw.png", ["hungry"] = 50 }
8 changes: 6 additions & 2 deletions bobber.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ local FISHING_BOBBER_ENTITY={
visual_size = {x=1/3, y=1/3, z=1/3},
textures = {"fishing:bobber_box"},
-- {left ,bottom, front, right, top , back}
collisionbox = {-2/16, -4/16, -2/16, 2/16, 1/16, 2/16},
collisionbox = {-2/16, -4/16, -2/16, 2/16, 2/16, 2/16},
randomtime = 50,
baitball = 0,
prize = "",
Expand Down Expand Up @@ -169,7 +169,11 @@ local FISHING_BOBBER_ENTITY={

self.randomtime = math.random(1,5)*10
if math.random(1, 100) <= fishing_setting.settings["fish_chance"] then
self.prize = fishing_setting.prizes["fish"][math.random(1,#fishing_setting.prizes["fish"])]
if self.water_type and self.water_type == "sea" then
self.prize = fishing_setting.prizes["sea"]["little"][math.random(1,#fishing_setting.prizes["sea"]["little"])]
else
self.prize = fishing_setting.prizes["rivers"]["little"][math.random(1,#fishing_setting.prizes["rivers"]["little"])]
end
else
if math.random(1, 100) <= 10 then
self.prize = fishing_setting.func.get_loot()
Expand Down
12 changes: 8 additions & 4 deletions bobber_shark.lua
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ local FISHING_BOBBER_SHARK_ENTITY={
-- if fish or others items, move bobber to simulate fish on the line
if self.prize ~= "" and math.random(1,3) == 1 then
if self.old_pos2 == true then
pos.y = pos.y-0.0425
pos.y = pos.y-0.050
self.object:moveto(pos, false)
self.old_pos2 = false
else
pos.y = pos.y+0.0425
pos.y = pos.y+0.050
self.object:moveto(pos, false)
self.old_pos2 = true
end
Expand All @@ -173,15 +173,19 @@ local FISHING_BOBBER_SHARK_ENTITY={
self.prize = fishing_setting.prizes["treasure"][math.random(1,#fishing_setting.prizes["treasure"])]
end
elseif chance <= fishing_setting.settings["fish_chance"] then
self.prize = fishing_setting.prizes["shark"][math.random(1,#fishing_setting.prizes["shark"])]
if self.water_type and self.water_type == "sea" then
self.prize = fishing_setting.prizes["sea"]["big"][math.random(1,#fishing_setting.prizes["sea"]["big"])]
else
self.prize = fishing_setting.prizes["rivers"]["big"][math.random(1,#fishing_setting.prizes["rivers"]["big"])]
end
else
if math.random(1, 100) <= 10 then
self.prize = fishing_setting.func.get_loot()
end
end

if self.prize ~= "" then
pos.y = self.old_pos.y-0.2
pos.y = self.old_pos.y-0.140
self.object:moveto(pos, false)
minetest.sound_play("fishing_bobber1", {pos=pos,gain = 0.5,})
end
Expand Down
28 changes: 28 additions & 0 deletions crafting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,41 @@ minetest.register_craft({
recipe = "fishing:clownfish_raw",
cooktime = 2,
})

minetest.register_craft({
type = "cooking",
output = "fishing:fish_cooked",
recipe = "fishing:bluewhite_raw",
cooktime = 2,
})

minetest.register_craft({
type = "cooking",
output = "fishing:fish_cooked",
recipe = "fishing:exoticfish_raw",
cooktime = 2,
})

minetest.register_craft({
type = "cooking",
output = "fishing:fish_cooked",
recipe = "fishing:carp_raw",
cooktime = 2,
})

minetest.register_craft({
type = "cooking",
output = "fishing:fish_cooked",
recipe = "fishing:perch_raw",
cooktime = 2,
})

minetest.register_craft({
type = "cooking",
output = "fishing:fish_cooked",
recipe = "fishing:catfish_raw",
cooktime = 2,
})

-----------------------------------------------------------------------------------------------
-- Wheat Seed
Expand Down
40 changes: 40 additions & 0 deletions fishes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,46 @@ minetest.register_craftitem("fishing:bluewhite_raw", {
inventory_image = "fishing_bluewhite_raw.png",
on_use = minetest.item_eat(2),
})
-----------------------------------------------------------------------------------------------
-- exoticfish
-----------------------------------------------------------------------------------------------
minetest.register_craftitem("fishing:exoticfish_raw", {
description = fishing_setting.func.S("Exotic"),
groups = {},
inventory_image = "fishing_exoticfish_raw.png",
on_use = minetest.item_eat(2),
})

-----------------------------------------------------------------------------------------------
-- carp
-----------------------------------------------------------------------------------------------
minetest.register_craftitem("fishing:carp_raw", {
description = fishing_setting.func.S("Carp"),
groups = {},
inventory_image = "fishing_carp_raw.png",
on_use = minetest.item_eat(2),
})

-----------------------------------------------------------------------------------------------
-- perch
-----------------------------------------------------------------------------------------------
minetest.register_craftitem("fishing:perch_raw", {
description = fishing_setting.func.S("Perch"),
groups = {},
inventory_image = "fishing_perch_raw.png",
on_use = minetest.item_eat(2),
})

-----------------------------------------------------------------------------------------------
-- catfish
-----------------------------------------------------------------------------------------------
minetest.register_craftitem("fishing:catfish_raw", {
description = fishing_setting.func.S("Catfish"),
groups = {},
inventory_image = "fishing_catfish_raw.png",
on_use = minetest.item_eat(2),
})


-----------------------------------------------------------------------------------------------
-- Whatthef... it's a freakin' Shark!
Expand Down
93 changes: 33 additions & 60 deletions functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ end)
function fishing_setting.func.add_to_trophies(player, fish, desc)
local player_name = player:get_player_name()
if not player_name then return end
if fish == "fish_raw" or fish == "shark_raw" or fish == "pike_raw" or fish == "clownfish_raw" or fish == "bluewhite_raw" then
if string.find(fish, "_raw") ~= nil then
if fishing_setting.trophies[fish] == nil then
fishing_setting.trophies[fish] = {}
end
Expand All @@ -361,10 +361,10 @@ function fishing_setting.func.add_to_trophies(player, fish, desc)
end

if fishing_setting.contest["contest"] ~= nil and fishing_setting.contest["contest"] == true then
if fishing_setting.contest[fish] == nil then
fishing_setting.contest[fish] = {}
if fishing_setting.contest["nb_fish"] == nil then
fishing_setting.contest["nb_fish"] = {}
end
fishing_setting.contest[fish][player_name] = (fishing_setting.contest[fish][player_name] or 0) + 1
fishing_setting.contest["nb_fish"][player_name] = (fishing_setting.contest["nb_fish"][player_name] or 0) + 1
minetest.chat_send_all(S("Yeah, %s caught "..desc):format(player_name))
end
end
Expand Down Expand Up @@ -413,13 +413,13 @@ function fishing_setting.func.save_contest()
end
end

--function load councours data from file
--function load contest data from file
function fishing_setting.func.load_contest()
local file = io.open(fishing_setting.file_contest, "r")
local settings = {}
local settings
fishing_setting.contest = {["contest"] = false, ["duration"] = 3600, ["bobber_nb"] = 4}
if file then
settings = minetest.deserialize(file:read("*all"))
settings = minetest.deserialize(file:read("*all"))
file:close()
if settings ~= nil and type(settings) == "table" then
if settings["contest"] ~= nil then
Expand All @@ -431,20 +431,8 @@ function fishing_setting.func.load_contest()
if settings["bobber_nb"] ~= nil then
fishing_setting.contest["bobber_nb"] = settings["bobber_nb"]
end
if settings["fish_raw"] ~= nil then
fishing_setting.contest["fish_raw"] = settings["fish_raw"]
end
if settings["clownfish_raw"] ~= nil then
fishing_setting.contest["clownfish_raw"] = settings["clownfish_raw"]
end
if settings["bluewhite_raw"] ~= nil then
fishing_setting.contest["bluewhite_raw"] = settings["bluewhite_raw"]
end
if settings["shark_raw"] ~= nil then
fishing_setting.contest["shark_raw"] = settings["shark_raw"]
end
if settings["pike_raw"] ~= nil then
fishing_setting.contest["pike_raw"] = settings["pike_raw"]
if settings["nb_fish"] ~= nil then
fishing_setting.contest["nb_fish"] = settings["nb_fish"]
end
end
end
Expand Down Expand Up @@ -496,11 +484,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
if not name then return end
if fields["save"] then
if fishing_setting.tmp_setting["reset"] == true then
fishing_setting.contest["fish_raw"] = {}
fishing_setting.contest["clownfish_raw"] = {}
fishing_setting.contest["bluewhite_raw"] = {}
fishing_setting.contest["shark_raw"] = {}
fishing_setting.contest["pike_raw"] = {}
fishing_setting.contest["nb_fish"] = {}
end

local progress = (fishing_setting.contest["contest"] or false)
Expand Down Expand Up @@ -562,11 +546,10 @@ end

function fishing_setting.func.set_winners(list)
local win = {}
local i = 1
-- this uses an custom sorting function ordering by score descending
for k,v in spairs(list, function(t,a,b) return t[b] < t[a] end) do
table.insert(win, {[k]=v})
if #win >= 6 then
table.insert(win, {["name"]=k, ["nb"]=v})
if #win >= 15 then
break
end
end
Expand All @@ -575,44 +558,34 @@ end


function fishing_setting.func.get_stat()
local winners= {}
for k,v in pairs(fishing_setting.contest) do
if string.find(k, "_raw") ~= nil then
if fishing_setting.contest[k] ~= nil then
winners[k] = fishing_setting.func.set_winners(fishing_setting.contest[k])
else
winners[k] = {}
end
end
end
local formspec = {"size[12,8]label[4.6,0;"..S("Fishing contest rankings").."]"}
local X = 0
local Y
for fish, fishers in pairs(winners) do
Y = 1.1
table.insert(formspec, "label["..(X+0.4)..",0.5;"..string.gsub(fish, "_raw", ""):upper().."]") --fish name
for _,s in ipairs(fishers) do
for pl,nb in pairs(s) do
table.insert(formspec, "label["..(X) ..","..Y..";"..tostring(nb).."]") -- nb fish caught
table.insert(formspec, "label["..(X+0.5) ..","..Y..";"..tostring(pl).."]") -- playername
end
Y = Y + 0.4
end
X = X + 2.3
end
table.insert(formspec, "button_exit[5.4,7.5;1.2,1;close;"..S("Close").."]")
local winners = {}
if fishing_setting.contest["nb_fish"] ~= nil then
winners = fishing_setting.func.set_winners(fishing_setting.contest["nb_fish"])
end
local formspec = {"size[6,8]label[2,0;"..S("Fishing contest rankings").."]"}
local Y = 1.1
table.insert(formspec, "label[0.5,0.5;No]")
table.insert(formspec, "label[2,0.5;Name]")
table.insert(formspec, "label[4.2,0.5;Fish Total]")
for num,n in ipairs(winners) do
table.insert(formspec, "label[0.5,"..Y..";"..tostring(num).."]") -- classement
table.insert(formspec, "label[2,"..Y..";"..n["name"].."]") -- playername
table.insert(formspec, "label[4.3,"..Y..";"..tostring(n["nb"]).."]") -- nb fish caught
Y = Y + 0.4
end
table.insert(formspec, "button_exit[2.4,7.5;1.2,1;close;"..S("Close").."]")
return table.concat(formspec)
end

function fishing_setting.func.get_hunger_info(player_name)
local formspec = "size[6,8]label[1.9,0;Fishing Info Center]"
local y = 1
local formspec = "size[6,9]label[1.9,0;Fishing Info Center]"
local y = 0.8
for i, a in pairs(fishing_setting.baits) do
formspec = formspec .."item_image_button[1,"..tostring(y)..";1,1;"..tostring(i)..";"..tostring(i)..";]"..
"label[2.2,"..tostring(y+0.2)..";Chance to fish :"..tostring(a["hungry"]).."%]"
formspec = formspec .."item_image_button[1,"..tostring(y)..";1,1;"..tostring(i)..";"..tostring(i)..";]"..
"label[2.2,"..tostring(y+0.2)..";Chance to fish :"..tostring(a["hungry"]).."%]"
y = y+1
end
formspec = formspec .."button_exit[2,7.5;2,1;close;"..S("Close").."]"
formspec = formspec .."button_exit[2,8.5;2,1;close;"..S("Close").."]"
minetest.show_formspec(player_name,"fishing:material_info", formspec)
end

Expand Down
2 changes: 1 addition & 1 deletion init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-----------------------------------------------------------------------------------------------
local title = "Fishing - Crabman77's version"
local version = "0.0.2"
local version = "0.0.3"
local mname = "fishing"
-----------------------------------------------------------------------------------------------
-- original by wulfsdad (http://forum.minetest.net/viewtopic.php?id=4375)
Expand Down
Loading

0 comments on commit 14bdc52

Please sign in to comment.