Skip to content
This repository has been archived by the owner on Apr 29, 2020. It is now read-only.

Casket pr #6320

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
76 changes: 67 additions & 9 deletions scripts/globals/caskets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ local casketInfo =
112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
124, 125, 126, 127, 128, 130, 153, 157, 158, 159, 160, 166,
167, 169, 172, 173, 174, 176, 177, 178, 184, 190, 191, 192,
193, 194, 195, 196, 197, 198, 204, 205, 207, 212, 213
193, 194, 195, 196, 197, 198, 204, 205, 208, 212, 213
},
cs =
{
Expand Down Expand Up @@ -4340,6 +4340,64 @@ local casketItems =
{ 725, 16265}, -- Wivre Gorget
}
},
[dsp.zone.QUICKSAND_CAVES] =
{
regionalItems = {10949}, -- Smithy's Torque
temps =
{
----------------------------------
--| Weight | Item ID | Name |--
----------------------------------
{1060, 4117}, -- Hi-Potion +1
{ 700, 4118}, -- Hi-Potion +2
{ 230, 4119}, -- Hi-Potion +3
{1020, 4133}, -- Hi-Ether +1
{ 800, 4134}, -- Hi-Ether +2
{ 240, 4135}, -- Hi-Ether +3
{ 900, 4145}, -- Elixir
{ 820, 4148}, -- Antidote
{ 730, 4150}, -- Eye Drops
{ 850, 4151}, -- Echo Drops
{ 650, 4155}, -- Remedy
{1020, 4164}, -- Prism Powder
{ 940, 4165}, -- Silent Oil
{ 420, 4202}, -- Daedalus Wing
{ 220, 4206}, -- Catholicon
{ 430, 4302}, -- Pamama au Lait
{ 620, 4424}, -- Melon Juice
},
items =
{
----------------------------------
--| Weight | Item ID | Name |--
----------------------------------
{ 230, 645}, -- Darksteel Ore
{ 850, 702}, -- Ebony Log
{ 560, 737}, -- Gold Ore
{ 520, 823}, -- Gold Thread
{ 840, 843}, -- G. Bird Plume
{1250, 844}, -- Phoenix Feather
{2900, 888}, -- Sea Shell
{2500, 1155}, -- Iron Sand
{1900, 1213}, -- Dst. Bolt Heads
{2100, 1443}, -- Dried Mugwort
{ 240, 3309}, -- Barrage Turbine
{1700, 3434}, -- Cobalt Cell
{ 650, 3435}, -- Rubicund Cell
{1230, 3437}, -- Jade Cell
{5000, 4117}, -- Hi-Potion +1
{4400, 4120}, -- X-Potion
{ 600, 4121}, -- X-Potion +1
{4800, 4133}, -- Hi-Ether +1
{ 790, 4141}, -- Pro-Ether +1
{ 310, 4449}, -- Reishi Mushroom
{ 430, 5164}, -- Ground Wasabi
{ 625, 12829}, -- Beak Trousers
{ 365, 12683}, -- Darksteel Mufflers
{ 295, 12811}, -- Dst. Breeches
{ 680, 12740}, -- Silk Mitts
}
},
[dsp.zone.GUSTAV_TUNNEL] =
{
regionalItems = {10955, 11041}, -- Culinarian's Torque | Liminus Earring
Expand Down Expand Up @@ -4590,9 +4648,8 @@ end
-- Desc: Despawn a chest and reset its local var's
----------------------------------------------------------------------------------
local function removeChest(npc)
npc:AnimationSub(0)
npc:setStatus(dsp.status.DISAPPEAR)
npc:setLocalVar("[caskets]SPAWNSTATUS", casketInfo.spawnStatus.DESPAWNED)
npc:despawnNPC()
npc:releaseAllFromNPC()
end

---------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -4646,12 +4703,13 @@ local function setCasketData(player, x, y, z, r, npc, partyID, mobLvl)
npc:setLocalVar("[caskets]SPAWNTIME", os.time())
npc:setPos(x, y, z, r)
npc:setStatus(dsp.status.NORMAL)
npc:entityAnimationPacket("deru")
--npc:entityAnimationPacket("deru")
npc:setModelId(chestStyle)
sendChestDropMessage(player)
-------------------------------------------------------
-- Despawn chest after 3 Mins
-------------------------------------------------------
-- npc:showNPC(180)
npc:timer(180000, function(npc)
removeChest(npc)
end)
Expand Down Expand Up @@ -5255,11 +5313,11 @@ dsp.caskets.onEventFinish = function(player, csid, option, npc)
splitNumbers[1],
splitNumbers[1] +1,
splitNumbers[1] +2, 0)
elseif tonumber(splitNumbers[2]) == 9 then
elseif tonumber(splitNumbers[1]) == 9 then
player:messageSpecial(baseMessage + casketInfo.messageOffset.FIRST_DIGIT_IS,
splitNumbers[2] -2,
splitNumbers[2] -1,
splitNumbers[2], 0)
splitNumbers[1] -2,
splitNumbers[1] -1,
splitNumbers[1], 0)
else
player:messageSpecial(baseMessage + casketInfo.messageOffset.FIRST_DIGIT_IS,
splitNumbers[1] -1,
Expand Down
4 changes: 4 additions & 0 deletions scripts/mixins/zones/Quicksand_Caves.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---------------------------------------------------------
-- Caskets
---------------------------------------------------------
mixins = {require("scripts/mixins/spawn_casket")}
40 changes: 23 additions & 17 deletions scripts/zones/Quicksand_Caves/IDs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,28 @@ zones[dsp.zone.QUICKSAND_CAVES] =
{
text =
{
ITEM_CANNOT_BE_OBTAINED = 6382, -- You cannot obtain the <item>. Come back after sorting your inventory.
ITEM_OBTAINED = 6388, -- Obtained: <item>.
GIL_OBTAINED = 6389, -- Obtained <number> gil.
KEYITEM_OBTAINED = 6391, -- Obtained key item: <keyitem>.
NOTHING_OUT_OF_ORDINARY = 6402, -- There is nothing out of the ordinary here.
SENSE_OF_FOREBODING = 6403, -- You are suddenly overcome with a sense of foreboding...
NOW_IS_NOT_THE_TIME = 6404, -- Now is not the time for that!
CONQUEST_BASE = 7049, -- Tallying conquest results...
FISHING_MESSAGE_OFFSET = 7208, -- You can't fish here.
CHEST_UNLOCKED = 7316, -- You unlock the chest!
DOOR_FIRMLY_SHUT = 7324, -- The door is firmly shut.
POOL_OF_WATER = 7356, -- It is a pool of water.
YOU_FIND_NOTHING = 7359, -- You find nothing.
SOMETHING_IS_BURIED = 7364, -- Something is buried in this fallen pillar.
SENSE_OMINOUS_PRESENCE = 7368, -- You sense an ominous presence...
REGIME_REGISTERED = 10362, -- New training regime registered!
HOMEPOINT_SET = 11424, -- Home point set!
ITEM_CANNOT_BE_OBTAINED = 6382, -- You cannot obtain the <item>. Come back after sorting your inventory.
ITEM_OBTAINED = 6388, -- Obtained: <item>.
GIL_OBTAINED = 6389, -- Obtained <number> gil.
KEYITEM_OBTAINED = 6391, -- Obtained key item: <keyitem>.
NOTHING_OUT_OF_ORDINARY = 6402, -- There is nothing out of the ordinary here.
SENSE_OF_FOREBODING = 6403, -- You are suddenly overcome with a sense of foreboding...
NOW_IS_NOT_THE_TIME = 6404, -- Now is not the time for that!
CONQUEST_BASE = 7049, -- Tallying conquest results...
FISHING_MESSAGE_OFFSET = 7208, -- You can't fish here.
CHEST_UNLOCKED = 7316, -- You unlock the chest!
DOOR_FIRMLY_SHUT = 7324, -- The door is firmly shut.
POOL_OF_WATER = 7356, -- It is a pool of water.
YOU_FIND_NOTHING = 7359, -- You find nothing.
SOMETHING_IS_BURIED = 7364, -- Something is buried in this fallen pillar.
SENSE_OMINOUS_PRESENCE = 7368, -- You sense an ominous presence...
PLAYER_OBTAINS_ITEM = 8276, -- <name> obtains <item>!
UNABLE_TO_OBTAIN_ITEM = 8277, -- You were unable to obtain the item.
PLAYER_OBTAINS_TEMP_ITEM = 8278, -- <name> obtains the temporary item: <item>!
ALREADY_POSSESS_TEMP = 8279, -- You already possess that temporary item.
NO_COMBINATION = 8284, -- You were unable to enter a combination.
REGIME_REGISTERED = 10362, -- New training regime registered!
HOMEPOINT_SET = 11424, -- Home point set!
},
mob =
{
Expand Down Expand Up @@ -90,6 +95,7 @@ zones[dsp.zone.QUICKSAND_CAVES] =
[3] = {479.000, -14.000, -815.000},
[4] = {814.000, -14.000, -761.000}
},
CASKET_BASE = 17629663,
ORNATE_DOOR_OFFSET = 17629685,
CHAINS_THAT_BIND_US_QM = 17629738,
TREASURE_COFFER = 17629739,
Expand Down
20 changes: 20 additions & 0 deletions scripts/zones/Quicksand_Caves/npcs/Treasure_Casket.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-----------------------------------
-- NPC: Treasure Casket
-----------------------------------
require("scripts/globals/caskets")
-----------------------------------

function onTrigger(player, npc)
dsp.caskets.onTrigger(player, npc)
end

function onTrade(player, npc, trade)
dsp.caskets.onTrade(player, npc, trade)
end

function onEventUpdate(player, csid, option)
end

function onEventFinish(player, csid, option)
dsp.caskets.onEventFinish(player, csid, option)
end
10 changes: 5 additions & 5 deletions scripts/zones/The_Sanctuary_of_ZiTah/IDs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ zones[dsp.zone.THE_SANCTUARY_OF_ZITAH] =
ZILART_MONUMENT = 7740, -- It is an ancient Zilart monument.
STURDY_BRANCH = 7763, -- It is a beautiful, sturdy branch.
SENSE_OMINOUS_PRESENCE = 7848, -- You sense an ominous presence...
PLAYER_OBTAINS_ITEM = 8082, -- <name> obtains <item>!
UNABLE_TO_OBTAIN_ITEM = 8083, -- You were unable to obtain the item.
PLAYER_OBTAINS_TEMP_ITEM = 8084, -- <name> obtains the temporary item: <item>!
ALREADY_POSSESS_TEMP = 8085, -- You already possess that temporary item.
NO_COMBINATION = 8090, -- You were unable to enter a combination.
PLAYER_OBTAINS_ITEM = 8077, -- <name> obtains <item>!
UNABLE_TO_OBTAIN_ITEM = 8078, -- You were unable to obtain the item.
PLAYER_OBTAINS_TEMP_ITEM = 8079, -- <name> obtains the temporary item: <item>!
ALREADY_POSSESS_TEMP = 8080, -- You already possess that temporary item.
NO_COMBINATION = 8085, -- You were unable to enter a combination.
REGIME_REGISTERED = 10268, -- New training regime registered!
COMMON_SENSE_SURVIVAL = 12257, -- 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.
},
Expand Down
51 changes: 51 additions & 0 deletions src/map/lua/lua_baseentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2142,6 +2142,55 @@ inline int32 CLuaBaseEntity::hideNPC(lua_State *L)
return 0;
}

