Hide,Show and random for features

Hide,Show and random for features

Requests for features in the spring code.

Moderator: Moderators

Post Reply
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10454
Joined: 24 Jan 2006, 21:12

Hide,Show and random for features

Post by PicassoCT »

Image
Image

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, 
int piecesArray[], int excludedArray[]

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 features has random activated
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;
}
}
I presume its a lot more work, with much more sideeffects and even more funny rewriting the featuredef class. The Pros: Its fully backward compatible, not breaking any of the oldfeatures, as for these, the code is simply skipped and the whole feature is shown.
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
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Hide,Show and random for features

Post by Forboding Angel »

Use gaia units. That way you get the full arsenal. Check out gunmetal harbor for an extravagant example.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Hide,Show and random for features

Post by Beherith »

Or look at Magic Forest :D (just dont forget to include a blank radar icon like I did)
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10454
Joined: 24 Jan 2006, 21:12

Re: Hide,Show and random for features

Post by PicassoCT »

so basically every scrapheap as gai unit set to neutral?

okay..
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Hide,Show and random for features

Post by smoth »

pretty much. Scripts existing is one of the biggest distinction from units to features.
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10454
Joined: 24 Jan 2006, 21:12

Re: Hide,Show and random for features

Post by PicassoCT »

so if you want more .. they are basically depreicated?
Post Reply

Return to “Feature Requests”