Beispiel #1
0
int CallPriceForwardCSGO(int client, const char *weapon)
{
	const char *weaponalias = GetTranslatedWeaponAlias(weapon);
	int weaponID = AliasToWeaponID(weaponalias);
	if (weaponID <= 0)
	{
		return -1;
	}
	void *info = GetWeaponInfo(weaponID);
	if (!info)
	{
		return -1;
	}
	const char *weapon_name = (const char *)((intptr_t)info + weaponNameOffset);
	int price = *(int *)((intptr_t)info + g_iPriceOffset);
	int changedprice = price;
	cell_t result = Pl_Continue;

	g_pPriceForward->PushCell(client);
	g_pPriceForward->PushString(weapon_name);
	g_pPriceForward->PushCellByRef(&changedprice);
	g_pPriceForward->Execute(&result);
		
	if (result == Pl_Continue)
		return -1;
	if (SetWeaponPrice(weaponID, changedprice))
		return price;
	else
		return -1;
}
Beispiel #2
0
bool SetWeaponPrice(const char *weapon, int price)
{
	const char *weaponalias = GetTranslatedWeaponAlias(weapon);
	int weaponID = AliasToWeaponID(weaponalias);
	if (weaponID <= 0)
	{
		return false;
	}
	void *info = GetWeaponInfo(weaponID);
	if (!info)
	{
		return false;
	}
	*(int *)((intptr_t)info+g_iPriceOffset) = price;
	return true;

}
/**
 *  Debug command to give a named weapon
 */
void CCSBot::GiveWeapon( const char *weaponAlias )
{
	const char *translatedAlias = GetTranslatedWeaponAlias( weaponAlias );

	char wpnName[128];
	Q_snprintf( wpnName, sizeof( wpnName ), "weapon_%s", translatedAlias );
	WEAPON_FILE_INFO_HANDLE	hWpnInfo = LookupWeaponInfoSlot( wpnName );
	if ( hWpnInfo == GetInvalidWeaponInfoHandle() )
	{
		return;
	}

	CCSWeaponInfo *pWeaponInfo = dynamic_cast< CCSWeaponInfo* >( GetFileWeaponInfoFromHandle( hWpnInfo ) );
	if ( !pWeaponInfo )
	{
		return;
	}

	if ( !Weapon_OwnsThisType( wpnName ) )
	{
		CBaseCombatWeapon *pWeapon = Weapon_GetSlot( pWeaponInfo->iSlot );
		if ( pWeapon )
		{
			if ( pWeaponInfo->iSlot == WEAPON_SLOT_PISTOL )
			{
				DropPistol();
			}
			else if ( pWeaponInfo->iSlot == WEAPON_SLOT_RIFLE )
			{
				DropRifle();
			}
		}
	}

	GiveNamedItem( wpnName );
}
Beispiel #4
0
//--------------------------------------------------------------------------------------------------------------
// Takes the bot pointer and constructs the net name using the current bot name prefix.
void UTIL_ConstructBotNetName( char *name, int nameLength, const BotProfile *profile )
{
	if (profile == NULL)
	{
		name[0] = 0;
		return;
	}

	// if there is no bot prefix just use the profile name.
	if ((cv_bot_prefix.GetString() == NULL) || (strlen(cv_bot_prefix.GetString()) == 0))
	{
		Q_strncpy( name, profile->GetName(), nameLength );
		return;
	}

	// find the highest difficulty
	const char *diffStr = BotDifficultyName[0];
	for ( int i=BOT_EXPERT; i>0; --i )
	{
		if ( profile->IsDifficulty( (BotDifficultyType)i ) )
		{
			diffStr = BotDifficultyName[i];
			break;
		}
	}

	const char *weaponStr = NULL;
	if ( profile->GetWeaponPreferenceCount() )
	{
		weaponStr = profile->GetWeaponPreferenceAsString( 0 );

		const char *translatedAlias = GetTranslatedWeaponAlias( weaponStr );

		char wpnName[128];
		Q_snprintf( wpnName, sizeof( wpnName ), "weapon_%s", translatedAlias );
		WEAPON_FILE_INFO_HANDLE	hWpnInfo = LookupWeaponInfoSlot( wpnName );
		if ( hWpnInfo != GetInvalidWeaponInfoHandle() )
		{
			CCFWeaponInfo *pWeaponInfo = dynamic_cast< CCFWeaponInfo* >( GetFileWeaponInfoFromHandle( hWpnInfo ) );
			if ( pWeaponInfo )
			{
				weapontype_t weaponType = pWeaponInfo->m_eWeaponType;
				weaponStr = CCFWeaponInfo::WeaponTypeToString( weaponType );
			}
		}
	}
	if ( !weaponStr )
	{
		weaponStr = "";
	}

	char skillStr[16];
	Q_snprintf( skillStr, sizeof( skillStr ), "%.0f", profile->GetSkill()*100 );

	char temp[MAX_PLAYER_NAME_LENGTH*2];
	char prefix[MAX_PLAYER_NAME_LENGTH*2];
	Q_strncpy( temp, cv_bot_prefix.GetString(), sizeof( temp ) );
	Q_StrSubst( temp, "<difficulty>", diffStr, prefix, sizeof( prefix ) );
	Q_StrSubst( prefix, "<weaponclass>", weaponStr, temp, sizeof( temp ) );
	Q_StrSubst( temp, "<skill>", skillStr, prefix, sizeof( prefix ) );
	Q_snprintf( name, nameLength, "%s %s", prefix, profile->GetName() );
}