Jump to content

Photo

Sometimes I really suck at this...


  • Please log in to reply
12 replies to this topic

#1 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 24 May 2017 - 07:09 PM

So, yeah, trying to make a script which flips the boomerang's graphics, depending on its direction (Well, rotates, actually, but same thing) so that I can replace the boomerang in my quest with an attack falcon. I already have the sprites set for it facing up, just need to do the flipping. With a lot of help, I came up with this:
import "std.zh"
import "ffcscript.zh"
import "stdExtra.zh"
import "string.zh"


global script slot_2
{
    void run(){

       

        while(true)
        {
                     for (int i = 1; i <= Screen->NumLWeapons(); ++i) 
            {
             lweapon Falcon = Screen->LoadLWeapon(i);
             if (Falcon->ID != LW_BRANG) continue;
             else if (Falcon->ID == LW_BRANG)
              {
                if (Falcon->Dir == DIR_DOWN)
                {
                    Falcon->OriginalTile = 21400;
                    Falcon->Flip = 3;
                }
                else if (Falcon->Dir == DIR_RIGHT)
                {
                    Falcon->OriginalTile = 21408;
                    Falcon->Flip = 0;
                }
                else if (Falcon->Dir == DIR_LEFT)
                {
                    Falcon->OriginalTile = 21400;
                    Falcon->Flip = 2;
                }
                else if (Falcon->Dir == DIR_UP)
                {
                    Falcon->OriginalTile = 21408;
                    Falcon->Flip = 0;
                }
                else if (Falcon->Dir == DIR_LEFTUP)
                {
                    Falcon->OriginalTile = 21400;
                    Falcon->Flip = 2;
                }
                else if (Falcon->Dir == DIR_LEFTDOWN)
               {
                    Falcon->OriginalTile = 21400;
                    Falcon->Flip = 2;
                }
                else if (Falcon->Dir == DIR_RIGHTUP)
                {
                    Falcon->OriginalTile = 21408;
                    Falcon->Flip = 0;
                }
                else if (Falcon->Dir == DIR_RIGHTDOWN)
                {
                    Falcon->OriginalTile = 21408;
                    Falcon->Flip = 0;
                }
              }

            Waitframe();

        }
    }
}
}
    
 
  

 
But it seems to be having a problem compiling: "Line 14: Error T21: Could Not Match Type Signature LoadLWeapon(Screen,  LWeapon)." I'm a bit lost with this one.
 
Edited to expand it slightly, but it still doesn't work.
 
EDITED to fix the syntax error, compiles now, bricks ZC upon launch. I have to ctrl+alt+delete it

Edited by Binx, 25 May 2017 - 12:11 AM.


#2 David

David

    Fallen leaves... adorn my night.

  • Administrators
  • Real Name:David
  • Pronouns:He / Him

Posted 24 May 2017 - 08:59 PM

I believe what you actually want on that line is:
for(int i = 1; i <= Screen->NumLWeapons(); ++i) {
     lweapon Falcon = Screen-LoadLWeapon(i);   //Change from Falcon to i
}

You are iterating over all the lweapons on the screen, so you are starting by loading the lweapon "1". If that lweapon isn't a boomerang, then the for loop runs again but with "i" being "2". It keeps doing this until it find the appropriate lweapon that you are looking for. Hope this helps!


  • Binx likes this

#3 strike

strike

    life is fragile, temporary, and precious

  • Members
  • Real Name:Olórin

Posted 24 May 2017 - 09:16 PM

Couldn't you use directional sprites without scripts? Sorry if that is completely wrong.

 

-Strike



#4 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 24 May 2017 - 09:22 PM

Ugh, so many stupid mistakes.... Every time... Ok, well, it compiles, but it bricks ZC, now... But that might be me mixing it with the FFC Follower script. Trying to make a follower that follows me except when there's a boomerang onscreen, but still does the boomerang thing.

import "std.zh"
import "ffcscript.zh"
import "stdExtra.zh"
import "string.zh"


