Skip to content

Commit

Permalink
implement quest Better the Demon You Know
Browse files Browse the repository at this point in the history
Co-authored-by: jamesbradleym <[email protected]>
Co-authored-by: dallano <[email protected]>
  • Loading branch information
jamesbradleym and dallano committed May 31, 2024
1 parent 1242529 commit da94a67
Show file tree
Hide file tree
Showing 11 changed files with 302 additions and 21 deletions.
86 changes: 86 additions & 0 deletions scripts/actions/mobskills/Substitute.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
-----------------------------------
-- Substitute
-- Dummy ability used several mobs.
--
-- Marquis Andrealphus:
-- Uses this ability to warp target player
-- out of the zone
--
-- BCNM: Die by the Sword
-- Mobs use this ability to switch animation
-- ID as well as physical resistances
-----------------------------------
local mobskillObject = {}

local resistances =
{
xi.mod.SLASH_SDT,
xi.mod.PIERCE_SDT,
xi.mod.IMPACT_SDT,
xi.mod.HTH_SDT,
}

mobskillObject.onMobSkillCheck = function(target, mob, skill)
return 0
end

mobskillObject.onMobWeaponSkill = function(target, mob, skill)
-- Marquis Andrealphus
if mob:getPool() == 2571 then
local party = target:getParty()
local control = false

-- Ability is only used when there is another party
-- member in the party, or party size > 1
if mob:getPool() == 2571 then
if #party > 1 then
for _, v in ipairs(target:getParty()) do
if v:getZone() == target:getZone() then
control = true
end
end
else
control = true
end
end

if control then
mob:timer(1000, function(mobArg)
mobArg:injectActionPacket(target:getID(), 4, 261, 0, 0, 0, 10, 1)
mobArg:timer(3000, function(mobArg1)
xi.teleport.escape(target)
end)
end)
end

-- Die by the Sword BCNM
else
local oldAnim = mob:getAnimationSub()
local newAnim = oldAnim

while newAnim == oldAnim do
newAnim = math.random(1, 3)
end

mob:setAnimationSub(newAnim)

for i = 1, 4 do
if i == newAnim then
mob:setMod(resistances[i], 1000)
else
mob:setMod(resistances[i], -2500)
end
end

if newAnim == 3 then
mob:setMod(resistances[4], 1000)
else
mob:setMod(resistances[4], -2500)
end
end

skill:setMsg(xi.msg.basic.NONE)
return 0
end

return mobskillObject
2 changes: 2 additions & 0 deletions scripts/enum/item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,7 @@ xi.item =
SQUARE_OF_BUGARD_LEATHER = 1637,
MOBLIN_MASK = 1638,
BOTTLE_OF_RICE_VINEGAR = 1652,
DEMON_PEN = 1653,
IGNEOUS_ROCK = 1654,
SEALION_CREST_KEY = 1658,
CORAL_CREST_KEY = 1659,
Expand Down Expand Up @@ -6029,6 +6030,7 @@ xi.item =
OPTICAL_NEEDLE = 18175,
NAZAR_BONJUK = 18176,
KAKANPU = 18177,
GOBLIN_GRENADE = 18180,
CRUDE_ARROW = 18181,
CRUDE_ARROW_P1 = 18182,
CRUDE_ARROW_P2 = 18183,
Expand Down
150 changes: 150 additions & 0 deletions scripts/quests/otherAreas/Better_the_Demon_You_Know.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
-----------------------------------
-- Better the Demon you Know
-----------------------------------
-- Log ID: 4, Quest ID: 105
-- Koblakiq !pos -64 21 -117 11
-- qm_demon_you_know !pos 20 -24 15 161
-----------------------------------
local castleZvahlBaileysID = zones[xi.zone.CASTLE_ZVAHL_BAILEYS]
-----------------------------------
local quest = Quest:new(xi.questLog.OTHER_AREAS, xi.quest.id.otherAreas.BETTER_THE_DEMON_YOU_KNOW)

quest.reward =
{
item = xi.item.GOBLIN_GRENADE,
title = xi.title.APOSTATE_FOR_HIRE
}

