by date
Dynamic create/remove foliage on client/server
Dynamic create/remove foliage on client/server
| Name: | Kefan Xu | |
|---|---|---|
| Date Posted: | Nov 02, 2006 | |
| Rating: | Not Rated | |
| Public: | YES | |
| Comments: | YES | |
| RSS Feed: | or Subscribe with . | |
| Profile Page: | View profile page for Kefan Xu |
Blog post
This is an example of dynamic create fxShapeReplicator type object
on both clients and server, will generalte flowers from player's current
position, hope others can find this helpful.
I was looking for a solution to do this, and i found this thread
www.garagegames.com/mg/forums/result.thread.php?qt=18448,
so here we have some example code here.
Some notes:
1. you need to replace shapeFile = "~/data/shapes/Plants/flower.dts";
with your own shape file.
2. to remove object, this may not need commandToclient(%cl, 'doReplicate');
3. you can change fxShapeReplicator to fxFoliageReplicator, it should works
also, but not tested.
4. This is just a testing code.
--------------------------Client code:-----------------------------------------------------
---------------------------------Server code: -----------------------------------------------
on both clients and server, will generalte flowers from player's current
position, hope others can find this helpful.
I was looking for a solution to do this, and i found this thread
www.garagegames.com/mg/forums/result.thread.php?qt=18448,
so here we have some example code here.
Some notes:
1. you need to replace shapeFile = "~/data/shapes/Plants/flower.dts";
with your own shape file.
2. to remove object, this may not need commandToclient(%cl, 'doReplicate');
3. you can change fxShapeReplicator to fxFoliageReplicator, it should works
also, but not tested.
4. This is just a testing code.
--------------------------Client code:-----------------------------------------------------
$rshapes = new simGroup(rshapes);
function clientCmdCreateFlowers(%pos)
{
schedule(1000, 0, "CreateFlowers", %pos);
}
function clientCmdDoReplicate()
{
schedule(2000, 0, "startFoliageReplication");
schedule(2800, 0, "startClientReplication");
}
function CreateFlowers(%pos)
{
logMessage("clientCmdCreateFlower:" @ %pos, 1);
%flowers = new fxShapeReplicator(Flowers) {
position = %pos;
rotation = "1 0 0 0";
scale = "1 1 1";
HideReplications = "0";
ShowPlacementArea = "1";
PlacementAreaHeight = "25";
PlacementColour = %pos;
shapeFile = "~/data/shapes/Plants/flower.dts";
Seed = "1376312589";
ShapeCount = "148";
ShapeRetries = "80";
InnerRadiusX = "0";
InnerRadiusY = "0";
OuterRadiusX = "280";
OuterRadiusY = "280";
AllowOnTerrain = "1";
AllowOnInteriors = "1";
AllowOnStatics = "1";
AllowOnWater = "0";
AllowWaterSurface = "0";
AlignToTerrain = "0";
Interactions = "1";
AllowedTerrainSlope = "90";
TerrainAlignment = "1 1 1";
FixShapeAspect = "0";
ShapeScaleMin = "0.43 0.43 0.43";
ShapeScaleMax = "1.18 1.18 1.18";
ShapeRotateMin = "0 0 0";
ShapeRotateMax = "0 0 0";
OffsetZ = "0";
};
rshapes.add(%flowers);
}
function clientCmdRMFlowers()
{
schedule(100, 0, "rmFlowers");
}
function rmFlowers()
{
%count = rshapes.getCount();
logMessage("rmFlowers:" @ %count, 1);
for(%i=0; %i<%count; %i++)
{
%obj = rshapes.getObject(%i);
logMessage("rmFlowers:" @ %obj, 1);
rshapes.remove(%obj);
%obj.schedule(10, "delete");
%count --;
%i--;
}
}
---------------------------------Server code: -----------------------------------------------
$rshapes = new simGroup(rshapes);
function ServerCmdCreateFlowers(%client)
{
%count = ClientGroup.getCount();
%pos = vectorAdd(%client.player.getPosition(), "0 0 2");
createFlowers(%pos);
logMessage("CmdCreateFlowers:" @ %pos, 1);
for (%i = 0; %i < %count; %i++)
{
%cl = ClientGroup.getObject(%i);
if( !%cl.isAIControlled() ){
commandToclient(%cl, 'CreateFlowers', %pos);
commandToclient(%cl, 'doReplicate');
}
}
}
function createFlowers(%pos)
{
logMessage("clientCmdCreateFlower:" @ %pos, 1);
%flowers = new fxShapeReplicator(Flowers) {
position = "-188.838 -108.911 168.018";
rotation = "1 0 0 0";
scale = "1 1 1";
HideReplications = "0";
ShowPlacementArea = "1";
PlacementAreaHeight = "25";
PlacementColour = "0.400000 0.000000 0.800000 1.000000";
shapeFile = "~/data/shapes/Plants/flower.dts";
Seed = "1376312589";
ShapeCount = "148";
ShapeRetries = "80";
InnerRadiusX = "0";
InnerRadiusY = "0";
OuterRadiusX = "280";
OuterRadiusY = "280";
AllowOnTerrain = "1";
AllowOnInteriors = "1";
AllowOnStatics = "1";
AllowOnWater = "0";
AllowWaterSurface = "0";
AlignToTerrain = "0";
Interactions = "1";
AllowedTerrainSlope = "90";
TerrainAlignment = "1 1 1";
FixShapeAspect = "0";
ShapeScaleMin = "0.43 0.43 0.43";
ShapeScaleMax = "1.18 1.18 1.18";
ShapeRotateMin = "0 0 0";
ShapeRotateMax = "0 0 0";
OffsetZ = "0";
};
rshapes.add(%flowers);
}
function ServerCmdRMFlowers(%client)
{
rmFlowers();
%count = ClientGroup.getCount();
logMessage("CmdRMFolowers:"@%count);
for (%i = 0; %i < %count; %i++)
{
%cl = ClientGroup.getObject(%i);
if( !%cl.isAIControlled() ){
commandToclient(%cl, 'rmFlowers');
commandToclient(%cl, 'doReplicate');
}
}
}
function rmFlowers()
{
%count = rshapes.getCount();
logMessage("rmFlowers:" @ %count, 1);
for(%i=0; %i<%count; %i++)
{
%obj = rshapes.getObject(%i);
logMessage("rmFlowers:" @ %obj, 1);
rshapes.remove(%obj);
%obj.schedule(10, "delete");
%count --;
%i--;
}
}
Recent Blog Posts
| List: | 06/16/07 - Coolsailors beta2 release 01/01/07 - Coolsailors new pics 11/02/06 - Dynamic create/remove foliage on client/server 08/02/06 - Coolsailors updates (game trailer) 06/04/06 - Coolsailors |
|---|
Submit your own resources!| Clint S. Brewer (Nov 02, 2006 at 18:03 GMT) |
| Andrew Hull (Nov 02, 2006 at 20:52 GMT) |
| Kefan Xu (Nov 02, 2006 at 23:52 GMT) |



Edited on Nov 03, 2006 02:22 GMT
| AndrewOsborne (Nov 03, 2006 at 23:09 GMT) |
| Allyn "Mr_Bloodworth" Mcelrath (Nov 04, 2006 at 03:23 GMT) |
| Kefan Xu (Nov 04, 2006 at 17:17 GMT) |
larger pictures ( 800x600):
1st one: www.coolsailors.com/photos/screenshot_001-000031.png
2nd one: www.coolsailors.com/photos/screenshot_001-000041.png
Edited on Nov 04, 2006 17:18 GMT
You must be a member and be logged in to either append comments or rate this resource.


Not Rated