global script slot_2
{
    void run(){

        int reqItem = 23; //Item that makes the FFC follower follow you
        int ffcNumber = 32; //The number of the FFC used.  This script will "hijack" this one, so don't use it for anything else on screens when you expect the player to have a follower.
        int firstFollowerCombo = 65272; //combo of the first combo.  In order, the concecutive combos must be "still up", "still down", "still left", "still right", "moving up", "moving down", "moving left", "moving right".
        int csetOfFollower = 8;
        bool firstCheck = false; //leave this alone
        ffc follower;

        int pastX;
        int currentX;
        int followerX[13];

        int pastY;
        int currentY;
        int followerY[13];

        int index;

        while(true)
        {

            if(Link->Item[reqItem] == true)
            {
                     for (int i = 1; i <= Screen->NumLWeapons(); ++i) 
            {
             lweapon Falcon = Screen->LoadLWeapon(i);
             if (Falcon->ID != LW_BRANG)
             {
                if(Link->Action != LA_SCROLLING && firstCheck == false){
                    follower = Screen->LoadFFC(ffcNumber);
                    follower->Data = firstFollowerCombo;
                    follower->CSet = csetOfFollower;

                    pastX = Link->X;
                    follower->X = Link->X;
                    pastY = Link->Y;
                    follower->Y = Link->Y;

                    for ( int i = 0; i < 13; i++ ){
                        followerX[i] = Link->X;
                        followerY[i] = Link->Y;
                    }

                    firstCheck = true;
                }
                if(Link->Action != LA_SCROLLING){
                    if((Link->InputUp || Link->InputDown || Link->InputRight || Link->InputLeft)&&(!(Link->InputA || Link->InputB))){
                        pastX = follower->X;
                        follower->X = followerX[0];
                        for(index=0; index<12; index++){
                            followerX[index] = followerX[index + 1];
                        }
                        followerX[12] = Link->X;

                        pastY = follower->Y;
                        follower->Y = followerY[0];
                        for(index=0; index<12; index++){
                            followerY[index] = followerY[index + 1];
                        }
                        followerY[12] = Link->Y;
                    }

                    if(follower->Y > pastY){
                        follower->Data = firstFollowerCombo + 5;
                    }
                    else if(follower->Y < pastY){
                        follower->Data = firstFollowerCombo + 4;
                    }
                    else if(follower->X > pastX){
                        follower->Data = firstFollowerCombo + 7;
                    }
                    else if(follower->X < pastX){
                        follower->Data = firstFollowerCombo + 6;
                    }
                    if(!(Link->InputUp || Link->InputDown || Link->InputRight || Link->InputLeft)){
                        if((follower->Data == (firstFollowerCombo + 4))||(follower->Data == (firstFollowerCombo + 5))||(follower->Data == (firstFollowerCombo + 6))||(follower->Data == (firstFollowerCombo + 7))){
                            follower->Data = follower->Data - 4;
                        }
                        else if((follower->Data == (firstFollowerCombo + 3))||(follower->Data == (firstFollowerCombo + 2))||(follower->Data == (firstFollowerCombo + 1))||(follower->Data == (firstFollowerCombo))){
                            
                        }
                        else{
                            follower->Data = firstFollowerCombo;
                        }
                    }
                }
                if(Link->Action == LA_SCROLLING){
                    firstCheck = false;
                }
            }
             else if (Falcon->ID == LW_BRANG)
              {
                if (Falcon->Dir == DIR_DOWN)
                {
                    Falcon->OriginalTile = 21400;
                    Falcon->Flip = 3;
                }
                else if (Falcon->Dir == DIR_RIGHT)
                {
                    Falcon->OriginalTile = 21408;
                    Falcon->Flip = 0;
                }
                else if (Falcon->Dir == DIR_LEFT)
                {
                    Falcon->OriginalTile = 21400;
                    Falcon->Flip = 2;
                }
                else if (Falcon->Dir == DIR_UP)
                {
                    Falcon->OriginalTile = 21408;
                    Falcon->Flip = 0;
                }
                else if (Falcon->Dir == DIR_LEFTUP)
                {
                    Falcon->OriginalTile = 21400;
                    Falcon->Flip = 2;
                }
                else if (Falcon->Dir == DIR_LEFTDOWN)
               {
                    Falcon->OriginalTile = 21400;
                    Falcon->Flip = 2;
                }
                else if (Falcon->Dir == DIR_RIGHTUP)
                {
                    Falcon->OriginalTile = 21408;
                    Falcon->Flip = 0;
                }
                else if (Falcon->Dir == DIR_RIGHTDOWN)
                {
                    Falcon->OriginalTile = 21408;
                    Falcon->Flip = 0;
                }
              }

            Waitframe();

        }
    }
}
}
}

