Author Topic: Faster Idle  (Read 2687 times)

0 Members and 1 Guest are viewing this topic.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Faster Idle
« on: September 03, 2009, 05:43:10 am »
As most scripers know, AppOnIdle is invoked about once every second. There have been various attempts to create methods that can have something being called more often. This topic's intent is to simply list some current ways, and discuss advantages of one over another, and also to discuss other possible methods of accomplishing this.

Bullet Bot
Concept:
A bot is spawned, usually outside the play field, and bullets are created above him. Gravity takes effect and falls onto the bot, invoking OnPlayerDamage. The result is set to 0, or a negative number.
Advantages:
-Custom intervals (although difficult to set, and make even)
-Avoids server deaths by calling any function less often (which cannot be done with Poly Hurt Bot) if interval is high enough
Disadvantages:
-May need a custom map, or a map with room outside the map for the idle bot to sit on
-Gravity modifiers may ruin this
-Timing is hard to tweak to make regular intervals
-Bullets may move the bot slightly, and because MovePlayer does not work with bots, it may be necessary to respawn the bot once in a while; it could be possible to do tests to see if its working properly (location of bot, or if bot stops receiving damage)

Poly Hurt Bot
Concept:
A bot is spawned on top of a hurts, deadly, or bloody deadly polygon, and simply sits there. OnPlayerDamage constantly gets called, and setting 0 or a negative result will keep the bot alive.
Advantages:
-Regular intervals (needs to be tested for exact number; if I recall correctly, it is once per tick); these can be filtered through to be used at your own custom intervals
Disadvantages:
-May require a custom map (more often than Bullet Bot), or a map with an inaccessible area with a hurt or other varying polygon type for the bot to sit on

Threaded Loop
Concept:
Create a thread that calls a function which will do an infinite loop. This loop will use Sleep and call a new Idle function. It is optional to call this function in a new thread or not. If the function is expected to take time, it should be called in a new thread (as we don't want our idle loop to hold up)
Advantages:
-Easy to create
-User specific intervals, which may be in ticks, milliseconds, or anything else
-Avoids server deaths by calling any function less often (which cannot be done with Poly Hurt Bot) if interval is high enough
Disadvantages:
-Scripting core thread usage is unstable sometimes; it really depends on where you host it, and how stressed the server is, as I've actually rarely had any huge issues with threads except in the case where I create tons of them. If I did have any issues, I just recreate the thread.
-If the loop dies for whatever reason, it may be necessary to do checks and recreate the loop (its possible for the thread to die, without the server flipping out)

Admin Connection
Concept:
Having an external bot connect to a server as an admin, and constantly send packets of data, and using OnAdminMessage as the main event for faster idle.
Advantages:
-User specific intervals
Disadvantages:
-Requires external application (unless connected to self via sockets)
-May cause internet lag on the server (depending on how good the internet is)
-May cause server lag if other scripts are also heavially parsing OnAdminMessage
-Lag may cause the interval to vary from time to time.

Bot Flag
Concept:
Having a bot sit still, and spawning a flag on top of or above the bot. The flag can be the team opposing the bot's team, or friendly, but would require ReturnFlaging it.
Advantages:
Disadvantages:
-Message saying bot either returned or grabbed the flag very often, spamming the players' consoles.

NTS: example code
NTS: finish checking posts and updating main topic
« Last Edit: September 04, 2009, 01:47:10 pm by DorkeyDear »

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: Faster Idle
« Reply #1 on: September 03, 2009, 12:29:49 pm »
Quote
-Regular intervals (needs to be tested for exact number; if I recall correctly, it is once per tick);
Yes, only hurt poly is 32(but I'm not 100% sure).

Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
Re: Faster Idle
« Reply #2 on: September 03, 2009, 03:22:30 pm »
Ya, we TOTALLY need a faster idle.

All you said must be all the ways to do it. Maybe some people know others.. It would be nice.

Offline Toumaz

  • Veteran
  • *****
  • Posts: 1906
Re: Faster Idle
« Reply #3 on: September 03, 2009, 11:21:24 pm »
you can also have an external program connect to the tcp admin socket and then have that send a message at X Hz, then parsing that in OnAdminMessage and calling your faster AppOnIdle - if you're that desperate!

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: Faster Idle
« Reply #4 on: September 03, 2009, 11:56:00 pm »
That isn't so desperate. Placing flag above ground and bot under it and use onflagreturn, that would be desperate...

Offline croat1gamer

  • Veteran
  • *****
  • Posts: 1327
  • OMG CHANGING AVATAR!!! ^ω^
Re: Faster Idle
« Reply #5 on: September 04, 2009, 04:37:25 am »
you can also have an external program connect to the tcp admin socket and then have that send a message at X Hz, then parsing that in OnAdminMessage and calling your faster AppOnIdle - if you're that desperate!
Gief.

And then, my Clips script should be finished.
Last year, I dreamt I was pissing at a restroom, but I missed the urinal and my penis exploded.

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: Faster Idle
« Reply #6 on: September 04, 2009, 04:51:09 am »
External Messages
Concept:
-Have an external program connect to the tcp admin socket and then have that send a message, then parsing that in OnAdminMessage and calling your faster AppOnIdle
Advantages:
-User specific intervals, which may be in ticks, milliseconds, or anything else
-Avoids server deaths by calling any function less often (which cannot be done with Poly Hurt Bot) if interval is high enough
Disadvantages:
-Someone has to make that program...
-Spam in console(huuuuuge), so no way for admining via TCP without filtering.

Offline Toumaz

  • Veteran
  • *****
  • Posts: 1906
Re: Faster Idle
« Reply #7 on: September 04, 2009, 06:26:14 am »
I suppose you could also use the server's socket functions to connect to a 'server' program instead of having the program connect to the server, but I've no clue how stable sockets actually are as I've never used them. At least that'd get rid of the console spam.

And making the client program/script is trivial; I'll whip a few up in different flavours and post them here soonish.

Edit: PHP bot and a .pas example attached. It's rather shite, but it should hopefully get the point across.
« Last Edit: September 04, 2009, 07:49:14 am by Toumaz »

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: Faster Idle
« Reply #8 on: September 04, 2009, 12:06:15 pm »
Using socket functions gives same effect as using sleep, it's just more complicated.

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: Faster Idle
« Reply #9 on: September 04, 2009, 01:15:53 pm »
And it's more unstable