Moving Units
Apr 25 2008, 2:07 pm
By: major  

Apr 25 2008, 2:07 pm major Post #1



Hi. I know you probably are going to ask for a test map, but I hope that someone had this kind of an error.
If not I'll make a test map.

What I am trying to do is a trigger that swaps units. If you move a unit to a certain part of the swapping area (for example a beacon) - it will be moved to the playfield, and the one on the playfield will be moved back to the swapping area. You get the idea.
The swapping zone is divided into two parts. One, at which the units just stand and do nothing, waiting for the player to move them to the second part (StartTrans Location). And that second part handling the swapping trigger(Transform Location).

Here is how the trigger works, in its most basic form.

Players:
Force 1
Conditions:
Current Player brings at least 1 [men] to 'Transform Location'.
Current Player brings at least 1 [men] to 'PlayField'.
Actions:
Center location labbeled 'Select' on [men] owned by Current Player at 'PlayField'.
Move 1 [men] for Current Player at 'Select' to 'StartTrans Location'.
Move 1 [men] for Current Player at 'Transform Location' to 'Select'.
Preserve Trigger.

And what happens is that it works ok, but sometimes, like 1 to 20 times, it doesn't move that unit at 'Transform Location' but still moves the unit at the PlayField to the 'StartTrans Location'. And I end up with 2 units at the swapping zone and no units on the PlayField... What is wrong ???

I wrote that it's the most basic form. Because i tried to solve that bug and I wrote like hundred versions of this trigger. I used a location called 'waitingroom' something inbetween. The guy at the playfield goes to the waiting room, the unit at the transform zone is moved then to the playfield. And after a few seconds the mate at the waitingroom goes to the swapping area.
The same.

I thought maybe it was because the wait functions i used somewhere in my triggers. So I improved them to be death timers.
Still the same.
What can be wrong. Do you have any ideas ?

///
and yes, these locations don't intersect, they are pretty far from each other.

Post has been edited 2 time(s), last time on Apr 25 2008, 2:15 pm by major.



None.

Apr 25 2008, 3:02 pm major Post #2



What I noticed now is, that it is most likely to happen when the to-be swapped unit (that on the playfield) is running close to a wall. Can that be a problem ? I don't get any unplaceable error. Is it shown with the Move Unit method ? The select location is very small, so i don't get it, how come the unit was actually there, but it's unplaceable for the swapped unit next second...

Can that be the problem ? If yes, how can i fight it ?



None.

Apr 25 2008, 3:50 pm NudeRaider Post #3

We can't explain the universe, just describe it; and we don't know whether our theories are true, we just know they're not wrong. >Harald Lesch

Well that's a problem I also ran into. And good that you mentioned that it happens only near walls or otherwise I wouldn't have figured.

The problem is that if you try to move a unit to unplaceable terrain the move will just not take place without any messages or noticeable effects whatsoever (except the unsuccessfully teleported unit will lose it's orders). Unfortunately you can walk closer to walls than you can teleport.

Now if you had a vertical or horizontal wall it would be easy to fix: Make 4 locations in the play field that act like a invisible border and are about 1,5 Tiles thick. When the player tries to swap inside any of the 4 locations don't execute the swapping until he has moved out (and possibly give a text message explaining it).

But probably you have nice isometric walls so you need another method. You could, instead of centering only 1 location on the unit inside PlayField, create a mobile grid of 9 locations. 2x2 should work. Then you just teleport the unit at 'Transform Loc' to each of the 9 grid locations, starting with center. That means, if possible, the unit will be teleported exactly where the other was. When successful, the other 8 move unit actions don't find a unit at 'Transform Loc' and nothing happens. When unsuccessful, each location will be selected until a valid position is found and the unit will be moved away from 'Transform Loc'.

Here's a link about Grid Systems (scroll down to mobile grid) if you're unfamiliar with them.




Apr 25 2008, 4:27 pm major Post #4



The grid system works like a charm ! Thanks a lot.



None.

Apr 26 2008, 6:44 am Wormer Post #5



A way toooooooo complicated, guys :)

To solve the problem all you need is simply to exchange two actions in the trigger above:
Players:
Force 1
Conditions:
Current Player brings at least 1 [men] to 'Transform Location'.
Current Player brings at least 1 [men] to 'PlayField'.
Actions:
Center location labbeled 'Select' on [men] owned by Current Player at 'PlayField'.
Move 1 unit1 for Current Player at 'Transform Location' to 'Select'.
Move 1 unit2 for Current Player at 'Select' to 'StartTrans Location'.
Preserve Trigger.