I'm sure there's just something I'm missing, or I made a mistake with the placement of something. EDIT: definitely not an issue with placement (well, maybe but that's not what's bricking ZC) the boomerang changing aspect of it is causing the game to freeze.

 

 

Couldn't you use directional sprites without scripts? Sorry if that is completely wrong.

 

-Strike

Nah, boomerangs always use the same sprite, no flips, no rotation. Otherwise, there'd be no way I'd be trying to script this. Plus, I'm aiming to have the falcon's sprite reverse when it's returning to you. (So if you throw it left, it faces left, then when it gets to the end, faces right and returns)


Edited by Binx, 25 May 2017 - 12:13 AM.


#5 cavthena

cavthena

    Apprentice

  • Members
  • Real Name:Clayton
  • Location:I wish I knew

Posted 25 May 2017 - 12:00 AM

First up, when working in global you want to place your code in functions whenever possible. This helps keep your code clean and in ZC's case, you can stuff more into your code.

 

I changed your Boomerang script a bit. I commented the code where I made changes. The idea here is to make sure you only set the tile when required and not every frame (creating massive amounts of Lag).

Edit: Collapsed the if-else block a bit. Some instructions repeat.

const int BRANG_STATE = 0; //Slot of lweapon->Misc[] to use.

void BrangFlip()
{
	for (int i = Screen->NumLWeapons(); i > 0; i--) //Counting down is safer. Do not count 0 as that will log an error and cause lag.
	{
		lweapon Falcon = Screen->LoadLWeapon(Falcon);
		
		//Added Valid check and only check if falcon is brang. continue instruction is not needed.
		if (Falcon->ID == LW_BRANG && Falcon->isValid() && Falcon->Misc[BRANG_STATE] == 0)
		{
			BrangChange(Falcon); //Change if-else block to a function for easier use.
			
			//Set the checked value to the weapon dead state of WDS_BOUNCE or 1. For later checks.
			Falcon->Misc[BRANG_STATE] = WDS_BOUNCE; //Set this lweapon as checked, no need to set the direction again.
		}
		else if(Falcon->ID == LW_BRANG && Falcon->isValid() && Falcon->Misc[BRANG_STATE] == Falcon->DeadState)
		{
			BrangChange(Falcon); //Change tile again if Brang is now reflected and returning to Link.
			Falcon->Misc[BRANG_STATE] = -1; //Set to -1 to never use again.
		}
	}
}

void BrangChange(lweapon Falcon)
{
	if (Falcon->Dir == DIR_DOWN)
	{
		Falcon->OriginalTile = 21400;
		Falcon->Flip = 3;
	}
	else if (Falcon->Dir == DIR_LEFTUP || Falcon->Dir == DIR_LEFTDOWN || Falcon->Dir == DIR_LEFT)
	{
		Falcon->OriginalTile = 21400;
		Falcon->Flip = 2;
	}
	else //Changed to else as this is the last direction possible. Collapsed RIGHTUP, RIGHTDOWN, UP, and RIGHT.
	{
		Falcon->OriginalTile = 21408;
		Falcon->Flip = 0;
	}
}

Edited by cavthena, 25 May 2017 - 12:12 AM.

  • Binx likes this

#6 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 25 May 2017 - 12:45 AM

So, the functions go inside, before or after the while loop? Also, thanks, that really cleans things up.

Ok, so this is what I've tried, 

Fail Global combining

And I get: Line 28: Error T21 Could not match type signature BrangChange().


EDIT: Wait, I figured it out. didn't need that line in the global. Now it compiles.... And it's still bricking ZC.


Edited by Binx, 25 May 2017 - 12:46 AM.


#7 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 25 May 2017 - 05:55 AM

import "std.zh"
import "ffcscript.zh"
import "stdExtra.zh"
import "string.zh"

const int BRANG_STATE = 0; //Slot of lweapon->Misc[] to use.


