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

Solved [L4D2]Rotating Objects around player


Post New Thread Reply   
 
Thread Tools Display Modes
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
__________________
My Noob Plugins

Discord:WhiteFire#1301
Steam:WhiteFire
Youtube

Last edited by King_OXO; 11-27-2023 at 19:17.
King_OXO is offline
XGAK
Junior Member
Join Date: May 2018
Old 11-22-2023 , 20:48   Re: [L4D2]Rotating Objects around player
Reply With Quote #2

use phys_torque to control the rotation.
take a look at TF2 Rollermine spawner
XGAK is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 11-23-2023 , 06:27   Re: [L4D2]Rotating Objects around player
Reply With Quote #3

[l4d2] Luffy Items, by GsiX, has some rotating features, you may want to check.

https://forums.alliedmods.net/attach...9&d=1352321672
__________________

Last edited by Marttt; 11-23-2023 at 06:28.
Marttt is offline
King_OXO
Senior Member
Join Date: Dec 2020
Location: Brazil
Old 11-23-2023 , 16:59   Re: [L4D2]Rotating Objects around player
Reply With Quote #4

Quote:
Originally Posted by Marttt View Post
[l4d2] Luffy Items, by GsiX, has some rotating features, you may want to check.

https://forums.alliedmods.net/attach...9&d=1352321672
Ty bro. you always help me
__________________
My Noob Plugins

Discord:WhiteFire#1301
Steam:WhiteFire
Youtube

Last edited by King_OXO; 11-23-2023 at 16:59.
King_OXO is offline
King_OXO
Senior Member
Join Date: Dec 2020
Location: Brazil
Old 11-27-2023 , 19:03   Re: [L4D2]Rotating Objects around player
Reply With Quote #5

Quote:
Originally Posted by Marttt View Post
[l4d2] Luffy Items, by GsiX, has some rotating features, you may want to check.

https://forums.alliedmods.net/attach...9&d=1352321672
Bro, your answer worked, but now I have another problem. The particles are spawning wrong "info_particle_system (particle) has no particle system name specified!"( error particle, the one with several red "x"s) and entities are not attached correctly to the client:
"Entity prop_dynamic(prop_dynamic) has bad parent activator"
"ERROR: Tried to SetParentAttachment for entity prop_dynamic (prop_dynamic), but it has no parent."

I think the problem is in detecting the keys inside the tank_spawn_effects.cfg file and exploding the string
Attached Files
File Type: cfg tank_spawn_effects.cfg (2.6 KB, 48 views)
File Type: sp Get Plugin or Get Source (l4d2_tank_spawn.sp - 73 views - 19.0 KB)
__________________
My Noob Plugins

Discord:WhiteFire#1301
Steam:WhiteFire
Youtube

Last edited by King_OXO; 11-29-2023 at 10:56.
King_OXO is offline
Uncle Jessie
Member
Join Date: May 2016
Location: Mind Prison
Old 11-28-2023 , 00:22   Re: [L4D2]Rotating Objects around player
Reply With Quote #6

Quote:
Originally Posted by King_OXO View Post
Bro, your answer worked, but now I have another problem. The particles are spawning wrong "info_particle_system (particle) has no particle system name specified!"( error particle, the one with several red "x"s) and entities are not attached correctly to the client:
"Entity prop_dynamic(prop_dynamic) has bad parent activator"
"ERROR: Tried to SetParentAttachment for entity prop_dynamic (prop_dynamic), but it has no parent."

I'll put the plugin in the post for you to check

I think the problem is in detecting the keys inside the tank_spawn_effects.cfg file and exploding the string
lol
Uncle Jessie is offline
King_OXO
Senior Member
Join Date: Dec 2020
Location: Brazil
Old 11-29-2023 , 10:59   Re: [L4D2]Rotating Objects around player
Reply With Quote #7

Quote:
Originally Posted by Uncle Jessie View Post
lol
What do you mean by "lol"?
__________________
My Noob Plugins

Discord:WhiteFire#1301
Steam:WhiteFire
Youtube
King_OXO 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:20.


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