Skip to content

Commit

Permalink
make work with LSB
Browse files Browse the repository at this point in the history
  • Loading branch information
KnowOne134 committed Jan 29, 2025
1 parent 56e9d31 commit 73a8dc5
Show file tree
Hide file tree
Showing 14 changed files with 92 additions and 132 deletions.
112 changes: 51 additions & 61 deletions scripts/globals/dark_rider.lua
Original file line number Diff line number Diff line change
@@ -1,35 +1,41 @@
require('scripts/globals/zone')
require('scripts/globals/keyitems')
require('scripts/globals/npc_util')

darkRider = {}
darkRider.MAX_HOOFPRINTS_PER_DAY = 2
-----------------------------------
-- Warhorse Hoofprint global file
-----------------------------------
local bhaflauID = zones[xi.zone.BHAFLAU_THICKETS]
local caedarvaID = zones[xi.zone.CAEDARVA_MIRE]
local mountID = zones[xi.zone.MOUNT_ZHAYOLM]
local wajaomID = zones[xi.zone.WAJAOM_WOODLANDS]
-----------------------------------

xi = xi or {}
xi.darkRider = {}
xi.darkRider.MAX_HOOFPRINTS_PER_DAY = 2

local hoofprintIds = {
[dsp.zone.WAJAOM_WOODLANDS] = {
16986599,
16986600,
16986601,
[xi.zone.WAJAOM_WOODLANDS] = {
wajaomID.npc.HOOFPRINT,
wajaomID.npc.HOOFPRINT + 1,
wajaomID.npc.HOOFPRINT + 2,
},
[dsp.zone.BHAFLAU_THICKETS] = {
16990560,
16990561,
16990562,
[xi.zone.BHAFLAU_THICKETS] = {
bhaflauID.npc.HOOFPRINT,
bhaflauID.npc.HOOFPRINT + 1,
bhaflauID.npc.HOOFPRINT + 2,
},
[dsp.zone.MOUNT_ZHAYOLM] = {
17027510,
17027511,
17027512,
[xi.zone.MOUNT_ZHAYOLM] = {
mountID.npc.HOOFPRINT,
mountID.npc.HOOFPRINT + 1,
mountID.npc.HOOFPRINT + 2,
},
[dsp.zone.CAEDARVA_MIRE] = {
17101242,
17101243,
17101244,
[xi.zone.CAEDARVA_MIRE] = {
caedarvaID.npc.HOOFPRINT,
caedarvaID.npc.HOOFPRINT + 1,
caedarvaID.npc.HOOFPRINT + 2,
},
}

local hoofprintPositions = {
[dsp.zone.WAJAOM_WOODLANDS] = {
[xi.zone.WAJAOM_WOODLANDS] = {
{ 400, -24, 2 }, -- K-9
{ 345, -18, -41 }, -- J-9 E edge
{ 221, -18, -63 }, -- J-9 W edge
Expand All @@ -52,7 +58,7 @@ local hoofprintPositions = {
{ -360, -32, 680 }, -- F-5 behind tower
{ 105, -26, 320 }, -- I-7
},
[dsp.zone.BHAFLAU_THICKETS] = {
[xi.zone.BHAFLAU_THICKETS] = {
{ 447, -18, 266 }, -- I-8
{ 425, -20.25, 239 }, -- I-9
{ 298, -8.5, 211 }, -- H-8 center of open area
Expand All @@ -66,7 +72,7 @@ local hoofprintPositions = {
{ 336, -18, 380 }, -- H-7 SE corner
{ 379, -17, 380 }, -- I-7 in tunnel
},
[dsp.zone.MOUNT_ZHAYOLM] = {
[xi.zone.MOUNT_ZHAYOLM] = {
{ -401, -14.5, 374 }, -- D/E-6
{ -458, -13, 357 }, -- D-6
{ -350, -14, 330 }, -- E-6 near manhole cover
Expand All @@ -76,7 +82,7 @@ local hoofprintPositions = {
{ 598, -14, -4 }, -- K-8
{ 762, -14.5, -55 }, -- L-8
},
[dsp.zone.CAEDARVA_MIRE] = {
[xi.zone.CAEDARVA_MIRE] = {
{ -600, 4.5, -100 }, -- G-9 (2nd map)
{ 212, 0, -533 }, -- I-9
{ 280, -16, -357 }, -- J-8
Expand All @@ -87,17 +93,13 @@ local hoofprintPositions = {
},
}


local hoofprintZones = {}
for zoneId, _ in pairs(hoofprintPositions) do
hoofprintZones[#hoofprintZones+1] = zoneId
hoofprintZones[#hoofprintZones + 1] = zoneId
end

darkRider.zone = {}

-- Adds hoofprints if the current zone is the one picked for that day
function darkRider.zone.addHoofprints(zone)

xi.darkRider.addHoofprints = function(zone)
-- We need a random number that's the same across servers,
-- so we add a bunch of vanadiel time values, which will be the same across servers, but should
-- result in a seemingly "random" area and positions each time when combined with the modulo operator.
Expand All @@ -113,70 +115,58 @@ function darkRider.zone.addHoofprints(zone)
local possiblePositions = utils.shuffle(hoofprintPositions[zone:getID()])
local possibleHoofprintIds = hoofprintIds[zone:getID()]

local daysSinceEpoch = VanadielDaySinceEpoch()
local currentHoofprintCount = zone:getLocalVar("HoofprintCount")
local daysSinceEpoch = VanadielUniqueDay()
local currentHoofprintCount = zone:getLocalVar('HoofprintCount')

local hoofprintsToAdd = math.fmod(fakeRandomNum, darkRider.MAX_HOOFPRINTS_PER_DAY) + 1
local hoofprintsToAdd = math.fmod(fakeRandomNum, xi.darkRider.MAX_HOOFPRINTS_PER_DAY) + 1

for i = 1, #possibleHoofprintIds do
if hoofprintsToAdd <= 0 then
break
end

local hoofprint = GetNPCByID(possibleHoofprintIds[i])
if hoofprint ~= nil and hoofprint:getStatus() ~= dsp.status.NORMAL then
if hoofprint ~= nil and hoofprint:getStatus() ~= xi.status.NORMAL then
hoofprint:setPos(possiblePositions[i])
hoofprint:setStatus(dsp.status.NORMAL)
hoofprint:untargetable(false)
hoofprint:setLocalVar("DaysSinceEpoch", daysSinceEpoch)
hoofprint:setStatus(xi.status.NORMAL)
hoofprint:setLocalVar('DaysSinceEpoch', daysSinceEpoch)
currentHoofprintCount = currentHoofprintCount + 1
hoofprintsToAdd = hoofprintsToAdd - 1
else
printf("Did not find hoofprint with ID: %d", possibleHoofprintIds[i])
printf('Did not find hoofprint with ID: %d', possibleHoofprintIds[i])
end
end

zone:setLocalVar("HoofprintCount", currentHoofprintCount)
zone:setLocalVar('HoofprintCount', currentHoofprintCount)
end

-- Remove hoofprints at 06:00 from previous day
function darkRider.zone.onGameHour(zone)
xi.darkRider.onGameHour = function(zone)
if VanadielHour() ~= 6 then
return
end

local hoofprintCount = zone:getLocalVar("HoofprintCount")
local hoofprintCount = zone:getLocalVar('HoofprintCount')
if hoofprintCount == 0 then
return
end

local daysSinceEpoch = VanadielDaySinceEpoch()
local daysSinceEpoch = VanadielUniqueDay()
local possibleHoofprintIds = hoofprintIds[zone:getID()]
for i = 1, #possibleHoofprintIds do
local hoofprint = GetNPCByID(possibleHoofprintIds[i])

-- Hide hoofprint if it was shown in a previous day
if hoofprint ~= nil and
hoofprint:getStatus() == dsp.status.NORMAL and
hoofprint:getLocalVar("DaysSinceEpoch") < daysSinceEpoch
if
hoofprint ~= nil and
hoofprint:getStatus() == xi.status.NORMAL and
hoofprint:getLocalVar('DaysSinceEpoch') < daysSinceEpoch
then
hoofprint:setStatus(dsp.status.DISAPPEAR)
hoofprint:untargetable(true)
hoofprint:setStatus(xi.status.DISAPPEAR)
hoofprint:resetLocalVars()
hoofprintCount = hoofprintCount - 1
end
end

zone:setLocalVar("HoofprintCount", hoofprintCount)
end


function darkRider.hoofprintTrigger(player, npc)
if not player:hasKeyItem(dsp.ki.SP_WILDCAT_BADGE) then
if player:hasKeyItem(dsp.ki.DARK_RIDER_HOOFPRINT) or player:getVar("[Assault]SP") == 0 then
return
end

npcUtil.giveKeyItem(player, dsp.ki.DARK_RIDER_HOOFPRINT)
end
zone:setLocalVar('HoofprintCount', hoofprintCount)
end
1 change: 1 addition & 0 deletions scripts/zones/Bhaflau_Thickets/IDs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ zones[xi.zone.BHAFLAU_THICKETS] =
npc =
{
HARVESTING = GetTableOfIDs('Harvesting_Point'),
HOOFPRINT = GetFirstID('Warhorse_Hoofprint'),
},
}

Expand Down
11 changes: 5 additions & 6 deletions scripts/zones/Bhaflau_Thickets/Zone.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ zoneObject.onInitialize = function(zone)
GetMobByID(ID.mob.HARVESTMAN):setRespawnTime(math.random(900, 10800))

xi.helm.initZone(zone, xi.helmType.HARVESTING)
darkRider.zone.addHoofprints(zone)
xi.darkRider.addHoofprints(zone)
end

zoneObject.onZoneIn = function(player, prevZone)
Expand All @@ -38,12 +38,11 @@ zoneObject.afterZoneIn = function(player)
end

zoneObject.onGameHour = function(zone)
updateZoneDigItems(zone)
darkRider.zone.onGameHour(zone)
end
xi.darkRider.onGameHour(zone)

zoneObjectonGameDay = function(zone)
darkRider.zone.addHoofprints(zone)
if VanadielHour() == 0 then
xi.darkRider.addHoofprints(zone)
end
end

zoneObject.onEventUpdate = function(player, csid, option, npc)
Expand Down
9 changes: 0 additions & 9 deletions scripts/zones/Bhaflau_Thickets/npcs/Warhorse_Hoofprint.lua

This file was deleted.

1 change: 1 addition & 0 deletions scripts/zones/Caedarva_Mire/IDs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ zones[xi.zone.CAEDARVA_MIRE] =
LOGGING = GetTableOfIDs('Logging_Point'),
RUNIC_PORTAL_AZOUPH = GetFirstID('Runic_Portal_Azouph'),
RUNIC_PORTAL_DVUCCA = GetFirstID('Runic_Portal_Dvucca'),
HOOFPRINT = GetFirstID('Warhorse_Hoofprint'),
},
}

Expand Down
12 changes: 6 additions & 6 deletions scripts/zones/Caedarva_Mire/Zone.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ zoneObject.onInitialize = function(zone)
GetMobByID(ID.mob.KHIMAIRA):setRespawnTime(math.random(12, 36) * 3600) -- 12 to 36 hours after maintenance, in 1-hour increments

xi.helm.initZone(zone, xi.helmType.LOGGING)
darkRider.zone.addHoofprints(zone)
xi.darkRider.addHoofprints(zone)
end

zoneObject.onZoneIn = function(player, prevZone)
Expand Down Expand Up @@ -47,12 +47,12 @@ end
zoneObject.onTriggerAreaEnter = function(player, triggerArea)
end

zoneObject.onGameDay = function(zone)
darkRider.zone.addHoofprints(zone)
end

zoneObject.onGameHour = function(zone)
darkRider.zone.onGameHour(zone)
xi.darkRider.onGameHour(zone)

if VanadielHour() == 0 then
xi.darkRider.addHoofprints(zone)
end
end

zoneObject.onEventUpdate = function(player, csid, option, npc)
Expand Down
9 changes: 0 additions & 9 deletions scripts/zones/Caedarva_Mire/npcs/Warhorse_Hoofprint.lua

This file was deleted.

3 changes: 2 additions & 1 deletion scripts/zones/Mount_Zhayolm/IDs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ zones[xi.zone.MOUNT_ZHAYOLM] =
},
npc =
{
MINING = GetTableOfIDs('Mining_Point'),
MINING = GetTableOfIDs('Mining_Point'),
HOOFPRINT = GetFirstID('Warhorse_Hoofprint'),
},
}

Expand Down
11 changes: 7 additions & 4 deletions scripts/zones/Mount_Zhayolm/Zone.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ zoneObject.onInitialize = function(zone)
GetMobByID(ID.mob.CERBERUS):setRespawnTime(math.random(12, 36) * 3600)

xi.helm.initZone(zone, xi.helmType.MINING)
darkRider.zone.addHoofprints(zone)
xi.darkRider.addHoofprints(zone)
end

zoneObject.onZoneIn = function(player, prevZone)
Expand All @@ -37,13 +37,16 @@ end
zoneObject.onTriggerAreaEnter = function(player, triggerArea)
end

zoneObject.onGameDay = function(zone)
zoneObject.onGameDay = function()
xi.apkallu.updateHate(xi.zone.MOUNT_ZHAYOLM, -3)
darkRider.zone.addHoofprints(zone)
end

zoneObject.onGameHour = function(zone)
darkRider.zone.onGameHour(zone)
xi.darkRider.onGameHour(zone)

if VanadielHour() == 0 then
xi.darkRider.addHoofprints(zone)
end
end

zoneObject.onEventUpdate = function(player, csid, option, npc)
Expand Down
9 changes: 0 additions & 9 deletions scripts/zones/Mount_Zhayolm/npcs/Warhorse_Hoofprint.lua

This file was deleted.

1 change: 1 addition & 0 deletions scripts/zones/Wajaom_Woodlands/IDs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ zones[xi.zone.WAJAOM_WOODLANDS] =
npc =
{
HARVESTING = GetTableOfIDs('Harvesting_Point'),
HOOFPRINT = GetFirstID('Warhorse_Hoofprint'),
},
}

Expand Down
12 changes: 6 additions & 6 deletions scripts/zones/Wajaom_Woodlands/Zone.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local zoneObject = {}
zoneObject.onInitialize = function(zone)
xi.helm.initZone(zone, xi.helmType.HARVESTING)
xi.chocobo.initZone(zone)
darkRider.zone.addHoofprints(zone)
xi.darkRider.addHoofprints(zone)
end

zoneObject.onZoneIn = function(player, prevZone)
Expand All @@ -27,12 +27,12 @@ end
zoneObject.onTriggerAreaEnter = function(player, triggerArea)
end

zoneObject.onGameDay = function(zone)
darkRider.zone.addHoofprints(zone)
end

zoneObject.onGameHour = function(zone)
darkRider.zone.onGameHour(zone)
xi.darkRider.onGameHour(zone)

if VanadielHour() == 0 then
xi.darkRider.addHoofprints(zone)
end
end

zoneObject.onEventUpdate = function(player, csid, option, npc)
Expand Down
9 changes: 0 additions & 9 deletions scripts/zones/Wajaom_Woodlands/npcs/Warhorse_Hoofprint.lua

This file was deleted.

Loading

0 comments on commit 73a8dc5

Please sign in to comment.