Jump to content

bug, bad docs, or gotcha?


Recommended Posts

The docs for party_size() simply say "Returns the number of characters in the party." Based on that, and since I can't really be sure of how big a party was brought into my scenario, I've taken to doing something like this:

 

Code:
short i,max;...max = party_size();i = 0;while (i < max) {  if (char_ok(i) == TRUE) {    // do something with PC here  }  i = i + 1;}
However, say you have a 4-character party, but all of them except, say, character 2 is dead. In that case, party_size() returns 1 (when I expected 4, based on the docs). So my loop runs through once, with character 0, who is dead, and nothing happens.

 

I suppose it's easy enough to work around by always doing:

 

Code:
i = 0;while (i < 6) {  if (char_ok(i) == TRUE) {    // do stuff here  }  i = i + 1;}
(Or at least I'm presuming char_ok() will return FALSE on a non-existant character... anyone know for sure?)

 

-spyderbytes

 

EDIT: typo in 2nd code block

Link to comment
Share on other sites

I may well just not be thinking of something, but I don't really see how the current behavior of party_size() would be more advantageous than the behavior I expected (that is, seems better to me to know total size of party, not just learn how many are alive and kicking).

 

Not that we're talking a massive number of cycles either way, but I would think a single call to a party_size() (or equivalent that returned what I expected) would certainly incur less overhead than the unnecessary iterations through a loop (which is why I was querying party_size() in the first place smile ).

 

-spyderbytes

Link to comment
Share on other sites

Agreed, Drakefyre. It's not that there are that many times I end up iterating the group (mostly when I'm just being fiddly about where they are for a cutscene and such--in a neat little row starting from a particular loc). I probably wouldn't have discovered this at all if I hadn't been working on a, well, I guess you'd call it a trap, that has some rather, well, I guess you'd call it odd, behavior. laugh

 

I was testing what happens if players are both stupid and unlucky, and all but one of the characters ended up dying... before the trap was going through a final iteration to turn the thumbscrews a bit more. eekeek I'm toning the worst case down a tad...

 

-spyderbytes

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...