EireMadHatter wrote
What about if say theres a material called soot or charred.
.....like a black water for now.....but it covers stuff similar to how water does. When items burn.
This is a good idea. There are powder materials, like sand, snow and gunpowder available, so soot would be a natural extension to this concept.
Well, the results go as follows:
03.png: Get into the level. What the? A flaming wand of striking!
04.png: This kobold's pants are on fire! It is getting ridiculous.
05.png: get stick with pick-axe (it is not on fire)
07.png: apply the stick...
08.png: the stick is now on fire! Some output thingees indicate the state of the flag responsible for determining whether the object is on fire or not.
09.png: what does the rest of the level look like? There is a flaming spider!
As you can observe, there is lots of functionality missing. Like for instance, there is no discrimination yet between items in a stack that are on fire, or not on fire, so these items just pile together and look silly at the moment.
It begs the question, why are only some of the objects in the level on fire?
This is because when the flag is instantiated, it is not initialised to zero first. Most of the locations in the memory contain the integer zero, but there are still some memory locations that contain garbage, and so these are non zero. The variable Burning will take on a non-zero value, and so this will reveal itself as a spot fire in a level in the game.
My question is, in the code added in object.h, how do I initialise the truth variable Burning to zero generally?
Code:
//In object.h:
class object : public entity, public id
{
public:
...
truth Burning; //Added
virtual void SetIsBurning(truth What) {Burning = What;} //Added
virtual truth IsBurning() const { return Burning; } //Added
//In miscitem.h:
ITEM(stick, item)
{
public:
virtual truth Apply(character*); //Added
virtual truth IsAppliable(ccharacter*) const { return true; } //Added
protected:
virtual void AddPostFix(festring& String, int) const { AddLumpyPostFix(String); }
virtual truth ShowMaterial() const { return false; }
virtual truth WeightIsIrrelevant() const { return true; }
};
//in miscitem.cpp
truth stick::Apply(character* Applier) //Added this function
{
if(Applier->IsPlayer())
{
ADD_MESSAGE("You light %s.", CHAR_NAME(DEFINITE));
ADD_MESSAGE("Burning is %d", Burning);
ADD_MESSAGE("IsBurning is %d", IsBurning());
}
SetIsBurning(true);
UpdatePictures();
ADD_MESSAGE("The %s now burns brightly.", CHAR_NAME(DEFINITE));
ADD_MESSAGE("Burning is %d", Burning);
ADD_MESSAGE("IsBurning is %d", IsBurning());
return true;
}
//in object.cpp:
void object::UpdatePictures(graphicdata& GraphicData, v2 Position, int SpecialFlags, alpha MaxAlpha, int GraphicsContainerIndex, bposretriever BitmapPosRetriever) const
{
...
alpha Alpha;
// added this new condition below
if(IsBurning()) //is burning is sometimes initially filled with crap, so Burning should be initialised to zero
{
SpecialFlags &= ST_FLAMES; //this should be the |= operator, not the &= operator.
}