Unit Leaves Region Slow to React

Gryffin

New Member
Reaction score
6
UPDATE:
This problem has been solved!
Please see page 2 for the solution.

Original Post:
Hello, I've searched the forum about this, but didn't find anything that answered what I need to know. I have a trigger where a unit leaves a region. However, the trigger is extremely slow to react. The game does not recognize that the unit has left the region for at least a good 5 seconds after she has done so. Unfortunately, I need the trigger to be instantaneous. I tried changing Reaction Delay Max in the Gameplay Constants to 0.01, but to no avail. Does anyone know if Unit Leaves Region is an inherently slow event, or if I'm potentially doing something wrong. I do have a few conditions it needs to check, but I don't see how that would be an issue. I could possibly create 4 regions in a box around my unit, and say unit enters region, but I would like to see if I could get this to work first. Also, the region is placed on the unit. So the unit never entered the region, technically; the region was moved to the position of unit.

Thanks for the help.
 

kaboo

New Member
Reaction score
45
for me it always worked correctly
but, mby there is an issue with your trigger
 

canons200

New Member
Reaction score
50
try to post your trigger here? editor only follow what you set, editor never wrong =.='
 

Gryffin

New Member
Reaction score
6
Here you go. The first action, the display to all players, takes at least 5 seconds to display after the unit has left the region, very often not triggering at all.

Trigger:
  • messenger leaves region red
    • Events
      • Unit - A unit leaves MessengerBoxRed <gen>
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • (Leaving unit) Equal to Messenger[1]
          • ((Leaving unit) is in HasMoved) Equal to False
          • MessInvOpenRunning Equal to False
          • MessLeavesRegionRunning Equal to False
    • Actions
      • Game - Display to (All players) the text: MessLeavesRegion Ru...
      • Set MessLeavesRegionRunning = True
      • Wait 1.00 seconds
      • Unit Group - Add (Leaving unit) to HasMoved
      • Unit - Order (Leaving unit) to Stop
      • Unit - Set (Leaving unit) movement speed to 0.00
      • Set ActionPoints = (ActionPoints - 1.00)
      • Set ActionPointsInt = (Integer(ActionPoints))
      • Player - Set (Owner of (Leaving unit)) Current gold to ActionPointsInt
      • Multiboard - Set the text for PlayerMultiboards[1] item in column 2, row 2 to (String((Player 1 (Red) Current gold)))
      • Multiboard - Set the text for PlayerMultiboards[1] item in column 2, row 3 to (String((Player 2 (Blue) Current gold)))
      • Set MovementCheat = 0
 

canons200

New Member
Reaction score
50
why your trigger so complicated? i also don't know how to help you...............try to disable some condition and check 1 by 1 to see which condition makes problem.

is your trigger leave region only work for 1 unit? because boolean only work for true and false. mean if you have 1 unit leave region, boolean is working fine.

But if you have many unit, the boolean only work at the first time for the unit leave, unless you reset the boolean action.

eg, 1 unit> boolean default is false, event check false and make it true and run your action, then reset to false again so the event can run again > enable other unit to repear the action

eg 10 unit, the trigger for the 1 unit run first, it set from FALSE set to TRUE, in the meanwhile the action is continue, second unit steps it.... but the condition is TRUE now, so wont run the trigger.
 

X.Terror.X

New Member
Reaction score
10
the trigger isnt the easyest one to understand :S

but i see 1 major problem
you ask from a "Leaving unit" actions while after 1 second wait timer that unit isnt "leaving unit" anymore

this might cause 1 of the problems
but it doesnt say much about how u explained your problem


so store the leaving unit in a varible before wait timer
the only problem is that this will bug if the trigger is used twice in a period or time
 

Gryffin

New Member
Reaction score
6
Hey everyone. Thanks for the responses.
Unfortunately, I'd already tried everything you've described.
The trigger is designed to work with only one unit, the Messenger, hence the condition.
The trigger, as it stands, will never fire, actually, even though I tried deleting my boolean conditions (whch, since they weren't broken, fixed nothing).
The reason I know its not working because if the game detected the Messenger leaving the region, it would display the message "MessLeavesRegion Running" immediately. It never displays the message.

I'm positive the region is in the right place, because I've created a floating text check to make sure. But no matter how many times I leave the region and reenter and leave again, the trigger never goes off.

READ: I've Finally figured it out. The region isn't actually moving. At certain times, I tell the region to be centered on position of the Messenger. The game even tells me this is happening because I create a float text of R on the position of the region. But the game is lying or the region is immediately moving back, because the region is aways in its original position on the map.
 

Gryffin

New Member
Reaction score
6
Gosh darn it. I still can't get this to work.
I've tried a new method. Feel free to take a look and see if you have any ideas.

Trigger:
  • Messenger
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • (Unit-type of (Trained unit)) Equal to Messenger
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Trained unit)) Equal to Player 1 (Red)
        • Then - Actions
          • Set MessengerOrigin[1] = (Position of (Trained unit))
          • Unit - Kill (Trained unit)
          • Set Messenger[1] = Messenger 0005 <gen>
          • Set MessengerInvFull[1] = False
          • Set MessengerOrigin[1] = (Position of (Trained unit))
          • Unit - Change ownership of Messenger[1] to Player 1 (Red) and Change color
          • Unit - Set Messenger[1] movement speed to 0.00
          • Unit - Move Messenger 0005 <gen> instantly to MessengerOrigin[1]
          • Set MessengerBox[1] = (Region centered at MessengerOrigin[1] with size (100.00, 100.00))
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Trained unit)) Equal to Player 2 (Blue)
            • Then - Actions
              • Set MessengerOrigin[2] = (Position of (Trained unit))
              • Unit - Kill (Trained unit)
              • Set Messenger[2] = Messenger 0006 <gen>
              • Set MessengerInvFull[2] = False
              • Unit - Change ownership of Messenger[2] to Player 2 (Blue) and Change color
              • Unit - Set Messenger[1] movement speed to 0.00
              • Unit - Move Messenger 0006 <gen> instantly to MessengerOrigin[2]
              • Set MessengerBox[2] = (Region centered at MessengerOrigin[2] with size (100.00, 100.00))
            • Else - Actions
              • Do nothing


Trigger:
  • messenger leaves region red
    • Events
      • Unit - A unit leaves (Region centered at (Position of Messenger 0005 <gen>) with size (100.00, 100.00))
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • playerTurn Not equal to 0
          • (Leaving unit) Equal to Messenger[1]
          • MessInvOpenRunning Equal to False
          • MessLeavesRegionRunning Equal to False
    • Actions
      • Game - Display to (All players) the text: MessLeavesRegion Ru...
      • Set MessLeavesRegionRunning = True
      • Wait 1.00 seconds
      • Unit Group - Add Messenger[1] to HasMoved
      • Unit - Order Messenger[1] to Stop
      • Unit - Set Messenger[1] movement speed to 0.00
      • Set ActionPoints = (ActionPoints - 1.00)
      • Set ActionPointsInt = (Integer(ActionPoints))
      • Player - Set Player 1 (Red) Current gold to ActionPointsInt
      • Multiboard - Set the text for PlayerMultiboards[1] item in column 2, row 2 to (String((Player 1 (Red) Current gold)))
      • Multiboard - Set the text for PlayerMultiboards[1] item in column 2, row 3 to (String((Player 2 (Blue) Current gold)))
      • Set MovementCheat = 0
 
Reaction score
107
Just so you know, conditions are automatically set to be "and" so you don't need that particular line. Also this applies to "do nothing", it quite literally does nothing, so you don't need it either.

As for your problem, you said that you're moving the region? Moving regions with triggers is mostly pretty bugged. The enter/leave region will only trigger on the original location of the region, the only way around it is to re-add the event to the trigger so the enter/leave will register with the new location of the region. But this could pose problems with the trigger firing at the wrong time.. I didn't look at your new method of triggering, but this is just something to keep in mind.
 

Gryffin

New Member
Reaction score
6
well, instead of moving region, why don't you use more region?

It's possible I could make a grid of regions, and set a variable to the most recently entered region as the messenger moves. But that would be fairly variable for the movement distance limitations I would like to set later. Excellet idea though.

@Baka-ranger: Thanks for the comments. I'll keep those in mind. Have you had a chance to look at the newly posted trigger in my previous post? I try to create the region as the messenger is leaving it, so to speak, but it also does not work.
 
