Jump to content

Photo

Combo Flag Script that Disables a Directional Input?


  • Please log in to reply
18 replies to this topic

#1 Anthus

Anthus

    Deified

  • Members
  • Location:Dark Ohio

Posted 30 September 2023 - 12:05 PM

Would it be possible to get a scripted combo flag that disables one of the four directional inputs? I'm not sure if this is a simple thing or not, but it would be used with conveyors. I'd need one for each of the four directions. I know you can force walk with conveyors to get a similar effect, but this doesn't allow for lateral movement if you have more than one conveyor of the same direction side by side. Simply disabling the input while on any given combo seems to be the easiest way to do what I'm trying to do. Thanks in advance!



#2 Bagu

Bagu

    Fandomizer

  • Members
  • Real Name:A.I. Bot Bottomheimer
  • Location:Germany

Posted 30 September 2023 - 12:11 PM

Would it be possible to get a scripted combo flag that disables one of the four directional inputs? I'm not sure if this is a simple thing or not, but it would be used with conveyors. I'd need one for each of the four directions. I know you can force walk with conveyors to get a similar effect, but this doesn't allow for lateral movement if you have more than one conveyor of the same direction side by side. Simply disabling the input while on any given combo seems to be the easiest way to do what I'm trying to do. Thanks in advance!

Would you like the script to disable the certain dir-input, when the player is on the flagged combo, or already when walking against it?



#3 Anthus

Anthus

    Deified

  • Members
  • Location:Dark Ohio

Posted 30 September 2023 - 12:18 PM

Would you like the script to disable the certain dir-input, when the player is on the flagged combo, or already when walking against it?

It would disable the input as long as the player is on, or passing over the flagged combo, preventing them from going "backwards". These flags would be used over conveyors.



#4 Bagu

Bagu

    Fandomizer

  • Members
  • Real Name:A.I. Bot Bottomheimer
  • Location:Germany

Posted 30 September 2023 - 01:04 PM

...untested, but I think it should work

I made it a function void for any script

...for example, used in global- & hero script (active)



 

//#include "std.zh"

const int CF_DIRUP_FALSE	= 116;// just placeholders for example
const int CF_DIRDOWN_FALSE	= 117;// you will certainly modify 'em
const int CF_DIRLEFT_FALSE	= 118;
const int CF_DIRRIGHT_FALSE	= 119;

void Disable_InputFlags(){
    if(Screen->ComboF[ComboAt(Hero->X+8, Hero->Y+8)] == CF_DIRUP_FALSE || ComboFI(Hero->X+8, Hero->Y+8, CF_DIRUP_FALSE)){
        if((Hero->Dir == DIR_UP && Hero->Z == 0) && (Hero->InputUp || Hero->PressUp)){Hero->InputUp = false; Hero->PressUp = false;}
    }
    if(Screen->ComboF[ComboAt(Hero->X+8, Hero->Y+8)] == CF_DIRDOWN_FALSE || ComboFI(Hero->X+8, Hero->Y+8, CF_DIRDOWN_FALSE)){
        if((Hero->Dir == DIR_DOWN && Hero->Z == 0) && (Hero->InputDown|| Hero->PressDown)){Hero->InputDown = false; Hero->PressDown = false;}
    }
    if(Screen->ComboF[ComboAt(Hero->X+8, Hero->Y+8)] == CF_DIRLEFT_FALSE || ComboFI(Hero->X+8, Hero->Y+8, CF_DIRLEFT_FALSE)){
        if((Hero->Dir == DIR_LEFT && Hero->Z == 0) && (Hero->InputLeft || Hero->PressLeft)){Hero->InputLeft = false; Hero->PressLeft = false;}
    }
    if(Screen->ComboF[ComboAt(Hero->X+8, Hero->Y+8)] == CF_DIRRIGHT_FALSE || ComboFI(Hero->X+8, Hero->Y+8, CF_DIRRIGHT_FALSE)){
        if((Hero->Dir == DIR_RIGHT && Hero->Z == 0) && (Hero->InputRight || Hero->PressRight)){Hero->InputRight = false; Hero->PressRight = false;}
    }
}


//example scripts


global script NoDir_global
{
    void run(){
	while(true){
	    Disable_InputFlags();
	    Waitdraw();
	    Waitframe();
	}
    }
}


hero script NoDir_hero
{
    void run(){
	while(true){
	    Disable_InputFlags();
	    Waitdraw();
	    Waitframe();
	}
    }
}

I just edited the posted script, because I missed to change one "Hero->Dir" in a copied line
...before, it was checking, wrong direction, in the last line of the void



...btw:

It also checks inherent flags...


Edited by Bagu, 30 September 2023 - 02:03 PM.

  • Anthus likes this

#5 Bagu

Bagu

    Fandomizer

  • Members
  • Real Name:A.I. Bot Bottomheimer
  • Location:Germany

Posted 30 September 2023 - 01:27 PM

I'm not sure if it would make more sense, to make it a combodata script (independend of flags)
...so you could just make some scripted copies of your conveyors



#6 Bagu

Bagu

    Fandomizer

  • Members
  • Real Name:A.I. Bot Bottomheimer
  • Location:Germany

Posted 30 September 2023 - 01:59 PM

I made it more flexible

...I wasn't sure if you want to the hero to be affected by the script, only when he's on the ground (Z = 0)
and facing the certain, disabled direction...
...or instantly, as long as on the flagged combo


So, I added the "Instant" bool
...assign "true" to istantly affect the Hero, or "false" if he should be on the ground and facing target direction


EDIT:

...btw, you can even  disable 2 directions (on corners of two crossing conveyors, fo example)
just combine flags & inherent flags.
 

#include "std.zh"//remove this, if already included


//**CONSTANT INITs

const int CF_DIRUP_FALSE	= 116;//Assign the ID#s of your chosen,
const int CF_DIRDOWN_FALSE	= 117;//input-disabling Flags.
const int CF_DIRLEFT_FALSE	= 118;
const int CF_DIRRIGHT_FALSE	= 119;




//**GLOBAL FUNCTION
//Put the line "Disable_InputFlags(true or false)" in the "while(true)"-loop of any kind of script....

void Disable_InputFlags(bool Instant){  //**false = only disables input if Hero->Z is = 0 and if the player is looking into the disabled direction)
					//          (it allows to Jump, against disabled Direction)
					//**true = instantly disables the certain input, as long, as on the flagged combo)
    if(!Instant){
        if(Screen->ComboF[ComboAt(Hero->X+8, Hero->Y+8)] == CF_DIRUP_FALSE || ComboFI(Hero->X+8, Hero->Y+8, CF_DIRUP_FALSE)){
            if((Hero->Dir == DIR_UP && Hero->Z == 0) && (Hero->InputUp || Hero->PressUp)){Hero->InputUp = false; Hero->PressUp = false;}
        }
        if(Screen->ComboF[ComboAt(Hero->X+8, Hero->Y+8)] == CF_DIRDOWN_FALSE || ComboFI(Hero->X+8, Hero->Y+8, CF_DIRDOWN_FALSE)){
            if((Hero->Dir == DIR_DOWN && Hero->Z == 0) && (Hero->InputDown || Hero->PressDown)){Hero->InputDown = false; Hero->PressDown = false;}
        }
        if(Screen->ComboF[ComboAt(Hero->X+8, Hero->Y+8)] == CF_DIRLEFT_FALSE || ComboFI(Hero->X+8, Hero->Y+8, CF_DIRLEFT_FALSE)){
            if((Hero->Dir == DIR_LEFT && Hero->Z == 0) && (Hero->InputLeft || Hero->PressLeft)){Hero->InputLeft = false; Hero->PressLeft = false;}
        }
        if(Screen->ComboF[ComboAt(Hero->X+8, Hero->Y+8)] == CF_DIRRIGHT_FALSE || ComboFI(Hero->X+8, Hero->Y+8, CF_DIRRIGHT_FALSE)){
            if((Hero->Dir == DIR_RIGHT && Hero->Z == 0) && (Hero->InputRight || Hero->PressRight)){Hero->InputRight = false; Hero->PressRight = false;}
	}
    }
    else if(Instant){
        if(Screen->ComboF[ComboAt(Hero->X+8, Hero->Y+8)] == CF_DIRUP_FALSE || ComboFI(Hero->X+8, Hero->Y+8, CF_DIRUP_FALSE)){
            if(Hero->InputUp || Hero->PressUp){Hero->InputUp = false; Hero->PressUp = false;}
        }
        if(Screen->ComboF[ComboAt(Hero->X+8, Hero->Y+8)] == CF_DIRDOWN_FALSE || ComboFI(Hero->X+8, Hero->Y+8, CF_DIRDOWN_FALSE)){
            if(Hero->InputDown || Hero->PressDown){Hero->InputDown = false; Hero->PressDown = false;}
        }
        if(Screen->ComboF[ComboAt(Hero->X+8, Hero->Y+8)] == CF_DIRLEFT_FALSE || ComboFI(Hero->X+8, Hero->Y+8, CF_DIRLEFT_FALSE)){
            if(Hero->InputLeft || Hero->PressLeft){Hero->InputLeft = false; Hero->PressLeft = false;}
        }
        if(Screen->ComboF[ComboAt(Hero->X+8, Hero->Y+8)] == CF_DIRRIGHT_FALSE || ComboFI(Hero->X+8, Hero->Y+8, CF_DIRRIGHT_FALSE)){
            if(Hero->InputRight || Hero->PressRight){Hero->InputRight = false; Hero->PressRight = false;}
        }
    }
}



