b=0 charge = 0 -- Called when the weapon is created. function onInit( ) _SWEPSetSound( MyIndex, "single_shot", "NPC_Strider.Shoot" ); end -- Called every frame function onThink( ) if( _PlayerIsKeyDown( Owner, IN_ATTACK2) ==false ) and charge > 0 then charge = 0 _EntEmitSound( Owner, "vehicles/apc/apc_shutdown.wav" ) end end -- function onPrimaryAttack( ) charge=0 local vPlayerAng = _PlayerGetShootAng( Owner ); if (vPlayerAng == nil) then _Msg("Playerang was null!\n") return; end; local vPlayerVel = vecMul( vPlayerAng, vector3(-600, -600, -600) ); --_EntSetVelocity( Owner, vPlayerVel ); if ( _PlayerInfo( Owner, "connected" ) == false ) then return; end if ( _PlayerInfo( Owner, "alive" ) == false ) then return; end local vPlayerAng = _PlayerGetShootAng( Owner ); if (vPlayerAng == nil) then _Msg("Playerang was null!\n") return; end; local vecpos = _PlayerGetShootPos( Owner ); local plyang = _PlayerGetShootAng( Owner ); local plyright = _EntGetRightVector( Owner ); _TraceLine( vecpos, plyang, 80000, Owner ); local hitpos = _TraceEndPos(); if ( _TraceHit() == false ) then hitpos = vecAdd( vecpos, vecMul( plyang, vector3(80000,80000,80000) ) ) end --Finaly! The bullets come out of the barrel of the gun! Huzzah! vecpos = vecAdd( vecpos, vector3( 0, 0, -20 ) ); plyright = vecAdd( plyright, vector3( 0, 0, 0 ) ); local muzzlepos = vecAdd( vecpos, vecMul( plyright, vector3(35,35,0))) --EXPLOSIONS! SPLASH DAMAGE! YAY! local lasExplode = _EntCreate( "env_explosion" ) _EntSetKeyValue( lasExplode, "iMagnitude", 140 ) _EntSetPos( lasExplode, hitpos ) _EntSpawn( lasExplode ) _EntFire( lasExplode, "Explode", "", 0 ) local LazStart = _EntCreate( "info_target" ); _EntSetPos( LazStart, muzzlepos ); _EntSetName( LazStart, "LazStart" ); local LazEnd = _EntCreate( "info_target" ); _EntSetPos( LazEnd, hitpos ); _EntSetName( LazEnd, "LazEnd" ); local LazBeam = _EntCreate( "env_beam" ); _EntPrecacheModel("sprites/lgtning.spr"); _EntSetName( LazBeam, "LazBeam" ); --I HATE SETTING KEYVALUES _EntSetKeyValue( LazBeam, "texture", "sprites/lgtning.spr" ); _EntSetKeyValue( LazBeam, "renderamt", 255 ); _EntSetKeyValue( LazBeam, "rendercolor", "255 255 255" ); _EntSetKeyValue( LazBeam, "life", 1.5 ); _EntSetKeyValue( LazBeam, "damage", 0 ); _EntSetKeyValue( LazBeam, "LightningStart", "LazStart" ); _EntSetKeyValue( LazBeam, "LightningEnd", "LazEnd" ); _EntSetKeyValue( LazBeam, "spawnflags", 1 ); _EntSetKeyValue( LazBeam, "TouchType", 0 ); _EntSetKeyValue( LazBeam, "framestart", 0 ); _EntSetKeyValue( LazBeam, "framerate", 0 ); _EntSetKeyValue( LazBeam, "NoiseAmplitude", 6 ); _EntSetKeyValue( LazBeam, "TextureScroll", 35 ); _EntSetKeyValue( LazBeam, "BoltWidth", 1 ); _EntSetKeyValue( LazBeam, "Radius", 256 ); _EntSetKeyValue( LazBeam, "StrikeTime", 1 ); local LazBeam2 = _EntCreate( "env_beam" ); _EntPrecacheModel("effects/tp_beam001.spr"); _EntSetName( LazBeam2, "LazBeam2" ); _EntSetKeyValue( LazBeam2, "texture", "tp_beam001.spr" ); _EntSetKeyValue( LazBeam2, "renderamt", 255 ); _EntSetKeyValue( LazBeam2, "rendercolor", "255 255 255" ); _EntSetKeyValue( LazBeam2, "life", 0.5 ); _EntSetKeyValue( LazBeam2, "damage", 0 ); _EntSetKeyValue( LazBeam2, "LightningStart", "LazStart" ); _EntSetKeyValue( LazBeam2, "LightningEnd", "LazEnd" ); _EntSetKeyValue( LazBeam2, "spawnflags", 0 ); _EntSetKeyValue( LazBeam2, "TouchType", 0 ); _EntSetKeyValue( LazBeam2, "framestart", 0 ); _EntSetKeyValue( LazBeam2, "framerate", 0 ); _EntSetKeyValue( LazBeam2, "NoiseAmplitude", 0 ); _EntSetKeyValue( LazBeam2, "TextureScroll", 35 ); _EntSetKeyValue( LazBeam2, "BoltWidth", 30 ); _EntSetKeyValue( LazBeam2, "Radius", 256 ); _EntSetKeyValue( LazBeam2, "StrikeTime", 1 ); _EntFire( LazBeam, "turnon", "", ""); _EntFire( LazBeam2, "turnon", "", ""); _EntSpawn( LazStart ); _EntSpawn( LazEnd ); _EntSpawn( LazBeam ); _EntSpawn( LazBeam2 ); _EntFire( LazBeam, "kill", "", 0.2); _EntFire( LazBeam2, "kill", "", 4.2); _EntFire( LazStart, "kill", "", 0.2 ); _EntFire( LazEnd, "kill", "", 0.2 ); --Huge motherfucking laser! _EffectInit(); _EffectSetEnt( Owner ); _EffectSetOrigin( hitpos ); _EffectSetStart( muzzlepos ); _EffectSetMagnitude( 3); _EffectDispatch( "FadingLineTeam" ); _EffectSetMagnitude( 4 ); _EffectSetScale( 200 ); _EffectDispatch( "FadingLineTeam" ); _EffectSetMagnitude( 2 ); _EffectSetScale( 200 ); _EffectDispatch( "FadingLineTeam" ); _EffectSetMagnitude( 9 ); _EffectSetScale( 10 ); _EffectDispatch( "Explosion" ); -- _EntRemove( lasExplode ) end -- Secondary gives ammo function onSecondaryAttack() local chargesound = "weapons/physcannon/energy_bounce1.wav" if(charge>=0)then _EntEmitSoundEx(Owner, chargesound, 1, (charge/11)); end charge = charge+1 if( charge > 30 )then local vPlayerAng = _PlayerGetShootAng( Owner ); if (vPlayerAng == nil) then _Msg("Playerang was null!\n") return; end; local vPlayerVel = vecMul( vPlayerAng, vector3(-2000, -2000, -2000) ); --_EntSetVelocity( Owner, vPlayerVel ); if ( _PlayerInfo( Owner, "connected" ) == false ) then return; end if ( _PlayerInfo( Owner, "alive" ) == false ) then return; end local vPlayerAng = _PlayerGetShootAng( Owner ); if (vPlayerAng == nil) then _Msg("Playerang was null!\n") return; end; local vecpos = _PlayerGetShootPos( Owner ); local plyang = _PlayerGetShootAng( Owner ); local plyright = _EntGetRightVector( Owner ); _TraceLine( vecpos, plyang, 80000, Owner ); local hitpos = _TraceEndPos(); if ( _TraceHit() == false ) then hitpos = vecAdd( vecpos, vecMul( plyang, vector3(80000,80000,80000) ) ) end vecpos = vecAdd( vecpos, vector3( 0, 0, -20 ) ); plyright = vecAdd( plyright, vector3( 0, 0, 0 ) ); local muzzlepos = vecAdd( vecpos, vecMul( plyright, vector3(35,35,0))) --EXPLOSIONS! SPLASH DAMAGE! YAY! local lasExplode = _EntCreate( "env_explosion" ) _EntSetKeyValue( lasExplode, "iMagnitude", 250 ) _EntSetPos( lasExplode, hitpos ) _EntSpawn( lasExplode ) _EntFire( lasExplode, "Explode", "", 0 ) local LazStart = _EntCreate( "info_target" ); _EntSetPos( LazStart, muzzlepos ); _EntSetName( LazStart, "LazStart" ); local LazEnd = _EntCreate( "info_target" ); _EntSetPos( LazEnd, hitpos ); _EntSetName( LazEnd, "LazEnd" ); if( _TraceHitNonWorld() ==true)then _EntSetPos( LazEnd, vecAdd( hitpos, vecMul( plyang, vector3( 500, 500, 500 ) ) )); else _EntSetPos( LazEnd, hitpos); end local LazBeam = _EntCreate( "env_beam" ); _EntPrecacheModel("sprites/plasmabeam.spr"); _EntSetName( LazBeam, "LazBeam" ); --I HATE SETTING KEYVALUES _EntSetKeyValue( LazBeam, "texture", "sprites/plasmabeam.spr" ); _EntSetKeyValue( LazBeam, "renderamt", 255 ); _EntSetKeyValue( LazBeam, "rendercolor", "255 255 255" ); _EntSetKeyValue( LazBeam, "life", 0.5 ); _EntSetKeyValue( LazBeam, "damage", 300 ); _EntSetKeyValue( LazBeam, "LightningStart", "LazStart" ); _EntSetKeyValue( LazBeam, "LightningEnd", "LazEnd" ); _EntSetKeyValue( LazBeam, "spawnflags", 1 ); _EntSetKeyValue( LazBeam, "TouchType", 0 ); _EntSetKeyValue( LazBeam, "framestart", 0 ); _EntSetKeyValue( LazBeam, "framerate", 0 ); _EntSetKeyValue( LazBeam, "NoiseAmplitude", 2 ); _EntSetKeyValue( LazBeam, "TextureScroll", 35 ); _EntSetKeyValue( LazBeam, "BoltWidth", 100 ); _EntSetKeyValue( LazBeam, "Radius", 256 ); _EntSetKeyValue( LazBeam, "StrikeTime", 1 ); local LazBeam2 = _EntCreate( "env_beam" ); _EntPrecacheModel("sprites/physbeam.spr"); _EntSetName( LazBeam2, "LazBeam2" ); _EntSetKeyValue( LazBeam2, "texture", "sprites/physbeam.spr" ); _EntSetKeyValue( LazBeam2, "renderamt", 255 ); _EntSetKeyValue( LazBeam2, "rendercolor", "255 255 255" ); _EntSetKeyValue( LazBeam2, "life", 0.5 ); _EntSetKeyValue( LazBeam2, "damage", 300 ); _EntSetKeyValue( LazBeam2, "LightningStart", "LazStart" ); _EntSetKeyValue( LazBeam2, "LightningEnd", "LazEnd" ); _EntSetKeyValue( LazBeam2, "spawnflags", 0 ); _EntSetKeyValue( LazBeam2, "TouchType", 0 ); _EntSetKeyValue( LazBeam2, "framestart", 0 ); _EntSetKeyValue( LazBeam2, "framerate", 0 ); _EntSetKeyValue( LazBeam2, "NoiseAmplitude", 0 ); _EntSetKeyValue( LazBeam2, "TextureScroll", 25 ); _EntSetKeyValue( LazBeam2, "BoltWidth", 80 ); _EntSetKeyValue( LazBeam2, "Radius", 256 ); _EntSetKeyValue( LazBeam2, "StrikeTime", 1 ); _EntFire( LazBeam, "turnon", "", ""); _EntFire( LazBeam2, "turnon", "", ""); _EntSpawn( LazStart ); _EntSpawn( LazEnd ); _EntSpawn( LazBeam ); _EntSpawn( LazBeam2 ); _EntFire( LazBeam, "kill", "", 0.2); _EntFire( LazBeam2, "kill", "", 4.2); _EntFire( LazStart, "kill", "", 0.2 ); _EntFire( LazEnd, "kill", "", 0.2 ); _EffectInit(); _EffectSetEnt( Owner ); _EffectSetOrigin( hitpos ); _EffectSetStart( muzzlepos ); _EffectSetMagnitude( 3); _EffectDispatch( "FadingLineTeam" ); _EffectSetMagnitude( 4 ); _EffectSetScale( 500 ); _EffectDispatch( "FadingLineTeam" ); _EffectSetMagnitude( 2 ); _EffectSetScale( 500 ); _EffectDispatch( "FadingLineTeam" ); _EffectInit(); _EffectSetEnt( Owner ); _EffectSetOrigin( hitpos ); _EffectSetStart( hitpos ); _EffectSetMagnitude( 500 ); _EffectSetScale( 500 ); _EffectDispatch( "AR2Explosion" ); _EntEmitSound( Owner, "ambient/levels/labs/electric_explosion1.wav" ) _EntEmitSound( Owner, "beams/beamstart5.wav" ) charge=0 _SWEPUseAmmo(MyIndex,0,5) end end -- Weapon settings. -- These are only accessed once when setting the weapon up function getWeaponSwapHands() return false; end function getWeaponFOV() return 55; end function getWeaponSlot() return 4; end function getWeaponSlotPos() return 7; end function getFiresUnderwater() return false; end function getReloadsSingly() return false; end function getDamage() return 700; end function getPrimaryShotDelay() return 0.0001; end function getSecondaryShotDelay() return 0.01; end function getPrimaryIsAutomatic() return true; end function getSecondaryIsAutomatic() return true; end function getBulletSpread() return vector3( 0.0, 0.0, 0.0 ); end function getViewKick() return vector3( -15, 0, 0); end function getViewKickRandom() return vector3( 0, 0, 0 ); end function getBulletSpreadSecondary() return vector3( 0.001, 0.001, 0.001 ); end function getViewKickSecondary() return vector3( 0.0, 0.0, 0.0); end function getViewKickRandomSecondary() return vector3( 0.0, 0.0, 0.0 ); end function getViewModel( ) return "models/weapons/v_rpg.mdl"; end function getWorldModel( ) return "models/weapons/w_rocket_launcher.mdl"; end function getClassName() return "weapon_lasercannon"; end function getPrimaryAmmoType() return "357"; end function getSecondaryAmmoType() return "357"; end -- return -1 if it doesn't use clips function getMaxClipPrimary() return 9999; end function getMaxClipSecondary() return -1; end -- ammo in gun by default function getDefClipPrimary() return 9999; end function getDefClipSecondary() return -1; end -- pistol, smg, ar2, shotgun, rpg, phys, crossbow, melee, slam, grenade function getAnimPrefix() return "rpg"; end function getPrintName() return "Laser Cannon"; end function getHUDMaterial( ) return "gmod/SWEP/weapon_laserdance"; end -- 0 = Don't override, shoot bullets, make sound and flash -- 1 = Don't shoot bullets but do make flash/sounds -- 2 = Only play animations -- 3 = Don't do anything function getPrimaryScriptOverride() return 0; end function getSecondaryScriptOverride() return 3; end