Skip to content

Commit

Permalink
implement A Generous General
Browse files Browse the repository at this point in the history
Co-authored-by: jamesbradleym <[email protected]>
Co-authored-by: hookstar <[email protected]>
  • Loading branch information
jamesbradleym and hooksta4 committed May 31, 2024
1 parent 1242529 commit b16baed
Show file tree
Hide file tree
Showing 8 changed files with 395 additions and 3 deletions.
290 changes: 290 additions & 0 deletions scripts/quests/otherAreas/A_Generous_General.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,290 @@
-----------------------------------
-- A Generous General
-----------------------------------
-- Log ID: 4, Quest ID: 109
-----------------------------------
-- Oldton zone !pos 566 -12 685 106
-- Faulpie !gotoid 17719379
-- iron box !pos -141 7 157 11
-----------------------------------
local oldtonID = zones[xi.zone.OLDTON_MOVALPOLOS]
local southernSanDoriaID = zones[xi.zone.SOUTHERN_SAN_DORIA]
-----------------------------------
local quest = Quest:new(xi.questLog.OTHER_AREAS, xi.quest.id.otherAreas.A_GENEROUS_GENERAL)

local spawnedMobs =
{
oldtonID.mob.GENEROUS_GENERAL_OFFSET,
oldtonID.mob.GENEROUS_GENERAL_OFFSET + 1,
oldtonID.mob.GENEROUS_GENERAL_OFFSET + 2,
oldtonID.mob.GENEROUS_GENERAL_OFFSET + 3,
oldtonID.mob.GENEROUS_GENERAL_OFFSET + 4,
oldtonID.mob.GENEROUS_GENERAL_OFFSET + 5,
oldtonID.mob.GENEROUS_GENERAL_OFFSET + 6,
}

quest.reward =
{
item = xi.item.CHOPLIXS_COIF,
title = xi.title.MOBLIN_KINSMAN,
}

