Jump to content

[Template] Adding Ocean Fish to the Game


Lucemodok
 Share

Recommended Posts

Hello, I'm Lucemodok (or Luce) and I have come here again to show you how to add custom ocean fish to the game.

Spoiler

-- In modmain.lua do the following:
local FISH_DEFS = require("prefabs/oceanfishdef").fish -- We need the file that defines fish for this, this ".fish" is for the actual fish.
local SCHOOL_WEIGHTS = require("prefabs/oceanfishdef").school -- This ".school" is for the chances of your fish's schools to spawn.

local SCHOOL_SIZE = { -- The minimum and max size of your fish's schools.
	TINY = 		{min=1,max=3}, -- Minimum 1 fish, maximum 3 fish.
	SMALL = 	{min=2,max=5}, -- Minimum 2 fish, maximum 5 fish.
	MEDIUM = 	{min=4,max=6}, -- Minimum 4 fish, maximum 6 fish.
	LARGE = 	{min=6,max=10},	 -- Minimum 6 fish, maximum 10 fish.
}

local SCHOOL_AREA = { -- The area your school covers in what I call units, 1 unit is approximately the player hitbox.
	TINY = 		2, -- 2 units.
	SMALL = 	3, -- 3 units.
	MEDIUM = 	6, -- 6 units.
	LARGE = 	10,	 -- 10 units.
}

local WANDER_DIST = { -- How much the fish wanders around in units.
	SHORT = 	{min=5,max=15}, -- Minimum 5 units, maximum 15 units.
	MEDIUM = 	{min=15,max=30}, -- Minimum 15 units, maximum 30 units.
	LONG = 		{min=20,max=40}, -- Minimum 20 units, maximum 40 units.
}

local ARRIVE_DIST = { 
	CLOSE = 	3,
	MEDIUM = 	8,
	FAR = 		12,
}

local WANDER_DELAY = { -- How long the schools of fish take to start wandering.
	SHORT = 	{min=0,max=10}, -- Minimum 0 seconds, maximum 10 seconds.
	MEDIUM = 	{min=10,max=30}, -- Minimum 10 seconds, maximum 30 seconds.
	LONG = 		{min=30,max=60}, -- Minimum 30 seconds, maximum 60 seconds.
}

local SEG = 30
local DAY = SEG*16

local SCHOOL_WORLD_TIME = { -- How long the school of fish sticks around.
	SHORT = 	{min=SEG*8,max=SEG*16}, -- Minimum 4 minutes, maximum 8 minutes.
	MEDIUM = 	{min=DAY,max=DAY*2}, -- Minimum 8 minutes, maximum 16 minutes.
	LONG = 		{min=DAY*2,max=DAY*4},  -- Minimum 16 minutes, maximum 32 minutes.
}

local LOOT = { -- What the fish gives when murdered.
	TINY = 			{ "fishmeat_small" }, -- Fish morsel
	SMALL = 		{ "fishmeat_small" },
	SMALL_COOKED = 	{ "fishmeat_small_cooked" }, -- Cooked fish morsel
	MEDIUM = 		{ "fishmeat" }, -- Fish meat
	LARGE = 		{ "fishmeat" },
	HUGE = 			{ "fishmeat" },
    CORN =			{ "corn" }, -- Corn
    POPCORN =		{ "corn_cooked" }, -- Popcorn
    ICE =			{ "fishmeat", "ice", "ice" }, -- Fish meat and two ice
    PLANTMEAT =		{ "plantmeat" }, -- Leafy meat
}

local PERISH = { -- What the fish gives when it dies naturally.
	TINY = 		"fishmeat_small", -- Fish morsel
	SMALL = 	"fishmeat_small",
	MEDIUM = 	"fishmeat", -- Fish meat
	LARGE = 	"fishmeat",
	HUGE = 		"fishmeat",
    CORN =      "corn", -- Corn
    POPCORN =   "corn_cooked", -- Popcorn
	PLANTMEAT = "spoiled_food", -- Leafy meat
}

local COOKING_PRODUCT = { -- What the fish gives when cooked alive.
	TINY = 		"fishmeat_small_cooked", -- Cooked fish morsel
	SMALL = 	"fishmeat_small_cooked",
	MEDIUM = 	"fishmeat_cooked", -- Cooked fish meat
	LARGE = 	"fishmeat_cooked",
	HUGE = 		"fishmeat_cooked",
    CORN =      "corn_cooked", -- Popcorn
	PLANTMEAT = "plantmeat_cooked", -- Cooked leafy meat
}

local DIET = { -- What the fish eats.
	OMNI = { caneat = { FOODGROUP.OMNI } }, -- Eats anythin the player eats.
	VEGGIE = { caneat = { FOODGROUP.VEGETARIAN } }, -- Eats what wurt eats.
	MEAT = { caneat = { FOODTYPE.MEAT } }, -- Only eats meat.
}

COOKER_INGREDIENT_SMALL = { meat = .5, fish = .5 } -- Value of .5 meat and .5 fish in the crockpot.
COOKER_INGREDIENT_MEDIUM = { meat = 1, fish = 1 } -- Value of 1 meat and 1 fish in the crockpot.
COOKER_INGREDIENT_MEDIUM_ICE = { meat = 1, fish = 1, frozen = 1 } -- Value of 1 meat, 1 fish and 1 frozen in the crockpot.

