| 10-05-2008, 10:07 AM | #2 |
Sorry to bump a thread so young but I ended up having a new problem along the road... JASS:function Trig_Swap_I_Actions takes nothing returns nothing local integer i = 0 local integer i2 = 0 local group g = CreateGroup() local group g2 = CreateGroup() local unit u = GetSpellTargetUnit() local real x = 0 local real y = 0 set udg_MovesTaken = udg_MovesTaken + 1 call GroupEnumUnitsInRange(g, GetUnitX(u), GetUnitY(u), 200., null) call GroupRemoveUnit(g, gg_unit_E000_0021) call KillUnit(GetAttacker()) loop exitwhen u==null set u = FirstOfGroup(g) if GetUnitTypeId(u) == 'h001' and GetUnitTypeId(u) != 'h002' then set x = GetUnitX(u) set y = GetUnitY(u) call ReplaceUnitBJ(u, 'h000', bj_UNIT_STATE_METHOD_ABSOLUTE) call SetUnitOwner(u, Player(9), true) elseif GetUnitTypeId(u) == 'h000' and GetUnitTypeId(u) != 'h002' then set x = GetUnitX(u) set y = GetUnitY(u) call ReplaceUnitBJ(u, 'h001', bj_UNIT_STATE_METHOD_ABSOLUTE) call SetUnitOwner(u, Player(11), true) endif call GroupRemoveUnit(g, u) endloop call DestroyGroup(g) set u = GetTriggerUnit() call GroupEnumUnitsOfType(g2, 'On', null) loop exitwhen u == null set u = FirstOfGroup(g2) if GetUnitTypeId(u) == 'h001' then set i = i + 1 endif endloop call BJDebugMsg("Lights: "+I2S(i)) if i == 0 then set udg_Integer2 = udg_Integer2 + 1 endif call DestroyGroup(g) set u = null set g = null endfunction It's telling me that line has an "Expected expression" and I don't know what to do, I had it before but now it's not working for some reason. |
| 10-05-2008, 10:48 AM | #3 |
What is 'On' ?? To which unit is it refereeing to ? Maybe you will have to use something like H2S ... not sure though, need more info. |
| 10-05-2008, 10:49 AM | #4 |
Because the type of argument is NOT integer, but string: JASS:native GroupEnumUnitsOfType takes group whichGroup, string unitname, boolexpr filter returns nothing JASS:call GroupEnumUnitsOfType(g2, "On", null) |
| 10-05-2008, 10:53 AM | #5 |
Oh shit, I keep forgetting that uses strings. Warghabargle, all the other ones use integers! Thanks! EDIT! New problem! JASS:function Trig_Init_Actions takes nothing returns nothing local unit u local integer i = 3 local integer i2 = 21 call GroupEnumUnitsInRect(udg_AllStage, gg_rct_FourthStage, null) call GroupEnumUnitsInRect(udg_StageLevel[5], gg_rct_FourthStage, null) call GroupEnumUnitsInRect(udg_StageLevel[3], gg_rct_FourthStage, null) call GroupEnumUnitsInRect(udg_StageLevel[2], gg_rct_ThirdStage, null) call GroupEnumUnitsInRect(udg_StageLevel[1], gg_rct_SecondStage, null) call GroupEnumUnitsInRect(udg_StageLevel[0], gg_rct_FirstStage, null) set udg_NumLights[3] = 96 set udg_NumLights[2] = 65 set udg_NumLights[1] = 40 set udg_NumLights[0] = 21 loop call GroupRemoveGroup(udg_StageLevel[i - 1], udg_StageLevel[i]) set i = i - 1 exitwhen i == 0 endloop call GroupRemoveGroup(udg_StageLevel[0], udg_StageLevel[5]) loop set u = FirstOfGroup(udg_StageLevel[5]) call ShowUnitHide(u) call GroupRemoveUnit(udg_StageLevel[5], u) exitwhen u == null endloop // .... endfunction I have a grid of On lights, it's meant to hide the lights that aren't part of the first stage. Thing is, this trigger isn't hiding them. The GUI equivalent did. Trigger: Initialization![]() Conditions![]() Actions![]() ![]() Set StageLevel[6] = (Units in FourthStage <gen>)![]() ![]() Set StageLevel[5] = (Units in FourthStage <gen>)![]() ![]() Set StageLevel[3] = (Units in FourthStage <gen>)![]() ![]() Set StageLevel[2] = (Units in ThirdStage <gen>)![]() ![]() Set StageLevel[1] = (Units in SecondStage <gen>)![]() ![]() Set StageLevel[0] = (Units in FirstStage <gen>)![]() ![]() Set NumLights[3] = 96![]() ![]() Set NumLights[2] = 65![]() ![]() Set NumLights[1] = 40![]() ![]() Set NumLights[0] = 21![]() ![]() Unit Group - Remove Puzzle Solver 0021 <gen> from StageLevel[6]![]() ![]() Unit Group - Remove all units of StageLevel[0] from StageLevel[1]![]() ![]() Unit Group - Remove all units of StageLevel[0] from StageLevel[6]![]() ![]() ![]() ![]() ..... |
| 10-05-2008, 11:43 AM | #6 |
JASS:call GroupEnumUnitsInRect(udg_AllStage, gg_rct_FourthStage, null) call GroupEnumUnitsInRect(udg_StageLevel[5], gg_rct_FourthStage, null) call GroupEnumUnitsInRect(udg_StageLevel[3], gg_rct_FourthStage, null) call GroupEnumUnitsInRect(udg_StageLevel[2], gg_rct_ThirdStage, null) call GroupEnumUnitsInRect(udg_StageLevel[1], gg_rct_SecondStage, null) call GroupEnumUnitsInRect(udg_StageLevel[0], gg_rct_FirstStage, null) Those will crash Macs. Don't use null, use a function that returns true instead. |
| 10-05-2008, 12:00 PM | #7 | |
Rep all people who helped ya xD Quote:
|
| 10-05-2008, 12:09 PM | #8 | |
Quote:
I've seen this used EVERYWHERE. Not to sound accusing, but where's the support for your statement? EDIT! Also, I think I'd know where Mac would crash. Also, what would these trick functions look like? |
| 10-05-2008, 02:00 PM | #9 |
Malf is incorrect. That does not cause a crash; the culprit is this: JASS:function Filter takes nothing returns nothing call Blah() endfunction call GroupEnumUnitsInRect(udg_TempGroup, udg_MyRect, Condition(function Filter)) |
| 10-05-2008, 02:11 PM | #10 |
I've read that but he was running it at like 1000 times per second right? Unless my puzzle takes 5 days to finish and you're taking like 2 moves per second, it's highly unlikely that it will matter in my map. |
| 10-05-2008, 02:17 PM | #11 |
Try this, it would work, if I understood problem) JASS:function RemoveUnits takes nothing returns nothing call GroupRemoveUnit(udg_StageLevel[5], GetEnumUnit()) endfunction function HideUnits takes nothing returns nothing call ShowUnit(GetEnumUnit(), false) endfunction function Trig_Init_Actions takes nothing returns nothing local integer i = 0 call GroupEnumUnitsInRect(udg_AllStage, gg_rct_FourthStage, null) call GroupEnumUnitsInRect(udg_StageLevel[5], gg_rct_FirstStage, null) // note the difference call GroupEnumUnitsInRect(udg_StageLevel[3], gg_rct_FourthStage, null) call GroupEnumUnitsInRect(udg_StageLevel[2], gg_rct_ThirdStage, null) call GroupEnumUnitsInRect(udg_StageLevel[1], gg_rct_SecondStage, null) call GroupEnumUnitsInRect(udg_StageLevel[0], gg_rct_FirstStage, null) loop set i = i + 1 exitwhen i > 3 call ForGroup(udg_StageLevel[i], function RemoveUnits) endloop call ForGroup(udg_StageLevel[5], function HideUnits) call DestroyGroup(udg_StageLevel[5]) // . . . endfunction |
| 10-05-2008, 04:31 PM | #12 |
I need StageLevel[5] to be the opposite of [0], so you're almost right there. Also, from what I've heard, ForGroup calls are evil. I'll give it a shot when I get World Editor access. EDIT! Now this may sound like a really silly off topic request, but could somebody get me a benchmark for both square root and power? Yes, I am aware of how stupid this is but that's why it's tiny-text! |
| 10-05-2008, 05:09 PM | #13 | |
Quote:
About the benchmark, I know a benchmark for Pow, but not for Square. Anyway, this test may help you creating your own benchmark(see the last posts): http://www.wc3campaigns.net/showthread.php?t=102881 |
| 10-05-2008, 05:57 PM | #14 | |
Quote:
|
| 10-06-2008, 02:45 AM | #15 |
I just need that tidbit for something else and I don't want to start a new topic about it. I'll get to work on my triggers now. EDIT! Pheonix, your link is broken. EDIT! Oh shit I am so sorry, I had "Run ON Map Initialization" unchecked, it was checked when I started but wasn't later on. +Rep to whoever helped a mistaken problem EDIT! Apparently I'm not out of the woods yet. JASS:function Trig_Init_Actions takes nothing returns nothing local integer i = 4 local integer i2 = 0 local unit u local group g = CreateGroup() call GroupEnumUnitsInRect(udg_AllStage, gg_rct_FifthStage, null) call GroupEnumUnitsInRect(udg_StageLevel[5], gg_rct_FifthStage, null ) call GroupEnumUnitsInRect(udg_StageLevel[4], gg_rct_FifthStage, null ) call GroupEnumUnitsInRect(udg_StageLevel[3], gg_rct_FourthStage, null ) call GroupEnumUnitsInRect(udg_StageLevel[2], gg_rct_ThirdStage, null ) call GroupEnumUnitsInRect(udg_StageLevel[1], gg_rct_SecondStage, null ) call GroupEnumUnitsInRect(udg_StageLevel[0], gg_rct_FirstStage, null ) loop call GroupRemoveGroup(udg_StageLevel[i - 1], udg_StageLevel[i]) set i = i - 1 exitwhen i == 0 endloop call GroupRemoveGroup(udg_StageLevel[0], udg_StageLevel[5]) call BJDebugMsg("AllStage = " + I2S(CountUnitsInGroup(udg_AllStage))) call BJDebugMsg("Stage[0] = " + I2S(CountUnitsInGroup(udg_StageLevel[0]))) call BJDebugMsg("Stage[1] = " + I2S(CountUnitsInGroup(udg_StageLevel[1]))) call BJDebugMsg("Stage[2] = " + I2S(CountUnitsInGroup(udg_StageLevel[2]))) call BJDebugMsg("Stage[3] = " + I2S(CountUnitsInGroup(udg_StageLevel[3]))) call BJDebugMsg("Stage[4] = " + I2S(CountUnitsInGroup(udg_StageLevel[4]))) call BJDebugMsg("Stage[5] = " + I2S(CountUnitsInGroup(udg_StageLevel[5]))) loop set u = FirstOfGroup(udg_StageLevel[5]) call ShowUnit(u, false) call GroupRemoveUnit(udg_StageLevel[5], u) exitwhen u==null endloop call DestroyGroup(udg_StageLevel[5]) // ..... endfunction Problems: - Units STILL not hiding (for some god-knows-why reason) - Groups have the following number of units in them AllStage = 96 Stage[0] = 8 Stage[1] = 13 Stage[2] = 0 Stage[3] = 0 Stage[4] = 0 Stage[5] = 0 <-- That's why things aren't hiding, but I don't know why that's 0. Heck, even when I don't do anything to it it's zero. |