quest.sections =
{
{
check = function(player, status, vars)
return status == xi.questStatus.QUEST_AVAILABLE and
player:hasCompletedQuest(xi.questLog.OTHER_AREAS, xi.quest.id.otherAreas.FOR_THE_BIRDS) and
not quest:getMustZone(player)
end,

[xi.zone.OLDTON_MOVALPOLOS] =
{
['Koblakiq'] = quest:progressEvent(20, { [1] = xi.item.DEMON_PEN }),

onEventFinish =
{
[20] = function(player, csid, option, npc)
quest:begin(player)
end,
},
},
},
{
check = function(player, status, vars)
return status == xi.questStatus.QUEST_ACCEPTED
end,

[xi.zone.OLDTON_MOVALPOLOS] =
{
['Koblakiq'] =
{
onTrigger = function(player, npc)
local prog = quest:getVar(player, 'Prog')

if prog == 0 then
return quest:progressEvent(21, { [1] = xi.item.DEMON_PEN }) -- Additional Dialogue
elseif quest:getVar(player, 'Wait') > os.time() then
return quest:progressEvent(23)
elseif
prog == 1 and
quest:getVar(player, 'Wait') < os.time()
then
return quest:progressEvent(24)
elseif prog == 2 then
return quest:progressEvent(25)
elseif player:hasKeyItem(xi.ki.ZEELOZOKS_EARPLUG) then
return quest:progressEvent(26)
end
end,

onTrade = function(player, npc, trade)
if
quest:getVar(player, 'Prog') == 0 and
npcUtil.tradeHasExactly(trade, { xi.item.DEMON_PEN })
then
return quest:progressEvent(22)
end
end,
},

onEventFinish =
{
[22] = function(player, csid, option, npc)
player:tradeComplete()
quest:setVar(player, 'Wait', os.time() + 60) -- midnight for era, 1 min for retail
quest:setVar(player, 'Prog', 1)
end,

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

[26] = function(player, csid, option, npc)
if quest:complete(player) then
player:delKeyItem(xi.ki.ZEELOZOKS_EARPLUG)
end
end,
},
},

[xi.zone.CASTLE_ZVAHL_BAILEYS] =
{
['qm_demon_you_know'] =
{
onTrigger = function(player, npc)
local mobs =
{
castleZvahlBaileysID.mob.DEMON_YOU_KNOW_OFFSET,
castleZvahlBaileysID.mob.DEMON_YOU_KNOW_OFFSET + 1,
castleZvahlBaileysID.mob.DEMON_YOU_KNOW_OFFSET + 2,
castleZvahlBaileysID.mob.DEMON_YOU_KNOW_OFFSET + 3,
castleZvahlBaileysID.mob.DEMON_YOU_KNOW_OFFSET + 4,
}

if
quest:getVar(player, 'Prog') == 2 and
npcUtil.popFromQM(player, npc, mobs, { claim = true, hide = 0, })
then
player:messageSpecial(castleZvahlBaileysID.text.MOBLIN_EARPLUG)
return quest:message(castleZvahlBaileysID.text.MINIONS_ATTACK)

elseif
quest:getVar(player, 'Prog') == 3 and
not player:hasKeyItem(xi.ki.ZEELOZOKS_EARPLUG)
then
player:addKeyItem(xi.ki.ZEELOZOKS_EARPLUG)
return quest:messageSpecial(castleZvahlBaileysID.text.KEYITEM_OBTAINED, xi.ki.ZEELOZOKS_EARPLUG)
end
end,
},

['Marquis_Andrealphus'] =
{
onMobDeath = function(mob, player, isKiller, firstCall)
if quest:getVar(player, 'Prog') == 2 then
quest:setVar(player, 'Prog', 3)
end
end,
},
},
},
{
check = function(player, status, vars)
return status == xi.questStatus.QUEST_COMPLETED
end,

[xi.zone.OLDTON_MOVALPOLOS] =
{
['Koblakiq'] = quest:event(27):replaceDefault(),
},
},
}

return quest
5 changes: 3 additions & 2 deletions scripts/zones/Castle_Zvahl_Baileys/DefaultActions.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local ID = zones[xi.zone.CASTLE_ZVAHL_BAILEYS]

