Суббота, 25.11.2017, 04:37
Приветствую Вас Guest | RSS
Главная страница | Статьи | Регистрация | Вход
Меню сайта

Случайный рисунок

Категории каталога
Туториалы по маппингу (HL2) [68]
Туториалы по маппингу для Half-Life
Туториалы по текстурированию (HL2) [10]
Туторы по текстурированию для Half-Life
Туториалы по моделированию (HL2) [9]
Туторы по моделированию для Half-Life
Туториалы по программированию (HL2) [53]
Туторы по прагроммированию для Half-life
Другие туториалы (HL1 и HL2) [4]
Туторы которые не вошли в другие категории
Half-Life 2 Beta [1]
Статьи о npc и weapon в бете Half-Life 2, а так же мануалы и FAQ.
Туториалы по маппингу (HL1) [14]
Туторы по маппингу для Half-Life 1
Туториалы по текстурированию (HL1) [1]
Туторы по текстурированию для Half-Life 1
Туториалы по моделированию (HL1) [1]
Туторы по моделированию для Half-Life 1
Туториалы по программированию (HL1) [30]
Туторы по программированию для Half-Life 1

Наш опрос
Приводить ли сайт в чувство?
Всего ответов: 702

Начало » Статьи » Туториалы по программированию (HL2)

FlareGun
FlareGun - сигнальный пистолетик из беты. Поехали делать, в этот раз в проект ничего добовлять ненадо, просто откройте этот файл (src\dlls\hl2_dll\weapon_flaregun.cpp) и впешите в него следующий код:

//========= Copyright © 1996-2001, Valve LLC, All rights reserved. ============
//
// Purpose: Flare gun (fffsssssssssss!!)
//
// $NoKeywords: $
//=============================================================================

#include "cbase.h"
#include "player.h"
#include "gamerules.h"
#include "basehlcombatweapon.h"
#include "decals.h"
#include "soundenvelope.h"
#include "IEffects.h"
#include "engine/IEngineSound.h"
#include "weapon_flaregun.h"

#define FLARE_LAUNCH_SPEED 1500

LINK_ENTITY_TO_CLASS( env_flare, CFlare );

BEGIN_DATADESC( CFlare )

DEFINE_FIELD( m_pOwner, FIELD_CLASSPTR ),
DEFINE_FIELD( m_nBounces, FIELD_INTEGER ),
DEFINE_FIELD( m_flTimeBurnOut, FIELD_TIME ),
DEFINE_KEYFIELD( m_flScale, FIELD_FLOAT, "scale" ),
DEFINE_KEYFIELD( m_flDuration, FIELD_FLOAT, "duration" ),
DEFINE_FIELD( m_flNextDamage, FIELD_TIME ),
DEFINE_SOUNDPATCH( m_pBurnSound ),
DEFINE_FIELD( m_bFading, FIELD_BOOLEAN ),
DEFINE_FIELD( m_bLight, FIELD_BOOLEAN ),
DEFINE_FIELD( m_bSmoke, FIELD_BOOLEAN ),

//Input functions
DEFINE_INPUTFUNC( FIELD_FLOAT, "Start", InputStart ),
DEFINE_INPUTFUNC( FIELD_FLOAT, "Die", InputDie ),
DEFINE_INPUTFUNC( FIELD_VOID, "Launch", InputLaunch),

// Function Pointers
DEFINE_FUNCTION( FlareTouch ),
DEFINE_FUNCTION( FlareBurnTouch ),
DEFINE_FUNCTION( FlareThink ),

END_DATADESC()

//Data-tables
IMPLEMENT_SERVERCLASS_ST( CFlare, DT_Flare )
SendPropFloat( SENDINFO( m_flTimeBurnOut ), 0, SPROP_NOSCALE ),
SendPropFloat( SENDINFO( m_flScale ), 0, SPROP_NOSCALE ),
SendPropInt( SENDINFO( m_bLight ), 1, SPROP_UNSIGNED ),
SendPropInt( SENDINFO( m_bSmoke ), 1, SPROP_UNSIGNED ),
END_SEND_TABLE()

