Skip to content

Commit

Permalink
see desc
Browse files Browse the repository at this point in the history
- Added Unit#BonusManaCostAmplifier
- Added new modifiers
- Improve Ability#ManaCost
  • Loading branch information
Sicdex committed Jul 11, 2024
1 parent 5426ab7 commit d564bc0
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 38 deletions.
21 changes: 12 additions & 9 deletions wrapper/Objects/Base/Ability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class Ability extends Entity {
@NetworkedBasicField("m_bStolen")
public IsStolen = false
@NetworkedBasicField("m_iManaCost")
public ManaCost = 0
public NetworkedManaCost = 0
@NetworkedBasicField("m_flOverrideCastPoint")
public OverrideCastPoint = 0
@NetworkedBasicField("m_flCooldownLength")
Expand Down Expand Up @@ -192,6 +192,13 @@ export class Ability extends Entity {
public get IsCooldownReady(): boolean {
return this.Cooldown === 0
}
public get ManaCost(): number {
const value = Math.max(
this.NetworkedManaCost,
this.GetBaseManaCostForLevel(this.Level)
)
return value * this.ManaCostAmplifier
}
public get IsReady(): boolean {
if (!this.IsCooldownReady || this.Level === 0) {
return false
Expand Down Expand Up @@ -315,6 +322,9 @@ export class Ability extends Entity {
public get CastPointAmplifier(): number {
return this.Owner?.BonusCastPointAmplifier ?? 1
}
public get ManaCostAmplifier(): number {
return this.Owner?.BonusManaCostAmplifier ?? 1
}
public get CastRangeAmplifier(): number {
return this.Owner?.CastRangeAmplifier ?? 1
}
Expand Down Expand Up @@ -344,7 +354,7 @@ export class Ability extends Entity {
}
public get AOERadius(): number {
const value = this.GetBaseAOERadiusForLevel(this.Level) + this.BonusAOERadius
return Math.max(value * this.BonusAOERadiusAmplifier, value)
return value * this.BonusAOERadiusAmplifier
}
public get SkillshotRange(): number {
return this.CastRange
Expand Down Expand Up @@ -399,7 +409,6 @@ export class Ability extends Entity {
scale
)
}

public GetMaxCooldownForLevel(level: number): number {
if (this.AbilityData.HasMaxCooldownSpecial) {
return this.GetSpecialValue("AbilityCooldown", level)
Expand Down Expand Up @@ -511,11 +520,9 @@ export class Ability extends Entity {
const delay = castDelay + activationDelay
return speed > 0 ? owner.Distance2D(unit) / speed + delay : delay
}

public GetRawDamage(target: Unit, _health?: number) {
return !this.IsDebuffImmune(target) ? this.AbilityDamage : 0
}

public GetDamage(target: Unit, _manaCost?: number) {
const owner = this.Owner
if (owner === undefined) {
Expand All @@ -532,7 +539,6 @@ export class Ability extends Entity {
// TODO: damage block, ex. rune shield etc
return rawDamage * amplification
}

public UseAbility(
target?: Vector3 | Entity,
checkAutoCast: boolean = false,
Expand All @@ -549,11 +555,9 @@ export class Ability extends Entity {
showEffects
)
}

public UpgradeAbility() {
return this.Owner?.TrainAbility(this)
}

public PingAbility() {
return this.Owner?.PingAbility(this)
}
Expand Down Expand Up @@ -617,7 +621,6 @@ export class Ability extends Entity {
public IsDoubleTap(_order: ExecuteOrder): boolean {
return false
}

protected IsDebuffImmune(target?: Unit): boolean {
return (
(target?.IsDebuffImmune ?? false) &&
Expand Down
44 changes: 16 additions & 28 deletions wrapper/Objects/Base/Modifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ export class Modifier {
public BonusTurnRateAmplifier = 0
public BonusTurnRateAmplifierStack = false

// Bonus / Reduction mana cost
public BonusManaCostAmplifier = 0
public BonusManaCostAmplifierStack = false

// move speed resistance
/** @readonly */
// TODO?
Expand Down Expand Up @@ -633,55 +637,48 @@ export class Modifier {
const value = this.GetSpecialValue(specialName)
this.BonusBaseAttackTime = subtract ? value * -1 : value
}

protected SetFixedBaseAttackTime(specialName?: string, subtract = false) {
if (specialName === undefined) {
return
}
const value = this.GetSpecialValue(specialName)
this.FixedBaseAttackTime = subtract ? value * -1 : value
}

protected SetBaseBonusAttackSpeed(specialName?: string, subtract = false) {
if (specialName === undefined) {
return
}
const value = this.GetSpecialValue(specialName)
this.BaseBonusAttackSpeed = subtract ? value * -1 : value
}

protected SetBonusBaseAttackSpeedAmplifier(specialName?: string, subtract = false) {
if (specialName === undefined) {
return
}
const value = this.GetSpecialValue(specialName)
this.BaseAttackSpeedAmplifier = (subtract ? value * -1 : value) / 100
}

protected SetAttackSpeedAmplifier(specialName?: string, subtract = false) {
if (specialName === undefined) {
return
}
const value = this.GetSpecialAttackSpeedByState(specialName)
this.AttackSpeedAmplifier = (subtract ? value * -1 : value) / 100
}

protected SetBonusAttackSpeed(specialName?: string, subtract = false) {
if (specialName === undefined) {
return
}
const value = this.GetSpecialAttackSpeedByState(specialName)
this.BonusAttackSpeed = subtract ? value * -1 : value
}

protected SetFixedAttackAnimationPoint(specialName?: string, subtract = false) {
if (specialName === undefined) {
return
}
const value = this.GetSpecialValue(specialName)
this.FixedAttackAnimationPoint = subtract ? value * -1 : value
}

protected GetSpecialAttackSpeedByState(specialName: string): number {
const isImmune = this.IsMagicImmune() || this.IsDebuffImmune()
const isPassiveDisabled = this.IsPassiveDisabled()
Expand All @@ -693,7 +690,6 @@ export class Modifier {
}
return this.GetSpecialValue(specialName)
}

/** ======================= Move Speed ======================= */
protected SetStatusResistanceSpeed(specialName?: string, subtract = false) {
if (specialName === undefined) {
Expand All @@ -702,39 +698,34 @@ export class Modifier {
const value = this.GetSpecialValue(specialName)
this.StatusResistanceSpeed = (subtract ? value * -1 : value) / 100
}

protected SetFixedMoveSpeed(specialName?: string, subtract = false) {
if (specialName === undefined) {
return
}
const value = this.GetSpecialMoveSpeedByState(specialName)
this.MoveSpeedFixed = subtract ? value * -1 : value
}

protected SetBonusMoveSpeed(specialName?: string, subtract = false) {
if (specialName === undefined) {
return
}
const value = this.GetSpecialMoveSpeedByState(specialName)
this.BonusMoveSpeed = subtract ? value * -1 : value
}

protected SetBaseMoveSpeed(specialName?: string, subtract = false) {
if (specialName === undefined) {
return
}
const value = this.GetSpecialMoveSpeedByState(specialName)
this.MoveSpeedBase = subtract ? value * -1 : value
}

protected SetBaseMoveSpeedAmplifier(specialName?: string, subtract = false) {
if (specialName === undefined) {
return
}
const value = this.GetSpecialMoveSpeedByState(specialName)
this.MoveSpeedBaseAmplifier = (subtract ? value * -1 : value) / 100
}

protected SetMoveSpeedAmplifier(
specialName?: string,
subtract: boolean = false
Expand All @@ -745,7 +736,6 @@ export class Modifier {
const value = this.GetSpecialMoveSpeedByState(specialName)
this.BonusMoveSpeedAmplifier = (subtract ? value * -1 : value) / 100
}

protected GetSpecialMoveSpeedByState(specialName: string): number {
const isImmuneSlow = this.ShouldUnslowable()
const isPassiveDisabled = this.IsPassiveDisabled()
Expand All @@ -757,7 +747,6 @@ export class Modifier {
}
return this.GetSpecialValue(specialName)
}

/** ======================= Day night vision ======================= */
protected SetBonusDayVision(specialName?: string, subtract = false) {
if (specialName === undefined) {
Expand All @@ -766,23 +755,20 @@ export class Modifier {
const value = this.GetSpecialValue(specialName)
this.BonusDayVision = subtract ? value * -1 : value
}

protected SetBonusDayVisionAmplifier(specialName?: string, subtract = false) {
if (specialName === undefined) {
return
}
const value = this.GetSpecialValue(specialName)
this.BonusDayVisionAmplifier = (subtract ? value * -1 : value) / 100
}

protected SetBonusNightVision(specialName?: string, subtract = false) {
if (specialName === undefined) {
return
}
const value = this.GetSpecialValue(specialName)
this.BonusNightVision = subtract ? value * -1 : value
}

/** ======================= Attack Range ======================= */
protected SetFixedAttackRange(specialName?: string, subtract = false) {
if (specialName === undefined) {
Expand All @@ -791,15 +777,13 @@ export class Modifier {
const value = this.GetSpecialValue(specialName)
this.FixedAttackRange = subtract ? value * -1 : value
}

protected SetBonusAttackRange(specialName?: string, subtract = false) {
if (specialName === undefined) {
return
}
const value = this.GetSpecialValue(specialName)
this.BonusAttackRange = subtract ? value * -1 : value
}

protected SetAttackRangeAmplifier(specialName?: string, subtract = false) {
if (specialName === undefined) {
return
Expand All @@ -808,7 +792,6 @@ export class Modifier {
const state = this.IsDebuff && (this.IsMagicImmune() || this.IsDebuffImmune())
this.AttackRangeAmplifier = !state ? (subtract ? value * -1 : value) / 100 : 0
}

/** ======================= Cast Range ======================= */
protected SetBonusCastRange(specialName?: string, subtract = false) {
if (specialName === undefined) {
Expand All @@ -817,7 +800,6 @@ export class Modifier {
const value = this.GetSpecialValue(specialName)
this.BonusCastRange = subtract ? value * -1 : value
}

protected SetCastRangeAmplifier(specialName?: string, subtract = false) {
if (specialName === undefined) {
return
Expand All @@ -826,7 +808,6 @@ export class Modifier {
const state = this.IsDebuff && (this.IsMagicImmune() || this.IsDebuffImmune())
this.CastRangeAmplifier = !state ? (subtract ? value * -1 : value) / 100 : 0
}

/** ======================= AOE Radius ======================= */
protected SetBonusAOERadius(specialName?: string, subtract = false) {
if (specialName === undefined) {
Expand All @@ -840,7 +821,7 @@ export class Modifier {
return
}
const value = this.GetSpecialValue(specialName)
this.BonusAOERadiusAmplifier = subtract ? value * -1 : value
this.BonusAOERadiusAmplifier = (subtract ? value * -1 : value) / 100
}
/** ======================= Turn rate ======================= */
protected SetFixedTurnRate(specialName?: string, subtract = false) {
Expand All @@ -857,7 +838,6 @@ export class Modifier {
const value = this.GetSpecialValue(specialName)
this.FixedBaseTurnRate = subtract ? value * -1 : value
}

protected SetBonusTurnRate(specialName?: string, subtract = false) {
if (specialName === undefined) {
return
Expand All @@ -866,7 +846,6 @@ export class Modifier {
const state = this.IsDebuff && (this.IsMagicImmune() || this.IsDebuffImmune())
this.BonusTurnRate = !state ? (subtract ? value * -1 : value) : 0
}

protected SetTurnRateAmplifier(specialName?: string, subtract = false) {
if (specialName === undefined) {
return
Expand All @@ -875,7 +854,6 @@ export class Modifier {
const state = this.IsDebuff && (this.IsMagicImmune() || this.IsDebuffImmune())
this.BonusTurnRate = !state ? (subtract ? value * -1 : value) / 100 : 0
}

/** ======================= Status Resistance ======================= */
protected SetStatusResistanceAmplifier(specialName?: string, subtract = false) {
if (specialName === undefined) {
Expand All @@ -884,7 +862,14 @@ export class Modifier {
const value = this.GetSpecialValue(specialName)
this.StatusResistanceAmplifier = (subtract ? value * -1 : value) / 100
}

/** ======================= Bonus / Reduction mana costs ======================= */
protected SetBonusManaCostAmplifier(specialName?: string, subtract = false) {
if (specialName === undefined) {
return
}
const value = this.GetSpecialValue(specialName)
this.BonusManaCostAmplifier = (subtract ? value * -1 : value) / 100
}
/** @description NOTE: does not include talents (recommended use only items) */
protected byAbilityData(
abilName: string,
Expand Down Expand Up @@ -955,6 +940,9 @@ export class Modifier {

// cast point
this.SetBonusCastPointAmplifier()

// mana cost
this.SetBonusManaCostAmplifier()
}

private ThroughMagicImmunity(unit?: Unit, caster?: Unit) {
Expand Down
22 changes: 22 additions & 0 deletions wrapper/Objects/Base/Unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,9 @@ export class Unit extends Entity {
public get BonusAOERadiusAmplifier(): number {
return this.CalcualteBonusAOERadiusAmplifier()
}
public get BonusManaCostAmplifier(): number {
return this.CalcualteBonusManaCostAmplifier()
}
public get BaseStatusResistance(): number {
// maybe valve add new future status resist
return 0
Expand Down Expand Up @@ -2575,6 +2578,25 @@ export class Unit extends Entity {
}
return totalBonus
}

/** ================================ Cast point ======================================= */
protected CalcualteBonusManaCostAmplifier() {
let amp = 1
const buffs = this.Buffs,
names = new Set<string>()
for (let index = buffs.length - 1; index > -1; index--) {
const buff = buffs[index]
if (!buff.BonusManaCostAmplifier) {
continue
}
if (!buff.BonusManaCostAmplifierStack && names.has(buff.Name)) {
continue
}
names.add(buff.Name)
amp += buff.BonusManaCostAmplifier
}
return amp
}
}

export const Units = EntityManager.GetEntitiesByClass(Unit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { WrapperClassModifier } from "../../../Decorators"
import { Modifier } from "../../Base/Modifier"

@WrapperClassModifier()
export class modifier_item_kaya_and_sange extends Modifier {}
export class modifier_item_heavens_halberd extends Modifier {}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,11 @@ export class modifier_item_kaya_and_sange extends Modifier {
) {
super.SetStatusResistanceAmplifier(specialName, subtract)
}

public SetBonusManaCostAmplifier(
specialName = "manacost_reduction",
subtract = true
): void {
super.SetBonusManaCostAmplifier(specialName, subtract)
}
}
Loading

0 comments on commit d564bc0

Please sign in to comment.