Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x] (WIP) EncounterFight and state refactor; #928

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
fc46e57
ugly prototype of arenascript;
hkAlice Mar 7, 2023
c3107b8
remove scripts for battle;
hkAlice Mar 8, 2023
f8b0cfb
add EncounterFight, EncounterState; add example ifritnormal;
hkAlice Mar 8, 2023
69b7671
encounter status control;
hkAlice Mar 8, 2023
77089d4
add encounter to instancecontent; basic status handling;
hkAlice Mar 8, 2023
c1589c1
add timers and enrage mechanic;
hkAlice Mar 8, 2023
a10c0cd
more work on duty resets;
hkAlice Mar 8, 2023
25dbd60
more duty reset work, respawn players on duty reset;
hkAlice Mar 8, 2023
a5fdc0b
fix typos;
hkAlice Mar 8, 2023
c8ab6de
more instancecontent work;
hkAlice Mar 8, 2023
9035d44
rezone player; wait for all players to unlock zone entrance;
hkAlice Mar 9, 2023
9d49139
return spaced player name in case of player not found in db;
hkAlice Mar 24, 2023
6bd8dee
EncounterFight and state refactor;
hkAlice Mar 24, 2023
fd768eb
fix crash on bnpc fsm nullptr;
hkAlice Mar 24, 2023
9331fa3
wip: encounter timeline parsing
takhlaq Apr 29, 2024
41ac3b8
fix build
takhlaq May 5, 2024
6c5df82
more encounter timeline work
takhlaq May 6, 2024
05f9feb
wip: reorganise some timeline stuff
takhlaq May 6, 2024
342c30a
wip: refactor some encounter timeline stuff
takhlaq May 9, 2024
959df68
fix build
takhlaq May 9, 2024
daf906d
wip: add encounter combat state parsing
takhlaq May 9, 2024
f96c633
wip: encounter timepoint separate update from execute
takhlaq May 10, 2024
576930d
wip: encounter timeline use InstanceContentPtr instead of EncounterFi…
takhlaq May 10, 2024
025f57c
wip: more encounter timeline stuff
takhlaq May 10, 2024
43f9254
wip: refactor encounter timeline stuff to only modify state objects, …
takhlaq May 10, 2024
cf712cb
wip: encounter timeline actually populate the entry before adding to …
takhlaq May 10, 2024
a4d712f
wip: encounter timeline oops
takhlaq May 10, 2024
e4024a6
wip: timeline shit
takhlaq May 23, 2024
989e1ee
fix build
takhlaq May 23, 2024
b29971b
wip: timeline refactor to use Territory instead of just InstanceConte…
takhlaq May 27, 2024
8ce3dec
wip: timeline refactor to use condition's ui assigned id
takhlaq May 28, 2024
6f7198b
add debug command for actor move
takhlaq Jun 15, 2024
0e55c62
fix missing include in RNGMgr, expose rng engine
takhlaq Jun 19, 2024
011cf1b
add position offset calcs
takhlaq Jun 19, 2024
8fb9846
wip: initial target select filter work
takhlaq Jun 19, 2024
7cc3f65
split encounter timeline stuff into separate files
takhlaq Jun 20, 2024
26534d2
refactor timeline stuff, implement selectors
takhlaq Jun 21, 2024
29c9903
return const ref for Territory::getPlayers
takhlaq Jun 21, 2024
7b2ea40
encounter timeline fix json parsing
takhlaq Jun 22, 2024
2f4efec
fix some timeline bugs, temporarily disable gambits
takhlaq Jun 23, 2024
8c95254
fix timeline advancing, add ifrit normal encounter script
takhlaq Jun 23, 2024
9445bc0
fix 0 duration timepoints
takhlaq Jun 24, 2024
75a2fcb
reference conditions globally in timeline
takhlaq Jun 24, 2024
cf2d610
fick director bgm;
hkAlice Jun 25, 2024
34fc49f
added cbt;
hkAlice Jun 25, 2024
b38afc0
add left/right to nudge command
takhlaq Jun 25, 2024
e794df5
Merge branch 'bs-stuff' of https://github.com/hkAlice/Sapphire into b…
takhlaq Jun 25, 2024
3727306
add chara dirty flag, move bnpc position updates to tick
takhlaq Jun 25, 2024
73094fb
fix incorrect radius for bnpc
takhlaq Jun 26, 2024
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
Prev Previous commit
Next Next commit
add timers and enrage mechanic;
  • Loading branch information
hkAlice authored and takhlaq committed Jun 21, 2024
commit c1589c1f2094ee4b264261c5deda07942336b845
6 changes: 4 additions & 2 deletions src/world/Encounter/EncounterFight.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace Sapphire
bool m_bShouldFinish{ false };
StateStackPtr m_stateStack;
std::shared_ptr< EncounterFight > m_pEncounter;
uint64_t m_startTime{ 0 };

public:
EncounterState( std::shared_ptr< EncounterFight > pEncounter ) :
Expand All @@ -29,7 +30,7 @@ namespace Sapphire
bool shouldFinish() { return m_bShouldFinish; };

