Jump to content

Photo

Arrow Deflector?


  • Please log in to reply
3 replies to this topic

#1 Architect Abdiel

Architect Abdiel

    Kingdom Builder

  • Members
  • Real Name:Michael
  • Location:Florida

Posted 14 May 2017 - 01:35 PM

So, at the moment, I have my arrow set as a wand item so that it can bounce off magic mirror type combos.

However, I was wondering on the likelihood of setting up an arrow deflector, like from the DS games. What would it do? Here's what I was thinking.


Firstly, I figured that the constants would be.

ArrowDeflectorUp
ArrowDeflectorRight
ArrowDeflectorLeft
ArrowDeflectorDown


These would refer to the combo used for the arrow deflector. And based on the direction, the arrow would deflect in that direction.


I'm sure that much is possible, but how about this as well...?

If Link slashes the deflector with his sword, it would move 90 degrees to the right. So ArrowDeflectorUp would become ArrowDeflectorRight, and so on. Maybe even a step further and have it be able to point in 8 directions?

Where ArrowDeflectorUp would instead become ArrowDeflectorUpRight? Though I'm not sure if that would be possible to set up since I don't know if arrows have a diagonal sprite.

Edited by Maikeru D. Shinigami, 14 May 2017 - 01:37 PM.


#2 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 15 May 2017 - 09:19 PM

So, at the moment, I have my arrow set as a wand item so that it can bounce off magic mirror type combos.

However, I was wondering on the likelihood of setting up an arrow deflector, like from the DS games. What would it do? Here's what I was thinking.


Firstly, I figured that the constants would be.

ArrowDeflectorUp
ArrowDeflectorRight
ArrowDeflectorLeft
ArrowDeflectorDown


These would refer to the combo used for the arrow deflector. And based on the direction, the arrow would deflect in that direction.

I'm sure that much is possible, but how about this as well...?

If Link slashes the deflector with his sword, it would move 90 degrees to the right. So ArrowDeflectorUp would become ArrowDeflectorRight, and so on. Maybe even a step further and have it be able to point in 8 directions?

Where ArrowDeflectorUp would instead become ArrowDeflectorUpRight? Though I'm not sure if that would be possible to set up since I don't know if arrows have a diagonal sprite.


Hmm. I made this in the past, and quite recently, too. Someone had requested a custom prism script, and it is in a thread here somewhere, but it may be tedious to find that way, so I'll see what file it is, and post it for you.


This was the previous ffc:

 
import "std.zh"

//////////////////////////////
/// Reflect Weapons by FFC ///
/// By: ZoriaRPG           ///
/// v1.0                   ///
/// 28th July, 2016        ///
////////////////////////////////////////////////////////////////////////////////////////////////////
/// FFC Data Args:                                                                               ///
/// D0: Set to '1' or above, to cause reflected weapons to turn into their opposite:             ///
///     eweapons become lweapons, and lweapons become eweapons, similar to the standard mirrors. ///
////////////////////////////////////////////////////////////////////////////////////////////////////



const int REFLECT_SENSITIVITY = 12;
const int MISC_STATUS = 5;
const int WEAP_STATUS_REFL = 101;             

