Spell Forestborn

tommerbob

Minecraft. :D
Reaction score
110
That was a little confusing, but okay. It will make more sense the more I work with Jass, I'm sure.

Well, I got it to save with no errors, but now function NearTrees will not run. I put in a Debug message, and it doesn't show up.

JASS:
private function NearTree takes nothing returns nothing
    local Data data = GetTimerData(GetExpiredTimer())
    local location l = GetUnitLoc(D.caster)
 
    set D = data
    
    set D.tree = false
    
    call BJDebugMsg("This function is running")
    
    call EnumDestructablesInCircleBJ(AOE, l, function TreeCheck) //Picks every destructable in range
    
    if D.tree == true then
        if CAN_MOVE != true then                //If the caster should not move, updates his location.
            set D.newx = GetUnitX(D.caster)
            set D.newy = GetUnitY(D.caster)
            if D.newx != D.oldx or D.newy != D.oldy then
                set D.oldx = GetUnitX(D.caster)
                set D.oldy = GetUnitY(D.caster)
                call UnitRemoveAbility(D.caster, BOOK_ID)        //Remove bonuses if not stationary
                call UnitRemoveAbility(D.caster, BUFF_ID)        //Remove buff
            else
                call UnitAddAbility(D.caster, BOOK_ID)
                call SetUnitAbilityLevel(D.caster, EVADE_ID, D.evasion) //Sets evasion if near a tree and is stationary. 
                if HEAL_BASE > 0. then                                  //Heals caster if he is near a tree and is stationary.
                    call SetUnitState(D.caster, UNIT_STATE_LIFE, GetUnitState(D.caster, UNIT_STATE_LIFE) + D.heal)
                endif
            endif
        else
            call UnitAddAbility(D.caster, BOOK_ID)
            call SetUnitAbilityLevel(D.caster, MOVE_ID, D.movebonus)  //Sets the move bonus if near a tree
            call SetUnitAbilityLevel(D.caster, EVADE_ID, D.evasion) //Sets evasion if near a tree    
            if HEAL_BASE > 0. then                                  //Heals caster if near a tree
                call SetUnitState(D.caster, UNIT_STATE_LIFE, GetUnitState(D.caster, UNIT_STATE_LIFE) + D.heal)
            endif
        endif
    else 
        call UnitRemoveAbility(D.caster, BOOK_ID)     //Remove bonuses if not near a tree
        call UnitRemoveAbility(D.caster, BUFF_ID)     //Remove buff
    endif
    
    set D.time = D.time + INTERVAL
    if D.time >= D.duration then
        set D.tree = false
        call UnitRemoveAbility(D.caster, BOOK_ID)  //Removes evasion at end of duration
        call UnitRemoveAbility(D.caster, BUFF_ID)  //Remove buff
        call D.destroy()
    endif
    
    call RemoveLocation(l)
    set l = null
endfunction

private function Actions takes nothing returns boolean
    local Data data
    
    if GetSpellAbilityId() != SPELL_ID then
        return false
    endif
    
    set data = Data.create(GetTriggerUnit())
    
    call SetPlayerAbilityAvailable(GetOwningPlayer(GetTriggerUnit()), BOOK_ID, false) //Remove icons from hero UI
    call SetTimerData(data.t, data)
    call TimerStart(data.t, INTERVAL, true, function NearTree)
    
    return false
endfunction

My head hurts at this point. I'm more confused now than I was yesterday. :banghead: I think I need a really good concise simplified tutorial on structs and all this jazz. I should have put this in the Jass section before uploading it. :p
 

tooltiperror

Super Moderator
Reaction score
231
Andrewgosu wrote a golden tutorial on structs that should help you out.

Basically, I think you're not thinking of structs as objects, you're thinking of them as a machine would.
 

tommerbob

Minecraft. :D
Reaction score
110
Okay thanks. So do you know why the function won't run though?

Wait...a machine? lawl.

After reading through that tutorial by Androwgosu (which was very useful by the way. Great tutorial), and looking over my Action function again, I don't see what I am doing wrong. It should be calling the NearTree function, but its not.
 

tommerbob

Minecraft. :D
Reaction score
110
Bump for approval. I realize the staff is very busy, but if the spell is up to par, I'd like to see it approved. :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top