Jump to content

Photo

Shoelace Script request


  • Please log in to reply
19 replies to this topic

#1 Shoelace

Shoelace

    The Shaman of Sexy!

  • Members
  • Real Name:Michael
  • Pronouns:He / Him
  • Location:Arizona

Posted 24 August 2008 - 05:41 PM

Hi there. I have been messing with scripts lately and putting them in my quests. And I am in need of certain scripts. They are pretty easy scripts by the way, so here are the requests:

1. Person + direction:
Okay, I got a script where you press A to bring up a String message:

QUOTE
//
// "Person"
// Talk to the FFC by pressing A.
// Loosely based on scripts by pkmnfrk & beefster09
//
ffc script Person { void run(int m) { while(true) { while((Link->X < this->X - 8 && Link->Dir != DIR_RIGHT)
|| (Link->X > this->X + 8 && Link->Dir != DIR_LEFT)
|| (Link->Y < this->Y - 8 && Link->Dir != DIR_DOWN)
|| (Link->Y > this->Y + 8 && Link->Dir != DIR_UP)
|| (Link->X > this->X + 20 && Link->Dir == DIR_LEFT)
|| (Link->X < this->X - 20 && Link->Dir == DIR_RIGHT)
|| (Link->Y > this->Y + 24 && Link->Dir == DIR_UP)
|| (Link->Y < this->Y - 12 && Link->Dir == DIR_DOWN)
|| Link->Z > 0
|| this->Data == 0
|| !Link->InputA) { Waitframe(); } Link->InputA = false; Screen->Message(m);
do {
Waitframe();
} while (Link->InputA);
}
}}


For the past half hour, I have been trying to get this script to make it so the string will only come up if you are looking at a certain direction. So this is what I came up with:

-- There would be an if statement where say m=1 is all directions, m=2 is facing north, m=3 is facing west, m= 4 is east, and m= 5 is south.

I tryed to make it myself but it wasn't working, so hopefully this sorta thing is easy.

2. Pressing A -> Warp

This is an easy script I am guessing. Basically if you are standing on the FFC and you press A, you will be warped to the next screen. And I don't know if it matters or is needed but you can do a m=1: is for a direct warp and m=2 is for a stair warp.

3. Grasshoppers.

This is just a graphic thing. I was thinking of having little Tektites like things jumping around. They won't do any harm to the player as they are just to liven up the place i.e. a swamp. So yeah, they will randomly jump around the screen, and if possible jump away from Link if Link get close to them.


Anyways, hope any of you guys can help me out. I will give you credit also! Thanks

#2 Plissken

Plissken

    What's with these homies dissing our girls?

  • Members

Posted 24 August 2008 - 06:47 PM

I'll do number 2, give me a second.

Actually, this would require a bit more time from me, cause you wouldn't want Link to be standing RIGHT on the FFC to have to do this. So, I don't have a lot of time right now, but I can take a crack at it later tonight.

Edited by Plissken, 24 August 2008 - 07:02 PM.


#3 Elmensajero

Elmensajero

    Doyen(ne)

  • Members
  • Real Name:John
  • Location:Raleigh, North Carolina

Posted 24 August 2008 - 07:22 PM

I could do 1 and 2 pretty easily, even tonight if I can get my Microelectronics homework done early enough. 3 will take a little longer, and I'll need a few more details, but I'll let you know.

#4 Shoelace

Shoelace

    The Shaman of Sexy!

  • Members
  • Real Name:Michael
  • Pronouns:He / Him
  • Location:Arizona

Posted 24 August 2008 - 07:43 PM

QUOTE
Actually, this would require a bit more time from me, cause you wouldn't want Link to be standing RIGHT on the FFC to have to do this. So, I don't have a lot of time right now, but I can take a crack at it later tonight.


Well, yeah, I actually do want Link to be standing on the FFC. Because say for example, there is an exact spot that Link has to stand and when standing on that spot, then Link will warp. I wouldn't want him to warp if he isn't on that spot, because then it wouldn't go with the cutscenes and such.

