Skip to content

Commit

Permalink
Start on Monstrosity
Browse files Browse the repository at this point in the history
  • Loading branch information
zach2good committed Sep 26, 2023
1 parent 5635aea commit 8c48851
Show file tree
Hide file tree
Showing 20 changed files with 384 additions and 73 deletions.
19 changes: 19 additions & 0 deletions scripts/commands/monstrosity.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
local commandObj = {}

commandObj.cmdprops =
{
permission = 1,
parameters = ''
}

commandObj.onTrigger = function(player)
if player:getCharVar('MONSTROSITY_START') == 1 then
player:setCharVar('MONSTROSITY_START', 0)
else
player:setCharVar('MONSTROSITY_START', 1)
end

player:setPos(player:getXPos(), player:getYPos(), player:getZPos(), player:getRotPos(), player:getZoneID())
end

return commandObj
68 changes: 68 additions & 0 deletions scripts/globals/monstrosity.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
-----------------------------------
-- Monstrosity
-----------------------------------
require('scripts/globals/npc_util')
require('scripts/globals/quests')
-----------------------------------
xi = xi or {}
xi.monstrosity = xi.monstrosity or {}

-----------------------------------
-- Odyssean Passage
-----------------------------------

xi.monstrosity.odysseanPassageOnTrigger = function(player, npc)
-- TODO: Handle xi.settings.main.ENABLE_MONSTROSITY

-- TODO: If passage in the overworld, do logic X
local isMonstrosityUnlocked = player:hasKeyItem(xi.keyItem.RING_OF_SUPERNAL_DISJUNCTION)
if isMonstrosityUnlocked then
player:startEvent(883)
end

-- TODO: If passage in Feretory, do logic Y
-- In Feretory: Event 5 (0, 0, 0, 0, 0, 0, 0, 0)
end

-----------------------------------
-- Feretory
-----------------------------------

xi.monstrosity.feretoryOnZoneIn = function(player, prevZone)
-- TODO: Handle xi.settings.main.ENABLE_MONSTROSITY

-- TODO: Rabbit, Mandy, and Lizard are all unlocked to begin with, but you
-- : start as whatever matching item you traded

local cs = -1

player:setPos(-358.000, -3.400, -440.00, 63)

return cs
end

xi.monstrosity.feretoryOnEventUpdate = function(player, csid, option, npc)
end

xi.monstrosity.feretoryOnEventFinish = function(player, csid, option, npc)
end

-----------------------------------
-- Aengus (Feretory NPC)
-----------------------------------
-- Event 13 (As Lizard: 0, 0, 2, 0, 2, 90, 0, 0)

-----------------------------------
-- Teyrnon (Feretory NPC)
-----------------------------------
-- Event 7 (As Lizard: 0, 0, 0, 0, 0, 0, 0, 0)

-----------------------------------
-- Maccus (Feretory NPC)
-----------------------------------
-- Event 9 (As Lizard: 285, 2, 2, 0, 0, 0, 0, 0)

-----------------------------------
-- Suibhne (Feretory NPC)
-----------------------------------
-- Event 11 (As Lizard: 1, 1, 0, 0, 0, 0, 0, 0)
103 changes: 103 additions & 0 deletions scripts/quests/hiddenQuests/Monstrosity_Unlock.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
-----------------------------------
-- Unlocking Monstrosity
-----------------------------------

local quest = HiddenQuest:new('MonstrosityUnlock')

-- TODO: Handle xi.settings.main.ENABLE_MONSTROSITY
-- TODO: Hide completion behind a UniqueEvent flag

quest.sections =
{
-- Intro chatter
{
check = function(player, questVars, vars)
return quest:getVar(player, 'Prog') == 0
end,

[xi.zone.PASHHOW_MARSHLANDS] =
{
['Suspicious_Hume'] =
{
onTrigger = function(player, npc)
return quest:progressEvent(40)
end,
},

onEventFinish =
{
[40] = function(player, csid, option, npc)
if option == 0 then
quest:setVar(player, 'Prog', 1)
end
end,
},
},
},

-- Reminder
{
check = function(player, questVars, vars)
return quest:getVar(player, 'Prog') == 1
end,

[xi.zone.PASHHOW_MARSHLANDS] =
{
['Suspicious_Hume'] =
{
onTrigger = function(player, npc)
return quest:progressEvent(41)
end,
},
},

[xi.zone.PORT_WINDURST] =
{
['Suspicious_Tarutaru'] =
{
onTrade = function(player, npc, trade)
if
npcUtil.tradeHasExactly(trade, xi.item.LIZARD_TAIL)
then
return quest:progressEvent(881, 926, 0, 0, 0, 0, 0, 0, 4)
end
end,

-- Reminder
onTrigger = function (player, npc)
return quest:progressEvent(880)
end,
},

onEventFinish =
{
[881] = function(player, csid, option, npc)
if option == 0 then
quest:setVar(player, 'Prog', 2)
npcUtil.giveKeyItem(player, xi.ki.RING_OF_SUPERNAL_DISJUNCTION)
end
end,
},
},
},

-- Intro chatter
{
check = function(player, questVars, vars)
return quest:getVar(player, 'Prog') == 2
end,

[xi.zone.PORT_WINDURST] =
{
['Suspicious_Tarutaru'] =
{
-- Reminder
onTrigger = function (player, npc)
return quest:progressEvent(882)
end,
},
},
},
}

return quest
12 changes: 7 additions & 5 deletions scripts/zones/Feretory/Zone.lua
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
-----------------------------------
-- Zone: Feretory
-----------------------------------
require('scripts/globals/monstrosity')
-----------------------------------
local zoneObject = {}

zoneObject.onInitialize = function(zone)
-- Unused
end

zoneObject.onZoneIn = function(player, prevZone)
local cs = -1

player:setPos(-358.000, -3.400, -440.00, 63)

return cs
return xi.monstrosity.feretoryOnZoneIn(player, prevZone)
end

zoneObject.onTriggerAreaEnter = function(player, triggerArea)
-- Unused
end

zoneObject.onEventUpdate = function(player, csid, option, npc)
xi.monstrosity.feretoryOnEventUpdate(player, csid, option, npc)
end

zoneObject.onEventFinish = function(player, csid, option, npc)
xi.monstrosity.feretoryOnEventFinish(player, csid, option, npc)
end

return zoneObject
3 changes: 3 additions & 0 deletions settings/default/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ xi.settings.main =
-- VoidWalker
ENABLE_VOIDWALKER = 1,

-- VoidWalker
ENABLE_MONSTROSITY = 1,

-- TREASURE CASKETS
-- Retail droprate = 0.1 (10%) with no other effects active
-- Set to 0 to disable caskets.
Expand Down
2 changes: 2 additions & 0 deletions src/map/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ set(SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/mobskill.h
${CMAKE_CURRENT_SOURCE_DIR}/modifier.cpp
${CMAKE_CURRENT_SOURCE_DIR}/modifier.h
${CMAKE_CURRENT_SOURCE_DIR}/monstrosity.cpp
${CMAKE_CURRENT_SOURCE_DIR}/monstrosity.h
${CMAKE_CURRENT_SOURCE_DIR}/navmesh.cpp
${CMAKE_CURRENT_SOURCE_DIR}/navmesh.h
${CMAKE_CURRENT_SOURCE_DIR}/notoriety_container.cpp
Expand Down
3 changes: 2 additions & 1 deletion src/map/entities/charentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,9 @@ CCharEntity::CCharEntity()
m_mkeCurrent = 0;
m_asaCurrent = 0;

m_PMonstrosity = nullptr;

m_Costume = 0;
m_Monstrosity = 0;
m_hasTractor = 0;
m_hasRaise = 0;
m_weaknessLvl = 0;
Expand Down
4 changes: 3 additions & 1 deletion src/map/entities/charentity.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ along with this program. If not, see http://www.gnu.org/licenses/
#define _CHARENTITY_H

#include "event_info.h"
#include "monstrosity.h"
#include "packets/char.h"
#include "packets/entity_update.h"

Expand Down Expand Up @@ -447,10 +448,11 @@ class CCharEntity : public CBattleEntity
EntityID_t BazaarID{}; // Pointer to the bazaar we are browsing.
BazaarList_t BazaarCustomers; // Array holding the IDs of the current customers

std::unique_ptr<monstrosity::MonstrosityData_t> m_PMonstrosity;

uint32 m_InsideTriggerAreaID; // The ID of the trigger area the character is inside
uint8 m_LevelRestriction; // Character level limit
uint16 m_Costume;
uint16 m_Monstrosity; // Monstrosity model ID
uint32 m_AHHistoryTimestamp;
uint32 m_DeathTimestamp;
time_point m_deathSyncTime; // Timer used for sending an update packet at a regular interval while the character is dead
Expand Down
47 changes: 0 additions & 47 deletions src/map/lua/lua_baseentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5191,50 +5191,6 @@ uint16 CLuaBaseEntity::getCostume()
return PChar->m_Costume;
}