/************************************************************************
* Function: despawnNPC()
* Purpose : despawns an npc right away and removes any queued actions.
* Example : npc:despawnNPC()
* Notes : Currently only used to force despawn caskets.
************************************************************************/

inline int32 CLuaBaseEntity::despawnNPC(lua_State* L)
{
DSP_DEBUG_BREAK_IF(m_PBaseEntity == nullptr);
DSP_DEBUG_BREAK_IF(m_PBaseEntity->objtype != TYPE_NPC);

if (m_PBaseEntity->status == STATUS_NORMAL)
{
m_PBaseEntity->status = STATUS_DISAPPEAR;
m_PBaseEntity->loc.zone->PushPacket(m_PBaseEntity, CHAR_INRANGE, new CEntityUpdatePacket(m_PBaseEntity, ENTITY_DESPAWN, UPDATE_COMBAT));
m_PBaseEntity->PAI->QueueEmpty();
}
return 0;
}

/************************************************************************
* Function: releaseAllFromNPC()
* Purpose : releases any players currently interacting with the npc
* Example : npc:releaseAllFromNPC()
Omnione marked this conversation as resolved.
Show resolved Hide resolved
* Notes : Currently only used to force release for caskets.
************************************************************************/

inline int32 CLuaBaseEntity::releaseAllFromNPC(lua_State* L)
{
DSP_DEBUG_BREAK_IF(m_PBaseEntity == nullptr);
DSP_DEBUG_BREAK_IF(m_PBaseEntity->objtype != TYPE_NPC);

CBaseEntity* PTarget = (CBaseEntity*)m_PBaseEntity;

m_PBaseEntity->loc.zone->ForEachChar([&PTarget](CCharEntity* PChar)
{
if (PChar != nullptr && PChar->m_event.Target != nullptr)
{
if (PChar->m_event.Target == PTarget && PChar->m_event.EventID != -1)
{
PChar->pushPacket(new CReleasePacket(PChar, RELEASE_SKIPPING));
PChar->pushPacket(new CReleasePacket(PChar, RELEASE_EVENT));
}
}
});
return 0;
}

/************************************************************************
* Function: updateNPCHideTime()
* Purpose : Adds more time to an NPC being hidden
Expand Down Expand Up @@ -13995,6 +14044,8 @@ Lunar<CLuaBaseEntity>::Register_t CLuaBaseEntity::methods[] =
LUNAR_DECLARE_METHOD(CLuaBaseEntity,addPeriodicTrigger),
LUNAR_DECLARE_METHOD(CLuaBaseEntity,showNPC),
LUNAR_DECLARE_METHOD(CLuaBaseEntity,hideNPC),
LUNAR_DECLARE_METHOD(CLuaBaseEntity,releaseAllFromNPC),
LUNAR_DECLARE_METHOD(CLuaBaseEntity,despawnNPC),
LUNAR_DECLARE_METHOD(CLuaBaseEntity,updateNPCHideTime),

LUNAR_DECLARE_METHOD(CLuaBaseEntity,getWeather),
Expand Down
2 changes: 2 additions & 0 deletions src/map/lua/lua_baseentity.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ class CLuaBaseEntity
int32 addPeriodicTrigger(lua_State* L); // Adds a periodic trigger to the NPC that allows time based scripting
int32 showNPC(lua_State*); // Show an NPC
int32 hideNPC(lua_State*); // hide an NPC
int32 despawnNPC(lua_State* L);
int32 releaseAllFromNPC(lua_State* L);
int32 updateNPCHideTime(lua_State*); // Updates the length of time a NPC remains hidden, if shorter than the original hide time.

int32 getWeather(lua_State*); // Get Weather condition
Expand Down