| 05-07-2005, 02:17 PM | #1 |
Ok, because of the incredibly annoying bugged cast event responses, I decided to use local variables in a trigger. So far, it has gone all right, I translated all the actions that had to use the local variables to JASS and copied them into my GUI trigger as custom script lines. So far so good. However, I at some point came to the problem that I transformed a "pick all units in unit group" function to JASS and it turned into a entire function and a line that calls it. Seeing no way around it, I gave up on trying to have the whole trigger in, well, one trigger, and so I copied the function to the map header and the line that calls it to my trigger. Then I suddenly realized (dooh, I got a bunch of compile errors) I was using my local variables in that function, which was clearly wrong because the function is a separate thread. So, I changed the function to accept some parameters and used those in the function, and it no longer gives me any compile errors. However, I can't test yet if this bundle of JASS I mucked up actually works, because I have one more compile error, which I can't figure how to get rid of. It's in the line that calls this function, and I can't figure out how to write it properly, it says "Expected: ' ". So, here it is, first the now apparently unproblematic function: Code:
function DivineRetributionDamage takes integer HeroIndex, integer BaseDamage returns nothing
call AddSpecialEffectTargetUnitBJ( "origin", GetEnumUnit(), "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl" )
call DestroyEffectBJ( GetLastCreatedEffectBJ() )
call UnitDamageTargetBJ( udg_GPHero[HeroIndex], GetEnumUnit(), I2R(( BaseDamage / 2 )), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL )
endfunctionCode:
call ForGroupBJ( udg_TempCSUnitGroup[AnotherOneJustBecauseICan], function DivineRetributionDamage( AnotherOneJustBecauseICan, TempInt ) ) |
| 05-07-2005, 02:49 PM | #2 |
Blizzard is doing it wrong, you can't pass arguments to enumerating functions. You will have to use temporary a global variable to save the value of the local Or you can use something like this: Code:
local unit p
local group g=#the group for the enum#
loop
set p=FirstOfGroup(g)
exitwhen (p==null)
call GroupRemoveUnit(g,p)
//Do stuff with p as if it was the picked unit
endloop |
| 05-07-2005, 03:26 PM | #3 | |
Quote:
|
| 05-08-2005, 10:42 PM | #4 |
Not using p would only mean a lost of execution time and the risk of FirstOfGroup giving other value. |
| 05-09-2005, 01:39 AM | #5 |
That's a risk? I thought FirstOfGroup was, well, first of a group, always the same unless the group changes, which it doesn't untill you remove the unit from it, but by then you already want it to pick a differnet unit the next time the loop runs. Well, not to be arguing or anything, I used a unit anyway, just asking myself some questions so I'm not just a dumb follower. :) |
| 05-09-2005, 05:47 PM | #6 |
FirstOfGroup could change accidentally if one of the pieces of code you have inside the loop, make a trigger with an action run and if the action does something with a unit inside the group. Could happen. But most likelly blizzard always make weird things, really weird things and FirstOfGroup not always giving the same value could happen. |
