Skip to content

Instantly share code, notes, and snippets.

@Cheatoid
Last active December 5, 2020 07:29
Show Gist options
  • Save Cheatoid/2e3dd9802fb0153dac46f09f2dc7a0b2 to your computer and use it in GitHub Desktop.
Save Cheatoid/2e3dd9802fb0153dac46f09f2dc7a0b2 to your computer and use it in GitHub Desktop.
[E2] A quick code to test <rangerOffsetManual> function
@outputs Trace:ranger
@model models/hunter/misc/cone1x05.mdl
if ( first() )
{
    holoCreate( 1 )
    holoModel( 1, "hq_tube" )
    holoColor( 1, vec4( 230, 10, 230, 200 ) )
    runOnTick( 1 )
}
StartPos = entity():toWorld( vec( 0, 0, entity():aabbSize():z() ) )
Trace = rangerOffsetManual( StartPos, entity():toWorld( vec( 0, 0, 100 ) ), array( entity() ) )
HitPos = Trace:pos()
Dir = HitPos - StartPos
Rot = angnorm( ( matrix( Dir:toAngle() ) * matrix( ang( 90, 0, 0 ) ) ):toAngle() )
Radius = Dir * 0.5
Median = StartPos + Radius
holoPos( 1, Median )
holoAng( 1, Rot )
holoScaleUnits( 1, vec( 3, 3, Dir:length() ) )
setName( format(
    "Did trace hit anything? %s\nHit world? %s\nHit entity: %s\nHit group: %s\nHit texture: %q",
    Trace:hit() ? "Yes" : "No",
    Trace:hitWorld() ? "Yes" : "No",
    Trace:entity(),
    Trace:hitGroup(),
    Trace:hitTexture()
) )

screenshot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment