Talk:MERVBot Tutorial

From ASSS Wiki
Revision as of 15:34, 21 February 2005 by 50% Packetloss (talk | contribs) (Make bot spectate specific coordinates Section)
Jump to: navigation, search

General Convo

D1s: Anybody wanna format this int a table of contents? I'm lazy

Smong: That is sick. Maybe split into more pages? Says it is over 160k.

Pests: There is already pages defined. You could just split them up into that.

OK, I'm working on converting it to real HTML (using <pre>) instead of the &nbsp; crap. --Cyan~Fire

CypherJF: Should we just call this "the bot tutorial" based on the tutorial by Underlord? Then update it accordingly? -- And also, the link to MervBot w/e 37 is now 45; should we just comment that this tutorial was writen for the 37 -- or... comments! lol.

CypherJF: I'd like to say that all sections appear to have been updated for the Wiki; time to go through edit, and catch mistakes. Add to the wiki itself - perhaps more example code.

CypherJF: Cyan and I were talking about the section "Checking if pilot is in a safe zone"; whether or not to just remove it. I remarked that it's a nice section for those to the whole plugin deal. But, I was just noticing how it'd make more sense to put the "Useful Player data" before hand... So i guess the next step is to go through and try to address the logical-aspect of ordering of the content? What's your guys' take?

Smong: Uh yeah.. so why are there so many major edits to just one page? I can't see anything in recent changes but edits to the mervbot tutorial.

CypherJF: See my other notes: "CypherJF: Well I've been doing the edits from all around campus. Like yesterday I did 4-6 things from the MathLab; and the rest from the dorm, etc. lol. I don't think it really matters, since there isn't much other activity going on.. on the wiki." So, I'd make edits and just post em. It happened to be the only activity and sooo it looks worse than it is.

sscanf

Well, I'm using sscanf() for parsing player input. Yes, an advanced function, but maybe it will discourage C++ newbs from making bot plugins. Any comments? --Cyan~Fire

D1st0rt: Cool beans. I learned something new :D

Event list

Removed event list because it was redundant with dllcore.h, less descriptive, and too easy to get out-of-date. Anybody who wants it back, please post here so I can ignore you. :-D --Cyan~Fire

CypherJF: Like people are really going to read through the dllcore.h file.. on a webpage tutorial. hmm i think not. I still say keep it there.

If someone doesn't make the effort to look up events in dllcore.h, they shouldn't be making plugins. I think of this tutorial as more of a "here are the basics and intricacies of making a MERVBot plugin" more than "here is how to follow step-by-step instructions and call it programming". --Cyan~Fire

D1s: Even I look up things in dllcore.h, its a very useful resource. As long as it says to look in it, I don't think we'd need the full list here

Extra Code Samples

CypherJF: I'd like to somehow split these up better; and make them linkable, what do you guy's think?

CypherJF: I made sub-headers, and so they'll be added into the table of contents. Let me know what you guys think of it.

Alrighty, looks good. One thing I would ask is to try to save up a bunch of edits in a text editor or something, than have the myriad edits you do now. Thanks for sharing the burden with me! --Cyan~Fire

CypherJF: Well I've been doing the edits from all around campus. Like yesterday I did 4-6 things from the MathLab; and the rest from the dorm, etc. lol. I don't think it really matters, since there isn't much other activity going on.. on the wiki.

Oh, OK, that's fine. Also, do remember that the wiki will automatically do your <p>ing for you as long as you leave a blank line in-between "paragraphs". --Cyan~Fire

old toc

Please leave this here for now. --Cyan~Fire

Setup a MERVBot bot and project in visual c++
0) <a href="#0">Setting up a MERVBot bot</a>

Command.cpp
 1) <a href="#1">Player commands</a> (!play, !squadA vs squadB)

Spawn.cpp
 2) <a href="#2">Event descriptions</a> (describe events in spawn.cpp)
 2) <a href="#2">Messaging </a>("*arena hi", ":player:*scorereset)
 3) <a href="#3">MervBot Timer</a> (do this in 10 seconds)(countdown[n])
 4) <a href="#4">Writing Functions</a> (bool IsInCenter(Player *p))

