AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   [TF2] Creating rockets without rocket launcher (https://forums.alliedmods.net/showthread.php?t=311334)

Facksy 10-13-2018 15:14

[TF2] Creating rockets without rocket launcher
 
Hello guys, I wanna create a script which create rockets when you attack with your melee weapon, the problem is that I dont know properly how to create the rocket, every times I try to create it, either the rocket dont move and remains in air or the rocket dont collide with anything.
I just want a little script which spawn a rocket when you press m1 & m2 and aim where you are aiming, (and if possible the same with tf_projectile_arrow, i got a lot of issue with that one)
Thanks !

asherkin 10-14-2018 06:29

Re: [TF2] Creating rockets without rocket launcher
 
It's old code and needs some cleanup, but everything you need is in this function: https://github.com/asherkin/TFDodgeb...geball.sp#L379

Facksy 10-15-2018 05:36

Re: [TF2] Creating rockets without rocket launcher
 
Here is my code, everythings works well except the fact the rocket doesnt do any damage when it explodes, if any one knows why...
PHP Code:

public Action spawndemo(clientargs)
{
    
float epos[3], eyangl[3];
    
GetClientEyePosition(clientepos);
    
GetClientEyeAngles(clienteyangl);
    
fireProjectile(eposeyangl1100.090.0GetClientTeam(client), PROJECTILE_ROCKETtrue);
}


int fireProjectile(Float:vPosition[3], Float:vAngles[3] = NULL_VECTORFloat:flSpeed 1100.0Float:flDamage 90.0iTeam 1iType PROJECTILE_ROCKETbool:bCritical false)
{
    new 
String:strClassname[32] = "";
    new 
String:strEntname[32] = "";
    
    switch (
iType)
    {
        case 
PROJECTILE_ROCKET:
        {
            
strClassname "CTFProjectile_Rocket";
            
strEntname "tf_projectile_rocket";
        }
        case 
PROJECTILE_ROCKET_SENTRY:
        {
            
strClassname "CTFProjectile_SentryRocket";
            
strEntname "tf_projectile_sentryrocket";
        }
        default:
        {
            return -
1;
        }
    }

    new 
iRocket CreateEntityByName(strEntname);
    
    if(!
IsValidEntity(iRocket))
    {
        return -
1;
    }
    
    
decl Float:vVelocity[3];
    
decl Float:vBuffer[3];
    
    
GetAngleVectors(vAnglesvBufferNULL_VECTORNULL_VECTOR);
    
    
vVelocity[0] = vBuffer[0]*flSpeed;
    
vVelocity[1] = vBuffer[1]*flSpeed;
    
vVelocity[2] = vBuffer[2]*flSpeed;
    
    
TeleportEntity(iRocketvPositionvAnglesvVelocity);
    
    
SetEntData(iRocketFindSendPropInfo(strClassname"m_nSkin"), (iTeam-2), 1true);
    if (
iType == PROJECTILE_ROCKET)
    {
        
SetEntData(iRocketFindSendPropInfo(strClassname"m_bCritical"), bCriticaltrue);
    } else {
        
    }
    
SetEntDataFloat(iRocketFindSendPropInfo(strClassname"m_iDeflected") + 4flDamagetrue); // Credit to voogru
    
    
SetVariantInt(iTeam);
    
AcceptEntityInput(iRocket"TeamNum", -1, -10);

    
SetVariantInt(iTeam);
    
AcceptEntityInput(iRocket"SetTeam", -1, -10); 
    
    if (
iType == PROJECTILE_ROCKET_SENTRY)
    {
        new 
iVisModel CreateEntityByName("tfdb_nukeskin");
        
        
SetEntityModel(iVisModelNUKE_MODEL);
        
SetEntityModel(iRocketNUKE_MODEL);
        
SetVariantString("!activator");
        
AcceptEntityInput(iVisModel"SetParent"iRocket);
        new 
Float:vOrigin[3] = {0.00.00.0};
        
TeleportEntity(iVisModelvOriginvAnglesNULL_VECTOR);
        
SetEntData(iVisModelFindSendPropInfo(strClassname"m_nSkin"), (iTeam-2), 1true);
        
SetVariantInt(iTeam);
        
AcceptEntityInput(iVisModel"TeamNum", -1, -10);
        
SetVariantInt(iTeam);
        
AcceptEntityInput(iVisModel"SetTeam", -1, -10);
        
DispatchKeyValue(iVisModel"solid""0");
        
DispatchSpawn(iVisModel);
        
        
SetEntityRenderMode(iRocketRENDER_TRANSCOLOR);
        
SetEntityRenderColor(iRocket2552552550);
    }
    
    
DispatchSpawn(iRocket);
    
    return 
iRocket;




All times are GMT -4. The time now is 23:55.

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