Author Topic: Opening A Door  (Read 2224 times)

What are raycasting weapon fields? I've never heard of that.
Code: [Select]
//////////////////////////////////////////////////////////////////////////////////////////////////
//              Support_RaycastingWeapons.cs              //
//Creator: Space Guy [ID 130]                           //
//Allows you to create weapons that function by instant raycasts rather than projectiles   //
//Set these fields in the datablock:                        //
//raycastWeaponRange:      Range of weapon   (> 0)                  //
//raycastWeaponTargets:      Typemasks                     //
//raycastDirectDamage:      Direct Damage                     //
//raycastDirectDamageType:   Damage Type ID                     //
//raycastExplosionProjectile:   Creates this projectile on impact            //
//raycastExplosionSound:   AudioProfile of sound to play on impact            //
//                                    //
//Radius and Brick Damage can be done through the projectile and explosion.         //
//////////////////////////////////////////////////////////////////////////////////////////////////
You need to set those fields in the AlohomoraImage.

Code: [Select]
package AlohamoraDoorOpening
{
function AlohamoraImage::onHitObject(%this,%obj,%slot,%col,%pos,%normal)
{
if(%col.getDataBlock().category $= "JVS")
{
%col.doorOpen(0,0,"",%obj.client);
}
else
{
Parent::onHitObject(%this,%obj,%slot,%col,%pos,%normal);
}
}
};

activatePackage(AlohamoraDoorOpening);

Wouldn't this be easier? ^^

Code: [Select]
//////////////////////////////////////////////////////////////////////////////////////////////////
//              Support_RaycastingWeapons.cs              //
//Creator: Space Guy [ID 130]                           //
//Allows you to create weapons that function by instant raycasts rather than projectiles   //
//Set these fields in the datablock:                        //
//raycastWeaponRange:      Range of weapon   (> 0)                  //
//raycastWeaponTargets:      Typemasks                     //
//raycastDirectDamage:      Direct Damage                     //
//raycastDirectDamageType:   Damage Type ID                     //
//raycastExplosionProjectile:   Creates this projectile on impact            //
//raycastExplosionSound:   AudioProfile of sound to play on impact            //
//                                    //
//Radius and Brick Damage can be done through the projectile and explosion.         //
//////////////////////////////////////////////////////////////////////////////////////////////////
You need to set those fields in the AlohomoraImage.
Oh thats what those are for, ok well I keep getting syntax errors while referencing those... How do I set them? Ive tried like this:
Code: [Select]
datablock ShapeBaseImageData(AlohamoraImage : wandImage)
{
armReady        = true;
doColorShift    = true;
projectile      = AlohamoraProjectile;
raycastWeaponRange = 20
raycastWeaponTargets = FxBrickObjectType
raycastDirectDamage = 0
raycastExplosionProjectile = AlohamoraProjectile
};
Then I tried like this:
Code: [Select]
datablock ShapeBaseImageData(AlohamoraImage : wandImage)
{
armReady        = true;
doColorShift    = true;
projectile      = AlohamoraProjectile;
raycastWeaponRange: 20
raycastWeaponTargets: FxBrickObjectType
raycastDirectDamage: 0
raycastExplosionProjectile: AlohamoraProjectile
};
As in the spacecasts script. How would I set these?
EDIT: lol, silly me. This ended up working:
Code: [Select]
datablock ShapeBaseImageData(AlohamoraImage : wandImage)
{
armReady        = true;
doColorShift    = true;
projectile      = AlohamoraProjectile;
raycastWeaponRange = 20;
raycastWeaponTargets = $TypeMasks::FxBrickObjectType;
raycastDirectDamage = 0;
raycastExplosionProjectile = AlohamoraProjectile;
};
Thanks for all the help!
« Last Edit: May 21, 2009, 08:15:33 PM by lilboarder32 »

Well, I don't think it has to be that complicated, a door-opening hammer works like this:

Code: [Select]
package HammerDoorOpening
{
function HammerImage::onHitObject(%this,%obj,%slot,%col,%pos,%normal)
{
if(%col.getDataBlock().category $= "JVS")
{
%col.doorOpen(0,0,"",%obj.client);
}
else
{
Parent::onHitObject(%this,%obj,%slot,%col,%pos,%normal);
}
}
};

activatePackage(HammerDoorOpening);

So it could be pretty simple to do...

Code: [Select]
package AlohamoraDoorOpening
{
function AlohamoraImage::onHitObject(%this,%obj,%slot,%col,%pos,%normal)
{
if(%col.getDataBlock().category $= "JVS")
{
%col.doorOpen(0,0,"",%obj.client);
}
else
{
Parent::onHitObject(%this,%obj,%slot,%col,%pos,%normal);
}
}
};

