Read-only archive of the Armageddon Games Forums Archive (2000–2026) · About this archive

[846] ST_ITEM state doesn't update?

2 replies · 1,071 views · Started 30 July 2008

I have this script:

ffc script ItemGen {
void run(int it, int type, int sfx, int d1, int d2, int d3, int d4, int d5) {
//the d? variables change meaning depending on type.
bool fail = true;

while(true) {
if(type == 0) {
//monitoring Screen->D
//d1 is the number of elements
//d2 is the value
fail = false;
for (int i = 0; i < d1; i++) {
if(Screen->D[i] != d2) {
fail = true;
break;
}
}
if(!fail) break;
}
Waitframe();
}
if(Screen->State[ST_ITEM]) return;
Screen->State[ST_ITEM] = true;
item foo = Screen->CreateItem(it);
if(sfx != 0) Game->PlaySound(sfx);
foo->X = this->X;
foo->Y = this->Y;
}
}

Simply put, what it does it monitors whatever info you tell it to (currently, only the Screen->D variables), and when the conditions are met, it spawns an item. It then sets Screen->State[ST_ITEM] to true (since you solved the puzzle, got the item, etc), and quits. If, by chance, Screen->State[ST_ITEM] is already set, it won't spawn another item, since it's already been gotten.

It works just fine, except that if the player leaves the screen, and comes back, it will spawn another item. This seems to indicate that Screen->State[ST_ITEM] isn't being saved as it should, or that I'm misunderstanding what it does. It IS read/write, yes? And, it should be saved across screen loads, right?

Confirmed as fixed in b864. Can be moved to exterminated bugs.

...by the way, pkmnfrk, if you still are using this script, you might want to add a loop to check and make sure Link picks up the item before setting the ST_ITEM state, because if the player chooses not to get it, leaves the screen, and then comes back, the item will be gone for the rest of the game.