QUOTE
I could do 1 and 2 pretty easily, even tonight if I can get my Microelectronics homework done early enough. 3 will take a little longer, and I'll need a few more details, but I'll let you know.


You need more details. This is what I mean. I am going to make a 4x4 sprite for example, and I want to put it as a FFC. I will attach the script to this FFC to make it randomly jump around. It will do short little jumps that sort of look like a Tekitite. It won't jump as much as a Tekitite but it jumps like one except shorter hops. And if possible I want it to act scared of Link. So if Link gets close by it like 2 tiles away maybe, it will jump away from Link.

Basically it is kinda like if you walked into a grass field. When you start walking through the grass, things start to jump away from you out of the grass. I want it to create a sense of liveliness.

And if I want a whole bunch of them, all I would do is make a bunch of FFC's attached with the same script. And that could be used at places like my swamp area where there would a lot of those things. icon_smile.gif

#5 Silver

Silver

    If only scripting were that easy...

  • Members
  • Real Name:Silva
  • Location:Somewhere on this plane.

Posted 24 August 2008 - 07:48 PM

Do you mean like the birds in Yoshi's Island, where you enter a swampy area, get near then, and they fly away?
Just curious.

#6 Shoelace

Shoelace

    The Shaman of Sexy!

  • Members
  • Real Name:Michael
  • Pronouns:He / Him
  • Location:Arizona

Posted 24 August 2008 - 07:59 PM

I don't know, I don't remember Yoshi's Island very well, I rented it once when it first came out. But... yeah I think so, except it sometimes jumps around by itself like normal insects do and also it will jump in a 4-dimensional space opposed to Yoshi's Island's 2-D space. XD

#7 Silver

Silver

    If only scripting were that easy...

  • Members
  • Real Name:Silva
  • Location:Somewhere on this plane.

Posted 24 August 2008 - 08:05 PM

Oh. Can't help you there.
Honestly, I don't know how to script, so I was just asking.

#8 Plissken

Plissken

    What's with these homies dissing our girls?

  • Members

Posted 24 August 2008 - 09:23 PM

Wait, so you want it to be the EXACT position on the FFC to warp? Oh, well then I'll get it to you really quick here, it'll just be kinda hard to line it up right for the player in ZC.

#9 Bourkification

Bourkification

    Magus

  • Members

Posted 25 August 2008 - 01:17 AM

You don't have to script the grasshopper, you could just make a custom enemy that is invincible, then give it zero damage, and there you go, it's a GRASSHOPPER!!! icon_lol.gif Although if the enemy touches link, link will act as though he was damaged, but no life is taken away.

#10 Elmensajero

Elmensajero

    Doyen(ne)

  • Members
  • Real Name:John
  • Location:Raleigh, North Carolina

Posted 25 August 2008 - 01:25 AM

Okay, here is 2...
CODE
import "std.zh"

bool justwarped=false;

global script slot_2 //prevents Link from using "A" weapon while warping
{
    void run()
    {
        while(true)
        {
            if(justwarped)
            {
                Link->InputA=false;
                justwarped=false;
            }
            Waitframe();
        }
    }
}

//  ~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
//    Warptile - Warps Link to specified screen/dmap when Link presses "A" on tile
//    D0 = Warptype (1 = warp to blue square,2 = warp with Link staying at current position)
//    D1 = Dmap of screen to warp to
//    D2 = Screen location... Unfortunately, ffc arguments can't take hex values, so you have to use decimal, with
//        top row 0-15, second row 16-31, etc...
//    D3 = Tolerance - How many pixels off warptile Link can be but still use it. He is moved on top of the tile before
//        warping if warptype = 2
//  ~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

ffc script warptile
{
    void run(int warptype, int dmap, int screen, int tolerance)
    {
        while(true)
        {
            if(Link->X>=this->X-tolerance && Link->X<=this->X+tolerance && Link->Y>=this->Y-tolerance && Link->Y<=this->Y+tolerance && Link->InputA)
            {
                if(warptype==1) //Warp to blue square
                {
                    justwarped=true;
                    Link->Warp(dmap,screen);
                }
                if(warptype==2) //Warp to screen with Link staying at the coordinates of the tile warping him
                {
                    Link->X=this->X;
                    Link->Y=this->Y;
                    Waitframe();
                    justwarped=true;
                    Link->PitWarp(dmap,screen);
                }
            }
            
            Waitframe();
        }
    }
}


