View Single Post
Author Message
King_OXO
Senior Member
Join Date: Dec 2020
Location: Brazil
Old 11-22-2023 , 20:22   [L4D2]Rotating Objects around player
Reply With Quote #1

Could anyone help me with the rotations of objects with speeds?
I was trying to create a rotation scheme for the tank's rocks, in which they float around the tank, outlining it. There are eight rocks that keep rotating.

PHP Code:
//Spawn Rocks
            
for(int i 1<= 8i++)
        {
            
entity[i] = CreateEntityByName("prop_physics_override");
            if(
entity[i] != -1)
            {
                
char tName[64];
                
Format(tNamesizeof(tName), "TSE%d"client);
                
DispatchKeyValue(client"targetname"tName);
                
GetEntPropString(clientProp_Data"m_iName"tNamesizeof(tName));
                    
                
SetEntityModel(entity[i], Model);
                
                
DispatchKeyValue(entity[i], "targetname""FollowEntity");
                
DispatchKeyValueVector(entity[i], "origin"vPos);
                
DispatchKeyValueVector(entity[i], "Angles"vAng);
                
DispatchKeyValue(entity[i], "parentname"tName);
                
DispatchKeyValue(entity[i], "parentname"tName);
                
DispatchKeyValue(entity[i], "solid""0");
                
AcceptEntityInput(entity[i], "TurnOn");
                
DispatchSpawn(entity[i]);
                
                
followPosition[0] = followRadius CosineDegToRadfollowAngle )) + vPos[0];
                
followPosition[1] = followRadius SineDegToRadfollowAngle )) + vPos[1];
                
followPosition[2] = vPos[2];
            
                
TeleportEntity(entity[i], followPositionvAngNULL_VECTOR);
                
                
followAngle    += incRadius;    // next point attachment
            
}
            
            
SetEntityRenderColor(entity[i], sColor[0], sColor[1], sColor[2], sColor[3]);
        
            
GlowTarget(entity[i], sGlow[0], sGlow[1], sGlow[2]);
        
            
ClientModel[client][number][i-1] = EntIndexToEntRef(entity[i]);
            
        }
        
        
DataPack hPack = new DataPack();
        
hPack.WriteCell(GetClientUserId(client));
        
hPack.WriteCell(number);
        
hPack.WriteFloat(Pos[2]);
        
        
CreateTimer(0.01TimerRotationhPackTIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
//
//TimerRotaion
Action TimerRotation(Handle timerDataPack hPack)
{
    
hPack.Reset();
    
int client GetClientOfUserId(hPack.ReadCell());
    if(!
IsTank(client)) return Plugin_Stop;
    
int number GetClientOfUserId(hPack.ReadCell());
    
int entity[9];
    
float vAng[9][3], vVel[9][3], vPos[3], NewPosEntityPos[9][3];
    
GetClientAbsOrigin(clientvPos);
    
NewPos hPack.ReadFloat();
    
vPos[2] += NewPos;
    for(
int i 1<= 8i++)
    {
        
entity[i] = EntRefToEntIndex(ClientModel[client][number][i-1]);
        if(!
IsValidEntRef(entity[i])) continue;
        if(!
IsValidEntity(entity[i])) continue;
        
        
GetEntPropVector(entity[i], Prop_Data"m_vecOrigin"EntityPos[i]);
        
GetEntPropVector(entity[i], Prop_Data"m_angRotation"vAng[i]);
        
GetEntPropVector(entity[i], Prop_Data"m_vecVelocity"vVel[i]);
        
        if(
vAng[i][1] >= 360.0vAng[i][1] = 0.0;
        else 
vAng[i][1] += 3.6;
        
        if ( 
EntityPos[i][2] < vPos[2] )
        {
            
vAng[i][0] = -5.0;
            
GetAngleVectorsvAng[i], vVel[i], NULL_VECTORNULL_VECTOR);
            
NormalizeVectorvVel[i], vVel[i] );
            
vAng[i][0] = 0.0;
        }
        else if ( 
EntityPos[i][2] > ( vPos[2] + 45.0 ))
        {
            
vAng[i][0] = 5.0;
            
GetAngleVectorsvAng[i], vVel[i], NULL_VECTORNULL_VECTOR);
            
NormalizeVectorvVel[i], vVel[i] );
            
vAng[i][0] = 0.0;
        }
        else
        {
            
vAng[i][0] = 0.0;
            
GetAngleVectorsvAng[i], vVel[i], NULL_VECTORNULL_VECTOR);
            
NormalizeVectorvVel[i], vVel[i] );
        }
        
ScaleVector(vVel[i], 90.0);
        
TeleportEntityentity[i], NULL_VECTORvAng[i], vVel[i] );
    }
    
    return 
Plugin_Continue;
}

void GlowTarget(int entityint Rint Gint B)
{
    
SetEntProp(entityProp_Send"m_glowColorOverride"+ (256) + (65536));
    
SetEntProp(entityProp_Send"m_iGlowType"3);
    
SetEntProp(entityProp_Send"m_nGlowRange"3000);
    
SetEntProp(entityProp_Send"m_nGlowRangeMin"0);

I don't know if is this correct
__________________
_________________
Discord: gabrielbr007
YouTube: WhiteFire
Steam: WhiteFire

Last edited by King_OXO; 11-27-2023 at 19:17.
King_OXO is offline