View Single Post
Author Message
Skippy
Senior Member
Join Date: Nov 2011
Old 01-15-2014 , 19:37   Rocket Bounce Sphere Surface
Reply With Quote #1

I have this Sphere that I created and I want rockets to reflect off of the surface of the sphere. The thing is I can't use on start touch with the rocket and have it reflect off because there isn't technically a surface. But what I coded is when the rocket gets within the sphere radius then do the reflect but it doesn't reflect properly. (I literally just copied and pasted the code from Rocket Bounce)

PHP Code:
public Action:Timer_Rocket(Handle:timerany:entref)
{
    new 
entity EntRefToEntIndex(entref);
    
    if(
IsValidEntity(entity))
    {
        
decl Float:vOrigin[3];
        
GetEntPropVector(entityProp_Data"m_vecOrigin"vOrigin);
    
        
decl Float:vAngles[3];
        
GetEntPropVector(entityProp_Data"m_angRotation"vAngles);
    
        
decl Float:vVelocity[3];
        
GetEntPropVector(entityProp_Data"m_vecAbsVelocity"vVelocity);
    
        new 
Handle:trace TR_TraceRayFilterEx(vOriginvAnglesMASK_SHOTRayType_InfiniteTEF_ExcludeEntityentity);
    
        if(!
TR_DidHit(trace))
        {
            
CloseHandle(trace);
            return 
Plugin_Continue;
        }
    
        
decl Float:vNormal[3];
        
TR_GetPlaneNormal(tracevNormal);
    
        
CloseHandle(trace);
    
        new 
Float:dotProduct GetVectorDotProduct(vNormalvVelocity);
    
        
ScaleVector(vNormaldotProduct);
        
ScaleVector(vNormal2.0);
    
        
decl Float:vBounceVec[3];
        
SubtractVectors(vVelocityvNormalvBounceVec);
    
        
decl Float:vNewAngles[3];
        
GetVectorAngles(vBounceVecvNewAngles);
        
        if(
GetVectorDistance(coordvOrigin) < sphereRadius 5.0//Hitting Sphere
        
{
            
TeleportEntity(entityNULL_VECTORvNewAnglesvBounceVec);
        }    
    }
    return 
Plugin_Continue;

__________________
Plugins:
[Any] Aim Menu

Want a TF2 plugin? Feel free to pm me to discuss it.

Last edited by Skippy; 01-15-2014 at 19:39.
Skippy is offline