Reaction score
107
Just a few questions..
Why are you replacing the trained unit with a pre-placed one..?
Does changing the move speed of a unit through triggers actually work? If so, does it over ride the minimum value set in game play constants?

It seems like you're trying to make a board game of sorts, and you're trying to detect how far the unit moves to deduct "action points"? Might I suggest to prevent all movement until it is the players turn, then let them move as they like and check the distance of the unit from it's position at the start of the turn?
 

Gryffin

New Member
Reaction score
6
Just a few questions..
Why are you replacing the trained unit with a pre-placed one..?
Does changing the move speed of a unit through triggers actually work? If so, does it over ride the minimum value set in game play constants?

It seems like you're trying to make a board game of sorts, and you're trying to detect how far the unit moves to deduct "action points"? Might I suggest to prevent all movement until it is the players turn, then let them move as they like and check the distance of the unit from it's position at the start of the turn?

Hey.
I am developing a turn-based game, called Manifest. And, as you suggest, I check the movement distance of each unit individually as they are moved. I am updating daily a development blog about the title here, if you are interested. I will be posting about my movement triggers within the next week or so, likely.
http://www.moddb.com/mods/manifest

About your questions. I had to create the unit in the editor so that she may be referenced in the event. Messenger[1] is Messenger 005. The "region centered at position of" clause within unit leaves region may not reference a trained unit. It must reference a unit that exists in the editor, before the game begins.

Changing the move speed via triggers does indeed work, and quite well. It also overrides the gameplay constants. The minimum move speed in gameplay constants is 1, but triggers work perfectly well for resetting the move speed to zero.

I have a standard issued to order code for most units. But the messenger is a unique case in that she deals with items. A unit ordered to drop an item does not count as an order, or at least the game does not recognize it as one. This means that when she is ordered to drop or pickup or give an item, she bypasses the standard code and ignores the event, never setting off the trigger. That is why I need this custom code for the messenger. As far as I can tell, it is the only way to guarantee that she does not break the system, by detecting her having left a region.

My problem right now is that regions won't move properly. And I can't create a region around her that will detect properly either.

I really need suggetions on how to get this to work. I need to reset the location of the region when I want to, and be able to detect when the unit has left the region. And ideas are appreciated.
 
Reaction score
107
Rather than having the event on the trigger before it starts, you can just add the event to the trigger, using the messenger variable which you can set the trained unit to when it's trained. It's a minor issue, but having pre-placed things when not required just bug me :p

I'm still not exactly sure what you want to achieve... I tried looking on your link for more info, but didn't really find much, so if you could provide more detail, perhaps I could suggest an alternate solution to your problem, if not a fix.
 

Gryffin

New Member
Reaction score
6
Rather than having the event on the trigger before it starts, you can just add the event to the trigger, using the messenger variable which you can set the trained unit to when it's trained. It's a minor issue, but having pre-placed things when not required just bug me :p

I'm still not exactly sure what you want to achieve... I tried looking on your link for more info, but didn't really find much, so if you could provide more detail, perhaps I could suggest an alternate solution to your problem, if not a fix.

I've tried that. The event "A Unit Leaves Region Centered at Point" MUST be centered on a pre-existing unit, the point of which counts as a region. Therefore, to try this method, I had no choice but to create a unit in the editor then replace the trained unit with that pre-existing unit.

Once again, the problem is that I need to detect when the Messenger has moved using methods OTHER than Unit issued an order to point or object. When picking up or dropping items, the game does not detect these as issued an order to point or object )or any other order or orderstring as far as I can tell). Therefore, I need to know when the messenger has moved. A leaving region event makes perfect sense, except that regions cannot be moved around. And my latest method of detecting if the messenger has left a region around her also does not seem to work.
 
Reaction score
107
I meant, use the trigger line "trigger - add new event" to add the event to the region trigger, that way you can use a variable.

Also, do the generic unit events such as "unit acquires an item" or "unit loses an item" not work? Check the position of the messenger, against it's original position at the start of the turn?
 

Gryffin

New Member
Reaction score
6
I meant, use the trigger line "trigger - add new event" to add the event to the region trigger, that way you can use a variable.

Also, do the generic unit events such as "unit acquires an item" or "unit loses an item" not work? Check the position of the messenger, against it's original position at the start of the turn?

I got it to work! ...Sort of...
It's all thanks to your suggestion, too.
When a Messenger is trained, this trigger is run:
Trigger:
  • Messenger
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • (Unit-type of (Trained unit)) Equal to Messenger
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Trained unit)) Equal to Player 1 (Red)
        • Then - Actions
          • Set Messenger[1] = (Trained unit)
          • Set MessengerInvFull[1] = False
          • Set MessengerBox[1] = (Region centered at (Position of Messenger[1]) with size (100.00, 100.00))
          • Trigger - Add to messenger leaves region red <gen> the event (Unit - A unit leaves MessengerBox[1])


At the beginning of every turn, I run this code:
Trigger:
  • Set MessengerBox[1] = (Region centered at (Position of Messenger[1]) with size (100.00, 100.00))
    • Trigger - Add to messenger leaves region red <gen> the event (Unit - A unit leaves MessengerBox[1])


My Messenger movement code looks like this:
Trigger:
  • messenger leaves region red
    • Events
    • Conditions
      • playerTurn Not equal to 0
      • (Leaving unit) Equal to Messenger[1]
      • MessInvOpenRunning Equal to False
      • MessLeavesRegionRunning Equal to False
    • Actions
      • Game - Display to (All players) the text: MessLeavesRegion Ru...
      • Set MessLeavesRegionRunning = True
      • Wait 1.00 seconds
      • Unit Group - Add Messenger[1] to HasMoved
      • Unit - Order Messenger[1] to Stop
      • Unit - Set Messenger[1] movement speed to 0.00
      • Set ActionPoints = (ActionPoints - 1.00)
      • Set ActionPointsInt = (Integer(ActionPoints))
      • Player - Set Player 1 (Red) Current gold to ActionPointsInt
      • Multiboard - Set the text for PlayerMultiboards[1] item in column 2, row 2 to (String((Player 1 (Red) Current gold)))
      • Multiboard - Set the text for PlayerMultiboards[1] item in column 2, row 3 to (String((Player 2 (Blue) Current gold)))
      • Set MovementCheat = 0


And it totally works exactly as intended.
However, here comes the sad news. The game crashes on me now. And I've done some experimentation. I'm fairly certain that the reason the game crashes is because each turn, I continue to add the same event to the same trigger. The game becomes overloaded with so many events in one trigger.

So, naturally, I tried removing that action from the turn activation trigger. At the beginning of each turn, the variable for the region MessengerBox[1] is reset to the current location of the messenger. However, because the leaves region event is not re-added to the trigger also, the region doesn't actually move, and the messenger leaves region trigger fails. Because the event isn't re-added, the region remains where it was the first and only time the event was added, at the spot where the messenger was trained. I can move the messenger over there and then the code works just fine, but it needs to trigger from her present location, of course.

I have a catch-22. I can't continuously add the event to the leaves region trigger because it causes my game to crash. And as far as I can tell, no other system will work.

Any ideas?
 
Reaction score
107
Having numerous events on one trigger shouldn't cause the game to crash. Damage detection systems use the add event function and often have several hundred events on one trigger by the end of the game, so I'm rather doubtful that this is the cause..

As to why it would be crashing, I'm pretty stumped. I would think that there may be multiple instances of your trigger going at the same time, but if you say it work's perfectly, then that's probably not the case...

What you could do instead of using regions, is just to run a periodic trigger, checking whether the messenger is in range of it's previous position or not.
 

Gryffin

New Member
Reaction score
6
Having numerous events on one trigger shouldn't cause the game to crash. Damage detection systems use the add event function and often have several hundred events on one trigger by the end of the game, so I'm rather doubtful that this is the cause..

As to why it would be crashing, I'm pretty stumped. I would think that there may be multiple instances of your trigger going at the same time, but if you say it work's perfectly, then that's probably not the case...

What you could do instead of using regions, is just to run a periodic trigger, checking whether the messenger is in range of it's previous position or not.

Yeah. I've thought about the periodic option. But I'd rather avoid that because I think it's sort of a laggy, last resort option. Also, its not a s precise as unit leaves region. If I have to, I will use periodic event. I'm glad to hear that multiple events wouldn't crash the game. But then I ahve no idea what the issue is. I'll look at the code again and see if something else could be causing the crash. I do know for sure, however, that it has to do with the above messenger code I've implemented. The crash source is somwehere in there.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top