Skip to content

Commit

Permalink
Merge pull request #920 from Skyliegirl33/actions-war
Browse files Browse the repository at this point in the history
[3.x] Move modifier logic to StatusEffect, add parry, remove wrath
  • Loading branch information
SapphireMordred authored Mar 15, 2023
2 parents 4870b0b + 434eaa6 commit 9b3e793
Show file tree
Hide file tree
Showing 80 changed files with 1,970 additions and 1,729 deletions.
33 changes: 28 additions & 5 deletions data/actions/player.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"7": {
"name": "Attack",
"potency": 0,
"potency": 110,
"comboPotency": 0,
"flankPotency": 0,
"frontPotency": 0,
Expand All @@ -16,7 +16,7 @@
},
"8": {
"name": "Shot",
"potency": 0,
"potency": 100,
"comboPotency": 0,
"flankPotency": 0,
"frontPotency": 0,
Expand Down Expand Up @@ -629,7 +629,7 @@
},
"44": {
"name": "Vengeance",
"potency": 50,
"potency": 0,
"comboPotency": 0,
"flankPotency": 0,
"frontPotency": 0,
Expand All @@ -638,7 +638,18 @@
"restorePercentage": 0,
"nextCombo": [],
"statuses": {
"caster": [],
"caster": [
{
"id": 89,
"duration": 20000,
"modifiers": [
{
"modifier": "ReflectPhysical",
"value": 50
}
]
}
],
"target": []
}
},
Expand Down Expand Up @@ -1263,7 +1274,19 @@
"restorePercentage": 0,
"nextCombo": [],
"statuses": {
"caster": [],
"caster": [
{
"id": 116,
"duration": 10000,
"flag": 4096,
"modifiers": [
{
"modifier": "CriticalHitPercent",
"value": 100
}
]
}
],
"target": []
}
},
Expand Down
12 changes: 7 additions & 5 deletions deps/datReader/Exd/Structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,14 @@ namespace Excel
uint8_t EffectWidth;
uint8_t CostType;
uint8_t Cond;
uint8_t RecastGroup;
uint8_t Element;
uint8_t ProcStatus;
uint8_t UseClassJob;
uint8_t ClassJobCategory;
uint8_t RecastGroup;
uint8_t Init;
uint8_t Omen;
int8_t Learn;
uint8_t Learn;
int8_t UseClassJob;
int8_t SelectRange;
int8_t SelectCorpse;
int8_t AttackType;
Expand Down Expand Up @@ -429,7 +430,7 @@ namespace Excel
uint8_t HideCastBar : 1;
uint8_t IsTargetLine : 1;

int8_t padding0;
int8_t unknown : 8;
};

/* 75653 */
Expand Down Expand Up @@ -2053,7 +2054,8 @@ namespace Excel
uint8_t NotControl : 1;
uint8_t NotAction : 1;
uint8_t NotMove : 1;
uint8_t padding0 : 6;
uint8_t padding0 : 5;
uint8_t CanOff : 1;
uint8_t SemiTransparent : 1;
uint8_t FcAction : 1;
int8_t padding1[2];
Expand Down
1 change: 1 addition & 0 deletions sql/migrations/20230309164293_AddBorrowAction.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `characlass` ADD `BorrowAction` binary(40) DEFAULT NULL NULL AFTER `Lvl`;
4 changes: 3 additions & 1 deletion src/api/PlayerMinimal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,14 @@ void PlayerMinimal::saveAsNew()
break;
}

// CharacterId, ClassIdx, Exp, Lvl
// CharacterId, ClassIdx, Exp, Lvl, BorrowAction
auto stmtClass = g_charaDb.getPreparedStatement( Db::ZoneDbStatements::CHARA_CLASS_INS );
stmtClass->setUInt64( 1, m_characterId );
stmtClass->setInt( 2, g_exdData.getRow< Excel::ClassJob >( m_class )->data().WorkIndex );
stmtClass->setInt( 3, 0 );
stmtClass->setInt( 4, 1 );
std::vector< uint8_t > borrowActionVec( Common::ARRSIZE_BORROWACTION * 4 );
stmtClass->setBinary( 5, borrowActionVec );
g_charaDb.directExecute( stmtClass );

auto stmtSearchInfo = g_charaDb.getPreparedStatement( Db::ZoneDbStatements::CHARA_SEARCHINFO_INS );
Expand Down
27 changes: 23 additions & 4 deletions src/common/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace Sapphire::Common
const uint16_t ARRSIZE_UNLOCKS = 64u;
const uint16_t ARRSIZE_ORCHESTRION = 40u;
const uint16_t ARRSIZE_MONSTERNOTE = 12u;
const uint16_t ARRSIZE_BORROWACTION = 10u;

const uint8_t TOWN_COUNT = 6;

Expand Down Expand Up @@ -917,7 +918,25 @@ namespace Sapphire::Common
SlashingResistancePercent = 1027,
PiercingResistancePercent = 1028,
BluntResistancePercent = 1029,
ProjectileResistancePercent = 1030
ProjectileResistancePercent = 1030,
ParryPercent = 1031
};