CFlare *CFlare::activeFlares = NULL;

CFlare *CFlare::GetActiveFlares( void )
{
return CFlare::activeFlares;
}

Class_T CFlare::Classify( void )
{
return CLASS_FLARE;
}

CBaseEntity *CreateFlare( Vector vOrigin, QAngle Angles, CBaseEntity *pOwner, float flDuration )
{
CFlare *pFlare = CFlare::Create( vOrigin, Angles, pOwner, flDuration );

if ( pFlare )
{
pFlare->m_bPropFlare = true;
}

return pFlare;
}

void KillFlare( CBaseEntity *pOwnerEntity, CBaseEntity *pEntity, float flKillTime )
{
CFlare *pFlare = dynamic_cast< CFlare *>( pEntity );

if ( pFlare )
{
float flDieTime = (pFlare->m_flTimeBurnOut - gpGlobals->curtime) - flKillTime;

if ( flDieTime > 1.0f )
{
pFlare->Die( flDieTime );
pOwnerEntity->SetNextThink( gpGlobals->curtime + flDieTime + 3.0f );
}
}
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CFlare::CFlare( void )
{
m_flScale = 1.0f;
m_nBounces = 0;
m_bFading = false;
m_bLight = true;
m_bSmoke = true;
m_flNextDamage = gpGlobals->curtime;
m_lifeState = LIFE_ALIVE;
m_iHealth = 100;
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CFlare::Precache( void )
{
engine->PrecacheModel("models/weapons/flare.mdl" );

// FIXME: needed to precache the fire model. Shouldn't have to do this.
UTIL_PrecacheOther( "_firesmoke" );

enginesound->PrecacheSound("weapons/flaregun/burn.wav");
}

//-----------------------------------------------------------------------------
// Purpose:
// Input : &restore -
// Output : int
//-----------------------------------------------------------------------------
int CFlare::Restore( IRestore &restore )
{
int result = BaseClass::Restore( restore );

if ( m_spawnflags & SF_FLARE_NO_DLIGHT )
{
m_bLight = false;
}

if ( m_spawnflags & SF_FLARE_NO_SMOKE )
{
m_bSmoke = false;
}

CPASAttenuationFilter filter( this );
m_pBurnSound = CSoundEnvelopeController::GetController().SoundCreate( filter, entindex(), CHAN_WEAPON, "weapons/flaregun/burn.wav", 2.0f );

if ( ( m_flTimeBurnOut != -1.0f ) && ( m_flTimeBurnOut > gpGlobals->curtime ) )
{
CSoundEnvelopeController::GetController().Play( m_pBurnSound, 0.0f, 60 );
CSoundEnvelopeController::GetController().SoundChangeVolume( m_pBurnSound, 0.8f, 2.0f );
CSoundEnvelopeController::GetController().SoundChangePitch( m_pBurnSound, 100, 2.0f );
}

return result;
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CFlare::Spawn( void )
{
Precache();

SetModel( "models/weapons/flare.mdl" );

UTIL_SetSize( this, Vector( -2, -2, -2 ), Vector( 2, 2, 2 ) );

SetSolid( SOLID_BBOX );
AddSolidFlags( FSOLID_NOT_SOLID );

SetMoveType( MOVETYPE_NONE );
SetFriction( 0.6f );
SetGravity(0.5f);
m_flTimeBurnOut = gpGlobals->curtime + 30;

AddEffects( EF_NOSHADOW|EF_NORECEIVESHADOW );

if ( m_spawnflags & SF_FLARE_NO_DLIGHT )
{
m_bLight = false;
}

if ( m_spawnflags & SF_FLARE_NO_SMOKE )
{
m_bSmoke = false;
}

if ( m_spawnflags & SF_FLARE_INFINITE )
{
m_flTimeBurnOut = -1.0f;
}

if ( m_spawnflags & SF_FLARE_START_OFF )
{
AddEffects( EF_NODRAW );
}

AddFlag( FL_OBJECT );
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CFlare::Activate( void )
{
BaseClass::Activate();

// Start the burning sound if we're already on
if ( ( m_spawnflags & SF_FLARE_START_OFF ) == false )
{
StartBurnSound();
}
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CFlare::StartBurnSound( void )
{
if ( m_pBurnSound == NULL )
{
CPASAttenuationFilter filter( this );
m_pBurnSound = CSoundEnvelopeController::GetController().SoundCreate(
filter, entindex(), CHAN_WEAPON, "weapons/flaregun/burn.wav", 3.0f );
}
}

//-----------------------------------------------------------------------------
// Purpose:
// Input : vecOrigin -
// vecAngles -
// *pOwner -
// Output : CFlare
//-----------------------------------------------------------------------------
CFlare *CFlare::Create( Vector vecOrigin, QAngle vecAngles, CBaseEntity *pOwner, float lifetime )
{
CFlare *pFlare = (CFlare *) CreateEntityByName( "env_flare" );

if ( pFlare == NULL )
return NULL;

UTIL_SetOrigin( pFlare, vecOrigin );

pFlare->SetLocalAngles( vecAngles );
pFlare->Spawn();
pFlare->SetTouch( FlareTouch );
pFlare->SetThink( FlareThink );

//Start up the flare
pFlare->Start( lifetime );

//Don't start sparking immediately
pFlare->SetNextThink( gpGlobals->curtime + 0.5f );

//Burn out time
pFlare->m_flTimeBurnOut = gpGlobals->curtime + lifetime;

pFlare->RemoveSolidFlags( FSOLID_NOT_SOLID );
pFlare->AddSolidFlags( FSOLID_NOT_STANDABLE );

pFlare->SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE );

pFlare->SetOwnerEntity( pOwner );
pFlare->m_pOwner = pOwner;

return pFlare;
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
unsigned int CFlare::PhysicsSolidMaskForEntity( void ) const
{
return MASK_NPCSOLID;

/*
if ( GetFlags() & FL_NPC )
{
}
else if ( IsPlayer() )
{
return MASK_PLAYERSOLID;
}
return MASK_OPAQUE;
*/
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CFlare::FlareThink( void )
{
float deltaTime = ( m_flTimeBurnOut - gpGlobals->curtime );

if ( m_flTimeBurnOut != -1.0f )
{
//Fading away
if ( ( deltaTime <= FLARE_DECAY_TIME ) && ( m_bFading == false ) )
{
m_bFading = true;
CSoundEnvelopeController::GetController().SoundChangePitch( m_pBurnSound, 60, deltaTime );
CSoundEnvelopeController::GetController().SoundFadeOut( m_pBurnSound, deltaTime );
}

//Burned out
if ( m_flTimeBurnOut < gpGlobals->curtime )
{
CSoundEnvelopeController::GetController().SoundDestroy( m_pBurnSound );
m_pBurnSound = NULL;
UTIL_Remove( this );
return;
}
}

//Act differently underwater
if ( GetWaterLevel() > 1 )
{
UTIL_Bubbles( GetAbsOrigin() + Vector( -2, -2, -2 ), GetAbsOrigin() + Vector( 2, 2, 2 ), 1 );
m_bSmoke = false;
}
else
{
//Shoot sparks
if ( random->RandomInt( 0, 8 ) == 1 )
{
g_pEffects->Sparks( GetAbsOrigin() );
}
}

//Next update
SetNextThink( gpGlobals->curtime + 0.1f );
}

//-----------------------------------------------------------------------------
// Purpose:
// Input : *pOther -
//-----------------------------------------------------------------------------
void CFlare::FlareBurnTouch( CBaseEntity *pOther )
{
if ( pOther && pOther->m_takedamage && ( m_flNextDamage < gpGlobals->curtime ) )
{
pOther->TakeDamage( CTakeDamageInfo( this, m_pOwner, 1, (DMG_BULLET|DMG_BURN) ) );
m_flNextDamage = gpGlobals->curtime + 1.0f;
}
}

//-----------------------------------------------------------------------------
// Purpose:
// Input : *pOther -
//-----------------------------------------------------------------------------
void CFlare::FlareTouch( CBaseEntity *pOther )
{
Assert( pOther );
if ( !pOther->IsSolid() )
return;

if ( ( m_nBounces < 10 ) && ( GetWaterLevel() < 1 ) )
{
// Throw some real chunks here
g_pEffects->Sparks( GetAbsOrigin() );
}

//If the flare hit a person or NPC, do damage here.
if ( pOther && pOther->m_takedamage )
{
/*
The Flare is the iRifle round right now. No damage, just ignite. (sjb)

//Damage is a function of how fast the flare is flying.
int iDamage = GetAbsVelocity().Length() / 50.0f;

if ( iDamage < 5 )
{
//Clamp minimum damage
iDamage = 5;
}

//Use m_pOwner, not GetOwnerEntity()
pOther->TakeDamage( CTakeDamageInfo( this, m_pOwner, iDamage, (DMG_BULLET|DMG_BURN) ) );
m_flNextDamage = gpGlobals->curtime + 1.0f;
*/

CBaseCombatCharacter *pBCC;
pBCC = pOther->MyCombatCharacterPointer();

if( pBCC )
{
if( !pBCC->IsOnFire() )
{
pOther->MyCombatCharacterPointer()->Ignite( 100.0f );
}
}

Vector vecNewVelocity = GetAbsVelocity();
vecNewVelocity *= 0.1f;
SetAbsVelocity( vecNewVelocity );

SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE );
SetGravity(1.0f);

Die( 0.5 );

return;
}
else
{
// hit the world, check the material type here, see if the flare should stick.
trace_t tr;
tr = CBaseEntity::GetTouchTrace();

//Only do this on the first bounce
if ( m_nBounces == 0 )
{
surfacedata_t *pdata = physprops->GetSurfaceData( tr.surface.surfaceProps );

if ( pdata != NULL )
{
//Only embed into concrete and wood (jdw: too obscure for players?)
//if ( ( pdata->gameMaterial == 'C' ) || ( pdata->gameMaterial == 'W' ) )
{
Vector impactDir = ( tr.endpos - tr.startpos );
VectorNormalize( impactDir );

float surfDot = tr.plane.normal.Dot( impactDir );

//Do not stick to ceilings or on shallow impacts
if ( ( tr.plane.normal.z > -0.5f ) && ( surfDot < -0.9f ) )
{
RemoveSolidFlags( FSOLID_NOT_SOLID );
AddSolidFlags( FSOLID_TRIGGER );
UTIL_SetOrigin( this, tr.endpos + ( tr.plane.normal * 2.0f ) );
SetAbsVelocity( vec3_origin );
SetMoveType( MOVETYPE_NONE );

SetTouch( FlareBurnTouch );

int index = decalsystem->GetDecalIndexForName( "SmallScorch" );
if ( index >= 0 )
{
CBroadcastRecipientFilter filter;
te->Decal( filter, 0.0, &tr.endpos, &tr.startpos, ENTINDEX( tr.m_pEnt ), tr.hitbox, index );
}

CPASAttenuationFilter filter2( this, "Flare.Touch" );
EmitSound( filter2, entindex(), "Flare.Touch" );

return;
}
}
}
}

//Scorch decal
if ( GetAbsVelocity().LengthSqr() > (250*250) )
{
int index = decalsystem->GetDecalIndexForName( "FadingScorch" );
if ( index >= 0 )
{
CBroadcastRecipientFilter filter;
te->Decal( filter, 0.0, &tr.endpos, &tr.startpos, ENTINDEX( tr.m_pEnt ), tr.hitbox, index );
}
}

// Change our flight characteristics
SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE );
SetGravity(0.8f);

m_nBounces++;

//After the first bounce, smacking into whoever fired the flare is fair game
SetOwnerEntity( this );

// Slow down
Vector vecNewVelocity = GetAbsVelocity();
vecNewVelocity.x *= 0.8f;
vecNewVelocity.y *= 0.8f;
SetAbsVelocity( vecNewVelocity );

//Stopped?
if ( GetAbsVelocity().Length() < 64.0f )
{
SetAbsVelocity( vec3_origin );
SetMoveType( MOVETYPE_NONE );
RemoveSolidFlags( FSOLID_NOT_SOLID );
AddSolidFlags( FSOLID_TRIGGER );
SetTouch( FlareBurnTouch );
}
}
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CFlare::Start( float lifeTime )
{
StartBurnSound();

if ( m_pBurnSound != NULL )
{
CSoundEnvelopeController::GetController().Play( m_pBurnSound, 0.0f, 60 );
CSoundEnvelopeController::GetController().SoundChangeVolume( m_pBurnSound, 0.8f, 2.0f );
CSoundEnvelopeController::GetController().SoundChangePitch( m_pBurnSound, 100, 2.0f );
}

m_flTimeBurnOut = gpGlobals->curtime + lifeTime;

RemoveEffects( EF_NODRAW );

SetThink( FlareThink );
SetNextThink( gpGlobals->curtime + 0.1f );
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CFlare::Die( float fadeTime )
{
m_flTimeBurnOut = gpGlobals->curtime + fadeTime;

SetThink( FlareThink );
SetNextThink( gpGlobals->curtime + 0.1f );
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CFlare::Launch( const Vector &direction, float speed )
{
// Make sure we're visible
Start( 8.0f );

SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE );

// Punch our velocity towards our facing
SetAbsVelocity( direction * FLARE_LAUNCH_SPEED );

SetGravity( 1.0f );
}

//-----------------------------------------------------------------------------
// Purpose:
// Input : &inputdata -
//-----------------------------------------------------------------------------
void CFlare::InputStart( inputdata_t &inputdata )
{
Start( inputdata.value.Float() );
}

//-----------------------------------------------------------------------------
// Purpose:
// Input : &inputdata -
//-----------------------------------------------------------------------------
void CFlare::InputDie( inputdata_t &inputdata )
{
Die( inputdata.value.Float() );
}

//-----------------------------------------------------------------------------
// Purpose:
// Input : &inputdata -
//-----------------------------------------------------------------------------
void CFlare::InputLaunch( inputdata_t &inputdata )
{
Vector direction;
AngleVectors( GetAbsAngles(), &direction );

Launch( direction, FLARE_LAUNCH_SPEED );
}

IMPLEMENT_SERVERCLASS_ST(CFlaregun, DT_Flaregun)
END_SEND_TABLE()

LINK_ENTITY_TO_CLASS( weapon_flaregun, CFlaregun );
PRECACHE_WEAPON_REGISTER( weapon_flaregun );

//-----------------------------------------------------------------------------
// Purpose: Precache
//-----------------------------------------------------------------------------
void CFlaregun::Precache( void )
{
BaseClass::Precache();

UTIL_PrecacheOther( "env_flare" );
}

//-----------------------------------------------------------------------------
// Purpose: Main attack
//-----------------------------------------------------------------------------
void CFlaregun::PrimaryAttack( void )
{
CBasePlayer *pOwner = ToBasePlayer( GetOwner() );

if ( pOwner == NULL )
return;

if ( m_iClip1 <= 0 )
{
SendWeaponAnim( ACT_VM_DRYFIRE );
pOwner->m_flNextAttack = gpGlobals->curtime + SequenceDuration();
return;
}

m_iClip1 = m_iClip1 - 1;

SendWeaponAnim( ACT_VM_PRIMARYATTACK );
pOwner->m_flNextAttack = gpGlobals->curtime + 1;

CFlare *pFlare = CFlare::Create( pOwner->Weapon_ShootPosition(), pOwner->EyeAngles(), pOwner, FLARE_DURATION );

if ( pFlare == NULL )
return;

Vector forward;
pOwner->EyeVectors( &forward );

pFlare->SetAbsVelocity( forward * 1500 );

WeaponSound( SINGLE );
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CFlaregun::SecondaryAttack( void )
{
CBasePlayer *pOwner = ToBasePlayer( GetOwner() );

if ( pOwner == NULL )
return;

if ( m_iClip1 <= 0 )
{
SendWeaponAnim( ACT_VM_DRYFIRE );
pOwner->m_flNextAttack = gpGlobals->curtime + SequenceDuration();
return;
}

m_iClip1 = m_iClip1 - 1;

SendWeaponAnim( ACT_VM_PRIMARYATTACK );
pOwner->m_flNextAttack = gpGlobals->curtime + 1;

CFlare *pFlare = CFlare::Create( pOwner->Weapon_ShootPosition(), pOwner->EyeAngles(), pOwner, FLARE_DURATION );

if ( pFlare == NULL )
return;

Vector forward;
pOwner->EyeVectors( &forward );

pFlare->SetAbsVelocity( forward * 500 );
pFlare->SetGravity(1.0f);
pFlare->SetFriction( 0.85f );
pFlare->SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE );

WeaponSound( SINGLE );
}

Ок, сделали. А теперь откройте этот файл (src\dlls\hl2_dll\weapon_flaregun.h) и в него впешите это:

//========= Copyright © 1996-2003, Valve LLC, All rights reserved. ============
//
// Purpose:
//
//=============================================================================

#include "basehlcombatweapon.h"
#include "soundenvelope.h"

#ifndef WEAPON_FLAREGUN_H
#define WEAPON_FLAREGUN_H
#ifdef _WIN32
#pragma once
#endif

#define SF_FLARE_NO_DLIGHT 0x00000001
#define SF_FLARE_NO_SMOKE 0x00000002
#define SF_FLARE_INFINITE 0x00000004
#define SF_FLARE_START_OFF 0x00000008

#define FLARE_DURATION 30.0f
#define FLARE_DECAY_TIME 10.0f

//---------------------
// Flare
//---------------------

class CFlare : public CBaseCombatCharacter
{
public:
DECLARE_CLASS( CFlare, CBaseCombatCharacter );

CFlare( void );

static CFlare * GetActiveFlares( void );
CFlare * GetNextFlare( void ) const { return m_pNextFlare; }

static CFlare *Create( Vector vecOrigin, QAngle vecAngles, CBaseEntity *pOwner, float lifetime );

virtual unsigned int PhysicsSolidMaskForEntity( void ) const;

void Spawn( void );
void Precache( void );
int Restore( IRestore &restore );
void Activate( void );

void StartBurnSound( void );

void Start( float lifeTime );
void Die( float fadeTime );
void Launch( const Vector &direction, float speed );

Class_T Classify( void );

void FlareTouch( CBaseEntity *pOther );
void FlareBurnTouch( CBaseEntity *pOther );
void FlareThink( void );

void InputStart( inputdata_t &inputdata );
void InputDie( inputdata_t &inputdata );
void InputLaunch( inputdata_t &inputdata );

DECLARE_SERVERCLASS();
DECLARE_DATADESC();

static CFlare *activeFlares;

CBaseEntity *m_pOwner;
int m_nBounces; // how many times has this flare bounced?
CNetworkVar( float, m_flTimeBurnOut ); // when will the flare burn out?
CNetworkVar( float, m_flScale );
float m_flDuration;
float m_flNextDamage;

CSoundPatch *m_pBurnSound;
bool m_bFading;
CNetworkVar( bool, m_bLight );
CNetworkVar( bool, m_bSmoke );
CNetworkVar( bool, m_bPropFlare );

CFlare * m_pNextFlare;
};

//---------------------
// Flaregun
//---------------------
class CFlaregun:public CBaseHLCombatWeapon
{
public:
DECLARE_CLASS( CFlaregun, CBaseHLCombatWeapon );

DECLARE_SERVERCLASS();

void Precache( void );
void PrimaryAttack( void );
void SecondaryAttack( void );
};

#endif // WEAPON_FLAREGUN_H

Вот теперь надо откоментить пару строк и можно компилить, так что заходим сюда (src\game_shared\hl2\hl2_gamerules.cpp) и там откоментить строки:

//ConVar sk_plr_dmg_flare_round ( "sk_plr_dmg_flare_round","0", FCVAR_REPLICATED);
//ConVar sk_npc_dmg_flare_round ( "sk_npc_dmg_flare_round","0", FCVAR_REPLICATED);
//ConVar sk_max_flare_round ( "sk_max_flare_round","0", FCVAR_REPLICATED);

Теперь спускаемся в самый низ файла до строк def.AddAmmoType и там где то после строки:

def.AddAmmoType("SMG1", DMG_BULLET, TRACER_LINE_AND_WHIZ, "sk_plr_dmg_smg1", "sk_npc_dmg_smg1", "sk_max_smg1", BULLET_IMPULSE(200, 1225), 0 );

Вставим эту:

def.AddAmmoType("FlareRound", DMG_BURN, TRACER_LINE, "sk_plr_dmg_flare_round", "sk_npc_dmg_flare_round", "sk_max_flare_round", BULLET_IMPULSE(1500, 600), 0);

Теперь можно компилить, так как в клиен ничего песать ненадо smile Там и всё есть. Теперь когда откомпилили, идем в папку Scripts в папке вашего мода и там создаём файл под название weapon_flaregun.txt и в него впишем:

// Flare Gun

WeaponData
{
// Weapon data is loaded by both the Game and Client DLLs.
"printname" "FLAREGUN"
"viewmodel" "models/weapons/v_flaregun.mdl"
"playermodel" "models/weapons/w_flaregun.mdl"
"anim_prefix" "Pistol" //flaregun
"bucket" "1"
"bucket_position" "2"

"clip_size" "1"
// "clip2_size" "4"
"default_clip" "1"
// "default_clip2" "4"
"primary_ammo" "FlareRound"
"secondary_ammo" "None"

"weight" "1"
"item_flags" "0"

// Sounds for the weapon. There is a max of 16 sounds per category (i.e. max 16 "single_shot" sounds)
SoundData
{
"single_shot" "Weapon_FlareGun.Single"
"reload" "Weapon_FlareGun.Reload"
}

// Weapon Sprite data is loaded by the Client DLL.
TextureData
{
"weapon"
{
"file" "sprites/w_icons1b"
"x" "128"
"y" "64"
"width" "128"
"height" "64"
}
"weapon_s"
{
"file" "sprites/w_icons1b"
"x" "128"
"y" "64"
"width" "128"
"height" "64"
}
"ammo"
{
"file" "sprites/a_icons1"
"x" "55"
"y" "130"
"width" "73"
"height" "20"
}
"crosshair"
{
"font" "Crosshairs"
"character" "Q"
}
"autoaim"
{
"file" "sprites/crosshairs"
"x" "0"
"y" "48"
"width" "24"
"height" "24"
}
}

Сейчас сделаем звуки, зайдя в файл scripts\game_sounds_weapons.txt и там где то после обозначений звуков SMG1 впишем наши:

// weapon_flaregun.txt
"Weapon_FlareGun.Single"
{
"channel" "CHAN_WEAPON"
"volume" "0.55"
"soundlevel" "SNDLVL_GUNFIRE"

"wave" "weapons/flaregun/fire.wav"
}

"Weapon_FlareGun.Reload"
{
"channel" "CHAN_ITEM"
"volume" "0.7"
"soundlevel" "SNDLVL_NORM"

"wave" "weapons/flaregun/reload.wav"
}

"Weapon_FlareGun.Burn"
{
"channel" "CHAN_WEAPON"
"soundlevel" "SNDLVL_NORM"
"volume" "0.65"

"wave" "weapons/flaregun/burn.wav"
}

Теперь осталось совсем мало, зайдите в cfg\skill.cfg и там после строчек:

sk_plr_dmg_brickbat "3"
sk_npc_dmg_brickbat "2"
sk_max_brickbat "8"

Впишем эти:

sk_plr_dmg_flare_round "12"
sk_npc_dmg_flare_round "2"
sk_max_flare_round "20"

Всё, запускаем игру и как всегда радуемя новому оружию smile Скачать модели можете здесь.

Категория: Туториалы по программированию (HL2) | Добавил: DetLeR (16.09.2007) | Автор: Роман
Просмотров: 1571 | Комментарии: 5 | Рейтинг: 5.0 |

Всего комментариев: 5
5  
Не работает вообще. sad

4  
ХА! Удалил файлы weapon_flaregun.cpp и weapon_flaregun.h, перестроил server, затем снова прописал weapon_flaregun.cpp с weapon_flaregun.h. Компил. Вуля! Работает! =)
Интересные глюки в визуале! :-D

3  
У меня так же, сначала работало, раньше компилировало, недавно такая же ошибка стала выскакивать ((((

2  
Странно, сделай перебилд сервер.длл

1  
ошибка sad

2>e:\documents and settings\admin\рабочий стол\src_mod\dlls\hl2_dll\weapon_flaregun.cpp(244) : error C3867: 'CFlare::FlareTouch': function call missing argument list; use '&CFlare::FlareTouch' to create a pointer to member
2>e:\documents and settings\admin\рабочий стол\src_mod\dlls\hl2_dll\weapon_flaregun.cpp(245) : error C3867: 'CFlare::FlareThink': function call missing argument list; use '&CFlare::FlareThink' to create a pointer to member
2>e:\documents and settings\admin\рабочий стол\src_mod\dlls\hl2_dll\weapon_flaregun.cpp(433) : error C3867: 'CFlare::FlareBurnTouch': function call missing argument list; use '&CFlare::FlareBurnTouch' to create a pointer to member
2>e:\documents and settings\admin\рабочий стол\src_mod\dlls\hl2_dll\weapon_flaregun.cpp(484) : error C3867: 'CFlare::FlareBurnTouch': function call missing argument list; use '&CFlare::FlareBurnTouch' to create a pointer to member
2>e:\documents and settings\admin\рабочий стол\src_mod\dlls\hl2_dll\weapon_flaregun.cpp(507) : error C3867: 'CFlare::FlareThink': function call missing argument list; use '&CFlare::FlareThink' to create a pointer to member
2>e:\documents and settings\admin\рабочий стол\src_mod\dlls\hl2_dll\weapon_flaregun.cpp(518) : error C3867: 'CFlare::FlareThink': function call missing argument list; use '&CFlare::FlareThink' to create a pointer to member
2>e:\documents and settings\admin\рабочий стол\src_mod\dlls\hl2_dll\weapon_flaregun.cpp(657) : fatal error C1020: unexpected #endif


Добавлять комментарии могут только зарегистрированные пользователи.
[ Регистрация | Вход ]
Форма входа

Кто в Онлайн

Друзья сайта

Баннеры

  Сайт CrazyArts   Black   Сообщество сайтов о Half-Life   Самый   Только   Все   hl2 top 100     Rambler's Top100  

игры
игры

  Каталог сайтов Планета Топ 100 - Planet Top 100       ТОП ЛУЧШИХ ИГРОВЫХ САЙТОВ           Detroit Team Site :: Моды от Detroit Team, видео, новости.   Naruto-kun[Звезда Наруто]  


The idea of dising: Homie7