There are four arguments to the ffc which are explained in the script. For the screen location variable, for some reason hex values do not work when you input them in an argument in ZQuest, so just use Windows calculator or something to convert the destination screen from hex to decimal. Also, the global script fixes a bug where Link would use his "A" weapon on the screen that he warps to. Oh, Plissken was right, I am pretty sure you don't want Link to have to be exactly on the warptile, because the user will have trouble lining up both his x and y position at the same time exactly on the tile. So, the tolerance argument of the ffc lets you specify how many pixels Link can be slightly off the tile and still be able to use it. Set it to 0 if you want to keep it on the tile only. If you do set the tolerance and use warptype 2 (see comments in script), it will move Link onto the tile before warping him. If you need anything else added to this script just let me know, otherwise I will write #1 tomorrow between classes.

Edited by Elmensajero, 25 August 2008 - 01:32 AM.


#11 Shoelace

Shoelace

    The Shaman of Sexy!

  • Members
  • Real Name:Michael
  • Pronouns:He / Him
  • Location:Arizona

Posted 25 August 2008 - 03:01 AM

Thank you so much! Elmensajero, I tested it and it worked with flying colors, better than I thought actually! I am very grateful for it! icon_smile.gif TWO THUMBS UP! icon_razz.gif

QUOTE
You don't have to script the grasshopper, you could just make a custom enemy that is invincible, then give it zero damage, and there you go, it's a GRASSHOPPER!!! icon_lol.gif Although if the enemy touches link, link will act as though he was damaged, but no life is taken away.


That is sort of what I don't want. Say for example, I had 15 of these on a screen (don't ask why I would), and of course there would be a chance that they would hit Link. Even if it took no damage, it would be a little weird to be bouncing everywhere. lol

Also, in my game, the script won't just be used for a Grasshopper, they will have different sprites that use the same script for different areas. Like I will have jumping spiders, maybe frogs, I can do anything really. icon_smile.gif

#12 Elmensajero

Elmensajero

    Doyen(ne)

  • Members
  • Real Name:John
  • Location:Raleigh, North Carolina

Posted 25 August 2008 - 04:03 PM

Next on the list, we have number 1.
Notes: The script should be self explanatory. Your main problem above Shoelace is that you were only worrying about one variable for each direction. You have to make sure Link is in a certain area on the screen by checking both of his coordinates for each direction. Other than that it may have worked, I don't know, I just started from scratch. Now, for the grasshopper things, I don't know if I will end up scripting them, it seems like it will be difficult to make it look realistic since FFC's don't have a Z variable (at least I don't think they do, I haven't tried messing with that before, though). But, in case I do, do you want them to be similar to Tektites in that they move over unwalkable combos, or do you want them to not be able to pass through unwalkable combos, a certain script flag, or a combination of both? Anyways, here is the code...

CODE

//  ~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
//    Person - Allows Link to press "A" near an FFC to view a message
//    D0 = Message String Number
//    D1 = How far away in pixels Link can be from FFC in relation to what direction he is facing
//    D2 = How far off to the side of the FFC Link can be in pixels
//    D3 = North (Input a 1 if Link can face the corresponding direction and view the message. Otherwise, put 0.)
//    D4 = West
//    D5 = East
//    D6 = South
//  ~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=

