| 03-05-2008, 10:08 AM | #1 |
Hi. I was sondering if there is a way to make a unti obey only some orders (specified by the mod maker) and ignore others a player might give it? For example i want a unit to stand still and not moving even if the player gives an order but i don't want it to be immobilized cause i want it to move to e specific region only when it gets the order to attack a target. I tried to set the unit's movement speed to 0 and when it is ordered to attack set it back to default value but it didn't work the unit was moving.. I also tried to move the unit back to the center of a region (where it is supposed to be) when it is order to move or it gets out of the region but still i'm not happy with the result cause the unit will make some steps and then by magic it will turn back to the center of the region.. I tried to correct that way by ordering the unit to stop when it gets ordered to move but this doesn't work. A similar way that stoped the unit but after a few steps is to force the player press the S button. The best way i found till know is to make a clone unit (in a hidden place on the map) of the curently selected unit and give the orders to it. When the clone unit is ordered to attack then the real unit is ordered to do the actions i want from a trigger. But that create some other mostly visual problems like the absence of the green circel around the real unit which confuses most people (even me) and they select the same unit about 100 times before the realize that they actually have done it in the first place. So i was wondering if there are any improvements to the sollution i found or if there is a better way to do that and most preferably without hiden clone units. |
| 03-05-2008, 12:41 PM | #2 |
Intercept any order you don't want it to perform via the order events and then -- JASS:call PauseUnit(MyUnit, true) call IssueImmediateOrder(MyUnit, "stop") call PauseUnit(MyUnit, false) Then, the only order you let pass is the one that attacks a certain object in a region or whatever. |
| 03-05-2008, 04:18 PM | #3 | |
Quote:
i tried pausing units too but not that way. But if i pause the unit and order it to stop then i don't think it will get that order too cause in editor sais (when you use the pause/unpause function) that paused units do not take any orders but they remember the last order they had and they will performe it as soon as they are unpaused.. I tried your way too and it is like nothing happend. I ordered the unit to move and it did it normally. Probably what happend is that the unit was paused and then issued the order to stop but because it was paused it ignored it and when i unpaused it back it continued following the initial order it had and because this happened realy fast the unit allmost didn't stop moving at all.. I might got wrong about what you told me to do but i think it's right here is the code: Trigger: Anyway thnx for bothering to read this!! |
| 03-05-2008, 09:19 PM | #4 | |
Quote:
It should work, it's worked in nearly every spell I've submitted to the database. If it continues to falter, try to pause/stop/unpause on a 0.0 timer callback. |
| 03-06-2008, 02:52 AM | #5 | |
Quote:
Well i added some wait for 0.1 sec actions between the pause the order and the unpause action. The code became like this: Trigger: i'm not sure if this is what you told me to do in case it continues to fail but it works fine. I'll try to reduce maybe the waiting time cause the player for 0.2 seconds is loosing the command icons on the command card of the unit. That is not a big problem i don't mind a lot about that but why not try to improve it? Anyway thnx for the advice it was really usefull |