global script slot_2
{
    void run()
    {

        int reqItem = 23; //Item that makes the FFC follower follow you
        int ffcNumber = 32; //The number of the FFC used. This script will "hijack" this one, so don't use it for anything else on screens when you expect the player to have a follower.
        int firstFollowerCombo = 65272; //combo of the first combo. In order, the concecutive combos must be "still up", "still down", "still left", "still right", "moving up", "moving down", "moving left", "moving right".
        int csetOfFollower = 8;
        bool firstCheck = false; //leave this alone
        ffc follower; //We will be using this on every screen.

        int pastX;
        int currentX;
        int followerX[13];

        int pastY;
        int currentY;
        int followerY[13];

        int index; //This is a VERY BAD variable name, as it is used as a short name in MANY functions.
        //I would use follower_index for this. -Z
        //Don't complain to me if you see a flood of 'variable already declared' errors because of this.

        
        //BrangFlip(); //This is doing nothing as it is outside the loop.  -Z

        while(true)
        { //begin main infinite loop
            
            
            BrangFlip(); //Call the boomerange flipping function every frame.
            
            //I am going to comment his wall of text. -Z
            
            //If Link has whatever gimmic he needs...
//            if(Link->Item[reqItem] == true)
//            {

                //if you mean this to be a one-time thing, then you need to set firstCheck false
                //INSIDE this scope.
//                if(Link->Action != LA_SCROLLING && firstCheck == false)
//                {
//                    follower = Screen->LoadFFC(ffcNumber);
//                    follower->Data = firstFollowerCombo;
//                    follower->CSet = csetOfFollower;
//
//                    pastX = Link->X;
//                    follower->X = Link->X;
//                    pastY = Link->Y;
//                    follower->Y = Link->Y;

//                    for ( int i = 0; i < 13; i++ )
//                    { //I don;t care if you put braces on a line, or on a following line,
//                        //but please choose one or the other, and not both willy-nilly. -Z
//                        followerX[i] = Link->X;
//                        followerY[i] = Link->Y;
//                    
//                    }
//                    firstCheck = true; //Don;t load an ffc every flipping frame.
//                }
//            }
            
            //We could resolve these two things together, as you are again checking for scorlling.
            
            //Simplify all the checks that you want to do using scrolling into one block.
            //These if-else blocks would be better as functions. -Z
            if(Link->Action != LA_SCROLLING)
            {
                //If Link has the required item and we have not set up the ffc on this screen...
                if ( firstCheck = false && Link->Item[reqItem] == true )
                {
                    follower = Screen->LoadFFC(ffcNumber);
                    follower->Data = firstFollowerCombo;
                    follower->CSet = csetOfFollower;

                    pastX = Link->X;
                    follower->X = Link->X;
                    pastY = Link->Y;
                    follower->Y = Link->Y;

                    for ( int i = 0; i < 13; i++ )
                    { //I don;t care if you put braces on a line, or on a following line,
                        //but please choose one or the other, and not both willy-nilly. -Z
                        followerX[i] = Link->X;
                        followerY[i] = Link->Y;
                    
                    }
                    firstCheck = true; //Don;t load an ffc every flipping frame.
                }
                    
                if((Link->InputUp || Link->InputDown || Link->InputRight || Link->InputLeft)&&(!(Link->InputA || Link->InputB)))
                {
                    //No idea what all of the calcs do. -Z
                    pastX = follower->X;
                    follower->X = followerX[0];
                    for(index=0; index<12; index++)
                    { //or why this is hardcoded to 12. Oh, it's an array size?- Z
                        //! The array is a size of 13, so if you are using all of its indices
                        //! then you need to do < 13, or <= 12 here. -Z
                        followerX[index] = followerX[index + 1];
                    }
                    followerX[12] = Link->X;

                    pastY = follower->Y;
                    follower->Y = followerY[0];
                    
                    for(index=0; index<12; index++)
                    {
                        followerY[index] = followerY[index + 1];
                    }
                    followerY[12] = Link->Y;
                }

                if(follower->Y > pastY)
                {
                    follower->Data = firstFollowerCombo + 5;
                }
                else if(follower->Y < pastY)
                {
                    follower->Data = firstFollowerCombo + 4;
                }
                
                //!
                //!! You probably want if, not else-if here: -Z
                else if(follower->X > pastX)
                {
                    follower->Data = firstFollowerCombo + 7;
                }
                else if(follower->X < pastX)
                {
                    follower->Data = firstFollowerCombo + 6;
                }
                
                //If Link is holding down a directional button. Note that you should check for Press, too. -Z
                
                
                if(!(Link->InputUp || Link->InputDown || Link->InputRight || Link->InputLeft))
                {
                    if((follower->Data == (firstFollowerCombo + 4))||(follower->Data == (firstFollowerCombo + 5))||(follower->Data == (firstFollowerCombo + 6))||(follower->Data == (firstFollowerCombo + 7)))
                    {
                        follower->Data = follower->Data - 4;
                    }
                    else if((follower->Data == (firstFollowerCombo + 3))||(follower->Data == (firstFollowerCombo + 2))||(follower->Data == (firstFollowerCombo + 1))||(follower->Data == (firstFollowerCombo)))
                    {
                        //Do nothing? -Z
                    }
                    else
                    {
                        follower->Data = firstFollowerCombo;
                    }
                } //end check for input when not scrolling.
            } //end checks while scrolling
            //You could just have 'else' after this.
            if(Link->Action == LA_SCROLLING)
            {
                firstCheck = false; //Refresh on change screen.
            }
            
            //! Waitframe needs to be *inside* the loop. This would be much easier to spot if you
            //! used tabs to indent the code.
            
            Waitframe();
        } //End main loop.
    } //end run()
} //end global script





