Jump to content

Photo

FFC EnemyChangerCombo Request


  • Please log in to reply
9 replies to this topic

#1 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 23 April 2016 - 10:28 PM

I would like to request a script where enemy ID (D0) changes to enemy ID (D1) when it steps on combo (D2).


Edited by Cukeman, 26 April 2016 - 05:03 AM.


#2 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 26 July 2016 - 02:26 AM

ffc script FFCChangesNPC{
	void run(int n1, int n2) {
		npc a[2]; int q;
		Waitframes(5);
		while(true){
			
			for ( q = 1; q <= Screen->NumNPCs(); q++ ) {
				n[0] = Screen->LoadNPC(q);
				if ( n[0]->ID == n1 ) {
					if ( Collision(n[0],this) ) {
						n[0]->DrawXOffset = -200;
						n[0]->HitXOffset = -200;
						n[1] = Screen->CreateNPC(n2);
						n[1]->X = n[0]->X;
						n[1]->Y = n[0]->Y;
						Remove(n[0];
					}
				}
			}
		}
	}
}

ffc script ComboChangesNPC{
	void run(int n1, int n2, int comboID) {
		npc a[2]; int q[2];
		Waitframes(5);
		while(true){
			for ( q[0] = 1; q[0] <= Screen->NumNPCs(); q[0]++ ) {
				n[0] = Screen->LoadNPC(q);
				if ( n[0]->ID == n1 ) {
					for ( q[1] = 0; q[1] < 176; q[1]++ ) {
						if ( ComboD[q[1]] == comboID ) { 
							if ( ___Collision(q[1],n[0]) ) {
								n[0]->DrawXOffset = -200;
								n[0]->HitXOffset = -200;
								n[1] = Screen->CreateNPC(n2);
								n[1]->X = n[0]->X;
								n[1]->Y = n[0]->Y;
								Remove(n[0];
							}
						}
					}
				}
			}
		}
	}
	//Check for collision between npc 'n' and a combo at location 'cmb'. 
	bool Collision(int cmb, npc n){
		int c[8];
		c[0] = ComboX(cmb);
		c[1] = ComboY(cmb);
		c[2] = ComboX(cmb)+16;
		c[3] = ComboY(cmb)+16;
		c[4] = (n->X)+n->HitXOffset+n->DrawXOffset;
		c[5] = (n->Y)+n->HitYOffset+n->DrawYOffset;
		c[6] = c[4]+n->HitWidth;
		c[7] = c[5]+n->HitHeight;
		return RectCollision( c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7] );
	}
}
Untested. May have minor typos for you to find, but should otherwise work as you requested. Includes a bonus ffc that does this on collision with the ffc.

#3 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 26 July 2016 - 07:15 PM

In the first example I added a missing parenthesis making "Remove(n[0];" "Remove(n[0]);", now it says variable n is undeclared. Is there a list of compiling errors somewhere that I can bookmark for reference?



#4 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 26 July 2016 - 07:56 PM

In the first example I added a missing parenthesis making "Remove(n[0];" "Remove(n[0]);", now it says variable n is undeclared. Is there a list of compiling errors somewhere that I can bookmark for reference?

 

http://timelord.inso....50.2_v0.69.txt

 

Errors are in the file, with explanations.

 

 

Should be:

 

Remove(n[0]);

 

not

 

Remove(n);

 

What line is returning an invalid identifier on npc n?


  • Cukeman likes this

#5 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 26 July 2016 - 08:09 PM

What line is returning an invalid identifier on npc n?

 
All of these lines:

n[0] = Screen->LoadNPC(q);
				if ( n[0]->ID == n1 ) {
					if ( Collision(n[0],this) ) {
						n[0]->DrawXOffset = -200;
						n[0]->HitXOffset = -200;
						n[1] = Screen->CreateNPC(n2);
						n[1]->X = n[0]->X;
						n[1]->Y = n[0]->Y;
						Remove(n[0];

Edited by Cukeman, 26 July 2016 - 08:11 PM.


#6 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 26 July 2016 - 10:06 PM

import "std.zh"

ffc script FFCChangesNPC{
    void run(int n1, int n2) {
        npc n[2]; int q;
        Waitframes(5);
        while(true){
            
            for ( q = 1; q <= Screen->NumNPCs(); q++ ) {
                n[0] = Screen->LoadNPC(q);
                if ( n[0]->ID == n1 ) {
                    if ( Collision(n[0],this) ) {
                        n[0]->DrawXOffset = -200;
                        n[0]->HitXOffset = -200;
                        n[1] = Screen->CreateNPC(n2);
                        n[1]->X = n[0]->X;
                        n[1]->Y = n[0]->Y;
                        Remove(n[0]);
                    }
                }
            }
            Waitframe();
        }
    }
}

ffc script ComboChangesNPC{
    void run(int n1, int n2, int comboID) {
        npc n[2]; int q[2];
        Waitframes(5);
        while(true){
            for ( q[0] = 1; q[0] <= Screen->NumNPCs(); q[0]++ ) {
                n[0] = Screen->LoadNPC(q[0]);
                if ( n[0]->ID == n1 ) {
                    for ( q[1] = 0; q[1] < 176; q[1]++ ) {
                        if ( Screen->ComboD[q[1]] == comboID ) {
                            if ( ___Collision(q[1],n[0]) ) {
                                n[0]->DrawXOffset = -200;
                                n[0]->HitXOffset = -200;
                                n[1] = Screen->CreateNPC(n2);
                                n[1]->X = n[0]->X;
                                n[1]->Y = n[0]->Y;
                                Remove(n[0]);
                            }
                        }
                    }
                }
            }
            Waitframe();
        }
    }
    //Check for collision between npc 'n' and a combo at location 'cmb'.
    bool ___Collision(int cmb, npc n){
        int c[8];
        c[0] = ComboX(cmb);
        c[1] = ComboY(cmb);
        c[2] = ComboX(cmb)+16;
        c[3] = ComboY(cmb)+16;
        c[4] = (n->X)+n->HitXOffset+n->DrawXOffset;
        c[5] = (n->Y)+n->HitYOffset+n->DrawYOffset;
        c[6] = c[4]+n->HitWidth;
        c[7] = c[5]+n->HitHeight;
        return RectCollision( c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7] );
    }
}

Tested. Works. Quest: http://timelord.inso...ace_enemies.qst


Edited by ZoriaRPG, 26 July 2016 - 10:06 PM.


#7 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 26 July 2016 - 11:49 PM

For the FFC Changer:

 

I tested this script on a screen with 4 "Zol 1" enemies. They are set up to change into "Zol 2" enemies.

 

Currently the "Zol 1" enemies change when they're centered on any of the 8 tiles adjacent to the FFC. Could they not change until touching the center of the FFC?

 

Also, I noticed that if Link leaves the screen without killing any Zols, the ones that change are considered slain, and when Link returns to the screen he will only find the Zols that did not change. The Enemies Always Return flag does work, but I'm not sure if that's the best option.



#8 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 27 July 2016 - 12:04 AM

Oh, I forgot to update GuyCount. I'll do that after I sleep.

Is it the collision with the ffc, or collision with the combo that's doing it? I didn't notice that at all. I remember noticing that, and saying to meself that I had to fix it, then I forgot.
See if this fixes the enemies vanishing:


ffc script FFCChangesNPC{
    void run(int n1, int n2) {
        npc n[2]; int q;
        Waitframes(5);
        while(true){
            
            for ( q = 1; q <= Screen->NumNPCs(); q++ ) {
                n[0] = Screen->LoadNPC(q);
                if ( n[0]->ID == n1 ) {
                    if ( Collision(n[0],this) ) {
                        n[0]->DrawXOffset = -200;
                        n[0]->HitXOffset = -200;
                        n[1] = Screen->CreateNPC(n2);
                        n[1]->X = n[0]->X;
                        n[1]->Y = n[0]->Y;
                        Remove(n[0]);
                    }
                }
            }
								Game->GuyCount[Game->GetCurScreen()] = Screen->NumNPCs();
            Waitframe();
        }
    }
}

ffc script ComboChangesNPC{
    void run(int n1, int n2, int comboID) {
        npc n[2]; int q[2];
        Waitframes(5);
        while(true){
            for ( q[0] = 1; q[0] <= Screen->NumNPCs(); q[0]++ ) {
                n[0] = Screen->LoadNPC(q[0]);
                if ( n[0]->ID == n1 ) {
                    for ( q[1] = 0; q[1] < 176; q[1]++ ) {
                        if ( Screen->ComboD[q[1]] == comboID ) {
                            if ( ___Collision(q[1],n[0]) ) {
                                n[0]->DrawXOffset = -200;
                                n[0]->HitXOffset = -200;
                                n[1] = Screen->CreateNPC(n2);
                                n[1]->X = n[0]->X;
                                n[1]->Y = n[0]->Y;
                                Remove(n[0]);
                            }
                        }
                    }
                }
            }
								Game->GuyCount[Game->GetCurScreen()] = Screen->NumNPCs();
            Waitframe();
        }
    }
    //Check for collision between npc 'n' and a combo at location 'cmb'.
    bool ___Collision(int cmb, npc n){
        int c[8];
        c[0] = ComboX(cmb);
        c[1] = ComboY(cmb);
        c[2] = ComboX(cmb)+16;
        c[3] = ComboY(cmb)+16;
        c[4] = (n->X)+n->HitXOffset+n->DrawXOffset;
        c[5] = (n->Y)+n->HitYOffset+n->DrawYOffset;
        c[6] = c[4]+n->HitWidth;
        c[7] = c[5]+n->HitHeight;
        return RectCollision( c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7] );
    }
}


Edited by ZoriaRPG, 26 July 2016 - 11:58 PM.

  • Cukeman likes this

#9 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 27 July 2016 - 12:41 AM

Oh, I forgot to update GuyCount. I'll do that after I sleep.

Is it the collision with the ffc, or collision with the combo that's doing it? I didn't notice that at all. I remember noticing that, and saying to meself that I had to fix it, then I forgot.
See if this fixes the enemies vanishing:

 

...

 

 

 

Yes that fixed the enemies from not returning :)

 

It was the collision with the FFC that changed the enemies who touched the 8 adjacent tiles.

 

I haven't commented on the Combo changing script yet. It seemed like it was doing something odd, but I'd have to take a closer look to be sure.



#10 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 27 July 2016 - 01:39 AM

i'll need to change Collision() to DistXY().

These could be system timing issues, stemming from running the changing instructions from an ffc, and thus, after Waitdraw().

Seems as if it may be wise to add CenterCollision() and TrimCollision() to std.zh, after all.

Edited by ZoriaRPG, 27 July 2016 - 01:42 AM.



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users