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

RPG: Make each attack/defend trigger for all equipment types #509

Merged
merged 1 commit into from
Jun 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 39 additions & 4 deletions drodrpg/DRODLib/Combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,11 +605,19 @@ bool CCombat::Advance(
//NOTE: Only process this when not simulating a combat outcome
//to avoid script commands that change the room state being executed.

//Process player's custom weapon script.
//Process player's custom equipment scripts.
CCharacter* pCharacter = this->pGame->getCustomEquipment(ScriptFlag::Weapon);
if (pCharacter)
pCharacter->ProcessAfterAttack(CueEvents);

pCharacter = this->pGame->getCustomEquipment(ScriptFlag::Armor);
if (pCharacter)
pCharacter->ProcessAfterAttack(CueEvents);

pCharacter = this->pGame->getCustomEquipment(ScriptFlag::Accessory);
if (pCharacter)
pCharacter->ProcessAfterAttack(CueEvents);

if (!pMonsterBeingFought->ProcessAfterDefend(CueEvents))
{
bEndCombat = true;
Expand All @@ -635,11 +643,19 @@ bool CCombat::Advance(
//Update the monster's HP if this is an actual fight.
pMonsterBeingFought->HP = monHP;

//Process player's custom weapon script.
//Process player's custom equipment scripts.
CCharacter* pCharacter = this->pGame->getCustomEquipment(ScriptFlag::Weapon);
if (pCharacter)
pCharacter->ProcessAfterAttack(CueEvents);

pCharacter = this->pGame->getCustomEquipment(ScriptFlag::Armor);
if (pCharacter)
pCharacter->ProcessAfterAttack(CueEvents);

pCharacter = this->pGame->getCustomEquipment(ScriptFlag::Accessory);
if (pCharacter)
pCharacter->ProcessAfterAttack(CueEvents);

if (!pMonsterBeingFought->ProcessAfterDefend(CueEvents))
{
bEndCombat = true;
Expand Down Expand Up @@ -738,10 +754,18 @@ bool CCombat::Advance(
BeginFightingNextQueuedMonster(CueEvents);
}

//Process player's custom armor script.
//Process player's custom equipment scripts.
CCharacter* pCharacter = this->pGame->getCustomEquipment(ScriptFlag::Armor);
if (pCharacter)
pCharacter->ProcessAfterDefend(CueEvents);

pCharacter = this->pGame->getCustomEquipment(ScriptFlag::Weapon);
if (pCharacter)
pCharacter->ProcessAfterDefend(CueEvents);

pCharacter = this->pGame->getCustomEquipment(ScriptFlag::Accessory);
if (pCharacter)
pCharacter->ProcessAfterDefend(CueEvents);
}

//Check for player death after scripts are processed.
Expand Down Expand Up @@ -893,11 +917,22 @@ void CCombat::MonsterAttacksPlayerOnce(CCueEvents& CueEvents)
ASSERT(!this->bSimulated);
this->pMonster->ProcessAfterAttack(CueEvents);

//Process player's custom armor script.
//Process player's custom equipment scripts.
CCharacter* pCharacter = this->pGame->getCustomEquipment(ScriptFlag::Armor);
if (pCharacter)
pCharacter->ProcessAfterDefend(CueEvents);
CCharacter* pCharacter = this->pGame->getCustomEquipment(ScriptFlag::Armor);
if (pCharacter)
pCharacter->ProcessAfterDefend(CueEvents);

pCharacter = this->pGame->getCustomEquipment(ScriptFlag::Weapon);
if (pCharacter)
pCharacter->ProcessAfterDefend(CueEvents);

pCharacter = this->pGame->getCustomEquipment(ScriptFlag::Accessory);
if (pCharacter)
pCharacter->ProcessAfterDefend(CueEvents);

//Check for player death after scripts are processed.
if (!ps.HP)
CueEvents.Add(CID_MonsterKilledPlayer, this->pMonster);
Expand Down