Thats all :D You might want to distinguish between unit1 and unit2. The trick is based on the fact that even if the Select location is on the unplaceable terrain it will still move units there as long as there is at least one another unit. This is called displaceing movement.



Some.

Apr 26 2008, 8:56 am rockz Post #6

ᴄʜᴇᴇsᴇ ɪᴛ!

Yes, but I don't want my unit to move down every time I transfer.

Instead, It would be better to use the technique only when you're in danger (ie, a unit in the "transform location" and "StartTrans Location"). Move the unit2 back to the center(he should be able to move back), and move the unit1, then move unit2 back like Wormer said.



"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

Apr 26 2008, 2:13 pm Wormer Post #7



Can't you just add an action to center the unit if it is possible:
Move 1 unit1 for Current Player at 'Select' to 'Select'.



Some.

Apr 26 2008, 8:20 pm Falkoner Post #8



Well, a better way would be to move the unit on the field into another area before moving it back into the swapping area, then moving the unit in the swapping area to the location where the other unit used to be, then moving the unit in the waiting area to the swapping area.

Now, since the wall is a problem, then the more likely reason for the problem is because the unit is implaceable, and since you are moving them, you shouldn't be getting errors, so what you may want to do, is create another unit, try to move it onto the field, then in another trigger, check if the unit is still in the creation area, if so, it is implaceable, so you will not move the other units, if it does move, move it back to it's creating area, or remove it, and then move the units like in the above paragraph.

Post has been edited 1 time(s), last time on Apr 26 2008, 8:26 pm by Falkoner.



None.

Apr 27 2008, 6:45 am Wormer Post #9



Quote
Well, a better way would be to move the unit on the field into another area before moving it back into the swapping area, then moving the unit in the swapping area to the location where the other unit used to be, then moving the unit in the waiting area to the swapping area.
Why this is a better way? Do you mean units could shuffle?

Quote
Now, since the wall is a problem, then the more likely reason for the problem is because the unit is implaceable, and since you are moving them, you shouldn't be getting errors, so what you may want to do, is create another unit, try to move it onto the field, then in another trigger, check if the unit is still in the creation area, if so, it is implaceable, so you will not move the other units, if it does move, move it back to it's creating area, or remove it, and then move the units like in the above paragraph.
Falkoner, why do you need to have a special system to detect if the unit can be moved? Why cant you always move with displaceing movement?



Some.

Apr 27 2008, 1:16 pm Falkoner Post #10



Sorry, I was assuming he was continuing to use Men, which is why I suggested that method, if he for some reason continued to want to do it(like if the two units were the same) then that method would work best.

For your second question, if the area where the unit is on the playing field is not placeable, and you try swapping them, he will get moved in, but the other unit will not get moved out since it is implaceable, and then you get the glitch that he got, I guess you could try to remember which unit should be out using a switch, and that could also fix it.



None.

Apr 27 2008, 7:04 pm Wormer Post #11



Quote
Sorry, I was assuming he was continuing to use Men, which is why I suggested that method, if he for some reason continued to want to do it(like if the two units were the same) then that method would work best.
You no need to make excuses. :) I just dont understand why are you suggesting that.

Quote
For your second question, if the area where the unit is on the playing field is not placeable, and you try swapping them, he will get moved in, but the other unit will not get moved out since it is implaceable, and then you get the glitch that he got, I guess you could try to remember which unit should be out using a switch, and that could also fix it.
Do you mean totally unplaceable?.. I see, that makes sence.



Some.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[06:18 am]
Sylph-Of-Space -- No complaints here, i'm just curious!
[11:05 pm]
Ultraviolet -- :wob:
[03:55 pm]
Zoan -- :wob:
[10:34 am]
NudeRaider -- SEN doesn't rely on spammers initiate its sleep cycle. It hat fully automated rest and clean-up phases. Please understand that this is necessary for the smooth operation of the site. Thank you.
[2024-5-18. : 3:45 am]
Sylph-Of-Space -- Does the shoutbox get disabled when there's spammers?
[2024-5-17. : 6:47 am]
NudeRaider -- lil-Inferno
lil-Inferno shouted: nah
strong
[2024-5-17. : 5:41 am]
Ultraviolet -- 🤔 so inf is in you?
[2024-5-17. : 4:57 am]
O)FaRTy1billion[MM] -- my name is mud
[2024-5-17. : 4:35 am]
Ultraviolet -- mud, meet my friend, the stick
[2024-5-16. : 10:07 pm]
lil-Inferno -- nah
Please log in to shout.


Members Online: Roy, NudeRaider