mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-05 18:24:12 +00:00
Imminuty updates (#925)
* WIP Immunities * Immunity getters * remove redundent variable replace it use with it's equivalent * remove unused lookups, fix typos * fix tests * added imunity test * address feedback * more immunity tests * explicit this
This commit is contained in:
@@ -35,6 +35,14 @@ ControllablePhysicsComponent::ControllablePhysicsComponent(Entity* entity) : Com
|
||||
m_DirtyPickupRadiusScale = true;
|
||||
m_IsTeleporting = false;
|
||||
|
||||
m_ImmuneToStunAttackCount = 0;
|
||||
m_ImmuneToStunEquipCount = 0;
|
||||
m_ImmuneToStunInteractCount = 0;
|
||||
m_ImmuneToStunJumpCount = 0;
|
||||
m_ImmuneToStunMoveCount = 0;
|
||||
m_ImmuneToStunTurnCount = 0;
|
||||
m_ImmuneToStunUseItemCount = 0;
|
||||
|
||||
if (entity->GetLOT() != 1) // Other physics entities we care about will be added by BaseCombatAI
|
||||
return;
|
||||
|
||||
@@ -71,7 +79,14 @@ void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bo
|
||||
outBitStream->Write(m_JetpackBypassChecks);
|
||||
}
|
||||
|
||||
outBitStream->Write0(); //This contains info about immunities, but for now I'm leaving it out.
|
||||
outBitStream->Write1(); // always write these on construction
|
||||
outBitStream->Write(m_ImmuneToStunMoveCount);
|
||||
outBitStream->Write(m_ImmuneToStunJumpCount);
|
||||
outBitStream->Write(m_ImmuneToStunTurnCount);
|
||||
outBitStream->Write(m_ImmuneToStunAttackCount);
|
||||
outBitStream->Write(m_ImmuneToStunUseItemCount);
|
||||
outBitStream->Write(m_ImmuneToStunEquipCount);
|
||||
outBitStream->Write(m_ImmuneToStunInteractCount);
|
||||
}
|
||||
|
||||
if (m_IgnoreMultipliers) m_DirtyCheats = false;
|
||||
@@ -298,3 +313,44 @@ void ControllablePhysicsComponent::RemoveSpeedboost(float value) {
|
||||
SetSpeedMultiplier(m_SpeedBoost / 500.0f); // 500 being the base speed
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::SetStunImmunity(
|
||||
const eStateChangeType state,
|
||||
const LWOOBJID originator,
|
||||
const bool bImmuneToStunAttack,
|
||||
const bool bImmuneToStunEquip,
|
||||
const bool bImmuneToStunInteract,
|
||||
const bool bImmuneToStunJump,
|
||||
const bool bImmuneToStunMove,
|
||||
const bool bImmuneToStunTurn,
|
||||
const bool bImmuneToStunUseItem){
|
||||
|
||||
if (state == eStateChangeType::POP){
|
||||
if (bImmuneToStunAttack && m_ImmuneToStunAttackCount > 0) m_ImmuneToStunAttackCount -= 1;
|
||||
if (bImmuneToStunEquip && m_ImmuneToStunEquipCount > 0) m_ImmuneToStunEquipCount -= 1;
|
||||
if (bImmuneToStunInteract && m_ImmuneToStunInteractCount > 0) m_ImmuneToStunInteractCount -= 1;
|
||||
if (bImmuneToStunJump && m_ImmuneToStunJumpCount > 0) m_ImmuneToStunJumpCount -= 1;
|
||||
if (bImmuneToStunMove && m_ImmuneToStunMoveCount > 0) m_ImmuneToStunMoveCount -= 1;
|
||||
if (bImmuneToStunTurn && m_ImmuneToStunTurnCount > 0) m_ImmuneToStunTurnCount -= 1;
|
||||
if (bImmuneToStunUseItem && m_ImmuneToStunUseItemCount > 0) m_ImmuneToStunUseItemCount -= 1;
|
||||
} else if (state == eStateChangeType::PUSH) {
|
||||
if (bImmuneToStunAttack) m_ImmuneToStunAttackCount += 1;
|
||||
if (bImmuneToStunEquip) m_ImmuneToStunEquipCount += 1;
|
||||
if (bImmuneToStunInteract) m_ImmuneToStunInteractCount += 1;
|
||||
if (bImmuneToStunJump) m_ImmuneToStunJumpCount += 1;
|
||||
if (bImmuneToStunMove) m_ImmuneToStunMoveCount += 1;
|
||||
if (bImmuneToStunTurn) m_ImmuneToStunTurnCount += 1;
|
||||
if (bImmuneToStunUseItem) m_ImmuneToStunUseItemCount += 1;
|
||||
}
|
||||
|
||||
GameMessages::SendSetStunImmunity(
|
||||
m_Parent->GetObjectID(), state, m_Parent->GetSystemAddress(), originator,
|
||||
bImmuneToStunAttack,
|
||||
bImmuneToStunEquip,
|
||||
bImmuneToStunInteract,
|
||||
bImmuneToStunJump,
|
||||
bImmuneToStunMove,
|
||||
bImmuneToStunTurn,
|
||||
bImmuneToStunUseItem
|
||||
);
|
||||
}
|
||||
|
@@ -264,6 +264,30 @@ public:
|
||||
|
||||
std::vector<float> GetActiveSpeedboosts() { return m_ActivePickupRadiusScales; };
|
||||
|
||||
/**
|
||||
* Push or Pop a layer of stun immunity to this entity
|
||||
*/
|
||||
void SetStunImmunity(
|
||||
const eStateChangeType state,
|
||||
const LWOOBJID originator = LWOOBJID_EMPTY,
|
||||
const bool bImmuneToStunAttack = false,
|
||||
const bool bImmuneToStunEquip = false,
|
||||
const bool bImmuneToStunInteract = false,
|
||||
const bool bImmuneToStunJump = false,
|
||||
const bool bImmuneToStunMove = false,
|
||||
const bool bImmuneToStunTurn = false,
|
||||
const bool bImmuneToStunUseItem = false
|
||||
);
|
||||
|
||||
// getters for stun immunities
|
||||
const bool GetImmuneToStunAttack() { return m_ImmuneToStunAttackCount > 0;};
|
||||
const bool GetImmuneToStunEquip() { return m_ImmuneToStunEquipCount > 0;};
|
||||
const bool GetImmuneToStunInteract() { return m_ImmuneToStunInteractCount > 0;};
|
||||
const bool GetImmuneToStunJump() { return m_ImmuneToStunJumpCount > 0;};
|
||||
const bool GetImmuneToStunMove() { return m_ImmuneToStunMoveCount > 0;};
|
||||
const bool GetImmuneToStunTurn() { return m_ImmuneToStunTurnCount > 0;};
|
||||
const bool GetImmuneToStunUseItem() { return m_ImmuneToStunUseItemCount > 0;};
|
||||
|
||||
private:
|
||||
/**
|
||||
* The entity that owns this component
|
||||
@@ -389,6 +413,17 @@ private:
|
||||
* The active speed boost for this entity
|
||||
*/
|
||||
float m_SpeedBoost;
|
||||
|
||||
/**
|
||||
* stun immunity counters
|
||||
*/
|
||||
int32_t m_ImmuneToStunAttackCount;
|
||||
int32_t m_ImmuneToStunEquipCount;
|
||||
int32_t m_ImmuneToStunInteractCount;
|
||||
int32_t m_ImmuneToStunJumpCount;
|
||||
int32_t m_ImmuneToStunMoveCount;
|
||||
int32_t m_ImmuneToStunTurnCount;
|
||||
int32_t m_ImmuneToStunUseItemCount;
|
||||
};
|
||||
|
||||
#endif // CONTROLLABLEPHYSICSCOMPONENT_H
|
||||
|
@@ -55,8 +55,17 @@ DestroyableComponent::DestroyableComponent(Entity* parent) : Component(parent) {
|
||||
m_LootMatrixID = 0;
|
||||
m_MinCoins = 0;
|
||||
m_MaxCoins = 0;
|
||||
m_ImmuneStacks = 0;
|
||||
m_DamageReduction = 0;
|
||||
|
||||
m_ImmuneToBasicAttackCount = 0;
|
||||
m_ImmuneToDamageOverTimeCount = 0;
|
||||
m_ImmuneToKnockbackCount = 0;
|
||||
m_ImmuneToInterruptCount = 0;
|
||||
m_ImmuneToSpeedCount = 0;
|
||||
m_ImmuneToImaginationGainCount = 0;
|
||||
m_ImmuneToImaginationLossCount = 0;
|
||||
m_ImmuneToQuickbuildInterruptCount = 0;
|
||||
m_ImmuneToPullToPointCount = 0;
|
||||
}
|
||||
|
||||
DestroyableComponent::~DestroyableComponent() {
|
||||
@@ -106,7 +115,16 @@ void DestroyableComponent::Reinitialize(LOT templateID) {
|
||||
|
||||
void DestroyableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, uint32_t& flags) {
|
||||
if (bIsInitialUpdate) {
|
||||
outBitStream->Write0(); //Contains info about immunities this object has, but it's left out for now.
|
||||
outBitStream->Write1(); // always write these on construction
|
||||
outBitStream->Write(m_ImmuneToBasicAttackCount);
|
||||
outBitStream->Write(m_ImmuneToDamageOverTimeCount);
|
||||
outBitStream->Write(m_ImmuneToKnockbackCount);
|
||||
outBitStream->Write(m_ImmuneToInterruptCount);
|
||||
outBitStream->Write(m_ImmuneToSpeedCount);
|
||||
outBitStream->Write(m_ImmuneToImaginationGainCount);
|
||||
outBitStream->Write(m_ImmuneToImaginationLossCount);
|
||||
outBitStream->Write(m_ImmuneToQuickbuildInterruptCount);
|
||||
outBitStream->Write(m_ImmuneToPullToPointCount);
|
||||
}
|
||||
|
||||
outBitStream->Write(m_DirtyHealth || bIsInitialUpdate);
|
||||
@@ -336,7 +354,7 @@ void DestroyableComponent::SetDamageReduction(int32_t value) {
|
||||
|
||||
void DestroyableComponent::SetIsImmune(bool value) {
|
||||
m_DirtyHealth = true;
|
||||
m_ImmuneStacks = value ? 1 : 0;
|
||||
m_ImmuneToBasicAttackCount = value ? 1 : 0;
|
||||
}
|
||||
|
||||
void DestroyableComponent::SetIsGMImmune(bool value) {
|
||||
@@ -439,7 +457,7 @@ void DestroyableComponent::SetAttacksToBlock(const uint32_t value) {
|
||||
}
|
||||
|
||||
bool DestroyableComponent::IsImmune() const {
|
||||
return m_ImmuneStacks > 0 || m_IsGMImmune;
|
||||
return m_IsGMImmune || m_ImmuneToBasicAttackCount > 0;
|
||||
}
|
||||
|
||||
bool DestroyableComponent::IsKnockbackImmune() const {
|
||||
@@ -804,12 +822,53 @@ void DestroyableComponent::SetFaction(int32_t factionID, bool ignoreChecks) {
|
||||
AddFaction(factionID, ignoreChecks);
|
||||
}
|
||||
|
||||
void DestroyableComponent::PushImmunity(int32_t stacks) {
|
||||
m_ImmuneStacks += stacks;
|
||||
}
|
||||
void DestroyableComponent::SetStatusImmunity(
|
||||
const eStateChangeType state,
|
||||
const bool bImmuneToBasicAttack,
|
||||
const bool bImmuneToDamageOverTime,
|
||||
const bool bImmuneToKnockback,
|
||||
const bool bImmuneToInterrupt,
|
||||
const bool bImmuneToSpeed,
|
||||
const bool bImmuneToImaginationGain,
|
||||
const bool bImmuneToImaginationLoss,
|
||||
const bool bImmuneToQuickbuildInterrupt,
|
||||
const bool bImmuneToPullToPoint) {
|
||||
|
||||
void DestroyableComponent::PopImmunity(int32_t stacks) {
|
||||
m_ImmuneStacks -= stacks;
|
||||
if (state == eStateChangeType::POP) {
|
||||
if (bImmuneToBasicAttack && m_ImmuneToBasicAttackCount > 0) m_ImmuneToBasicAttackCount -= 1;
|
||||
if (bImmuneToDamageOverTime && m_ImmuneToDamageOverTimeCount > 0) m_ImmuneToDamageOverTimeCount -= 1;
|
||||
if (bImmuneToKnockback && m_ImmuneToKnockbackCount > 0) m_ImmuneToKnockbackCount -= 1;
|
||||
if (bImmuneToInterrupt && m_ImmuneToInterruptCount > 0) m_ImmuneToInterruptCount -= 1;
|
||||
if (bImmuneToSpeed && m_ImmuneToSpeedCount > 0) m_ImmuneToSpeedCount -= 1;
|
||||
if (bImmuneToImaginationGain && m_ImmuneToImaginationGainCount > 0) m_ImmuneToImaginationGainCount -= 1;
|
||||
if (bImmuneToImaginationLoss && m_ImmuneToImaginationLossCount > 0) m_ImmuneToImaginationLossCount -= 1;
|
||||
if (bImmuneToQuickbuildInterrupt && m_ImmuneToQuickbuildInterruptCount > 0) m_ImmuneToQuickbuildInterruptCount -= 1;
|
||||
if (bImmuneToPullToPoint && m_ImmuneToPullToPointCount > 0) m_ImmuneToPullToPointCount -= 1;
|
||||
|
||||
} else if (state == eStateChangeType::PUSH){
|
||||
if (bImmuneToBasicAttack) m_ImmuneToBasicAttackCount += 1;
|
||||
if (bImmuneToDamageOverTime) m_ImmuneToDamageOverTimeCount += 1;
|
||||
if (bImmuneToKnockback) m_ImmuneToKnockbackCount += 1;
|
||||
if (bImmuneToInterrupt) m_ImmuneToInterruptCount += 1;
|
||||
if (bImmuneToSpeed) m_ImmuneToSpeedCount += 1;
|
||||
if (bImmuneToImaginationGain) m_ImmuneToImaginationGainCount += 1;
|
||||
if (bImmuneToImaginationLoss) m_ImmuneToImaginationLossCount += 1;
|
||||
if (bImmuneToQuickbuildInterrupt) m_ImmuneToQuickbuildInterruptCount += 1;
|
||||
if (bImmuneToPullToPoint) m_ImmuneToPullToPointCount += 1;
|
||||
}
|
||||
|
||||
GameMessages::SendSetStatusImmunity(
|
||||
m_Parent->GetObjectID(), state, m_Parent->GetSystemAddress(),
|
||||
bImmuneToBasicAttack,
|
||||
bImmuneToDamageOverTime,
|
||||
bImmuneToKnockback,
|
||||
bImmuneToInterrupt,
|
||||
bImmuneToSpeed,
|
||||
bImmuneToImaginationGain,
|
||||
bImmuneToImaginationLoss,
|
||||
bImmuneToQuickbuildInterrupt,
|
||||
bImmuneToPullToPoint
|
||||
);
|
||||
}
|
||||
|
||||
void DestroyableComponent::FixStats() {
|
||||
|
@@ -396,16 +396,31 @@ public:
|
||||
void Smash(LWOOBJID source, eKillType killType = eKillType::VIOLENT, const std::u16string& deathType = u"", uint32_t skillID = 0);
|
||||
|
||||
/**
|
||||
* Pushes a layer of immunity to this entity, making it immune for longer
|
||||
* @param stacks the amount of immunity to add
|
||||
* Push or Pop a layer of status immunity to this entity
|
||||
*/
|
||||
void PushImmunity(int32_t stacks = 1);
|
||||
void SetStatusImmunity(
|
||||
const eStateChangeType state,
|
||||
const bool bImmuneToBasicAttack = false,
|
||||
const bool bImmuneToDamageOverTime = false,
|
||||
const bool bImmuneToKnockback = false,
|
||||
const bool bImmuneToInterrupt = false,
|
||||
const bool bImmuneToSpeed = false,
|
||||
const bool bImmuneToImaginationGain = false,
|
||||
const bool bImmuneToImaginationLoss = false,
|
||||
const bool bImmuneToQuickbuildInterrupt = false,
|
||||
const bool bImmuneToPullToPoint = false
|
||||
);
|
||||
|
||||
/**
|
||||
* Pops layers of immunity, making it immune for less longer
|
||||
* @param stacks the number of layers of immunity to remove
|
||||
*/
|
||||
void PopImmunity(int32_t stacks = 1);
|
||||
// Getters for status immunities
|
||||
const bool GetImmuneToBasicAttack() {return m_ImmuneToBasicAttackCount > 0;};
|
||||
const bool GetImmuneToDamageOverTime() {return m_ImmuneToDamageOverTimeCount > 0;};
|
||||
const bool GetImmuneToKnockback() {return m_ImmuneToKnockbackCount > 0;};
|
||||
const bool GetImmuneToInterrupt() {return m_ImmuneToInterruptCount > 0;};
|
||||
const bool GetImmuneToSpeed() {return m_ImmuneToSpeedCount > 0;};
|
||||
const bool GetImmuneToImaginationGain() {return m_ImmuneToImaginationGainCount > 0;};
|
||||
const bool GetImmuneToImaginationLoss() {return m_ImmuneToImaginationLossCount > 0;};
|
||||
const bool GetImmuneToQuickbuildInterrupt() {return m_ImmuneToQuickbuildInterruptCount > 0;};
|
||||
const bool GetImmuneToPullToPoint() {return m_ImmuneToPullToPointCount > 0;};
|
||||
|
||||
/**
|
||||
* Utility to reset all stats to the default stats based on items and completed missions
|
||||
@@ -428,7 +443,7 @@ public:
|
||||
|
||||
/**
|
||||
* Notify subscribed scripts of Damage actions.
|
||||
*
|
||||
*
|
||||
* @param attacker The attacking Entity
|
||||
* @param damage The amount of damage that was done
|
||||
*/
|
||||
@@ -493,11 +508,6 @@ private:
|
||||
*/
|
||||
uint32_t m_AttacksToBlock;
|
||||
|
||||
/**
|
||||
* The layers of immunity this entity has left
|
||||
*/
|
||||
int32_t m_ImmuneStacks;
|
||||
|
||||
/**
|
||||
* The amount of damage that should be reduced from every attack
|
||||
*/
|
||||
@@ -577,6 +587,19 @@ private:
|
||||
* The list of scripts subscribed to this components actions
|
||||
*/
|
||||
std::map<LWOOBJID, CppScripts::Script*> m_SubscribedScripts;
|
||||
|
||||
/**
|
||||
* status immunity counters
|
||||
*/
|
||||
uint32_t m_ImmuneToBasicAttackCount;
|
||||
uint32_t m_ImmuneToDamageOverTimeCount;
|
||||
uint32_t m_ImmuneToKnockbackCount;
|
||||
uint32_t m_ImmuneToInterruptCount;
|
||||
uint32_t m_ImmuneToSpeedCount;
|
||||
uint32_t m_ImmuneToImaginationGainCount;
|
||||
uint32_t m_ImmuneToImaginationLossCount;
|
||||
uint32_t m_ImmuneToQuickbuildInterruptCount;
|
||||
uint32_t m_ImmuneToPullToPointCount;
|
||||
};
|
||||
|
||||
#endif // DESTROYABLECOMPONENT_H
|
||||
|
@@ -959,7 +959,7 @@ void InventoryComponent::HandlePossession(Item* item) {
|
||||
return;
|
||||
}
|
||||
|
||||
GameMessages::SendSetStunned(m_Parent->GetObjectID(), eStunState::PUSH, m_Parent->GetSystemAddress(), LWOOBJID_EMPTY, true, false, true, false, false, false, false, true, true, true, true, true, true, true, true, true);
|
||||
GameMessages::SendSetStunned(m_Parent->GetObjectID(), eStateChangeType::PUSH, m_Parent->GetSystemAddress(), LWOOBJID_EMPTY, true, false, true, false, false, false, false, true, true, true, true, true, true, true, true, true);
|
||||
|
||||
// Set the mount Item ID so that we know what were handling
|
||||
possessorComponent->SetMountItemID(item->GetId());
|
||||
|
@@ -54,7 +54,7 @@ void PossessorComponent::Mount(Entity* mount) {
|
||||
// GM's to send
|
||||
GameMessages::SendSetJetPackMode(m_Parent, false);
|
||||
GameMessages::SendVehicleUnlockInput(mount->GetObjectID(), false, m_Parent->GetSystemAddress());
|
||||
GameMessages::SendSetStunned(m_Parent->GetObjectID(), eStunState::PUSH, m_Parent->GetSystemAddress(), LWOOBJID_EMPTY, true, false, true, false, false, false, false, true, true, true, true, true, true, true, true, true);
|
||||
GameMessages::SendSetStunned(m_Parent->GetObjectID(), eStateChangeType::PUSH, m_Parent->GetSystemAddress(), LWOOBJID_EMPTY, true, false, true, false, false, false, false, true, true, true, true, true, true, true, true, true);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
EntityManager::Instance()->SerializeEntity(mount);
|
||||
|
@@ -95,7 +95,7 @@ void RailActivatorComponent::OnUse(Entity* originator) {
|
||||
|
||||
void RailActivatorComponent::OnRailMovementReady(Entity* originator) const {
|
||||
// Stun the originator
|
||||
GameMessages::SendSetStunned(originator->GetObjectID(), PUSH, originator->GetSystemAddress(), LWOOBJID_EMPTY,
|
||||
GameMessages::SendSetStunned(originator->GetObjectID(), eStateChangeType::PUSH, originator->GetSystemAddress(), LWOOBJID_EMPTY,
|
||||
true, true, true, true, true, true, true
|
||||
);
|
||||
|
||||
@@ -123,7 +123,7 @@ void RailActivatorComponent::OnRailMovementReady(Entity* originator) const {
|
||||
|
||||
void RailActivatorComponent::OnCancelRailMovement(Entity* originator) {
|
||||
// Remove the stun from the originator
|
||||
GameMessages::SendSetStunned(originator->GetObjectID(), POP, originator->GetSystemAddress(), LWOOBJID_EMPTY,
|
||||
GameMessages::SendSetStunned(originator->GetObjectID(), eStateChangeType::POP, originator->GetSystemAddress(), LWOOBJID_EMPTY,
|
||||
true, true, true, true, true, true, true
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user