Author Topic: Problem with a Spray Can item (Projectiles + datablocks)  (Read 906 times)

I attempting to create a Spray Can item that looks exactly like the Spray Can but doesn't color bricks. So far I've gotten everything else working but the spray projectile doesn't collide with bricks, terrain or interior. I also can't seem to find the datablock that is the actual stream of paint. The Spray Can projectile doesn't have any "cloud" image assigned to it which it clearly has in game. Also by default the stream of paint is blue, again I am unable the datablock that controls that color. Any help?

Code: [Select]
datablock AudioProfile(propSprayActivateSound : sprayActivateSound)
{
description = AudioClose3d;
preload = true;
};

datablock AudioProfile(propSprayFireSound : sprayFireSound)
{
description = AudioClosestLooping3d;
preload = true;
};

datablock ParticleData(propSprayPaintDropletParticle : bluePaintDropletParticle)
{
   colors[0] = "1 0 0 0.5";
   colors[1] = "0 1 0 0";
   colors[2] = "1 1 1 1";
   colors[3] = "1 1 1 1";
};

datablock ParticleData(propSprayPaintExplosionParticle : bluePaintExplosionParticle)
{
   colors[0] = "1 0 0 0.5";
   colors[1] = "0 0 1 0";
   colors[2] = "1 1 1 1";
   colors[3] = "1 1 1 1";
};

datablock ParticleEmitterData(propSprayPaintDropletEmitter : bluePaintDropletEmitter)
{
className = "ParticleEmitterData";
lifetimeMS = "100";
particles = "propSprayPaintDropletParticle";
};

datablock ParticleEmitterData(propSprayPaintExplosionEmitter : bluePaintExplosionEmitter)
{
className = "ParticleEmitterData";
lifetimeMS = "100";
particles = "propSprayPaintExplosionParticle";
};

datablock ExplosionData(propSprayPaintExplosion : bluePaintExplosion)
{
className = "ExplosionData";
emitter[0] = "propSprayPaintExplosionEmitter";
emitter[1] = "propSprayPaintDropletEmitter";
};

datablock ProjectileData(propSprayCanProjectile : bluePaintProjectile)
{
className = "ProjectileData";
uiName = "";
muzzleVelocity = "20";
lifetime = "300";
explosion = "propSprayPaintExplosion";
explodeOnDeath = 0;
explodeOnPlayerImpact = 0;
};

datablock ItemData(propSprayCanItem)
{
category = "Tools";
className = "WeaponImage";

shapeFile = "base/data/shapes/spraycan.dts";
mass = 1;
drag = 0.5;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;

uiName = "Spray Can Tool";
iconName = "./Icon_SprayCan";
doColorShift = false;
colorShiftColor = "0.471 0.471 0.471 1.000";
image = propSprayCanImage;
canDrop = true;
};

datablock ShapeBaseImageData(propSprayCanImage : blueSprayCanImage)
{
item = propSprayCanItem;
projectile = propSprayCanProjectile;
projectileType = Projectile;
showBricks = 0;

stateSound[0] = "propSprayActivateSound";
stateSound[2] = "propSprayFireSound";
};

function propSprayCanImage::onFire(%this, %obj, %slot)
{
%obj.playthread(2, root);
}
I've recolored the explosion for testing purposes.
« Last Edit: April 03, 2011, 05:49:01 AM by Demian »

bluePaintEmitter is the stream of paint. This is emitted as a particle effect on the weapon, not associated with the projectile - like the gun flash or more specifically the various Flamethrower weapons. If you do blueSprayCanImage.dump(); you'll be able to find out exactly which state particle effect to change.

The default blue paint can emits the "cloud" particles on hit so you're breaking something.

Thanks Space Guy. It appears that I missed that line in the image. Anyways, here is the latest script. The paint still does not collide with anything and doesn't create that explosion.

Code: [Select]
datablock AudioProfile(propSprayActivateSound : sprayActivateSound)
{
description = AudioClose3d;
preload = true;
};

datablock AudioProfile(propSprayFireSound : sprayFireSound)
{
description = AudioClosestLooping3d;
preload = true;
};

