I was diagonal movement with this script right now, as it happens. This script should prevent glitching through the barriers:
Both of those above issues, I had fixed about 20 minutes ago, and then I noticed the diagonal movement issue, and I knew I had to resolve it.
Try this out...
//D0: The combo ID of the combo that you want to use for this.
//D1: A timer, to ensure that messages don't repeat too quickly. I'd advice 60 or 80 for this.
//D2: The layer that you placed the combo onto.
//D3: The ZString that you want to display.
//D4: A sound effect ID that you wish to play, if any.
ffc script NotThisWayCombo{
void run(int comboID , int delay, int layer, int msg, int sfx){
int adj[10]; //x = 0, y = 1; dir = 2, timer = 3, 5 = loc
//int lastcombo = -1; int timer; int dir;
while(true){
//! this could be good for solid damage combos
if ( adj[3] ) adj[3]--;
if ( adj[3] <= 0 ) adj[3] = 0;
if ( Link->Dir == DIR_LEFT ) { adj[0] = 2; adj[1] = 8;}
if ( Link->Dir == DIR_RIGHT ) { adj[0] = 7; adj[1] = 8;}
if ( Link->Dir == DIR_DOWN ) { adj[1] = 14; adj[0] = 8; }
if ( Link->Dir == DIR_UP ) { adj[1] = 6; adj[0] = 8; }
adj[2] = Link->Dir;
if ( ( GetLayerComboD(layer, ComboAt(Link->X+8, Link->Y+8)) == comboID ) || ( GetLayerComboD(layer, ComboAt(Link->X+adj[0], Link->Y+adj[1]) ) == comboID ) && !adj[3] ) { //&& ComboAt(Link->X+8, Link->Y+8) != lastcombo ){
adj[3] = delay;
adj[4] = ComboAt(Link->X+8, Link->Y+8);
//lastcombo = ComboAt(Link->X+8, Link->Y+8);
Screen->Message(msg);
if ( sfx ) Game->PlaySound(sfx);
for ( int q = 0; q < 32; q++ ) {
//he's on the left edge of the screen
if ( adj[2] == DIR_UP && q%4 == 0 ) {
if ( ComboAt(Link->X, Link->Y-2) > 0x9F ) break;
if ( CanWalk(Link->X, Link->Y, DIR_DOWN,1, false)
&& GetLayerComboD(layer, ComboAt(Link->X, Link->Y+16) )!= comboID
&& GetLayerComboD(layer, ComboAt(Link->X+4, Link->Y+16) )!= comboID
&& GetLayerComboD(layer, ComboAt(Link->X+8, Link->Y+16) )!= comboID
&& GetLayerComboD(layer, ComboAt(Link->X+12, Link->Y+16) )!= comboID
&& GetLayerComboD(layer, ComboAt(Link->X+15, Link->Y+16) )!= comboID
) Link->Y += 1;
if ( GridY(Link->Y) == Link->Y ) break;
}
if ( adj[2] == DIR_DOWN && q%4 == 0 ) {
if ( ComboAt(Link->X, Link->Y+18) < 0x10 ) break;
if ( CanWalk(Link->X, Link->Y, DIR_UP,1, false)
&& GetLayerComboD(layer, ComboAt(Link->X, Link->Y-1) )!= comboID
&& GetLayerComboD(layer, ComboAt(Link->X+4, Link->Y-1) )!= comboID
&& GetLayerComboD(layer, ComboAt(Link->X+8, Link->Y-1) )!= comboID
&& GetLayerComboD(layer, ComboAt(Link->X+12, Link->Y-1) )!= comboID
&& GetLayerComboD(layer, ComboAt(Link->X+15, Link->Y-1) )!= comboID
) Link->Y -= 1;
if ( GridY(Link->Y) == Link->Y ) break;
}
if ( adj[2] == DIR_RIGHT && q%4 == 0 ) {
if ( ComboAt(Link->X, Link->Y) % 16 == 0 ) break;
if ( CanWalk(Link->X, Link->Y, DIR_LEFT,1, false)
&& GetLayerComboD(layer, ComboAt(Link->X-1, Link->Y) ) != comboID
&& GetLayerComboD(layer, ComboAt(Link->X-1, Link->Y+4) )!= comboID
&& GetLayerComboD(layer, ComboAt(Link->X-1, Link->Y+8) )!= comboID
&& GetLayerComboD(layer, ComboAt(Link->X-1, Link->Y+12) )!= comboID
&& GetLayerComboD(layer, ComboAt(Link->X-1, Link->Y+15) )!= comboID
) Link->X -= 1;
if ( GridX(Link->X-2) == Link->X ) break;
}
if ( adj[2] == DIR_LEFT && q%4 == 0 ) {
if ( (ComboAt(Link->X+18, Link->Y) & 15) == 1 ) break;
if ( CanWalk(Link->X, Link->Y, DIR_RIGHT,1 ,false)
&& GetLayerComboD(layer, ComboAt(Link->X+16, Link->Y) ) != comboID
&& GetLayerComboD(layer, ComboAt(Link->X+16, Link->Y+4)) != comboID
&& GetLayerComboD(layer, ComboAt(Link->X+16, Link->Y+8) )!= comboID
&& GetLayerComboD(layer, ComboAt(Link->X+16, Link->Y+12) )!= comboID
&& GetLayerComboD(layer, ComboAt(Link->X+16, Link->Y+15) )!= comboID
) Link->X += 1;
if ( GridX(Link->X) == Link->X ) break;
}
WaitNoAction();
}
}
Waitframe();
}
}
}
Plus a
test quest that will demonstrate the set-up.
This might be an interesting way to handle solid damage combos, too. Just force Link->HitDir to -1, and get rid of the message.
If Link enters at an odd angle, the script won't move him, but the player gains control. That isn't an ideal solution, but as a temporary work-around, it gives you something to work with.
I have an idea for how to determine the point of entry for diagonal movement, and such, too.
Edited by ZoriaRPG, 08 December 2016 - 03:16 PM.