Jump to content

Photo

Next combo if combo on screen


  • Please log in to reply
70 replies to this topic

#16 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 12 March 2012 - 09:45 AM

QUOTE(tox_von @ Mar 12 2012, 12:03 AM) View Post

there might need to be a break statement there seem to be heaps of if statements.Possibly one isn't ending.

When i tried the example it didnt cylcle wrong and it worked about 10 times when i tried it.

I think its been fixed above.


Are you sure? The blue/white tile did change to the unwalkable combo after stepping on another step next?

#17 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 12 March 2012 - 10:34 AM

If statements don't 'end'. True or false, they run through their code and then it's over. I added breaks to the for() loops that check for the trigger (not the ones that change the combos), but aside from saving time that doesn't change anything.

#18 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 12 March 2012 - 11:14 AM

It still doesnt work right.
Shouldn't those if statements be in a loop? The trigger the script is looking for, is not on the screen, it appears through combo cycling.

Well, I don't understand much about scripting, so it may be that I'm totally wrong.

#19 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 12 March 2012 - 01:11 PM

Which script is giving you the problem? The "change if found", "change if not found", or "add layer combo"?

Oh, I just realized that the "change if not found" changes the combo if the trigger is found. Fixed and re-posted:
Scripts

Edited by MoscowModder, 12 March 2012 - 05:34 PM.


#20 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 12 March 2012 - 02:55 PM

icon_smile.gif I hope you didn't miss post#14. It's the "change if found" script that gives the problem. Thank you for fixing the second script btw!

#21 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 12 March 2012 - 04:10 PM

I think I found the problem. My script was only designed to change all target combos immediately after the trigger appears. Now it should continue to run indefinitely. See above ^^

#22 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 12 March 2012 - 04:27 PM

Now ZC crashes, when the trigger is on screen.

Edited by Avataro, 12 March 2012 - 04:31 PM.


#23 Saffith

Saffith

    IPv7 user

  • Members

Posted 12 March 2012 - 04:56 PM

When you say the game crashes, do you mean to say it hangs? "Crash" means it closes by itself, and "hang" means it freezes. One is caused by bugs in the game and the other is a script problem, so it's an important distinction.

Anyway, looks like there's a Waitframe missing. I'll go ahead and add that in:
Scripts


#24 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 12 March 2012 - 05:26 PM

Yes I meant to say, that it freezes. I'll try to remember from now on..

Ok, now this script is almost working.
I just want the bool triggerFound to turn false if the trigger disappears from the screen. Only the first script needs this. The other two scripts work perfectly!

#25 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 12 March 2012 - 05:36 PM

Give this a shot:
CODE
ffc script changeCombosIfFound2Way{
    void run ( int triggercombo, int targetcombo ){
        bool triggerFound = false;
        while(!triggerFound){
            for(int i=0; i<175; i++){
                if(Screen->ComboD[i]==triggercombo){
                    for(int i=0; i<175; i++)
                        if(Screen->ComboD[i]==targetcombo) Screen->ComboD[i]++;
                }
                else{
                    for(int i=0; i<175; i++)
                        if(Screen->ComboD[i]==targetcombo+1) Screen->ComboD[i]--;
                }
            }
            Waitframe();
        }
    }
}


#26 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 12 March 2012 - 05:45 PM

This script slows down my ZC to 12 Frames per second.

#27 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 12 March 2012 - 06:07 PM

Hmm... let's see about making it more efficient. Now if nothing changes, it only checks each combo per screen once.

CODE
ffc script changeCombosIfFound2Way{
    void run ( int triggercombo, int targetcombo ){
        bool triggerActive = false;
        bool combosChanged = false;
        while(!triggerFound){
            for(int i=0; i<175; i++){
                if(Screen->ComboD[i]==triggercombo){
                    triggerActive = true;
                }
                else{
                    triggerActive = false;
                }
                if(triggerActive==true && combosChanged==false){
                    for(int i=0; i<175; i++)
                        if(Screen->ComboD[i]==targetcombo) Screen->ComboD[i]++;
                    combosChanged = true;
                }
                if(triggerActive==false && combosChanged==true){
                    for(int i=0; i<175; i++)
                        if(Screen->ComboD[i]==targetcombo+1) Screen->ComboD[i]--;
                    combosChanged = false;
                }
            }
            Waitframe();
        }
    }
}


#28 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 12 March 2012 - 06:18 PM

Now it does not slow down ZC anymore, but it still does not work. The trigger combo appeared on the screen, but the target combo did not change.

#29 tox_von

tox_von

    Zelda Addict

  • Members
  • Real Name:Redgor
  • Location:Toxicville , Simcity

Posted 12 March 2012 - 07:08 PM

probably break again if the variabl;es change the loops dont seem to notice and need to reset.

#30 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 12 March 2012 - 07:15 PM

Huzzah! Fix'd it. It had nothing to do with breaks, though - it set the "triggeractive" variable to false for every combo that wasn't the trigger; now it sets it to false at the end of the while(true) loop. If it still doesn't work, I would blame the SFX script interfering with it, in which case I could (try to) combine the two scripts.

CODE
ffc script changeCombosIfFound2Way{
    void run ( int triggercombo, int targetcombo ){
        bool triggerActive = false;
        bool combosChanged = false;
        while(true){
            for(int i=0; i<175; i++){
                //Check for the trigger combo
                if(Screen->ComboD[i]==triggercombo) triggerActive = true;
            }
                //If trigger is ON and target is NOT changed, change it
                if(triggerActive==true && combosChanged==false){
                    for(int i=0; i<175; i++)
                        if(Screen->ComboD[i]==targetcombo) Screen->ComboD[i]++;
                    combosChanged = true;
                }
                //If trigger is OFF and target IS changed, change it back
                if(triggerActive==false && combosChanged==true){
                    for(int i=0; i<175; i++)
                        if(Screen->ComboD[i]==targetcombo+1) Screen->ComboD[i]--;
                    combosChanged = false;
                }
            triggerActive = false;
            Waitframe();
        }
    }
}



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users