|
|
Diskusn boardy |
|
|
|
Najnovie lnky |
|
Automatická textová správa Vocko Tutoril 07.06.2009 : 11:02:12
|
V tomto tutoriále si spravíme automatickú textovú správu, ktorá sa prehraje vždy s nejakým zvukom. |
|
|
|
|
Env_mirror alebo zrkadlenie modelov Vocko Tutoril 24.04.2009 : 18:49:30
|
Tutoriál na zrkadlenie tu už je, ale èo ak chceme odráža i modely? Na tom nám poslúži entita env_mirror, ktorá sa nachádza iba v Spirite 1.4 alebo novšej verzii. |
|
|
HL2 : Obloukový prùchod R4z0r Tutoril 01.05.2008 : 05:48:46
|
Dnes si ukážeme zpùsob, jak vytvoøit elegantní obloukový prùchod, bez nutnosti používat øezání geometrie brushem... |
|
|
|
|
Pridanie mp3 do spiritu NICKSss Tutoril 02.03.2008 : 20:55:09
|
Návod na pridanie mp3 do Half-Life 1 alebo Spirt 1.2,otestované na verzii 1.2.
Asi už mate zbrane add-ons vo Spirite 1.2 a nechcete prejst na ver.1.4 lebo všetko stratite
pre Mp3... Na internete som našiel návody pre HL1 a po anglicky ktoré po skompilovani
fungovali asi takto : Aplikácia HL.EXE Neodpovedá... |
|
|
*locus Deli Tutoril 22.02.2008 : 20:13:47
|
Pre niektorých mapperov neznámy pojem, ale pre niektorých ve¾mi úèinná pomôcka.
Vïaka tomuto príspevku sa vám posnažím priblíži tajomstvá jednej z najväèších zbraní spiritu.
|
|
|
Spirit of Half-Life - Predstavenie Wizz Tutoril 27.10.2007 : 08:52:04
|
Predtým než sa pustíte do èítania, chcel by som Vás upozorni že èlánok už nemusí by 100% aktualny. Èlánok som totiž napísal ešte za svojich mladých èias - 13. júna 2004, èo je viac ako tri roky. Zverejni som sa ho rozhodol po nátlaku a výhražkach ostatných redaktorov |
|
|
|
Smoke grenade qery [17.05.2004 : 18:41:11] 112 Tutoril tan : 2808 Priemern znmka : 2 |
Dnes sa pokúsime vytvori smoke grenade èiže dymivý granát :D
Nakolko to èítam z vlastných zdrojákoch, ktoré som písal neskoro v noci, dúfam ze tam nezabudnem niè napísa. Keby to niekomu náhodou nechcelo chodi tak mi pls napíšte nejakú správu aby som to mohol opravi.
Zaèneme tým, že si do adresára VALVE\MODELS nahráme súbory p_smokegrenade.mdl, v_smokegrenade.mdl a w_smokegrenade.mdl. Ïalej vytvoríme súbor smokegrenade.cpp, ktorý bude obsahova nasledujúci text:
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "weapons.h"
#include "nodes.h"
#include "player.h"
#define SMOKEGRENADE_PRIMARY_VOLUME 450
enum smokegrenade_e
{
SMOKEGRENADE_IDLE = 0,
SMOKEGRENADE_PINPULL,
SMOKEGRENADE_THROW1, // toss
SMOKEGRENADE_DRAW
};
class CSmokeGrenade : public CBasePlayerWeapon
{
public:
void Spawn( void );
void Precache( void );
int iItemSlot( void ) { return 5; }
int GetItemInfo(ItemInfo *p);
void PrimaryAttack( void );
BOOL Deploy( void );
BOOL CanHolster( void );
void Holster( int skiplocal = 0 );
void WeaponIdle( void );
float m_flStartThrow;
float m_flReleaseThrow;
};
LINK_ENTITY_TO_CLASS( weapon_smokegrenade, CSmokeGrenade );
void CSmokeGrenade::Spawn( )
{
Precache( );
m_iId = WEAPON_SMOKEGRENADE;
SET_MODEL(ENT(pev), "models/w_smokegrenade.mdl");
pev->dmg = 0;
m_iDefaultAmmo = SMOKEGRENADE_DEFAULT_GIVE;
FallInit();// get ready to fall down.
}
void CSmokeGrenade::Precache( void )
{
PRECACHE_MODEL("models/w_smokegrenade.mdl");
PRECACHE_MODEL("models/v_smokegrenade.mdl");
PRECACHE_MODEL("models/p_smokegrenade.mdl");
}
int CSmokeGrenade::GetItemInfo(ItemInfo *p)
{
p->pszName = STRING(pev->classname);
p->pszAmmo1 = "Hand Grenade";
p->iMaxAmmo1 = SMOKEGRENADE_MAX_CARRY;
p->pszAmmo2 = NULL;
p->iMaxAmmo2 = -1;
p->iMaxClip = WEAPON_NOCLIP;
p->iSlot = 4;
p->iPosition = 4;
p->iId = m_iId = WEAPON_SMOKEGRENADE;
p->iWeight = SMOKEGRENADE_WEIGHT;
p->iFlags = ITEM_FLAG_LIMITINWORLD | ITEM_FLAG_EXHAUSTIBLE;
return 1;
}
BOOL CSmokeGrenade::Deploy( )
{
m_flReleaseThrow = -1;
return DefaultDeploy( "models/v_smokegrenade.mdl", "models/p_smokegrenade.mdl", SMOKEGRENADE_DRAW, "crowbar" );
}
BOOL CSmokeGrenade::CanHolster( void )
{
// can only holster hand grenades when not primed!
return ( m_flStartThrow == 0 );
}
void CSmokeGrenade::Holster( int skiplocal /* = 0 */ )
{
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;
if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType])
{
SendWeaponAnim( SMOKEGRENADE_DRAW );
}
else
{
// no more grenades!
m_pPlayer->pev->weapons &= ~(1<
SetThink( DestroyItem );
pev->nextthink = gpGlobals->time + 0.1;
}
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM);
}
void CSmokeGrenade::PrimaryAttack()
{
if (!m_flStartThrow && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] > 0)
{
m_flStartThrow = gpGlobals->time;
m_flReleaseThrow = 0;
SendWeaponAnim( SMOKEGRENADE_PINPULL );
m_flTimeWeaponIdle = gpGlobals->time + 0.5;
}
}
void CSmokeGrenade::WeaponIdle( void )
{
if (m_flReleaseThrow == 0)
m_flReleaseThrow = gpGlobals->time;
if (m_flTimeWeaponIdle > gpGlobals->time)
return;
if (m_flStartThrow)
{
Vector angThrow = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle;
if (angThrow.x < 0)
angThrow.x = -10 + angThrow.x * ((90 - 10) / 90.0);
else
angThrow.x = -10 + angThrow.x * ((90 + 10) / 90.0);
float flVel = (90 - angThrow.x) * 4;
if (flVel > 500)
flVel = 500;
UTIL_MakeVectors( angThrow );
Vector vecSrc = m_pPlayer->pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_forward * 16;
Vector vecThrow = gpGlobals->v_forward * flVel + m_pPlayer->pev->velocity;
// alway explode 3 seconds after the pin was pulled
float time = m_flStartThrow - gpGlobals->time + 3.0;
if (time < 0)
time = 0;
CGrenade::SmokeShootTimed( m_pPlayer->pev, vecSrc, vecThrow, time );
SendWeaponAnim( SMOKEGRENADE_THROW1 );
// player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
m_flStartThrow = 0;
m_flNextPrimaryAttack = gpGlobals->time + 0.5;
m_flTimeWeaponIdle = gpGlobals->time + 0.5;
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
if ( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
{
// just threw last grenade
// set attack times in the future, and weapon idle in the future so we can see the whole throw
// animation, weapon idle will automatically retire the weapon for us.
m_flTimeWeaponIdle = m_flNextSecondaryAttack = m_flNextPrimaryAttack = gpGlobals->time + 0.5;// ensure that the animation can finish playing
}
return;
}
else if (m_flReleaseThrow > 0)
{
// we've finished the throw, restart.
m_flStartThrow = 0;
if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType])
{
SendWeaponAnim( SMOKEGRENADE_DRAW );
}
else
{
RetireWeapon();
return;
}
m_flTimeWeaponIdle = gpGlobals->time + RANDOM_FLOAT ( 10, 15 );
m_flReleaseThrow = -1;
return;
}
if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType])
{
int iAnim;
float flRand = RANDOM_FLOAT(0, 1);
if (flRand <= 0.75)
{
iAnim = SMOKEGRENADE_IDLE;
m_flTimeWeaponIdle = gpGlobals->time + RANDOM_FLOAT ( 10, 15 );// how long till we do this again.
}
else
{
iAnim = SMOKEGRENADE_IDLE;
m_flTimeWeaponIdle = gpGlobals->time + 75.0 / 30.0;
}
SendWeaponAnim( iAnim );
}
}
|
Ïalej si otvoríme súbor ggrenade.cpp vymeníme nasledujúce procedúry:
void CGrenade::Smoke( void )
{
if (UTIL_PointContents ( pev->origin ) == CONTENTS_WATER)
{
UTIL_Bubbles( pev->origin - Vector( 64, 64, 64 ), pev->origin + Vector( 64, 64, 64 ), 100 );
}
else
{
if (pev->dmg==1)
{
int mytemp;
for (mytemp=0;mytemp<20+RANDOM_FLOAT(-2,10);mytemp++)
{
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin );
WRITE_BYTE( TE_SMOKE );
WRITE_COORD( pev->origin.x + RANDOM_FLOAT(-25, 25));
WRITE_COORD( pev->origin.y + RANDOM_FLOAT(-15, 15));
WRITE_COORD( pev->origin.z + RANDOM_FLOAT(-25, 25));
WRITE_SHORT( g_sModelIndexSmoke );
WRITE_BYTE( 50 + RANDOM_FLOAT(-10, 10)); // scale * 10
WRITE_BYTE( RANDOM_FLOAT(1, 6)); // framerate
MESSAGE_END();
}
/*MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin );
WRITE_BYTE( TE_SMOKE );
WRITE_COORD( pev->origin.x );
WRITE_COORD( pev->origin.y );
WRITE_COORD( pev->origin.z );
WRITE_SHORT( g_sModelIndexSmoke );
WRITE_BYTE( 50 ); // scale * 10
WRITE_BYTE(3 ); // framerate
MESSAGE_END();*/
}
else
{
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin );
WRITE_BYTE( TE_SMOKE );
WRITE_COORD( pev->origin.x );
WRITE_COORD( pev->origin.y );
WRITE_COORD( pev->origin.z );
WRITE_SHORT( g_sModelIndexSmoke );
WRITE_BYTE( (pev->dmg - 50) * 0.80 ); // scale * 10
WRITE_BYTE( 12 ); // framerate
MESSAGE_END();
}
}
UTIL_Remove( this );
}
void CGrenade::Explode( TraceResult *pTrace, int bitsDamageType )
{
float flRndSound;// sound randomizer
pev->model = iStringNull;//invisible
pev->solid = SOLID_NOT;// intangible
pev->takedamage = DAMAGE_NO;
// Pull out of the wall a bit
if ( pTrace->flFraction != 1.0 )
{
if (pev->dmg==1)
{
pev->origin = pTrace->vecEndPos + (pTrace->vecPlaneNormal * 76 * 0.6);
}
else
{
pev->origin = pTrace->vecEndPos + (pTrace->vecPlaneNormal * (pev->dmg - 24) * 0.6);
}
}
int iContents = UTIL_PointContents ( pev->origin );
if (pev->dmg==1)
{
}
else
{
MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin );
WRITE_BYTE( TE_EXPLOSION ); // This makes a dynamic light and the explosion sprites/sound
WRITE_COORD( pev->origin.x ); // Send to PAS because of the sound
WRITE_COORD( pev->origin.y );
WRITE_COORD( pev->origin.z );
if (iContents != CONTENTS_WATER)
{
WRITE_SHORT( g_sModelIndexFireball );
}
else
{
WRITE_SHORT( g_sModelIndexWExplosion );
}
WRITE_BYTE( (pev->dmg - 50) * .60 ); // scale * 10
WRITE_BYTE( 15 ); // framerate
WRITE_BYTE( TE_EXPLFLAG_NONE );
MESSAGE_END();
}
CSoundEnt::InsertSound ( bits_SOUND_COMBAT, pev->origin, NORMAL_EXPLOSION_VOLUME, 3.0 );
entvars_t *pevOwner;
if ( pev->owner )
pevOwner = VARS( pev->owner );
else
pevOwner = NULL;
pev->owner = NULL; // can't traceline attack owner if this is set
RadiusDamage ( pev, pevOwner, pev->dmg -1, CLASS_NONE, bitsDamageType );
if (pev->dmg==1)
{
}
else
{
if ( RANDOM_FLOAT( 0 , 1 ) < 0.5 )
{
UTIL_DecalTrace( pTrace, DECAL_SCORCH1 );
}
else
{
UTIL_DecalTrace( pTrace, DECAL_SCORCH2 );
}
}
flRndSound = RANDOM_FLOAT( 0 , 1 );
switch ( RANDOM_LONG( 0, 2 ) )
{
case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/debris1.wav", 0.55, ATTN_NORM); break;
case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/debris2.wav", 0.55, ATTN_NORM); break;
case 2: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/debris3.wav", 0.55, ATTN_NORM); break;
}
pev->effects |= EF_NODRAW;
SetThink( Smoke );
pev->velocity = g_vecZero;
pev->nextthink = gpGlobals->time + 0.3;
if (iContents != CONTENTS_WATER)
{
int sparkCount = RANDOM_LONG(0,3);
for ( int i = 0; i < sparkCount; i++ )
Create( "spark_shower", pev->origin, pTrace->vecPlaneNormal, NULL );
}
}
|
A ešte pridáme túto procedúru:
CGrenade * CGrenade:: SmokeShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time )
{
CGrenade *pGrenade = GetClassPtr( (CGrenade *)NULL );
pGrenade->Spawn();
UTIL_SetOrigin( pGrenade->pev, vecStart );
pGrenade->pev->velocity = vecVelocity;
pGrenade->pev->angles = UTIL_VecToAngles(pGrenade->pev->velocity);
pGrenade->pev->owner = ENT(pevOwner);
pGrenade->SetTouch( BounceTouch ); // Bounce if touched
// Take one second off of the desired detonation time and set the think to PreDetonate. PreDetonate
// will insert a DANGER sound into the world sound list and delay detonation for one second so that
// the grenade explodes after the exact amount of time specified in the call to ShootTimed().
pGrenade->pev->dmgtime = gpGlobals->time + time;
pGrenade->SetThink( TumbleThink );
pGrenade->pev->nextthink = gpGlobals->time + 0.1;
if (time < 0.1)
{
pGrenade->pev->nextthink = gpGlobals->time;
pGrenade->pev->velocity = Vector( 0, 0, 0 );
}
pGrenade->pev->sequence = RANDOM_LONG( 3, 6 );
pGrenade->pev->framerate = 1.0;
// Tumble through the air
// pGrenade->pev->avelocity.x = -400;
pGrenade->pev->gravity = 0.5;
pGrenade->pev->friction = 0.8;
SET_MODEL(ENT(pGrenade->pev), "models/w_smokegrenade.mdl");
pGrenade->pev->dmg = 1;
return pGrenade;
}
|
A samozrejme nesmieme zabudnú na WEAPONS.H kde pridáme tieto riadky:
#define WEAPON_SMOKEGRENADE 20
#define SMOKEGRENADE_WEIGHT 5
#define SMOKEGRENADE_MAX_CARRY 5
#define SMOKEGRENADE_MAX_CLIP WEAPON_NOCLIP
#define SMOKEGRENADE_DEFAULT_GIVE 5
|
Ïalej nájdeme v súbore WEAPONS.H tento riadok:
static CGrenade *ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time );
|
a zaòho pridáme tento riadok:
static CGrenade *SmokeShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time ); |
V súbore WEAPONS.CPP nájdeme tento riadok:
UTIL_PrecacheOtherWeapon("weapon_handgrenade");
|
a zaòho doplníme tento riadok:
UTIL_PrecacheOtherWeapon("weapon_smokegrenade");
|
A nakoniec v PLAYER.CPP nájdeme riadky:
case 101:
gEvilImpulse101 = TRUE;
GiveNamedItem( "item_suit" );
GiveNamedItem( "item_battery" );
GiveNamedItem( "weapon_crowbar" );
GiveNamedItem( "weapon_9mmhandgun" );
GiveNamedItem( "ammo_9mmclip" );
GiveNamedItem( "weapon_shotgun" );
GiveNamedItem( "ammo_buckshot" );
GiveNamedItem( "weapon_9mmAR" );
GiveNamedItem( "ammo_9mmAR" );
GiveNamedItem( "ammo_ARgrenades" );
GiveNamedItem( "weapon_handgrenade" );
|
a doplníme tam:
GiveNamedItem( "weapon_smokegrenade" );
|
Tak a ak som niekde nespravil chybu tak by to malo zbehnú na prvý pokus.
|
BODOVANIE LNKU Boduje sa ako v kole (1- vborn, 5-zl)
Priemern znmka : 2 Hlasovalo : 6
|
|
|
|
|