| 02-06-2007, 03:54 AM | #1 |
Why does this crash? and how do I fix it JASS:function mfs takes nothing returns nothing local group g local location loc local integer l local unit pick local location loc2 local set l = GetUnitAbilityLevelSwapped(GetSpellAbilityId(), GetTriggerUnit()) set loc = GetUnitLoc(GetTriggerUnit()) set g = GetUnitsInRangeOfLocAll(200.00 * l, loc) call ForGroupBJ(g,function mfs) set pick = GetEnumUnit() set loc2 = GetUnitLoc(pick) call AddSpecialEffectLocBJ(loc2,"Abilities\\Spells\\Undead\\ReplenishMana\\SpiritTouchTarget.mdl") call UnitDamageTargetBJ(GetTriggerUnit(),pick,l * 123,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL) call RemoveLocation(loc) call RemoveLocation(loc2) set loc = null set loc2 = null set l = null call DestroyGroup(g) set g = null pick = null endfunction |
| 02-06-2007, 03:58 AM | #2 |
Well, you have a JASS:local <blank> JASS:pick = null And another thing, I haven't really used the ForGroup function much yet, but wouldn't that leave open the possibility of a nearly infinite loop: JASS:call ForGroupBJ(g,function mfs) |
| 02-06-2007, 04:07 AM | #3 |
I recommend downloading JassCraft. It can check your scripts without the annoying crashes and has all the natives and blizzard function on hand. Download here It really helps! Take it from a new user of JassCraft. |
| 02-06-2007, 05:12 AM | #4 |
Ok, I dont understand how it loops infinite? cause, I dont understand where the loop is? im used to GUI so Im used to havingh Pick every unit in units blah Loop - Actions and putting the stuff to loop in there? But is the stuff I loop the function I call? |
| 02-06-2007, 05:20 AM | #5 |
Well, the way I see it, it would go like this: Code:
function mfs called, mfs makes group, calls the ForGroup on mfs
(for number of units in group) (say there's four units)
|—function mfs called, mfs makes group (and damages units)—————————————————— (call one / unit one)
|—function mfs called, mfs makes group (and damages units) -------------- (sub-call one / unit one)
|—function mfs called, mfs makes group (damages units) --------------- (sub-sub-call one / unit one)
|— . . . etc.
|—function mfs called, mfs makes group (and damages units) -------------- (sub-call two / unit two)
|—function mfs called, mfs makes group (and damages units) -------------- (sub-call three / unit three)
|—function mfs called, mfs makes group (and damages units) -------------- (sub-call four / unit four)
|—function mfs called, mfs makes group (and damages units)—————————————————— (call two)
|—function mfs called, mfs makes group (and damages units)
|— . . . (etc)
|—function mfs called, mfs makes group (and damages units)—————————————————— (call three)
|— . . . (etc)
|—function mfs called, mfs makes group (and damages units)—————————————————— (call four)
|— . . . (etc)The function you have now will pretty much make a group, call a function to loop through the group, but in doing so call itself, remake that group, then call itself again for every loop iteration, thus starting another chain of calls... resulting in a nearly infinite loop, ending whenever there are no more units available to pick (removed). In any case, that's just how I think it'd go, someone else would probably have more credibility in this area. If this is the case, though, you'd have to put all your actions concerning the group into a separate function and call that function with your ForGroup call. Check out how Blizzard does it: Trigger: Converted to JASS, it looks like this: JASS:function Trig_pickall_Func001A takes nothing returns nothing call KillUnit( GetEnumUnit() ) endfunction function Trig_pickall_Actions takes nothing returns nothing call ForGroupBJ( GetUnitsInRectAll(GetPlayableMapRect()), function Trig_pickall_Func001A ) endfunction //=========================================================================== function InitTrig_pickall takes nothing returns nothing set gg_trg_pickall = CreateTrigger( ) call TriggerAddAction( gg_trg_pickall, function Trig_pickall_Actions ) endfunction They have a separate function to handle what to do to each individual unit. |
