Author Topic: collison error  (Read 3556 times)

ok i made a portabel base ( :cookieMonster:) and you can shoot though it...why i dont wan tthis to happen (i do have a custom collison box on it)


Code: [Select]
//porable base by grand theif fox
$hsinstall = 1;
datablock AudioProfile(BASEExplosionSound)
{
   filename    = "./sound/arrowHit.wav";
   description = AudioClose3d;
   preload = true;
};

datablock AudioProfile(BASEFireSound)
{
   filename    = "./sound/bowFire.wav";
   description = AudioClosest3d;
   preload = true;
};


//arrow trail
datablock ParticleData(BASETrailParticle)
{
dragCoefficient = 3.0;
windCoefficient = 0.0;
gravityCoefficient = 0.0;
inheritedVelFactor = 0.0;
constantAcceleration = 0.0;
lifetimeMS = 2000;
lifetimeVarianceMS = 0;
spinSpeed = 10.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
useInvAlpha = false;
animateTexture = false;
//framesPerSec = 1;

textureName = "base/data/particles/ring";
//animTexName = "~/data/particles/dot";

// Interpolation variables
colors[0] = "1 1 1 0.2";
colors[1] = "1 1 1 0.0";
sizes[0] = 0.2;
sizes[1] = 0.01;
times[0] = 0.0;
times[1] = 1.0;
};

datablock ParticleEmitterData(BASETrailEmitter)
{
   ejectionPeriodMS = 2;
   periodVarianceMS = 0;

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

   ejectionOffset = 0;

   thetaMin         = 0.0;
   thetaMax         = 90.0; 

   particles = BASETrailParticle;
};

//effects
datablock ParticleData(BASEExplosionParticle)
{
dragCoefficient      = 5;
gravityCoefficient   = 0.1;
inheritedVelFactor   = 0.2;
constantAcceleration = 0.0;
lifetimeMS           = 500;
lifetimeVarianceMS   = 300;
textureName          = "base/data/particles/chunk";
spinSpeed = 10.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
colors[0]     = "0.9 0.9 0.6 0.9";
colors[1]     = "0.9 0.5 0.6 0.0";
sizes[0]      = 0.25;
sizes[1]      = 0.0;
};

datablock ParticleEmitterData(BASEExplosionEmitter)
{
   ejectionPeriodMS = 7;
   periodVarianceMS = 0;
   ejectionVelocity = 5;
   velocityVariance = 1.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 90;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "BASEExplosionParticle";
};

datablock ExplosionData(BASEExplosion)
{
   //explosionShape = "";
soundProfile = BASEExplosionSound;

   lifeTimeMS = 150;

   particleEmitter = BASEExplosionEmitter;
   particleDensity = 10;
   particleRadius = 0.2;

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

   shakeCamera = false;
   camShakeFreq = "10.0 11.0 10.0";
   camShakeAmp = "1.0 1.0 1.0";
   camShakeDuration = 0.5;
   camShakeRadius = 10.0;

   // Dynamic light
   lightStartRadius = 0;
   lightEndRadius = 2;
   lightStartColor = "0.3 0.6 0.7";
   lightEndColor = "0 0 0";
};


//projectile
AddDamageType("BASEDirect",   '<bitmap:add-ons/ci/star> %1',    '%2 <bitmap:add-ons/ci/arrow> %1',1,1);

