Jump to content

Photo

Flying Owl


  • Please log in to reply
10 replies to this topic

#1 Sephiroth

Sephiroth

    The Legendary Sephiroth

  • Members
  • Location:Somewhere... Lemme know if you find me :)

Posted 20 May 2010 - 03:42 PM

Ok, for all of you scripters out there, I have a rather simple (I think) request.

I'd like to use this script on multiple screens, so any settings it does save should be tied to the screen.

Anyways, basically what I'd like to do is have an FFC (Say, FFC 32) be the "trigger box" for the script, stepping into this "zone" would cause the script to activate.

Now what does it do when activated?

A new FFC is "created" (or rather used) to hold the animation of LA's owl flying frames. (See here for example.) The owl would be 32 pixels wide, 16 pixels tall during the flying animation. (For the animation, if you want to use 3 different combos, (left half flying, right half flying, and sitting), that would be great as well. I can tweak the animations that way.)

The owl would swoop in from the top left corner of the screen and land somewhere on the screen, maybe using FFC 31 to denotate where the owl lands. (This might be the most complicated part, figuring out a path for the owl to swoop in, then swoop out afterward.) (A shadow under the owl is a plus if possible.)

Once the owl lands, the owl changes to a 16x16 animated sprite, and the script should play a message string. (D0)

After the message string is played, the owl flies off to the top right corner of the screen and sets some flag to cause the script not to occur again. These owl encounters are only to be one-time events.

If you need additional information, I would gladly be able to provide as much as I can. However, the reason I am requesting this is for story purposes in my quest.

Thanks in advance.

#2 lucas92

lucas92

    Defender

  • Members

Posted 20 May 2010 - 07:53 PM

I will look into it tomorrow, when I'll be less tired from my final exams from school. icon_wink.gif

EDIT- Just found a bug with the Screen->FastCombo() function. I'm going to report it.
Here what I have so far:

EDIT2: Completed the script. Just say if you want something to be modified.
CODE

import "std.zh"

//The left combo
const int OWL_FLYING_DATA = 48;

const int OWL_STILL_DATA = 165;
const int OWL_CSET = 6;
const int SHADOW_TILE_DATA = 13;
const int SHADOW_CSET = 6;
//D0-D3 : Bounding rectangle
//D4-D5 : Owl posing coordinates
//D6 : The message
//D7 : The screen flag to activate when the owl has been encountered, value go 0 to 7
ffc script owl
{
    void run(int x1,int y1,int x2,int y2,int owl_final_x,int owl_final_y,int message_id,int flag)
    {
        bool activated = false;
        float owl_x = 0;
        float owl_y = 0;
        float angle = 90;
        bool owl_posed = false;
        bool owl_quitting = false;
        bool message = false;
        
        if(Screen->D[flag]==0)
        {
            while(true)
            {
                if(Link->X > x1 && Link->Y > y1 && Link->X < x2 && Link->Y < y2)
                    activated = true;
                if(activated)
                {
                    if(!owl_posed && !owl_quitting)
                    {
                        angle--;
                        owl_x = owl_final_x*Cos(angle);
                        owl_y = -owl_final_y*Sin(angle)+owl_final_y;
                        if(angle<=0)
                            owl_posed = true;
                        if(!owl_posed)
                        {
                            Screen->DrawCombo(3, owl_x+8, owl_final_y, SHADOW_TILE_DATA, 1, 1,SHADOW_CSET, -1, -1, 0, 0, 0,0, 0, true, 64);
                            Screen->DrawCombo(3, owl_x, owl_y, OWL_FLYING_DATA, 2, 1,OWL_CSET, -1, -1, 0, 0, 0,0, 0, true, 128);
                        }
                    }
                    if(owl_posed)
                    {
                        Screen->DrawCombo(3, owl_x, owl_y, OWL_STILL_DATA, 1, 1,OWL_CSET, -1, -1, 0, 0, 0,0, 0, true, 128);                
                        if(!message)
                        {
                            message = true;
                            Screen->Message(message_id);
                        }
                        else
                        {
                            owl_quitting = true;
                            owl_posed = false;
                            angle = -90;
                        }
                    }
                    if(owl_quitting)
                    {
                        angle++;
                        owl_x = (248-owl_final_x)*Cos(angle)+owl_final_x;
                        owl_y = -owl_final_y*Sin(angle);
                        Screen->DrawCombo(3, owl_x+8, owl_final_y, SHADOW_TILE_DATA, 1, 1,SHADOW_CSET, -1, -1, 0, 0, 0,0, 0, true, 64);
                        Screen->DrawCombo(3, owl_x, owl_y, OWL_FLYING_DATA, 2, 1,OWL_CSET, -1, -1, 0, 0, 0,0, 0, true, 128);
                        if(owl_y < 0)
                        {
                            activated = false;
                            Screen->D[flag] = 1;
                        }
                    }
                }
                if(Screen->D[flag]==1)
                    break;
                Waitframe();
            }
        }
    }
}

Edited by lucas92, 21 May 2010 - 01:39 PM.


#3 Sephiroth

Sephiroth

    The Legendary Sephiroth

  • Members
  • Location:Somewhere... Lemme know if you find me :)