activatePackage(AlohamoraDoorOpening);

^^ Use this format for future door openers, I tested it and it works btw ^^
« Last Edit: May 21, 2009, 08:16:31 PM by Club559 »

Well, I don't think it has to be that complicated, a door-opening hammer works like this:

-snip-

So it could be pretty simple to do...

-snip
Yes, but I am using the raycasting thing and just forgot to add the raycasting weapon fields. It works now so thanks for all the help.

EDIT:Ok, it's working fine now, just an explosion doesn't show up. I'll post script one more time cuz I cant figure out why any explosion shows.

Code: [Select]
datablock ItemData(AlohamoraItem)
{
category = "Weapon";  // Mission editor category
className = "Weapon"; // For inventory system

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

//gui stuff
uiName = "Alohamora";
iconName = "";
doColorShift = false;
//colorShiftColor = "0 0 1 1";

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

datablock ParticleData(AlohamoraExplosionParticle)
{
dragCoefficient      = 9.99995;
gravityCoefficient   = -0.002;
inheritedVelFactor   = 0.11;
constantAcceleration = 0.0;
spinRandomMin        = -90;
spinRandomMax        = 90;
lifetimeMS           = 400;
lifetimeVarianceMS   = 300;
textureName          = "base/data/particles/chunk";
colors[0]            = "0 0 1 0.6";
colors[1]            = "0 0 1 0.8";
colors[2]            = "0 0 1 1";
colors[3]            = "0 0 1 .4";
sizes[0]             = 0.3;
sizes[1]             = 0.3;
sizes[2]             = 0.2;
sizes[3]             = 0.2;
times[0]             = 0;
times[1]             = 0.8;
times[2]             = 1;
times[3]             = 2;
};

datablock ParticleEmitterData(AlohamoraExplosionEmitter)
{
ejectionPeriodMS = 2;
periodVarianceMS = 0;
ejectionVelocity = 10;
velocityVariance = 5;
ejectionOffset   = 0.25;
thetaMin         = 0;
thetaMax         = 120;
phiReferenceVel  = 0;
phiVariance      = 360;
overrideAdvance  = false;
particles        = "AlohamoraExplosionParticle";
};

datablock ExplosionData(AlohamoraExplosion : wandExplosion)
{
lifetimeMS      = 180;
emitter[0]      = AlohamoraExplosionEmitter;
lightStartColor = "0 0 1 .9";
lightEndColor   = "0 0 0 0";
};

datablock ParticleData(AlohamoraParticleA)
{
dragCoefficient      = 0;
gravityCoefficient   = -0.5;
inheritedVelFactor   = 0;
constantAcceleration = 0.0;
spinRandomMin        = -90;
spinRandomMax        = 90;
lifetimeMS           = 600;
lifetimeVarianceMS   = 200;
textureName          = "base/data/particles/dot";
colors[0]            = "0 0 1 0.9";
colors[1]            = "0 0 1 0.7";
colors[2]            = "0 0 1 0.5";
colors[3]            = "0 0 1 0.3";
sizes[0]             = 0.1;
sizes[1]             = 0.1;
sizes[2]             = 0.2;
sizes[3]             = 1;
times[0]             = 0;
times[1]             = 0.8;
times[2]             = 1;
times[3]             = 2;
};

datablock ParticleEmitterData(AlohamoraEmitterA)
{
ejectionPeriodMS = 10;
periodVarianceMS = 2;
ejectionVelocity = 0.2;
velocityVariance = 0;
ejectionOffset   = 0.09;
thetaMin         = 0;
thetaMax         = 180;
phiReferenceVel  = 0;
phiVariance      = 360;
overrideAdvance  = false;
particles        = "AlohamoraParticleA";
};


datablock ParticleData(AlohamoraParticleB)
{
dragCoefficient      = 0;
gravityCoefficient   = -0.2;
inheritedVelFactor   = 0.5;
constantAcceleration = 0.0;
spinRandomMin        = -90;
spinRandomMax        = 90;
lifetimeMS           = 600;
lifetimeVarianceMS   = 200;
textureName          = "base/data/particles/dot";
colors[0]            = "1 0 0 0.9";
colors[1]            = "1 0 0 0.9";
colors[2]            = "1 0 0 0.9";
colors[3]            = "1 0 0 0.9";
sizes[0]             = 0.1;
sizes[1]             = 0.1;
sizes[2]             = 0.2;
sizes[3]             = 1;
times[0]             = 0;
times[1]             = 0.8;
times[2]             = 1;
times[3]             = 2;
};

datablock ParticleEmitterData(AlohamoraEmitterB)
{
ejectionPeriodMS = 4;
periodVarianceMS = 2;
ejectionVelocity = 0.2;
velocityVariance = 0;
ejectionOffset   = 0.09;
thetaMin         = 0;
thetaMax         = 180;
phiReferenceVel  = 0;
phiVariance      = 360;
overrideAdvance  = false;
particles        = "AlohamoraParticleB";
};

datablock ProjectileData(AlohamoraProjectile)
{
//   projectileShapeName = "./bullet.dts";
   directDamage        = 0;

   brickExplosionRadius = 0;
   brickExplosionImpact = false;          //destroy a brick if we hit it directly?
   brickExplosionForce  = 0;
   brickExplosionMaxVolume = 0;          //max volume of bricks that we can destroy
   brickExplosionMaxVolumeFloating = 0;  //max volume of bricks that we can destroy if they aren't connected to the ground

   impactImpulse      = 1900;
   verticalImpulse   = 400;
   explosion           = AlohamoraExplosion;

   muzzleVelocity      = 200;
   velInheritFactor    = 1;

   armingDelay         = 00;
   lifetime            = 9000;
   fadeDelay           = 8500;
   bounceElasticity    = 0.5;
   bounceFriction      = 0.20;
   isBallistic         = false;
   gravityMod = 0.0;

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


datablock ShapeBaseImageData(AlohamoraImage : wandImage)
{
armReady        = true;
doColorShift    = true;
projectile      = AlohamoraProjectile;
raycastWeaponRange = 20;
raycastWeaponTargets = $TypeMasks::FxBrickObjectType;
raycastDirectDamage = 0;
raycastExplosionProjectile = AlohamoraProjectile;
};

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

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



function AlohamoraImage::onHitObject(%this,%obj,%slot,%col,%pos,%normal)
{
if((%col.getType() & $TypeMasks::FxBrickObjectType))
{
if(%col.doorID() > -1)
{
%col.doorOpen(0,0,"",%obj.client);

%col.schedule(3000, "doorClose");
}
}
}
exec("./support_Spacecasts.cs");

Entire script if you dont want to download.
« Last Edit: May 21, 2009, 08:32:42 PM by lilboarder32 »

Step 1: Put it in to a package.
Step 2: Edit the code inside the package to look like this.
Code: [Select]
function AlohamoraImage::onHitObject(%this,%obj,%slot,%col,%pos,%normal)
{
if((%col.getType() & $TypeMasks::FxBrickObjectType))
{
if(%col.doorID() > -1)
{
%col.doorOpen(0,0,"",%obj.client);

%col.schedule(3000, "doorClose");
Parent::onHitObject(%this,%obj,%slot,%col,%pos,%normal);
}
}
else
{
Parent::onHitObject(%this,%obj,%slot,%col,%pos,%normal);
}
}
Step 3: Add this code after the package.
Code: [Select]
activatePackage(packageNameNotInQuotes);
Then everything should work fine!

Okay, works now! Thanks for the help!

Now, I have another question... I don't wanna start another topic, so I'll post it here. Could I do the exact same thing, but target a player instead and turn their screen white? Would this work at all?
Code: [Select]
package Conjunctivitus
{
function ConjunctivitusImage::onHitObject(%this,%obj,%slot,%col,%pos,%normal)
{
if((%col.getType() & $TypeMasks::PlayerObjectType))
{
%col.player.setWhiteOut(.8);
Parent::onHitObject(%this,%obj,%slot,%col,%pos,%normal);
}
else
{
Parent::onHitObject(%this,%obj,%slot,%col,%pos,%normal);
}
}
};

activatePackage(Conjunctivitus);
exec("./support_Spacecasts.cs");

Well it should work. Try it out.

Okay, works now! Thanks for the help!

Now, I have another question... I don't wanna start another topic, so I'll post it here. Could I do the exact same thing, but target a player instead and turn their screen white? Would this work at all?
Code: [Select]
package Conjunctivitus
{
function ConjunctivitusImage::onHitObject(%this,%obj,%slot,%col,%pos,%normal)
{
if((%col.getType() & $TypeMasks::PlayerObjectType))
{
%col.player.setWhiteOut(.8);
Parent::onHitObject(%this,%obj,%slot,%col,%pos,%normal);
}
else
{
Parent::onHitObject(%this,%obj,%slot,%col,%pos,%normal);
}
}
};

activatePackage(Conjunctivitus);
exec("./support_Spacecasts.cs");
Look at some flash-bang grenade, think it's just flash grenade.

It should just be %col, not %col.player.

It should just be %col, not %col.player.
K, I put that, but I keep getting syntax errors on the .8 part. It shows the halt at:
%col.setWhiteOut(##.8##);
?

You need a numeral before the dot point, ie. 0.8

XD woops, thanks.
« Last Edit: May 25, 2009, 07:19:49 PM by lilboarder32 »