Skip to content

Commit

Permalink
Implement Fisherman's Heart Quest and supporting tools
Browse files Browse the repository at this point in the history
  • Loading branch information
paladindamarus committed Sep 11, 2024
1 parent 7a46bb1 commit 432a726
Show file tree
Hide file tree
Showing 17 changed files with 755 additions and 2 deletions.
53 changes: 53 additions & 0 deletions scripts/commands/getfishhistory.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
-----------------------------------
-- func: getFishHistory
-- desc: Prints the history stats of a given player
-----------------------------------
---@type TCommand
local commandObj = {}

commandObj.cmdprops =
{
permission = 1,
parameters = 's'
}

commandObj.onTrigger = function(player, target)
-- validate target
local targ
if target ~= nil then
targ = GetPlayerByName(target)
else
targ = player:getCursorTarget()
end

if targ == nil then
if target ~= nil then
player:printToPlayer(string.format('Player named %s not found!', target))
return
else
player:printToPlayer('Find a target, either by name or cursor!')
return
end
elseif not targ:isPC() then
player:printToPlayer('Target is not a player!')
return
end

if targ == nil then
return
end

if targ:getFishingStats() == nil then
player:printToPlayer('Unable to retrieve stats from target!')
return
end

local fishStats = targ:getFishingStats() or {}
player:printToPlayer(string.format('Showing Fishing Stats for: %s', targ:getName() or 'Unknown'), xi.msg.channel.SYSTEM_3)
player:printToPlayer(string.format('Lines Cast: %s', fishStats['fishLinesCast'] or 0), xi.msg.channel.SYSTEM_3)
player:printToPlayer(string.format('Fish Caught: %s', fishStats['fishReeled'] or 0), xi.msg.channel.SYSTEM_3)
player:printToPlayer(string.format('Biggest Fish: %s ilms (%s)', fishStats['fishLongestLength'] or 0, fishStats['fishLongestId'] or 0), xi.msg.channel.SYSTEM_3)
player:printToPlayer(string.format('Heaviest Fish: %s ponzes (%s)', fishStats['fishHeaviestWeight'] or 0, fishStats['fishHeaviestId'] or 0), xi.msg.channel.SYSTEM_3)
end

return commandObj
2 changes: 1 addition & 1 deletion scripts/globals/quests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ xi.quest.id =
THE_SAND_CHARM = 8, -- +
A_POTTER_S_PREFERENCE = 9, -- +
THE_OLD_LADY = 10, -- +
FISHERMAN_S_HEART = 11,
FISHERMAN_S_HEART = 11, -- + Converted
DONATE_TO_RECYCLING = 16, -- +
UNDER_THE_SEA = 17, -- +
ONLY_THE_BEST = 18, -- +
Expand Down
147 changes: 147 additions & 0 deletions scripts/quests/otherAreas/Fishermans_Heart.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
-----------------------------------
-- Fisherman's Heart
-- Katsunaga !pos -4.726 -1.148 2.183
-- Log ID: 4, Quest ID: 11
-----------------------------------
local quest = Quest:new(xi.questLog.OTHER_AREAS, xi.quest.id.otherAreas.FISHERMAN_S_HEART)

quest.reward =
{
fame_area = xi.fameArea.WINDURST,
fame = 30,
}