EDIBLE_VALUES_SMALL_MEAT = {health = TUNING.HEALING_TINY, hunger = TUNING.CALORIES_SMALL, sanity = 0, foodtype = FOODTYPE.MEAT} -- 1 HP and 12.5 hunger if something eats the fish alive.
EDIBLE_VALUES_MEDIUM_MEAT = {health = TUNING.HEALING_MEDSMALL, hunger = TUNING.CALORIES_MED, sanity = 0, foodtype = FOODTYPE.MEAT} -- 8 HP and 25 hunger if something eats the fish alive.
EDIBLE_VALUES_SMALL_VEGGIE = {health = TUNING.HEALING_SMALL, hunger = TUNING.CALORIES_SMALL, sanity = 0, foodtype = FOODTYPE.VEGGIE} -- 3 HP and 12.5 hunger if something eats the fish alive.
EDIBLE_VALUES_MEDIUM_VEGGIE = {health = TUNING.HEALING_SMALL, hunger = TUNING.CALORIES_MED, sanity = 0, foodtype = FOODTYPE.VEGGIE} -- 3 HP and 12.5 hunger if something eats the fish alive.
EDIBLE_VALUES_PLANTMEAT = {health = 0, hunger = TUNING.CALORIES_SMALL, sanity = -TUNING.SANITY_SMALL, foodtype = FOODTYPE.MEAT} -- 12.5 Hunger and -10 Sanity hunger if something eats the fish alive.

local SET_HOOK_TIME_SHORT = { base = 1, var = 0.5 }
local SET_HOOK_TIME_MEDIUM = { base = 2, var = 0.5 }

local BREACH_FX_SMALL = { "ocean_splash_small1", "ocean_splash_small2"} -- The effect that appears when a small fish splashes in and out of the water.
local BREACH_FX_MEDIUM = { "ocean_splash_med1", "ocean_splash_med2"} -- The effect that appears when a medium fish splashes in and out of the water.

local SHADOW_SMALL = {1, .75}  -- The shadow of a small fish.
local SHADOW_MEDIUM = {1.5, 0.75} -- The shadow of a medium fish.

STRINGS.NAMES.CUSTOMFISH_SMALL_1 = "Custom Fish" -- Your fish's name.

FISH_DEFS.customfish_small_1 = {
    prefab = "customfish_small_1", -- The fish's prefab.
    bank = "customfish_small", -- The sprite bank of your fish.
    build = "customfish_small_1", -- The sprite of your fish.
    weight_min = 25.30, -- The minimum weight of your fish.
    weight_max = 40.60, -- The maximum weight of your fish.

    walkspeed = 0.9, -- How fast they move normally
    runspeed = 3.0, -- How fast they "run".
    stamina =
    {
        drain_rate = 1.0, -- How fast your fish's stamina drains.
        recover_rate = 0.05, -- How fast your fish's stamina recovers.
        struggle_times	= {low = 3, r_low = 1, high = 6, r_high = 1}, -- How long your fish struggles.
        tired_times		= {low = 7, r_low = 1, high = 5, r_high = 1}, -- How long your fish is tired.
        tiredout_angles = {has_tention = 45, low_tention = 90},
    },

    schoolmin = SCHOOL_SIZE.TINY.min,
    schoolmax = SCHOOL_SIZE.TINY.max,
    schoolrange = SCHOOL_AREA.SMALL,
    schoollifetimemin = SCHOOL_WORLD_TIME.SHORT.min,
    schoollifetimemax = SCHOOL_WORLD_TIME.SHORT.max,

    herdwandermin = WANDER_DIST.SHORT.min,
    herdwandermax = WANDER_DIST.SHORT.max,
    herdarrivedist = ARRIVE_DIST.CLOSE,	 
    herdwanderdelaymin = WANDER_DELAY.SHORT.min,
    herdwanderdelaymax = WANDER_DELAY.SHORT.max,

    set_hook_time = SET_HOOK_TIME_SHORT,
    breach_fx = BREACH_FX_SMALL,
    loot = LOOT.SMALL,
    cooking_product = COOKING_PRODUCT.SMALL,
    perish_product = PERISH.SMALL,
    fishtype = "meat", -- What kind of fish it is.

    lures = TUNING.OCEANFISH_LURE_PREFERENCE.MEAT,
    diet = DIET.MEAT,
    cooker_ingredient_value = COOKER_INGREDIENT_SMALL, 
    edible_values = EDIBLE_VALUES_SMALL_MEAT,

    dynamic_shadow = SHADOW_SMALL,
}

local SCHOOL_VERY_COMMON		= 4 -- A chance of 4 for your school to appear, the highest chance.
local SCHOOL_COMMON				= 2 -- A chance of 2 for your school to appear.
local SCHOOL_UNCOMMON			= 1  -- A chance of 1 for your school to appear.
local SCHOOL_RARE				= 0.25  -- A chance of .25 for your school to appear, the lowest chance.

SCHOOL_WEIGHTS[SEASONS.AUTUMN][GROUND.OCEAN_BRINEPOOL].customfish_small_1 = SCHOOL_VERY_COMMON -- Ocean grounds include OCEAN_COASTAL, OCEAN_SWELL, OCEAN_HAZARDOUS, OCEAN_ROUGH, OCEAN_BRINEPOOL_SHORE and OCEAN_BRINEPOOL.
SCHOOL_WEIGHTS[SEASONS.WINTER][GROUND.OCEAN_BRINEPOOL].customfish_small_1 = SCHOOL_VERY_COMMON
SCHOOL_WEIGHTS[SEASONS.SPRING][GROUND.OCEAN_BRINEPOOL].customfish_small_1 = SCHOOL_VERY_COMMON
SCHOOL_WEIGHTS[SEASONS.SUMMER][GROUND.OCEAN_BRINEPOOL].customfish_small_1 = SCHOOL_VERY_COMMON

 

The non-commented things I didn't know how to explain.

 

Thanks for reading and I hope this helps you.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...