Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name ArTech GG5
- @inputs [Gun Gun2 Base TBase]:entity [Active R PrevWeapon NextWeapon Shift Light]:number [CamRanger]:ranger
- @outputs [Position]:vector
- @outputs [Weld FOV Distance FLIR]:number
- @outputs [Self Parent]:entity
- @outputs [Filter]:array
- @persist [Inertia Inertia2 GunAng GunAng2]:angle
- @persist [Offset ZoomOffset]:vector
- @persist [MaxElevation MaxDepression MinYaw MaxYaw RotateSpeed Unlock CamToggle Dist]:number
- @persist [MaxElevation2 MaxDepression2 MinYaw2 MaxYaw2 RotateSpeed2]:number
- @trigger Active PrevWeapon NextWeapon R Shift Light
- #@model models/cheeze/pcb2/pcb1.mdl
- # Version 1.0.2
- if ( changed(Active) ) {
- # Camera settings
- Offset = vec(0, 0, 40) # cam pos relative to turret base
- ZoomOffset = vec(50,-10,10) # cam pos when zoomed in relative to gun
- Distance = 230 # cam radius
- # Main gun settings
- MaxElevation = 20
- MaxDepression = 10
- MinYaw = 360
- MaxYaw = 360
- RotateSpeed = 40 # Degrees per second
- # Secondary gun settings - Optional and only applies if you have a second gun
- MaxElevation2 = 45
- MaxDepression2 = 10
- MinYaw2 = 360
- MaxYaw2 = 360
- RotateSpeed2 = 120 # Degrees per second
- # Automatic settings do not touch these no reason to
- Self = Base
- Parent = TBase
- Filter = entity():getConstraints() # Ranger filter
- Filter:pushEntity(Gun)
- Filter:pushEntity(Base)
- Filter:pushEntity(TBase)
- Filter:pushEntity(Gun2)
- GunAng = Self:toLocal(Gun:angles())
- GunAng2 = Self:toLocal(Gun2:angles())
- MinYaw *= -1
- MinYaw2 *= -1
- MaxElevation*= -1
- MaxElevation2*= -1
- RotateSpeed /= 20
- RotateSpeed2 /= 20
- Inertia = shiftL(ang(Gun:inertia())):setRoll(0)
- Inertia2 = shiftL(ang(Gun2:inertia())):setRoll(0)
- Weld = 1
- Unlock = 0
- FOV = 90
- Dist = Distance
- Position = TBase:massCenter() + Offset
- }
- elseif ( inputClk() ) {
- if( PrevWeapon ) { FOV = max(FOV/2, 5) }
- elseif ( NextWeapon ) { FOV = min(FOV*2, 90) }
- elseif( changed(R) & R ) {
- if ( Unlock ) { Unlock = 0 }
- else { Unlock = 1 , interval(50) }
- Weld = !Unlock
- }
- elseif( changed(Shift) & Shift) {
- CamToggle = !CamToggle
- Position = CamToggle ? Gun:toWorld(ZoomOffset) : TBase:massCenter() + Offset
- Distance = CamToggle ? 0 : Dist
- FOV = 90
- Parent = CamToggle ? Gun : TBase
- }
- elseif(changed(Light)&Light){
- FLIR = !FLIR
- }
- }
- if ( Unlock & clk() ) {
- GunDir = (CamRanger:pos() - Gun:pos()):normalized()
- GunAng = angnorm(clamp(GunAng - clamp(heading(vec(), GunAng, Self:toLocalAxis(GunDir)), -RotateSpeed, RotateSpeed), ang(MaxElevation, MinYaw, 0), ang(MaxDepression, MaxYaw, 0)))
- Ang = -heading(vec(), Gun:angles(), Self:toWorld(GunAng):forward())
- Gun:applyAngForce((Ang* 450 - Gun:angVel() * 35) * Inertia)
- if(Gun2){
- GunDir2 = (CamRanger:pos() - Gun2:pos()):normalized()
- GunAng2 = angnorm(clamp(GunAng2 - clamp(heading(vec(), GunAng2, Self:toLocalAxis(GunDir2)), -RotateSpeed2, RotateSpeed2), ang(MaxElevation2, MinYaw2, 0), ang(MaxDepression2, MaxYaw2, 0)))
- Ang2 = -heading(vec(), Gun2:angles(), Self:toWorld(GunAng2):forward())
- Gun2:applyAngForce((Ang2* 450 - Gun2:angVel() * 35) * Inertia2)
- }
- interval(50)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement