Read-only archive of the Armageddon Games Forums Archive (2000–2026) · About this archive

FFCs break sometimes?

11 replies · 2,135 views · Started 03 October 2010

I think there's something wrong with the FFCs because sometimes an FFC doesn't work or at least not all the way.

For instances I am using a hole script and it doesn't work in one screen for some reason,
and then I have an NPC script and it won't talk to me or face my direction.

Hot Water Music wrote:I think there's something wrong with the FFCs because sometimes an FFC doesn't work or at least not all the way.

For instances I am using a hole script and it doesn't work in one screen for some reason,
and then I have an NPC script and it won't talk to me or face my direction.



Can you post the scripts you are using?

I made a revision on the NPC script that allows the NPC to be solid, move, and guard spaces.
Sometimes the NPC doesn't turn towards the player, or talk, or guard, but they still block the player by the "solid" script.

I got the "broken" not working NPCs to work by copy and pasting another one, so I'm not sure if it's the script's fault if that's the case.

Here's a demo quest:
http://www.box.net/shared/uafoe1heag

import "std.zh"
ffc script real_npcV2 {
void run(int m, int gmitem, int f, int d, int def_dir, int npcissolid, int gm_min, int gm_max) {
int d_x;
int d_y;
int a_x;
int a_y;
int ir;
int tho=(this->TileHeight*16-16);
int orig_d = this->Data;
int Apressed2;
int Appr2;
int onscreenedge;
if(d == 0) d = 48;


while(true) {

//This detects if link is on the edge of the screen
if (Link->X<8 || Link->Y<8 || Link->X>232 || Link->Y>152){onscreenedge=1;} else {onscreenedge=0;}

//This checks if you're above or below the NPC to create an overhead effect
if (Link->Y<this->Y-8+tho && onscreenedge==0){this->Flags[FFCF_OVERLAY] = true;} else {this->Flags[FFCF_OVERLAY] = false;}

//This detects if A was pressed, allowing you to exit messages with the A button
if (Link->InputA)
{
if (Apressed2==1){Apressed2=0;}
else
{if (Appr2==0){Apressed2=1; Appr2=1;}}
}
else
{
Apressed2=0;
Appr2=0;
}

d_x = this->X - Link->X;
d_y = this->Y+(this->TileHeight*16-16) - Link->Y;
a_x = Abs(d_x);
a_y = Abs(d_y);

if(f != 0) {
if(a_x < d && a_y < d) {
if(a_x <= a_y) {
if(d_y >= 0) {
this->Data = orig_d + DIR_DOWN;
} else {
this->Data = orig_d + DIR_UP;
}
} else {
if(d_x >= 0) {
this->Data = orig_d + DIR_LEFT;
} else {
this->Data = orig_d + DIR_RIGHT;
}
}
} else {
this->Data = orig_d + def_dir;
}
}
//This checks if you have item D1, and makes the NPC disappear if you do.
if (Link->Item[gmitem] == true){this->X=-256; this->Y=-256;}
else
{

if (gm_max>0)
{
if (Link->X>gm_min-32 && Link->X<gm_max+32 && Link->Y>this->Y+tho-32 && Link->Y<this->Y+tho+32) {ir=1;} else {ir=0;}
if (Link->X<this->X-2 && this->X>gm_min && ir==1)
{
if (Link->X>gm_min){this->Vx= (- this->X + Link->X)/4;}else{this->Vx= (- this->X + gm_min)/4;}
}
if (Link->X>this->X+2 && this->X<gm_max && ir==1)
{
if (Link->X<gm_max){this->Vx= (Link->X - this->X)/4;}else{this->Vx= (gm_max - this->X)/4;}
}
if (Link->X<this->X+2 && Link->X>this->X-2){this->Vx=0;}
if (ir==0){this->Vx=0;}
if (this->X<gm_min+1){
if (this->Vx<0)this->Vx=0;
this->X=gm_min;
}
if (this->X>gm_max-1){
if (this->Vx>0)this->Vx=0;
this->X=gm_max;
}
}

if (gm_max<0)
{
if (Link->Y>-gm_min-32 && Link->Y<-gm_max+32 && Link->X>this->X-32 && Link->X<this->X+32) {ir=1;} else {ir=0;}
if (Link->Y<this->Y-2+tho && this->Y+tho>-gm_min && ir==1)
{
if (Link->Y>-gm_min){this->Vy= (- this->Y-tho + Link->Y)/4;} else {this->Vy= (- this->Y-tho + -gm_min)/4;}
}
if (Link->Y>this->Y+2+tho && this->Y+tho<-gm_max && ir==1)
{
if (Link->Y<-gm_max){this->Vy= (Link->Y - this->Y-tho)/4;} else {this->Vy= (-gm_max - this->Y-tho)/4;}
}
if (Link->Y<this->Y+2+tho && Link->Y>this->Y-2+tho){this->Vy=0;}
if (ir==0){this->Vy=0;}
if (this->Y+tho<-gm_min+1){
if (this->Vy<0)this->Vy=0;
this->Y=-gm_min-tho;
}
if (this->Y+tho>-gm_max-1){
if (this->Vy>0)this->Vy=0;
this->Y=-gm_max-tho;
}
}

}

if (this->Vy>0)this->Data = orig_d + DIR_UP;
if (this->Vy<0)this->Data = orig_d + DIR_DOWN;
if (this->Vx>0)this->Data = orig_d + DIR_RIGHT;
if (this->Vx<0)this->Data = orig_d + DIR_LEFT;

if(Apressed2==1 && a_x < 24 && a_y < 24) {
//This is all checking if Link is facing the NPC while to the left, to the right, above, or below the NPC
if (Link->X<this->X-8 && Link->Y>this->Y+tho-12 && Link->Y<this->Y+tho+8 && Link->Dir == DIR_RIGHT || Link->X>this->X+8 && Link->Y>this->Y+tho-12 && Link->Y<this->Y+tho+8 && Link->Dir == DIR_LEFT || Link->Y<this->Y+tho-8 && Link->X>this->X-8 && Link->X<this->X+8 && Link->Dir == DIR_DOWN || Link->Y>this->Y+tho+8 && Link->X>this->X-8 && Link->X<this->X+8 && Link->Dir == DIR_UP){
Apressed2=0;
Screen->Message(m);
Link->InputA = false;
}

}

//This enables the NPC to be solid without having to lay a solid combo under it.
if (npcissolid>0){
if ((Abs(Link->X - this->X) < 10) &&
(Link->Y <= this->Y+tho + 12) && (Link->Y > this->Y+tho+8)){Link->Y = this->Y+tho+12;}

if ((Abs(Link->Y - this->Y-tho) < 10) &&
(Link->X >= this->X - 12) && (Link->X < this->X-8)){Link->X = this->X-12;}

if ((Abs(Link->X - this->X) < 10) &&
(Link->Y >= this->Y+tho - 12) && (Link->Y < this->Y+tho-8)){Link->Y = this->Y+tho-12;}

if ((Abs(Link->Y - this->Y-tho) < 10) &&
(Link->X <= this->X + 12) && (Link->X > this->X+8)){Link->X = this->X+12;}
}
Waitframe();
}
}
}