Useful operations
 6) <a href="#6">Cycling players</a>
 7) <a href="#7">Check if pilot is in safe zone</a>
 8) <a href="#8">Random numbers</a>
 9) <a href="#9">Time without using countdown[n]</a>
10) <a href="#10">Storing data for pilots</a>
11) <a href="#11">Output data in messages</a>
12) <a href="#12">Input/Output to files</a>
13) <a href="#13">Programming commands</a>
14) <a href="#14">Useful player data</a>
15) <a href="#15">Bot built in functions</a>

Example Code

a) <a href="#15a">No antiwarp in center of map</a>
b) <a href="#15b">Setting freq size depending on how many pilots in game</a>
c) <a href="#15c">Tracking kills and announcing when pilot gets 10 kills in a row without dying </a>
d) <a href="#15d">Warp pilot to coord when they are in a certain region</a>
e) <a href="#15e">Structures within structures</a>
f) <a href="#15f">Tracking flag data</a>
g) <a href="#15g">Way to do simple /!spam feature</a>
h) <a href="#15h">Implementing a simple stack to do "next in line for several 'boxes' at once"</a>
i) <a href="#15i">Reading any text from a .txt and printing it to pilot line by line</a>
j) <a href="#15j">Example of printing player stats grid</a>
k) <a href="#15k">Example of checking if any pilots are within a region</a>
l) <a href="#15l">Example of functions to get a pilot's struct id info from a name or *player info</a>
m) <a href="#15m">Example of creating a logfile name using date and squad names</a>
n) <a href="#15n">Sending messages to playing freqs or public and logging depending on status</a>
o) <a href="#15o">Example of reading in all player/freqs to struct data</a>
p) <a href="#15p">Example of finding MVP from struct data</a>
q) <a href="#15q">Print time stamp of event</a>
r) <a href="#15r">Simple way to track player bomb/bullet damage stats</a>
s) <a href="#15s">Simple way to print those stats</a>
t) <a href="#15t">Make bot spectate specific coordinates</a>

Example Code commenting system

What's the use of it? --Cyan~Fire

Smong: So if people don't understand the examples they can request help or a clarification. Also people that do understand an example might want to post a better/alternative solution. I suppose since you need an account to edit a page, maybe the wiki can be setup so you don't need an account to edit the discussion page so people can put comments in there.

I think I wasn't being very clear, Cypher didn't understand me either. I was talking about his <!-- EXAMPLE A: BEGIN--> stuff. Anyway, I've gotten permission from him to remove it, it was only supposed to be temporary. The idea of anonymous talk posts is a good idea, but I'm not sure if its possible. --Cyan~Fire

Make bot spectate specific coordinates Section

--50% Packetloss 14:34, Feb 21, 2005 (EST)

This is what is currently there.

tell(makeFollowing(false));
tell(makeFlying(true));
me->move(512 * 16, 600 * 16);
tell(makeSendPosition(true));

Now when you tell the bot tell(makeFlying(true)); the core makes DLLFlying= true; Thus in the core's function void Host::doEvents() instead of the bot sending position packets, the job is left to the dll.

//...
if (DLLFlying)
{
	Uint32 limit = settings.SendPositionDelay;

	if (time - lastPosition > limit)
	{
		imports->talk(makePositionHook());
	}
}
else if (Me->ship == SHIP_Spectator)
{	// Spectating
	Uint32 limit = settings.SendPositionDelay;

	if (time - lastPosition > limit)
	{
		// Cycle player spectated
		if (Me->ship == SHIP_Spectator)
			spectateNext();

			sendPosition(false);
	}
}
else if //...

So in the dll, in the positionhook event, you need to add tell(sendPosition(false));. Im not sure if it will have a dramatic effect if the bot is in spec (never tested it), but if the bot is in a ship it will disappear from the screen. I don't know a lot about this wiki stuff so Ill leave it up to you ladies to edit.