| 04-21-2009, 02:03 AM | #1 |
Hey I'm sorry to post another thread. I wasn't sure if this should be in the same thread or not, but I was wondering if someone could check over my code. The code does not seem to be working and any help would be appreciated. Trigger Rundown: Basically, this trigger is a test for one that I will create later. This function gets all the points on the map and checks to see if its of type dirt. Then it creates a rect and then a region. It then adds the event to another trigger where the actions are to kill the unit. Errors: It's running through all the loops, I used a BJDebugMsg and it calls it. It is not creating the regions or adding it to the trigger though. So my unit does not die. Any help would be a big help, I really appreciate it :). Code: Basic Kill Unit JASS:function Trig_Kill_Unit_Actions takes nothing returns nothing call KillUnit( GetTriggerUnit() ) endfunction //=========================================================================== function InitTrig_Kill_Unit takes nothing returns nothing set gg_trg_Kill_Unit = CreateTrigger( ) call TriggerAddAction( gg_trg_Kill_Unit, function Trig_Kill_Unit_Actions ) endfunction Check and create Regions JASS:function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing local real x = 0 local real y = 976 local rect r local region reg loop exitwhen y < -1519 loop exitwhen x > 1231 if(GetTerrainType(x, y) == 'Ldrt') then set r = Rect(x, y, x + 32, y + 32) set reg = CreateRegion() call RegionAddRect(reg, r) call TriggerRegisterEnterRegion( gg_trg_Kill_Unit, reg, null ) endif set x = x + 1 endloop set x = 0 set y = y - 1 endloop endfunction //=========================================================================== function InitTrig_Untitled_Trigger_001 takes nothing returns nothing set gg_trg_Untitled_Trigger_001 = CreateTrigger( ) call TriggerRegisterTimerEventSingle( gg_trg_Untitled_Trigger_001, 0.01 ) call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions ) endfunction |
| 04-21-2009, 04:20 AM | #2 |
You're definitely hitting the thread operation (OP) limit. It's probably working for some of the tiles along the top of the map, but it's definitely crashing before it completes all of the tiles. The only way to fix this is to use some ExecuteFunc business or initialize all of the tiles in stages. Another thing is that you're decrementing X and Y by 1 each time. You should instead decrement by 32s, since that's the size of a terrain tile. |
| 04-22-2009, 12:38 AM | #3 |
I'm not sure what you mean by the thread operation limit, could you tell me what it is and maybe list an example of an example of how to fix it? I know what you mean by the decrement though. Thank you for reading my code. |
| 04-22-2009, 02:35 AM | #4 |
You have far too many "Events" added to your function. A region doesn't need to be square, rectangular, or even cohesive. This:function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing local real x = 0 local real y = 976 local rect r local region reg loop exitwhen y < -1519 loop exitwhen x > 1231 if(GetTerrainType(x, y) == 'Ldrt') then set r = Rect(x, y, x + 32, y + 32) set reg = CreateRegion() call RegionAddRect(reg, r) call TriggerRegisterEnterRegion( gg_trg_Kill_Unit, reg, null ) endif set x = x + 1 endloop set x = 0 set y = y - 1 endloop endfunction Can change to This:function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing local real x = 0 local real y = 976 local region reg = CreateRegion( ) loop exitwhen y < -1519 loop exitwhen x > 1231 if(GetTerrainType(x, y) == 'Ldrt') then call RegionAddRect(reg, Rect(x, y, x + 32, y + 32)) endif set x = x + 32 endloop set x = 0 set y = y - 32 endloop call TriggerRegisterEnterRegion( gg_trg_Kill_Unit, reg, null ) endfunction |
| 04-22-2009, 02:50 AM | #5 |
Wow thank you that helped me get a lot closer to fixing it. The unit dies on some dirt spaces but not all. Like a big patch on the top left will not kill the unit anywhere. But like small patches in the middle and bottom right kill it. Seems like thick patches of dirt don't kill but a width of one tile will kill it. You think you could help me some more, if needed I can upload the map? |
| 04-22-2009, 02:57 AM | #6 |
Make sure you have the right dimensions for the map. Edit: See if it changes for the better if you increment your starting X and Y values by 16 (to get the "middle" of a tile). |
| 04-22-2009, 10:18 AM | #7 | |
Quote:
If your x goes only from 0 to 1231 (what kind of number is that anyway) then that typically means the left side of the map will not be affected, since the coordinate 0 is in the middle of the map. |
| 04-22-2009, 06:42 PM | #8 |
I am using a 32 by 32 map. And all I did was just make a rect and gets its locations, which is why I have weird values This is just for test purposes.I will relook at the map. Thank you. |