datablock ProjectileData(BASEProjectile)
{
   projectileShapeName = "./shapes/por/pro.dts";

   directDamage        = 0;
   directDamageType    = $DamageType::BASEDirect;

   radiusDamage        = 0;
   damageRadius        = 0;
   radiusDamageType    = $DamageType::BASEDirect;

   explosion           = BASEExplosion;
   particleEmitter     = BASETrailEmitter;

   muzzleVelocity      = 500;
   velInheritFactor    = 1;

   armingDelay         = 0;
   lifetime            = 2000;
   fadeDelay           = 3500;
   bounceElasticity    = 0;
   bounceFriction      = 0;
   isBallistic         = true;
   gravityMod = 0.0;

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


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

// Basic Item Properties
shapeFile = "./shapes/por/gun.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;

//gui stuff
uiName = "Portable base Gun";
iconName = "./ItemIcons/BASE";
doColorShift = true;
colorShiftColor = "0.2 0.2 1 1.000";

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

////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(BASEImage)
{
   // Basic Item properties
   shapeFile = "./shapes/por/gun.dts";
   emap = true;

   // Specify mount point & offset for 3rd person, and eye offset
   // for first person rendering.
   mountPoint = 0;
   offset = "0 0 0";
   eyeOffset = 0; //"0.7 1.2 -0.5";
   rotation = eulerToMatrix( "0 0 10" );

   // 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 = true;

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

   // Projectile && Ammo.
   item = BASEItem;
   ammo = " ";
   projectile = BASEProjectile;
   projectileType = Projectile;

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

   doColorShift = true;
   colorShiftColor = BASEItem.colorShiftColor;//"0.400 0.196 0 1.000";

   //casing = " ";

   // 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] = weaponSwitchSound;

stateName[1]                     = "Ready";
stateSequence[1]                = "Ready";
stateTransitionOnTriggerDown[1]  = "Fire";
stateAllowImageChange[1]         = true;

stateName[2]                    = "Fire";
stateTransitionOnTimeout[2]     = "Reload";
stateTimeoutValue[2]            = 0.05;
stateFire[2]                    = true;
stateAllowImageChange[2]        = false;
stateSequence[2]                = "Fire";
stateScript[2]                  = "onFire";
stateWaitForTimeout[2] = true;
stateSound[2] = BASEFireSound;

stateName[3] = "Reload";
stateSequence[3]                = "Reload";
stateAllowImageChange[3]        = false;
stateTimeoutValue[3]            = 0.5;
stateWaitForTimeout[3] = true;
stateTransitionOnTimeout[3]     = "Check";

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

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


};

function BASEProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
if(isobject(%obj.client.BASEA) && isObject(%obj.client.BASEB)){
%obj.client.BASEA.delete();
%obj.client.BASEB.delete();
}
if(isObject(%obj.client.BASEA) && !isObject(%obj.client.BASEB)){
%pos2 = VectorAdd(%pos, "0 0" SPC 0.2);
%obj.client.BASEB = new StaticShape()
{
   position = %pos2;
   datablock = BASEB;
   scale = "2 2 2";
};
%obj.client.BASEB.otherBASE = %obj.client.BASEA;
%obj.client.BASEA.otherBASE = %obj.client.BASEB;
}

if(!isObject(%obj.client.BASEA) && !isObject(%obj.client.BASEB)){
%pos2 = VectorAdd(%pos, "0 0" SPC 0.2);
%obj.client.BASEA = new StaticShape()
{
   position = %pos2;
   datablock = BASEA;
   scale = "2 2 2";
};
}
}

datablock StaticShapeData(BASEA)
{
category = "BASE";   //Mission editor category
item = BASEbasea;
shapeFile = "./shapes/por/porb.dts";
};

datablock StaticShapeData(BASEB)
{
category = "BASE";   //Mission editor category
item = BASEbaseb;
shapeFile = "./shapes/por/porb.dts";
};

function ServerCmdDeleteBASEs(%client)
{
%client.BASEA.delete();
%client.BASEB.delete();
}
function baseA::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
}

function baseB::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
}

I don't know, But from looking, I'd say there's probably a few spelling errors in the code.

%obj.client should be %client.obj

I doubt there are spelling errors due to having of copied most the code from other mods to use as a starting function base.

One question, It's not a car mobile base, what is it, lol.

Do collisions work if you spawn one in F11?

*cough*thatlookslikemyportalcode*cough*...

