HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Problem with init visibility

06-24-2006, 06:42 PM#1
MasterofSickness
I have the following Trigger, which will be fired at map initialation from another trigger, but after this trigger, I can't recieve any text messages, nor the players get their amount of money they should get at the beginning...
Here is the trigger in GUI and JASS:
1) GUI:
Trigger:
Events
Conditions
Collapse Actions
-------- Denkmal('h03R') --------
Custom script: local player p
Custom script: local rect Reg
Custom script: local rect Reg2=RectFromLoc(Location(-14336, -8192), Location(0, 8192))
Custom script: local force f=GetPlayersAll()
Custom script: local force f2=GetPlayersAllies(Player(0))
Custom script: local group g=GetUnitsOfTypeIdAll('h03R')
Custom script: local location Loc1=GetUnitLoc(FirstOfGroup(g))
Custom script: local location Loc2
Custom script: local location Loc3=Location(0,0)
-------- MAP Visibility&Border --------
Custom script: call DisplayTextToForce(GetPlayersAll(),"NOW")
Custom script: call GroupRemoveUnit(g,FirstOfGroup(g))
Custom script: set Loc2=GetUnitLoc(FirstOfGroup(g))
Custom script: set Reg=RectFromLoc(Location(-13312, -7676), Location(13312, 7676))
Custom script: call DisplayTextToForce(GetPlayersAll(),"LOOP")
Custom script: loop
Custom script: set p=ForcePickRandomPlayer(f)
Custom script: exitwhen p==null
Custom script: call SetCameraBoundsToRectForPlayerBJ(p,Reg)
Custom script: call CreateFogModifierRadiusLocBJ(true,p,FOG_OF_WAR_VISIBLE,Loc1,512)
Custom script: call CreateFogModifierRadiusLocBJ(true,p,FOG_OF_WAR_VISIBLE,Loc2,512)
Custom script: call CreateFogModifierRadiusLocBJ(true,p,FOG_OF_WAR_VISIBLE,Loc3,512)
Custom script: call ForceRemovePlayer(f,p)
Custom script: endloop
Custom script: call DisplayTextToForce(GetPlayersAll(),"THEN")
-------- ClearMemory --------
-------- WEST Visibility --------
Custom script: set f=GetPlayersAllies(Player(0))
Custom script: set Reg=RectFromLoc(Location(-14336, -8192), Location(0, 8192))
Custom script: loop
Custom script: set p=ForcePickRandomPlayer(f2)
Custom script: exitwhen p==null
Custom script: call CreateFogModifierRectBJ(true,p,FOG_OF_WAR_VISIBLE,Reg2)
Custom script: call ForceRemovePlayer(f2,p)
Custom script: endloop
-------- ClearMemory --------

2) JASS:
Collapse JASS:
function Trig_InitSicht_Actions takes nothing returns nothing
    // Denkmal('h03R')
    local player p
    local rect Reg
    local rect Reg2=RectFromLoc(Location(-14336, -8192), Location(0, 8192))
    local force f=GetPlayersAll()
    local force f2=GetPlayersAllies(Player(0))
    local group g=GetUnitsOfTypeIdAll('h03R')
    local location Loc1=GetUnitLoc(FirstOfGroup(g))
    local location Loc2
    local location Loc3=Location(0,0)
    // MAP Visibility&Border
    call DisplayTextToForce(GetPlayersAll(),"NOW")
    call GroupRemoveUnit(g,FirstOfGroup(g))
    set Loc2=GetUnitLoc(FirstOfGroup(g))
    set Reg=RectFromLoc(Location(-13312, -7676), Location(13312, 7676))
    call DisplayTextToForce(GetPlayersAll(),"LOOP")
    loop
    set p=ForcePickRandomPlayer(f)
    exitwhen p==null
    call SetCameraBoundsToRectForPlayerBJ(p,Reg)
    call CreateFogModifierRadiusLocBJ(true,p,FOG_OF_WAR_VISIBLE,Loc1,512)
    call CreateFogModifierRadiusLocBJ(true,p,FOG_OF_WAR_VISIBLE,Loc2,512)
    call CreateFogModifierRadiusLocBJ(true,p,FOG_OF_WAR_VISIBLE,Loc3,512)
    call ForceRemovePlayer(f,p)
    endloop
    call DisplayTextToForce(GetPlayersAll(),"THEN")
    // ClearMemory
    // WEST Visibility
    set f=GetPlayersAllies(Player(0))
    set Reg=RectFromLoc(Location(-14336, -8192), Location(0, 8192))
    loop
    set p=ForcePickRandomPlayer(f2)
    exitwhen p==null
    call CreateFogModifierRectBJ(true,p,FOG_OF_WAR_VISIBLE,Reg2)
    call ForceRemovePlayer(f2,p)
    endloop
    // ClearMemory
