Jump to content

Photo

Next combo if combo on screen


  • Please log in to reply
70 replies to this topic

#61 tox_von

tox_von

    Zelda Addict

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

Posted 02 April 2012 - 04:15 PM

think i fixed it.

CODE
import "std.zh"

ffc script changeCombosIfFound2Way{
    void run ( int trigger1, int trigger2, int target1, int target2 ){
        bool triggerActive = false;
        bool combosChanged = false;
        while(true){
            triggerActive = (FirstComboOf(trigger1, 0) != -1 || FirstComboOf(trigger2, 0) != -1);
            //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]==target1)
                      {Screen->ComboD[i]++;
                        combosChanged = true;
                       }
                    else if(Screen->ComboD[i]==target2) 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]==target1+1 || Screen->ComboD[i]==target2+1)
                     {Screen->ComboD[i]--;
                        combosChanged = false;
                    }
            }
            Waitframe();
        }
    }
}


#62 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 02 April 2012 - 04:58 PM

You almost got it, but you missed one error. I forgot to add brackets for the if() statements that now have more than one line of code in them.

CODE
ffc script changeCombosIfFound2Way{
    void run ( int trigger1, int trigger2, int target1, int target2 ){
        bool triggerActive = false;
        bool combosChanged = false;
        while(true){
            triggerActive = (FirstComboOf(trigger1, 0) != -1 || FirstComboOf(trigger2, 0) != -1)
            //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]==target1){
                        Screen->ComboD[i]++;
                        combosChanged = true;
                    }
                    else if(Screen->ComboD[i]==target2){
                        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]==target1+1){
                        Screen->ComboD[i]--;
                        CombosChanged = false;
                    }
                    if(Screen->ComboD[i]==target2+1){
                        Screen->ComboD[i]--;
                        combosChanged = false;
                    }
                }
            }
            Waitframe();
        }
    }
}

Edited by MoscowModder, 02 April 2012 - 04:59 PM.


#63 tox_von

tox_von

    Zelda Addict

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

Posted 02 April 2012 - 06:10 PM

yeah it did say something about i not defined when there was more than one line but i hadnt used for loops much before.

#64 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 07 April 2012 - 05:00 PM

The last thing I need is a modification of the first script: ChangeComboIfFound.
It should not change the target combos on layer 0, but the target combos on layer 1.
ChangeCombosIfFound script


The trigger is still on layer 0.

Edited by Avataro, 07 April 2012 - 05:10 PM.


#65 tox_von

tox_von

    Zelda Addict

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

Posted 07 April 2012 - 05:24 PM

you can do that like this yourself if you need to.

CODE
import "std.zh"

/// 1st is layer 2nd is position 3rd is combo.

ffc script new_script
{
    void run()
    {
        SetLayerComboD(6,12,33);  
        SetLayerComboD(5,5,34);          
    }
}


#66 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 07 April 2012 - 05:25 PM

Done.

CODE
ffc script changeCombosIfFound{
    void run ( int triggercombo, int targetcombo, int targetLayer ){
        bool triggerFound = false;
        while(true){
            triggerFound = false;
            for(int i=0; i<175; i++){
                if(Screen->ComboD[i]==triggercombo){
                    triggerFound = true;
                }
            }
            if ( triggerFound ){
                for(int j=0; j<175; j++){
                    if(GetLayerComboD(targetLayer, i) == targetcombo){
                        SetLayerComboD(targetLayer, i, targetcombo+1);
                    }
                }
            }
            Waitframe();
        }
    }
}


#67 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 18 April 2012 - 11:23 AM

Thank you :-D
After those scripts change the combo, they end (stop working). What to add in the scriptfile to make the scripts work endless? I'm talking about the change combo if (not) found scripts.

Edited by Avataro, 18 April 2012 - 11:23 AM.


#68 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 18 April 2012 - 01:16 PM

I have so many different versions of those scripts... can you post the code of the ones that need changing?

P.S. Did you see/try my complete Hamiltonian Path script with expanded secret options?

#69 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 18 April 2012 - 02:05 PM

Alright, it's these two scripts that need it. I have made some little modifications myself:
Scripts

I'll try the hamilition path scripts at the weekend, if thats okay for yuo icon_biggrin.gif

#70 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 18 April 2012 - 02:56 PM

It's a pretty simple change: change while(whatever) to while(true).

I also changed your SFX number from a hard-coded value to an argument for re-use. If you don't like that, you can change it back.
CODE
ffc script changeCombosIfNotFoundSfx{
    void run ( int triggercombo, int targetcombo, int sfx ){
        bool triggerFound = true; //Must be true to run the loop
        while ( true ) //Now loops forever
        {
            triggerFound = false; //Reset the flag each frame
            for(int i=0; i<175; i++){ //Check each combo
                if(Screen->ComboD[i]==triggercombo){ //If the trigger is found
                    triggerFound = true; //set the flag to keep going
                }
            }
            Waitframe();
        } //Once trigger is not found, exit loop
        for(int i=0; i<175; i++){ //For each combo
            if(Screen->ComboD[i]==targetcombo){
            Screen->ComboD[i]++; //If it is the target combo, change it
            Game->PlaySound(sfx);
        }
        //All done; exit script
    }
}

ffc script changeCombosBackIfFoundSfx{
    void run ( int triggercombo, int targetcombo, int sfx ){
        bool triggerFound = false;
        while(true){ //Should already work forever
            triggerFound = false;
            for(int i=0; i<175; i++){
                if(Screen->ComboD[i]==triggercombo){
                    triggerFound = true;
                }
            }
            if ( triggerFound ){
                for(int j=0; j<175; j++){
                    if(Screen->ComboD[j]==targetcombo){
                        Screen->ComboD[j]--; //change combo back
                        Game->PlaySound(sfx);
                    }
                }
            }
            Waitframe();
        }
    }
}


#71 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 18 April 2012 - 03:10 PM

Thank you for this. Hope it works icon_smile.gif


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users