Author Topic: My projectile keeps turning black.  (Read 1450 times)



The sword spawn is grey, when I hold it the sword is grey but when I throw the sword the projectile is black. I have no idea how to fix it, yes I am editing off Tezuni's black knife script but it feels like it's missing something.

Code: [Select]
//BlackKnifeKnife.cs
datablock AudioProfile(BlackKnifeBrickSound)
{
   filename    = "./KnifeBrick.wav";
   description = AudioClosest3d;
   preload = true;
};
datablock AudioProfile(BlackKnifePlayerSound)
{
   filename    = "./KnifePlayer.wav";
   description = AudioClosest3d;
   preload = true;
};
datablock AudioProfile(BlackKnifeSwingSound)
{
   filename    = "./KnifeSwing.wav";
   description = AudioClosest3d;
   preload = true;
};

datablock ParticleData(BlackKnifeExplosionParticle)
{
   dragCoefficient      = 2;
   gravityCoefficient   = 1.0;
   inheritedVelFactor   = 0.2;
   constantAcceleration = 0.0;
   spinRandomMin = -90;
   spinRandomMax = 90;
   lifetimeMS           = 500;
   lifetimeVarianceMS   = 300;
   textureName          = "base/data/shapes/blank";
   colors[0]     = "0.7 0.7 0.9 0.9";
   colors[1]     = "0.9 0.9 0.9 0.0";
   sizes[0]      = 0.5;
   sizes[1]      = 0.25;
};

datablock ParticleEmitterData(BlackKnifeExplosionEmitter)
{
   ejectionPeriodMS = 7;
   periodVarianceMS = 0;
   ejectionVelocity = 8;
   velocityVariance = 1.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 60;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "BlackKnifeExplosionParticle";

   uiName = "BlackKnife Hit";
};

datablock ExplosionData(BlackKnifeExplosion)
{
   //explosionShape = "";
   lifeTimeMS = 500;

   soundProfile = BlackKnifeBrickSound;

   particleEmitter = BlackKnifeExplosionEmitter;
   particleDensity = 10;
   particleRadius = 0.2;

   faceViewer     = true;
   explosionScale = "1 1 1";

   shakeCamera = true;
   camShakeFreq = "20.0 22.0 20.0";
   camShakeAmp = "1.0 1.0 1.0";
   camShakeDuration = 0.5;
   camShakeRadius = 10.0;

   // Dynamic light
   lightStartRadius = 3;
   lightEndRadius = 0;
   lightStartColor = "00.0 0.0 0.0";
   lightEndColor = "0 0 0";
};

//Stab Projectile
AddDamageType("BlackKnife",   '<bitmap:add-ons/Weapon_Black_Knife/CI_BlackKnife> %1',    '%2 <bitmap:add-ons/Weapon_Black_Knife/CI_BlackKnife> %1',0.75,1);
datablock ProjectileData(BlackKnifeStabProjectile)
{
   shapeFile = "base/data/shapes/empty.dts";
   directDamage        = 30;
   directDamageType  = $DamageType::BlackKnife;
   radiusDamageType  = $DamageType::BlackKnife;

   brickExplosionRadius = 0;
   brickExplosionImpact = true;
   brickExplosionForce = 0;
   brickExplosionMaxVolume = 1;
   brickExplosionMaxVolumeFloating = 2;
   explosion           = BlackKnifeExplosion;

   muzzleVelocity      = 50;
   velInheritFactor    = 1;

   armingDelay         = 0;
   lifetime            = 100;
   fadeDelay           = 70;
   bounceElasticity    = 0;
   bounceFriction      = 0;
   isBallistic         = true;
   gravityMod = 0.50;

   hasLight    = false;
   lightRadius = 3.0;
   lightColor  = "0 0 0.5";

   uiName = "Black Knife Stab";
};

//Thrown projectile
datablock ProjectileData(BlackKnifeThrowProjectile)
{
   projectileShapeName = "./BlackKnifeProjectile.dts";
   directDamage        = 100;
   directDamageType  = $DamageType::BlackKnife;
   radiusDamageType  = $DamageType::BlackKnife;
   particleEmitter       = spearTrailEmitter;
   explodeOnPlayerImpact = true;
   explodeOnDeath        = true; 

   armingDelay         = 30000;
   lifetime            = 30000;
   fadeDelay           = 30000;

   isBallistic         = true;
   bounceAngle         = 170; //stick almost all the time
   minStickVelocity    = 10;
   bounceElasticity    = 0.2;
   bounceFriction      = 0.01;   
   gravityMod = 0.25;
   doColorShift = true;
   colorShiftColor = "0.471 0.471 0.471 1.000";


   hasLight    = false;
   lightRadius = 3.0;
   lightColor  = "0 0 0.5";

   muzzleVelocity      = 65;
   velInheritFactor    = 1;
   lightColor  = "0 0 0.5";

   uiName = "Black Knife Throw";
};

