Author Topic: Help for BL RTS: Directional fireRelay code  (Read 510 times)

Hey I posted a reply on one of my threads and forgot that I had to ask it here. So here it is:

Quote
You know how I was saying the Events weren't working properly? Well take a look at this. Say I use this output in the direction of up. With the way this is written, it would only work if the target brick overlaps the center. In the case that the target brick is offset away from the center (which is my case all the time) the event doesn't even work.

The default events of fireRelayUp etc. use some sort of dynamic tracking system that tracks the nearest target brick no matter it's position along the original brick's edge. It also (surprise, surprise) can activate ALL the bricks along it's edge. So to everyone who thought I just sucked, go suck an egg. Anyhoo, how do I take a look at the default directional fireRelay events' code so I can edit/report this VCE event?

Code: [Select]
function fxDtsBrick::VCE_relayCallFunction(%brick,%direction,%name,%args,%client)
{
%start = posFromTransform(%brick.getTransform());
%db = %brick.getDatablock();
%angle = %brick.getAngleID();
if(%angle == 1 || %angle == 3)
{
%addX = %db.brickSizeY * 0.55;
%addY = %db.brickSizeX * 0.55;
}
else
{
%addX = %db.brickSizeX * 0.55;
%addY = %db.brickSizeY * 0.55;
}
%addZ = %db.brickSizeZ * 0.22;
//Up Down North East South West
switch(%direction)
{
case 0:
%add = 0 SPC 0 SPC %addZ;
case 1:
%add = 0 SPC 0 SPC -%addZ;
case 2:
%add = 0 SPC %addY SPC 0;
case 3:
%add = %addX SPC 0 SPC 0;
case 4:
%add = 0 SPC -%addY SPC 0;
case 5:
%add = -%addX SPC 0 SPC 0;
}
%end = vectorAdd(%start,%add);
%ray = containerRaycast(%start,%end,$TypeMasks::FxBrickAlwaysObjectType,%brick);
%col = firstWord(%ray);
if(isObject(%col))
{
if(getTrustLevel(%col,%brick) < 2)
return;
%col.VCE_callFunction(%name,%args,%client);
}
}
« Last Edit: August 08, 2011, 07:30:05 PM by onesis »

ContainerRaycast will make a straight line searching for bricks. You'll probably want to use initContainerBoxSearch (the arguments are %center, %size (I'm not sure what exactly this is), %typemasks).

Thanks that helps a lot. Now...how do I use it =P

The fillcan uses it, you should be able to figure out how to use it from poking around with the fillcan.


This is what I modified it to, but now it doesn't even work. I don't know this scripting language at all I'm just guessing based on what I know about c++.

Code: [Select]
function fxDtsBrick::VCE_relayCallFunction(%brick,%direction,%name,%args,%client)
{
%start = posFromTransform(%brick.getTransform());
%db = %brick.getDatablock();
%angle = %brick.getAngleID();
if(%angle == 1 || %angle == 3)
{
%addX = %db.brickSizeY * 0.55;
%addY = %db.brickSizeX * 0.55;
}
else
{
%addX = %db.brickSizeX * 0.55;
%addY = %db.brickSizeY * 0.55;
}
%addZ = %db.brickSizeZ * 0.22;
//Up Down North East South West
switch(%direction)
{
case 0:
%add = 0 SPC 0 SPC %addZ;
case 1:
%add = 0 SPC 0 SPC -%addZ;
case 2:
%add = 0 SPC %addY SPC 0;
case 3:
%add = %addX SPC 0 SPC 0;
case 4:
%add = 0 SPC -%addY SPC 0;
case 5:
%add = -%addX SPC 0 SPC 0;
}
%end = vectorAdd(%start,%add);
//Up Down North East South West
switch(%direction)
{
case 0:
%box = (%addX-0.1) SPC (%addY-0.1) SPC (0.1);
case 1:
%box = (%addX-0.1) SPC (%addY-0.1) SPC (0.1);
case 2:
%box = (%addX-0.1) SPC (0.1) SPC (%addZ-0.1);
case 3:
%box = (0.1) SPC (%addY-0.1) SPC (%addZ-0.1);
case 4:
%box = (%addX-0.1) SPC (0.1) SPC (%addZ-0.1);
case 5:
%box = (0.1) SPC (%addY-0.1) SPC (%addZ-0.1);
}
%ray = InitContainerBoxSearch(%end,%box,$TypeMasks::FxBrickAlwaysObjectType);
%col = firstWord(%ray);
if(isObject(%col))
{
if(getTrustLevel(%col,%brick) < 2)
return;
%col.VCE_callFunction(%name,%args,%client);
}
}

and in the bottom switch i tried db.bricksize first, and without all the 0.1's