virtual void init() = 0;
virtual void update( double deltaTime ) = 0;
virtual void update( uint64_t deltaTime ) = 0;

virtual void finish() = 0;
};
Expand All @@ -53,7 +54,7 @@ namespace Sapphire

virtual void init() = 0;
virtual void start() = 0;
virtual void update( double deltaTime ) = 0;
virtual void update( uint64_t deltaTime ) = 0;
virtual void reset() = 0;

virtual void addState( EncounterState::EncounterStatePtr pState, bool initState = true ) = 0;
Expand All @@ -64,6 +65,7 @@ namespace Sapphire
virtual EncounterFightStatus getEncounterFightStatus() const = 0;

protected:
uint64_t m_startTime{ 0 };
EncounterState::StateStackPtr m_stateStack;
std::set< Entity::PlayerPtr > m_playerList;
std::unordered_map< uint32_t, Entity::BNpcPtr > m_bnpcs;
Expand Down
58 changes: 48 additions & 10 deletions src/world/Encounter/InstanceContent/IfritNormal.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ namespace Sapphire
static constexpr int IFRIT = 4126276;
static constexpr int HELLFIRE = 0;
};
class IfritStateOne : public EncounterState

class IfritStateTwo : public EncounterState
{
public:
IfritStateOne( EncounterFightPtr pEncounter ) : EncounterState( pEncounter )
IfritStateTwo( EncounterFightPtr pEncounter ) : EncounterState( pEncounter )
{
}

Expand All @@ -20,21 +21,35 @@ namespace Sapphire
Logger::info( "ifrit FAN CLUB GEOcities <blink>EUNUCH ONLY</blink>" );
}

void update( double deltaTime ) override
void update( uint64_t deltaTime ) override
{
if( m_startTime == 0 )
m_startTime = deltaTime;

auto timeElapsedMs = deltaTime - m_startTime;

auto pIfrit = m_pEncounter->getBNpc( IfritNormalData::IFRIT );

pIfrit->setRot( pIfrit->getRot() - .2f );
pIfrit->sendPositionUpdate();

if( timeElapsedMs > 5000 )
{
m_bShouldFinish = true;
}
}

void finish() override
{

Logger::info( "stage 2 done, going back to stage 1" );
}
};

class IfritStateTwo : public EncounterState

class IfritStateOne : public EncounterState
{
public:
IfritStateTwo( EncounterFightPtr pEncounter ) : EncounterState( pEncounter )
IfritStateOne( EncounterFightPtr pEncounter ) : EncounterState( pEncounter )
{
}

Expand All @@ -43,17 +58,36 @@ namespace Sapphire
Logger::info( "ifrit FAN CLUB GEOcities <blink>EUNUCH ONLY</blink>" );
}

void update( double deltaTime ) override
void update( uint64_t deltaTime ) override
{
if( m_startTime == 0 )
m_startTime = deltaTime;

auto timeElapsedMs = deltaTime - m_startTime;

auto pIfrit = m_pEncounter->getBNpc( IfritNormalData::IFRIT );

pIfrit->setRot( pIfrit->getRot() + .2f );
pIfrit->sendPositionUpdate();

if( timeElapsedMs > 5000 )
{
auto ifritTwoState = std::make_shared< IfritStateTwo >( m_pEncounter );
m_pEncounter->addState( ifritTwoState );
}

if( timeElapsedMs > 10000 )
{
pIfrit->hateListGetHighest()->die();
}
}

void finish() override
{

}
};


class IfritEncounterFight : public EncounterFight
{
public:
Expand All @@ -65,6 +99,7 @@ namespace Sapphire
void init() override
{
m_status = EncounterFightStatus::IDLE;
m_startTime = 0;

m_stateStack = std::make_shared< EncounterState::StateStack >();

Expand Down Expand Up @@ -93,22 +128,23 @@ namespace Sapphire
m_status = EncounterFightStatus::ACTIVE;
}

void update( double deltaTime ) override
void update( uint64_t deltaTime ) override
{
// todo: better way to start fights here..

auto ifrit = getBNpc( IfritNormalData::IFRIT );

if( ifrit; ifrit->hateListGetHighestValue() != 0 && m_status == EncounterFightStatus::IDLE )
{
m_startTime = deltaTime;
start();
}

if( m_status == EncounterFightStatus::ACTIVE && ifrit && !ifrit->hateListGetHighest()->isAlive() )
{
m_status = EncounterFightStatus::FAIL;
}

if( m_stateStack; !m_stateStack->empty() )
{
if( m_stateStack->top()->shouldFinish() )
Expand Down Expand Up @@ -150,6 +186,8 @@ namespace Sapphire
auto bnpc = m_bnpcs.find( layoutId );
if( bnpc != std::end( m_bnpcs ) )
return bnpc->second;

return nullptr;
}

void removeBNpc( uint32_t layoutId ) override
Expand Down