quest.sections =
{
-- Quest available, but fishing rank is 1 and skill < 20
-- (NOTE: Fishing Rank 0 is handled as default action)
{
check = function(player, status, vars)
return
status == xi.questStatus.QUEST_AVAILABLE and
player:getSkillRank(xi.skill.FISHING) >= 1 and -- Must have leveled up to first fishing rank
player:getCharSkillLevel(xi.skill.FISHING) < 200 -- Skill is below 20.0
end,

[xi.zone.MHAURA] =
{
['Katsunaga'] = quest:event(191),
},
},

-- Quest available, skill >= 20, Windurst Fame >= 2
{
check = function(player, status, vars)
return
status == xi.questStatus.QUEST_AVAILABLE and
player:getFameLevel(xi.fameArea.WINDURST) >= 2 and
player:getCharSkillLevel(xi.skill.FISHING) >= 200
end,

[xi.zone.MHAURA] =
{
['Katsunaga'] =
{
onTrigger = function(player, npc)
return quest:progressEvent(192, xi.item.GUGRU_TUNA)
end,
},

onEventFinish =
{
[192] = function(player, csid, option, npc)
quest:begin(player)
end,
},
},
},

-- Quest Accepted
{
check = function(player, status, vars)
return status == xi.questStatus.QUEST_ACCEPTED
end,

[xi.zone.MHAURA] =
{
['Katsunaga'] =
{
onTrigger = function(player, npc)
return quest:progressEvent(194, xi.item.GUGRU_TUNA)
end,

onTrade = function(player, npc, trade)
if npcUtil.tradeHasExactly(trade, xi.item.GUGRU_TUNA) then
local fishingStats = player:getFishingStats() or {}
return quest:progressEvent(193, {
[1] = fishingStats['fishLinesCast'] or 0,
[2] = fishingStats['fishReeled'] or 0,
[3] = fishingStats['fishLongestLength'] or 0,
[4] = fishingStats['fishLongestId'] or 0,
[5] = fishingStats['fishHeaviestWeight'] or 0,
[6] = fishingStats['fishHeaviestId'] or 0,
})
end
end,
},

onEventFinish =
{
[193] = function(player, csid, option, npc)
player:confirmTrade()
quest:complete(player)
end,
},
},
},

-- Quest Complete
{
check = function(player, status, vars)
return status == xi.questStatus.QUEST_COMPLETED
end,

[xi.zone.MHAURA] =
{
['Katsunaga'] =
{
onTrigger = function(player, npc)
return quest:progressEvent(197, player:getFishingCatchCount() or 0) -- Number of fish types caught
end,
},

onEventUpdate =
{
[197] = function(player, csid, option, npc)
if option == 33554432 then
-- 'Catching Fish'
local fishingStats = player:getFishingStats() or {}
player:updateEvent({
[0] = player:getFishingCatchCount(),
[1] = fishingStats['fishLinesCast'] or 0,
[2] = fishingStats['fishReeled'] or 0,
[3] = fishingStats['fishLongestLength'] or 0,
[4] = fishingStats['fishLongestId'] or 0,
[5] = fishingStats['fishHeaviestWeight'] or 0,
[6] = fishingStats['fishHeaviestId'] or 0,
})
elseif option == 0 then
-- 'Types of Fish Caught'
local fishingCatches = player:getFishingCatches() or {}
-- The server sends the client the bitmap data as a series of 32-bit integers
player:updateEvent({
[0] = fishingCatches[0] or 0,
[1] = fishingCatches[1] or 0,
[2] = fishingCatches[2] or 0,
[3] = fishingCatches[3] or 0,
[4] = fishingCatches[4] or 0,
[5] = fishingCatches[5] or 0,
})
end
end,
},
},
},
}

return quest
38 changes: 38 additions & 0 deletions scripts/specs/core/CBaseEntity.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3881,6 +3881,44 @@ end
function CBaseEntity:getHistory(index)
end

--@nodiscard
--@return table
function CBaseEntity:getFishingStats()
end

--@nodiscard
--@return table
function CBaseEntity:getFishingCatches()
end

--@nodiscard
--@return integer
function CBaseEntity:getFishingCatchCount()
end

--@nodiscard
--@param fishId integer
--@param isCaught boolean
--@return nil
function CBaseEntity:setFishCaught(fishId, isCaught)
end

--@nodiscard
--@return nil
function CBaseEntity:clearFishCaught()
end

--@nodiscard
--@return nil
function CBaseEntity:clearFishHistory()
end

--@nodiscard
--@param fishId integer
--@return boolean
function CBaseEntity:hasCaughtFish(fishId)
end

---@nodiscard
---@return table
function CBaseEntity:getChocoboRaisingInfo()
Expand Down
1 change: 1 addition & 0 deletions scripts/zones/Mhaura/DefaultActions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ return {
['Hagain'] = { event = 10002 },
['Itzha_Delavhitta'] = { event = 900 },
['Jikka-Abukka'] = { event = 850 },
['Katsunaga'] = { event = 190 },
['Kotan-Purutan'] = { event = 140 },
['Kupupu'] = { event = 800 },
['Lacia'] = { event = 10021 },
Expand Down
1 change: 0 additions & 1 deletion scripts/zones/Mhaura/npcs/Katsunaga.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ entity.onTrade = function(player, npc, trade)
end

entity.onTrigger = function(player, npc)
player:startEvent(190)
end

entity.onEventUpdate = function(player, csid, option, npc)
Expand Down
16 changes: 16 additions & 0 deletions sql/char_fishing_history.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- --------------------------------------------------------
-- Add history for player fishing data
-- --------------------------------------------------------

DROP TABLE IF EXISTS `char_fishing_history`;
CREATE TABLE IF NOT EXISTS `char_fishing_history` (
`charid` int(10) unsigned NOT NULL,
`fish_catches` blob,
`fish_linescast` int(6) unsigned NOT NULL DEFAULT 0,
`fish_reeled` int(5) unsigned NOT NULL DEFAULT 0,
`fish_longest` int(4) unsigned NOT NULL DEFAULT 0,
`fish_longest_id` int(4) unsigned NOT NULL DEFAULT 0,
`fish_heaviest` int(4) unsigned NOT NULL DEFAULT 0,
`fish_heaviest_id` int(4) unsigned NOT NULL DEFAULT 0,
PRIMARY KEY (`charid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Loading

0 comments on commit 432a726

Please sign in to comment.