datablock ParticleEmitterData(spearTrailEmitter)
{
   ejectionPeriodMS = 5;
   periodVarianceMS = 0;

   ejectionVelocity = 0; //0.25;
   velocityVariance = 0; //0.10;

   ejectionOffset = 0;

   thetaMin         = 0.0;
   thetaMax         = 90.0; 

   particles = spearTrailParticle;

   useEmitterColors = true;
   uiName = "Spear Trail";
};


//////////
// item //
//////////
datablock ItemData(BlackKnifeItem)
{
category = "Weapon";  // Mission editor category
className = "Weapon"; // For inventory system

// Basic Item Properties
shapeFile = "./BlackKnife.dts";
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;

//gui stuff
uiName = "Black Knife";
iconName = "./icon_BlackKnife";
doColorShift = true;
colorShiftColor = "0.471 0.471 0.471 1.000";

// Dynamic properties defined by the scripts
image = BlackKnifeImage;
canDrop = true;
};

////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(BlackKnifeImage)
{
   // Basic Item properties
   shapeFile = "./BlackKnife.dts";
   emap = true;

   // Specify mount point & offset for 3rd person, and eye offset
   // for first person rendering.
   mountPoint = 0;
   offset = "0 0 0";

   // When firing from a point offset from the eye, muzzle correction
   // will adjust the muzzle vector to point to the eye LOS point.
   // Since this weapon doesn't actually fire from the muzzle point,
   // we need to turn this off. 
   correctMuzzleVector = false;

   eyeOffset = "0 0 0";

   // Add the WeaponImage namespace as a parent, WeaponImage namespace
   // provides some hooks into the inventory system.
   className = "WeaponImage";

   // Projectile && Ammo.
   item = BlackKnifeItem;
   ammo = " ";
   projectile = BlackKnifeStabProjectile;
   projectileType = Projectile;

   //melee particles shoot from eye node for consistancy
   melee = true;
   doRetraction = false;
   //raise your arm up or not
   armReady = true;

   //casing = " ";
   doColorShift = true;
   colorShiftColor = "0.471 0.471 0.471 1.000";

   // Images have a state system which controls how the animations
   // are run, which sounds are played, script callbacks, etc. This
   // state system is downloaded to the client so that clients can
   // predict state changes and animate accordingly.  The following
   // system supports basic ready->fire->reload transitions as
   // well as a no-ammo->dryfire idle state.

   // Initial start up state
stateName[0]                     = "Activate";
stateTimeoutValue[0]             = 0.5;
stateTransitionOnTimeout[0]      = "Ready";
stateSound[0]                    = false;

stateName[1]                     = "Ready";
stateTransitionOnTriggerDown[1]  = "PreFire";
stateAllowImageChange[1]         = true;

stateName[2] = "PreFire";
stateScript[2]                  = "onPreFire";
stateAllowImageChange[2]        = false;
stateTimeoutValue[2]            = 0.1;
stateTransitionOnTimeout[2]     = "Fire";

stateName[3]                    = "Fire";
stateTransitionOnTimeout[3]     = "CheckFire";
stateTimeoutValue[3]            = 0.2;
stateFire[3]                    = true;
stateAllowImageChange[3]        = false;
stateSequence[3]                = "Fire";
stateScript[3]                  = "onFire";
stateWaitForTimeout[3] = true;
stateSound[3]                   = BlackKnifeSwingSound;

stateName[4] = "CheckFire";
stateTransitionOnTriggerUp[4] = "StopFire";
stateTransitionOnTriggerDown[4] = "Fire";


stateName[5]                    = "StopFire";
stateTransitionOnTimeout[5]     = "Ready";
stateTimeoutValue[5]            = 0.2;
stateAllowImageChange[5]        = false;
stateWaitForTimeout[5] = true;
stateSequence[5]                = "StopFire";
stateScript[5]                  = "onStopFire";


};

function BlackKnifeImage::onPreFire(%this, %obj, %slot)
{
%obj.playthread(2, armattack);
}

function BlackKnifeImage::onStopFire(%this, %obj, %slot)
{
%obj.playthread(2, root);
}

$BlackKnifeStabLimit = 2;

if(isFile("Add-Ons/System_ReturnToBlockland/server.cs"))
{
    if(!$RTB::RTBR_ServerControl_Hook)
exec("Add-Ons/System_ReturnToBlockland/RTBR_ServerControl_Hook.cs");

    RTB_registerPref("Stab Limit", "Black Knife", "$BlackKnifeStabLimit","list Once 1 Unlimited 2","Weapon_Black_Knife", 0, 0, 1);
}


