Author Topic: Opening A Door  (Read 2250 times)

I am just creating an item that when the projectile collides with a door, it opens the door. I just have a few questions.
1. Can you just make it so it triggers the output event?
2. Do I need to add the doorOpen output event function from the JVS script?
Here is my code as of now:
Code: [Select]
function OpenProjectile::OnCollision(%this, %target)

{
%target = $typeMasks::fxDtsBrickAlwaysObjectType;

if(!isObject(%target))
{
messageClient(%client, '', "\c6You must use this on a door.");

return;
}
if(%target.category $= "JVS")
{
processOutputEvent(doorOpen);
}
}

Here is the code from JVS:
Code: [Select]
function fxDTSBrick::doorOpen(%obj,%openType,%openDir,%text,%client)
{
%doorID = %obj.doorID();
%direction[0] = "CW";
%direction[1] = "CCW";
%direction = %direction[%openDir];

if(%openType < DoorRestrictionsSO.numRestrictions && (%direction $= "CCW" || %direction $= "CW") && %doorID > -1)
{
%obj.doorCheck();
%permitted = -1;

if(%openType == 0)
{
%permitted = 1;
}
else
{
%action = "OPEN";
eval("%permitted = %obj." @ DoorRestrictionsSO.restrictionMethod[%openType] @ "(%action,%direction,%text,%client);");
}

if(%permitted == 1)
{
%obj.doorPermittedUse(%client,0,"OPEN",%direction);
}
else if(%permitted == 0)
{
%obj.onDoorRestricted(%client);
}
}
}
Do I need to implement the JVS function in my script? Or how can I just trigger the doorOpen output event?

Tom

Code: [Select]
function CityRPBatonProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal)
{
serverPlay3D(hammerHitSound, %pos);

if((%col.getType() & $typeMasks::fxBrickObjectType))
{
if(isObject(%col.door))
{
%col.doorOpen();

%col.schedule(3000, "doorClose");
}

return;
}
From cityRP code.

Code: [Select]
function CityRPBatonProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal)
{
serverPlay3D(hammerHitSound, %pos);

if((%col.getType() & $typeMasks::fxBrickObjectType))
{
if(isObject(%col.door))
{
%col.doorOpen();

%col.schedule(3000, "doorClose");
}

return;
}
From cityRP code.
Wow, I totally forgot about that! Thanks!
EDIT: Okay so now I have implemented that CityRP code, yet it doesn't work exactly. Here is code as of now:
Code: [Select]
function openProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal)
{
if((%col.getType() & $typeMasks::fxBrickObjectType))
{
if(isObject(%col.door))
{
%col.doorOpen();

%col.schedule(3000, "doorClose");
}
return;
}
}
« Last Edit: May 17, 2009, 08:22:47 PM by lilboarder32 »

Tom

How is it not working. Also, the return is not needed.

Okay I changed that around a bit, but I have an idea why it might not work. I set up the projectile like the Old School Rifle by Bushido so it hits really fast, would that cause onCollision to screw up?
Here is my code now, I changed FxBrickObjectType to FxDtsBrickType and removed the return, so do you see any problems?
Code: [Select]
function OpenProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal)
{
if((%col.getType() & $typeMasks::fxDtsBrickType))
{
if(isObject(%col.door))
{
%col.doorOpen();

%col.schedule(3000, "doorClose");
}
}
}

When using the raycasting weapons script, you should use [Weapon Image, probably openImage]::onHitObject(%this,%obj,%slot,%col,%pos,%normal), not projectile collision.

Since a raycast isn't actually a projectile, it doesn't return as a projectile collision. A raycast is like an instant beam that shoots from something, but it's invisible.

Since a raycast isn't actually a projectile, it doesn't return as a projectile collision. A raycast is like an instant beam that shoots from something, but it's invisible.
He's using Space Guy's instant hit system, according to the fact that he said something about basing it off the old school rifle.

Still not working XD. Heres code:
Code: [Select]
function OpenImage::onHitObject(%this,%obj,%slot,%col,%pos,%normal)
{
if((%col.getType() & $typeMasks::fxDtsBrickType))
{
if(isObject(%col.door))
{
%col.doorOpen();

%col.schedule(3000, "doorClose");
}
}
}

He's using Space Guy's instant hit system, according to the fact that he said something about basing it off the old school rifle.
What are you saying? Am I wrong? I know what hes doing.

On topic: You should just do a raycast your self. I'll help you later maybe.
« Last Edit: May 18, 2009, 09:51:12 PM by AGlass0fMilk »

Getting to work on an Alohamora wand? ;)
Good luck!

What are you saying? Am I wrong? I know what hes doing.
I'm saying he's using space guy's instant raycast projectile system. Like space guy mentioned theres a custom collision function (onHitObject)...

lilboarder I have no idea whats going wrong but your scripts never seem to work when they should be.
« Last Edit: May 18, 2009, 11:10:01 PM by Destiny/Zack0Wack0 »

I'm saying he's using space guy's instant raycast projectile system. Like space guy mentioned theres a custom collision function (onHitObject)...

lilboarder I have no idea whats going wrong but your scripts never seem to work when they should be.
Haha I know! I'm working on a mod for Cucumber's RPG. If I post the whole script will you take a look at it to see if theres anything I put wrong?


Ok, thanks. Here is the server.cs, the item name is changed for cucumber's rpg so its not actually called "open".