Skip to content

Commit

Permalink
[3.x] WIP: Initial Action and StatusEffect implementation (#958)
Browse files Browse the repository at this point in the history
* Check statuses to determine valid lut entry

* Add duration field to statuses

* Rename buildEffects to make more sense

* Add basic generic handler for applying statuseffects

* Add more modifiers

* Add basic modifier impl for Chara

* Apply/remove modifiers for statuseffects

* Add some example statuses to lut

* Fix windows build error

* Don't clear tick effect

* Add status entry for Maim

* Apply status effects properly for self when having a target

* Fix hasStatusEffect to prevent duplicates

* Basic dot/hot ticks implemented

* Update HP on tick effects

* Apply effect to correct target

* Add method to simplify applying statuses to self

* Add job actions for warrior

* Add some actions and statuses for war

* Add even more modifiers

* Add statuseffect cost type

* Add option to not send statusremove order

* Change delModifier assert to return early instead

* Add option for scripts to enable the generic/lut handler

* Add enums for common action values

* fix indentation

* Fix modifier name for Defiance

* Remove status tick logging

* Move modifiers to statuseffect

* Add ParryPercent modifier

* Remove wrath when Defiance ends

* Apply modifiers in applyStatus

* Remove unused method

* Persistence for cross-class skills

* Add flags to StatusEffects

* Some exd struct fixes

* Some aoe work

* Add flags to lut

* Add missing changeclass

* Add SET_STATUS_ME to ActionIntegrity

* Improve offensive action check

* Add flag to overloaded applyStatusEffectSelf

* indentation fix

* Some calculation work

* Null-check ActionResultBuilder

---------

Co-authored-by: Lucy <44952533+Skyliegirl33@users.noreply.github.com>
Co-authored-by: Mordred <30826167+SapphireMordred@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 21, 2024
1 parent 5189042 commit 7bfd953
Show file tree
Hide file tree
Showing 37 changed files with 902 additions and 87 deletions.
163 changes: 152 additions & 11 deletions data/actions/player.json
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,18 @@
"restorePercentage": 0,
"nextCombo": [],
"statuses": {
"caster": [],
"caster": [
{
"id": 83,
"duration": 20000,
"modifiers": [
{
"modifier": "DefensePercent",
"value": 20
}
]
}
],
"target": []
}
},
Expand All @@ -414,7 +425,18 @@
"nextCombo": [],
"statuses": {
"caster": [],
"target": []
"target": [
{
"id": 244,
"duration": 30000,
"modifiers": [
{
"modifier": "TickDamage",
"value": 20
}
]
}
]
}
},
"34": {
Expand Down Expand Up @@ -478,7 +500,18 @@
45
],
"statuses": {
"caster": [],
"caster": [
{
"id": 85,
"duration": 24000,
"modifiers": [
{
"modifier": "DamageDealtPercent",
"value": 20
}
]
}
],
"target": []
}
},
Expand All @@ -493,7 +526,18 @@
"restorePercentage": 0,
"nextCombo": [],
"statuses": {
"caster": [],
"caster": [
{
"id": 86,
"duration": 20000,
"modifiers": [
{
"modifier": "AttackPowerPercent",
"value": 50
}
]
}
],
"target": []
}
},
Expand Down Expand Up @@ -523,7 +567,18 @@
"restorePercentage": 0,
"nextCombo": [],
"statuses": {
"caster": [],
"caster": [
{
"id": 87,
"duration": 20000,
"modifiers": [
{
"modifier": "HPPercent",
"value": 20
}
]
}
],
"target": []
}
},
Expand Down Expand Up @@ -574,7 +629,7 @@
},
"44": {
"name": "Vengeance",
"potency": 50,
"potency": 0,
"comboPotency": 0,
"flankPotency": 0,
"frontPotency": 0,
Expand All @@ -583,7 +638,18 @@
"restorePercentage": 0,
"nextCombo": [],
"statuses": {
"caster": [],
"caster": [
{
"id": 89,
"duration": 20000,
"modifiers": [
{
"modifier": "ReflectPhysical",
"value": 50
}
]
}
],
"target": []
}
},
Expand Down Expand Up @@ -643,7 +709,34 @@
"restorePercentage": 0,
"nextCombo": [],
"statuses": {
"caster": [],
"caster": [
{
"id": 91,
"duration": 0,
"modifiers": [
{
"modifier": "HPPercent",
"value": 25
},
{
"modifier": "DamageDealtPercent",
"value": -25
},
{
"modifier": "HealingMagicRecoveryPercent",
"value": 20
},
{
"modifier": "AccuracyPercent",
"value": 5
},
{
"modifier": "EnmityPercent",
"value": 20
}
]
}
],
"target": []
}
},
Expand Down Expand Up @@ -703,7 +796,12 @@
"restorePercentage": 0,
"nextCombo": [],
"statuses": {
"caster": [],
"caster": [
{
"id": 97,
"duration": 30000
}
],
"target": []
}
},
Expand Down Expand Up @@ -1176,7 +1274,19 @@
"restorePercentage": 0,
"nextCombo": [],
"statuses": {
"caster": [],
"caster": [
{
"id": 116,
"duration": 10000,
"flag": 4096,
"modifiers": [
{
"modifier": "CriticalHitPercent",
"value": 100
}
]
}
],
"target": []
}
},
Expand Down Expand Up @@ -2454,7 +2564,38 @@
"nextCombo": [],
"statuses": {
"caster": [],
"target": []
"target": [
{
"id": 180,
"duration": 24000,
"modifiers": [
{
"modifier": "TickDamage",
"value": 35
}
]
},
{
"id": 191,
"duration": 24000,
"modifiers": [
{
"modifier": "HealingRecoveryPercent",
"value": -20
}
]
},
{
"id": 240,
"duration": 24000,
"modifiers": [
{
"modifier": "HeavyPercent",
"value": 40
}
]
}
]
}
},
"169": {
Expand Down
13 changes: 7 additions & 6 deletions deps/datReader/Exd/Structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,14 +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;
uint8_t Unknown;
int8_t Learn;
uint8_t Learn;
int8_t UseClassJob;
int8_t SelectRange;
int8_t SelectCorpse;
int8_t AttackType;
Expand Down Expand Up @@ -430,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 @@ -2054,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
71 changes: 53 additions & 18 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 @@ -887,22 +888,55 @@ namespace Sapphire::Common
Perception = 73,

// Unique modifiers
HPPercent = 1000,
MPPercent = 1001,
TPPercent = 1002,
GPPercent = 1003,
CPPercent = 1004,
PhysicalDamagePercent = 1005,
MagicDamagePercent = 1006,
AttackPowerPercent = 1007,
DefensePercent = 1008,
AccuracyPercent = 1009,
EvasionPercent = 1010,
MagicDefensePercent = 1011,
CriticalHitPowerPercent = 1012,
CriticalHitResiliencePercent = 1013,
CriticalHitPercent = 1014,
EnmityPercent = 1015
TickHeal = 1000,
TickDamage = 1001,
StrengthPercent = 1002,
DexterityPercent = 1003,
VitalityPercent = 1004,
IntelligencePercent = 1005,
MindPercent = 1006,
PietyPercent = 1007,
HPPercent = 1008,
MPPercent = 1009,
TPPercent = 1010,
GPPercent = 1011,
CPPercent = 1012,
PhysicalDamagePercent = 1013,
MagicDamagePercent = 1014,
AttackPowerPercent = 1015,
DefensePercent = 1016,
AccuracyPercent = 1017,
EvasionPercent = 1018,
MagicDefensePercent = 1019,
CriticalHitPowerPercent = 1020,
CriticalHitResiliencePercent = 1021,
CriticalHitPercent = 1022,
EnmityPercent = 1023,
DamageDealtPercent = 1024,
DamageTakenPercent = 1025,
HealingMagicRecoveryPercent = 1026,
SlashingResistancePercent = 1027,
PiercingResistancePercent = 1028,
BluntResistancePercent = 1029,
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 All @@ -923,6 +957,7 @@ namespace Sapphire::Common
MagicPoints = 3,
TacticsPoints = 5,
TacticsPoints1 = 6,
StatusEffect = 10,
Sprint = 18,
// WARGauge = 22,
// DRKGauge = 25,
Expand Down Expand Up @@ -1830,8 +1865,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
Loading

0 comments on commit 7bfd953

Please sign in to comment.