I searched through original Pumpkin scripts (they can be a great reference too when) and found this function in genexp.slo script. Looks like type is not STRUCTURESTAT but rather a numerical constant representing some structure type. Search scriptlang.rtf for "Structure types", it has a list of available structure types, like REF_FACTORY, REF_HQ etc.PSWDeanCorso wrote: Now for...
INT numStructsByTypeInArea(PLAYER, TYPE, X1,Y1, X2,Y2) // What are the "TYPE"s avaliable?
I have tried 'factory' which is defined in the stock .vlo as a STRUCTURESTAT;
factory STRUCTURESTAT "A0LightFactory"
And it gave the type mismatch error.
You provide 'factory' (probably of type STRUCTURESTAT) as first parameter, while numStructsByTypeInArea() expects a player number:PSWDeanCorso wrote: Also, for the numbering of paramters;
numFactories = numStructsByTypeInArea(factory, factory, baseX,baseY, tempx,tempy); // Line 159
Gives;
script parse error:
Type mismatch for paramter 0 at line 159 // gave another for para 1
Token: -1, Text:')'
Script player1.slo did not compile
scriptlang.rtf:
Code: Select all
INT numStructsByTypeInArea(PLAYER, TYPE, X1,Y1, X2,Y2)
It is probably because all trucks are trying to build on the same spot, in the best case scenario you will end up with one truck starting to build a factory and other trucks helping it build the same factory.PSWDeanCorso wrote: This event init once and should loop 5 times and stop, as far as I know my while/count loop should to the trick, but is not... it builds one factory only (this loop is in my last post, commented out)
The reason is probably that you call pickStructLocation() for all 5 trucks before the first truck actually starts building the first factory, so wz returns the same spot as valid construction site for all trucks. To prevent this from happening you can check trucks orderx/ordery member variables, like:
Code: Select all
boolResult = FALSE; //Holds TRUE if some truck was already ordered to build something on the same location
initIterateGroup(buildGroup);
droid = iterateGroup(buildGroup);
while(droid != NULLOBJECT and not boolResult)
{
if(droid.order == DORDER_BUILD) //if this truck was ordered to build something
{
//Building within some range
if(distBetweenTwoPoints(buildX,buildY, droid.orderx , droid.ordery) < 128) //closer than 1 tile
{
boolResult = TRUE;
}
}
droid= iterateGroup(buildGroup);
}
Example:
Code: Select all
if(droid.stat != NULLSTRUCTURESTAT and tempDroid.stat == factory) //assuming factory has type STRUCTURESTAT
{
[...]
}