Jump to content

Photo

3 item script


  • Please log in to reply
13 replies to this topic

#1 Jay

Jay

    Magus

  • Members
  • Real Name:Justin

Posted 02 November 2009 - 06:08 PM

I could really use a script that allows you to use 3 item instead of one, like z and x being used for items as well, could anyone help?

#2 Joe123

Joe123

    Retired

  • Members

Posted 02 November 2009 - 06:23 PM

There's a quest rule, 'Can Select A Button Item In Subscreen' (or similar), which allows you to swap your sword out for another item.
As for a script which allows you to use three items - you'd have to have every item in your inventory re-scripted from scratch. I'm afraid this isn't really practical.

And could you please post future script requests in the Script Request sub-forum, rather than just in Scripting Discussion. As you can see, I have moved this one for you.

#3 Jay

Jay

    Magus

  • Members
  • Real Name:Justin

Posted 02 November 2009 - 06:28 PM

ok my bad, alright a bit tough I geuss, I got the rolling and shield one to put into it, any proper global scripts around to talk to npc's, like with the A button when in front of the person causing a message string to come up??

#4 Joe123

Joe123

    Retired

  • Members

Posted 02 November 2009 - 06:38 PM

What you want for that is not a global script, but an ffc script which you apply to each NPC.
This one should suffice:
CODE
ffc script RealNPC{
    void run(int m, int sfx, int defdir, int faced, int talkd){
        int origd = this->Data;
        if(faced == 0) faced = 40;
        if(talkd == 0) talkd = 24;

        while(true){
            int dx = this->X-Link->X; int ax = Abs(dx);
            int dy = this->Y-Link->Y; int ay = Abs(dy);
            if(defdir != 0){
                if(ax < faced && ay < faced){
                    if(ax <= ay){
                        if(dy >= 0) this->Data = origd+DIR_UP;
                        else this->Data = origd+DIR_DOWN;
                    }else{
                        if(dx >= 0) this->Data = origd+DIR_LEFT;
                        else this->Data = origd+DIR_RIGHT;
                    }
                }else this->Data = origd+(defdir-1);
            }
            if(Link->InputA && ax < talkd && ay < talkd && Link->Z == 0){
                if(sfx != 0) Game->PlaySound(sfx);
                Link->InputA = false;
                Screen->Message(m);
                do Waitframe();
                while(Link->InputA);
            }
        Waitframe();
        }
    }
}


#5 Jay

Jay

    Magus

  • Members
  • Real Name:Justin

Posted 02 November 2009 - 07:04 PM

Yup looks pretty good thanks!
though I'm having alot of troubles uploading this bloody thing. and the roll defend global script into it, I imported it after going to Scripts-Compile Zscript...

Then Clicked import, imported the script file with the .z on the end.
but when i try to compile it, no luck.

#6 Plissken

Plissken

    What's with these homies dissing our girls?

  • Members

Posted 02 November 2009 - 07:48 PM

What error message do you get?

#7 Jay

Jay

    Magus

  • Members
  • Real Name:Justin

Posted 02 November 2009 - 09:35 PM

The talk to npc ffc one that joe123 gave me, sais all 4 directions are undeclared or something like that.
And the roll, and defend one says like
Line 98- SYNTAX error bla bla bla, unable to parse or inpute file
something along those lines
anything on it?

#8 Plissken

Plissken

    What's with these homies dissing our girls?

  • Members

Posted 02 November 2009 - 09:37 PM

You "bla bla bla"ed out the important part. Mind just putting everything that's in the .z file in [code=auto:0] tags so I can take a look at it and try to fix it?

Edited by Plissken, 02 November 2009 - 09:38 PM.


#9 Jay

Jay

    Magus

  • Members
  • Real Name:Justin

Posted 02 November 2009 - 10:05 PM

sorry, yeah here it is
LINE 98: SYNTAX ERROR, UNEXPECTED IF, EXPECTING SEMICOLON, ON TOKEN IF FATAL ERROR P00: CAN'T OPEN OR PARSE INPUT FILE
-- -- PRESS A KEY -- --
And the one for the talking to npc ffc, the only error it said, was dir. up left right and down were undeclared.
thank you.

#10 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 02 November 2009 - 10:37 PM

add the line: "
CODE
import "std.zh"

" to the .z file.

#11 Jay

Jay

    Magus

  • Members
  • Real Name:Justin

Posted 02 November 2009 - 11:18 PM

where do I put it in the file?

Nvm, Have figured it out for the talking npc one anywway, though It is compiled and assigned tp FFC # 1, I do not know how to put it into play?

#12 Christian

Christian

    Summoner

  • Members
  • Real Name:Chris
  • Location:New Jersey

Posted 03 November 2009 - 12:41 AM

CODE

import "std.zh"

ffc script RealNPC{
    void run(int m, int sfx, int defdir, int faced, int talkd){
        int origd = this->Data;
        if(faced == 0) faced = 40;
        if(talkd == 0) talkd = 24;

        while(true){
            int dx = this->X-Link->X; int ax = Abs(dx);
            int dy = this->Y-Link->Y; int ay = Abs(dy);
            if(defdir != 0){
                if(ax < faced && ay < faced){
                    if(ax <= ay){
                        if(dy >= 0) this->Data = origd+DIR_UP;
                        else this->Data = origd+DIR_DOWN;
                    }else{
                        if(dx >= 0) this->Data = origd+DIR_LEFT;
                        else this->Data = origd+DIR_RIGHT;
                    }
                }else this->Data = origd+(defdir-1);
            }
            if(Link->InputA && ax < talkd && ay < talkd && Link->Z == 0){
                if(sfx != 0) Game->PlaySound(sfx);
                Link->InputA = false;
                Screen->Message(m);
                do Waitframe();
                while(Link->InputA);
            }
        Waitframe();
        }
    }
}


You put:
CODE

import "std.zh"

on top of your script file only if you're using certain functions that requieres std.zh.

#13 Zenith

Zenith

    Old Guard

  • Members

Posted 03 November 2009 - 02:30 PM

Wait, so...what functions require it and what do you not need it for?

#14 Joe123

Joe123

    Retired

  • Members

Posted 03 November 2009 - 04:05 PM

Any of the useful functions and constants included within the file.
A few common-place examples are:
  • ComboAt
  • Floor
  • Waitframes
  • Distance
  • DIR_ constants
  • LW_ & EW_ constants
  • I_ constants
  • NPC_ constants
However the number of functions included have increased dramatically recently and I imagine not everyone is aware of their nature/how useful they may be yet, so it's likely to gain more usage in future.
It's basically a set of functions that we on the dev team decided would be a useful addition to the language without having to be hard-coded into ZScript itself. If you have any suggestions for additions to it that people may find useful, feel free to post them at AGN or make a thread here or something and they'll be considered.


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users