Jump to content

Photo

NPC Activates Secret Request


  • Please log in to reply
10 replies to this topic

#1 Vinyl Scratch

Vinyl Scratch

  • Members

Posted 29 April 2010 - 07:18 PM

Hey, im new to the forums. I have a request for a script: Can someone make me a script that, when you talk to a NPC, it activates the secret on the screen. Ive seen it in other quests.

#2 AgentLym

AgentLym

    • Zelda and Pokémon Master •

  • Members
  • Location:Skyloft

Posted 29 April 2010 - 10:12 PM

QUOTE(Joe123)
Creates an NPC that you can talk to.

CODE
ffc script RealNPC_TriggersSecrets{
    void run(int m, int sfx, int defdir, int d, int ffcnumber, int input){
        ffc NPC = this;
        if(ffcnumber != 0) Screen->LoadFFC(ffcnumber);
        NPC->Misc[0] = NPC->Data;
        if(d == 0) d = 40;
        
        while(true){
            SetGraphic(NPC,defdir,d);
            if(CanTalk(NPC,input)){
                SetInput(input,false);
                if(sfx != 0) Game->PlaySound(sfx);
                Screen->Message(m);
                Screen->TriggerSecrets();
            }
            Waitframe();
        }
    }
    bool CanTalk(ffc NPC,int input){
        return (SelectPressInput(input) && Abs(NPC->X-Link->X) < 24 && Abs(NPC->Y-Link->Y) < 24 && Link->Z == 0);
    }
    void SetGraphic(ffc NPC, int defdir, int d){
        int dx = NPC->X-Link->X; int ax = Abs(dx);
        int dy = NPC->Y-Link->Y; int ay = Abs(dy);
        if(defdir != 0){
            if(ax < d && ay < d){
                if(ax <= ay){
                    if(dy >= 0) NPC->Data = NPC->Misc[0]+DIR_UP;
                    else NPC->Data = NPC->Misc[0]+DIR_DOWN;
                }else{
                    if(dx >= 0) NPC->Data = NPC->Misc[0]+DIR_LEFT;
                    else NPC->Data = NPC->Misc[0]+DIR_RIGHT;
                }
            }else NPC->Data = NPC->Misc[0]+(defdir-1);
        }
    }
}

//Only include these two functions once in your script file
bool SelectPressInput(int input){
    if(input == 0) return Link->PressA;
    else if(input == 1) return Link->PressB;
    else if(input == 2) return Link->PressL;
    else if(input == 3) return Link->PressR;
}
void SetInput(int input, bool state){
    if(input == 0) Link->InputA = state;
    else if(input == 1) Link->InputB = state;
    else if(input == 2) Link->InputL = state;
    else if(input == 3) Link->InputR = state;
}


D0 is the message to play
D1 is an SFX if you want one, 0 for no SFX
D2 is whether you want the NPC to face Link. If 0 the NPC will stay still, 1-4 it will face Link with default direction up for 1, down for 2, left for 3 and right for 4
D3 is the distance away Link must be for the NPC to face him, default 40 pixels
D4 is the ffc the script should apply to - allowing for a different script to move an NPC and then this one to attach the NPC actions. Leave at 0 to have this ffc be the NPC
D5 is the input to check for when talking to the NPC, 0 is A, 1 is B, 2 is L and 3 is R.
The NPC should consist of 4 combos, facing up, down, left, right on the combosheet with the first one select as the ffc's data.

The script will only function correctly with both the 'Messages Freeze All Action' and the 'Messages Disappear' Quest Rules checked.
Note: This script uses a number of functions common to some other scripts of mine in the database. These functions should only be included in your script file once
This script was originally written by pkmnfrk, but I've taken it apart a put it back together again with various new bits since he first wrote it.


There ya go! It's basically a direct copy of pkmnfrk's NPC code that Joe123 majorly edited (which I assume you're using), but it triggers secrets as well as a message. All I did was stick in a "Screen->TriggerSecrets()" command right after the message line. icon_wink.gif It should work, but if it doesn't, report your findings here (or report your success here, for that matter icon_razz.gif )!

And, by the way, welcome to Pure! Hopefully you find this place friendly! icon_smile.gif

Edited by AgentLym, 30 April 2010 - 01:54 PM.


#3 Joe123

Joe123

    Retired

  • Members

Posted 30 April 2010 - 02:42 AM

QUOTE(AgentLym @ Apr 30 2010, 04:12 AM) View Post
There ya go! It's basically a direct copy of pkmnfrk's NPC code
No it's not, I re-wrote it. It works quite similar but the code's structured differently.


#4 AgentLym

AgentLym

    • Zelda and Pokémon Master •

  • Members
  • Location:Skyloft

Posted 30 April 2010 - 06:59 AM

Oh, I thought that you had just uploaded it for pkmnfrk, since I don't even think he has an account here. icon_razz.gif Sorry about the confusion. *fixed*

#5 Joe123

Joe123

    Retired

  • Members

Posted 30 April 2010 - 08:50 AM

No, I mean it's basically his code still which is why I credited him, but I did edit it quite a lot.

#6 Vinyl Scratch

Vinyl Scratch

  • Members

Posted 30 April 2010 - 03:32 PM

um....i found an error, i believe that its because i have the script twice, one for the normal NPC and for the NPC->Secret, but idk.
Here is the Error Report:
Pass 1: Parsing
Pass 2: Preprocessing
Pass 3: Building symbol tables
tmp, line 191: Error S04: Function SetInput was already declared with that type signature.

Edit: nvm, i fixed it. i had copied and pasted too much of it. icon_razz.gif

Edited by Shadox, 30 April 2010 - 05:10 PM.


#7 cosmofield

cosmofield

    Magical Girl

  • Members
  • Location:Sweden

Posted 30 April 2010 - 04:15 PM

Maybe remove one of them and it should work. icon_unsettled.gif

#8 Vinyl Scratch

Vinyl Scratch

  • Members

Posted 30 April 2010 - 05:20 PM

I found a problem with the FFC, I have the 2 rules that are needed for NPCs to work, Messages freeze all action and messages dissapear, but while the text is around, halfway through, Link can move. I dont know if im doing something wrong or what. icon_unsettled.gif

#9 AgentLym

AgentLym

    • Zelda and Pokémon Master •

  • Members
  • Location:Skyloft

Posted 01 May 2010 - 09:29 PM

That happens to me too... I dunno why (as in, if it's script related or engine related, so... yeah). But, on my games, he's only able to move for about 4 frames or so, then he freezes again (at least long enough to fire a sword beam icon_razz.gif). Is that how it is for you?

#10 Vinyl Scratch

Vinyl Scratch

  • Members

Posted 01 May 2010 - 11:57 PM

yeah, thats exactly what happened to me.
I wonder if its a glitch or something.

#11 Joe123

Joe123

    Retired

  • Members

Posted 02 May 2010 - 12:39 PM

Sounds like a bug...


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users