Posted 21 May 2010 - 08:54 PM

Ok, this is awesome. Very awesome.

One issue however, and I'm unsure if this is the issue you mentioned.

After the owl lands and changes to the "posing" combo, he vanishes in the blink of an eye when the string plays. The owl should remain on screen during the entirety of the message.

Other than that, this is a beautiful script. Thanks again.

#4 Radien

Radien

    Courage

  • Members
  • Real Name:Steve
  • Location:Oregon

Posted 21 May 2010 - 09:24 PM

This isn't in the database yet, but I edited some owl tiles by Sephiroth's request. They'll be posted on the site soon enough, but until then here is a Tinypic upload for your use and reference.

IPB Image

This is the LA owl, edited for DoR with some added detail and a compatible palette.

As you can see, all the tiles used in a flying (and landing) animation are available in 1x2 combo size.

#5 Sephiroth

Sephiroth

    The Legendary Sephiroth

  • Members
  • Location:Somewhere... Lemme know if you find me :)

Posted 22 May 2010 - 08:06 AM

Hehe, after a little bit of tinkering around with the script, I managed to solve the mysterious vanishing owl trick. Now the script works perfectly. ^_^

What I did was change the DrawCombo to a this->Data to change the combo of the FFC itself, use this->X and this->Y to position the FFC, and this->CSet to get the correct CSet for the owl. icon_razz.gif

__________________________________________________________________

e: Updated script. lucas92 has also been placed in the credits for my quest as well. Thank you so much.

CODE
//The left combo
const int OWL_FLYING_DATA = 1049;

const int OWL_STILL_DATA = 1048;
const int OWL_CSET = 8;
const int SHADOW_TILE_DATA = 1051;
const int SHADOW_CSET = 8;
//D0-D3 : Bounding rectangle
//D4-D5 : Owl posing coordinates
//D6 : The message
//D7 : The screen flag to activate when the owl has been encountered, value go 0 to 7
ffc script owl
{
    void run(int x1,int y1,int x2,int y2,int owl_final_x,int owl_final_y,int message_id,int flag)
    {
        bool activated = false;
        float owl_x = 0;
        float owl_y = 0;
        float angle = 90;
        bool owl_posed = false;
        bool owl_quitting = false;
        bool message = false;
        
        if(Screen->D[flag]==0)
        {
            while(true)
            {
                if(Link->X > x1 && Link->Y > y1 && Link->X < x2 && Link->Y < y2)
                    activated = true;
                if(activated)
                {
                    NoAction();
                    if(!owl_posed && !owl_quitting)
                    {
                        angle--;
                        owl_x = owl_final_x*Cos(angle);
                        owl_y = -owl_final_y*Sin(angle)+owl_final_y;
                        if(angle<=0)
                            owl_posed = true;
                        if(!owl_posed)
                        {
                            Screen->DrawCombo(3, owl_x+8, owl_final_y, SHADOW_TILE_DATA, 1, 1,SHADOW_CSET, -1, -1, 0, 0, 0, 0, 0, true, 64);
                            Screen->DrawCombo(3, owl_x, owl_y, OWL_FLYING_DATA, 2, 1,OWL_CSET, -1, -1, 0, 0, 0, 0, 0, true, 128);
                        }
                    }
                    if(owl_posed)
                    {
                        this->Data = OWL_STILL_DATA;
                        this->CSet = OWL_CSET;
                        this->X = owl_x+8;
                        this->Y = owl_y;
                        if(!message)
                        {
                            message = true;
                            Screen->Message(message_id);
                        }
                        else
                        {
                            this->Data = 141; // BE SURE TO CHANGE THIS TO A BLANK NON-ZERO COMBO!
                            owl_quitting = true;
                            owl_posed = false;
                            angle = -90;
                        }
                    }
                    if(owl_quitting)
                    {
                        angle++;
                        owl_x = (248-owl_final_x)*Cos(angle)+owl_final_x;
                        owl_y = -owl_final_y*Sin(angle);
                        Screen->DrawCombo(3, owl_x+8, owl_final_y, SHADOW_TILE_DATA, 1, 1,SHADOW_CSET, -1, -1, 0, 0, 0, 0, 0, true, 64);
                        Screen->DrawCombo(3, owl_x, owl_y, OWL_FLYING_DATA, 2, 1,OWL_CSET, -1, -1, 0, 0, 0, 0, 0, true, 128);
                        if(owl_y < 0)
                        {
                            activated = false;
                            Screen->D[flag] = 1;
                        }
                    }
                }
                if(Screen->D[flag]==1)
                    break;
                Waitframe();
            }
        }
    }
}

//Stops Link from being able to do anything
void NoAction() {
    Link->InputR = false;
    Link->InputL = false;
    Link->InputA = false;
    Link->InputB = false;
    Link->InputLeft = false;
    Link->InputRight = false;
    Link->InputUp = false;
    Link->InputDown = false;
    Link->InputStart = false;
}


Fixes the vanishing owl trick, as well as implements frozen player during the fly-in and fly-out sequence.

#6 lucas92

lucas92

    Defender

  • Members

