Author Topic: Freeze Wand *Script Need Help*  (Read 654 times)

So I made this wand out of the duplicator script because I love how the color looks. It's supposed to freeze people by changing their datablock on collision, but the wand collides against the air?! Here is a gif of what I'm talking about
https://imgflip.com/gif/n6y67

I'm a newbie at scripting, but I can't find anything wrong... Here's the script:


Code: [Select]
datablock itemData(FTWandItem)
{
cameraMaxDist   = 0.1;
canDrop         = 1;
category        = "Weapon";
className       = "Tool";
colorShiftColor = "0 1 1 1";
density         = 0.2;
doColorShift    = 1;
elasticity      = 0.2;
emap            = 1;
friction        = 0.6;
iconName        = "base/client/ui/itemIcons/wand";
image           = "FTWandImage";
shapeFile       = "base/data/shapes/wand.dts";
uiName          = "Freeze Wand";
};
datablock particleData(FTWandExplosionParticle)
{
colors[0]          = "0.3 0.3 1 0.9";
colors[1]          = "0 0.2 1 0.7";
colors[2]          = "0.3 0.4 1 0.5";
gravityCoefficient = 0;
lifetimeMS         = 400;
lifetimeVarianceMS = 200;
sizes[0]           = 0.6;
sizes[1]           = 0.4;
sizes[2]           = 0.3;
spinRandomMax      = 90;
spinRandomMin      = -90;
textureName        = "base/data/particles/ring";
times[1]           = 0.8;
times[2]           = 1;
};

datablock particleEmitterData(FTWandExplosionEmitter)
{
ejectionOffset   = 0.5;
ejectionPeriodMS = 4;
ejectionVelocity = 3;
particles        = wandExplosionParticle;
periodVarianceMS = 2;
thetaMax         = 180;
velocityVariance = 0;
};
datablock explosionData(FTWandExplosion)
{
camShakeDuration = 0.5;
camShakeFreq     = "1 1 1";
emitter[0]       = wandExplosionEmitter;
faceViewer       = 1;
lifetimeMS       = 180;
lightEndRadius   = 0.5;
lightStartColor  = "0 0.7 1 1";
lightStartRadius = 1;
shakeCamera      = 1;
soundProfile     = "wandHitSound";
};
datablock projectileData(FTWandProjectile)
{
bounceElasticity = 0;
bounceFriction   = 0;
explodeOnDeath   = 1;
explosion        = wandExplosion;
fadeDelay        = 2;
gravityMod       = 0;
lifetime         = 0;
    mask             = $TypeMasks::FxBrickAlwaysObjectType | $TypeMasks::InteriorObjectType | $TypeMasks::TerrainObjectType;
range            = 10;
};
datablock particleData(FTWandParticleA)
{
colors[0]          = "0.0 0.6 1 0.9";
colors[1]          = "0 0.2 1 0.7";
colors[2]          = "0.3 0.4 1 0.5";
gravityCoefficient = -0.5;
lifetimeMS         = 400;
lifetimeVarianceMS = 200;
sizes[0]           = 0.1;
sizes[1]           = 0.4;
sizes[2]           = 0.6;
spinRandomMax      = 90;
spinRandomMin      = -90;
textureName        = "base/data/particles/ring";
times[1]           = 0.8;
times[2]           = 1;
};

datablock particleEmitterData(FTWandEmitterA)
{
ejectionOffset   = 0.09;
ejectionPeriodMS = 50;
ejectionVelocity = 0.2;
particles        = FTWandParticleA;
periodVarianceMS = 2;
thetaMax         = 180;
velocityVariance = 0;
};
datablock particleData(FTWandParticleB)
{
colors[0]          = "0.0 0.6 1 0.9";
colors[1]          = "0 0.2 1 0.7";
colors[2]          = "0.3 0.4 1 0.5";
gravityCoefficient = -0.4;
dragCoefficient    = 2;
lifetimeMS         = 400;
lifetimeVarianceMS = 200;
sizes[0]           = 0.4;
sizes[1]           = 0.6;
sizes[2]           = 0.9;
spinRandomMax      = 0;
spinRandomMin      = 0;
textureName        = "base/client/ui/brickIcons/1x1";
times[1]           = 0.5;
times[2]           = 1;
};

datablock particleEmitterData(FTWandEmitterB)
{
ejectionOffset   = -0.0;
ejectionPeriodMS = 10;
ejectionVelocity = 0;
particles        = FTWandParticleB;
periodVarianceMS = 2;
thetaMin = 0.0;
thetaMax         = 0.1;
velocityVariance = 0;
orientParticles  = true;
phiVariance = 10;
};
datablock shapeBaseImageData(FTWandImage : wandImage)
{
raycastWeaponRange = 10;
raycastWeaponTargets = $TypeMasks::All;
raycastDirectDamageType = $DamageType::wandDirect;
raycastExplosionProjectile = wandProjectile;
raycastExplosionSound = wandHitSound;

projectile = wandProjectile;
showBricks = true;
colorShiftColor = "0.000000 1.000000 1.000000 1.000000";
item = FTWandItem;
stateEmitter[1] = FTWandEmitterA;
stateEmitter[3] = FTWandEmitterB;
};


function FTWandImage::onStopFire(%this, %obj, %slot) //Makes you stop swinging
{
%obj.stopThread(2);
}

function FTWandImage::onPreFire(%this, %obj, %slot)
{
%obj.playThread(2, armAttack);
}

//function FTWandImage::OnUnMount(%this, %obj)
//{
//%obj.playThread(0,root);
//}

function FTWandProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal) //When the projectile hits something.
{
    if(%col.getClassName() $= "Player") //If it's a player
    {
        %client = %obj.Client;
        %client.setDatablock(PlayerFrozen);
    }
parent::onCollision(%this, %obj, %col, %fade, %pos, %normal);

}
I don't think I have any interfering addons, I only have 5 addons enabled for testing... Any help?
« Last Edit: June 21, 2015, 06:08:18 PM by Courage »

Datablocks are set on players, not clients. Also, %obj is the projectile that's colliding with something. You'll want to use %col - this is the object the project is colliding with.

Also you'll want to change the datablock of the object you hit, not its client. Also make sure you have the raycast support script enabled since it appears you're making a raycast weapon.