• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] need help

Status
Not open for further replies.
Level 16
Joined
Feb 22, 2006
Messages
960
I wrote this little spell... and it don't want to work

what did i wrong, because i can't see anything wrong

JASS:
struct holystruct
  unit target
  real life
  integer counter
  integer countertwo = 0
    method onDestroy takes nothing returns nothing
        set this.target = null
        set this.countertwo = 0
    endmethod
endstruct

function hlCondition takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction

function holytimer takes nothing returns nothing
  local timer t = GetExpiredTimer()
  local holystruct Dat = GetHandleInt(t,"struct")
  local effect sfx
  local real life
    set sfx = AddSpecialEffectTarget("Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl",Dat.target,"origin")
    set life = GetUnitState(Dat.target,UNIT_STATE_LIFE)
    call SetUnitState(Dat.target,UNIT_STATE_LIFE,life+Dat.life)
    call BJDebugMsg("Heal")    
    call DestroyEffect(sfx)
    set Dat.countertwo = Dat.countertwo + 1
    if (Dat.countertwo >= Dat.counter) then
        call DestroyTimer(t)
        call holystruct.destroy(Dat)
    endif
    set t = null    
endfunction

function hlActions takes nothing returns nothing
  local holystruct Dat = holystruct.create()
  local timer t = CreateTimer()
  local unit u = GetTriggerUnit()
  local unit tar = GetSpellTargetUnit()
  local integer counter = (4+(GetUnitAbilityLevelSwapped('A000',u)*1))  
    set Dat.target = tar
    set Dat.counter = counter
    set Dat.life = (GetHeroInt(u,true))    
    call TimerStart(t,1.00,true,function holytimer)
    call SetHandleInt(t,"struct",Dat)
    set u = null
    set tar = null
endfunction

function InitTrig_HolyLight takes nothing returns nothing
  local trigger HL = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(HL,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(HL,Condition(function hlCondition))
    call TriggerAddAction( HL, function hlActions )
  set HL = null  
endfunction
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Lol much.
Works perfectly(I think) here.
Though I can suggest using:
GetUnitAbilityLevel(u,'A000')

Instead of:
GetUnitAbilityLevelSwapped('A000',u)

And you didn't null t in hlActions
P.s. Though you can improve the code a bit by replacing stuff like:
JASS:
local effect sfx
  local real life
    set sfx = AddSpecialEffectTarget("Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl",Dat.target,"origin")
set life = GetUnitState(Dat.target,UNIT_STATE_LIFE)
with
JASS:
local effect sfx = AddSpecialEffectTarget("Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl",Dat.target,"origin")
  local real life = GetUnitState(Dat.target,UNIT_STATE_LIFE)
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
But, there is no problem...
If you think there is, please tell us what it is... cause my paranormal guessing skills are all used up for now.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
FFS.
What is not working...
I.e. Unit is not healed; No effect appears.
And for the last time already: It is working...
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
:D
Next, say what the problem is(along with the desired result). I.e. Syntax error.
 
Status
Not open for further replies.
Top