HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

help with this script please....

04-13-2007, 09:43 PM#1
shakib_028
this spell is suppose to slow the enemy down... according to hw much mana he has left... bt wat happens is it slows enemy down and after the duration is over the enemy get maxumim movement spell "522" perma.... can anyone explain to me why??

the code: the spell is based on cripple...

Code:
constant function Exhaustion_Buf takes nothing returns integer
  return 'B012'
endfunction

constant function Exhaustion_Abi takes nothing returns integer
  return 'A06B'
endfunction

constant function Exhaustion_Slow_Amount takes integer l returns real
  return 0.15*l
endfunction

function Trig_Exhaustion_Cond takes nothing returns boolean
  return GetSpellAbilityId() == Exhaustion_Abi()
endfunction  

function remove_exhaustion takes nothing returns nothing
  local trigger t = GetTriggeringTrigger()
  local unit v = GetHandleUnit(t, "victim")
  local real d = GetHandleReal(t, "speed")
  local integer l
  local real mm
  local real cm
  local real s = GetUnitMoveSpeed(v) + d
  
  if GetUnitAbilityLevel(v, Exhaustion_Buf()) <= 0 then 
    call SetUnitMoveSpeed(v, s)
    call FlushHandleLocals(t)
    call DestroyTrigger(t)
  else
    set mm = GetUnitState(v, UNIT_STATE_MAX_MANA) + 1  //prevent division by 0
    set cm = GetUnitState(v, UNIT_STATE_MANA) + 1
    set l = GetHandleInt(t, "level")
    call SetUnitMoveSpeed(v, s*Exhaustion_Slow_Amount(l)*cm/mm)   
    call SetHandleReal(t, "speed",s*(1-Exhaustion_Slow_Amount(l)*cm/mm))  
  endif
  set t = null
  set v = null
endfunction  

function Trig_Exhaustion_Actions takes nothing returns nothing
  local unit v = GetSpellTargetUnit()
  local unit c = GetTriggerUnit()
  local integer l = GetUnitAbilityLevel(c, Exhaustion_Abi())
  local real s = GetUnitMoveSpeed(v)
  local real mm = GetUnitState(v, UNIT_STATE_MAX_MANA) + 1  //prevent division by 0
  local real cm = GetUnitState(v, UNIT_STATE_MANA) + 1
  local trigger t = CreateTrigger()
  
  call SetUnitMoveSpeed(v, s*Exhaustion_Slow_Amount(l)*cm/mm)
  call SetHandleReal(t, "speed", s*(1 - Exhaustion_Slow_Amount(l)*cm/mm)) //reimbursed speed
  call SetHandleHandle(t, "victim", v)
  call SetHandleInt(t, "level", l)
  call TriggerRegisterTimerEvent(t, 0.3, true)
  call TriggerAddAction(t, function remove_exhaustion)  
endfunction

//===========================================================================
function InitTrig_Exhaustion takes nothing returns nothing
    set gg_trg_Exhaustion = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Exhaustion, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Exhaustion, Condition (function Trig_Exhaustion_Cond) )
    call TriggerAddAction( gg_trg_Exhaustion, function Trig_Exhaustion_Actions )
endfunction
04-13-2007, 09:56 PM#2
tamisrah
You should use JASS tags ([ JASS] [/jass]) when posting JASS scripts

To your question: Replace the line where you want to reset the movementspeed of your unit
Collapse JASS:
call SetUnitMoveSpeed(v,s)
with this
Collapse JASS:
call SetUnitMoveSpeed( v, GetUnitDefaultMoveSpeed(v) )
04-13-2007, 10:28 PM#3
The)TideHunter(
No.
Change:
local real s = GetUnitMoveSpeed(v) + d to a minus, as you are removing the bonus now, not giving him another one.
So it should be:
local real s = GetUnitMoveSpeed(v) - d