PDA

View Full Version : Is it possible to cycle FFCs?



Malstygian
12-26-2009, 03:01 PM
Here's my setup:

I have an outer rim of squares surrounding a platform. I want to make it so a spike pops up in the upper left corner of the outer rim, retracts and then have a spike pop up out of the next square to the right, retracts, etc. Now, using animation frames & speeds and whatnot, I can make this happen ONCE around the perimeter, but cannot for the life of me figure out how to get the pattern to repeat continuously.

I've tried FFCs, but I don't think FFCs can cycle - someone please tell me if they can because I believe that would solve my problem.

I've also tried using a global script by testing the ability of looping an FFC continuously, but it seemingly executes once and then never wants to repeat. I'm thinking that using LoadFFC only supplies the pointer, but doesn't "execute or trigger" the actual FFC on the screen. Is there a function or code to actually "execute or trigger" the FFC?

Here's the code if it helps (like I said, this isn't the final version. This is just trying to have an FFC loop continuously in one spot):


global script Boss
{
void run()
{
while(true)
{
// Level 1's Boss Screen
if(Game->GetCurMap() == 2 && Game->GetCurScreen() == 44)
{
Boss1();
}
Waitframe();
}

void Boss1()
{
while(true)
{
// Will just this line cause the FFC to execute?
ffc Spike = Screen->LoadFFC(1);

// Or do I have manipulate its properties?
Spike->X = 64;
Spike->Y = 64;

Waitframe();
}
}
}

Finally, I'm using ZC 2.5 build 1112.

Any help on this would be very much appreciated.

pkmnfrk
12-26-2009, 03:55 PM
You're much more likely to get results using an actual FFC script. Here's one which will do the spike thing you want:


//change this, obviously
const int SPIKE_COMBO = 540;

//and these
const int SPIKE_X_FROM = 2;
const int SPIKE_X_TO = 13;
const int SPIKE_Y_FROM = 2;
const int SPIKE_Y_TO = 8;


ffc script MakeSpikesPopUpInACircle {
int ComboAtC(int x, int y) {
return y * 16 + x;
}
void run(int speed, int fancy) {
this->Data = 0;
if(speed <= 0) speed = 10;
while(true) {
int c = 0;
int c2 = 0;
//start with the top side
for(int x = SPIKE_X_FROM + 1; x <= SPIKE_X_TO; x++) {
c = Screen->ComboD[ComboAtC(x, SPIKE_Y_FROM)];
Screen->ComboD[ComboAtC(x, SPIKE_Y_FROM)] = SPIKE_COMBO;

if(fancy != 0) {
c2 = Screen->ComboD[ComboAtC(SPIKE_X_TO - x + SPIKE_X_FROM, SPIKE_Y_TO)];
Screen->ComboD[ComboAtC(SPIKE_X_TO - x + SPIKE_X_FROM, SPIKE_Y_TO)] = SPIKE_COMBO;
}

Waitframes(speed);
Screen->ComboD[ComboAtC(x, SPIKE_Y_FROM)] = c;
if(fancy != 0) Screen->ComboD[ComboAtC(SPIKE_X_TO - x + SPIKE_X_FROM, SPIKE_Y_TO)] = c2;
}

//Next, do the right side
for(int y = SPIKE_Y_FROM + 1; y <= SPIKE_Y_TO; y++) {
c = Screen->ComboD[ComboAtC(SPIKE_X_TO, y)];
Screen->ComboD[ComboAtC(SPIKE_X_TO, y)] = SPIKE_COMBO;

if(fancy != 0) {
c2 = Screen->ComboD[ComboAtC(SPIKE_X_FROM, SPIKE_Y_TO - y + SPIKE_Y_FROM)];
Screen->ComboD[ComboAtC(SPIKE_X_FROM, SPIKE_Y_TO - y + SPIKE_Y_FROM)] = SPIKE_COMBO;
}

Waitframes(speed);
Screen->ComboD[ComboAtC(SPIKE_X_TO, y)] = c;
if(fancy != 0) Screen->ComboD[ComboAtC(SPIKE_X_FROM, SPIKE_Y_TO - y + SPIKE_Y_FROM)] = c2;
}

//next, we'll do the bottom
for(int x = SPIKE_X_TO - 1; x >= SPIKE_X_FROM; x--) {
c = Screen->ComboD[ComboAtC(x, SPIKE_Y_TO)];
Screen->ComboD[ComboAtC(x, SPIKE_Y_TO)] = SPIKE_COMBO;

if(fancy != 0) {
c2 = Screen->ComboD[ComboAtC(SPIKE_X_TO - x + SPIKE_X_FROM, SPIKE_Y_FROM)];
Screen->ComboD[ComboAtC(SPIKE_X_TO - x + SPIKE_X_FROM, SPIKE_Y_FROM)] = SPIKE_COMBO;
}

Waitframes(speed);
Screen->ComboD[ComboAtC(x, SPIKE_Y_TO)] = c;
if(fancy != 0) Screen->ComboD[ComboAtC(SPIKE_X_TO - x + SPIKE_X_FROM, SPIKE_Y_FROM)] = c2;
}

//Finally the left side
for(int y = SPIKE_Y_TO - 1; y >= SPIKE_Y_FROM; y--) {
c = Screen->ComboD[ComboAtC(SPIKE_X_FROM, y)];
Screen->ComboD[ComboAtC(SPIKE_X_FROM, y)] = SPIKE_COMBO;

if(fancy != 0) {
c2 = Screen->ComboD[ComboAtC(SPIKE_X_TO, SPIKE_Y_TO - y + SPIKE_Y_FROM)];
Screen->ComboD[ComboAtC(SPIKE_X_TO, SPIKE_Y_TO - y + SPIKE_Y_FROM)] = SPIKE_COMBO;
}

Waitframes(speed);
Screen->ComboD[ComboAtC(SPIKE_X_FROM, y)] = c;
if(fancy != 0) Screen->ComboD[ComboAtC(SPIKE_X_TO, SPIKE_Y_TO - y + SPIKE_Y_FROM)] = c2;
}

}
}
}

... Except, for some reason, this doesn't work. Link can't be damaged by it... I have no idea why. Boots make you immune to spikes!

Malstygian
12-26-2009, 05:25 PM
I'm not sure, but perhaps you need to call the ComboSetFlag or ComboSetInherentFlag functions though I'm not sure. I tried to also use a script using DrawCombo, but I ran into the same problem - it wouldn't damage Link the way I set the combo up.

But anyway, thank you very much for your help, I'll play with your script to see if I can get it to work the way I need it.

pkmnfrk
12-26-2009, 07:13 PM
I considered the Combo Type/Flag angle (damage combos are set by type, not by flag) and tried adding code that sets the type too, but it didn't do anything different, so I ripped it out again. Setting ComboD[] should set ComboT[] and comboI[] as well.

Another idea I had while I ran out to the store just now was to make the FFC itself damaging and to move it around. I'll see what I can do with that idea...

pkmnfrk
12-26-2009, 11:07 PM
Lololololol! hay guis! ges wat?!?!!?? if Link starts wth the boots, spikes dnt damaamge hime!!!!

*cough*

Aka, don't have Link start with Boots when you want to test the effectiveness of spikes!

Malstygian
12-26-2009, 11:47 PM
Sorry that you had to go through that bit of frustration - I was going to say that the script as you posted it worked fine for my spike combo. I've adjusted the parameters to fit my needs - the only thing I need to figure out is how to adjust the speed of the rotation to go a bit slower.

Do the two run-time-arguments you have in the run function (speed and fancy) come from the arguments tab of the FFC? So if I don't touch any of the values in that tab, both arguments will have a value of 0? And what does the fancy variable represent?

I am a pretty proficient programmer so I had no problems understanding your script. I guess I just have to play around with the syntax of ZScript so I can get the effects I want. Thanks again.

pkmnfrk
12-27-2009, 12:17 AM
Sorry, I meant to post what the parameters were, but I got sidetracked by the spikes/boots thing >_<

Anyway, yeah, you pass arguments via the arguments tab. D0-D7 represent the arguments to the run function. In this case,

D0 - int - Speed of the spike rotation (in frames, determines how long the spikes stay in one spot before moving to the next spot)
D1 - bool - Whether the spikes are "fancy" (i.e, there's a second set of spikes opposite of the first one)

The speed parameter defaults to 10 (i.e. if you pass 0). Most of my scripts have reasonable defaults. Usually that default is 0, so I get it for free :)