What I am trying to accomplish, is creating random trees from the bioware blueprints, since the CEP naming conventions aren't nearly as organized. To avoid the engine creating objects at completely random vectors, subsequently in undesired locations (in front of doors), I figured I would just place around 100+ waypoints on the map with random facing directions and positions.
Keep in mind I am a novice scripter, so the code below may be very inefficient and not work at all
What I would like to know is, what would be the most efficient, laggfree way to accomplish this?
And the estimated execute time to pass through all 100 placed objects.
So if I draw 100 waypoints, named "wp_skip_bf1_001" through "wp_skip_bf1_100", this script should have a 50% chance of creating a random Large sized tree at that waypoint. IIRC there is about 20 trees to pick from, if I only used "x3_plc_treel".
I appreciate any help with accomplishing this effectively
----------
void main()
{
//Random Tree, last 3 characters will define the random blueprint
string sTree = GetStringRight("x3_plc_treel", 3);
//Random Waypoint, last 3 characters will define the random waypoint
string sWP = GetStringRight("wp_skip_bf1_", 3);
object oWP = GetObjectByTag(sWP);
//Random Location for trees based off waypoints drawn on map
location lWP = GetLocation(oWP);
//Max amount of trees to create per map
int nMAX = 50;
//Count of how many trees have been created, incrementing to nMAX...
int nCount = 0;
//Chance to spawn a tree
int nChance = 50;
object oTarget = GetFirstObjectInArea(OBJECT_SELF);
//Perform if its one of the random waypoints
if(GetObjectType(oTarget) == OBJECT_TYPE_WAYPOINT && oTarget == oWP)
{
//nChance% to spawn a tree per random waypoint
if(d100() >= nChance)
{
//Perform if there hasnt been nMAX trees spawned
if(nCount < nMAX )
{
//Create random tree at the waypoint
CreateObject(OBJECT_TYPE_PLACEABLE, sTree, lWP);
//Increment the count by 1
nCount++;
}
}
}
//Get the next waypoint
oTarget = GetNextObjectInArea(OBJECT_SELF);
}
Modifié par SKIPPNUTTZ, 21 novembre 2011 - 09:08 .





Retour en haut