datablock ParticleData(propSprayPaintDropletParticle : bluePaintDropletParticle)
{
   colors[0] = "1 0 0 0.5";
   colors[1] = "0 1 0 0";
   colors[2] = "1 1 1 1";
   colors[3] = "1 1 1 1";
};

datablock ParticleData(propSprayPaintExplosionParticle : bluePaintExplosionParticle)
{
   colors[0] = "1 0 0 0.5";
   colors[1] = "0 0 1 0";
   colors[2] = "1 1 1 1";
   colors[3] = "1 1 1 1";
};

datablock ParticleData(propSprayPaintParticle : bluePaintParticle)
{
   colors[0] = "1 0 0 0.5";
   colors[1] = "0 1 0 0";
   colors[2] = "1 1 1 1";
   colors[3] = "1 1 1 1";
};

datablock ParticleEmitterData(propSprayPaintDropletEmitter : bluePaintDropletEmitter)
{
particles = "propSprayPaintDropletParticle";
};

datablock ParticleEmitterData(propSprayPaintExplosionEmitter : bluePaintExplosionEmitter)
{
particles = "propSprayPaintExplosionParticle";
};

datablock ParticleEmitterData(propSprayPaintEmitter : bluePaintEmitter)
{
particles = "propSprayPaintParticle";
};

datablock ExplosionData(propSprayPaintExplosion : bluePaintExplosion)
{
emitter[0] = "propSprayPaintExplosionEmitter";
emitter[1] = "propSprayPaintDropletEmitter";
};

datablock ProjectileData(propSprayCanProjectile : bluePaintProjectile)
{
uiName = "";
muzzleVelocity = 20;
lifetime = 300;
explosion = propSprayPaintExplosion;
explodeOnDeath = 0;
explodeOnPlayerImpact = 0;
};

datablock ItemData(propSprayCanItem)
{
shapeFile = "base/data/shapes/spraycan.dts";
mass = 1;
drag = 0.5;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;

uiName = "Spray Can Tool";
iconName = "./Icon_SprayCan";
doColorShift = false;
colorShiftColor = "0.471 0.471 0.471 1.000";
image = propSprayCanImage;
canDrop = true;
};

datablock ShapeBaseImageData(propSprayCanImage : blueSprayCanImage)
{
item = propSprayCanItem;
projectile = propSprayCanProjectile;
showBricks = 0;

stateSound[0] = propSprayActivateSound;

stateSound[2] = propSprayFireSound;
stateEmitter[2] = propSprayPaintEmitter;
};

function propSprayCanImage::onFire(%this, %obj, %slot)
{
%obj.playthread(2, root);
}
« Last Edit: April 03, 2011, 06:11:14 AM by Demian »

Well, the paint projectile disappears without exploding after 0.3 seconds and doesn't explode if you hit players. Are you sure it's actually reaching the surface?

Just incase anyone doesn't know - the spray can uses raycasting for collision, the projectile is just for the spray effect.

Well, the paint projectile disappears without exploding after 0.3 seconds and doesn't explode if you hit players. Are you sure it's actually reaching the surface?
Increasing the lifetime and muzzle velocity had no effect.

Just incase anyone doesn't know - the spray can uses raycasting for collision, the projectile is just for the spray effect.
You mean it uses raycast for the explosion too? I have to assume this is hardcoded somewhere because it is not in any of the files that I've dumbed. (Image, item, explosion, projectile, emitters, particles and sounds) Can I do this with projectiles?

All I need right now is the explosion when the stream of paint hits something.
« Last Edit: April 03, 2011, 07:28:51 AM by Demian »

Just incase anyone doesn't know - the spray can uses raycasting for collision, the projectile is just for the spray effect.
Paint goes through non-raycasting bricks and takes time to hit. The Hammer/Wrench/Wand raycast but paint works by projectile.


For me the paint goes through everything. It doesn't collide with anything.

Edit: Wait a second, I already have a projectile that does collide with everything and spawns an explosion when it hits something. How come the Spray Can isn't shooting those?
« Last Edit: April 04, 2011, 05:01:20 AM by Demian »