Jump to content

Photo

Always another question with me...


  • Please log in to reply
8 replies to this topic

#1 Xiion

Xiion

    Senior

  • Members

Posted 11 July 2008 - 04:58 PM

Ok I'm making a new item, and I've got it pretty much working, except for the graphical effect...

What I want to happen is: when you use the item, it creates a short rainstorm.
Whats currently happening is: the screen flickers like it got the 1st frame of the animation, but doesn't get past that.
Heres the script handling the animation:
CODE
//animation!
    int frames = 0;
    int x=0;
    int y=0;
    
    for (frames = 0; frames<= 15; frames++)
        {
            for (x=-16;x <= 256; x+=16)
            {
                for(y=0; y <= 176; y+=16)
                {
                    Screen->DrawTile(6,x,y, 29460+frames,1,1, 5,1,0,0,0,0,1,64);
                }
            }
            Waitframe();
        }

Nothing I haven't used before, in fact I copied it from another (ffc) script, where it works fine. Is it just because this is an item script that it doesn't work?

On another note, is there any way to get the candles "use once per screen" flag onto a non-candle item? Probably not a scripting question, but it might be, I don't know. If I did, I wouldn't be asking now would I?

#2 Mitchfork

Mitchfork

    no fun. not ever.

  • Members
  • Real Name:Mitch
  • Location:Alabama

Posted 11 July 2008 - 05:10 PM

I don't know much about scripting, but I've heard that DrawTile only works for one frame. icon_frown.gif

#3 Joe123

Joe123

    Retired

  • Members

Posted 11 July 2008 - 05:26 PM

Just for refrence, 'int a = 0;' is exactly the same as just 'int a;'
CODE
int frames; int i;
for(frames = 0;frames < 15;frames++){
    for(i=0;i<176;i++){
        Screen->DrawTile(6, i%16*16, Floor(i/16)*16,29460+frames,1,1,5,1,0,0,0,0,1,64);
    }
Waitframe();
}

That's an optimization of it for you.

Anyway, I'm afraid he's addressed the 'drawing for one frame' issue Ebola.

The problem is that Item scripts run for one frame only.
So what you'll need to do is something a little like this:

CODE
bool raining;

item script rainmaker{
    void run(){
        raining = true;
    }
}

global script slot_2{
    void run(){
    int frames; int i;
        while(true){
            if(raining){
                for(frames = 0;frames < 15;frames++){
                    for(i=0;i<176;i++){
                        Screen->DrawTile(6, i%16*16, Floor(i/16)*16,29460+frames,1,1,5,1,0,0,0,0,1,64);
                    }
                Waitframe();
                }
            raining = false;
            }

            //other global scripts go in this space here

        Waitframe();
        }
    }
}


Variables declared outside of script-scope are common to all scripts, so you can set raining in the item script, then the global script will make it rain when it checks that variable.
You can only have one global script (the bottom slot doesn't run every frame of the game), so you'll have to put any other global processes in the space I've noted.

Obviously you probably won't want it exactly like that, as it doesn't actually do anything apart from a graphical effect, that's just to show you how to set it up.

And I believe you can set that 'once per screen' flag for other items too, although I may be wrong.

Edited by Joe123, 11 July 2008 - 05:28 PM.


#4 Xiion

Xiion

    Senior

  • Members

Posted 11 July 2008 - 05:55 PM

Ahhh I see...

That little detail of "item scripts only run one frame"... didn't know that. Ok....

Hmmm okay lets see how this works...

Also, thats a really nifty optimization, took me a minute to figure out how it works. Gonna go apply that to some other scripts.

Edit: Alright works like a charm! Thanks Joe!

Edited by Xiion, 11 July 2008 - 06:08 PM.


#5 Joe123

Joe123

    Retired

  • Members

Posted 11 July 2008 - 06:31 PM

Glad it works, I hadn't actually tried it.
It's my method for turning combo reference numbers back into coordinates though, so it should've done (and apparently it did =P).
Combos on the screen are referenced from 0->176, like 'i' in the script.

#6 Xiion

Xiion

    Senior

  • Members

Posted 11 July 2008 - 10:59 PM

One other question, 'cause I can't seem to find the answer on the wiki....

I want to have my script trigger secrets in particular rooms, how would I go about doing that. It seems like its possible, or should be at least, but I have no idea how to do it.

#7 Joe123

Joe123

    Retired

  • Members

Posted 12 July 2008 - 04:20 AM

Ah now, that's a bit awkward really.
There's no direct way of doing it, so you have to make a work-around.

My way of doing it at the moment is like this:
CODE
int orig = Screen->ComboT[ComboAt(Link->X,Link->Y);
Screen->ComboT[ComboAt(Link->X,Link->Y)] = CT_STRIGFLAG; //which is 'sensitive permanent trigger combo'
Waitframes(3);
Screen->ComboT[ComboAt(Link->X,Link->Y)] = orig;


As you can see though, it's not really ideal as it involves manipulating the combotypes of what's on the screen.

You might be able to create a better method by setting the flag at (-16,0) to say, flag 6 (arrow), and then spawning an arrow combo on top of it.
I've never tried that though, so I can't tell you whether it'd work or not.

#8 Xiion

Xiion

    Senior

  • Members

Posted 12 July 2008 - 11:17 AM

Wow thats really convoluted....

So I guess the script specific flags aren't quite implemented yet... just kinda there to taunt us...

Ok. Thanks again.


#9 Joe123

Joe123

    Retired

  • Members

Posted 12 July 2008 - 11:22 AM

No they are, they're just not used in the same way as normal flags.
You can place them down in the editor, and then check them in a script.
You have to script what they do, that's the idea.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users