Jump to content

Photo

ffcscript.zh


  • Please log in to reply
26 replies to this topic

#16 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 04 December 2012 - 06:41 PM

QUOTE
But even doing all that won't stop non-scripted FFC movement. To deal with that, you'd have to use the global script to prevent it, possibly by remembering each one's position and restoring it each frame.



Or you could place a combo/FFC with a "Freeze all movement" combo type.

Right?

#17 Saffith

Saffith

    IPv7 user

  • Members

Posted 04 December 2012 - 07:09 PM

Do you mean "Screen Freeze (FFCs Only)"? You can't do that, because it would also freeze the script you're trying to run.

#18 Saffith

Saffith

    IPv7 user

  • Members

Posted 01 May 2013 - 10:20 AM

Updated. Just two small changes:
- Invalid script numbers now fail correctly, so you can use Game->GetFFCScript() without validating the result
- The argument array no longer needs to be 8 elements

#19 Nightmeres

Nightmeres

    Defender

  • Members

Posted 13 July 2014 - 07:07 AM

cant seam to import this file do i need to compile it?



#20 Saffith

Saffith

    IPv7 user

  • Members

Posted 13 July 2014 - 08:58 AM

It should go in the ZC program directory, the same place as std.zh.

#21 Nightmeres

Nightmeres

    Defender

  • Members

Posted 13 July 2014 - 12:11 PM

thankyou, it works now :cheese:



#22 Saffith

Saffith

    IPv7 user

  • Members

Posted 19 August 2014 - 10:34 PM

Updated. It will now make sure not to grab changers.

#23 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Location:Rainbow Factory

Posted 20 August 2014 - 07:27 AM

I love you...



#24 ywkls

ywkls

    Master

  • Members

Posted 20 December 2016 - 02:43 PM

This is something that I noted was happening with one of my scripts whenever I used the functions RunFFCScript or RunFFCScriptOrQuit.

Whenever I used an item script to launch an ffc, if that ffc's script had settings to its TileHeight or TileWidth; there was a chance that the next item script to launch an ffc after the previous ffc no longer existed would retain those values.

The simplest solution that I found to fix this was to do the folllowing.

int RunFFCScript(int scriptNum, float args){
    // Invalid script
    if(scriptNum<0 || scriptNum>511)
        return 0;
    
    ffc theFFC;
    
    // Find an FFC not already in use
    for(int i=FFCS_MIN_FFC; i<=FFCS_MAX_FFC; i++){
        theFFC=Screen->LoadFFC(i);
        
        if(theFFC->Script!=0 ||
         (theFFC->Data!=0 && theFFC->Data!=FFCS_INVISIBLE_COMBO) ||
         theFFC->Flags[FFCF_CHANGER])
            continue;
        
        // Found an unused one; set it up
        theFFC->Data=FFCS_INVISIBLE_COMBO;
        //Reset the ffc's tile width and height to prevent carryover from earlier scripts.
	theFFC->TileWidth = 1;
	theFFC->TileHeight = 1;
        theFFC->Script=scriptNum;
        
        if(args!=NULL){
            for(int j=Min(SizeOfArray(args), 8)-1; j>=0; j--)
                theFFC->InitD[j]=args[j];
        }
        
        return i;
    }
    
    // No FFCs available
    return 0;
}

From what I can tell, making this change prevents the bug in question from happening.


Edited by ywkls, 20 December 2016 - 02:44 PM.


#25 Saffith

Saffith

    IPv7 user

  • Members

Posted 21 December 2016 - 01:55 PM

I don't know if I'd consider it a bug, exactly, but there shouldn't be any harm in resetting the FFC's data. I'll do that next update.
  • ywkls likes this

#26 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 20 January 2018 - 07:42 AM

There is another issue, and this one is also subtle.
 
The *Running() functions do not check to see if the ffc is in a state where it can run script code. It returns if a script is assigned, but that is all.
 
A basic hypothetical situation:
 
You have a global script that assigns ffc running conditions, halting them by setting their data = 0, and resuming them by setting their data = 1;
You want to use CountFFCsRunning() to determine how many instances of that script are running.
You have three ffcs with that script assigned, with data set to 1; and 4 with data set to 0.
The desired result of CountFFCsRunning(), would be 3, but, it returns 7.
 
I do not know if anything relies on those functions to return NumFFCsWithScript(int s), but, this is what I would do for these checks:
 
 

 

Edit: A better alternative, is probably an extra definition with a boolean argument, such as CountFFCsRunning(int script, bool only_active), as that would not break any scripts that depend on this quirk.



#27 Saffith

Saffith

    IPv7 user

  • Members

Posted 23 January 2018 - 01:34 PM

Eh, maybe. Thing is, Data==0 doesn't imply that the script isn't running. It won't start running, but it will continue once it's started. There's no way for another script to tell the difference.


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users