Skip to content

Commit

Permalink
new ways to fish
Browse files Browse the repository at this point in the history
and new fish icons
  • Loading branch information
BrunoSupremo committed Jul 4, 2022
1 parent 2a9726b commit 4bb9550
Show file tree
Hide file tree
Showing 26 changed files with 407 additions and 28 deletions.
6 changes: 3 additions & 3 deletions ai/actions/fisher/go_fish_action.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
--I do not give consent to copy this
local GoFish = class()

GoFish.name = 'go to a dock to fish'
GoFish.name = 'go to a fishing_spot to fish'
GoFish.does = 'archipelago_biome:go_fish'
GoFish.status_text_key = 'archipelago_biome:ai.actions.status_text.fishing'
GoFish.args = { }
Expand All @@ -21,6 +20,7 @@ function find_a_fishing_spot(ai_entity)
end

local function rate_fishing_spot(entity)
--take entity type (zone, boat or dock) and distance into consideration
local rng = _radiant.math.get_default_rng()
return rng:get_real(0, 1)
end
Expand All @@ -42,7 +42,7 @@ return ai:create_compound_action(GoFish)
:execute('stonehearth:find_best_reachable_entity_by_type', {
filter_fn = ai.CALL(find_a_fishing_spot, ai.ENTITY),
rating_fn = rate_fishing_spot,
description = 'find a dock'
description = 'find a fishing_spot'
})
:execute('stonehearth:goto_entity', {
entity = ai.PREV.item
Expand Down
19 changes: 16 additions & 3 deletions ai/actions/fisher/turn_to_face_water_action.lua
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
local Entity = _radiant.om.Entity
local TurnToFaceWater = class()
local rng = _radiant.math.get_default_rng()

TurnToFaceWater.name = 'correct rotation facing the water'
TurnToFaceWater.does = 'archipelago_biome:turn_to_face_water'
TurnToFaceWater.args = {
dock = Entity
dock = Entity
}
TurnToFaceWater.version = 2
TurnToFaceWater.priority = 1

function TurnToFaceWater:run(ai, entity, args)
local face = radiant.entities.get_facing(args.dock)
radiant.entities.turn_to(entity, face)
if radiant.entities.get_posture(entity) == "stonehearth:in_boat" then
radiant.entities.turn_to(entity, rng:get_int(0,360))
else
local face = 0
local fisher_field_component = args.dock:get_component("archipelago_biome:fisher_field")
if fisher_field_component then
local water_location = fisher_field_component:get_water_direction(radiant.entities.get_world_grid_location(entity))
entity:get_component('mob'):turn_to_face_point(water_location)
face = radiant.entities.get_facing(entity)
else
face = radiant.entities.get_facing(args.dock)
end
radiant.entities.turn_to(entity, face+rng:get_int(-35,35))
end
end

return TurnToFaceWater
6 changes: 3 additions & 3 deletions archipelago_biome_server.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
archipelago_biome = {}
print("Archipelago Biome Mod version 22.6.13")
print("Archipelago Biome Mod version 22.7.4")

--[[
fisher village
spawn whale, maybe from turtle rig. or as a fancy and decorated landmark
wave effect for storm weather
fish anywhere near water, docks will be just a prefered place
rework pirate hat
Bugs:
Expand Down
137 changes: 137 additions & 0 deletions call_handlers/fishing_call_handler.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
local Color4 = _radiant.csg.Color4
local Point3 = _radiant.csg.Point3
local Cube3 = _radiant.csg.Cube3

local validator = radiant.validator

local FishingCallHandler = class()

function FishingCallHandler._custom_is_valid_location(self_variable, brick)
--i had to hack into this stupid function because it was the only way to make it work 😡
if not brick then
return false
end

if radiant.terrain.is_blocked(brick) then
return false
end
if not radiant.terrain.is_supported(brick) then
return false
end
local entities = radiant.terrain.get_entities_at_point(brick)
for _, entity in pairs(entities) do
if not self_variable._can_contain_entity_filter_fn(entity, self_variable) then
return false
end
end
return FishingCallHandler.has_water_below(brick)
end

function FishingCallHandler:choose_new_fish_location(session, response)
stonehearth.selection:select_xz_region("fish_zone")
:use_designation_marquee(Color4(129, 192, 165, 255))
:set_cursor('archipelago_biome:cursors:zone_fish')
:set_invalid_cursor('archipelago_biome:cursors:zone_fish_invalid')
:require_unblocked(true)
:require_supported(true)
:allow_unselectable_support_entities(true)
:set_can_contain_entity_filter(function(entity)
if radiant.entities.get_entity_data(entity, 'stonehearth:designation') then
return false
end
if entity:get_component('terrain') then
return false
end
return true
end)
:set_find_support_filter(function(result, select_xz_region)
select_xz_region._is_valid_location = FishingCallHandler._custom_is_valid_location

local entity = result.entity
if not entity then
return stonehearth.selection.FILTER_IGNORE
end
local rcs = entity:get_component('region_collision_shape')
local region_collision_type = rcs and rcs:get_region_collision_type()
if region_collision_type == _radiant.om.RegionCollisionShape.NONE then
return stonehearth.selection.FILTER_IGNORE
end

if result.brick then
return true
end
return stonehearth.selection.FILTER_IGNORE
end)

:done(function(selector, box)
local size = {
x = box.max.x - box.min.x,
y = box.max.z - box.min.z,
}
_radiant.call('archipelago_biome:create_new_field', box.min, size)
:done(function(r)
response:resolve({ field = r.field })
end)
:always(function()
selector:destroy()
end)
end)
:fail(function(selector)
selector:destroy()
response:reject('no region')
end)
:go()
end

function FishingCallHandler.has_water_below(origin)
return
FishingCallHandler._get_water_below(origin-Point3.unit_z) or
FishingCallHandler._get_water_below(origin+Point3.unit_z) or
FishingCallHandler._get_water_below(origin-Point3.unit_x) or
FishingCallHandler._get_water_below(origin+Point3.unit_x)
end

function FishingCallHandler._get_water_below(neighbor_point)
local ground_point = radiant.terrain.get_standable_point(neighbor_point)
local entities_present = radiant.terrain.get_entities_at_point(ground_point)

for id, entity in pairs(entities_present) do
local water_component = entity:get_component('stonehearth:water')
if water_component then
return true
end
end
return false
end

function FishingCallHandler:create_new_field(session, response, location, size)
validator.expect_argument_types({'Point3', 'table'}, location, size)

local entity = radiant.entities.create_entity('archipelago_biome:fisher:field', { owner = session.player_id })
radiant.terrain.place_entity(entity, location)

local shape = Cube3(Point3.zero, Point3(size.x, 1, size.y))
entity:add_component('region_collision_shape')
:set_region_collision_type(_radiant.om.RegionCollisionShape.NONE)
:set_region(_radiant.sim.alloc_region3())
:get_region():modify(function(cursor)
cursor:add_unique_cube(shape)
end)
entity:add_component('destination')
:set_region(_radiant.sim.alloc_region3())
:get_region():modify(function(cursor)
cursor:add_unique_cube(shape)
end)
entity:get_component('destination')
:set_adjacent(_radiant.sim.alloc_region3())
:get_adjacent():modify(function(cursor)
cursor:add_unique_cube(shape)
end)

local fisher_field = entity:get_component('archipelago_biome:fisher_field')
fisher_field:set_size(size.x,size.y)

return { field = entity }
end

return FishingCallHandler
31 changes: 31 additions & 0 deletions components/boat_dock/boat_dock.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ end
function ArchipelagoBoatDock:initialize()
self._sv.platform = nil
self._sv.other_dock = nil
self._sv.dock_spots = {}
self._sv._effect_overlay = nil
end

Expand All @@ -26,6 +27,7 @@ function ArchipelagoBoatDock:activate()
self._removed_from_world_listener = radiant.events.listen(self._entity, 'stonehearth:on_removed_from_world', function()
self:destroy_platform()
self:destroy_other_dock()
self:destroy_fishing_spot()
if self._sv._effect_overlay then
self._sv._effect_overlay:stop()
self._sv._effect_overlay = nil
Expand Down Expand Up @@ -54,12 +56,29 @@ function ArchipelagoBoatDock:create_connections()
if other_side then
self:create_platform(other_side)
self:create_destination_dock(other_side)
self:create_fishing_spot(radiant.entities.get_world_grid_location(self._entity), other_side)
else
self._sv._effect_overlay = radiant.effects.run_effect(self._entity, "archipelago_biome:effects:overlay:no_connection", nil, nil, { playerColor = radiant.entities.get_player_color(self._entity) })
end
end
end

function ArchipelagoBoatDock:create_fishing_spot(this_side, other_side)
local total_distance = this_side:distance_to(other_side)
if total_distance > 15 then
local middle_point = (this_side+other_side)/2
local dock_spot = radiant.entities.create_entity("archipelago_biome:decoration:dock_spot",
{owner = self._entity:get_player_id()})
radiant.terrain.place_entity_at_exact_location(dock_spot,
middle_point +Point3.unit_y*2)

table.insert(self._sv.dock_spots, dock_spot)

self:create_fishing_spot(middle_point, this_side)
self:create_fishing_spot(middle_point, other_side)
end
end

function ArchipelagoBoatDock:find_other_side()
local mob = self._entity:get_component('mob')
local facing = mob:get_facing()
Expand Down Expand Up @@ -153,9 +172,21 @@ function ArchipelagoBoatDock:destroy_other_dock()
end
end

function ArchipelagoBoatDock:destroy_fishing_spot()
if self._sv.dock_spots then
for i, dock_spot in ipairs(self._sv.dock_spots) do
if dock_spot and dock_spot:is_valid() then
radiant.entities.destroy_entity(dock_spot)
end
end
self._sv.dock_spots = {}
end
end

function ArchipelagoBoatDock:destroy()
self:destroy_platform()
self:destroy_other_dock()
self:destroy_fishing_spot()

if self._sensor_trace then
self._sensor_trace:destroy()
Expand Down
39 changes: 39 additions & 0 deletions components/fisher_field/fisher_field.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
local FisherFieldComponent = class()
local Point2 = _radiant.csg.Point2
local Point3 = _radiant.csg.Point3

function FisherFieldComponent:initialize()
self._sv.size = nil
end

function FisherFieldComponent:create()
self._sv.size = Point2.zero
end

function FisherFieldComponent:set_size(x, z)
self._sv.size = Point2(x, z)
self.__saved_variables:mark_changed()
end

function FisherFieldComponent:get_water_direction(origin)
return
FisherFieldComponent:_get_water_below(origin-Point3.unit_z) or
FisherFieldComponent:_get_water_below(origin+Point3.unit_z) or
FisherFieldComponent:_get_water_below(origin-Point3.unit_x) or
FisherFieldComponent:_get_water_below(origin+Point3.unit_x)
end

function FisherFieldComponent:_get_water_below(neighbor_point)
local ground_point = radiant.terrain.get_standable_point(neighbor_point)
local entities_present = radiant.terrain.get_entities_at_point(ground_point)

for id, entity in pairs(entities_present) do
local water_component = entity:get_component('stonehearth:water')
if water_component then
return neighbor_point
end
end
return false
end

return FisherFieldComponent
Binary file modified data/commands/archer_arrows/fish_arrows.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/cursors/zone_fish.cur
Binary file not shown.
Binary file added data/cursors/zone_fish_invalid.cur
Binary file not shown.
9 changes: 0 additions & 9 deletions data/fishing/fishing.json
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,6 @@
"effort":100,
"xp":10
},
"ice_cube":{
"alias":"archipelago_biome:resources:ice_cube",
"weight":1,
"is_biome":[
"stonehearth:biome:arctic"
],
"effort":10,
"xp":1
},
"tropical_fish":{
"alias":"archipelago_biome:food:tropical_fish",
"weight":20,
Expand Down
Binary file modified data/traits/passion_fisher/passion_fisher_trait.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions data/ui/start_menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,19 @@
"hotkey": ""
}
}
},
"zone_menu": {
"items": {
"create_fish": {
"name": "i18n(archipelago_biome:ui.game.menu.zone_menu.items.create_fish.display_name)",
"description": "i18n(archipelago_biome:ui.game.menu.zone_menu.items.create_fish.description)",
"required_job": "archipelago_biome:jobs:fisher",
"required_job_text": "i18n(archipelago_biome:ui.game.menu.zone_menu.items.create_fish.required_job_text)",
"class": "button",
"icon": "/archipelago_biome/ui/game/start_menu/images/zone_fish.png",
"sticky": true,
"hotkey_action": "zone:fish"
}
}
}
}
Binary file modified jobs/archer/archer_buffs/fish_in_face.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions jobs/fisher/field/field.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"type": "entity",
"components": {
"stonehearth:defense_zone": {},
"archipelago_biome:fisher_field": {},
"stonehearth:commands": {
"commands": [
"stonehearth:commands:destroy_item"
]
}
},
"entity_data": {
"archipelago_biome:fishing_spot":{},
"stonehearth:designation": {
"allow_placed_items": false
},
"stonehearth:item": {
"clearable": false
},
"stonehearth:catalog": {
"display_name": "i18n(archipelago_biome:jobs.fisher.field.display_name)",
"description": "i18n(archipelago_biome:jobs.fisher.field.description)"
}
}
}
Loading

0 comments on commit 4bb9550

Please sign in to comment.