Буду говорить прямо: создаём на сервере файл weapon_hmg1.cpp и пишем туда этот код: //========= Copyright © 2007, Valve LLC, OlegS, All rights reserved. ============ // // Purpose: Экскулюзив для detler.ucoz.ru // //============================================================================= #include "cbase.h" #include "basehlcombatweapon.h" #include "NPCevent.h" #include "basecombatcharacter.h" #include "AI_BaseNPC.h" #include "player.h" #include "game.h" #include "in_buttons.h" class CWeaponSMG2 : public CHLSelectFireMachineGun { public: DECLARE_CLASS( CWeaponSMG2, CHLSelectFireMachineGun ); CWeaponSMG2(); DECLARE_SERVERCLASS(); const Vector &GetBulletSpread( void ); void Precache( void ); void AddViewKick( void ); void Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombatCharacter *pOperator ); float GetFireRate( void ) { return 0.1f; } int CapabilitiesGet( void ) { return bits_CAP_WEAPON_RANGE_ATTACK1; } DECLARE_ACTTABLE(); }; IMPLEMENT_SERVERCLASS_ST(CWeaponSMG2, DT_WeaponSMG2) END_SEND_TABLE() LINK_ENTITY_TO_CLASS( weapon_smg2, CWeaponSMG2 ); PRECACHE_WEAPON_REGISTER(weapon_smg2); acttable_t CWeaponSMG2::m_acttable[] = { { ACT_RANGE_ATTACK1, ACT_RANGE_ATTACK_SMG2, true }, }; IMPLEMENT_ACTTABLE(CWeaponSMG2); //========================================================= CWeaponSMG2::CWeaponSMG2( ) { m_fMaxRange1 = 2000; m_fMinRange1 = 32; m_iFireMode = FIREMODE_3RNDBURST; } void CWeaponSMG2::Precache( void ) { BaseClass::Precache(); } //----------------------------------------------------------------------------- // Purpose: // Output : const Vector //----------------------------------------------------------------------------- const Vector &CWeaponSMG2::GetBulletSpread( void ) { static const Vector cone = VECTOR_CONE_10DEGREES; return cone; } //----------------------------------------------------------------------------- // Purpose: // Input : *pEvent - // *pOperator - //----------------------------------------------------------------------------- void CWeaponSMG2::Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombatCharacter *pOperator ) { switch( pEvent->event ) { case EVENT_WEAPON_SMG2: { Vector vecShootOrigin, vecShootDir; vecShootOrigin = pOperator->Weapon_ShootPosition( ); CAI_BaseNPC *npc = pOperator->MyNPCPointer(); ASSERT( npc != NULL ); vecShootDir = npc->GetActualShootTrajectory( vecShootOrigin ); WeaponSound(SINGLE_NPC); pOperator->FireBullets( 1, vecShootOrigin, vecShootDir, VECTOR_CONE_PRECALCULATED, MAX_TRACE_LENGTH, m_iPrimaryAmmoType, 2 ); m_iClip1 = m_iClip1 - 1; } break; default: BaseClass::Operator_HandleAnimEvent( pEvent, pOperator ); break; } } //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponSMG2::AddViewKick( void ) { #define EASY_DAMPEN 0.5f #define MAX_VERTICAL_KICK 2.0f //Degrees #define SLIDE_LIMIT 1.0f //Seconds //Get the view kick CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); if (!pPlayer) return; DoMachineGunKick( pPlayer, EASY_DAMPEN, MAX_VERTICAL_KICK, m_fFireDuration, SLIDE_LIMIT ); } Теперь лезем на клиент и открываем файл c_weapon__stubs.cpp и пишем после строки STUB_WEAPON_CLASS( weapon_smg1, WeaponSMG1, C_HLSelectFireMachineGun ); пишем эту строку STUB_WEAPON_CLASS( weapon_hmg1, WeaponHMG1, C_HLSelectFireMachineGun ); Все, скомпилили? Это еще не все. Теперь пишем скрипт для нашего оружия. Итак, лезем в %ПАПКУ_С_МОДОМ\scripts и создаём файл weapon_hmg1.txt. Я использую такой текст скрипта, вы можете его изменить по своему вкусу: // Хиви мэчин Ган 1 WeaponData { // Weapon data is loaded by both the Game and Client DLLs. "printname" "HMG1" "viewmodel" "models/weapons/v_hmg.mdl" \\Модель из тутора "playermodel" "models/weapons/w_hmg1.mdl" \\Модель из тутора "anim_prefix" "ar2" "bucket" "2" "bucket_position" "3" "clip_size" "30" "default_clip" "30" "clip2_size" "-1" "default_clip2" "-1" "primary_ammo" "AR2" "secondary_ammo" "none" "weight" "5" "item_flags" "0" // Тут мы прописываем звуки. Как их сделать? Читай дальше. SoundData { "single_shot" "Weapon_HMG1.Single" "single_shot_npc" "Weapon_HMG1.NPC_Single" "burst" "Weapon_HMG1.Burst" } // Weapon Sprite data is loaded by the Client DLL. TextureData { "weapon" { "font" "WeaponIcons" "character" "l" } "weapon_s" { "font" "WeaponIconsSelected" "character" "l" } "ammo" { "font" "WeaponIcons" "character" "u" } "ammo2" { "font" "WeaponIcons" "character" "z" } "crosshair" { "font" "Crosshairs" "character" "Q" } "autoaim" { "file" "sprites/crosshairs" "x" "0" "y" "48" "width" "24" "height" "24" } } } Теперь создадим звуки. Я объясню, как их добавлять на примере звука выстрела. Для добавления звуков оружия нам нужен файл game_sounds_weapons.txt "Weapon_HMG1.Single" { "channel" "CHAN_WEAPON" "volume" "1.0" "soundlevel" "SNDLVL_GUNFIRE" "rndwave" { "wave" "weapons/hmg1_7.wav" "wave" "weapons/hmg1_8.wav" "wave" "weapons/hmg1_9.wav" } } "Weapon_HMG1.NPC_Single" { "channel" "CHAN_WEAPON" "volume" "1.0" "soundlevel" "SNDLVL_GUNFIRE" "rndwave" { "wave" "weapons/hmg1_7.wav" "wave" "weapons/hmg1_8.wav" "wave" "weapons/hmg1_9.wav" } } "Weapon_HMG1.Burst" { "channel" "CHAN_WEAPON" "volume" "1.0" "soundlevel" "SNDLVL_GUNFIRE" "wave" "weapons/hmg1_3rounds_3.wav" } Модели и звуки к туториалу
|