| 01-19-2007, 08:14 PM | #1 |
JASS:globals boolean udg_All_Random endglobals function Command_All_Random_Hero_Callback takes nothing returns nothing call KillUnit(GetEnumUnit()) endfunction function Command_All_Random_Hero takes nothing returns nothing local group g = GetUnitsOfPlayerAndType(GetEnumPlayer(), 'ushd') if IsUnitType(GetEnumUnit(), UNIT_TYPE_HERO) then call SetUnitOwner( GetEnumUnit(), GetEnumPlayer(), true ) call ForGroup( g, function Command_All_Random_Hero_Callback ) endif call DestroyGroup(g) set g = null endfunction function Command_All_Random_Sentinel takes nothing returns nothing local group g = GetRandomSubGroup(1, GetUnitsInRectMatching(gg_rct_NESelection,null)) call ForGroup( g, function Command_All_Random_Hero ) call DestroyGroup(g) set g = null endfunction function Command_All_Random_Horde takes nothing returns nothing local group g = GetRandomSubGroup(1, GetUnitsInRectMatching(gg_rct_OrcSelection,null)) call ForGroup( g, function Command_All_Random_Hero ) call DestroyGroup(g) set g = null endfunction function Command_All_Random_Actions takes nothing returns nothing set udg_All_Random = true call Announcement( "All Random has been enabled. Each player will receive a random hero." ) call ForForce( udg_Players_Sentinel, function Command_All_Random_Sentinel ) call ForForce( udg_Players_Horde, function Command_All_Random_Horde ) call CS_KillTrigger(GetTriggeringTrigger()) endfunction //=========================================================================== function InitTrig_Command_All_Random takes nothing returns nothing set gg_trg_Command_All_Random = CreateTrigger( ) call TriggerRegisterPlayerChatEvent( gg_trg_Command_All_Random, Player(1), "-ar", true ) call TriggerAddAction( gg_trg_Command_All_Random, function Command_All_Random_Actions ) endfunction It's a trigger that enables all random, much like in dota allstars. However, when I try to enable this trigger it gives errors such as "missing endif", "Expected variable name", and other odd errors. |
| 01-19-2007, 08:40 PM | #2 |
JASS:function Command_All_Random_Hero takes nothing returns nothing local group g = GetUnitsOfPlayerAndType(GetEnumPlayer(), 'ushd') if IsUnitType(GetEnumUnit(), UNIT_TYPE_HERO) then call SetUnitOwner( GetEnumUnit(), GetEnumPlayer(), true ) call ForGroup( g, function Command_All_Random_Hero_Callback ) endif call DestroyGroup(g) set g = null endfunction This shouldn't create a syntax problem though, just it would never work as you want it to. JASS:globals boolean udg_All_Random endglobals Try declaring "All_Random" in the variable editor in the trigger editor. I'm assuming the non-native/BJ functions you're calling are from the CS, therefore I assume they parse properly. But you should check them anyways, in case you modified them at all. |
| 01-19-2007, 08:54 PM | #3 |
I'm using preprocessors. WEHelper 1.7 + JASSHelper. Also, I just reconstructed this trigger in GUI, then hit the convert to custom text button. It shows GetEnumPlayer() and GetEnumUnit() inside the callback. |
| 01-19-2007, 09:01 PM | #4 |
Actually, the use of GetEnumPlayer() should still work. If you noticed, he had a ForForce function that had the ForGroup function in the callback, which means he can use GetEnumPlayer() and it should still work fine. EDIT: Found the problem (luckily Jass Craft has a list of the Caster System functions) GetUnitsOfPlayerAndType should be GetUnitsOfPlayerAndTypeId |
| 01-19-2007, 10:34 PM | #5 |
An inlined ForGroup inside of a ForForce still keeps the GetEnumPlayer() reference? That's interesting. |
| 01-19-2007, 10:47 PM | #6 |
I would think that it does. I was able to do it in GUI, so it should work in JASS as well. |
| 01-20-2007, 09:28 AM | #7 | |
Quote:
GetUnitsOfPlayerAndType is a library function I wrote. I use it in many other triggers and it works fine. |
| 01-20-2007, 10:46 AM | #8 |
You can't nest ForGroup's. |
| 01-20-2007, 10:48 AM | #9 |
Is that what the problem is? I thought for sure I could. Works in GUI... |
| 01-20-2007, 11:08 AM | #10 |
It won't cause compile errors, but nesting ForGroup's can cause problems with the EnumUnit reference. |
| 01-20-2007, 11:14 AM | #11 |
Okay, here's the new code, same errors. JASS:globals boolean udg_All_Random endglobals function Command_All_Random_Hero takes nothing returns nothing local group g = GetUnitsOfPlayerAndType(GetEnumPlayer(), 'ushd') local unit p = null if IsUnitType(GetEnumUnit(), UNIT_TYPE_HERO) then call SetUnitOwner( GetEnumUnit(), GetEnumPlayer(), true ) loop set p = FirstOfGroup(g) exitwhen p == null call KillUnit(p) call GroupRemoveUnit(g,p) endloop endif call DestroyGroup(g) set g = null endfunction function Command_All_Random_Sentinel takes nothing returns nothing local group g = GroupPickRandomUnit(GetUnitsInRectMatching(gg_rct_NESelection,null)) call ForGroup( g, function Command_All_Random_Hero ) call DestroyGroup(g) set g = null endfunction function Command_All_Random_Horde takes nothing returns nothing local group g = GroupPickRandomUnit(GetUnitsInRectMatching(gg_rct_OrcSelection,null)) call ForGroup( g, function Command_All_Random_Hero ) call DestroyGroup(g) set g = null endfunction function Command_All_Random_Actions takes nothing returns nothing set udg_All_Random = true call Announcement( "All Random has been enabled. Each player will receive a random hero." ) call ForForce( udg_Players_Sentinel, function Command_All_Random_Sentinel ) call ForForce( udg_Players_Horde, function Command_All_Random_Horde ) call CS_KillTrigger(GetTriggeringTrigger()) endfunction //=========================================================================== function InitTrig_Command_All_Random takes nothing returns nothing set gg_trg_Command_All_Random = CreateTrigger( ) call TriggerRegisterPlayerChatEvent( gg_trg_Command_All_Random, Player(1), "-ar", true ) call TriggerAddAction( gg_trg_Command_All_Random, function Command_All_Random_Actions ) endfunction Here's the function GetUnitsOfPlayerAndType. JASS:function GetUnitsOfPlayerAndType_Filter takes nothing returns boolean return GetOwningPlayer(GetEnumUnit()) == bj_groupEnumOwningPlayer endfunction function GetUnitsOfPlayerAndType takes player p, integer id returns group local group g = CreateGroup() local boolexpr cond = Condition(function GetUnitsOfPlayerAndType_Filter) set bj_groupEnumOwningPlayer = p call GroupEnumUnitsOfType(g,UnitId2String(id),cond) call DestroyBoolExpr(cond) set cond = null return g endfunction Here's the Announcement function. JASS:function Announcement takes string message returns nothing call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_SECRET, " ") call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_SECRET, message) endfunction |
| 01-20-2007, 02:30 PM | #12 |
A problem with the group g. (Group/Handle) JASS:globals boolean udg_All_Random //rect gg_rct_NESelection //rect gg_rct_OrcSelection //force udg_Players_Sentinel //force udg_Players_Horde //trigger gg_trg_Command_All_Random endglobals function GetUnitsOfPlayerAndType_Filter takes nothing returns boolean return GetOwningPlayer(GetEnumUnit()) == bj_groupEnumOwningPlayer endfunction function GetUnitsOfPlayerAndType takes player p, integer id returns group local group g = CreateGroup() local boolexpr cond = Condition(function GetUnitsOfPlayerAndType_Filter) set bj_groupEnumOwningPlayer = p call GroupEnumUnitsOfType(g,UnitId2String(id),cond) call DestroyBoolExpr(cond) set cond = null return g endfunction function Command_All_Random_Hero takes nothing returns nothing local group g = GetUnitsOfPlayerAndType(GetEnumPlayer(), 'ushd') local unit p = null if IsUnitType(GetEnumUnit(), UNIT_TYPE_HERO) then call SetUnitOwner( GetEnumUnit(), GetEnumPlayer(), true ) loop set p = FirstOfGroup(g) exitwhen p == null call KillUnit(p) call GroupRemoveUnit(g,p) endloop endif call DestroyGroup(g) set g = null endfunction function Command_All_Random_Sentinel takes nothing returns nothing local group g = GroupPickRandomUnit(GetUnitsInRectAll(gg_rct_NESelection) call ForGroup( g, function Command_All_Random_Hero ) call DestroyGroup(g) set g = null endfunction function Command_All_Random_Horde takes nothing returns nothing local group g = GroupPickRandomUnit(GetUnitsInRectAll(gg_rct_OrcSelection) call ForGroup( g, function Command_All_Random_Hero ) call DestroyGroup(g) set g = null endfunction function Announcement takes string message returns nothing call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_SECRET, " ") call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_SECRET, message) endfunction function Command_All_Random_Actions takes nothing returns nothing set udg_All_Random = true call Announcement( "All Random has been enabled. Each player will receive a random hero." ) call ForForce( udg_Players_Sentinel, function Command_All_Random_Sentinel ) call ForForce( udg_Players_Horde, function Command_All_Random_Horde ) call DestroyTrigger(GetTriggeringTrigger()) endfunction //=========================================================================== function InitTrig_Command_All_Random takes nothing returns nothing set gg_trg_Command_All_Random = CreateTrigger( ) call TriggerRegisterPlayerChatEvent( gg_trg_Command_All_Random, Player(1), "-ar", true ) call TriggerAddAction( gg_trg_Command_All_Random, function Command_All_Random_Actions ) endfunction This works fine. |
| 01-20-2007, 02:49 PM | #13 |
So where's the problem? |
| 01-20-2007, 06:02 PM | #14 |
For future purposes, giving the line where the error occurs is very helpful. The more information you provide, the more likely it is that someone will be able to help you. local group g = GroupPickRandomUnit(GetUnitsInRectMatching(gg_rct_NESelection,null)) In both instances of that, you are assigning a unit to a group variable. |
| 01-20-2007, 06:21 PM | #15 |
Well... It doesn't look like this trigger is the problem, it just shows up as the problem. I fixed the group problem and it still gives same errors. All I can come up with is it is WEHelper related. Update: I made a completely new trigger, initially enabled and copy/pasted this trigger. It works with no errors. It seems that WEHelper does not parse triggers that are disabled and then re-enabled. It actually tries to parse the trigger as if it was the World Editor. |
