Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
What is EVENT_Tick in spawn.cpp?

 
Post new topic   Reply to topic Printable version
 View previous topic  MERVBot Help Needed Post :: Post Bot give creds via another bot  View next topic  
Author Message
Quan Chi2
Member of "Sexy Teenagers that Code" Group
Member of


Age:34
Gender:Gender:Male
Joined: Mar 25 2005
Posts: 860
Location: NYC
Offline

PostPosted: Fri Nov 25, 2005 8:26 am    Post subject: What is EVENT_Tick in spawn.cpp? Reply to topic Reply with quote

What is it? What is EVENT_Tick?
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
Solo Ace
Yeah, I'm in touch with reality...we correspond from time to time.


Age:37
Gender:Gender:Male
Joined: Feb 06 2004
Posts: 2583
Location: The Netherlands
Offline

PostPosted: Fri Nov 25, 2005 9:21 am    Post subject: Reply to topic Reply with quote

It's used for "ticking" a player in the playerlist.

No, just kidding.

EVENT_Tick is an event "called" every... milisecond?
You can time for multiple events in it, just search the forums or check Underlord's tutorial.
Back to top
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


Age:39
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Fri Nov 25, 2005 9:31 am    Post subject: Reply to topic Reply with quote

I thought it was every second. But it has been years since I've worked with MERV.
_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Quan Chi2
Member of "Sexy Teenagers that Code" Group
Member of


Age:34
Gender:Gender:Male
Joined: Mar 25 2005
Posts: 860
Location: NYC
Offline

PostPosted: Fri Nov 25, 2005 10:18 am    Post subject: Reply to topic Reply with quote

How would I make my plugin return to the arena that I did a command in?

like

i do

if(c->check("arenago"))
{
String Destination = c->final;
tell(makeChangeArena(Destination));
}

then i want it to come right back. What would I do then?
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Fri Nov 25, 2005 10:44 am    Post subject: Reply to topic Reply with quote

It's every second.
_________________
This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Bjorn
Novice


Joined: Apr 27 2004
Posts: 45
Offline

PostPosted: Fri Nov 25, 2005 1:34 pm    Post subject: Reply to topic Reply with quote

It's every second and i'd also like to add that dont use this event to do any precise measurements of time since it will often be off by quite abit after awhile.
Back to top
View users profile Send private message Add User to Ignore List Send email
Bak
?ls -s
0 in


Age:26
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Sat Nov 26, 2005 2:31 pm    Post subject: Reply to topic Reply with quote

why will it be "off by quite abit after awhile" ?
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Sat Nov 26, 2005 6:10 pm    Post subject: Reply to topic Reply with quote

Bjorn wrote:
It's every second and i'd also like to add that dont use this event to do any precise measurements of time since it will often be off by quite abit after awhile.


Bak wrote:
why will it be "off by quite abit after awhile" ?


I am going to reply to this, but will do so in the context of Powerbot since I don't know how Merv does it.

Powerbot sends a TICK event to all modules at no more than once every 100ms. So if you need to check something "often", you can do so in response to this event. If you only need to check something "about once every second", you could count off 10 TICK events.

Inside the core, I am in a tight loop doing all the things the core needs to do (network recv/send, reliability layer, various module events). Each bot has its own thread, and to keep the threads from using 100% CPU when there's nothing happening, I call Sleep(5). This is sufficient to bring CPU usage down to 0% even with 20 bots with 10 modules each.

So why can't you count, say, 100 TICK events to get 10 seconds? Because any given thread (or process) is not guaranteed to get processing time, and also because Sleep(5) guarantees that you will NOT get back in for 5ms, but does not guarantee that it will not be longer. In fact under XP, I believe, that the foreground thread runs for 40ms before being interrupted (unless it gives up the slice by calling Sleep/Wait/GetMessage/etc), and a background thread runs for 20ms. So each TICK event might actually take 120ms, making 100 of them be more like 12 seconds.

So, if you need a very accurate 2500ms, for example, then you should (in Powerbot) use the TICK event, check GetTickCount() for yourself based on when the time interval started. You would get an accuracy between 2500 and 2600ms plus any delay caused by other processes. If you needed MUCH more accuracy than that, then you would need to create your own thread and call GetTickCount() very often to see when your interval had passed. However, you would probably then still need to sync up with the bot's thread, which would add 100+ms of sync time into the mix. Therefore it would not be worth it.

FYI: The Powerbot core also has a timer function. You can call SetTimer(t) and you wil get a TIMER event at t (or greater) ms in the future. The timer functionality is only as accurate as the TICK accuracy, but it's a little more convenient when you need lots of timed events.
_________________
4,691 irradiated haggis!
Back to top
View users profile Send private message Add User to Ignore List
Bak
?ls -s
0 in


Age:26
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Sat Nov 26, 2005 9:39 pm    Post subject: Reply to topic Reply with quote

That's reasonable, looks like that's how MERVBot does it too.

Code: Show/Hide
Uint32 time = getTime();

...

if (time - lastTick >= 100)
{
    lastTick = time;
    imports->talk(makeTick());
}


Code: Show/Hide
Uint32 getTime()
{
    return GetTickCount() / 10;
}



If one wanted more accuracy (but possibly more than one tick per second on some instances) we could do:
Code: Show/Hide
if (time - lastTick >= 100)
{
    lastTick += 100;
    imports->talk(makeTick());
}


This assumes lastTick is initialized properly.
Back to top
View users profile Send private message Add User to Ignore List AIM Address
D1st0rt
Miss Directed Wannabe


Age:37
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Sun Nov 27, 2005 2:22 am    Post subject: Reply to topic Reply with quote

It's like if the bots are in a race. The starting gun is fired, but they probably won't start simultaneously with the gun because of the reaction time required to recognize that it is time to start and then actually start.
_________________

Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Sun Nov 27, 2005 2:13 pm    Post subject: Reply to topic Reply with quote

Uhhh, thanks for the analogy.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Bot Questions All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 469 page(s) served in previous 5 minutes.

phpBB Created this page in 0.496469 seconds : 35 queries executed (88.0%): GZIP compression disabled