/// Custom item Trigger for Spike Rooms
/// By: ZoriaRPG
/// Requested by NJF
/// 16th May, 2017
/// v0.2
//D0: The lweapon type to use to trigger. Use the lweapon constants in std.zh for this value.
//D1: The flag to use. 100 is Script_5.
//D2: The combo to change all flagged tiles into. If set to '0' , all flagged combos will advance by one,
// as combo->Next combos.
//D3: The duration of your combo animation in cycle, for the changed combos.
// If they do not revert on a timer, set this to 0.
//D4: if this is set to 1, the combos will also be changed when the timer expires, not merely the flags.
//D5: Sound to play when triggered.`
ffc script changetiles{
void run(int item_trigger, int flag, int change_into, int revert_time, int change_combos, int sfx) {
lweapon l; int q[2]; bool triggered; int locs[176]; int cmbs[176];
while(true){
if ( !triggered ) {
q[0] = Screen->NumLWeapons();
for ( ; q[0] > 0; q[0]-- ) {
l = Screen->LoadLWeapon(q[0]);
if ( l->ID == item_trigger ) {
if ( Collision(l,this) ) {
if ( sfx > 0 ) Gsame->PlaySound(sfx);
for ( q[1] = 0; q[1] < 176; q[1]++ ) {
if ( change_combos ) { cmbs[q[1]] = Screen->ComboD[q[1]]; }
if ( Screen->ComboF[q[1]] == flag ) {
if ( change_into > 0 ) Screen->ComboD[q[1]] = change_into;
else Screen->ComboD[q[1]]++;
locs[q[1]] = Screen->ComboF[q[1]]; //Save the flag.
Screen->ComboF[q[1]] = 0;
}
}
triggered = true;
}
}
}
}
if ( revert_time > 0 ) {
if ( triggered ) {
int time_revert = revert_time;
while(time_revert--) {
Waitframe();
}
//Revert the flags
for ( q[1] = 0; q[1] < 176; q[1]++ ) {
if ( locs[q[1]] > 0 ) {
Screen->ComboF[q[1]] = locs[q[1]];
locs[q[1]] = 0;
}
if ( change_combos ) { Screen->ComboD[q[1]] = cmbs[q[1]]; }
}
triggered = false;
}
}
Waitframe();
}
}
}
This may do what you want.
Edited by ZoriaRPG, 16 May 2017 - 06:23 AM.