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.
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.
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.