Raised This Month: $12 Target: $400
 3% 

TR_TraceRayFilter Help - Move beam relative to player angle


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 06-06-2020 , 10:59   TR_TraceRayFilter Help - Move beam relative to player angle
Reply With Quote #1

If you run this code, 4 colored beams show surrounding you like a box. Right now, the box just moves with you which is only half of the idea. What I am trying to do is have each beam also rotate in the same direction if you move your mouse left or right. In other words, we should always have the same color beams showing in the same position relative to the player if they turn. The "box" should always be facing the same way as the player is turning. I am unsure how to go about this.

Using GetClientEyeAngles(client, fAngles), and then using the fAngles[1] vector seem to accomplish that movement, just not sure how to work it into the rest of the code to do what I want.

Thanks for any help!

PHP Code:
#include <sourcemod>
#include <sdktools>


int beammdl;
float g_fCmdWait[MAXPLAYERS+1];

public 
OnMapStart() {
    
beammdl PrecacheModel("materials/sprites/laserbeam.vmt"true); 
}

public 
Action OnPlayerRunCmd(int clientintbuttonsintimpulsefloat vel[3], float angles[3], intweaponintsubtypeintcmdnuminttickcountintseedint mouse[2]) {
    if(
g_fCmdWait[client] > GetGameTime()) { return Plugin_Continue; }

    
DrawBox(client);
    
g_fCmdWait[client] = GetGameTime() + 0.1;

    return 
Plugin_Continue;
}

DrawBox(client) {
    
decl Float:fBeamStart[3];
    
decl Float:fBeamEnd[3];
    
decl Float:fAngles[3];
    
decl iColor[4];
    
    
GetClientAbsOrigin(clientfBeamStart);
    
GetClientEyeAngles(clientfAngles);

    
fBeamStart[0] += 16.0;
    
fBeamStart[1] += 16.0;
    
    
fAngles[0] = -90.0;
    
    
iColor[0] = 255;
    
iColor[1] = 0;
    
iColor[2] = 0;
    
iColor[3] = 255;

    for(
int i<= 3i++) {
        switch (
i) {
            case 
1: { 
                
fBeamStart[0] -= 32.0;
                
iColor[0] = 0;
                
iColor[1] = 255;
                
iColor[2] = 0;
            }
            case 
2: { 
                
fBeamStart[1] -= 32.0;
                
iColor[0] = 0;
                
iColor[1] = 255;
                
iColor[2] = 255;
            }
            case 
3: { 
                
fBeamStart[0] += 32.0;
                
iColor[0] = 255;
                
iColor[1] = 255;
                
iColor[2] = 0;        
            }
        }

        
TR_TraceRayFilter(fBeamStartfAnglesMASK_SHOTRayType_InfiniteTraceEntityFilterclient);
        
TR_GetEndPosition(fBeamEnd);

        
TE_SetupBeamPoints(fBeamStartfBeamEndbeammdl0000.11.01.010.0iColor1); 
        
TE_SendToAll();
    }
}

public 
bool TraceEntityFilter(int entityint maskany data){
    if (
entity == data)
        return 
false;
    return 
true;

__________________
{__ PIRATES COVE __} ● HIGH-KILL Community | Stats ●
Half-Life 2: Deathmatch
66.151.244.149:27016 => CONNECT
scorpius2k1 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:45.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode