Make wrapper for casting skills (#987)

* Make wrapper for casting skills
this is to reduce magic numbers in the code base

Only updated one use of this to demo that this works.
Will be do more in a sepearate PR.

Also, inadvertantly fix damage stacking and self-damage in the teslapack

* add skill<->behavior caching

* explicit by reference

* address emo's feedback
This commit is contained in:
Aaron Kimbrell
2023-02-10 02:30:17 -06:00
committed by GitHub
parent 91c0c1fcfb
commit 3cd0d1ec3d
7 changed files with 46 additions and 11 deletions

View File

@@ -119,6 +119,15 @@ public:
*/
void RegisterPlayerProjectile(LWOOBJID projectileId, BehaviorContext* context, const BehaviorBranchContext& branch, LOT lot);
/**
* Wrapper for CalculateBehavior that mimics the call structure in scripts and helps reduce magic numbers
* @param skillId the skill to cast
* @param target the target of the skill
* @param optionalOriginatorID change the originator of the skill
* @return if the case succeeded
*/
bool CastSkill(const uint32_t skillId, LWOOBJID target = LWOOBJID_EMPTY, const LWOOBJID optionalOriginatorID = LWOOBJID_EMPTY);
/**
* Initializes a server-side skill calculation.
* @param skillId the skill ID
@@ -190,6 +199,11 @@ private:
*/
uint32_t m_skillUid;
/**
* Cache for looking up a behavior id via a skill ID
*/
static std::unordered_map<uint32_t, uint32_t> m_skillBehaviorCache;
/**
* Sync a server-side projectile calculation.
* @param entry the projectile information