endfunction

//===========================================================================
function InitTrig_InitSicht takes nothing returns nothing
    set gg_trg_InitSicht = CreateTrigger(  )
    call TriggerAddAction( gg_trg_InitSicht, function Trig_InitSicht_Actions )
endfunction

Also, already in the trigger the text message "THEN" doesn't appear!
("NOW" and "LOOP" appear)
So, what is the problem?
I surely forgot anything, but I don't get what...
EDIT: Help please... I also try to give reputation if I can...(how much rep can I give away? It seems to not working anymore)
EDIT2:
When I used this old trigger with GUI-commands it worked, but after trying to create one in JASS then this strange mistake appeared. So here is the old working GUI trigger if this helps you with helping me (but I have to warn: I tried translating the GUI-commands, because I have a german editor):
Trigger:
Events
Conditions
Collapse Actions
Set SpielergruppeAr[0] = (All players)
Collapse PlayerGroup - Pick every player in SpielergruppeAr[0] and do (Actions)
Collapse ~Loop - Actions
Set RegAr[0] = (Region((Point(-13312.00, -7676.00)), (Point(13312.00, 7676.00))))
Camera - Set the camera bounds for (Picked player) to RegAr[0]
Custom script: call RemoveRect (udg_RegAr[0])
Set Temp_Einheitengruppe_Array[5] = (Units of type |cff008000Denkmal|r)
UnitGroup - Pick every unit in Temp_Einheitengruppe_Array[5] and do (Visibility - Create an initially Aktiviert visibility modifier for (Picked player) emitting Sichtbarkeit from (Position of (Picked unit)) to a radius of 512.00)
Custom script: call DestroyGroup (udg_Temp_Einheitengruppe_Array[5])
Set Temp_Punkt_Array[1] = (Point(0.00, 0.00))
Visibility - Create an initially Aktiviert visibility modifier for (Picked player) emitting Sichtbarkeit from Temp_Punkt_Array[1] to a radius of 512.00
Custom script: call RemoveLocation (udg_Temp_Punkt_Array[1])
Set SpielergruppeAr[0] = (All allies of Player 1 (Red))
Collapse PlayerGroup - Pick every player in SpielergruppeAr[0] and do (Actions)
Collapse ~Loop - Actions
Set RegAr[0] = (Region((Point(-14336.00, -8192.00)), (Point(0.00, 8192.00))))
Visibility - Create an initially Aktiviert visibility modifier for (Picked player) emitting Sichtbarkeit across RegAr[0]
Custom script: call RemoveRect (udg_RegAr[0])
Set SpielergruppeAr[0] = (All allies of Player 2 (Blue))
Collapse PlayerGroup - Pick every player in SpielergruppeAr[0] and do (Actions)
Collapse ~Loop - Aktionen
Set RegAr[0] = (Region((Point(0.00, -8192.00)), (Point(14336.00, 8192.00))))
Visibility - Create an initially Aktiviert visibility modifier for (Picked player) emitting Sichtbarkeit across RegAr[0]
Custom script: call RemoveRect (udg_RegAr[0])

