- Joined
- Dec 4, 2019
- Messages
- 4
The spell is about the Thrall's feral spirit.
I made a Devotion aura based spell and gave it to the summoned wolves. It has a very small radius (Single target) and has 4 levels. The rawcode of the spell is 'W001'.
Plan was to check every 2s of gametime the number of Wolves in each of the Wolves' range of 400 and set the aura level equal to the number of wolves close by. (simulating a wolf pack, the more the merrier.)
Thing is, only one of the wolves gets updated, the rest have max aura no matter the distance from other wolves because they are getting summoned clumped up. Thrall's spell summons 4 wolves btw, vanilla stats.
Also (thanks to the BJDebugMsg) I know that the WolfPack function never gets to the end. I do not know why since (I think) there are no endless loops. I tried one single group with constant cleaning after each wolf check, and I tried 4 different groups (present code). I also tried using TriggerSleep with 1s wait in a loop simulating a periodic timer of 1s.
I am new to this site and Jass coding in general and I would appreciate some help
If I overstepped some rules, please let me know I will adjust the post.
Anyways, here's the code (it's messy I know, but I am a beginner, be gentle
)
Also used TimerUtilsEx library to my absolute confusion (timers are weird).
I made a Devotion aura based spell and gave it to the summoned wolves. It has a very small radius (Single target) and has 4 levels. The rawcode of the spell is 'W001'.
Plan was to check every 2s of gametime the number of Wolves in each of the Wolves' range of 400 and set the aura level equal to the number of wolves close by. (simulating a wolf pack, the more the merrier.)
Thing is, only one of the wolves gets updated, the rest have max aura no matter the distance from other wolves because they are getting summoned clumped up. Thrall's spell summons 4 wolves btw, vanilla stats.
Also (thanks to the BJDebugMsg) I know that the WolfPack function never gets to the end. I do not know why since (I think) there are no endless loops. I tried one single group with constant cleaning after each wolf check, and I tried 4 different groups (present code). I also tried using TriggerSleep with 1s wait in a loop simulating a periodic timer of 1s.
I am new to this site and Jass coding in general and I would appreciate some help
If I overstepped some rules, please let me know I will adjust the post.
Anyways, here's the code (it's messy I know, but I am a beginner, be gentle
Also used TimerUtilsEx library to my absolute confusion (timers are weird).
JASS:
scope WolfPack initializer Init
globals
private unit Wolf1
private unit Wolf2
private unit Wolf3
private unit Wolf4
private boolexpr b
private integer c
endglobals
private function WolfCheck takes unit u returns boolean
return (GetUnitName(u) == "Shadow Wolf" and GetWidgetLife(u) > 0.405)
endfunction
private function Filterb takes nothing returns boolean
return WolfCheck(GetFilterUnit())
endfunction
private function WolfPack takes nothing returns nothing
local group g_1
local group g_2
local group g_3
local group g_4
local integer w = 0
local unit u
//First Wolf
set g_1 = GetUnitsInRangeOfLocMatching(400, GetUnitLoc(Wolf1), b)
loop
set u = FirstOfGroup (g_1)
exitwhen (u==null)
set w=w+1
call GroupRemoveUnit (g_1, u)
endloop
call SetUnitAbilityLevel (Wolf1, 'W001', w)
call SetUnitAbilityLevel (Wolf1, 'W002', w)
set w=0
// Second Wolf
set g_2 = GetUnitsInRangeOfLocMatching(400, GetUnitLoc(Wolf2), b)
loop
set u = FirstOfGroup (g_2)
exitwhen (u==null)
set w=w+1
call GroupRemoveUnit(g_2,u)
endloop
call SetUnitAbilityLevel (Wolf2, 'W001', w)
call SetUnitAbilityLevel (Wolf2, 'W002', w)
set w=0
// Third Wolf
set g_3 = GetUnitsInRangeOfLocMatching(400, GetUnitLoc(Wolf3), b)
loop
set u = FirstOfGroup (g_3)
exitwhen (u==null)
set w=w+1
call GroupRemoveUnit(g_3,u)
endloop
call SetUnitAbilityLevel (Wolf3, 'W001', w)
call SetUnitAbilityLevel (Wolf3, 'W002', w)
set w=0
// Fourth Wolf
set g_4 = GetUnitsInRangeOfLocMatching(400, GetUnitLoc(Wolf4), b)
loop
set u = FirstOfGroup (g_4)
exitwhen (u==null)
set w=w+1
call GroupRemoveUnit(g_4,u)
endloop
call SetUnitAbilityLevel (Wolf4, 'W001', w)
call SetUnitAbilityLevel (Wolf4, 'W002', w)
set w=0
set c=c+1
call DestroyGroup (g_1)
call DestroyGroup (g_2)
call DestroyGroup (g_3)
call DestroyGroup (g_4)
set g_1=null
set g_2=null
set g_3=null
set g_4=null
call BJDebugMsg ("WolfPack done")
if c>29 then
set c=0
set Wolf1=null
set Wolf2=null
set Wolf3=null
set Wolf4=null
endif
endfunction
private function Actions takes nothing returns nothing
local group g
local unit u
local integer c = 0
local timer t
call TriggerSleepAction (1)
set t = NewTimer()
call BJDebugMsg ("Actions starting")
set g = GetUnitsInRangeOfLocMatching(1000, GetUnitLoc(GetTriggerUnit()), b)
set Wolf1 = FirstOfGroup(g)
call GroupRemoveUnit(g,Wolf1)
set Wolf2 = FirstOfGroup(g)
call GroupRemoveUnit(g,Wolf2)
set Wolf3 = FirstOfGroup(g)
call GroupRemoveUnit(g,Wolf3)
set Wolf4 = FirstOfGroup(g)
call GroupRemoveUnit(g,Wolf4)
call SetWidgetLife (Wolf1, 200)
call SetWidgetLife (Wolf2, 200)
call SetWidgetLife (Wolf3, 200)
call SetWidgetLife (Wolf4, 200)
call BJDebugMsg("B4 calling the functions")
call TimerStart (t, 2, true, function WolfPack )
call DestroyGroup (g)
set g=null
call BJDebugMsg ("Actions worked")
endfunction
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'T003'
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition (t,Condition(function Conditions))
call TriggerAddAction( t, function Actions )
set Wolf1= null
set Wolf2= null
set Wolf3= null
set Wolf4= null
set b= Condition (function Filterb)
endfunction
endscope