quest.sections =
{
{
check = function(player, status, vars)
return status == xi.questStatus.QUEST_AVAILABLE and
player:getQuestStatus(xi.questLog.OTHER_AREAS, xi.quest.id.otherAreas.AN_AFFABLE_ADAMANTKING) ~= xi.questStatus.QUEST_ACCEPTED and
player:getQuestStatus(xi.questLog.OTHER_AREAS, xi.quest.id.otherAreas.AN_UNDERSTANDING_OVERLORD) ~= xi.questStatus.QUEST_ACCEPTED and
player:getQuestStatus(xi.questLog.OTHER_AREAS, xi.quest.id.otherAreas.A_MORAL_MANIFEST) ~= xi.questStatus.QUEST_ACCEPTED and
player:getVar('BstHeadGearQuest_Conquest') < NextConquestTally() and
not player:hasItem(xi.item.CHOPLIXS_COIF) and
player:getMainLvl() >= 60
end,

[xi.zone.OLDTON_MOVALPOLOS] =
{
onZoneIn =
{
function(player, prevZone)
local pos = player:getPos()
if
pos.x >= -323.0 and
pos.y >= 6.0 and
pos.z >= -261.0 and
pos.x <= -321.0 and
pos.y <= 9.0 and
pos.z <= -258.0
then
return 60
end
end,
},

onEventFinish =
{
[60] = function(player, csid, option, npc)
if option == 0 then
quest:begin(player) -- begin quest
elseif option == 1 then
player:setVar('BstHeadGearQuest_Conquest', NextConquestTally()) -- if player declines they must wait until next conquest tally
end
end,
},
},
},

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

[xi.zone.SOUTHERN_SAN_DORIA] =
{
['Faulpie'] =
{
onTrigger = function(player, npc)
local prog = quest:getVar(player, 'Prog')
local partsWait = quest:getVar(player, 'partsWait')
if prog == 0 then
return quest:progressEvent(770) -- tells player what items are needed
elseif prog == 1 then
return quest:event(771):importantOnce() -- reminder to get buffalo hide and sheep leather or cancel quest
elseif
prog >= 2 and
partsWait ~= 0 -- player is currently waiting for parts
then
if partsWait <= os.time() then
return quest:progressEvent(775) -- ready to go
else
return quest:event(773):importantOnce() -- player must wait till vana midnight and zone(era only)
end
elseif prog == 3 then
return quest:event(774):importantOnce() -- Get another part for 100000 gil or give up
end
end,

onTrade = function(player, npc, trade)
if
npcUtil.tradeHasExactly(trade, { xi.item.BUFFALO_HIDE, xi.item.SQUARE_OF_SHEEP_LEATHER, { 'gil', 10000 } }) and
quest:getVar(player, 'Prog') == 1
then
return quest:progressEvent(772)
end
end,
},

onEventFinish =
{
[770] = function(player, csid, option, npc)
quest:setVar(player, 'Prog', 1)
end,

[771] = function(player, csid, option, npc)
if option == 100 then
player:messageSpecial(southernSanDoriaID.text.QUEST_CANCELLED)
quest:setVar(player, 'Prog', 0) -- reset progress
player:delQuest(quest.areaId, quest.questId)
player:setVar('BstHeadGearQuest_Conquest', 0) -- player can accept other headgear quests upon cancelling without conquest wait
end
end,

[772] = function(player, csid, option, npc)
quest:setVar(player, 'Prog', 2)
quest:setVar(player, 'partsWait', getVanaMidnight())
player:confirmTrade()
player:delGil(10000)
end,

[774] = function(player, csid, option, npc)
if option == 0 then
if player:getGil() > 100000 then
quest:setVar(player, 'partsWait', getVanaMidnight())
player:delGil(100000)
else
player:messageSpecial(southernSanDoriaID.text.NOT_HAVE_ENOUGH_GIL)
end
elseif option == 100 then
player:messageSpecial(zones[player:getZoneID()].text.QUEST_CANCELED)
quest:setVar(player, 'Prog', 0)
player:delQuest(quest.areaId, quest.questId)
player:setVar('BstHeadGearQuest_Conquest', 0) -- player can accept other headgear quests upon cancelling
end
end,

[775] = function(player, csid, option, npc)
if npcUtil.giveItem(player, xi.item.GOBLIN_COIF_CUTTING) then -- only progress vars if player receives parts
if quest:getVar(player, 'Prog') == 2 then
quest:setVar(player, 'Prog', 3) -- only progress if current prog is 2, otherwise player is already at, or beyond, Prog 3
end

quest:setVar(player, 'partsWait', 0)
end
end,
},
},

[xi.zone.OLDTON_MOVALPOLOS] =
{
onZoneIn =
{
function(player, prevZone)
local pos = player:getPos()
if
pos.x >= -323.0 and
pos.y >= 6.0 and
pos.z >= -261.0 and
pos.x <= -321.0 and
pos.y <= 9.0 and
pos.z <= -258.0 and
quest:getVar(player, 'Prog') == 3 and
player:getEquipID(xi.slot.HEAD) == xi.item.GOBLIN_COIF
then
return 61 -- Give player Goblin Recommendation Letter
end
end,
},

['Iron_Box'] =
{
onTrigger = function(player, npc, trade)
if player:getEquipID(xi.slot.HEAD) == xi.item.GOBLIN_COIF then
if player:hasKeyItem(xi.ki.GOBLIN_RECOMMENDATION_LETTER) then
return quest:progressEvent(62)
elseif quest:getVar(player, 'Prog') == 5 then
return quest:progressEvent(63)
end
end
end,

onTrade = function(player, npc, trade)
if
npcUtil.tradeHasExactly(trade, { xi.item.GOBLIN_COIF }) and
quest:getVar(player, 'Prog') == 6
then
return quest:progressEvent(64) -- reward player with Choplix's Coif
end
end,
},

onEventFinish =
{
[61] = function(player, csid, option, npc)
npcUtil.giveKeyItem(player, xi.ki.GOBLIN_RECOMMENDATION_LETTER)
quest:setVar(player, 'Prog', 4)
end,

[62] = function(player, csid, option, npc)
if npcUtil.popFromQM(player, npc, spawnedMobs, { claim = true, hide = 0 }) then
player:messageSpecial(oldtonID.text.RECOMMENDATION_LETTER)
end
end,

[63] = function(player, csid, option, npc)
quest:setVar(player, 'Prog', 6)
end,

[64] = function(player, csid, option, npc)
if quest:complete(player) then
player:confirmTrade()
player:setVar('BstHeadGearQuest_Conquest', NextConquestTally())
player:setCharVar('generousGeneralZone', 1)
end
end,
},

['Goblin_Preceptor'] =
{
onMobDeath = function(mob, player, optParams)
for i = oldtonID.mob.GENEROUS_GENERAL_OFFSET, oldtonID.mob.GENEROUS_GENERAL_OFFSET + 6 do
DespawnMob(i)
end

if quest:getVar(player, 'Prog') == 4 then
quest:setVar(player, 'Prog', 5)
player:delKeyItem(xi.ki.GOBLIN_RECOMMENDATION_LETTER)
end
end,
}
},
},

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

[xi.zone.OLDTON_MOVALPOLOS] =
{
onZoneIn =
{
function(player, prevZone)
local pos = player:getPos()
if
pos.x >= -323.0 and
pos.y >= 6.0 and
pos.z >= -261.0 and
pos.x <= -321.0 and
pos.y <= 9.0 and
pos.z <= -258.0 and
player:getCharVar('generousGeneralZone') == 1 and
player:getEquipID(xi.slot.HEAD) == xi.item.CHOPLIXS_COIF
then
return 65
end
end,
},

onEventFinish =
{
[65] = function(player, csid, option, npc)
if npcUtil.giveItem(player, xi.item.GOLD_BEASTCOIN) then
player:setCharVar('generousGeneralZone', 0)
end
end,
}
},
}
}

