Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ffc script TorchPuzzle
- {
- /**
- * Args:
- * D0: Screen->D[] register to use. Should be a number 0 to 7.
- * D1: Unlit torch combo. The 'next' combo should be the lit torch combo.
- * D2: Error SFX for when wrong answer is put in.
- * D3: If set to 0, the puzzle remains solved forever. Otherwise, the puzzle resets when you leave the room.
- * D4 - D7: Positions of correct torches. These 4 combo positions (0-175) must all be lit, in order.
- * Make sure `Run Script at Screen Init` is checked on the FFC.
- */
- void run(int reg, int unlitCombo, int error_sfx, bool temp, int pos1, int pos2, int pos3, int pos4)
- {
- int litCombo = unlitCombo+1;
- if(Screen->D[reg] & 1b) //start Already solved
- {
- for(int q = 0; q < 176; ++q) //Light all torches onscreen
- {
- if(Screen->ComboD[q] == unlitCombo)
- Screen->ComboD[q] = litCombo;
- }
- return; //exit script
- } //end Already solved
- int trchs[176];
- int num_trchs = 0;
- //start find torches
- {
- for(int q = 0; q < 176; ++q)
- {
- if(Screen->ComboD[q] == unlitCombo)
- trchs[num_trchs++] = q;
- }
- } //end
- int cur_trchs[4];
- int cur_lit = 0;
- while(true)
- {
- for(int q = Screen->NumLWeapons(); q > 0; --q)
- {
- lweapon weap = Screen->LoadLWeapon(q);
- if(weap->Type != LW_FIRE) continue;
- for(int t = 0; t < num_trchs; ++t) //start check torch collision
- {
- int loc = trchs[t];
- for(int p = 0; p < cur_lit; ++p)
- {
- if(loc == cur_trchs[p])
- {
- loc = -1;
- break;
- }
- }
- if(loc < 0) continue;
- if(RectCollision(ComboX(loc), ComboY(loc), ComboX(loc)+15, ComboY(loc)+15,
- weap->X + weap->HitXOffset, weap->Y + weap->HitYOffset,
- weap->X+weap->HitXOffset+weap->HitWidth-1, weap->Y+weap->HitYOffset+weap->HitHeight-1)
- )
- {
- cur_trchs[cur_lit++] = loc;
- Screen->ComboD[loc] = litCombo;
- break;
- }
- } //end check torch collision
- if(cur_lit == 4)
- break;
- }
- Waitframe();
- if(cur_lit == 4) //start If 4 have been lit
- {
- //start If they were correct...
- if(cur_trchs[0] == pos1 && cur_trchs[1] == pos2 && cur_trchs[2] == pos3 && cur_trchs[3] == pos4)
- {
- if(!temp)
- {
- Screen->State[ST_SECRET] = true;
- Screen->D[reg] |= 1b;
- }
- Game->PlaySound(SFX_SECRET);
- for(int q = 0; q < num_trchs; ++q) //Light all torches onscreen
- {
- Screen->ComboD[trchs[q]] = litCombo;
- }
- Screen->TriggerSecrets();
- return; //Quit script
- } //end If they were correct...
- else //start If they were wrong...
- {
- Game->PlaySound(error_sfx);
- for(int q = 0; q < num_trchs; ++q)
- {
- Screen->ComboD[trchs[q]] = unlitCombo;
- }
- for(int q = 0; q < 4; ++q)
- {
- cur_trchs[q] = 0;
- }
- cur_lit = 0;
- for(int q = Screen->NumLWeapons(); q > 0; --q) //start Delete all fire weapons
- {
- lweapon weap = Screen->LoadLWeapon(q);
- if(weap->Type == LW_FIRE)
- {
- Remove(weap);
- continue;
- }
- } //end Delete all fire weapons
- Waitframe();
- } //end If they were wrong...
- } //end If 4 have been lit
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement