| 04-29-2004, 07:25 PM | #1 |
Ok, in my TD, I use 1 trigger to handle all the movement, instead of 30, so what I did was make this trigger. Quite a few people said it would work, yet the thing simply doesn't fire. and I don't understand why. Thank you for your help. --DoCa *NOTE* I know it checks if the Owning Player is P1, this was just to test it. |
| 04-29-2004, 08:42 PM | #2 |
I myself encountered a problem like this. I had set up an array of regions 1 through 104 which controlled the paths of 8 groups. These are unique paths, aside from 4 locations coinciding with 4 locations for every pair. (1-2, etc) Now, I did this in GUI and what I did was make it parse the array for the region the unit was in, and then compare that to the region the unit should be in. It went something like this: Unit groups are spawned, and assigned a unit group 1 through 16 (24 units per spawn, 8 spawns). Then, when a unit reaches a location, it parses the array with a For Loop. So if it were say, Location #5, the unit would HAVE to be in Group 1. So then an If/Then would halt the trigger or continue based on whether or not the unit was in the appropriate group. Mysteriously, this trigger simply failed to work. I cannot explain it because I had tested it myself, and even put in debug tags that would check if it was getting the right information. I tested it with player-filled unit groups, other units, etc. It would parse the data correctly, it would do everything... except it simply stopped at one point. There's simply a problem, and I could not figure out how to solve it. However, I think I did notice a problem in your JASS. Actually, a problem that exists in GUI as well. You cannot have an event be a variable, if I remember right. And it looks like your events are from an array. Try individually using the locations instead of referring to an array. I don't know if that's a JASS limitation or just a GUI limitation that you can't refer to a variable in an event. |
| 04-29-2004, 09:18 PM | #3 |
Right, I figured that out after posting that. it has been fixed. Now what happens.. the Trigger fires, and it moves some of the time, but not others. I have to manually move the unit out and then back into the rect for it to move, which simply won't work for a TD... If you'd like to take a look at the new trigger, it's Here. |
| 04-30-2004, 01:13 AM | #4 |
That's the problem I had with mine. Of course, mine was simultaneously managing at least 48 units, and up to 288. So I think the problem doesnt lie in the JASS, because obviously it works some of the time, and if you put debug DisplayTextToForce messages in it, you will find it is giving out the right data. The problem lies in the interface between the compiled JASS and the underlying C or C++ that WC3 is written in. I don't think it's efficient or powerful enough to continually run and re-que the same trigger. That said, the trigger que may be the ultimate culprit here. I know that the trigger que has no problem running ~50 triggers simultaneously, but to run a single trigger 50 times takes a great deal more time. It's possible that the trigger que is designed to do this to prevent an overflow when the same trigger is manipulating data at the same time, but there is more than one trigger at once running. For example, lets say in order to manage where units go the trigger modified a global variable, or even a local variable (since the trigger would be running multiple times, simultaneously), then that variable will be reset every time the trigger runs. So if you run it 3 times in a row, you are resetting that value and thus screwing up the remainder of the trigger. Let's say you run the same trigger twice, if it were possible. Trigger is: Unit enters region Unit enters region (etc) Actions are: Forloop If region (triggering unit) is in == region[A] then set Location = A,A, else do nothing endloop Issue unit order to point (Center of Location) Now, normally that would be ok. But what if that trigger runs twice, and the que works something like this: If condition is true, setting location to 1,1 If condition is true, setting location to 2,2 Issuing unit order to Location Issuing unit order to Location Now, that's a conflicting operation. Which the trigger que would obviously avoid, hence why it may not run your trigger simultaneously. Obviously, these are just theories, the mechanics behind WC3 and JASS are utterly unknown. |
| 05-01-2004, 01:26 AM | #5 |
Having the same trigger run multiple times at the same time is no problem for any operation on locals since each is a separate thread which means they do not share locals. |
| 05-01-2004, 02:26 AM | #6 |
Then I'm all out of reasons why my trigger and his trigger don't work. |
| 05-01-2004, 02:35 AM | #7 |
Mine works now. Anarki found another way of doing it, and it works quite nicely. |
| 05-01-2004, 07:44 AM | #8 |
A post or code snippet, please? |
| 05-02-2004, 03:36 AM | #9 |
ok heres the spawn trigger Code:
function Trig_StartLevel_Conditions takes nothing returns boolean if ( GetUnitTypeId(GetSoldUnit()) == 'o000' ) then return true endif return false endfunction function Trig_StartLevel_Actions takes nothing returns nothing local integer x = GetPlayerId(GetOwningPlayer(GetSellingUnit())) local integer i = 1 local location whichPoint = GetRectCenter(udg_SpawnPoints[x]) local location whichTarget = GetRectCenter(udg_WorkerPoints[x]) set udg_CurrentLevel[x] = 1 //udg_CurrentLevel[x] + 1 set udg_ConcurrentLevels[x] = ( udg_ConcurrentLevels[x] + 1 ) call RemoveUnit( GetSoldUnit() ) loop exitwhen i > 10 + 2 * udg_Gametype call CreateNUnitsAtLocFacingLocBJ( 1, udg_LevelTypes[udg_CurrentLevel[x]], udg_AttackerPlayers[x], whichPoint, whichTarget ) call SetUnitUserData( GetLastCreatedUnit(), udg_CustomValues[x] ) call GroupAddUnitSimple( GetLastCreatedUnit(), udg_WaypointGroups[x] ) call IssuePointOrderLoc( GetLastCreatedUnit(), "move", whichTarget ) set i = i + 1 call TriggerSleepAction( 1.00 - I2R(udg_Gametype) * 0.10) endloop endfunction //=========================================================================== function InitTrig_StartLevel takes nothing returns nothing set gg_trg_StartLevel = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_StartLevel, EVENT_PLAYER_UNIT_SELL ) call TriggerAddCondition( gg_trg_StartLevel, Condition( function Trig_StartLevel_Conditions ) ) call TriggerAddAction( gg_trg_StartLevel, function Trig_StartLevel_Actions ) endfunction and the redirect trigger (each of the 8 is almost the same) Code:
function Trig_Player1Waypoints_Actions takes nothing returns nothing local integer i = GetUnitUserData(GetEnteringUnit()) local unit whichUnit = GetEnteringUnit() local location whichPoint if ( IsUnitOwnedByPlayer(GetEnteringUnit(), Player(8)) == true ) or ( IsUnitOwnedByPlayer(GetEnteringUnit(), Player(9)) == true ) or ( IsUnitOwnedByPlayer(GetEnteringUnit(), Player(10)) == true ) or ( IsUnitOwnedByPlayer(GetEnteringUnit(), Player(11)) == true ) then if i == 8 then set whichPoint = GetRandomLocInRect(gg_rct_Middle2) call SetUnitUserData( GetEnteringUnit(), ( 0 )) else set whichPoint = GetRectCenter(udg_Waypoints[i + 1]) call SetUnitUserData( GetEnteringUnit(), ( GetUnitUserData(GetEnteringUnit()) + 1 ) ) endif call IssuePointOrderLoc( whichUnit, "move", whichPoint ) endif call RemoveLocation(whichPoint) set whichPoint = null set whichUnit = null endfunction //=========================================================================== function InitTrig_Player1Waypoints takes nothing returns nothing set gg_trg_Player1Waypoints = CreateTrigger( ) call TriggerRegisterEnterRectSimple( gg_trg_Player1Waypoints, gg_rct_P1R1 ) call TriggerRegisterEnterRectSimple( gg_trg_Player1Waypoints, gg_rct_P1R2 ) call TriggerRegisterEnterRectSimple( gg_trg_Player1Waypoints, gg_rct_P1R3 ) call TriggerRegisterEnterRectSimple( gg_trg_Player1Waypoints, gg_rct_P1R4 ) call TriggerRegisterEnterRectSimple( gg_trg_Player1Waypoints, gg_rct_P1R5 ) call TriggerRegisterEnterRectSimple( gg_trg_Player1Waypoints, gg_rct_P1R6 ) call TriggerRegisterEnterRectSimple( gg_trg_Player1Waypoints, gg_rct_P1R7 ) call TriggerRegisterEnterRectSimple( gg_trg_Player1Waypoints, gg_rct_P1R8 ) call TriggerRegisterEnterRectSimple( gg_trg_Player1Waypoints, gg_rct_P1R9 ) call TriggerAddAction( gg_trg_Player1Waypoints, function Trig_Player1Waypoints_Actions ) endfunction |