*cough*thatlookslikemyportalcode*cough*...
*cough*moddded *cough

need some cough drops aloshi?

%obj.client should be %client.obj

I doubt there are spelling errors due to having of copied most the code from other mods to use as a starting function base.
nope clients can already hit there heads on it
EDIT:gun can shoot trew it....how do i fix this
« Last Edit: April 13, 2007, 05:15:13 PM by Grand Theif Fox »

You give me headaches trying to read your writing.




Oh, I wasn't blocked. Sorry.

Fixed code:

Code: [Select]
//porable base by grand theif fox
$hsinstall = 1;
datablock AudioProfile(BASEExplosionSound)
{
   filename    = "./sound/arrowHit.wav";
   description = AudioClose3d;
   preload = true;
};

datablock AudioProfile(BASEFireSound)
{
   filename    = "./sound/bowFire.wav";
   description = AudioClosest3d;
   preload = true;
};


//arrow trail
datablock ParticleData(BASETrailParticle)
{
dragCoefficient = 3.0;
windCoefficient = 0.0;
gravityCoefficient = 0.0;
inheritedVelFactor = 0.0;
constantAcceleration = 0.0;
lifetimeMS = 2000;
lifetimeVarianceMS = 0;
spinSpeed = 10.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
useInvAlpha = false;
animateTexture = false;
//framesPerSec = 1;

textureName = "base/data/particles/ring";
//animTexName = "~/data/particles/dot";

// Interpolation variables
colors[0] = "1 1 1 0.2";
colors[1] = "1 1 1 0.0";
sizes[0] = 0.2;
sizes[1] = 0.01;
times[0] = 0.0;
times[1] = 1.0;
};

datablock ParticleEmitterData(BASETrailEmitter)
{
   ejectionPeriodMS = 2;
   periodVarianceMS = 0;

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

   ejectionOffset = 0;

   thetaMin         = 0.0;
   thetaMax         = 90.0;

   particles = BASETrailParticle;
};

//effects
datablock ParticleData(BASEExplosionParticle)
{
dragCoefficient      = 5;
gravityCoefficient   = 0.1;
inheritedVelFactor   = 0.2;
constantAcceleration = 0.0;
lifetimeMS           = 500;
lifetimeVarianceMS   = 300;
textureName          = "base/data/particles/chunk";
spinSpeed = 10.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
colors[0]     = "0.9 0.9 0.6 0.9";
colors[1]     = "0.9 0.5 0.6 0.0";
sizes[0]      = 0.25;
sizes[1]      = 0.0;
};

datablock ParticleEmitterData(BASEExplosionEmitter)
{
   ejectionPeriodMS = 7;
   periodVarianceMS = 0;
   ejectionVelocity = 5;
   velocityVariance = 1.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 90;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "BASEExplosionParticle";
};

datablock ExplosionData(BASEExplosion)
{
   //explosionShape = "";
soundProfile = BASEExplosionSound;

   lifeTimeMS = 150;

   particleEmitter = BASEExplosionEmitter;
   particleDensity = 10;
   particleRadius = 0.2;

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

   shakeCamera = false;
   camShakeFreq = "10.0 11.0 10.0";
   camShakeAmp = "1.0 1.0 1.0";
   camShakeDuration = 0.5;
   camShakeRadius = 10.0;

   // Dynamic light
   lightStartRadius = 0;
   lightEndRadius = 2;
   lightStartColor = "0.3 0.6 0.7";
   lightEndColor = "0 0 0";
};


//projectile
AddDamageType("BASEDirect",   '<bitmap:add-ons/ci/star> %1',    '%2 <bitmap:add-ons/ci/arrow> %1',1,1);