ffc script ReflectMagic{
    void run(int changetype){
        eweapon e; lweapon l; int q; int w;
        while(true){
            for ( w = 1; w <= Screen->NumLWeapons(); w++ ) {
                l = Screen->LoadLWeapon(w);
                if ( ( l->ID == LW_MAGIC || l->ID == LW_ARROW || l->ID == LW_BEAM  ) && l->Misc[MISC_STATUS] != WEAP_STATUS_REFL ) {
                    if ( __DistXY(this,l,REFLECT_SENSITIVITY) ) {
                        if ( !changetype ) {
                            l->Dir = __DirRev(l->Dir);
                            l->Flip = __FlipRef(l);
                            l->Misc[MISC_STATUS] = WEAP_STATUS_REFL;
                        }
                        if ( changetype ) {
                            if ( __LWeaponToEWeaponID(l->ID) >= 0 ) {
                                l->Dir = __DirRev(l->Dir);
                                l->Flip = __FlipRef(l);
                                eweapon b = __LWeaponToEWeapon(l);
                                l->Misc[MISC_STATUS] = WEAP_STATUS_REFL;
                                b->Misc[MISC_STATUS] = WEAP_STATUS_REFL;
                                Remove(l);
                            }
                        }
                    }
                }
            }
            for ( q = 1; q <= Screen->NumEWeapons(); q++ ) {
                e = Screen->LoadEWeapon(q);
                if ( ( e->ID == EW_MAGIC || e->ID == EW_ARROW || e->ID == EW_BEAM || e->ID == EW_WIND || e->ID == EW_FIREBALL || e->ID == EW_ROCK ) && e->Misc[MISC_STATUS] != WEAP_STATUS_REFL ) {
                    if ( __DistXY(this,e,REFLECT_SENSITIVITY) ) {
                        if ( !changetype ) {
                            e->Misc[MISC_STATUS] = WEAP_STATUS_REFL;
                            e->Dir = __DirRev(e->Dir);
                            e->Flip = __FlipRef(e);
                        }
                        if ( changetype ) {
                            if ( __EWeaponToLWeaponID(e->ID) >= 0 ) {
                                e->Dir = __DirRev(e->Dir);
                                e->Flip = __FlipRef(e);
                                lweapon c = __EWeaponToLWeapon(e);
                                c->Misc[MISC_STATUS] = WEAP_STATUS_REFL;
                                Remove(e);
                            }
                        }
                    }
                }
            }
                
            Waitframe();
        }
    }
    
    int __FlipRef(lweapon l){
        if ( l->Dir == DIR_DOWN || l->Dir == DIR_UP && !l->Flip ) return 2;
        if ( l->Dir == DIR_DOWN || l->Dir == DIR_UP && l->Flip ) return 0;
        if ( l->Dir == DIR_LEFT || l->Dir == DIR_RIGHT && !l->Flip ) return 1;
        if ( l->Dir == DIR_LEFT || l->Dir == DIR_RIGHT && l->Flip ) return 0;
        return -1;
    }

    int __FlipRef(eweapon l){
        if ( l->Dir == DIR_DOWN || l->Dir == DIR_UP && !l->Flip ) return 2;
        if ( l->Dir == DIR_DOWN || l->Dir == DIR_UP && l->Flip ) return 0;
        if ( l->Dir == DIR_LEFT || l->Dir == DIR_RIGHT && !l->Flip ) return 1;
        if ( l->Dir == DIR_LEFT || l->Dir == DIR_RIGHT && l->Flip ) return 0;
        return -1;
    }
    
    int __DirRev(int dir) {
        if ( dir == DIR_LEFT) return DIR_RIGHT;
        if ( dir == DIR_DOWN) return DIR_UP;
        if ( dir == DIR_UP) return DIR_DOWN;
        if ( dir == DIR_RIGHT) return DIR_LEFT;
        if ( dir == DIR_LEFTUP) return DIR_RIGHTDOWN;
        if ( dir == DIR_RIGHTDOWN) return DIR_LEFTUP;
        if ( dir == DIR_LEFTDOWN) return DIR_RIGHTUP;
        if ( dir == DIR_RIGHTUP) return DIR_LEFTDOWN;
    }
    
    bool __DistX(ffc a, lweapon b, int distance) {
        int dist;
        if ( a->X > b->X ) dist = a->X - b->X;
        else dist = b->X - a->X;
        return ( dist <= distance );
    }
    bool __DistX(ffc a, eweapon b, int distance) {
        int dist;
        if ( a->X > b->X ) dist = a->X - b->X;
        else dist = b->X - a->X;
        return ( dist <= distance );
    }
    
    bool __DistY(ffc a, lweapon b, int distance) {
        int dist;
        if ( a->Y > b->Y ) dist = a->Y - b->Y;
        else dist = b->Y - a->Y;
        return ( dist <= distance );
    }
    bool __DistY(ffc a, eweapon b, int distance) {
        int dist;
        if ( a->Y > b->Y ) dist = a->Y - b->Y;
        else dist = b->Y - a->Y;
        return ( dist <= distance );
    }
    bool __DistXY(ffc a, lweapon b, int distance) {
        int distx; int disty;
        if ( a->X > b->X ) distx = a->X - b->X;
        else distx = b->X - a->X;
    
        if ( a->Y > b->Y ) disty = a->Y - b->Y;
        else disty = b->Y - a->Y;

        return ( distx <= distance && disty <= distance );
    }

    bool __DistXY(ffc a, eweapon b, int distance) {
        int distx; int disty;
        if ( a->X > b->X ) distx = a->X - b->X;
        else distx = b->X - a->X;
    
        if ( a->Y > b->Y ) disty = a->Y - b->Y;
        else disty = b->Y - a->Y;

        return ( distx <= distance && disty <= distance );
    }
    lweapon __EWeaponToLWeapon(eweapon a){
        int type = EWeaponToLWeaponID(a->ID);
        //if ( type == -1 ) return type;
        lweapon b = Screen->CreateLWeapon(type);
        b->X = a->X;
        b->Y = a->Y;
        b->Z = a->Z;
        b->Jump = a->Jump;
        b->Extend = a->Extend;
        b->TileWidth = a->TileWidth;
        b->TileHeight = a->TileHeight;
        b->HitWidth = a->HitWidth;
        b->HitHeight = a->HitHeight;
        b->HitZHeight = a->HitZHeight;
        b->HitXOffset = a->HitXOffset;
        b->HitYOffset = a->HitYOffset;
        b->DrawXOffset = a->DrawXOffset;
        b->DrawYOffset = a->DrawYOffset;
        b->DrawZOffset = a->DrawZOffset;
        b->Tile = a->Tile;
        b->CSet = a->CSet;
        b->DrawStyle = a->DrawStyle;
        b->Dir = a->Dir;
        b->OriginalTile = a->OriginalTile;
        b->OriginalCSet = a->OriginalCSet;
        b->FlashCSet = a->FlashCSet;
        b->NumFrames = a->NumFrames;
        b->Frame = a->Frame;
        b->ASpeed = a->ASpeed;
        b->Damage = a->Damage;
        b->Step = a->Step;
        b->Angle = a->Angle;
        b->Angular = a->Angular;
        b->CollDetection = a->CollDetection;
        b->DeadState = a->DeadState;
        b->Flash = a->Flash;
        b->Flip = a->Flip;
        for (int i = 0; i < 16; i++)
            b->Misc[i] = a->Misc[i];
        return b;
    }



    //Copy the attributes of a given lweapon to a new eweapon.
    //Returns -1 on error, including if the type (weap->ID) conversion is illegal.
    eweapon __LWeaponToEWeapon(lweapon a){
        int type = LWeaponToEWeaponID(a->ID);
    //    if ( type == -1 ) return type;
        eweapon b = Screen->CreateEWeapon(type);
        b->X = a->X;
        b->Y = a->Y;
        b->Z = a->Z;
        b->Jump = a->Jump;
        b->Extend = a->Extend;
        b->TileWidth = a->TileWidth;
        b->TileHeight = a->TileHeight;
        b->HitWidth = a->HitWidth;
        b->HitHeight = a->HitHeight;
        b->HitZHeight = a->HitZHeight;
        b->HitXOffset = a->HitXOffset;
        b->HitYOffset = a->HitYOffset;
        b->DrawXOffset = a->DrawXOffset;
        b->DrawYOffset = a->DrawYOffset;
        b->DrawZOffset = a->DrawZOffset;
        b->Tile = a->Tile;
        b->CSet = a->CSet;
        b->DrawStyle = a->DrawStyle;
        b->Dir = a->Dir;
        b->OriginalTile = a->OriginalTile;
        b->OriginalCSet = a->OriginalCSet;
        b->FlashCSet = a->FlashCSet;
        b->NumFrames = a->NumFrames;
        b->Frame = a->Frame;
        b->ASpeed = a->ASpeed;
        b->Damage = a->Damage;
        b->Step = a->Step;
        b->Angle = a->Angle;
        b->Angular = a->Angular;
        b->CollDetection = a->CollDetection;
        b->DeadState = a->DeadState;
        b->Flash = a->Flash;
        b->Flip = a->Flip;
        for (int i = 0; i < 16; i++)
            b->Misc[i] = a->Misc[i];
        return b;
    }
    
    //Converts the ID (type) of a given weapon to its opposite class.
    //Returns -1 if the type is illegal.
    int __EWeaponToLWeaponID(int type){
        if ( type == EW_ARROW ) return LW_ARROW;
        if ( type == EW_BRANG ) return LW_BRANG;
        if ( type == EW_BEAM ) return LW_BEAM;
        if ( type == EW_MAGIC ) return LW_MAGIC;
        if ( type == EW_BOMB ) return LW_BOMB;
        if ( type == EW_BOMBBLAST ) return LW_BOMBBLAST;
        if ( type == EW_SBOMB ) return LW_SBOMB;
        if ( type == EW_SBOMBBLAST ) return LW_SBOMBBLAST;
        if ( type == EW_WIND ) return LW_WIND;
        if ( type >= 31 && type <= 40 ) return type;
        else return -1;
    }

    //Converts the ID (type) of a given weapon to its opposite class.
    //Returns -1 if the type is illegal.
    int __LWeaponToEWeaponID(int type){
        if ( type == LW_ARROW ) return EW_ARROW;
        if ( type == LW_BRANG ) return EW_BRANG;
        if ( type == LW_BEAM ) return EW_BEAM;
        if ( type == LW_MAGIC ) return EW_MAGIC;
        if ( type == LW_BOMB ) return EW_BOMB;
        if ( type == LW_BOMBBLAST ) return EW_BOMBBLAST;
        if ( type == LW_SBOMB ) return EW_SBOMB;
        if ( type == LW_SBOMBBLAST ) return EW_SBOMBBLAST;
        if ( type == LW_WIND ) return EW_WIND;
        if ( type >= 31 && type <= 40 ) return type;
        else return -1;
    }

}

Edited by ZoriaRPG, 15 May 2017 - 09:22 PM.


#3 Architect Abdiel

Architect Abdiel

    Kingdom Builder

  • Members
  • Real Name:Michael
  • Location:Florida

Posted 21 May 2017 - 04:25 PM

Thank you. Is there anything specific I need to do in game to get things moving in the right direction? Or does it just need to be placed down with a magic prism? And would this work with making the prism switch directions with sword slashing, or is that too much?

Another question while I am here.

Is there a script for sideview swimming?

I also want to set up sideview ladders. Which I wasn't able to get working like a year ago. But I might be able to figure it out now since I'm a bit more knowledgeable.

#4 justin

justin

    Adept

  • Members

Posted 21 May 2017 - 07:09 PM

Sideview swimming script here
http://www.purezc.ne...ic=64529&page=2


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users