Posted 22 May 2010 - 08:30 AM

I just learnt something new. Everyone can learn out of this. I will repost an another version of the script that will play a music while the owl is there.


#7 Sephiroth

Sephiroth

    The Legendary Sephiroth

  • Members
  • Location:Somewhere... Lemme know if you find me :)

Posted 22 May 2010 - 08:42 AM

QUOTE(lucas92 @ May 22 2010, 08:30 AM) View Post

I just learnt something new. Everyone can learn out of this. I will repost an another version of the script that will play a music while the owl is there.


Oh, awesome. Will you be able to get it to return to the original MIDI that was playing before the script kicks in?

#8 lucas92

lucas92

    Defender

  • Members

Posted 22 May 2010 - 09:05 AM

Yep, there you go:
CODE
import "std.zh"

void NoAction()
{
    Link->InputUp = false;
    Link->InputDown = false;
    Link->InputLeft = false;
    Link->InputRight = false;
    Link->InputR = false;
    Link->InputL = false;
    Link->InputA = false;
    Link->InputB = false;
}

const int OWL_FLYING_DATA = 48;
const int OWL_STILL_DATA = 165;
const int OWL_CSET = 6;
const int SHADOW_TILE_DATA = 13;
const int SHADOW_CSET = 6;
const int OWL_MUSIC = 2;
//D0-D3 : Bounding rectangle
//D4-D5 : Owl posing coordinates
//D6 : The message
//D7 : The screen flag to activate when the owl has been encountered, value go 0 to 7
ffc script owl
{
    void run(int x1,int y1,int x2,int y2,int owl_final_x,int owl_final_y,int message_id,int flag)
    {
        this->X = 0;
        this->Y = 0;
        bool activated = false;
        float angle = 90;
        bool owl_posed = false;
        bool owl_quitting = false;
        bool message = false;
        int lastMidi = Game->GetMIDI();
        
        if(Screen->D[flag]==0)
        {
            while(true)
            {
                if(Link->X > x1 && Link->Y > y1 && Link->X < x2 && Link->Y < y2)
                {
                    activated = true;
                    Game->PlayMIDI(OWL_MUSIC);
                }
                if(activated)
                {
                    this->CSet = OWL_CSET;
                    if(!owl_posed && !owl_quitting)
                    {
                    
                        angle--;
                        this->X = owl_final_x*Cos(angle);
                        this->Y = -owl_final_y*Sin(angle)+owl_final_y;
                        if(angle<=0)
                            owl_posed = true;
                        if(!owl_posed)
                        {
                            this->Data = OWL_FLYING_DATA;
                            this->TileWidth = 2;
                            Screen->DrawCombo(3, this->X+8, owl_final_y, SHADOW_TILE_DATA, 1, 1,SHADOW_CSET, -1, -1, 0, 0, 0,0, 0, true, 64);
                        }
                        NoAction();
                    }
                    if(owl_posed)
                    {
                        this->Data = OWL_STILL_DATA;
                                                this->TileWidth = 1;            
                        if(!message)
                        {
                            message = true;
                            Screen->Message(message_id);
                        }
                        else
                        {
                            owl_quitting = true;
                            owl_posed = false;
                            angle = -90;
                            Game->PlayMIDI(lastMidi);
                        }
                        NoAction();
                    }
                    if(owl_quitting)
                    {
                        angle++;
                        Game->PlayMIDI(lastMidi);
                        this->X = (248-owl_final_x)*Cos(angle)+owl_final_x;
                        this->Y = -owl_final_y*Sin(angle);
                        this->TileWidth = 2;
                        Screen->DrawCombo(3, this->X+8, owl_final_y, SHADOW_TILE_DATA, 1, 1,SHADOW_CSET, -1, -1, 0, 0, 0,0, 0, true, 64);
                        this->Data = OWL_FLYING_DATA;
                        if(this->Y < 0)
                        {
                            activated = false;
                            Screen->D[flag] = 1;
                            this->Data = 0;
                        }
                    }
                }
                if(Screen->D[flag]==1)
                    break;
                Waitframe();
            }
        }
    }
}


I've taken NoAction() from the GB power bracelet script in the database...

Edited by lucas92, 22 May 2010 - 09:06 AM.


#9 Sephiroth

Sephiroth

    The Legendary Sephiroth

  • Members
  • Location:Somewhere... Lemme know if you find me :)

Posted 22 May 2010 - 09:25 AM

Interesting, I tried that one out and while the MIDI did change, it reverted to the previous dmap's midi instead of the current dmap's midi. o_O

#10 lucas92

lucas92

    Defender

  • Members

Posted 22 May 2010 - 09:38 AM

You mean after you went back on the screen or just after the message?

This should have worked though...

Well, I can fix this issue, but this will take an another argument (D8) for the script...

#11 Sephiroth

Sephiroth

    The Legendary Sephiroth

  • Members
  • Location:Somewhere... Lemme know if you find me :)

Posted 22 May 2010 - 09:52 AM

I self-fixed it myself. Instead of using a second Game->PlayMIDI, I changed it to a Link->PitWarp. works perfectly.

Video of it in action.


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users