fxReplicatorBlocker
by Thomas \"Man of Ice\" Lund · 09/21/2004 (3:08 pm) · 17 comments
Download Code File
What is this
I've always felt the replicators to be powerful, and thanks Melv for those! But they are lacking a little, and today I finally got around to do something about some of the things I feel are missing.
This is a nifty little new object type that allows you to block out replication inside a replicator area. The idea has long been in my head, and today I saw the unused VehicleBlocker code. So I jumped right into it and coded away.
Screenshots tell it all, so here is one:

Dump some of these into your scene and you can have 1 replicator create a huge forrest, and the blockers then "carve" paths through the forrest as needed. The alternative would be to have tons of replicators and fiddling with their sizes and rotations.
Engine changes
It is quite easy to add this.
Add the 2 attached files to the game/fx dir, and then do the following changes
main.cc
After this
objectTypes.h
After this
fxShapeReplicator changes
in game/fx/fxShapeReplicator.cc find this
and change it to
Script changes
Open common/editor/objectBuilderGui.gui and add this somewhere in there
Open common/editor/EditorGui.cs and find this:
(or whatever is the next item number)
Thats it!!
In your mission editor add replicators and blockers as you see fit. Good luck and enjoy!!
TODO
I ran out of time for today, so I didnt get the blockers to properly update themselves graphically when you change their dimension. A save/reload of the level does the trick.
This should also go into the foilage replicator, but I ran out of time. I'll add this later too.
What is this
I've always felt the replicators to be powerful, and thanks Melv for those! But they are lacking a little, and today I finally got around to do something about some of the things I feel are missing.
This is a nifty little new object type that allows you to block out replication inside a replicator area. The idea has long been in my head, and today I saw the unused VehicleBlocker code. So I jumped right into it and coded away.
Screenshots tell it all, so here is one:

Dump some of these into your scene and you can have 1 replicator create a huge forrest, and the blockers then "carve" paths through the forrest as needed. The alternative would be to have tons of replicators and fiddling with their sizes and rotations.
Engine changes
It is quite easy to add this.
Add the 2 attached files to the game/fx dir, and then do the following changes
main.cc
After this
Con::setIntVariable("$TypeMasks::StaticRenderedObjectType", StaticRenderedObjectType);
Con::setIntVariable("$TypeMasks::DamagableItemObjectType", DamagableItemObjectType);add thisCon::setIntVariable("$TypeMasks::fxReplicatorBlockerObjectType", fxReplicatorBlockerObjectType);objectTypes.h
After this
DamagableItemObjectType = bit(27),add this
fxReplicatorBlockerObjectType = bit(28),
fxShapeReplicator changes
in game/fx/fxShapeReplicator.cc find this
// Initialise RayCast Search Start/End Positions.
ShapeStart = ShapeEnd = ShapePosition;
ShapeStart.z = 2000.f;
ShapeEnd.z= -2000.f;and change it to
// Initialise RayCast Search Start/End Positions.
ShapeStart = ShapeEnd = ShapePosition;
ShapeStart.z = 2000.f;
ShapeEnd.z= -2000.f;
// Check for blockers
RayInfo BlockerRayEvent;
if (isServerObject()) {
if (gServerContainer.collideBox(ShapeStart, ShapeEnd, fxReplicatorBlockerObjectType, &BlockerRayEvent)) {
continue;
}
} else {
if (gClientContainer.collideBox( ShapeStart, ShapeEnd, fxReplicatorBlockerObjectType, &BlockerRayEvent)) {
continue;
}
}Script changes
Open common/editor/objectBuilderGui.gui and add this somewhere in there
function ObjectBuilderGui::buildfxReplicatorBlocker(%this)
{
%this.className = "fxReplicatorBlocker";
%this.addField("dimensions", "TypePoint3", "Dimensions", "2 2 2");
%this.process();
}Open common/editor/EditorGui.cs and find this:
%Environment_Item[10] = "fxFoliageReplicator"; %Environment_Item[11] = "fxLight";and add this
%Environment_Item[12] = "fxReplicatorBlocker";
(or whatever is the next item number)
Thats it!!
In your mission editor add replicators and blockers as you see fit. Good luck and enjoy!!
TODO
I ran out of time for today, so I didnt get the blockers to properly update themselves graphically when you change their dimension. A save/reload of the level does the trick.
This should also go into the foilage replicator, but I ran out of time. I'll add this later too.
#2
09/21/2004 (4:54 pm)
Classic. I'll re-upload tonight (@work now). I'll post here when I re-uploaded the file.
#3
Oh! And remember that you need to hit "Apply" on the replicator to force it to place the shapes. Just adding the blocker will not trigger replication
09/21/2004 (10:55 pm)
OK - reuploadet the zip. I hope that did itOh! And remember that you need to hit "Apply" on the replicator to force it to place the shapes. Just adding the blocker will not trigger replication
#5
09/22/2004 (4:49 am)
nice
#7
Also I haven't looked but are fxShapeReplicator and fxFoliageReplicator up to date with the latest GG changes in 1.3? I am thinking specifically of the databits changes I am pretty sure that Foliage is but I hadn't thought about Shape until I saw this resource.
09/22/2004 (6:44 am)
A really nice idea. Look forward to your redux with fxFoliageReplicator!!Also I haven't looked but are fxShapeReplicator and fxFoliageReplicator up to date with the latest GG changes in 1.3? I am thinking specifically of the databits changes I am pretty sure that Foliage is but I hadn't thought about Shape until I saw this resource.
#8
09/22/2004 (5:17 pm)
Very cool :)
#9
in game/fx/fxFoliageReplicator.cc find this
FoliageStart = FoliageEnd = FoliagePosition;
FoliageStart.z = 2000.f;
FoliageEnd.z= -2000.f;
and change it to
// Check for blockers
RayInfo BlockerRayEvent;
if (isServerObject())
{
if (gServerContainer.collideBox(FoliageStart, FoliageEnd, fxReplicatorBlockerObjectType, &BlockerRayEvent))
{
continue;
}
}
else
{
if (gClientContainer.collideBox( FoliageStart, FoliageEnd, fxReplicatorBlockerObjectType, &BlockerRayEvent))
{
continue;
}
}
03/07/2005 (12:52 am)
To get this working with fxFoliageReplicator...in game/fx/fxFoliageReplicator.cc find this
FoliageStart = FoliageEnd = FoliagePosition;
FoliageStart.z = 2000.f;
FoliageEnd.z= -2000.f;
and change it to
// Check for blockers
RayInfo BlockerRayEvent;
if (isServerObject())
{
if (gServerContainer.collideBox(FoliageStart, FoliageEnd, fxReplicatorBlockerObjectType, &BlockerRayEvent))
{
continue;
}
}
else
{
if (gClientContainer.collideBox( FoliageStart, FoliageEnd, fxReplicatorBlockerObjectType, &BlockerRayEvent))
{
continue;
}
}
#10
08/25/2005 (9:19 pm)
this is good , thank you thomas.
#11
For example.. I've got a massive forrest populated using replicators, containing trees, shrubs, grass... etc..
Then along comes a missile and blows a chunk out of the ground, destroying all trees, sending debris into the air...fires and so on.. places a ReplicatorBlocker where the trees once were, leaving a nice large hole in the forrest.
can this be done or is this a mission startup time only object?
02/20/2006 (11:14 pm)
Sorry for the necro, but can this be used in real time?...For example.. I've got a massive forrest populated using replicators, containing trees, shrubs, grass... etc..
Then along comes a missile and blows a chunk out of the ground, destroying all trees, sending debris into the air...fires and so on.. places a ReplicatorBlocker where the trees once were, leaving a nice large hole in the forrest.
can this be done or is this a mission startup time only object?
#12
02/21/2006 (3:53 am)
Hey Jason, I'm not actually using the blocker but I've looked at the code a bit. In general it's a mission loadtime event that places all the trees, and would look to the blocker to not place the trees there. What you would want to do is modify the fxfoliagereplicator or the shape replicator or whatever to take some sort of bounding volume and remove any trees / foliage items it's placed within those bounds in realtime. I've thought about doing this myself for certain things with the fxfoliagereplicator, just haven't done it yet.
#13
Yeah - its a load time thing. fxReplicator shoots rays to place the trees.
But in theory it should be quite easy to write a different kind of object, that based on a radius does a setVisible(false) on every object of type X. It would even be a script only thing.
Just an idea to get you on track.
02/21/2006 (6:40 am)
HeyYeah - its a load time thing. fxReplicator shoots rays to place the trees.
But in theory it should be quite easy to write a different kind of object, that based on a radius does a setVisible(false) on every object of type X. It would even be a script only thing.
Just an idea to get you on track.
#14
04/26/2006 (2:48 pm)
Thankyou so much for this resource. It helps me out alot! Btw, it works fine in TGE 1.4.
#15
EDIT: One thing that tripped my build up:
fxReplicatorBlockerObjectType = bit(28),
This looks like it needs to be BIT(28), in TGE 1.5. I got lots (and lots) of errors, but they all went away after changing this.
EDIT: Upon testing, I found that I'm getting an error. Whenever I try to create or load an fxShapeReplicator, I get the following error:
01/30/2007 (3:10 am)
Excellent idea ;) Thanks for taking the time and initiative to work it up.EDIT: One thing that tripped my build up:
fxReplicatorBlockerObjectType = bit(28),
This looks like it needs to be BIT(28), in TGE 1.5. I got lots (and lots) of errors, but they all went away after changing this.
EDIT: Upon testing, I found that I'm getting an error. Whenever I try to create or load an fxShapeReplicator, I get the following error:
#16
08/18/2008 (6:15 am)
Unfortunately, I'm getting the same error.
#17
01/28/2009 (10:45 pm)
Works in TGEA 1.8.
Torque Owner Markus Nuebel
Can you re-upload it?