/************************************************************************
* Function: getCostume2()
* Purpose : Sets or returns a monstrosity costume
* Example : player:costume2( costumeId )
* Notes : Not currently implemented
************************************************************************/

uint16 CLuaBaseEntity::getCostume2()
{
if (m_PBaseEntity->objtype != TYPE_PC)
{
ShowWarning("Invalid entity type calling function (%s).", m_PBaseEntity->GetName());
return 0;
}

auto* PChar = static_cast<CCharEntity*>(m_PBaseEntity);
return PChar->m_Monstrosity;
}

/************************************************************************
* Function: setCostume2()
* Purpose : Sets or returns a monstrosity costume
* Example : player:costume2( costumeId )
* Notes : Not currently implemented
************************************************************************/

void CLuaBaseEntity::setCostume2(uint16 costume)
{
if (m_PBaseEntity->objtype != TYPE_PC)
{
ShowWarning("Invalid entity type calling function (%s).", m_PBaseEntity->GetName());
return;
}

auto* PChar = static_cast<CCharEntity*>(m_PBaseEntity);

if (PChar->m_Monstrosity != costume && PChar->status != STATUS_TYPE::SHUTDOWN && PChar->status != STATUS_TYPE::DISAPPEAR)
{
PChar->m_Monstrosity = costume;
PChar->updatemask |= UPDATE_LOOK;
PChar->pushPacket(new CCharAppearancePacket(PChar));
}
}

/************************************************************************
* Function: getAnimation()
* Purpose : Returns the assigned default animation of an entity
Expand Down Expand Up @@ -17063,9 +17019,6 @@ void CLuaBaseEntity::Register()
SOL_REGISTER("setModelId", CLuaBaseEntity::setModelId);
SOL_REGISTER("setCostume", CLuaBaseEntity::setCostume);
SOL_REGISTER("getCostume", CLuaBaseEntity::getCostume);
SOL_REGISTER("getCostume2", CLuaBaseEntity::getCostume2);
SOL_REGISTER("setCostume2", CLuaBaseEntity::setCostume2);

SOL_REGISTER("getAnimation", CLuaBaseEntity::getAnimation);
SOL_REGISTER("setAnimation", CLuaBaseEntity::setAnimation);
SOL_REGISTER("getAnimationSub", CLuaBaseEntity::getAnimationSub);
Expand Down
3 changes: 1 addition & 2 deletions src/map/lua/lua_baseentity.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,7 @@ class CLuaBaseEntity
void setModelId(uint16 modelId, sol::object const& slotObj);
void setCostume(uint16 costume);
uint16 getCostume();
uint16 getCostume2(); // monstrosity costume
void setCostume2(uint16 costume);

uint8 getAnimation();
void setAnimation(uint8 animation);
uint8 getAnimationSub();
Expand Down
Loading

0 comments on commit 8c48851

Please sign in to comment.