添加Walkbot 1.6代码
在国外论坛上看到的,挺有意思就转过来了.没有翻译,但是意思应该都能看懂吧.
1. Downloading and Adding files to project.
First download these files: Walkbot 1.6 Source Files
Optinal (recommanded): Add the 'Walkbot.cpp' and the 'Walkbot.h' into your source files foulder of the current project.
open your project and open the files into the project..
2. Including files and Addings codes into 'Client.cpp'
First open your 'Client.cpp'.
at the top with all the Includes add this: 复制内容到剪贴板 代码:#include "walkbot.h"
Search for 复制内容到剪贴板 代码:int HUD_Redraw (float x, int y)
Add this anywhere in it 复制内容到剪贴板 代码:if (cvar.walkbot && wBot.onSwitch) wBot.wBotVisibility();
if (cvar.walkbot_draw) wBot.wBotDraw();
Search for 复制内容到剪贴板 代码:void PreV_CalcRefdef (struct ref_params_s *pparams)
Add this above the cvar.recoil 复制内容到剪贴板 代码:if (cvar.walkbot && wBot.onSwitch) {
if (gAimbot.target == -1) {
if (wBot.target != -1 && wBot.wPoints.size()) {
wBot.wBotAimingSpot[0] = 0.0f;
wBot.wBotAimingSpot[1] -= pparams->punchangle[1];
wBot.wBotAimingSpot[2] = 0.0f;
wBot.wBotCalculateAimingSpot();
VectorCopy(wBot.wBotAimingSpot, pparams->viewangles);
VectorCopy(wBot.wBotAimingSpot, pparams->cl_viewangles);
}
}
}
Search for 复制内容到剪贴板 代码:void PostV_CalcRefdef (struct ref_params_s *pparams)
Add this in it 复制内容到剪贴板 代码:if (cvar.walkbot && wBot.onSwitch && wBot.wPoints.size()) {
if (gAimbot.target == -1) {
if (wBot.target != -1) {
wBot.wBotAimingSpot[0] = 0.0f;
wBot.wBotAimingSpot[1] -= pparams->punchangle[1];
wBot.wBotAimingSpot[2] = 0.0f;
wBot.wBotCalculateAimingSpot();
}
}
}
Search for 复制内容到剪贴板 代码:void CL_CreateMove (float frametime, struct usercmd_s *usercmd, int active)
Add this in it 复制内容到剪贴板 代码:if (cvar.walkbot && wBot.onSwitch) {
if (gAimbot.target == -1) {
if (wBot.target != -1) {
VectorCopy (wBot.wBotAimingSpot, usercmd->viewangles);
gEngfuncs.SetViewAngles (wBot.wBotAimingSpot);
if (cvar.walkbot_auto) {
usercmd->forwardmove = 999;
if (!cvar.nospeed)
cvar.speed = cvar.walkbot_speed;
}
}
}
}
Search for 复制内容到剪贴板 代码:void AtRoundStart(void)
Add this in it 复制内容到剪贴板 代码:wBot.onSwitch = true;
wBot.target = -1;
wBot.oldtarget = -1;
for (int i=0;i<wBot.wPoints.size();i++) {
wBot.wPoints.hasBeenUsed = false;
}
Search for 复制内容到剪贴板 代码:void Init_Command_Interpreter()
Add this in it 复制内容到剪贴板 代码:REGISTER_COMMAND(wbot_save)
REGISTER_COMMAND(wbot_list)
REGISTER_COMMAND(wbot_add)
REGISTER_COMMAND(wbot_adjust)
REGISTER_COMMAND(wbot_clear )
REGISTER_COMMAND(wbot_remove)
Add this anywhere in the 'Client.cpp' 复制内容到剪贴板 代码:void func_wbot_save() {
char filepath[512];
sprintf(filepath,"%s\\Waypoints\\TempWaypointSave.cfg",ogcdir);
if (wBot.wPoints.size()) {
ofstream file;
file.open(filepath);
if (file.is_open()) {
file << "// Author: " << me.name << endl;
if (me.team == 1)
file << "// Team: Terrorists" << endl;
else if (me.team == 2)
file << "// Team: Counter-Terrorists" << endl;
file << "// Map: Unkecoo168n" << endl;
file << "// Path: " << endl;
file << "wbot_clear" << endl;
file << "walkbot 1" << endl;
file << "walkbot_auto " << cvar.walkbot_auto << endl;
file << "walkbot_radius " << cvar.walkbot_radius << endl;
file << endl;
for (int i=0;i < wBot.wPoints.size();i++) {
file << "wbot_add " << (int)wBot.wPoints.origin[0] << " " << (int)wBot.wPoints.origin[1] << " " << (int)wBot.wPoints.origin[2] << endl;
}
file.close();
Con_Echo("&wWaypoints saved (Waypoints/TempWaypointSave.cfg)");
}
else {
Con_Echo("&wERROR: Unable to open file.&a");
}
}
else
Con_Echo("&wERROR: No waypoints loaded.&a");
}
void func_wbot_load() {
char temp[64];
sprintf(temp,"\\Waypoints\\%s.cfg",cmd.argS(1));
ogc_exec(temp);
}
void func_wbot_list() {
if (wBot.wPoints.size()) {
for (int i = 0;i < wBot.wPoints.size();i++) {
Con_Echo("ID: &w%i&a X: &w%f&a Y: &w%f&a Z: &w%f&a\n", i, wBot.wPoints.origin[0], wBot.wPoints.origin[1], wBot.wPoints.origin[2]);
}
}
else
Con_Echo("&wNo waypoints loaded.&a");
}
void func_wbot_add() {
if (cmd.argF(1)) {
vec3_t wTemp;
wTemp[0] = cmd.argF(1);
wTemp[1] = cmd.argF(2);
wTemp[2] = cmd.argF(3);
wBot.addWaypoint(wTemp);
}
else {
wBot.addWaypoint(me.ent->origin);
Con_Echo("&wWaypoint added.&a\n");
}
}
void func_wbot_adjust() {
wBot.adjustWaypoint(cmd.argI(1),cmd.argF(2),cmd.argF(3),cmd.argF(4));
Con_Echo("&Waypoint succesfully edited.&a\n",cmd.argI(1));
}
void func_wbot_clear() {
wBot.clearWaypoints();
Con_Echo("&wWaypoints cleared.&a\n");
}
void func_wbot_remove() {
wBot.removeWaypoint(cmd.argI(1));
Con_Echo("&w%i succesfully removed.&a\n",cmd.argI(1));
}
3. Including files and Adding code into 'Opengl.cpp'
At top with includes add 复制内容到剪贴板 代码:#include "walkbot.h"
Search for 复制内容到剪贴板 代码:void APIENTRY pglViewport( GLint x,GLint y,GLsizei width,GLsizei height)
Add this in it 复制内容到剪贴板 代码:if (me.alive) {
if (cvar.walkbot && wBot.onSwitch)
wBot.wBotSelectWaypoint();
else {
wBot.target = -1;
wBot.onSwitch = false;
}
}
3. Registering CVARS
First open your 'Cvar.cpp' and add this in the Int's 复制内容到剪贴板 代码:REGISTER_CVAR_INT(walkbot ,0)
REGISTER_CVAR_INT(walkbot_draw, 0)
REGISTER_CVAR_INT(walkbot_radius, 50)
REGISTER_CVAR_INT(walkbot_auto, 0)
Open your 'Cvar.h' and add this in the Int's 复制内容到剪贴板 代码:int walkbot;
int walkbot_draw;
int walkbot_auto;
int walkbot_radius;
Ok ecoo168 you added Walkbot v1.6 into your source
This is the console commands
wbot_add (Adding a waypoint )
wbot_save (Saving current bot path )
wbot_list (List the current bot path )
walkbot (1=on||0=off)
walkbot_draw (1=on||0=off)
Add this in menu if u want 复制内容到剪贴板 代码:" " "> Walkbot 1.6" {
" " "- Add waypoint" "wbot_add"
" " "- Save current path" "wbot_save"
" " "Walkbot ON" "wbot_add;#wait;walkbot 1;walkbot_auto 1;walkbot_draw 1"
" " "Walkbot OFF" "walkbot 0;walkbot_auto 0;walkbot_draw 0"
}
Add errors if u get.. Then you will get help as fast as possible