Author Topic: How do you create a custom projectile?  (Read 1609 times)

I've been looking on youtube, the forums, and even asked some people, but how do you really create a custom projectile? I can't figure it out.


  - I'm trying to make something along the lines of a pong projectile, but an elongated rectangle which explodes on impact
« Last Edit: July 04, 2017, 11:16:22 PM by Shroom »

what kind of projectile are you trying to create?
look at an example and change it to what you want

if you want something with gravity, you could start with the gravity rocket or a bullet affected by gravity
if you want something more like a pinball/pong, start with those

describe the projectile you are trying to create

This is from T3d documentation, which is a little different than blockland, but for the most part the same.

also uiName will set the name of the projectile to be used in events

Code: [Select]
datablock ProjectileData(GrenadeLauncherProjectile)
{
 projectileShapeName = "art/shapes/weapons/SwarmGun/rocket.dts";
directDamage = 30;
radiusDamage = 30;
damageRadius = 5;
areaImpulse = 2000;
explosion = GrenadeLauncherExplosion;
waterExplosion = GrenadeLauncherWaterExplosion;
decal = ScorchRXDecal;
splash = GrenadeSplash;
particleEmitter = GrenadeProjSmokeTrailEmitter;
particleWaterEmitter = GrenadeTrailWaterEmitter;
muzzleVelocity = 30;
velInheritFactor = 0.3;
armingDelay = 2000;
lifetime = 10000;
fadeDelay = 4500;
bounceElasticity = 0.4;
bounceFriction = 0.3;
isBallistic = true;
gravityMod = 0.9;
lightDesc = GrenadeLauncherLightDesc;
damageType = "GrenadeDamage";
};

int    armingDelay
    Amount of time, in milliseconds, before the projectile will cause damage or explode on impact.

float    bounceElasticity
    Influences post-bounce velocity of a projectile that does not explode on contact.

float    bounceFriction
    Factor to reduce post-bounce velocity of a projectile that does not explode on contact.

DecalData    decal
    Decal datablock used for decals placed at projectile explosion points.

ExplosionData    Explosion
    Explosion datablock used when the projectile explodes outside of water.

int    fadeDelay
    Amount of time, in milliseconds, before the projectile begins to fade out.

float    gravityMod
    Scales the influence of gravity on the projectile.

float    impactForce

bool    isBallistic
    Detetmines if the projectile should be affected by gravity and whether or not it bounces before exploding.

int    lifetime
    Amount of time, in milliseconds, before the projectile is removed from the simulation.

LightDescription    lightDesc
    LightDescription datablock used for lights attached to the projectile.

float    muzzleVelocity
    Amount of velocity the projectile recieves from the "muzzle" of the gun.

ParticleEmitterData    ParticleEmitter
    Particle emitter datablock used to generate particles while the projectile is outside of water.

ParticleEmitterData    particleWaterEmitter
    Particle emitter datablock used to generate particles while the projectile is submerged in water.

filename    projectileShapeName
    File path to the model of the projectile.

Point3F    scale
    Scale to apply to the projectile's size.

SFXTrack    sound
    SFXTrack datablock used to play sounds while in flight.

SplashData    Splash
    Splash datablock used to create splash effects as the projectile enters or leaves water.

float    velInheritFactor
    Amount of velocity the projectile recieves from the source that created it.

ExplosionData    waterExplosion
    Explosion datablock used when the projectile explodes underwater.

You define one, just like the default projectiles are defined.
Take the code for a projectile similar to what you want to make, copy it, then change the datablock and UI names to something logical for your projectile and it should work assuming you're actually running the code. It'll be functionally identical, but then you can fiddle with the values to make it act how you want.
Check out weapon_gun's server.cs and find "gunProjectile" and everything inside the following pair of curly braces should be the projectile definition code, if you can't find it.