So... hope there comes fast help from you
06-25-2006, 12:59 AM#2
PipeDream
I'm guessing your goal in using ForcePickRandomPlayer was efficiency. Take a look at how it's implemented in Blizzard.j... Anyway, I recommend you use ForForce or even better just loop through integers. Red is Player(0) and the last player (gray?) is Player(11). Or you could do it with no loop at all via GetLocalPlayer().
I don't know precisely what the problem is, but I wouldn't be surprised if it went away if you avoid the force loop.
06-25-2006, 11:26 AM#3
MasterofSickness
Wow, I didn't have the faintest idea, you are so right!
Collapse JASS:
function ForcePickRandomPlayerEnum takes nothing returns nothing
    set bj_forceRandomConsidered = bj_forceRandomConsidered + 1
    if (GetRandomInt(1,bj_forceRandomConsidered) == 1) then
        set bj_forceRandomCurrentPick = GetEnumPlayer()
    endif
endfunction

//===========================================================================
// Picks a random player from a force.
//
function ForcePickRandomPlayer takes force whichForce returns player
    set bj_forceRandomConsidered = 0
    set bj_forceRandomCurrentPick = null
    call ForForce(whichForce, function ForcePickRandomPlayerEnum)
    return bj_forceRandomCurrentPick
endfunction

That is horrible! Didn't know that! I also didn't realized that I just can use Player(A)... *ouch* I will try this now with loop through Player(integer), because I want to use the GetLocalPlayer()-command as little as possible.
Thanks, I try to give you rep now

Edit: Worked! (Both, the rep and the visibility trigger) THX
06-25-2006, 03:09 PM#4
BertTheJasser
Collapse JASS:
//**************************************************************************
//* Do not aktivate "Bei Karten-Initialisierung ausführen"                 *
//* That will cause crash                                                  *
//*                                                                        *
//* I am not 100% sure if it works, as I destroy the rect at the end       *
//* If it does not work, put"//" before the line "call RemoveRect(r)"      *
//* Reputiation is recommended(?)                                          *
//**************************************************************************

function InitSicht_Actions takes nothing returns nothing
 local unit p=null
 local rect r=Rect(-13312,-7676),13312,7676)
 local real rad=512
 local real x=0
 local real y=0
 local group g=CreateGroup()
 local boolexpr b=Filter(function GetUnitsOfTypeIdAllFilter)
    //Create a filter to pick only "Denkmäler"
    set bj_groupEnumTypeId='h03R' //set the "Denkmal" id 
    call GroupEnumUnitsInRect(g,bj_mapInitialPlayableArea,b)
    //destroy the filter and nullify
    call DestroyBoolExpr(b)
    set b=null   

    call DisplayTextToPlayer(GetLocalPlayer(),0,0,"A")
    // set the bounds of the camera for all players
    call SetCameraBoundsToRect(r)
    //loop through all "Denkmäler"
    loop
        set p=FirstOfGroup(g)
        exitwhen p==null
        call GroupRemoveUnit(g,u)
        set i=0
        //Create for each Denkmal for each player a fogmodifier and aktivate the fogmodifier
        loop
            exitwhen i>11
            call FogModifierStart(CreateFogModifierRadius(Player(i),FOG_OF_WAR_VISIBLE,GetUnitX(p),GetUnitY(p),rad,true,true))
            set i=i+1
        endloop
    endloop
    //kill the group and nullify
    call DestroyGroup(g)
    set g=null
    //to nullify is actually not required, but I always do it
    set p=null

    call DisplayTextToPlayer(GetLocalPlayer(),0,0,"B")

    //Move Rect to new position
    call SetRect(r,-14336,-8192,0, 8192)
    //loop through all players and create the depednig fo modifiers
    set i=0
    loop
        exitwhen i>11
        if IsPlayerAlly(Player(0),Player(i)) and IsPlayerAlly(Player(i),Player(0)) then
            call FogModifierStart(CreateFogModifierRect(p,FOG_OF_WAR_VISIBLE,r,true,true))
        endif
        call FogModifierStart(CreateFogModifierRadius(Player(i),FOG_OF_WAR_VISIBLE,x,y,rad,true,true))
        set i=i+1
    endloop
    call RemoveRect(r)
    set r=null
