Hero gains a attribute event

Accname

2D-Graphics enthusiast
Reaction score
1,463
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.
 

Wratox1

Member
Reaction score
22
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.

im not talking about attribute bonus, i have a trigger that will add 1 strength for example, and i want to be able to detect when a hero gains the attribute
 

esb

Because none of us are as cruel as all of us.
Reaction score
329
Well then, when the trigger that adds 1 strength runs, run the other one.
 

Wratox1

Member
Reaction score
22
Well then, when the trigger that adds 1 strength runs, run the other one.

omg why didnt i think of that! thank you!
+rep!

i have another question:
with the event:
Trigger:
  • Unit - A unit enters weapon1 <gen>


if i have many regions, and adding this event for all of them to 1 trigger, how can i check which region was entered?
or what is the simplest way to do it?
 

Accname

2D-Graphics enthusiast
Reaction score
1,463
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.
 

Wratox1

Member
Reaction score
22
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 was trying to not having to create 1 trigger for each region..
but how uneffective is it to have a loop running through all the regions compared to the other method? is it noticeable in-game?
 

Accname

2D-Graphics enthusiast
Reaction score
1,463
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.
 

Wratox1

Member
Reaction score
22
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.

hmm, i think i will do the second method, because when someone enters a region, i have a boolean that i will set to false=the region is not active anymore, an with the first method i will have to either have alot of if-then-elses or find a way to check the indexnumber of the entered region and the compare it with the boolean index..
 

Ashlebede

New Member
Reaction score
43
The part about regions overlapping can be easily avoided with [ljass]GetTriggeringRegion()[/ljass] instead of checking if the triggering unit is in the region. I think it has a GUI equivalent, but I'm too lazy to plug in my USB device, open up world editor, wait 5 minutes for its startup... although I ain't sure whether GUI can compare [ljass]region[/ljass]s and [ljass]rect[/ljass]s...

Best would be to have multiple triggers, though.

Oh, and you can delete a region when it's not active anymore instead of setting booleans or whatever. That way its events just don't trigger anymore and I think you save a couple bytes of RAM.

[ljass]call RemoveRegion(GetTriggeringRegion()) //clears the region[/ljass]
[ljass]call RemoveRect(gg_rct_My_Regions_Name) //clears the rect (part of the region which is in fact just the same, in GUI)[/ljass]

You need to use both of these for the best result. Along with

[ljass]call DestroyTrigger(GetTriggeringTrigger())[/ljass]

To disable the whole trigger and make it unretrievable, but save some RAM.
 

AoW_Hun7312

I'm a magic man, I've got magic hands.
Reaction score
76
Trigger:
  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Repeat for # of regions. --------
      • Set Regions[0] = Region 000 <gen>
      • Set Regions[1] = Region 001 <gen>
      • Set Regions[2] = Region 002 <gen>
      • -------- Replace 2 with the last index. --------
      • Set LastRegionIndex = 2
      • For each (Integer A) from 0 to LastRegionIndex, do (Actions)
        • Loop - Actions
          • Trigger - Add to Detect Entering Unit <gen> the event (Unit - A unit enters Regions[(Integer A)])


Trigger:
  • Detect Entering Unit
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 0 to LastRegionIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Regions[(Integer A)] contains (Triggering unit)) Equal to True
            • Then - Actions
              • -------- Your actions here. --------
            • Else - Actions
 

Ashlebede

New Member
Reaction score
43
May I ask what use it is to use an initialization trigger to add events if you still have to enter the regions manually? >_> (except waste a couple bytes of RAM...)

You'd have to make an equal number of [ljass]if,then,else[/ljass]'s, anyways, the only difference being you have to check which region [ljass]Regions[(Integer A)][/ljass] is, which means even more tests... so it's basically worse performance, though it most definitely doesn't make any significant difference. It doesn't increase readability or anything, either.

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...
 

Jedi

New Member
Reaction score
63
You need to wait 0.00 seconds or something like that since unit enters region event fires when unit enters, but region contains unit check is unit's origin in region.
 

Wratox1

Member
Reaction score
22
region overlapping wont be a problem, but thanks anyway!

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...
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..
 

Accname

2D-Graphics enthusiast
Reaction score
1,463
@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.
 

Ashlebede

New Member
Reaction score
43
@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.

Note, however, that it returns a [ljass]region[/ljass], not a [ljass]rect[/ljass]. That means you probably cannot compare [ljass]GetTriggeringRegion()[/ljass] and [ljass]gg_rct_My_Regions_Name[/ljass] without using Jass and/or storing the regions in a [ljass]region[/ljass] variable.

The difference between a region and a rect is that the rect is always a rectangle. The region is an area which can contain one or more rects.

The solution would be creating a [ljass]handle[/ljass] (there is no [ljass]region[/ljass] type in GUI, what is called "region" is in fact a [ljass]rect[/ljass]) global variable and give it a [ljass]region[/ljass]-type value to compare to have something to compare [ljass]GetTriggeringRegion()[/ljass] with.

The pros : you can be sure which region was entered, this is the most accurate method.

The cons : it requires custom script for event registration and conditions. This also means a second trigger for event registration (unless your trigger is converted to Jass).

An example usage:

JASS:
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


Trigger:
  • //Hand-written
    • Events
    • --------Added in the other trigger--------
    • Conditions
    • --------Whatever you need here--------
    • Actions
      • Custom Script : if udg_My_Handle_Variable==GetTriggeringRegion() then
      • --------Actions---------
      • Custom Script : endif


There really is a GetTriggeringRegion() Funktion? lol, i never knew, i asked that several times nobody ever told me that.

There is always a way to find out which elements "trigger the trigger" for every element, as far as I know. In fact, your whole map could be in a single trigger... although performance-wise, it would be verry stupid. But it could.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top