Help~~ How to make sure command only be executed once?

23 views
Skip to first unread message

zhe wang

unread,
Aug 1, 2012, 1:05:53 PM8/1/12
to bw...@googlegroups.com
hey guys, I wonder where should I put functions to make sure it is only executed once.  
For example, I write a function DenfendDropReaver() for defending protoss reaver strategy, the function works like this:
1.When I find the opponent's shuttle in my area, I want all my units gather and follow it. 
2.If the shuttle drops a reaver, I order all my units go and attack it.
3. After that, I want my units stay idle.

Because I don't know when  opponent's shuttle will come, so I have to put this function in OnFrame().
However, anything related to unit control in the function Onframe() works terrible because it is called each frame, so all units just stuck. 
Even if I try to use unit->getOrder() to fix that, it still works bad. 
So how could I realize the effect as I choose my units and right click just for one time, and then the units stay idle?

 
By the way, I've tried many ways to find a polygon's boundary but failed.....

Krasimir Krystev

unread,
Aug 1, 2012, 1:43:08 PM8/1/12
to bw...@googlegroups.com
I think this should be implemented in your program logic. For example store the last frame you ordered a unit to do something and don't issue any new orders to the same unit until at least X number of frames have passed. X might be 24 (a second) or a little more or less depending on the order in question.
--
BR

zhe wang

unread,
Aug 2, 2012, 2:57:59 AM8/2/12
to bw...@googlegroups.com
Thank you for the reply and suggestion.
I also consider using frame to control that , but still, this order always exist in onFrame(). So no matter how long the interval it is, the command still issues repeatedly. 
I just expect when I issue a command then it is executed once, so that no conflict between different commands.

For example, when frame=1000, I need my unit go to Position A.  After few seconds (I'm not sure about the exact time), I want it move to Position B, and during the execution of this command(Position B), an emergency may happen, so I need my unit back to Position A immediately. Just like:

go to Position A() ------- do it once
go to Position B() ------- do it once
back to Position A() ------- do it once

...

Does that mean I have to set a flag for every command function..?      

在 2012年8月2日星期四UTC+9上午2时43分08秒,krasi0写道:
I think this should be implemented in your program logic. For example store the last frame you ordered a unit to do something and don't issue any new orders to the same unit until at least X number of frames have passed. X might be 24 (a second) or a little more or less depending on the order in question.

--
BR
Message has been deleted

Krasimir Krystev

unread,
Aug 2, 2012, 3:05:09 PM8/2/12
to bw...@googlegroups.com
Check on how such things are implemented in more advanced bots like skynet

On Thu, Aug 2, 2012 at 9:58 AM, zhe wang <wwzz...@gmail.com> wrote:


在 2012年8月2日星期四UTC+9上午2时05分53秒,zhe wang写道:
在 2012年8月2日星期四UTC+9上午2时05分53秒,zhe wang写道:
在 2012年8月2日星期四UTC+9上午2时05分53秒,zhe wang写道:
在 2012年8月2日星期四UTC+9上午2时05分53秒,zhe wang写道:
在 2012年8月2日星期四UTC+9上午2时05分53秒,zhe wang写道:



--
BR
Reply all
Reply to author
Forward
0 new messages