Dota2 关闭基础生命/魔法恢复量
虽然现在使用Modifier来修改,但还是存在一些问题没解决,1级时没法修改成功,我在升级的事件dota_player_gained_level
来再次触发后可以修改,但是还存在一定的恢复量(0.x
的量)
//关闭基础血量/魔法恢复
@registerModifier()
export class modifierBaseRegenDisable extends APermanentModifier
{
IsHidden(): boolean
{
return true;
}
DeclareFunctions(): modifierfunction[]
{
return [
//关闭基础恢复
modifierfunction.MODIFIER_PROPERTY_HEALTH_REGEN_CONSTANT,
modifierfunction.MODIFIER_PROPERTY_MANA_REGEN_CONSTANT
]
}
private _healthValue:number = 0;
private _manaValue:number = 0;
private _getOwner() : CDOTA_BaseNPC_Hero
{
return this.GetParent() as CDOTA_BaseNPC_Hero;
}
GetHealthAndMana()
{
this.SetHasCustomTransmitterData(true);
this.ForceRefresh();
}
AddCustomTransmitterData(): TData
{
this._healthValue = this._getOwner().GetBaseHealthRegen();
this._manaValue =(this._getOwner() as CDOTA_BaseNPC_Hero).GetBaseManaRegen();
return {
hValue: this._healthValue,
mValue: this._manaValue
};
}
HandleCustomTransmitterData(data: NetworkedData<TData>)
{
this._healthValue = data.hValue;
this._manaValue = data.mValue;
}
GetModifierConstantManaRegen(): number
{
return -this._manaValue;
}
GetModifierConstantHealthRegen(): number
{
return -this._healthValue;
}
}
type TData = {hValue:number, mValue:number};
game_mode.ts
里的事件的内容
ListenToGameEvent("dota_player_gained_level", event =>
{
const hero = EntIndexToHScript(event.hero_entindex) as CDOTA_BaseNPC_Hero;
const buff = hero.FindModifierByName(modifierBaseRegenDisable.name) as modifierBaseRegenDisable;
if (buff)
buff.GetHealthAndMana();
}, this);