| 06-25-2006, 12:59 AM | #2 |
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 |
Wow, I didn't have the faintest idea, you are so right! 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 |
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 | ||
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:
That properly took a little bit time and Quote:
(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? 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 |
JASS:set Reg=RectFromLoc(Location(0, -8192), Location(14336, 8192)) Use this one instead JASS:set Reg=Rect(0,-8192,14336, 8192) Here the same: 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 JASS:set A=(A+1) And JASS:local group g=GetUnitsOfTypeIdAll('h03R') I suggest you really to use mine. ;D |
| 06-25-2006, 04:44 PM | #7 | |
1) JASS:set Reg=RectFromLoc(Location(0, -8192), Location(14336, 8192)) JASS:native RectFromLoc takes location min, location max returns rect 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:
WHAT??? Are you really sure? SH*T!Why is this so? W8, is it because of the bj-function? 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 |
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 |
Ah, I think understood my prob in 1) 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 |
Yes, that's it. |
| 06-26-2006, 06:49 AM | #11 |
here's my version of the unit-type function :) 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 |
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. |
