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 The Helper:
    Hope you have safe travels my friend!
    +1
  • vypur85 vypur85:
    Wow spring time in Japan is awesome. Enjoy!
  • The Helper The Helper:
    Hopefully it will be more pleasure than work
  • vypur85 vypur85:
    Recently tried out ChatGPT about WE triggering. Wow it's capable of giving a somewhat legitimate response.
  • The Helper The Helper:
    I am sure it has read all the info on the forums here
  • The Helper The Helper:
    i think triggering is just scripting and chatgpt is real good at code
  • vypur85 vypur85:
    Yeah I suppose so. It's interesting how it can explain in so much detail.
  • vypur85 vypur85:
    But yet it won't work.
  • The Helper The Helper:
    it does a bad ass job doing excel vba code it has leveled me up at my job when I deal with excel that is for sure
  • vypur85 vypur85:
    Nice! I love Excel coding as well. Has always been using Google to help me. Maybe I'll use ChatGPT next time when I need it.
  • The Helper The Helper:
    yeah whatever it puts out even if it is not perfect I can fix it and the latest version of chatgpt can create websites from pictures it will not be long until it can do that with almost all the tools
    +1
  • The Helper The Helper:
    These new Chat AI programs are going to change everything everyone better Buckle the Fuck Up!
  • The Helper The Helper:
    oh and Happy Tuesday Evening! :)
    +1
  • jonas jonas:
    Im worried they'll change things for worse
  • jonas jonas:
    A lot more low quality content, a lot more half-baked stuff.
  • jonas jonas:
    If you're good enough to spot the mistakes of the answers you don't need it in the first place. If you aren't good enough, you're gonna rely on some half-correct stuff
  • The Helper The Helper:
    the earlier AI is and has been used extensively for publishing news and other content for a while now
  • jonas jonas:
    I used to be active on quora, it's now flooded with extremely similar, superficial answers that often miss the point of the question
  • N NJJ:
    hi
  • N NJJ:
    Hello, gathering all my old accounts… :)
    +1
  • The Helper The Helper:
    by all means gather it all up!
  • The Helper The Helper:
    Happy Thursday!
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

    The Helper Discord

    Members online

    No members online now.

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top