Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controllable dummies #11

Open
Henningstone opened this issue Mar 29, 2018 · 0 comments
Open

Controllable dummies #11

Henningstone opened this issue Mar 29, 2018 · 0 comments
Labels

Comments

@Henningstone
Copy link
Owner

Make it possible for gametypes to add dummies to the server that can then be controlled through a handle. This is meant to provide a simple interface to hide away all the input logic in cases where it's not needed. The standard way of setting manipulating the dummy's input struct will of course still be available for granular bot development.

In order to correspond with master server rules, dummies on the server will not increase the player count in the server list, but instead decrease the number of slots available on the server. The server browser's scoreboard will group together all the bots into a single element at the top, just displaying SPEC < 5 bots > to inform potential new players that there are server sided bots on this server.

A call to Srv.Server:AddDummy(string Name, string ) will return a CPlayerDummy pointer. The CPlayerDummy class inherits from CPlayer and adds additional methods for easy dummy control.
These methods should include:

  • WalkTowards(vec2 *Point) makes the dummy go towards the given point. There will no checks be done if the point can actually be reached, that's up to the scripter. If the dummy does actually reach the point, it will do it's best to stay there until instructed differently. Call with nil as the argument to stop moving.
  • JumpIf( { function Eval(CCharacter DummyChr) *} ) The given function is evaluated every tick if a destination point has been set using WalkTowards. If the given function returns true, the dummy will jump. this and self are valid for the concerned dummy object.
  • TargetPlayer(CPlayer *Player [, int AccDev]) will make the dummy target this player (i.e. aim at him) with the given accuracy deviation. 0 means aiming perfectly on the tee, higher values set a margin for randomization. Default is 0. Pass nil as the first argument to unset the target.
  • Attack() makes the dummy attack the set target if it is in range of the dummy's current weapon. (This method only instructs it to shoot, no positional change will be performed in order to be able to hit the target). The dummy will keep on attacking until Peaceful() is called. If there is no target set, this function does nothing.
  • AttackIf( { function Eval *} ) The given function is evaluated every tick after Attack() has been called. If Eval does not return true, the dummy will ignore that he's supposed to attack for the current tick. Call AttackIf with nil as an argument to unset the callback, which will make the dummy always attack. this and self are valid for the concerned dummy object.
  • Peaceful() stops the dummy from attacking (but does not unset the target)

Possible events emitted by dummies include:

  • OnTargetReached(vec2 Point) called when the dummy first gets closer than 32 to the point specified with WalkTowards. The point is passed as an argument; this and self are valid for the concerned dummy object.

// TODO: amend these lists with whatever comes to mind


A note about uncommon semantics used in this document:

  • (1) An asterisk (*) to the left of an argument means that this argument can be nil.
  • (2) Curly brackets ({}) around an argument mean, that this argument has to be an an array (i.e. a consecutively numerical indexed table) of elements of the denoted type.
  • (3) An asterisk to the left of the closing bracket in (2) denotes, that you can pass a table, but also just a single element of the given type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant