

Basically, what i ran into is this..
you dont have lua with features. They are dead in the water (if you dont write a gadget..and i will do that - to have it burn for some time after death) what i want is one feature- with many pieces, whos apppearance can be randomized. Basically.. i build a very highdetailed scrapheap.. and by the power of the random.. allow it to appear diffrent on each spawning of said scrapheap...
im not a idiot anymore...
well not that big of a idiot as before..
i m thats for certain -
well i ahem, therefore i request.
im not demanding a full blown unitscript .. it would just be nice.. if a feature had several pieces.. if you could toogle the random show and hide in the unitdef.
And add a list of pieces that should be excluded. That way.. bushe without branches and all those odditys could be avoided.
Code: Select all
void CFeature::Initialize(const float3& _pos, const FeatureDef* _def, short int _heading,
int facing, int _team, int _allyteam, std::string fromUnit, const float3& speed, int _smokeTime,
Code: Select all
)
{
pos = _pos;
def = _def;
defName = def->myName;
heading = _heading;
buildFacing = facing;
team = _team;
allyteam = _allyteam;
emitSmokeTime = _smokeTime;
createdFromUnit = fromUnit;
ChangeTeam(team); // maybe should not be here, but it prevents crashes caused by team = -1
pos.CheckInBounds();
health = def->maxHealth;
blocking = def->blocking;
xsize = ((facing & 1) == 0) ? def->xsize : def->zsize;
zsize = ((facing & 1) == 1) ? def->xsize : def->zsize;
mass = def->mass;
noSelect = def->noSelect;
if (def->drawType == DRAWTYPE_MODEL) {
model = LoadModel(def);
if (!model) {
logOutput.Print("Features: Couldn't load model for " + defName);
SetRadius(0.0f);
midPos = pos;
} else {
height = model->height;
SetRadius(model->radius);
midPos = pos + model->relMidPos;
collisionVolume = new CollisionVolume(def->collisionVolume, model->radius);
if (def->ranDom)
{
for (int i=0,i< (def->numberOfPieces),++i)
{
int allowToShow=1;
for (int j=0,j < (def->numberOfExludedPieces),++j)
if (piecesArray == excludedArray[j])? allowToShow=0: ;
if (allowToShow==1)
{//im sorry, i dont know what syncronized library is refered too generate randomness in spring. Also dont know how to tell open_gl here to not draw the piece. Therfore luapseudocode.
if (math.random(0,1)==1)
Show(piecesArray)
else
Hide(piecesArray)
}
Code: Select all
}
}
}
}
else if (def->drawType >= DRAWTYPE_TREE) {
SetRadius(TREE_RADIUS);
midPos = pos + (UpVector * TREE_RADIUS);
height = 2 * TREE_RADIUS;
// LoadFeaturesFromMap() doesn't set a scale for trees
collisionVolume = new CollisionVolume(def->collisionVolume, TREE_RADIUS);
}
else {
// geothermal (no collision volume)
SetRadius(0.0f);
midPos = pos;
}
featureHandler->AddFeature(this);
qf->AddFeature(this);
CalculateTransform();
if (blocking) {
Block();
}
if (def->floating) {
finalHeight = ground->GetHeight(pos.x, pos.z);
} else {
finalHeight = ground->GetHeight2(pos.x, pos.z);
}
if (def->drawType >= DRAWTYPE_TREE) {
treeDrawer->AddTree(def->drawType - 1, pos, 1);
}
if (speed != ZeroVector) {
deathSpeed = speed;
}
}
Contra: Random is expensive.. it makes intial feature loading even more expensive. Also its.. novice code - and well.. i have no clue what i do up there
: (
https://github.com/yokosou/spring/blob/ ... eature.cpp