//example scripts


global script NoDir_global
{
    void run(){
	while(true){
	    Disable_InputFlags(true);//"true", so affecting instantly
	    Waitdraw();              //assign "false" to make it depending on Hero->Dir & Hero->Z
	    Waitframe();
	}
    }
}


hero script NoDir_hero
{
    void run(){
	while(true){
	    Disable_InputFlags(true);//"true", so affecting instantly
	    Waitdraw();              //assign "false" to make it depending on Hero->Dir & Hero->Z
	    Waitframe();
	}
    }
}

Edited by Bagu, 01 October 2023 - 08:07 AM.

  • Anthus likes this

#7 Anthus

Anthus

    Deified

  • Members
  • Location:Dark Ohio

Posted 30 September 2023 - 03:05 PM

Thanks a ton for this, Bagu, I will test it soon, hopefully in the next 24 hours (I'm a little busy this weekend). I will let you know how it works.
  • Bagu likes this

#8 Bagu

Bagu

    Fandomizer

  • Members
  • Real Name:A.I. Bot Bottomheimer
  • Location:Germany

Posted 30 September 2023 - 03:17 PM

Thanks and no rush. :)



#9 Anthus

Anthus

    Deified

  • Members
  • Location:Dark Ohio

Posted 30 September 2023 - 04:03 PM

Just wanted to let you know, it does compile, so I think it will work. :)


  • Bagu likes this

#10 Bagu

Bagu

    Fandomizer

  • Members
  • Real Name:A.I. Bot Bottomheimer
  • Location:Germany

Posted 30 September 2023 - 04:13 PM

If it needs some advanced modification, just let me know.


  • Anthus likes this

#11 Anthus

Anthus

    Deified

  • Members
  • Location:Dark Ohio

Posted 02 October 2023 - 06:19 PM

So it turns out I have no idea what I'm doing lol. It compiles, but I'm not sure how to actually use it. I assumed the numbers at the top were for the flags (so I edited them to be 98-101) but placing those flags doesn't seem to have an effect. I'm probably missing something super obvious.

 

I'm not sure how to set a "hero script" and I can't seem to find the dialogue that lets you assign scripts to slots, but that might only be for FFC scripts (I am unsure)? Also how would I decide which bool to use? Would I just move the "!" to the one I don't want to use? (Sorry I am a complete novice with coding stuff, I've only used a few scripts before). Thanks again!

 

EDIT: This is what my script looks like:

Spoiler

 

I guess I should just ask, how do I actually use combo flag scripts correctly lol?



#12 Bagu

Bagu

    Fandomizer

  • Members
  • Real Name:A.I. Bot Bottomheimer
  • Location:Germany

Posted 02 October 2023 - 06:25 PM

...are you using the function in an active global- or hero script?
...or in any other type of script?



#13 Anthus

Anthus

    Deified

  • Members
  • Location:Dark Ohio

Posted 02 October 2023 - 06:26 PM

...are you using the function in an active global- or hero script?
...or in any other type of script?

Uhh. Neither, I think. I just changed the numbers at the top, compiled it, and placed a flag to test it. It's clear I missed a step here though. I would like to avoid using a global if possible though.


  • Bagu likes this

#14 Bagu

Bagu

    Fandomizer

  • Members
  • Real Name:A.I. Bot Bottomheimer
  • Location:Germany

Posted 02 October 2023 - 06:28 PM

Uhh. Neither, I think. I just changed the numbers at the top, compiled it, and placed a flag to test it. It's clear I missed a step here though. I would like to avoid using a global if possible though.

just put this in the "while(true)" loop, of your active hero script
 

Disable_InputFlags(true);

...it should work
...I tested it, meanwhile


EDIT :

Or simply assign the template hero script, to your hero script's active slot (if still vacant)


Edited by Bagu, 02 October 2023 - 08:13 PM.