return {
['Flame_of_Fate'] = { messageSpecial = ID.text.NOTHING_OUT_OF_ORDINARY },
['Shadowy_Pillar'] = { messageSpecial = ID.text.NOTHING_OUT_OF_ORDINARY },
['Flame_of_Fate'] = { messageSpecial = ID.text.NOTHING_OUT_OF_ORDINARY },
['Shadowy_Pillar'] = { messageSpecial = ID.text.NOTHING_OUT_OF_ORDINARY },
['qm_demon_you_know'] = { messageSpecial = ID.text.YOU_FIND_NOTHING },
}
21 changes: 13 additions & 8 deletions scripts/zones/Castle_Zvahl_Baileys/IDs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,23 @@ zones[xi.zone.CASTLE_ZVAHL_BAILEYS] =
LOGIN_NUMBER = 7162, -- In celebration of your most recent login (login no. <number>), we have provided you with <number> points! You currently have a total of <number> points.
MEMBERS_LEVELS_ARE_RESTRICTED = 7182, -- Your party is unable to participate because certain members' levels are restricted.
CHEST_UNLOCKED = 7238, -- You unlock the chest!
MOBLIN_EARPLUG = 7564, -- You see a moblin earplug on the ground. Could Zeelok have met his end here?
MINIONS_ATTACK = 7565, -- Marquis Andrealphus and his minions attack!
YOU_FIND_NOTHING = 7566, -- You find nothing.
BEGONE = 7567, -- Insolent adventurer! Begone from these halls!
COMMON_SENSE_SURVIVAL = 7613, -- It appears that you have arrived at a new survival guide provided by the Adventurers' Mutual Aid Network. Common sense dictates that you should now be able to teleport here from similar tomes throughout the world.
},
mob =
{
MARQUIS_SABNOCK = GetFirstID('Marquis_Sabnock'),
LIKHO = GetFirstID('Likho'),
MARQUIS_ALLOCEN = GetFirstID('Marquis_Allocen'),
MARQUIS_AMON = GetFirstID('Marquis_Amon'),
DUKE_HABORYM = GetFirstID('Duke_Haborym'),
GRAND_DUKE_BATYM = GetFirstID('Grand_Duke_Batym'),
DARK_SPARK = GetFirstID('Dark_Spark'),
MIMIC = GetFirstID('Mimic'),
MARQUIS_SABNOCK = GetFirstID('Marquis_Sabnock'),
LIKHO = GetFirstID('Likho'),
MARQUIS_ALLOCEN = GetFirstID('Marquis_Allocen'),
MARQUIS_AMON = GetFirstID('Marquis_Amon'),
DUKE_HABORYM = GetFirstID('Duke_Haborym'),
GRAND_DUKE_BATYM = GetFirstID('Grand_Duke_Batym'),
DARK_SPARK = GetFirstID('Dark_Spark'),
MIMIC = GetFirstID('Mimic'),
DEMON_YOU_KNOW_OFFSET = GetFirstID('Marquis_Andrealphus'),
},
npc =
{
Expand Down
37 changes: 37 additions & 0 deletions scripts/zones/Castle_Zvahl_Baileys/mobs/Marquis_Andrealphus.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
-----------------------------------
-- Area: Castle Zvahl Baileys
-- NM: Marquis Andrealphus
-- Quest: Better the Demon you Know
-----------------------------------
local ID = zones[xi.zone.CASTLE_ZVAHL_BAILEYS]
-----------------------------------
local entity = {}

entity.onMobEngaged = function(mob)
-- Blood Weapon Timer
mob:setLocalVar('timer', os.time() + 180)
end

entity.onMobFight = function(mob, target)
if mob:getLocalVar('timer') < os.time() then
mob:setLocalVar('timer', os.time() + 180)
mob:useMobAbility(695)
end

-- Escape player with hate out of zone
if mob:getHPP() < 75 and mob:getLocalVar('hpControl1') == 0 then
mob:showText(mob, ID.text.BEGONE)
mob:setLocalVar('hpControl1', 1)
mob:useMobAbility(307, target)

elseif mob:getHPP() < 25 and mob:getLocalVar('hpControl2') == 0 then
mob:showText(mob, ID.text.BEGONE)
mob:setLocalVar('hpControl2', 1)
mob:useMobAbility(307, target)
end
end

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

return entity
6 changes: 3 additions & 3 deletions sql/mob_groups.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11036,9 +11036,9 @@ INSERT INTO `mob_groups` VALUES (46,1786,161,'Grand_Duke_Batym',0,128,1213,0,0,7
INSERT INTO `mob_groups` VALUES (47,993,161,'Demons_Avatar',0,128,0,0,0,52,54,0);
INSERT INTO `mob_groups` VALUES (48,917,161,'Dark_Spark',0,128,0,8500,0,55,55,0);
INSERT INTO `mob_groups` VALUES (49,2664,161,'Mimic',0,128,1683,0,0,64,66,0);
INSERT INTO `mob_groups` VALUES (50,2571,161,'Marquis_Andrealphus',0,128,0,0,0,76,76,0);
INSERT INTO `mob_groups` VALUES (51,982,161,'Demon_Banneret',0,128,0,0,0,61,61,0);
INSERT INTO `mob_groups` VALUES (52,992,161,'Demon_Secretary',0,128,0,0,0,61,61,0);
INSERT INTO `mob_groups` VALUES (50,2571,161,'Marquis_Andrealphus',0,128,0,0,0,76,76,0); -- era HP: 4000, minlvl: 52, maxlvl: 52
INSERT INTO `mob_groups` VALUES (51,982,161,'Demon_Banneret',0,128,0,0,0,61,61,0); -- era HP: 1000, minlvl: 48, maxlvl: 49
INSERT INTO `mob_groups` VALUES (52,992,161,'Demon_Secretary',0,128,0,0,0,61,61,0); -- era HP: 1000, minlvl: 48, maxlvl: 49
INSERT INTO `mob_groups` VALUES (53,994,161,'Demons_Elemental',0,128,623,0,0,43,45,0);
INSERT INTO `mob_groups` VALUES (54,994,161,'Demons_Elemental',0,128,623,0,0,60,64,0);

Expand Down
2 changes: 1 addition & 1 deletion sql/mob_pools.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2624,7 +2624,7 @@ INSERT INTO `mob_pools` VALUES (2567,'Maritime_Peiste','Maritime_Peiste',192,0x0
INSERT INTO `mob_pools` VALUES (2568,'Marquis_Allocen','Marquis_Allocen',358,0x0000E60200000000000000000000000000000000,1,1,4,240,100,0,1,0,1,2,0,0,247,135,0,0,0,0,0,358,358);
INSERT INTO `mob_pools` VALUES (2569,'Marquis_Amon','Marquis_Amon',358,0x0000E90200000000000000000000000000000000,4,4,10,240,100,0,1,0,1,2,0,0,325,135,0,0,2,0,0,358,358);
INSERT INTO `mob_pools` VALUES (2570,'Marquis_Andras','Marquis_Andras',358,0x0000EB0200000000000000000000000000000000,9,9,6,240,100,0,1,1,1,2,0,32,139,159,0,0,0,0,0,358,358);
INSERT INTO `mob_pools` VALUES (2571,'Marquis_Andrealphus','Marquis_Andrealphus',358,0x0000E50200000000000000000000000000000000,8,8,5,240,100,0,1,0,1,2,0,0,0,3,0,0,5,0,0,358,358);
INSERT INTO `mob_pools` VALUES (2571,'Marquis_Andrealphus','Marquis_Andrealphus',358,0x0000E50200000000000000000000000000000000,8,8,5,240,100,0,1,0,1,2,87,0,0,6,0,0,5,0,0,358,358);
INSERT INTO `mob_pools` VALUES (2572,'Marquis_Cimeries','Marquis_Cimeries',358,0x0000EB0200000000000000000000000000000000,11,11,6,240,100,0,1,1,1,2,0,32,20,159,0,0,0,0,0,358,358);
INSERT INTO `mob_pools` VALUES (2573,'Marquis_Decarabia','Marquis_Decarabia',358,0x0000F40200000000000000000000000000000000,10,10,9,240,100,0,1,1,1,2,0,32,139,159,0,0,6,0,0,358,358);
INSERT INTO `mob_pools` VALUES (2574,'Marquis_Forneus','Marquis_Forneus',358,0x0000F00200000000000000000000000000000000,8,8,7,240,100,0,1,1,1,2,55,32,0,1181,0,0,301,0,0,358,358);
Expand Down
2 changes: 1 addition & 1 deletion sql/mob_skills.sql
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ INSERT INTO `mob_skills` VALUES (302,46,'wild_oats',0,7.0,2000,1500,4,0,0,0,0,0,
INSERT INTO `mob_skills` VALUES (304,48,'photosynthesis',0,7.0,2000,1500,1,0,0,0,0,0,0);
INSERT INTO `mob_skills` VALUES (305,49,'leaf_dagger',0,7.0,2000,1500,4,0,0,0,0,0,0);
INSERT INTO `mob_skills` VALUES (306,50,'scream',1,15.0,2000,1500,4,0,0,0,0,0,0);
-- INSERT INTO `mob_skills` VALUES (307,439,'substitute',0,7.0,2000,1500,4,0,0,0,0,0,0);
INSERT INTO `mob_skills` VALUES (307,439,'substitute',0,40.0,2000,0,4,0,0,0,0,0,0);
INSERT INTO `mob_skills` VALUES (308,52,'frogkick',0,7.0,2000,1500,4,0,0,0,0,0,0);
INSERT INTO `mob_skills` VALUES (309,53,'spore',0,7.0,2000,1500,4,0,0,0,0,0,0);
INSERT INTO `mob_skills` VALUES (310,54,'queasyshroom',0,7.0,2000,1500,4,0,0,0,0,0,0);
Expand Down
10 changes: 5 additions & 5 deletions sql/mob_spawn_points.sql
Original file line number Diff line number Diff line change
Expand Up @@ -57650,11 +57650,11 @@ INSERT INTO `mob_spawn_points` VALUES (17436962,'Stygian_Demon','Stygian Demon',
INSERT INTO `mob_spawn_points` VALUES (17436963,'Demons_Elemental','Demon\'s Elemental',18,1.000,1.000,1.000,0);
INSERT INTO `mob_spawn_points` VALUES (17436964,'Dark_Spark','Dark Spark',48,62.000,-24.000,19.000,10);
INSERT INTO `mob_spawn_points` VALUES (17436965,'Mimic','Mimic',49,189.783,20.290,20.761,77);
INSERT INTO `mob_spawn_points` VALUES (17436966,'Marquis_Andrealphus','Marquis Andrealphus',50,0.000,0.000,0.000,0);
INSERT INTO `mob_spawn_points` VALUES (17436967,'Demon_Banneret','Demon Banneret',51,0.000,0.000,0.000,0);
INSERT INTO `mob_spawn_points` VALUES (17436968,'Demon_Secretary','Demon Secretary',52,0.000,0.000,0.000,127);
INSERT INTO `mob_spawn_points` VALUES (17436969,'Demon_Banneret','Demon Banneret',51,0.000,0.000,0.000,0);
INSERT INTO `mob_spawn_points` VALUES (17436970,'Demon_Secretary','Demon Secretary',52,0.000,0.000,0.000,0);
INSERT INTO `mob_spawn_points` VALUES (17436966,'Marquis_Andrealphus','Marquis Andrealphus',50,-15.500,-24.000,20.000,250);
INSERT INTO `mob_spawn_points` VALUES (17436967,'Demon_Banneret','Demon Banneret',51,19.340,-24.000,10.500,200);
INSERT INTO `mob_spawn_points` VALUES (17436968,'Demon_Secretary','Demon Secretary',52,19.340,-24.000,15.500,200);
INSERT INTO `mob_spawn_points` VALUES (17436969,'Demon_Banneret','Demon Banneret',51,19.340,-24.000,24.50,60);
INSERT INTO `mob_spawn_points` VALUES (17436970,'Demon_Secretary','Demon Secretary',52,19.340,-24.000,29.50,60);

-- ------------------------------------------------------------
-- Castle Zvahl Keep (Zone 162)
Expand Down
2 changes: 1 addition & 1 deletion sql/npc_list.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19771,7 +19771,7 @@ INSERT INTO `npc_list` VALUES (17436998,'Treasure_Chest','Treasure Chest',189,11
INSERT INTO `npc_list` VALUES (17436999,'Treasure_Coffer','Treasure Coffer',126,-72.899,0.137,19.549,6,40,40,0,0,0,0,3,0x0000C10300000000000000000000000000000000,0,NULL,0);
INSERT INTO `npc_list` VALUES (17437000,'Switchstix','Switchstix',36,386.091,-12.000,-17.399,24,40,40,0,0,0,0,27,0x0000550000000000000000000000000000000000,0,NULL,1);
INSERT INTO `npc_list` VALUES (17437001,'qm1','???',0,0.000,0.000,0.000,0,40,40,0,0,0,2,2051,0x0000320000000000000000000000000000000000,0,NULL,0);
INSERT INTO `npc_list` VALUES (17437002,'qm2','???',213,19.400,-24.141,19.185,1,40,40,0,0,0,0,3,0x0000340000000000000000000000000000000000,0,NULL,0);
INSERT INTO `npc_list` VALUES (17437002,'qm_demon_you_know','???',213,19.400,-24.141,19.185,1,40,40,0,0,0,0,3,0x0000340000000000000000000000000000000000,0,NULL,0);
INSERT INTO `npc_list` VALUES (17437003,'Ramblix','Ramblix',158,377.847,-12.166,-25.548,0,40,40,0,0,0,6,27,0x0000550000000000000000000000000000000000,0,NULL,1);
INSERT INTO `npc_list` VALUES (17437004,'Goblin_Footprint','Goblin Footprint',158,377.847,-12.166,-25.548,1,40,40,0,0,0,0,3,0x0000340000000000000000000000000000000000,0,NULL,0);
INSERT INTO `npc_list` VALUES (17437005,'blank','',0,0.000,0.000,0.000,0,50,50,0,0,0,2,2051,0x0000340000000000000000000000000000000000,0,NULL,1);
Expand Down

0 comments on commit da94a67

Please sign in to comment.