enum class StatusEffectFlag : uint32_t
{
BuffCategory = 1,
DebuffCategory = 2,
Permanent = 4,
IsGaze = 8,
Transfiguration = 16,
CanDispel = 32,
LockActions = 64,
LockControl = 128,
LockMovement = 256,
Invisibilty = 512,
CanStatusOff = 1024,
FcBuff = 2048,
RemoveOnSuccessfulHit = 4096
};

enum struct ActionAspect : uint8_t
Expand Down Expand Up @@ -1034,7 +1053,7 @@ namespace Sapphire::Common
CritDirectHitDamage = 3
};

enum class ActionEffectResultFlag : uint8_t
enum class ActionResultFlag : uint8_t
{
None = 0,
Absorbed = 0x04,
Expand Down Expand Up @@ -1853,8 +1872,8 @@ namespace Sapphire::Common
{
SingleTarget = 1,
CircularAOE = 2,
Type3 = 3, // another single target? no idea how to call it
RectangularAOE = 4,
RectangularAOE = 3,
ConeAOE = 4,
CircularAoEPlaced = 7
};

Expand Down
6 changes: 3 additions & 3 deletions src/common/Database/ZoneDbConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ void Sapphire::Db::ZoneDbConnection::doPrepareStatements()
prepareStatement( CHARA_SEL_QUEST, "SELECT * FROM charaquest WHERE CharacterId = ?;", CONNECTION_SYNC );

/// CLASS INFO
prepareStatement( CHARA_CLASS_SEL, "SELECT ClassIdx, Exp, Lvl FROM characlass WHERE CharacterId = ?;",
prepareStatement( CHARA_CLASS_SEL, "SELECT ClassIdx, Exp, Lvl, BorrowAction FROM characlass WHERE CharacterId = ?;",
CONNECTION_SYNC );
prepareStatement( CHARA_CLASS_INS, "INSERT INTO characlass ( CharacterId, ClassIdx, Exp, Lvl ) VALUES( ?,?,?,? );",
prepareStatement( CHARA_CLASS_INS, "INSERT INTO characlass ( CharacterId, ClassIdx, Exp, Lvl, BorrowAction ) VALUES( ?,?,?,?,? );",
CONNECTION_BOTH );
prepareStatement( CHARA_CLASS_UP, "UPDATE characlass SET Exp = ?, Lvl = ? WHERE CharacterId = ? AND ClassIdx = ?;",
prepareStatement( CHARA_CLASS_UP, "UPDATE characlass SET Exp = ?, Lvl = ?, BorrowAction = ? WHERE CharacterId = ? AND ClassIdx = ?;",
CONNECTION_ASYNC );
prepareStatement( CHARA_CLASS_DEL, "DELETE FROM characlass WHERE CharacterId = ?;", CONNECTION_ASYNC );

Expand Down
5 changes: 1 addition & 4 deletions src/scripts/action/common/ActionSprint3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ class ActionSprint3 : public Sapphire::ScriptAPI::ActionScript
return;

uint32_t duration = ( sourceChara->getAsPlayer()->getTp() / 50 ) * 1000;

action.getEffectbuilder()->applyStatusEffect( sourceChara, 50, 30 );

sourceChara->getAsPlayer()->addStatusEffectByIdIfNotExist( 50, duration, *sourceChara, 30 );
action.getActionResultBuilder()->applyStatusEffectSelf( 50, duration, 30, false );
sourceChara->getAsPlayer()->setTp( 0 );
}
};
Expand Down
20 changes: 11 additions & 9 deletions src/scripts/action/war/ActionInnerBeast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <Actor/Player.h>
#include <Action/CommonAction.h>
#include <Action/Action.h>
#include <StatusEffect/StatusEffect.h>

using namespace Sapphire;
using namespace Sapphire::World::Action;
Expand All @@ -25,20 +26,21 @@ class ActionInnerBeast : public Sapphire::ScriptAPI::ActionScript
if( !pPlayer )
return;

if( !pPlayer->hasStatusEffect( Unchained ) )
pPlayer->delModifier( Common::ParamModifier::DamageDealtPercent, -25 );
if( auto status = pPlayer->getStatusEffectById( Defiance ); status )
status->setModifier( Common::ParamModifier::DamageDealtPercent, 0 );

auto dmg = action.calcDamage( Potency );
action.getEffectbuilder()->damage( pSource, pTarget, dmg.first, dmg.second );
action.getEffectbuilder()->heal( pTarget, pSource, dmg.first, Common::ActionHitSeverityType::NormalHeal,
Common::ActionEffectResultFlag::EffectOnSource );
action.getActionResultBuilder()->damage( pSource, pTarget, dmg.first, dmg.second );
action.getActionResultBuilder()->heal( pTarget, pSource, dmg.first, Common::ActionHitSeverityType::NormalHeal,
Common::ActionResultFlag::EffectOnSource );

action.applyStatusEffectSelf( InnerBeast );
pPlayer->addStatusEffectByIdIfNotExist( InnerBeast, 15000, *pSource,
{ StatusModifier{ Common::ParamModifier::DamageTakenPercent, -20 } } );
action.getActionResultBuilder()->applyStatusEffectSelf( InnerBeast, 15000, 0, { StatusModifier{ Common::ParamModifier::DamageTakenPercent, -20 } } );

if( !pPlayer->hasStatusEffect( Unchained ) )
pPlayer->addModifier( Common::ParamModifier::DamageDealtPercent, -25 );
{
if( auto status = pPlayer->getStatusEffectById( Defiance ); status )
status->setModifier( Common::ParamModifier::DamageDealtPercent, -25 );
}
}
};

Expand Down
7 changes: 4 additions & 3 deletions src/scripts/action/war/ActionUnchained.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <Actor/Player.h>
#include <Action/CommonAction.h>
#include <Action/Action.h>
#include <StatusEffect/StatusEffect.h>

using namespace Sapphire;
using namespace Sapphire::World::Action;
Expand All @@ -21,10 +22,10 @@ class ActionUnchained : public Sapphire::ScriptAPI::ActionScript
if( !pPlayer )
return;

pPlayer->delModifier( Common::ParamModifier::DamageDealtPercent, -25 );
if( auto status = pPlayer->getStatusEffectById( Defiance ); status )
status->setModifier( Common::ParamModifier::DamageDealtPercent, 0 );

action.applyStatusEffectSelf( Unchained );
pPlayer->addStatusEffectByIdIfNotExist( Unchained, 20000, *pPlayer->getAsChara() );
action.getActionResultBuilder()->applyStatusEffectSelf( Unchained, 20000, 0 );
}
};

Expand Down
5 changes: 3 additions & 2 deletions src/scripts/quest/festivalquest/FesEst101.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ class FesEst101 : public Sapphire::ScriptAPI::QuestScript

void Scene00002Return( World::Quest& quest, Entity::Player& player, const Event::SceneResult& result )
{
player.addStatusEffectById( Status0, 0, player, Transformation0 );
// todo - fix status effect without action?
//player.addStatusEffectById( Status0, 0, player, Transformation0 );
eventMgr().sendEventNotice( player, getId(), 0, 0 );
quest.setSeq( Seq2 );
}
Expand Down Expand Up @@ -294,7 +295,7 @@ class FesEst101 : public Sapphire::ScriptAPI::QuestScript

void Scene00010Return( World::Quest& quest, Entity::Player& player, const Event::SceneResult& result )
{
player.addStatusEffectById( Status0, 0, player, Transformation0 );
// player.addStatusEffectById( Status0, 0, player, Transformation0 );
}

//////////////////////////////////////////////////////////////////////
Expand Down
5 changes: 5 additions & 0 deletions src/scripts/statuseffect/StatusEffectDefiance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ class StatusEffectDefiance : public Sapphire::ScriptAPI::StatusEffectScript
void onExpire( Entity::Chara& actor ) override
{
actor.removeSingleStatusEffectById( Unchained );
actor.removeSingleStatusEffectById( Wrath );
actor.removeSingleStatusEffectById( WrathII );
actor.removeSingleStatusEffectById( WrathIII );
actor.removeSingleStatusEffectById( WrathIV );
actor.removeSingleStatusEffectById( Infuriated );
}
};

Expand Down
5 changes: 3 additions & 2 deletions src/scripts/statuseffect/StatusEffectUnchained.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <ScriptObject.h>
#include <Actor/Player.h>
#include <Action/CommonAction.h>
#include <StatusEffect/StatusEffect.h>

using namespace Sapphire;
using namespace Sapphire::World::Action;
Expand All @@ -15,8 +16,8 @@ class StatusEffectUnchained : public Sapphire::ScriptAPI::StatusEffectScript

void onExpire( Entity::Chara& actor ) override
{
if( actor.hasStatusEffect( Defiance ) )
actor.addModifier( Common::ParamModifier::DamageDealtPercent, -25 );
if( auto status = actor.getStatusEffectById( Defiance ); status )
status->setModifier( Common::ParamModifier::DamageDealtPercent, -25 );
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/tools/action_parse/actions/player.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"7": {
"name": "Attack",
"potency": 0,
"potency": 110,
"comboPotency": 0,
"flankPotency": 0,
"frontPotency": 0,
Expand All @@ -16,7 +16,7 @@
},
"8": {
"name": "Shot",
"potency": 0,
"potency": 100,
"comboPotency": 0,
"flankPotency": 0,
"frontPotency": 0,
Expand Down
2 changes: 2 additions & 0 deletions src/tools/action_parse/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ struct StatusEntry
{
uint16_t id;
int32_t duration;
uint32_t flag;
std::vector< StatusModifier > modifiers;
};

Expand Down Expand Up @@ -78,6 +79,7 @@ void to_json( nlohmann::ordered_json& j, const StatusEntry& statusEntry )
j = nlohmann::ordered_json{
{ "id", statusEntry.id },
{ "duration", statusEntry.duration },
{ "flag", statusEntry.flag },
{ "modifiers", statusEntry.modifiers }
};
}
Expand Down
Loading

0 comments on commit 9b3e793

Please sign in to comment.