| 06-25-2009, 03:48 AM | #1 |
JASS:scope Necromancy initializer Init globals private constant integer SPELL = 'A00J' private constant integer HEROID = 'U000' private integer Count = 0 private timer TIMER = CreateTimer() private constant real TIMEOUT = 1 private group Casters = CreateGroup() private boolexpr b private boolexpr unitcheck endglobals private struct data implement AutoData static data temp unit target boolean used timer t method onDestroy takes nothing returns nothing endmethod endstruct private function CheckUnits takes nothing returns boolean local data d set d = d.temp return GetOwningPlayer(GetFilterUnit()) == GetOwningPlayer(d.target) and not IsUnitType(GetFilterUnit(),UNIT_TYPE_HERO) endfunction private function Check takes nothing returns boolean return GetUnitTypeId(GetFilterUnit()) == HEROID endfunction private function Conditions takes nothing returns boolean return GetLearnedSkill() == SPELL endfunction private function Remove takes nothing returns nothing local data d = GetTimerData(GetExpiredTimer()) set Damage[d.target] = Damage[d.target] - 5 set MaxMana[d.target] = MaxMana[d.target] - 50 call ReleaseTimer(d.t) call BJDebugMsg("released") set d.used = false endfunction private function DoEffect takes nothing returns nothing local unit u = GetEnumUnit() local unit t local data d = data[u] local data c set d.temp = d call GroupEnumUnitsInRange(ENUM_GROUP,GetUnitX(u),GetUnitY(u),600,unitcheck) loop set t = FirstOfGroup(ENUM_GROUP) exitwhen t == null set c = data[t] if c == 0 then set c = data.create() set c.used = false set c.target = t set c.t = NewTimer() set data[t] = d endif if not c.used then set c.used = true set Damage[u] = Damage[u] + 5 set MaxMana[u] = MaxMana[u] + 50 call BJDebugMsg("adding") call SetTimerData(c.t,d) call TimerStart(c.t,5,false,function Remove) endif call GroupRemoveUnit(ENUM_GROUP,t) endloop set u = null endfunction private function Loop takes nothing returns nothing call ForGroup(Casters,function DoEffect) endfunction private function Actions takes nothing returns nothing local unit u = GetTriggerUnit() local data d if not IsUnitInGroup(u,Casters) then set d = data.create() set d.target = u set data[u] = d endif if FirstOfGroup(Casters) == null then call TimerStart(TIMER,TIMEOUT,true,function Loop) endif call GroupAddUnit(Casters,d.target) set u = null endfunction //=========================================================================== private function Init takes nothing returns nothing local trigger t = CreateTrigger() call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_HERO_SKILL) call TriggerAddCondition(t,Condition(function Conditions)) call TriggerAddAction(t,function Actions ) set b = Filter(function Check) set unitcheck = Filter(function CheckUnits) endfunction endscope JASS:if not c.used then set c.used = true set Damage[u] = Damage[u] + 5 set MaxMana[u] = MaxMana[u] + 50 call BJDebugMsg("adding") call SetTimerData(c.t,d) call TimerStart(c.t,5,false,function Remove) endif This part is running 2 times although it's supposed to run once. |
| 06-25-2009, 03:58 AM | #2 |
maybe this part sets it to c.used to true JASS:if c == 0 then set c = data.create() set c.used = false set c.target = t set c.t = NewTimer() set data[t] = d endif |
| 06-25-2009, 03:59 AM | #3 |
It runs once, I did a debug message to check Value for unit goes 0 1 1 1 1 1 1 and so on.. One thing I noticed is that the first cast bugs only and runs 2 times, after that it works fine, what's wrong? |
| 06-25-2009, 05:54 AM | #4 |
Your code. (All of it) |
| 06-25-2009, 05:55 AM | #5 |
maybe the bug has something to do, not with c, but with data[t] not working properly the first time? |
| 06-25-2009, 07:44 AM | #6 |
No it works but solved by making a new script for UP. |