void BrangFlip()
{
    for (int i = Screen->NumLWeapons(); i > 0; i--) //Counting down is safer. Do not count 0 as that will log an error and cause lag.
    {
        lweapon Falcon = Screen->LoadLWeapon(i); //I would also mention, that ++i is different to i++.
                            //I noticed that in your earlier script, and ++i increments before the return.
                            //and i++ increments after the return.

        //Added Valid check and only check if falcon is brang. continue instruction is not needed.
        if (Falcon->ID == LW_BRANG )  
        { //Short circuit on the item ID. ZScript in 2.50 does not automaticall short circuit, so
            //every iteration will check all three of these conditions even if ONE IS FALSE.
            //By checking against the ID first, you remove any non-boomerange lweapons
            //from extraneous checks.
            if ( Falcon->isValid() && Falcon->Misc[BRANG_STATE] == 0)
            {
                BrangChange(Falcon); //Change if-else block to a function for easier use.

                //Set the checked value to the weapon dead state of WDS_BOUNCE or 1. For later checks.
                Falcon->Misc[BRANG_STATE] = WDS_BOUNCE; //Set this lweapon as checked, no need to set the direction again.
            }
            else if( Falcon->isValid() && Falcon->Misc[BRANG_STATE] == Falcon->DeadState)
            {
                BrangChange(Falcon); //Change tile again if Brang is now reflected and returning to Link.
                Falcon->Misc[BRANG_STATE] = -1; //Set to -1 to never use again.
            }
        }
    }
}


const int FALCON_TILE_BASE     = 21400; //The base tile.
const int FALCON_TILE_ALT     = 21408;  //The alternate tile.
// Putting it here as a constant makes changing it much easier later, if needed. -Z
// ...as you can change it in your code in ONE PLACE.


void BrangChange(lweapon Falcon)
{
    if (Falcon->Dir == DIR_DOWN)
    {
        Falcon->OriginalTile = FALCON_TILE_BASE; //I STRONGLY ADVISE making these CONSTANTS.
        Falcon->Flip = 3;
    }
    else if (Falcon->Dir == DIR_UP)
    {
        Falcon->OriginalTile = FALCON_TILE_BASE;
        Falcon->Flip = 0;
    }
    else if (Falcon->Dir == DIR_LEFTUP || Falcon->Dir == DIR_LEFTDOWN || Falcon->Dir == DIR_LEFT)
    {
        Falcon->OriginalTile = FALCON_TILE_ALT;
        Falcon->Flip = 2;
    }
    else //Changed to else as this is the last direction possible. Collapsed RIGHTUP, RIGHTDOWN, and RIGHT.
    {
        Falcon->OriginalTile = FALCON_TILE_ALT;
        Falcon->Flip = 0;
    }
}

...because I like you.


Edited by ZoriaRPG, 25 May 2017 - 05:56 AM.

  • Binx likes this

#8 cavthena

cavthena

    Apprentice

  • Members
  • Real Name:Clayton
  • Location:I wish I knew

Posted 25 May 2017 - 07:59 AM

 

 

//Short circuit on the item ID. ZScript in 2.50 does not automaticall short circuit, so
            //every iteration will check all three of these conditions even if ONE IS FALSE.

 