ffc script person
{
    void run(int m, int distanceaway, int sidedistance, int north, int west, int east, int south)
    {
        int msgwaittime=20; //How many frames Link must wait before he can view the message again
        int wt=0;
        
        while(true)
        {
            if(Link->InputA && Link->Z==0 && this->Data!=0 && wt==0)
            {
                if(Link->Dir==DIR_UP && north==1 && Link->Y>this->Y && Link->Y<=this->Y+16+distanceaway && Link->X>=this->X-sidedistance && Link->X<=this->X+sidedistance)
                {
                    Link->InputA=false;
                    Screen->Message(m);
                    wt=msgwaittime;
                }
                else if(Link->Dir==DIR_LEFT && west==1 && Link->X>this->X && Link->X<=this->X+16+distanceaway && Link->Y>=this->Y-sidedistance && Link->Y<=this->Y+sidedistance)
                {
                    Link->InputA=false;
                    Screen->Message(m);
                    wt=msgwaittime;
                }
                else if(Link->Dir==DIR_RIGHT && east==1 && Link->X>=this->X-16-distanceaway && Link->X<this->X && Link->Y>=this->Y-sidedistance && Link->Y<=this->Y+sidedistance)
                {
                    Link->InputA=false;
                    Screen->Message(m);
                    wt=msgwaittime;
                }
                else if(Link->Dir==DIR_DOWN && south==1 && Link->Y>=this->Y-16-distanceaway && Link->Y<this->Y && Link->X>=this->X-sidedistance && Link->X<=this->X+sidedistance)
                {
                    Link->InputA=false;
                    Screen->Message(m);
                    wt=msgwaittime;
                }
                do
                {
                    if(wt>0) wt--;
                    Waitframe();
                } while(Link->InputA); //"borrowed this from _L_'s npc script to prevent message from restarting when finished when player holds the "A" button down
            }
            
            if(wt>0) wt--;
            Waitframe();
        }
    }
}

Edited by Elmensajero, 23 October 2008 - 06:10 PM.


#13 Saffith

Saffith

    IPv7 user

  • Members

Posted 25 August 2008 - 05:00 PM

Here's a grasshopper script.
Script
Demo

It takes one argument, which is optional. D0 sets how close Link can get before it jumps away from him; the default it 24. If it's negative, they won't be afraid of him at all (as illustrated by the blue arrows in the demo).

Edited by Saffith, 26 August 2008 - 12:54 PM.


#14 Shoelace

Shoelace

    The Shaman of Sexy!

  • Members
  • Real Name:Michael
  • Pronouns:He / Him
  • Location:Arizona

Posted 25 August 2008 - 05:02 PM

Thanks! But, Elmensajero, I have been testing it out for a while, and I can't figure it out. Say I have a screen like this:

gsg
gfg
ggg

Where g=ground tile, s= is the sprite for the sign post, and f is for the FFC placement where it is where you press A.

Anyways, I have been testing this script out and when I am standing on f it won't display the message. However, if I am a tile below it, it will display. I don't know if I am setting it up wrong but I have been changing the values of the distanceaway, and the side distance, it is just making that ground tile below differ. So am I doing something wrong. What numbers do I have put in for it to work on the FFC tile?

By the way, this is just a thought, but my Link is 1x2 however, the hitbox is still 1x1. And no other script has problems with it so far, but just throwing that info in case.

Edit:
Awesome, Saffith, I just downloaded it, I am going to test it out right now.

Edit: Wow, Saffith that works just the way I wanted it to. This is going to going to make my game more lively. icon_smile.gif It is kinda addicting to chase the arrows around the screen. XD

#15 Elmensajero

Elmensajero

    Doyen(ne)

  • Members
  • Real Name:John
  • Location:Raleigh, North Carolina

Posted 25 August 2008 - 07:43 PM

Oh, I have it set up so the ffc IS the person / sign / whatever. But you prob will have problems if Link is a different size, let me look at it and see if I can fix it for a 1x2 Link (Is 2 the height or width?) You wanted the FFC to be placed next to the "person"? Wouldn't that make it difficult to talk to the person on all sides if you had to set the ffc next to it? Anyways, here is how it is supposed to work. Assume you have a screen similar to the above, except f is on top of s, and ^ is Link looking north.

ggg
gfg
g^g

distanceaway is how many pixels below the ffc that Link can be and still read the sign. Any closer is of course okay, but any further down and Link won't be able to read the sign anymore. sidedistance is how many pixels to the right or left of the center of the FFC Link can be (while still being below it). I found when testing it that distanceaway = 2 , sidedistance = 4 worked good, but I left it as a variable in case you needed to change it. Does that make more sense?


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users