View Single Post
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 11,010

Violet CLM has disabled reputation

Feb 4, 2013, 11:06 AM
Violet CLM is offline
Reply With Quote
Hmmm. That's a tricky one, because SP doesn't store jjOBJ copies of objects that aren't near to the player. It's only in MP that you get jjOBJs for everything all the time. But there might still be a solution...
Code:
bool areAllNormTurtlesDestroyed() {
  jjOBJ@ o;
  for (int i = 1; i < jjObjectCount; ++i) {
    @o = jjObjects[i];
    if (o.isActive && o.eventID == OBJECT::NORMTURTLE) return false;
  }
  for (uint16 x = 0; x < jjLayerWidth[4]; ++x) {
    (for uint16 y = 0; y < jjLayerHeight[4]; ++y) {
      if (jjEventGet(x,y) == OBJECT::NORMTURTLE && jjParameterGet(x,y,-1,1) == 0) return false;
    }
  }
  return true;
}
The key step is jjParameterGet(x,y,-1,1), which is a bit that is set to 1 in the event field when an object is created. The bit is set back to 0 if the object passes off screen and gets deactivated, but it is left at 1 if you destroy the object. Basically, if it's at 0 JJ2 takes that as a cue to create the object when that tile is close enough to the player -- if it's at 1, JJ2 ignores it. So that code might work, unless there's something else I'm not thinking of.
__________________