Author Topic: [*HELP*] Freeze Tag Wand [*HELP*]  (Read 616 times)

So I'm trying to make players become frozen when the wand collides on their character... The only problem is that, the wand won't collide with the character. It just hits through them.

Here's both scripts I've tried:

Code: [Select]
$Pref::FTWand::HighlightColor = getClosestPaintColor("0 1 1 1");

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        = FTWandExplosionParticle;
periodVarianceMS = 2;
thetaMax         = 180;
velocityVariance = 0;
};
datablock explosionData(FTWandExplosion)
{
camShakeDuration = 0.5;
camShakeFreq     = "1 1 1";
emitter[0]       = FTWandExplosionEmitter;
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        = FTWandExplosion;
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)
{
projectile = FTWandProjectile;
showBricks = true;
colorShiftColor = "0.000000 1.000000 1.000000 1.000000";
item = FTWandItem;
stateEmitter[1] = FTWandEmitterA;
stateEmitter[3] = FTWandEmitterB;
};

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

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

//function FTWandImage::OnUnMount(%this, %obj) //When you take the hammer off, to prevent your arm from being raised after using /banhammer
//{
//%obj.playThread(0,root);
//}

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

   }
   
parent::onHitObject(%this, %obj, %slot, %col, %pos, %normal);
}

And This One

Code: [Select]
datablock itemData(FTWandItem : wandItem)
{
category = "Weapon";
uiName = "Freeze Wand";
image = FTWandImage;
};

datablock shapeBaseImageData(FTWandImage : wandImage)
{
mountPoint = 0;
offset = "0 0 0";

orrectMuzzleVector = false;

eyeOffset = "0 0 0";

// SpaceCasts
raycastWeaponRange = 6;
raycastWeaponTargets = $TypeMasks::All;
raycastDirectDamage = 20;
raycastDirectDamageType = $DamageType::wandDirect;
raycastExplosionProjectile = wandProjectile;
raycastExplosionSound = wandHitSound;

    className = "WeaponImage";
item = FTWandItem;
projectile = wandProjectile;
    projectileType = Projectile;
colorShiftColor = "0.650000 0.650000 0.000000 1.000000";
showBricks = 0;
melee = true;
doRetraction = false;
    armReady = true;
    doColorShift = true;

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

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";
stateSound[3]                    = FTWandSwingSound;
stateWaitForTimeout[3] = true;

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 FTWandImage::onFire(%this, %obj, %slot)
{
%obj.playThread(2,armAttack);
}

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

//function FTWandImage::OnUnMount(%this, %obj) //When you take the hammer off, to prevent your arm from being raised after using /banhammer
//{
//%obj.playThread(0,root);
//}

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

   }
   
parent::onHitObject(%this, %obj, %slot, %col, %pos, %normal);
}

I've also tried onCollision and it still doesn't collide with the clients in game. Please help... Thanks!

onHitObject is not a default function, it's completely customized

How the Hammer, Wrench and Printer work, they do use ::onFire, but during that function it creates a raycast and then calls ::onHitObject with all the good stuff.