#15 Bagu

Bagu

    Fandomizer

  • Members
  • Real Name:A.I. Bot Bottomheimer
  • Location:Germany

Posted 02 October 2023 - 07:11 PM

Heres another version, without any global voids, inits etc
...so if you wanna use this version, the former one will be obsolet and can be deleted.

This version is made as an ffc script, but since this isn't global you'd have to place an ffc which is using this script,
on all the screens with flagged conveyors.

 

ffc script InputSkip_Flags
{
    void run(int Instant){

        //** D[0] "Instant" 
        //Assign "0" to make it depend on Hero->Z and Hero->Dir 
        //if bigger than "0" it's affecting instantly, as long as on the flagged combo

	const int CF_DIRUP_FALSE	= 98;
	const int CF_DIRDOWN_FALSE	= 99;
	const int CF_DIRLEFT_FALSE	= 100;
	const int CF_DIRRIGHT_FALSE	= 101;
	
	while(true){
	    if(!Instant){
	        if(Screen->ComboF[ComboAt(Hero->X+8, Hero->Y+8)] == CF_DIRUP_FALSE || ComboFI(Hero->X+8, Hero->Y+8, CF_DIRUP_FALSE)){
	            if((Hero->Dir == DIR_UP && Hero->Z == 0) && (Hero->InputUp || Hero->PressUp)){Hero->InputUp = false; Hero->PressUp = false;}
	        }
	        if(Screen->ComboF[ComboAt(Hero->X+8, Hero->Y+8)] == CF_DIRDOWN_FALSE || ComboFI(Hero->X+8, Hero->Y+8, CF_DIRDOWN_FALSE)){
	            if((Hero->Dir == DIR_DOWN && Hero->Z == 0) && (Hero->InputDown || Hero->PressDown)){Hero->InputDown = false; Hero->PressDown = false;}
	        }
	        if(Screen->ComboF[ComboAt(Hero->X+8, Hero->Y+8)] == CF_DIRLEFT_FALSE || ComboFI(Hero->X+8, Hero->Y+8, CF_DIRLEFT_FALSE)){
	            if((Hero->Dir == DIR_LEFT && Hero->Z == 0) && (Hero->InputLeft || Hero->PressLeft)){Hero->InputLeft = false; Hero->PressLeft = false;}
	        }
	        if(Screen->ComboF[ComboAt(Hero->X+8, Hero->Y+8)] == CF_DIRRIGHT_FALSE || ComboFI(Hero->X+8, Hero->Y+8, CF_DIRRIGHT_FALSE)){
	            if((Hero->Dir == DIR_RIGHT && Hero->Z == 0) && (Hero->InputRight || Hero->PressRight)){Hero->InputRight = false; Hero->PressRight = false;}
		}
	    }
	    else if(Instant){
	        if(Screen->ComboF[ComboAt(Hero->X+8, Hero->Y+8)] == CF_DIRUP_FALSE || ComboFI(Hero->X+8, Hero->Y+8, CF_DIRUP_FALSE)){
	            if(Hero->InputUp || Hero->PressUp){Hero->InputUp = false; Hero->PressUp = false;}
	        }
	        if(Screen->ComboF[ComboAt(Hero->X+8, Hero->Y+8)] == CF_DIRDOWN_FALSE || ComboFI(Hero->X+8, Hero->Y+8, CF_DIRDOWN_FALSE)){
	            if(Hero->InputDown || Hero->PressDown){Hero->InputDown = false; Hero->PressDown = false;}
	        }
	        if(Screen->ComboF[ComboAt(Hero->X+8, Hero->Y+8)] == CF_DIRLEFT_FALSE || ComboFI(Hero->X+8, Hero->Y+8, CF_DIRLEFT_FALSE)){
	            if(Hero->InputLeft || Hero->PressLeft){Hero->InputLeft = false; Hero->PressLeft = false;}
	        }
	        if(Screen->ComboF[ComboAt(Hero->X+8, Hero->Y+8)] == CF_DIRRIGHT_FALSE || ComboFI(Hero->X+8, Hero->Y+8, CF_DIRRIGHT_FALSE)){
	            if(Hero->InputRight || Hero->PressRight){Hero->InputRight = false; Hero->PressRight = false;}
	        }
	    }
	    Waitframe();
	}
    }
}

The advantage of the ffc version, is that the flags are still available for any other purpose.
...as long as you don't use this script, on the same screen.


Edited by Bagu, 02 October 2023 - 07:17 PM.

  • Anthus likes this


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users