package BlackKnifePackage
{
function BlackKnifeStabProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal, %client)
{
%currSlot = %obj.currTool;
%client = %obj.sourceObject.client;

if(isObject(%col.client.minigame))
{
if(%obj.client.minigame $= %col.client.minigame)
{
if(%col.getClassName() $= "Player")
{
if($BlackKnifeStabLimit==1)
{
%obj.sourceObject.tool[%currSlot] = 0;
                  %obj.sourceObject.weaponCount--;
messageClient(%obj.client,'MsgItemPickup',"",%currSlot,0);
serverCmdUnUseTool(%obj.client);
}

serverPlay3D(BlackKnifePlayerSound, %pos);
return Parent::onCollision(%this, %obj, %col, %fade, %pos, %normal, %client);
}

          }

if((%col.getType() && $TypeMasks::FxBrickObjectType))
                {
serverPlay3D(BlackKnifeBrickSound, %pos);
return Parent::onCollision(%this, %obj, %col, %fade, %pos, %normal, %client);
                }

else
{
return Parent::onCollision(%this, %obj, %col, %fade, %pos, %normal, %client);
}
}

function BlackKnifeThrowProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal, %client)
{
if((%col.getType() & $TypeMasks::PlayerObjectType) && isObject(%col.client))
        {
serverPlay3D(BlackKnifePlayerSound, %pos);
return Parent::onCollision(%this, %obj, %col, %fade, %pos, %normal, %client);     
          }

if((%col.getType() && $TypeMasks::FxBrickObjectType))
                {
serverPlay3D(BlackKnifeBrickSound, %pos);
return Parent::onCollision(%this, %obj, %col, %fade, %pos, %normal, %client);
                }

else
{
return Parent::onCollision(%this, %obj, %col, %fade, %pos, %normal, %client);
}      
}


function Armor::onTrigger(%this, %player, %slot, %val)
{
if(%player.getMountedImage(0) $= BlackKnifeImage.getID() && %slot $= 4 && %val)
{
%currSlot = %player.currTool;
%player.tool[%currSlot] = 0;
%player.weaponCount--;
messageClient(%player.client,'MsgItemPickup','',%currSlot,0);
serverCmdUnUseTool(%player.client);

%projectile = BlackKnifeThrowProjectile;
%vector = %player.getMuzzleVector(0);
%objectVelocity = %player.getVelocity();
%vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
%p = new Projectile()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %player.getMuzzlePoint(0);
sourceObject = %player;
sourceSlot = 0;
client = %player.client;
};
serverPlay3D(BlackKnifeSwingSound,%player.getPosition());
%player.playthread("3","Activate");
MissionCleanup.add(%p);
return %p;
}
Parent::onTrigger(%this, %player, %slot, %val);
}
};
activatePackage(BlackKnifePackage);

The sword model uses textures that are designed to work with colorshifting, which only applies to images and items and a few other things. Using the sword model as a projectile will cause weird things to happen, just as with almost any other default model.

Using the sword model as a projectile will cause weird things to happen, just as with almost any other default model.

But I'm not using a sword model as a projectile, I'm using a special projectile model for it.

If you noticed that isn't the default sword.

Well I changed the model from knife to spear and the spear is black so I know it's the script now.

Is the script color shifting the item.

Also, sticking items suck because they float in the air if the brick or person moves.

Is the script color shifting the item.

Nope

Also, sticking items suck because they float in the air if the brick or person moves.

I don't care I want it to stick and it disappears when it hits a player, what are you talking about?

The projectile model uses a texture that is black or the model has messed up normals.

The projectile model uses a texture that is black or the model has messed up normals.

Well I tried changing it but I can't find the colorshift for the projectile.

But I'm not using a sword model as a projectile, I'm using a special projectile model for it.

If you noticed that isn't the default sword.
Oh, I had just glanced at the picture. I'm still fairly certain that this is what's causing your problem, though.

Well I changed the model from knife to spear and the spear is black so I know it's the script now.
The spear model is also designed for colorshifting.

Well I tried changing it but I can't find the colorshift for the projectile.
It doesn't exist. You're just going to have to make the model use opaque textures.

Are you sure it's not script related?

I see your editing the black knife..

I see your editing the black knife..

I liked the throw function but I think I may have to start from scratch.

It appears you can't colorshift projectiles. On Appendix A page 108 there is no variable for colorshifting nor is there one in the default variables for projectiles.

You're just going to have to make the model use opaque textures.

Transparent versions of the grey and dark grey or transparent like transparent bricks/vehicles?

The spear doesn't have a transparent texture, so how do you know that will work?