Laserweapon: Difference between revisions
No edit summary |
No edit summary |
||
Line 115: | Line 115: | ||
''//----------------------------------------------------------------------------- | ''//----------------------------------------------------------------------------- | ||
// Purpose: | // Purpose: | ||
// Input : &startPos - | // Input : &startPos - | ||
// &endPos - | // &endPos - | ||
// width - | // width - | ||
// useMuzzle - | // useMuzzle - | ||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||
void CWeaponPistol::DrawBeam( const Vector &startPos, const Vector &endPos, float width ) | void CWeaponPistol::DrawBeam( const Vector &startPos, const Vector &endPos, float width ) | ||
{ | { | ||
//Tracer down the middle | //Tracer down the middle | ||
UTIL_Tracer( startPos, endPos, 0, TRACER_DONT_USE_ATTACHMENT, 6500, false, "GaussTracer" ); | UTIL_Tracer( startPos, endPos, 0, TRACER_DONT_USE_ATTACHMENT, 6500, false, "GaussTracer" ); | ||
//Draw the main beam shaft | //Draw the main beam shaft | ||
CBeam *pBeam = CBeam::BeamCreate( PHYSCANNON_BEAM_SPRITE, 15.5 ); | CBeam *pBeam = CBeam::BeamCreate( PHYSCANNON_BEAM_SPRITE, 15.5 ); | ||
pBeam->SetStartPos( startPos ); | pBeam->SetStartPos( startPos ); | ||
pBeam->PointEntInit( endPos, this ); | pBeam->PointEntInit( endPos, this ); | ||
pBeam->SetEndAttachment( LookupAttachment("Muzzle") ); | pBeam->SetEndAttachment( LookupAttachment("Muzzle") ); | ||
pBeam->SetWidth( width ); | pBeam->SetWidth( width ); | ||
// pBeam->SetEndWidth( 0.05f ); | // pBeam->SetEndWidth( 0.05f ); | ||
pBeam->SetBrightness( 255 ); | pBeam->SetBrightness( 255 ); | ||
pBeam->SetColor( 255, 185+random->RandomInt( -16, 16 ), 40 ); | pBeam->SetColor( 255, 185+random->RandomInt( -16, 16 ), 40 ); | ||
pBeam->RelinkBeam(); | pBeam->RelinkBeam(); | ||
pBeam->LiveForTime( 0.1f ); | pBeam->LiveForTime( 0.1f ); | ||
} | } | ||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||
// Purpose: | // Purpose: | ||
// Input : &tr - | // Input : &tr - | ||
// nDamageType - | // nDamageType - | ||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||
void CWeaponSniperRifle::DoImpactEffect( trace_t &tr, int nDamageType ) | void CWeaponSniperRifle::DoImpactEffect( trace_t &tr, int nDamageType ) | ||
{ | { | ||
//Draw our beam | //Draw our beam | ||
DrawBeam( tr.startpos, tr.endpos, 15.5 ); | DrawBeam( tr.startpos, tr.endpos, 15.5 ); | ||
if ( (tr.surface.flags & SURF_SKY) == false ) | if ( (tr.surface.flags & SURF_SKY) == false ) | ||
{ | { | ||
CPVSFilter filter( tr.endpos ); | CPVSFilter filter( tr.endpos ); | ||
te->GaussExplosion( filter, 0.0f, tr.endpos, tr.plane.normal, 0 ); | te->GaussExplosion( filter, 0.0f, tr.endpos, tr.plane.normal, 0 ); | ||
Line 158: | Line 191: | ||
UTIL_ImpactTrace( &tr, m_nBulletType ); | UTIL_ImpactTrace( &tr, m_nBulletType ); | ||
} | } | ||
} | } | ||
'' | '' | ||
We define the beam | We define the beam | ||
'''2 Open hl2_gamerules.cpp''' | '''2 Open hl2_gamerules.cpp''' | ||
Change | Change | ||
''def.AddAmmoType("Pistol", DMG_BULLET, TRACER_LINE_AND_WHIZ, "sk_plr_dmg_pistol", "sk_npc_dmg_pistol", "sk_max_pistol", BULLET_IMPULSE(200, 1225), 0 );'' | ''def.AddAmmoType("Pistol", DMG_BULLET, TRACER_LINE_AND_WHIZ, "sk_plr_dmg_pistol", "sk_npc_dmg_pistol", "sk_max_pistol", BULLET_IMPULSE(200, 1225), 0 );'' | ||
to | to | ||
''def.AddAmmoType("Pistol", DMG_DISSOLVE, TRACER_NONE, "sk_plr_dmg_pistol", "sk_npc_dmg_pistol", "sk_max_pistol", BULLET_IMPULSE(200, 1225), 0 ); | ''def.AddAmmoType("Pistol", DMG_DISSOLVE, TRACER_NONE, "sk_plr_dmg_pistol", "sk_npc_dmg_pistol", "sk_max_pistol", BULLET_IMPULSE(200, 1225), 0 ); | ||
'' | '' | ||
If the enemy dies, he will dissolve and there dont draw a line after the bullet | If the enemy dies, he will dissolve and there dont draw a line after the bullet | ||
'''3 Open \Steam\steamapps\SourceMods\MyMod\scripts\weapon_pistol.txt | '''3 Open \Steam\steamapps\SourceMods\MyMod\scripts\weapon_pistol.txt | ||
''' | ''' | ||
3.1 Change | 3.1 Change | ||
"printname" "#HL2_Pistol" | "printname" "#HL2_Pistol" | ||
to | to | ||
"printname" "LASER PISTOL" | "printname" "LASER PISTOL" | ||
We change the name in the bucket | We change the name in the bucket | ||
3.1 If u know how u can change the SoundData so it will make a better noise | 3.1 If u know how u can change the SoundData so it will make a better noise | ||
4 Open \Steam\steamapps\SourceMods\MyMod\cfg\skill.cfg | 4 Open \Steam\steamapps\SourceMods\MyMod\cfg\skill.cfg | ||
Change | Change | ||
sk_plr_dmg_pistol "5" | sk_plr_dmg_pistol "5" | ||
sk_npc_dmg_pistol "3" | sk_npc_dmg_pistol "3" | ||
sk_max_pistol "148" | sk_max_pistol "148" | ||
to | to | ||
sk_plr_dmg_pistol "20" | sk_plr_dmg_pistol "20" | ||
sk_npc_dmg_pistol "15" | sk_npc_dmg_pistol "15" | ||
sk_max_pistol "148" | sk_max_pistol "148" | ||
THis weapon doesn't shoot with normal bullets but with a laser so it will do a bigger damage to the enemy. | THis weapon doesn't shoot with normal bullets but with a laser so it will do a bigger damage to the enemy. | ||
END | END | ||
I hope this helps u a bit | I hope this helps u a bit | ||
Speedlly (Scubic) | Speedlly (Scubic) | ||
=> this weapon (or a part of it) is going to play a role in the game that were maken (Cubic Life) | => this weapon (or a part of it) is going to play a role in the game that were maken (Cubic Life) |
Revision as of 12:53, 8 November 2009
How to make a the pistol shoot with a laser: Laser Pistol!
1 Open pistol.cpp
1.1 Add this under includes "gamestat.h":
#include "beam_shared.h"
#include "ammodef.h"
#define PHYSCANNON_BEAM_SPRITE "sprites/orangelight1.vmt"
beam_shared.h defines alot abount beams
ammodef.h is needed for the trace of the laser
the PHYSCANNON_BEAM_SPRITE defines what sprite is used, if u change the vmt u can make the laser have another color
1.2 Add in public (under DECLARE_SERVERCLASS();):
void DrawBeam( const Vector &startPos, const Vector &endPos, float width );
void DoImpactEffect( trace_t &tr, int nDamageType );
DrawBeam and DoImpactEffect are new parts that we will put in the script
1.3 Add in private (under DECLARE_ACTTABLE();):
int m_nBulletType;
m_nBulletType is a variable that we will use in the script
1.4 Add under BEGIN_DATADESC( CWeaponPistol ):
DEFINE_FIELD( m_nBulletType, FIELD_INTEGER ),
an extra define of m_nBulletType
1.5 Change:
void PrimaryAttack( void );
to
void PrimaryAttack( trace_t &tr, int nDamageType, CBaseCombatCharacter *pOperator );
We will need trace_t &tr, int nDamageType, CBaseCombatCharacter *pOperator in the Primaryattack part
1.6 Go to
CWeaponPistol::CWeaponPistol( void )
Add:
m_nBulletType = -1;
1.7 Scroll down to:
void CWeaponPistol::PrimaryAttack( void )
and change it to
void CWeaponPistol::PrimaryAttack( trace_t &tr, int nDamageType, CBaseCombatCharacter *pOperator )
We will need trace_t &tr, int nDamageType, CBaseCombatCharacter *pOperator in this part
1.8 After
m_iPrimaryAttacks++;
gamestats->Event_WeaponFired( pOwner, true, GetClassname() );
Add:
Vector vecShootOrigin, vecShootDir;
vecShootOrigin = pOperator->Weapon_ShootPosition();
DrawBeam( vecShootOrigin, tr.endpos, 15.5 );
We say that hl2 has to draw a beam from vecShootOrigin to tr.endpos
1.9 Scroll down to the end of the script, add:
//-----------------------------------------------------------------------------
// Purpose:
// Input : &startPos -
// &endPos -
// width -
// useMuzzle -
//-----------------------------------------------------------------------------
void CWeaponPistol::DrawBeam( const Vector &startPos, const Vector &endPos, float width )
{
//Tracer down the middle
UTIL_Tracer( startPos, endPos, 0, TRACER_DONT_USE_ATTACHMENT, 6500, false, "GaussTracer" );
//Draw the main beam shaft
CBeam *pBeam = CBeam::BeamCreate( PHYSCANNON_BEAM_SPRITE, 15.5 );
pBeam->SetStartPos( startPos );
pBeam->PointEntInit( endPos, this );
pBeam->SetEndAttachment( LookupAttachment("Muzzle") );
pBeam->SetWidth( width );
// pBeam->SetEndWidth( 0.05f );
pBeam->SetBrightness( 255 );
pBeam->SetColor( 255, 185+random->RandomInt( -16, 16 ), 40 );
pBeam->RelinkBeam();
pBeam->LiveForTime( 0.1f );
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : &tr -
// nDamageType -
//-----------------------------------------------------------------------------
void CWeaponSniperRifle::DoImpactEffect( trace_t &tr, int nDamageType )
{
//Draw our beam
DrawBeam( tr.startpos, tr.endpos, 15.5 );
if ( (tr.surface.flags & SURF_SKY) == false )
{
CPVSFilter filter( tr.endpos );
te->GaussExplosion( filter, 0.0f, tr.endpos, tr.plane.normal, 0 );
m_nBulletType = GetAmmoDef()->Index("GaussEnergy");
UTIL_ImpactTrace( &tr, m_nBulletType );
}
}
We define the beam
2 Open hl2_gamerules.cpp
Change
def.AddAmmoType("Pistol", DMG_BULLET, TRACER_LINE_AND_WHIZ, "sk_plr_dmg_pistol", "sk_npc_dmg_pistol", "sk_max_pistol", BULLET_IMPULSE(200, 1225), 0 );
to
def.AddAmmoType("Pistol", DMG_DISSOLVE, TRACER_NONE, "sk_plr_dmg_pistol", "sk_npc_dmg_pistol", "sk_max_pistol", BULLET_IMPULSE(200, 1225), 0 );
If the enemy dies, he will dissolve and there dont draw a line after the bullet
3 Open \Steam\steamapps\SourceMods\MyMod\scripts\weapon_pistol.txt
3.1 Change
"printname" "#HL2_Pistol"
to
"printname" "LASER PISTOL"
We change the name in the bucket
3.1 If u know how u can change the SoundData so it will make a better noise
4 Open \Steam\steamapps\SourceMods\MyMod\cfg\skill.cfg
Change
sk_plr_dmg_pistol "5"
sk_npc_dmg_pistol "3"
sk_max_pistol "148"
to
sk_plr_dmg_pistol "20"
sk_npc_dmg_pistol "15"
sk_max_pistol "148"
THis weapon doesn't shoot with normal bullets but with a laser so it will do a bigger damage to the enemy.
END
I hope this helps u a bit
Speedlly (Scubic)
=> this weapon (or a part of it) is going to play a role in the game that were maken (Cubic Life)