datablock ProjectileData(BASEProjectile)
{
   projectileShapeName = "./shapes/por/pro.dts";

   directDamage        = 0;
   directDamageType    = $DamageType::BASEDirect;

   radiusDamage        = 0;
   damageRadius        = 0;
   radiusDamageType    = $DamageType::BASEDirect;

   explosion           = BASEExplosion;
   particleEmitter     = BASETrailEmitter;

   muzzleVelocity      = 500;
   velInheritFactor    = 1;

   armingDelay         = 0;
   lifetime            = 2000;
   fadeDelay           = 3500;
   bounceElasticity    = 0;
   bounceFriction      = 0;
   isBallistic         = true;
   gravityMod = 0.0;

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


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

// Basic Item Properties
shapeFile = "./shapes/por/gun.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;

//gui stuff
uiName = "Portable base Gun";
iconName = "./ItemIcons/BASE";
doColorShift = true;
colorShiftColor = "0.2 0.2 1 1.000";

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

////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(BASEImage)
{
   // Basic Item properties
   shapeFile = "./shapes/por/gun.dts";
   emap = true;

   // Specify mount point & offset for 3rd person, and eye offset
   // for first person rendering.
   mountPoint = 0;
   offset = "0 0 0";
   eyeOffset = 0; //"0.7 1.2 -0.5";
   rotation = eulerToMatrix( "0 0 10" );

   // 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 = true;

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

   // Projectile && Ammo.
   item = BASEItem;
   ammo = " ";
   projectile = BASEProjectile;
   projectileType = Projectile;

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

   doColorShift = true;
   colorShiftColor = BASEItem.colorShiftColor;//"0.400 0.196 0 1.000";

   //casing = " ";

   // 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] = weaponSwitchSound;

stateName[1]                     = "Ready";
stateSequence[1]                = "Ready";
stateTransitionOnTriggerDown[1]  = "Fire";
stateAllowImageChange[1]         = true;

stateName[2]                    = "Fire";
stateTransitionOnTimeout[2]     = "Reload";
stateTimeoutValue[2]            = 0.05;
stateFire[2]                    = true;
stateAllowImageChange[2]        = false;
stateSequence[2]                = "Fire";
stateScript[2]                  = "onFire";
stateWaitForTimeout[2] = true;
stateSound[2] = BASEFireSound;

stateName[3] = "Reload";
stateSequence[3]                = "Reload";
stateAllowImageChange[3]        = false;
stateTimeoutValue[3]            = 0.5;
stateWaitForTimeout[3] = true;
stateTransitionOnTimeout[3]     = "Check";

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

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


};

function BASEProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
if(isobject(%obj.client.BASEA) && isObject(%obj.client.BASEB))
{
%obj.client.BASEA.delete();
%obj.client.BASEB.delete();
}

if(isObject(%obj.client.BASEA) && !isObject(%obj.client.BASEB))
{
%pos2 = VectorAdd(%pos, "0 0" SPC 0.2);

%obj.client.BASEB = new StaticShape()
{
   position = %pos2;
   datablock = BASEB;
   scale = "2 2 2";
};

%obj.client.BASEB.otherBASE = %obj.client.BASEA;
%obj.client.BASEA.otherBASE = %obj.client.BASEB;
}

if(!isObject(%obj.client.BASEA) && !isObject(%obj.client.BASEB))
{
%pos2 = VectorAdd(%pos, "0 0" SPC 0.2);

%obj.client.BASEA = new StaticShape()
{
position = %pos2;
   datablock = BASEA;
   scale = "2 2 2";
};
}
}

datablock StaticShapeData(BASEA)
{
category = "BASE";   //Mission editor category
item = BASEA;
shapeFile = "./shapes/por/porb.dts";
};

datablock StaticShapeData(BASEB)
{
category = "BASE";   //Mission editor category
item = BASEB;
shapeFile = "./shapes/por/porb.dts";
};

function ServerCmdDeleteBASEs(%client)
{
%client.BASEA.delete();
%client.BASEB.delete();
}

function baseA::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
// Code..
}

function baseB::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
// Code..
}