Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions scripts/effects/mounted.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,26 @@ effectObject.onEffectGain = function(target, effect)
local mountId = effect:getPower()
-- Retail sends a music change packet (packet ID 0x5F) in both cases.

local music = 0
local animation = xi.animation.NONE

if
mountId == xi.mount.CHOCOBO or
mountId == xi.mount.NOBLE_CHOCOBO
then
target:changeMusic(xi.musicSlot.MOUNT, 212)
music = 212
animation = xi.animation.CHOCOBO
else
target:changeMusic(xi.musicSlot.MOUNT, 84)
music = 84
animation = xi.animation.MOUNT
end

if not target:isInEvent() then
local musicEnd = target:getCharVar('[CHOCOBO]MusicEnd')
if musicEnd == 0 or GetSystemTime() < musicEnd then
target:changeMusic(xi.musicSlot.MOUNT, music)
end

target:setAnimation(animation)
end

Expand All @@ -35,10 +41,20 @@ effectObject.onEffectGain = function(target, effect)
attohwaChasmGlobal.removeMimeoKIs(target)
end

-- Tick timer is reset on zone
effectObject.onEffectTick = function(target, effect)
local musicEnd = target:getCharVar('[CHOCOBO]MusicEnd')

if GetSystemTime() >= musicEnd then
target:changeMusic(xi.musicSlot.MOUNT, 0)
target:setCharVar('[CHOCOBO]MusicEnd', -1) -- Song played and finished.
effect:setTick(0)
end
end

effectObject.onEffectLose = function(target, effect)
target:setCharVar('[CHOCOBO]MusicEnd', 0)

if not target:isInEvent() then -- Paranoia safety check
target:setAnimation(xi.animation.NONE)
end
Expand Down
6 changes: 5 additions & 1 deletion scripts/globals/chocobo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ xi.chocobo.renterOnEventFinish = function(player, csid, option, eventSucceed)
end
end

player:addStatusEffect(xi.effect.MOUNTED, { duration = duration, origin = player, silent = true })
player:setCharVar('[CHOCOBO]MusicEnd', GetSystemTime() + 390)
player:addStatusEffect(xi.effect.MOUNTED, { duration = duration, origin = player, silent = true, tick = 15 })

-- Renting a chocobo force despawns every type of pets
-- Note: This does not honor cooldown reductions offered otherwise when dismissing pets with full life.
Expand All @@ -249,6 +250,9 @@ xi.chocobo.renterOnEventFinish = function(player, csid, option, eventSucceed)

if info.pos then
player:setPos(unpack(info.pos))
else
-- Set chocobo music if not renting from a city
player:changeMusic(xi.musicSlot.MOUNT, 212)
end
elseif chocoGame ~= 0 and csid == eventSucceed then
player:despawnPet()
Expand Down
13 changes: 12 additions & 1 deletion src/map/packets/s2c/0x00a_login.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,18 @@ GP_SERV_COMMAND_LOGIN::GP_SERV_COMMAND_LOGIN(CCharEntity* PChar, const EventInfo
packet.MusicNum[1] = PChar->PInstance ? PChar->PInstance->GetBackgroundMusicNight() : PChar->loc.zone->GetBackgroundMusicNight();
packet.MusicNum[2] = PChar->PInstance ? PChar->PInstance->GetSoloBattleMusic() : PChar->loc.zone->GetSoloBattleMusic();
packet.MusicNum[3] = PChar->PInstance ? PChar->PInstance->GetPartyBattleMusic() : PChar->loc.zone->GetPartyBattleMusic();
packet.MusicNum[4] = PChar->animation == xi::Animation::Mount ? 0x54 : 0xD4;
if (PChar->animation == xi::Animation::Chocobo && PChar->getCharVar("[CHOCOBO]MusicEnd") != -1) // Music has not played to completion yet.
{
packet.MusicNum[4] = 0xD4;
}
else if (PChar->animation == xi::Animation::Mount)
{
packet.MusicNum[4] = 0x54;
}
else
{
packet.MusicNum[4] = 0;
}

const auto csid = currentEvent->eventId;
if (csid != -1)
Expand Down
Loading