return quest
5 changes: 5 additions & 0 deletions scripts/zones/Oldton_Movalpolos/Default_Actions.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
local ID = zones[xi.zone.MOLDTON_MOVALPOLOS]

return {
['Iron_Box'] = { messageSpecial = ID.text.NOTHING_OUT_OF_ORDINARY },
}
10 changes: 7 additions & 3 deletions scripts/zones/Oldton_Movalpolos/IDs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ zones[xi.zone.OLDTON_MOVALPOLOS] =
GIL_OBTAINED = 6391, -- Obtained <number> gil.
KEYITEM_OBTAINED = 6393, -- Obtained key item: <keyitem>.
KEYITEM_LOST = 6394, -- Key item lost: <keyitem>.
NOT_HAVE_ENOUGH_GIL = 6395, -- You do not have enough gil.
FELLOW_MESSAGE_OFFSET = 6419, -- I'm ready. I suppose.
CARRIED_OVER_POINTS = 7001, -- You have carried over <number> login point[/s].
LOGIN_CAMPAIGN_UNDERWAY = 7002, -- The [/January/February/March/April/May/June/July/August/September/October/November/December] <number> Login Campaign is currently underway!
Expand All @@ -20,6 +21,7 @@ zones[xi.zone.OLDTON_MOVALPOLOS] =
CONQUEST_BASE = 7064, -- Tallying conquest results...
WAS_TAKEN_FROM_YOU = 7752, -- The Dawn Talisman was taken from you...
FISHING_MESSAGE_OFFSET = 7583, -- You can't fish here.
NOTHING_OUT_OF_ORDINARY = 7693, -- There is nothing out of the ordinary here.
MINING_IS_POSSIBLE_HERE = 7714, -- Mining is possible here if you have <item>.
ALTANA_DIE = 7740, -- Aaaltaaanaaa...Diiieee!!!
RAKOROK_DIALOGUE = 7738, -- Nsy pipul. Gattohre! I bisynw!
Expand All @@ -29,14 +31,16 @@ zones[xi.zone.OLDTON_MOVALPOLOS] =
},
mob =
{
BUGALLUG = GetFirstID('Bugallug'),
BUGBEAR_STRONGMAN = GetTableOfIDs('Bugbear_Strongman'),
GOBLIN_WOLFMAN = GetFirstID('Goblin_Wolfman'),
BUGALLUG = GetFirstID('Bugallug'),
BUGBEAR_STRONGMAN = GetTableOfIDs('Bugbear_Strongman'),
GOBLIN_WOLFMAN = GetFirstID('Goblin_Wolfman'),
GENEROUS_GENERAL_OFFSET = GetFirstID('Goblin_Preceptor'),
},
npc =
{
SCRAWLED_WRITING = GetFirstID('Scrawled_Writing'),
OVERSEER_BASE = GetFirstID('Conquest_Banner'),
IRON_BOX = GetFirstID('Iron_Box'),
TREASURE_CHEST = GetFirstID('Treasure_Chest'),
MINING = GetTableOfIDs('Mining_Point'),
},
Expand Down
23 changes: 23 additions & 0 deletions scripts/zones/Oldton_Movalpolos/mobs/Bugbear_Porterman.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
-----------------------------------
-- Area: Oldton Movalpolos
-- NM: Bugbear Porterman
-- Note: QNM for A Generous General
-----------------------------------
mixins = { require('scripts/mixins/job_special') }
-----------------------------------
local entity = {}

entity.onMobInitialize = function(mob)
mob:setMobMod(xi.mobMod.IDLE_DESPAWN, 180) -- 3 min despawn
end

entity.onMobEngage = function(mob, target)
end

entity.onMobDeath = function(mob, player, optParams)
end

entity.onMobDespawn = function(mob)
end

return entity
23 changes: 23 additions & 0 deletions scripts/zones/Oldton_Movalpolos/mobs/Dread_Dealing_Dredodak.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
-----------------------------------
-- Area: Oldton Movalpolos
-- NM: Dread Dealing Dredodak
-- Note: QNM for A Generous General
-----------------------------------
mixins = { require('scripts/mixins/job_special') }
-----------------------------------
local entity = {}

entity.onMobInitialize = function(mob)
mob:setMobMod(xi.mobMod.IDLE_DESPAWN, 180) -- 3 min despawn
end

entity.onMobEngage = function(mob, target)
end

entity.onMobDeath = function(mob, player, optParams)
end

entity.onMobDespawn = function(mob)
end

return entity
Loading

0 comments on commit b16baed

Please sign in to comment.