如何实现全菜单专杀设置
将压缩包中的Player.h Player.cpp加入工程文件
在cvar.h 中加入:
int player_x;
int player_y;
int player_w;
int firstkill;
在cvar.cpp中加入
REGISTER_CVAR_INT( player_x ,290)
REGISTER_CVAR_INT( player_y ,55)
REGISTER_CVAR_INT( player_w ,380)
REGISTER_CVAR_INT( firstkill ,1)
修改client.cpp
在前面加入
#include "Player.h"
查找int HUD_Redraw (float x, int y),在函数中加入
if (player_active) { drawPlayer (); }
查找int HUD_Key_Event( int eventcode, int keynum, const char *pszCurrentBinding )
在函数中最后的return( retval );之前加入:
if( gPlayerActive() && (keynum >= 239 && keynum <= 245))
查找void Init_Command_Interpreter(),在函数中加入
REGISTER_COMMAND(first_kill_mode)
REGISTER_COMMAND(addplayer)
REGISTER_COMMAND(relistplayer)
REGISTER_COMMAND(clearallplayer)
REGISTER_COMMAND(selectallplayer)
REGISTER_COMMAND(player_list)
REGISTER_COMMAND(player_select)
REGISTER_COMMAND(player_back)
REGISTER_COMMAND(player_off)
REGISTER_COMMAND(player_up)
REGISTER_COMMAND(player_down)
查找USER_MSG_INTERCEPT(DeathMsg)
确保如下语句必被执行:
vPlayers[victim].setAlive(false);
查找USER_MSG_INTERCEPT(ScoreAttrib)
确保如下语句必被执行:
if(info&1) { vPlayers[idx].setAlive(false); vPlayers[idx].clearPVS(); }
else { vPlayers[idx].setAlive();}
查找void ActivatePlayer(struct cl_entity_s *ent)
确保如下语句必被执行:
if(ent->curstate.solid) { vPlayers[px].setAlive(); }
修改bind.cpp
查找void func_menu_down ();在其下方加入:
void func_player_select();
void func_player_back ();
void func_player_up ();
void func_player_down ();
查找bool KeyBindManager::keyBlocked(const char* name),将其改为:
bool KeyBindManager::keyBlocked(const char* name)
{
bool block = myBind.find(name);
return block||gMenuActive()||gPlayerActive();
}
查找void KeyBindManager::notifyMouseEvent(char* name,bool down)
在函数中加入:
if(gPlayerActive())
{
if(!strcmp(name,"mouse1" )) { if(down)func_player_select(); return; } else
if(!strcmp(name,"mouse2" )) { if(down)func_player_back (); return; } else
if(!strcmp(name,"mwheelup" )) { if(down)func_player_up (); return; } else
if(!strcmp(name,"mwheeldown" )) { if(down)func_player_down (); return; }
}
专杀菜单修改完毕。可以编译了,如果有错,大部分问题都是出在函数或变量声名上,自己改改好了。
现在:
专杀模式cvar.firstkill 有4个值切换 0 1 2 3 , 你可以自己在程序中增加关于处理不同专杀模式的代码
可以对每个敌人进行3种设置: ogcPlayer.FirstKillPlayer[ax]=0、1、2,你可以自己在程序中增加处理优先的代码
最后别忘了,在.cfg文件中加入:
bind "home" "player_list"