Author Topic: Opening A Door  (Read 2233 times)

Bushido's damage isnt the thing that stores the instant hit and stuff. It's the projectile. And it uses space casts.
You have to exec spacecasts and do this:
Quote
//////////////////////////////////////////////////////////////////////////////////////////////////
//              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.         //
//////////////////////////////////////////////////////////////////////////////////////////////////

Wow, thank you so much for your help! So do I need to edit anything from the spacecasts script besides whats in the box and un-note it? I noticed it said like WeaponImage in there and stuff, do I need to put in my weapon name?

Wow, thank you so much for your help! So do I need to edit anything from the spacecasts script besides whats in the box and un-note it? I noticed it said like WeaponImage in there and stuff, do I need to put in my weapon name?
No, no it should be fine as long as you put the typemasks as the type mask for fxDtsBrickData.

Use %brick.doorOpen(0,0,"",%client)

The open direction (second argument) must be defined as "0" or "1" to open right.

I am just not very good with scripts, am I? Ugh, still not opening. Here's refined script:
Code: [Select]
function AlohamoraImage::onHitObject(%this,%obj,%slot,%col,%pos,%normal)
{
if((%col.getType() & $typeMasks::fxDtsBrickData))
{
if(isObject(%col.door))
{
%brick.doorOpen(0,0,"",%client);

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

I am just not very good with scripts, am I? Ugh, still not opening. Here's refined script:
Code: [Select]
function AlohamoraImage::onHitObject(%this,%obj,%slot,%col,%pos,%normal)
{
if((%col.getType() & $typeMasks::fxDtsBrickData))
{
if(isObject(%col.door))
{
%brick.doorOpen(0,0,"",%client);

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

Maybe change %client to %obj.client


Change %brick to %col (so it's the brick you hit), %client to %obj.client (so it's the person who fired it) and $typeMasks::fxDtsBrickData to $TypeMasks::FxBrickObjectType. (so it actually has the right type mask)

The exec line should ideally go in server.cs. You should then put the relevant fields for the explosions/etc. in AlohamoraImage. At least the range must be set for it to work, the rest will cause explosions/sounds on impact if you want like a normal bullet. (I assume you don't need damage for a "door opener", so set damage to 0 and leave the damage type out)

You might also want to use the Minigame door opening instead of Unrestricted as it currently is, if this item is going to be publicly released.
« Last Edit: May 20, 2009, 11:39:51 AM by Space Guy »

Okay, thanks. I tried all that and changed it all, yet it still does not open the door. Heres code:
Code: [Select]
function AlohamoraImage::onHitObject(%this,%obj,%slot,%col,%pos,%normal)
{
if((%col.getType() & $TypeMasks::FxBrickObjectType))
{
if(isObject(%col.door))
{
%col.doorOpen(0,0,"",%obj.client);

%col.schedule(3000, "doorClose");
}
}
}
exec("./support_Spacecasts.cs");
All of that is in the server.cs and I will post the entire script

Try taking away the if(isObject(%col.door)) part. See if it works, and post your results here.

Nope, didn't seem to change anything.

Try taking away the if(isObject(%col.door)) part. See if it works, and post your results here.
Why would that help? That would simply make it try and open and close bricks that may not even be doors.
EDIT: Although if(%col.doorID() > -1) might be a better way to check.
« Last Edit: May 21, 2009, 04:36:37 AM by Destiny/Zack0Wack0 »

You have not set up the ShapeBaseImageData's raycasting weapons fields. It will not fire at all until you do this.

What are raycasting weapon fields? I've never heard of that.

Try editing this script to your needs to see if it helps you. I've been exploring most of the coding help section now.

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

function serverCmdTogDoorOpener(%client)
{
if(!%client.canOpenDoorsWithHammah)
{
%client.canOpenDoorsWithHammah=1;
messageClient(%client,'',"\c6Opening doors with hammer: \c2ENABLED");
}
else
{
%client.canOpenDoorsWithHammah=0;
messageClient(%client,'',"\c6Opening doors with hammer: \c0DISABLED");
}
}

activatePackage(DoorOpener9000);
echo("Doors may now be barged into / opened with a \c4hammer\c0.");
« Last Edit: May 21, 2009, 06:23:27 PM by Club559 »