Damn you ZScript...

Well it was to good to be true. I'll be back after changing a few hundred lines of code.



#9 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 25 May 2017 - 10:08 AM

...because I like you.


Awesome! It compiles now. But... it only changes directions if it hits something (otherwise the bird returns flying backwards), and it doesn't change directions properly. It vertical flips on the horizontal ones (so I get an upside down, backwards flying bird) and then changes the tile on the vertical (so it goes up facing up, comes down facing right) and also the left-facing .  And the other thing is that the bird is vertically flipped facing left instead of horizontally. Not sure why this would be, since I used the "flip" values based on this from the wiki, and just checked them, facing left should be a horizontal flip

int Flip

Whether and how the weapon's tiles should be flipped.

  • 0: No flip
  • 1: Vertical flip
  • 2: Horizontal flip
  • 3: Rotate 180 degrees
  • 4: Rotate clockwise 90 degrees
  • 7: Rotate counter-clockwise 90 degrees

 

 

These are the tiles I'm using, I dunno if that would help. But it's a bit hard to explain exactly what I'm trying to get at.

JidM6Es.png

 

The other issue I'm having with it is that it doesn't stop drawing the follower when the boomerang's onscreen, so instead of having a bird follower that goes and attacks enemies, I have a bird follower, AND a bird that goes and attacks enemies.


Edited by Binx, 25 May 2017 - 10:08 AM.


#10 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 25 May 2017 - 10:24 AM

Nah, boomerangs always use the same sprite, no flips, no rotation. Otherwise, there'd be no way I'd be trying to script this. Plus, I'm aiming to have the falcon's sprite reverse when it's returning to you. (So if you throw it left, it faces left, then when it gets to the end, faces right and returns)

 

Yes there is a way. It wouldnt reverse when coming back though, I'm not sure on that one.

 

7882802143dd4583ad83409107d86822.png

 

Just check directional sprites. Here's a guide for how to set them up: http://www.purezc.ne...e=tiles&id=1415


Edited by Avataro, 25 May 2017 - 10:25 AM.

  • strike likes this

#11 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 25 May 2017 - 10:32 AM

Yes there is a way. It wouldnt reverse when coming back though, I'm not sure on that one.

 

7882802143dd4583ad83409107d86822.png

 

Just check directional sprites. Here's a guide for how to set them up: http://www.purezc.ne...e=tiles&id=1415

Oh, hey, how did I miss that? That's one problem down. Well, if I can't get them to reverse direction mid-stream, I may have to scrap the idea, though. It just looks wrong. A TK skill isn't terrible, even if it's not as cool.



#12 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 25 May 2017 - 10:50 AM



Oh, hey, how did I miss that? That's one problem down. Well, if I can't get them to reverse direction mid-stream, I may have to scrap the idea, though. It just looks wrong. A TK skill isn't terrible, even if it's not as cool.

 

 

if ( l->DeadState == WDS_BOUNCE )  //Set a return tile.

 

Try that.

 

You should also know, that you can set other tile rotation and flip values.

 

Here are the values from std.zh ( try looking at std.zh for 2.54, to see all the new goodies).

 

Flip Values

 

I would probably need to examine the quest itself to determine what it is doing, or not doing and what it needs to do.

 

If you are just changing the o.tile, you can likely do this far more simply by setting:

falcon->OriginalTile = FALCON_TILE_BASE;
//Do not manually set flip for o.tile. 

If you arrange your falcon tiles precisely as boomerang tiles are arranged, then you should not need to set the flip values at all. You need those when you are setting l->Tile or l->UseSprite. You need these for weapons that do not have internal sprite rotation, or flipping. Of course, if yo want to avoid the spinning animation, then you want to set these properties, rather than o.tile.

 

Changing the flip and rotation in conjunction with OriginalTile is likely the culprit here.

 

Please read all of my notes. Your use of int index as a variable identifier is a potentially bad idea, although in this instance, it is not as bad as if it were a global variable, as it is scoped.

 

More important is that you have arrays with a size of 13, and you are checking indices 0 to 11 of each. (I am not sure if this is intentional.)

 

I would replace each instance of 'index' in those loops and array calls with ffc_follower_index, and I would verify that you never need to read index 12 in those loops. If you do, then change < 12 to to < 13.

 