Yeah, I saw that the way the guards moved was incorrect, and it used division to move, but is that also the cause of some FFCs not correctly working in general?

Do you have a broken FFC script that doesn't use division?

You can probably test this with that script by doing a replace all from "/4" to "*0.25" and see if it works also. (probably will)

It still breaks until I place a copied FFC on the screen. If I removed the copied FFC it goes back to being broken.
My script worked in previous builds btw.

It was also doing the same with the hole script which makes it seem more of a bug than a script error.

I also copy pasted the broken FFC onto another screen and it worked.

Here's a video of what happens when I copy past the broken FFC to a new screen
http://www.youtube.com/watch?v=t3wF62OhgNA

Oh and since this bug still stands even after getting rid of division, I wouldn't count it as quarantined.

I've got at least one script not working right in 1316, one of the ghost.zh demo enemies. Don't know what the problem is yet, or if it's directly related to this, but there's definitely still something wrong.
It's worse in 1312, though.

Maybe it's a function I'm using that they tweaked in the newer builds. I don't know. I can't tell what it is because it doesn't give compile errors.

In the video, you can see the "solid" part of the script is still working on that broken FFC, but then on the quest I gave out, there's another one where absolutely nothing is working on the FFC.

Edit: So I messed around even more by copy and pasting the FFC. When I place one the other one starts working right but the one I placed is broke now, and then I placed another one and it happened again. Something is reacting negatively to how I've set up the FFCs. I think this glitch is the glitch I've reported before really, and I think it got worse in this build, so the only way I fixed it was by placing another FFC and putting it offscreen.

I just tried the new build, and the division error is definitely not a part of this problem.
Hopefully this will be fixed soon in a future build. The quest I linked on this thread should help out with the problem so you can debug what exactly is causing the problem to happen.

I think as of now I will use build 1296 until the problems are fixed.