Blockland Forums > Modification Help
Problem with a Spray Can item (Projectiles + datablocks)
Demian:
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: ---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);
}
--- End code ---
I've recolored the explosion for testing purposes.
Space Guy:
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.
Demian:
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: ---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);
}
--- End code ---
Space Guy:
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?
Ephialtes:
Just incase anyone doesn't know - the spray can uses raycasting for collision, the projectile is just for the spray effect.