You can also use decrement loops and SizeOfArray() as follows:

for ( int q = SizeOfArray(arr_id); q >= 0; q-- ) {
    arr_id[q] += foo;
}

This reads them backwards, mind. If you must read them forward, then it is faster (more efficient) to set a var to the array size.

 


 

Let me know if this makes sense to you.

 

Another Pro Tip: Get rid of all of those individual global vars, and make one array for them with some accessors. Your game is complex, and it is likely to need quite a lot of those in the end, and it is best to plan ahead.

 

Add this to your script file:

 

 

 

 

That is a generic global array and four basic accessors for it. You can make dedicated accessors for specific values too, which increases readability.

 



Damn you ZScript...

Well it was to good to be true. I'll be back after changing a few hundred lines of code.

 

This will likely be fixed for 2.54 and above. Gray has been working on it. My pro tip is to make a nest of if statements, using the most common denominator, or, in this case, you can just do if/else as:

for ( int q = Screen->NumLWeapons(); q > 0 q-- ) {
    lweapon l = Screen->LoadLWeapon(q);
   
    if ( !globalCondition ) { break; }
    if ( q->ID != weapon_type ) { continue; } //short circuit
    if ( q->Misc[n1] != n2 ) { continue; }
  
    //Otherwise it matches, so do things here.
}

That is an alternative to nested if statements. Otherwise, just follow the format that I used in the post.


Edited by ZoriaRPG, 25 May 2017 - 11:21 AM.


#13 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 28 May 2017 - 02:32 PM

if ( l->DeadState == WDS_BOUNCE )  //Set a return tile.
 
Try that.
 
You should also know, that you can set other tile rotation and flip values.
 
Here are the values from std.zh ( try looking at std.zh for 2.54, to see all the new goodies).
 
Flip Values

 

How is that any different than Falcon->Misc[BRANG_STATE] = WDS_BOUNCE; ? I could be wrong, but I think WDS_BOUNCE is only when it hits something (judging by how it's working in the script, currently)

I would probably need to examine the quest itself to determine what it is doing, or not doing and what it needs to do.

Uh... I guess I could set up a .zip, but the above sprites and script are the only changes to this quest (this isn't for Silver Dreams or OoT) I haven't even set up the directional sprites, yet

If you are just changing the o.tile, you can likely do this far more simply by setting:

falcon->OriginalTile = FALCON_TILE_BASE;
//Do not manually set flip for o.tile. 
If you arrange your falcon tiles precisely as boomerang tiles are arranged, then you should not need to set the flip values at all. You need those when you are setting l->Tile or l->UseSprite. You need these for weapons that do not have internal sprite rotation, or flipping. Of course, if yo want to avoid the spinning animation, then you want to set these properties, rather than o.tile.
 
Changing the flip and rotation in conjunction with OriginalTile is likely the culprit here.

 

I dunno, I mean, the initial animations are fine, including the flipped tiles, it's just not changing directions properly upon return
 

Please read all of my notes. Your use of int index as a variable identifier is a potentially bad idea, although in this instance, it is not as bad as if it were a global variable, as it is scoped.
 
More important is that you have arrays with a size of 13, and you are checking indices 0 to 11 of each. (I am not sure if this is intentional.)
 
I would replace each instance of 'index' in those loops and array calls with ffc_follower_index, and I would verify that you never need to read index 12 in those loops. If you do, then change < 12 to to < 13.
 
You can also use decrement loops and SizeOfArray() as follows:

for ( int q = SizeOfArray(arr_id); q >= 0; q-- ) {
    arr_id[q] += foo;
}
This reads them backwards, mind. If you must read them forward, then it is faster (more efficient) to set a var to the array size.
 

 
Let me know if this makes sense to you.
 
Another Pro Tip: Get rid of all of those individual global vars, and make one array for them with some accessors. Your game is complex, and it is likely to need quite a lot of those in the end, and it is best to plan ahead.
 
Add this to your script file:
 
 

 
 
That is a generic global array and four basic accessors for it. You can make dedicated accessors for specific values too, which increases readability.

 

This'll probably be great for the other 2 quests, this one's going to have very minimal scripting (This and a handful of item scripts). In all reality, I may not even use this, it's becoming so complicated.


Here's a zipped folder of the quest.


Edited by Binx, 28 May 2017 - 02:26 PM.



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users