连续扔雷的代码实现
void HeFire(float frametime, struct usercmd_s *usercmd, int active)
{
static int hegrenade_fire=0;
static int he_buy=0;
static int has_hegrenade=0;
if( !he_fire )return;
// hegrenade auto buy
if( !has_hegrenade && playerItems.money >= 300 && he_buy==0)
{
he_buy=1;
gEngfuncs.pfnClientCmd("buyequip");
}
if( he_buy )
{
he_buy++;
if(he_buy>he_buy_wait)
{
gEngfuncs.pfnClientCmd("menuselect 4");
has_hegrenade=1;
he_buy=0;
}
}
// hegrenade auto select
if( has_hegrenade && currentWeaponID != WEAPON_HE )
{
gEngfuncs.pfnClientCmd("slot4");
}
// hegrenade auto through out
if( currentWeaponID == WEAPON_HE && !hegrenade_fire)
{
usercmd->buttons |= IN_ATTACK;
hegrenade_fire=1;
}
if( hegrenade_fire )
{
hegrenade_fire++;
if( hegrenade_fire>2 )
{
usercmd->buttons &= ~IN_ATTACK;
hegrenade_fire=0;
has_hegrenade=0;
}
}
}
---------------------------------------------------------------------