トップ > MAP作成 > Jass Script > ライブラリ集 > 偽回避 受けたダメージを0に軽減するライブラリ。どんなダメージでも軽減できる。ただしスキルの場合、ダメージは受けないがスタン等の効果は発生する。 ライブラリlibrary PseudoEvasion requires Handles // // オブジェクトエディタで、Item Life Bonus(AIlf) ベースのスキルを作成してください。 // 作成したスキルの Max Life Gained(DataA1) を最大値(99999) に設定したあと、 // そのスキルコード(下の例では'A003')を記入してください。 // private function HP_BOOST takes nothing returns integer return 'A003' endfunction private function LifeReset takes nothing returns nothing local timer ExpTimer = GetExpiredTimer() local unit EvadeUnit = GetHandleUnit (ExpTimer, "EvadeUnit") local real Oldlife = GetHandleReal (ExpTimer, "Oldlife") call UnitRemoveAbility (EvadeUnit,HP_BOOST()) call SetUnitState (EvadeUnit,UNIT_STATE_LIFE,Oldlife) call PauseTimer (ExpTimer) call DestroyTimer (ExpTimer) call FlushHandle (ExpTimer) set ExpTimer = null set EvadeUnit = null endfunction // // この関数を、EVENT_UNIT_DAMAGED から呼び出してください。 // 詳しい使い方は、後述の使用例を参考に。 // function Pseudo_Evasion takes unit EvadeUnit returns nothing local real Damage = GetEventDamage() local real Life = GetUnitState(EvadeUnit,UNIT_STATE_LIFE) local real MaxLife = GetUnitState(EvadeUnit,UNIT_STATE_MAX_LIFE) local timer PETimer = null if Life>.0 then if(Life-Damage<.0)or(Life+Damage>MaxLife)then call SetUnitState (EvadeUnit, UNIT_STATE_LIFE, MaxLife) call UnitAddAbility (EvadeUnit, HP_BOOST()) set PETimer = CreateTimer() call SetHandleAgent (PETimer, "EvadeUnit" , EvadeUnit) call SetHandleReal (PETimer, "Oldlife" , Life) call TimerStart (PETimer, 0 , false, function LifeReset) else call SetUnitState (EvadeUnit, UNIT_STATE_LIFE, Life+Damage) endif endif set PETimer = null endfunction endlibrary 使い方のサンプルgg_unit_H000_0000の受けたダメージ全てを軽減する例 function Trigger1_Actions takes nothing returns nothing call Pseudo_Evasion(gg_unit_H000_0000) endfunction //=========================================================================== function Trigger1 takes nothing returns nothing set TRIG = CreateTrigger( ) call TriggerRegisterUnitEvent(TRIG, gg_unit_H000_0000, EVENT_UNIT_DAMAGED ) call TriggerAddAction (TRIG, function Trigger1_Actions) set TRIG = null endfunction このように、EVENT_UNIT_DAMAGEDのイベントから呼び出す必要があります。 処理の説明ダメージを受ける直前に、食らう分のダメージを瞬時に回復させる、という方法で、ダメージをうけてないかのように振舞っています。 ただしこの場合
以上の場合で、回復しすぎたりHPを回復できなかったりすることがあります。 そこで、1,2に該当する場合は、タイマーを使って以下の処理を行っています。
必要なライブラリ |