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

How to create a cube shaped beam?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
eyal282
Veteran Member
Join Date: Aug 2011
Old 12-07-2019 , 04:41   How to create a cube shaped beam?
Reply With Quote #1

Title, with TE_SetupBeamPoints or something similar
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline
Chrissy
Member
Join Date: May 2013
Old 12-07-2019 , 15:25   Re: How to create a cube shaped beam?
Reply With Quote #2

Code:
void CreateZonePoints(float vPoints[8][3])
{
    for(int i = 1; i < 7; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            vPoints[i][j] = vPoints[((i >> (2 - j)) & 1) * 7][j];
        }
    }
} 

void DrawZone(int iClient, float vPoints[8][3], float fLife)
{
    for(int i, i2 = 3; i2 >= 0; i += i2--)
    {
        for(int j = 1; j <= 7; j += (j / 2) + 1)
        {
            if(j != 7 - i)
            {
                TE_SetupBeamPoints(vPoints[i], vPoints[j], g_iBeamSprite, g_iHaloSprite, 0, 0, fLife, 2.0, 2.0, 0, 0.0, g_iZoneColor, 0);
				
                if(IsValidClient(iClient))
		{
			TE_SendToClient(iClient, 0.0);
		}
		else
		{
			TE_SendToAll(0.0);
		}
            }
        }
    }
}
This is what I have. It's a bit different but I believe the credit goes to blacky. Simply pass an array[8] with points [0] and [7] being the two opposite corners.

Last edited by Chrissy; 12-07-2019 at 15:27.
Chrissy is offline
foxhound27
AlliedModders Donor
Join Date: Sep 2019
Location: Argentina
Old 12-18-2019 , 15:49   Re: How to create a cube shaped beam?
Reply With Quote #3

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

//code by darwin2154 

int g_Glow;
int g_Laser;

public 
void OnPluginStart(){

RegConsoleCmd("sm_cube"Cube);

}


public 
void OnMapStart() 


g_Glow PrecacheModel("particle/particle_glow_10.vmt");  
g_Laser PrecacheModel("materials/sprites/laserbeam.vmt"); 

}


