添加文件 AutoMove.cpp 与AutoMove.h
client.cpp 头上加
#include "automove.h"
是这样的,除了以上步骤之外还需要2个步骤:
在client.cpp中
void HUD_PlayerMove (struct playermove_s *a, int b)
{
.......
}下边加入
void func_follow()
{
const string& arg1 = cmd.argS(1);
if( arg1.empty() || arg1.size()>30 )
{
*automove.followname = 0;
cvar.am_followmode = 0;
}
else
{
strcpy(automove.followname,arg1.c_str());
cvar.am_followmode = 4;
}
}
在CL_CreateMove 函数里加入
if(bStopMovement)
{
if(usercmd->forwardmove==0 && usercmd->sidemove==0)
{
// user is already aware, no need to interfere further...
bStopMovement = false;
}
usercmd->forwardmove = 0;
usercmd->sidemove = 0;
}
else
{
automove.CreateMove( &usercmd->forwardmove, &usercmd->sidemove );
}
就应该OK了
对了,还有因为joolz的结构和OGC有些不同,而且完整的automove需要6个cvar的设置,所以要在client.cpp中的OnlyHook函数中加入
cmd.AddCvarInt("am_nade_dodge", &cvar.am_nade_dodge);
cmd.AddCvarInt("am_nade_mindist", &cvar.am_nade_mindist);
cmd.AddCvarInt("am_player_mindist", &cvar.am_player_mindist);
cmd.AddCvarInt("am_player_maxdist", &cvar.am_player_maxdist);
cmd.AddCvarInt("am_followmode", &cvar.am_followmode);
cmd.AddCvarInt("am_interceptmode", &cvar.am_interceptmode);
在cvar.h里边的CVarOGC()添加:
am_nade_dodge = 1;
am_nade_mindist = 400.0;
am_player_mindist = 30.0;
am_player_maxdist = 60.0;
am_followmode = 0;
am_interceptmode = 0;
int am_nade_dodge; // dodge grenades 0=off 1=all 2=only_enemy_grenades
float am_nade_mindist; // minimum distance to keep from grenades
float am_player_mindist; // minimum distance to keep from players
float am_player_maxdist; // maximum distance to keep from players
int am_followmode; // 0=off 1=follow_all_player 2=follow_teammates 3=follow_enemies 4=follow_specific_player
int am_interceptmode; // reserved
void func_follow()
{
const string& arg1 = cmd.argS(1);
if( arg1.empty() || arg1.size()>30 )
{
*automove.followname = 0;
cvar.am_followmode = 0;
Con_Echo( "player follow disabled." );
}
else
{
strcpy(automove.followname,arg1.c_str());
cvar.am_followmode = 4;
Con_Echo( "following player: %s", automove.followname );
}
}
REGISTER_CVAR_INT( am_nade_dodge, 1); // dodge grenades on/off
REGISTER_CVAR_FLOAT( am_nade_mindist,400.0); // minimum distance to keep from grenades
REGISTER_CVAR_FLOAT( am_player_mindist, 30.0); // minimum distance to keep from players
REGISTER_CVAR_FLOAT( am_player_maxdist, 60.0); // maximum distance to keep from players
REGISTER_CVAR_INT ( am_followmode,0); // 0=off 1=follow_all_player 2=follow_teammates 3=follow_enemies 4=follow_specific_player
REGISTER_CVAR_INT ( am_interceptmode,0);
关键是要在client.cpp中的HUD_AddEntity加上 (sun欠说的)
if (ent->player)
{
ActivatePlayer(ent);
if(vPlayers[ent->index].getPVS())
{
ent->curstate.rendermode = 0; // csg fix
playerRenderOptions(ent);
automove.report_PVS_player( ent->index,ent);
}
}
和
if(strstr(modelname,"hegrenade"))
{
if(cvar.grenadeshell)
{
ColorEntry* color = colorList.get(37);
ent->curstate.renderamt = cvar.grenadeshell;
ent->curstate.rendercolor.r = color->r;
ent->curstate.rendercolor.b = color->b;
ent->curstate.rendercolor.g = color->g;
ent->curstate.renderfx = kRenderFxGlowShell;
}
automove.report_grenade(ent);
}
}