Wratox1
Member
- Reaction score
- 22
Are there any way to check when a hero gains a attribute with triggers?
no there aint. but you, as the maker of the map, should always know whenever the hero will get an attribute bonus or not. there aint that many ways to get one.
Well then, when the trigger that adds 1 strength runs, run the other one.
unfotunately there aint an easy way to do this.
one way would be that you store all these regions inside an array variable. when the event triggers, that means any of this regions has been entered, you run an iteration through all regions and check whether they contain the triggering unit or not.
thats not a very good method cause its rather uneffective. but its the easiest.
another way you could do it is creating a simple trigger like this for all regions:
Trigger:
- Events
- Unit - Unit enters region X
- Conditions
- Actions
- set Temp_Region = region X
- Trigger - Run MYTRIGGER (checking conditions)
and all the actions you want to do are within the other trigger called MYTRIGGER in the example.
Temp_Region would then be the region your unit entered.
(Triggering Unit) or (Entering Unit) would still work if you use it in the other trigger.
the second method is alot more effective performance-wise but its alot more work for you as well.
well, i'd say that depends on 2 factors. how many regions do you have and how fast are the computers you want to run that map on.
basically i dont think it would be that much of a problem since the comparison and the iteration itself shouldnt be that harmful to the performance.
just imagine, if you have 100 regions it will run 100 if/then/else statements every time one of the regions is entered.
another problem with this method would be if 2 regions overlap. this might result with your trigger thinking both regions have been entered at once even though the unit was standing within one of them before it entered the second.
well thats the problem, its the same for every region, except that i set a boolean-array to false, and i need to know which array-slot? to set to false.. the region-array and the boolean-array have equal amount of "slots"(what is it called?) and 1 region has its corresponding boolean..If it's the same actions for every region, then, yes, it is a good idea, though. But then there would be no real need to check which region is entered. Just a single trigger for the whole thing, without conditions...
@Ashlebede: There really is a GetTriggeringRegion() Funktion? lol, i never knew, i asked that several times nobody ever told me that.
well, of course, if there is then just use it.
function InitTrig_MyTrigger takes nothing returns nothing
local region r=CreateRegion()
set gg_trg_MyTrigger=CreateTrigger()
call PolledWait(.1)//make sure the other trigger's init was run
call RegionAddRect(r,gg_rct_My_Regions_Name) //add the rect to the region (doesn't work with handle-type vars
call TriggerRegisterEnterRegion(gg_trg_OtherTrigger,r,null) //add an event
set udg_My_Handle_Variable = r //this handle can only be used for comparison with the region, not as a parameter for functions.
set r = null //leak clearing
endfunction
There really is a GetTriggeringRegion() Funktion? lol, i never knew, i asked that several times nobody ever told me that.