public 
Action Cube(int clientint args)
{
  
float center[3];
  
GetEntPropVector(clientProp_Send"m_vecOrigin"center);
  
  
float one[3], two[3], three[3], four[3];
  
float oneh[3], twoh[3], threeh[3], fourh[3];
  
int Num 4// Number of points around a given position
    
    
int Degrees 360;  //Degrees in a circle
    
int Coeff    0;  //coefficient
    
int Mul      50;  
    
    
float point;
    
     
point DegToRad(float(* (Degrees Num) + Coeff)); 
      
     
//calculate the top first point
     
     
oneh[0] = center[0] + Sine(point) * Mul;  //Honestly, I don’t know how he calculates. In geometry is not strong. Ask the tail, this is its code.
     
oneh[1] = center[1] + Cosine(point) * Mul
     
oneh[2] = center[2] + 100.0// 50.0 - Cell height
     
     
one[0] = oneh[0]; //We get the bottom point
     
one[1] = oneh[1];
     
one[2] = center[2]; //Because if it’s lower, then the height will be like the center.
     
     
TE_SetupBeamPoints(oneonehg_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30); //We create vertical lasers connecting our 2 points.
     
TE_SendToAll();
      

     
     
point DegToRad(float(* (Degrees Num) + Coeff)); 
     
         
//calculate 2 points
         
     
twoh[0] = center[0] + Sine(point) * Mul
     
twoh[1] = center[1] + Cosine(point) * Mul
     
twoh[2] = center[2] + 100.0
     
     
two[0] = twoh[0];
     
two[1] = twoh[1];
     
two[2] = center[2];
     
     
TE_SetupBeamPoints(twotwohg_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30); //We create vertical lasers connecting our 2 points.
     
TE_SendToAll();
     
     
     
point DegToRad(float(* (Degrees Num) + Coeff)); 
        
     
//calculate 3 point    
        
     
threeh[0] = center[0] + Sine(point) * Mul
     
threeh[1] = center[1] + Cosine(point) * Mul
     
threeh[2] = center[2] + 100.0
     
     
three[0] = threeh[0];
     
three[1] = threeh[1];
     
three[2] = center[2];
     
     
TE_SetupBeamPoints(threethreehg_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30);
     
TE_SendToAll();
     
     
point DegToRad(float(* (Degrees Num) + Coeff)); 
        
        
//calculate 4 point
        
     
fourh[0] = center[0] + Sine(point) * Mul
     
fourh[1] = center[1] + Cosine(point) * Mul
     
fourh[2] = center[2] + 100.0
     
     
four[0] = fourh[0];
     
four[1] = fourh[1];
     
four[2] = center[2];
     
     
TE_SetupBeamPoints(fourfourhg_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30);
     
TE_SendToAll();
     
     
TE_SetupBeamPoints(onetwog_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30);  //We connect the lower points in a circle: 1 with 2, 2 with 3, 3 with 4, 4 with 1.
     
TE_SendToAll();
     
TE_SetupBeamPoints(twothreeg_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30);
     
TE_SendToAll();
     
TE_SetupBeamPoints(threefourg_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30);
     
TE_SendToAll();
     
TE_SetupBeamPoints(fouroneg_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30);
     
TE_SendToAll();
     
     
TE_SetupBeamPoints(onehtwohg_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30);  //We connect the lower points in a circle: 1 with 2, 2 with 3, 3 with 4.4 s 1.
     
TE_SendToAll();
     
TE_SetupBeamPoints(twohthreehg_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30);
     
TE_SendToAll();
     
TE_SetupBeamPoints(threehfourhg_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30);
     
TE_SendToAll();
     
TE_SetupBeamPoints(fourhonehg_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30);
     
TE_SendToAll();
     
     
//Connect the points of the side faces with each other with a cross.
     
TE_SetupBeamPoints(onehtwog_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30);  //We connect the lower points in a circle: 1 with 2, 2 with 3, 3 with 4.4 s 1.
     
TE_SendToAll();
     
TE_SetupBeamPoints(twohoneg_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30);
     
TE_SendToAll();
     
TE_SetupBeamPoints(twohthreeg_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30);
     
TE_SendToAll();
     
TE_SetupBeamPoints(threehtwog_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30);
     
TE_SendToAll();
     
TE_SetupBeamPoints(threehfourg_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30);
     
TE_SendToAll();
     
TE_SetupBeamPoints(fourhthreeg_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30);
     
TE_SendToAll();
     
TE_SetupBeamPoints(fourhoneg_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30);
     
TE_SendToAll();
     
TE_SetupBeamPoints(onehfourg_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30);
     
TE_SendToAll();
     
//Now the top points (get a cross)
     
TE_SetupBeamPoints(onehthreehg_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30);
     
TE_SendToAll();
     
TE_SetupBeamPoints(twohfourhg_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30);
     
TE_SendToAll();
     
//And the lower ones also cross
     
TE_SetupBeamPoints(onethreeg_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30);
     
TE_SendToAll();
     
TE_SetupBeamPoints(twofourg_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30);
     
TE_SendToAll();
     
// Who needs it, you can also connect everything inside.
     
TE_SetupBeamPoints(onehthreeg_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30);
     
TE_SendToAll();
     
TE_SetupBeamPoints(twohfourg_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30);
     
TE_SendToAll();
     
TE_SetupBeamPoints(onethreehg_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30);
     
TE_SendToAll();
     
TE_SetupBeamPoints(twofourhg_Laser,0,0,0,10.0,1.0,1.0,10,0.5,{0100255255},30);
     
TE_SendToAll();
     
     
TE_SetupSparks(onehone50010); // Create sparks in vertical lines
     
TE_SendToAll();
     
TE_SetupSparks(twohtwo50010); 
     
TE_SendToAll();
     
TE_SetupSparks(threehthree50010); 
     
TE_SendToAll();
     
TE_SetupSparks(fourhfour50010); 
     
TE_SendToAll();
     
     
center[2] = center[2] + 40.0;
     
TE_SetupGlowSprite(centerg_Glow5.05.020); //Make the glow in the center
     
TE_SendToAll();
     return 
Plugin_Handled;

foxhound27 is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 12-18-2019 , 16:13   Re: How to create a cube shaped beam?
Reply With Quote #4

Again something different:

sm_box in Dev Cmds plugin, using SMLib you can rotate the box to a specific orientation.

PHP Code:
...
    
GetEntPropVector(entityProp_Send"m_vecOrigin"vPos);
    
GetEntPropVector(entityProp_Send"m_vecMaxs"vMaxs);
    
GetEntPropVector(entityProp_Send"m_vecMins"vMins);

    if( 
vMins[0] == vMaxs[0] && vMins[1] == vMaxs[1] && vMins[2] == vMaxs[2] )
    {
        
vMins view_as<float>({ -15.0, -15.0, -15.0 });
        
vMaxs view_as<float>({ 15.015.015.0 });
    }
    else
    {
        
AddVectors(vPosvMaxsvMaxs);
        
AddVectors(vPosvMinsvMins);
    }

    
float vPos1[3], vPos2[3], vPos3[3], vPos4[3], vPos5[3], vPos6[3];
    
vPos1 vMaxs;
    
vPos1[0] = vMins[0];
    
vPos2 vMaxs;
    
vPos2[1] = vMins[1];
    
vPos3 vMaxs;
    
vPos3[2] = vMins[2];
    
vPos4 vMins;
    
vPos4[0] = vMaxs[0];
    
vPos5 vMins;
    
vPos5[1] = vMaxs[1];
    
vPos6 vMins;
    
vPos6[2] = vMaxs[2];

    
TE_SendBeam(vMaxsvPos1);
    
TE_SendBeam(vMaxsvPos2);
    
TE_SendBeam(vMaxsvPos3);
    
TE_SendBeam(vPos6vPos1);
    
TE_SendBeam(vPos6vPos2);
    
TE_SendBeam(vPos6vMins);
    
TE_SendBeam(vPos4vMins);
    
TE_SendBeam(vPos5vMins);
    
TE_SendBeam(vPos5vPos1);
    
TE_SendBeam(vPos5vPos3);
    
TE_SendBeam(vPos4vPos3);
    
TE_SendBeam(vPos4vPos2);
}

stock void TE_SendBeam(const float vMins[3], const float vMaxs[3])
{
    
TE_SetupBeamPoints(vMinsvMaxsg_iLaserIndexg_iHaloIndex005.01.01.010.0, { 25500255 }, 0);
    
TE_SendToAll();

__________________
Silvers is offline
Reply



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 05:03.


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