endfunction

function InitTrig_InitSicht takes nothing returns nothing
call ExecuteFunc("InitSicht_Actions")
endfunction
06-25-2006, 03:29 PM#5
MasterofSickness
Yeah, I just removed the ClearMemory-Actions for better comprehension view and for easier reading. In my map I use them!! :)

Cool, nice to know.
If I have a really big problem where I have to use my origin language, I will call you ;)

EDIT:
WoW! Did you all worked that out only for me?
If so, then I can't remember that I ever got that much help since I joined here...
I didn't ask for this, because I already found a solution:
Quote:
Edit: Worked! (Both, the rep and the visibility trigger) THX
,but you give me no choice.
That properly took a little bit time and
Quote:
Reputiation is recommended(?)
so, well I just have to give you rep... (ATM I can't, but you get soon)
Beside this, I think that the trigger I have now is also fine...or should I better use yours?
Collapse JASS:
function Trig_InitSicht_Actions takes nothing returns nothing
    // Denkmal('h03R')
    local integer A=0
    local rect Reg
    local group g=GetUnitsOfTypeIdAll('h03R')
    local location Loc1=GetUnitLoc(FirstOfGroup(g))
    local location Loc2
    local location Loc3=Location(0,0)
    // MAP Visibility&Border
    call GroupRemoveUnit(g,FirstOfGroup(g))
    set Loc2=GetUnitLoc(FirstOfGroup(g))
    set Reg=RectFromLoc(Location(-13312, -7676), Location(13312, 7676))
    loop
    exitwhen A==11
    call SetCameraBoundsToRectForPlayerBJ(Player(A),Reg)
    call CreateFogModifierRadiusLocBJ(true,Player(A),FOG_OF_WAR_VISIBLE,Loc1,512)
    call CreateFogModifierRadiusLocBJ(true,Player(A),FOG_OF_WAR_VISIBLE,Loc2,512)
    call CreateFogModifierRadiusLocBJ(true,Player(A),FOG_OF_WAR_VISIBLE,Loc3,512)
    set A=(A+1)
    endloop
    // ClearMemory
    call RemoveRect(Reg)
    call DestroyGroup (g)
    call RemoveLocation (Loc1)
    call RemoveLocation (Loc2)
    call RemoveLocation (Loc3)
    set Reg=null
    set g=null
    set Loc1=null
    set Loc2=null
    set Loc3=null
    // WEST Visibility
    set A=0
    set Reg=RectFromLoc(Location(-14336, -8192), Location(0, 8192))
    loop
    exitwhen A==8
    if (IsPlayerAlly(Player(A),Player(0)) == true) then
    call CreateFogModifierRectBJ(true,Player(A),FOG_OF_WAR_VISIBLE,Reg)
    endif
    set A=(A+1)
    endloop
    // ClearMemory
    call RemoveRect(Reg)
    set Reg=null
    // OST Visibility
    set A=1
    set Reg=RectFromLoc(Location(0, -8192), Location(14336, 8192))
    loop
    exitwhen A==11
    if (IsPlayerAlly(Player(A),Player(1)) == true) then
    call CreateFogModifierRectBJ(true,Player(A),FOG_OF_WAR_VISIBLE,Reg)
    endif
    set A=(A+1)
    endloop
    // ClearMemory
    call RemoveRect(Reg)
    set Reg=null
endfunction

//===========================================================================
function InitTrig_InitSicht takes nothing returns nothing
    set gg_trg_InitSicht = CreateTrigger(  )
    call TriggerAddAction( gg_trg_InitSicht, function Trig_InitSicht_Actions )
endfunction
06-25-2006, 04:26 PM#6
BertTheJasser
Collapse JASS:
    set Reg=RectFromLoc(Location(0, -8192), Location(14336, 8192))
This line leaks 2 locations!
Use this one instead
Collapse JASS:
set Reg=Rect(0,-8192,14336, 8192)

Here the same:
Collapse JASS:
    set Reg=RectFromLoc(Location(-14336, -8192), Location(0, 8192))
    loop
    exitwhen A==8
    if (IsPlayerAlly(Player(A),Player(0)) == true) then
    call CreateFogModifierRectBJ(true,Player(A),FOG_OF_WAR_VISIBLE,Reg)
    endif
    set A=(A+1)
    endloop
and player 11 will be never called as you exitwhen A==11. Change it to A>11

And
Collapse JASS:
    set A=(A+1)
forget the "(" and ")" s.

And
Collapse JASS:
    local group g=GetUnitsOfTypeIdAll('h03R')
and this itself leaks 2 groups at once, which you will never be able to recover.

I suggest you really to use mine. ;D
06-25-2006, 04:44 PM#7
MasterofSickness
1)
Collapse JASS:
set Reg=RectFromLoc(Location(0, -8192), Location(14336, 8192))
Does this really leak? I mean it only returns a rect:
Collapse JASS:
native RectFromLoc              takes location min, location max returns rect
When this would leak, I didn't understand the leak preventing really... hm...

2)
Yeah, I say exitwhen A==8, because the team in west is ment only, and that consist of four player (player(0,3,5,7))

3)
Quote:
And
Collapse JASS:
local group g=GetUnitsOfTypeIdAll('h03R')
and this itself leaks 2 groups at once, which you will never be able to recover.
WHAT??? Are you really sure? SH*T!
Why is this so? W8, is it because of the bj-function?
Collapse JASS:
function GetUnitsOfTypeIdAll takes integer unitid returns group
    local group   result = CreateGroup()
    local group   g      = CreateGroup()
    local integer index

    set index = 0
    loop
        set bj_groupEnumTypeId = unitid
        call GroupClear(g)
        call GroupEnumUnitsOfPlayer(g, Player(index), filterGetUnitsOfTypeIdAll)
        call GroupAddGroup(g, result)

        set index = index + 1
        exitwhen index == bj_MAX_PLAYER_SLOTS
    endloop
    call DestroyGroup(g)

    return result
endfunction

wew, then I better look through your trigger once again...
06-25-2006, 04:53 PM#8
BertTheJasser
Oh yeah. BJ sucks hardcore.
@1) you create 2 locations and never remove them! What do you expect? Should they fly away or just magically disappear? ;D
Just rreplace all that lines as I've said and no problem.
06-25-2006, 04:59 PM#9
MasterofSickness
Ah, I think understood my prob in 1)
Collapse JASS:
native RectFromLoc              takes location min, location max returns rect

The thing is, that the two locations which the native takes, first will be created from the given coordinates and then used and then are lost in the memory... right?

EDIT: posted while you posted :)

EDIT2: But I don't have to use a local real rad !?
AFAIK reals clear themself at the end of every trigger...
06-25-2006, 05:16 PM#10
BertTheJasser
Yes, that's it.
06-26-2006, 06:49 AM#11
aquilla
here's my version of the unit-type function :)
Collapse JASS:
function GetUnitsOfTypeId takes integer unitid returns group
    local group res = CreateGroup()
    local group g = CreateGroup()
    local unit f
    local integer i = 0
    loop
        exitwhen i > 12
        call GroupEnumUnitsOfPlayer(g, Player(i), null)
        loop
            set f = FirstOfGroup(g)
            exitwhen f == null
            if GetUnitTypeId(f) == unitid then
                call GroupAddUnit(res, f)
            endif
            call GroupRemoveUnit(g, f)
        endloop
        set i = i+1
    endloop
    call DestroyGroup(g)
    set bj_lastCreatedGroup = res
    set res = null
    set g = null
    set f = null
    return bj_lastCreatedGroup
endfunction
06-26-2006, 12:42 PM#12
BertTheJasser
Use a boolexpr and the blizzard var and it's filterfunc, create a group and return via bj_lastCreatedGroup or whatever.

I prefer my one as yours is VERY slow, for just picking some units of typeid.