Raised This Month: $404 Target: $400
 101% 

[TF2] Creating rockets without rocket launcher


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Facksy
Senior Member
Join Date: Apr 2017
Location: here
Old 10-13-2018 , 15:14   [TF2] Creating rockets without rocket launcher
Reply With Quote #1

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 !
__________________
HereMy Steam
Facksy is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 10-14-2018 , 06:29   Re: [TF2] Creating rockets without rocket launcher
Reply With Quote #2

It's old code and needs some cleanup, but everything you need is in this function: https://github.com/asherkin/TFDodgeb...geball.sp#L379
__________________
asherkin is offline
Facksy
Senior Member
Join Date: Apr 2017
Location: here
Old 10-15-2018 , 05:36   Re: [TF2] Creating rockets without rocket launcher
Reply With Quote #3

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;

__________________
HereMy Steam

Last edited by Facksy; 10-15-2018 at 05:39.
Facksy is offline
Reply


Thread Tools
Display Modes

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 16:33.


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