PDA

View Full Version : Animal Stalker



gray0x
11-21-2008, 06:33 PM
Basically, I want a non-solid 1x1 FFC to always travel behind Link after getting a certain item. Sorta like Pikachu from Pokemon Yellow, I guess.

I doubt it's impossible, seeing as it's probably simpler than the fairy script. Think anybody can do this for me?

pkmnfrk
11-22-2008, 03:11 AM
Do you need this companion to do anything at all? Or, is he/she/it purely for show?

If the latter, then you don't even need an FFC, just a script I could write for you.

gray0x
11-22-2008, 12:03 PM
It's just purely for show. And if it means anything, I'm using item 165 for what should trigger it.

And I don't need it to turn around and stuff, just a 2 frame 1 direction thing would work wonders.

lucas92
11-22-2008, 10:53 PM
import "std.zh"

bool animal;
//put it with your item
item script animalfriendpickup
{
void run()
{
animal=true;
}
}
//this ffc script should be put wherever you want the animal friend to appear.
//D0:number of the ffc taken by animal friend
//D1:its data when going up
//D2:---------when going down
//D3:---------when going left
//D4:---------when going right
//D5:the CSet of the animal friend
ffc script animalfriend
{
void run(int n,int d1, int d2, int d3, int d4, int c)
{
int animalData[4];
animalData[1]=d1;animalData[2]=d2;animalData[3]=d3;animalData[4]=d4;
ffc a=Screen->LoadFFC(n);
a->Cset=c;
if (animal==false)
{
Quit();
}
else
{
while(true)
{
if (Link->Dir==0)
{
a->Data=animalData[1];
a->X=Link->X;a->Y=Link->Y+16;
}
if (Link->Dir==1)
{
a->Data=animalData[2];
a->X=Link->X;a->Y=Link->Y-16;
}
if (Link->Dir==2)
{
a->Data=animalData[3];
a->X=Link->X+16;a->Y=Link->Y;
}
if (Link->Dir==3)
{
a->Data=animalData[4];
a->X=Link->X-16;a->Y=Link->Y;
}
Waitframe();
}
}
}
}

I did not test it. So it might not be working... :p

gray0x
11-23-2008, 01:37 AM
Well Lucas, that's not what I want, I can tell by the comments. It should follow Link around on every screens, and only should really face 1 direction. Putting an FFC on every screen would be too much of a pain in the ass :|

Thanks for trying though. 2 scripts for me in a day :O

pkmnfrk
11-23-2008, 12:26 PM
You want it to face in one direction, but be behind link?

This should do the trick:


import "std.zh"

const int animal_tile = 1234; //tile
const int animal_cset = 2; //cset
const int animal_speed = 8; //animation speed, in frames.
int animal_frame = 0; //frame, don't change this
int animal_timer = 0; //animation timer, don't change this

global script slot_2 {
void run() {
while(true) {
if(Link->Item[165]) animalbuddy();
Waitframe();
}
}

void animalbuddy() {
int dx;
int dy;
if (Link->Dir==0)
{

dx=Link->X;dy=Link->Y+16;
}
if (Link->Dir==1)
{
dx=Link->X;dy=Link->Y-16;
}
if (Link->Dir==2)
{
dx=Link->X+16;dy=Link->Y;
}
if (Link->Dir==3)
{
dx=Link->X-16;dy=Link->Y;
}
Screen->DrawTile(2, dx, dy, animal_tile + animal_frame, 1, 1, animal_cset, 1, 0, 0, 0, 0, true, 128);
animal_timer += 1;
if(animal_timer >= animal_speed) {
animal_timer = 0;
if(animal_frame == 0) animal_frame = 1; else animal_frame = 0;
}
}
}

lucas, I stole you if block :P

Regardless, this will activate the instant you pick up item #165, and will draw a tile behind link until the moment you lose the item.

You can customize it by changing the three consts at the top. Also, if you want it to be translucent (eg, a ghost or something), change the 128 at the end of the "Screen->DrawTile" line to a 64.

It compiles, but I haven't tested it.

gray0x
11-23-2008, 01:20 PM
I love you.
It works great, just as annoying as I hoped it would be. My only complaint is that it disappears if there's a message on screens, whats up with that?

pkmnfrk
11-23-2008, 07:38 PM
Is the "Messages freeze all action" rule on? If so, it's because the global script isn't running any more, and thus not drawing the animal.

If this is a problem, I could rework it to be an FFC script.

bob1000
11-24-2008, 11:05 PM
Hey pkmnfrk, can you modify that script to look in 4 directions and animate only while moving?

EDIT: Nevermind, I managed to do it myself. (Anyone hoping to have it face in 4 directions can add "(Link->Dir * 4)" to "Screen->DrawTile".)

pkmnfrk
11-26-2008, 12:39 AM
import "std.zh"

const int animal_tile = 1180; //tile
const int animal_cset = 7; //cset
const int animal_speed = 8; //animation speed, in frames.
const int animal_frames = 2; //number of frames


int animal_frame = 0; //frame, don't change this
int animal_timer = 0; //animation timer, don't change this


global script slot_2 {
void run() {
while(true) {
if(Link->Item[165]) animalbuddy();
Waitframe();
}
}

void animalbuddy() {
int dx;
int dy;
if (Link->Dir==DIR_UP)
{

dx=Link->X;dy=Link->Y+16;
}
if (Link->Dir==DIR_DOWN)
{
dx=Link->X;dy=Link->Y-16;
}
if (Link->Dir==DIR_LEFT)
{
dx=Link->X+16;dy=Link->Y;
}
if (Link->Dir==DIR_RIGHT)
{
dx=Link->X-16;dy=Link->Y;
}
Screen->DrawTile(2, dx, dy, animal_tile + animal_frame + (Link->Dir * animal_frames), 1, 1, animal_cset, 1, 0, 0, 0, 0, true, 128);
if(Link->Action == LA_WALKING) {
animal_timer += 1;
if(animal_timer >= animal_speed) {
animal_timer = 0;
animal_frame += 1;
if(animal_frame == animal_frames) animal_frame = 0;
}
} else {
animal_timer = 0;
animal_frame = 0;
}
}
}

This version has three new things:

* The buddy can face in multiple directions (place the tiles in consecutive order: UP, DOWN, LEFT, RIGHT).

* It will only animate when actually walking.

* You can customize the number of frames by changing the "animal_frames" constant at the top.

Although I didn't mention it before, you can change the prerequisite item by changing the "if(Link->Item[165]) ..." line.