Jump to content

Photo

Keeping failing at combining Global scripts.

Global Script combine FFC Solid

  • Please log in to reply
27 replies to this topic

#1 Sparkster

Sparkster

    The Sparking Spark of ZC

  • Members
  • Gender:Unspecified

Posted 01 March 2017 - 09:21 AM

Hello. Another fail of mine at combining global scripts was done. This is just because the global scripts contain more than just the stuff between while(true) and Waitframe().

 

For example a void run thing above the main loop or some more while(true) and Waitframe() things.

 

The tutorial of combining global scripts doesn't help me at all, even when I read it carefully.

 

So that's why I need you of combining Mero's Solid FFC script with my actual global one. Do you think you can do it?

 

Mero's Solid FFC Script

//import "std.zh"

//Global Constants
const int MISC_SOLIDFFC          = 14; //A misc value between 0 and 15 to denote a ffc as solid.
const int MISC_SFFC_X            = 0;  //This can be used by other ffcs as long as they're not solid.
const int SFFC_SIDEVIEWTHRESHOLD = 12; //Sideview X Overlap: used for hitdetection.
const int CRUSH_DAMAGE           = 8;  //Damage in 16ths of a heart dealt to link when he is crushed.
const int SF_SIDEWARP            = 2;  //The flag to denote that Left/Right sidewarps are used on a screen.
const int BIG_LINK               = 0;
const int CT_LADDER              = 0;  //If not using CT_RIGHTSTATUE

//Don't touch me, don't even think about setting these variables. HEY!
float SFFC_LinkX;
float SFFC_LinkY;

// this utility routine by Saffith checks for walkability of combos
bool isSolid(int x, int y){
    if(x<0 || x>255 || y<0 || y>175) return false;
    int mask=1111b;
    if(x%16< 8) mask&=0011b;
    else mask&=1100b;
    if(y%16< 8) mask&=0101b;
    else mask&=1010b;
    return (!(Screen->ComboS[ComboAt(x, y)]&mask)==0);
}
// this utility is used by the ffcs to check if the platform can move link.
bool CanMoveLink(int x){
    if(x > 0) x+=Link->X+16;
    else if(x < 0) x+=Link->X-1;
    if(x<0) return (Game->GetCurScreen()%16==0 && ScreenFlag(SF_MISC, SF_SIDEWARP));
    if(x>240) return (Game->GetCurScreen()%16==15 && ScreenFlag(SF_MISC,SF_SIDEWARP));
    int mask;
    if(x < Link->X) mask = 1100b;
    else mask = 11b;
    if(Cond(BIG_LINK || IsSideview(),false,true)){
        if(Link->Y % 16 < 8) mask &= ~101b;
    }
    return (Screen->ComboS[ComboAt(x, Link->Y)]&mask)==0 && !OnLadder();
}

// You can customize these functions to suit your needs.
// this utility is used to check if link is doing something that would interfer with him using an item.
bool LinkBusy()
{
    return (Link->Action==LA_ATTACKING||Link->Action == LA_CHARGING||Link->Action==LA_FROZEN);
}

// this utility is used to check if link using the feather.
bool UseFeather()
{
    return !LinkBusy() && ((GetEquipmentA()==I_ROCSFEATHER && Link->PressA) || (GetEquipmentB()==I_ROCSFEATHER && Link->PressB));
}

// this utility is used to check if link is on a sideview ladder.
bool OnLadder()
{
    int ct = Screen->ComboT[ComboAt(CenterLinkX(),CenterLinkY())];
    return (ct == Cond(CT_LADDER==0,CT_RIGHTSTATUE,CT_LADDER));
}

global script slot2_solidffc

{
    void run()
    {
        int olddmap = Game->GetCurDMap();
        int oldscreen = Game->GetCurScreen();
        int startx = Link->X;
        int starty = Link->Y;
        int linkxpos = startx;
        int linkypos = starty;
        bool dragged;
        while(true)
        {
            if((Link->Action!=LA_SCROLLING) && (olddmap != Game->GetCurDMap() || oldscreen != Game->GetCurScreen()))
            {
                olddmap = Game->GetCurDMap();
                oldscreen = Game->GetCurScreen();
                startx = Link->X;
                starty = Link->Y;
            }
            if(IsSideview())
            {
                //A fix for something I should of done different D:
                float linkposition = SFFC_SideviewShenanigans(linkxpos, linkypos);
                linkxpos = linkposition&0xFF;
                linkypos = (linkposition>>8)&0xFF;
                if((linkposition%1)*10000) dragged=true;
                else dragged=false;
            }
            Waitdraw();
            SolidFFCs(startx, starty, linkxpos, linkypos, dragged);
            linkxpos = Link->X;
            linkypos = Link->Y;
            Waitframe();
        }
    }
}

//Editing anything beneath this point may cause sickness, coma, brain anuerysm, or death.
//Do so at your own risk and don't hold me responsible. Have a good day! ^_^

void SolidFFCs(int startx, int starty, int linkxpos, int linkypos, bool dragged)
{
    int reservedx = Link->X;
    int reservedy = Link->Y;
    bool linkmoved[4]; //Up Down Left Right
    int edge[2];
    bool crushed;
    for(int i = 1; i <= 32 && !crushed; i++)
    {
        ffc f = Screen->LoadFFC(i);
        if(!f->Misc[MISC_SOLIDFFC]) continue;
        if(!SFFC_LinkCollision(f, edge)) continue;
        if(!SFFC_SetDirection(f, linkmoved, edge, linkxpos, linkypos))
        {
            crushed = SFFC_CrushLink(f, linkmoved, edge, startx, starty, dragged);
            continue;
        }
        crushed = SFFC_CrushLink(f, linkmoved, edge, startx, starty, dragged);
        if(!crushed)
        {
            if(edge[0]==DIR_UP || edge[0]==DIR_DOWN)
            {
                if(!IsSideview())
                {
                    SFFC_LinkY += edge[1];
                    if(Abs(SFFC_LinkY) >= 1) Link->Y += Floor(SFFC_LinkY);
                    SFFC_LinkY -= Floor(SFFC_LinkY);
                }
                else if(edge[0]==DIR_UP)
				{
					if(!(OnLadder() && UseFeather()))
				        Link->Jump=0; //Negate dat dang gravity
				}
				if(Link->InputLeft || Link->InputRight) Link->X = reservedx;
            }
            else if(edge[0]==DIR_LEFT ||edge[0]==DIR_RIGHT)
            {
                SFFC_LinkX += edge[1];
                if(Abs(SFFC_LinkX) >= 1) Link->X += Floor(SFFC_LinkX);
                SFFC_LinkX -= Floor(SFFC_LinkX);
                if(Link->InputUp || Link->InputDown || IsSideview()) Link->Y=reservedy;
            }
            reservedx=Link->X;
            reservedy=Link->Y;
        }
    }
}

//As usual Sideview gravity breaks everything even solid ffcs. XD
int SFFC_SideviewShenanigans(int linkxpos, int linkypos)
{
    bool linkmoved[4]; //Up Down Left Right
    int edge[2];
    float dragged;
    for(int i = 1; i <= 32; i++)
    {
        ffc f = Screen->LoadFFC(i);
        if(!f->Misc[MISC_SOLIDFFC]) continue;
        if(!SFFC_LinkCollision(f, edge) || !SFFC_SetDirection(f, linkmoved, edge, linkxpos, linkypos))
        {
            f->Misc[MISC_SFFC_X] = f->X;
            continue;
        }
        if(edge[0]==DIR_UP)
        {
             if(!OnLadder())
             {
                 if(UseFeather())
                 {
                     itemdata feather = Game->LoadItemData(I_ROCSFEATHER);
                     Link->Jump = feather->InitD[0];
                     Game->PlaySound(feather->UseSound);
                     f->Misc[MISC_SFFC_X] = f->X;
                     break; //Cause it should only happen once per frame.
                 }
                 else
                 {
                     if(Link->Jump<=0) Link->Jump=0;
                     Link->Y = f->Y-16;
                 }
                 linkypos = Link->Y;
             }
             if(CanMoveLink(f->X-f->Misc[MISC_SFFC_X]))
             {
                 SFFC_LinkX += f->X-f->Misc[MISC_SFFC_X];
                 if(Abs(SFFC_LinkX) >= 1)
                 {
                     Link->X += Floor(SFFC_LinkX);
                     SFFC_LinkX -= Floor(SFFC_LinkX);
                 }
                 linkxpos = Link->X;
                 dragged=0.9999;
             }
             else
             {
                 linkxpos = Link->X;
                 Link->Jump=0;
                 dragged=0;
             }
        }
        else if(edge[0]==DIR_DOWN && Link->Jump>0)
        {
            Link->Jump=0;
        }
        f->Misc[MISC_SFFC_X] = f->X;
    }
    return (linkxpos|(linkypos<<8))+dragged;
}

//Link Collision
bool SFFC_LinkCollision(ffc f, int edge)
{
    int linktop = Link->Y+Cond(BIG_LINK || IsSideview(), 0, 8)>>0;
    int linkbottom = Link->Y+15>>0;
    int linkleft = Link->X>>0;
    int linkright = Link->X+15>>0;
    int top = HitboxTop(f)>>0;
    int bottom = HitboxBottom(f)>>0;
    int left = HitboxLeft(f)>>0;
    int right = HitboxRight(f)>>0;
    int mod=0;
    if(IsSideview()) mod = SFFC_SIDEVIEWTHRESHOLD;
    // horizontal
    if(linktop < bottom && linkbottom > top)
    {
        if(IsSideview()) mod = 16-mod; //Less math.
        if(CenterLinkX() < CenterX(f)) // Left Side
        {
            edge[0]=DIR_LEFT;
            return (linkright >= left+mod);
        }
        else //Right Side
        {
            edge[0]=DIR_RIGHT;
            return (linkleft <= right-mod);
        }
    }
    // vertical
    else if(linkleft < right && linkright > left)
    {
        if(CenterLinkY() < CenterY(f)) // Top Side
        {
            edge[0]=DIR_UP;
            if(IsSideview()) return linkbottom+1 >= top && (linkleft > left-mod && linkleft < left+mod+(f->TileWidth-1)*16);
            else return (linkbottom >= top);
        }
        else //Bottom Side
        {
            edge[0]=DIR_DOWN;
            return (linktop <= bottom);
        }
    }
    else return false;
}

bool SFFC_SetDirection(ffc f, bool linkmoved, int edge, int linkxpos, int linkypos)
{
    //Move link to his old position.
    int x = Link->X;
    int y = Link->Y;
    Link->X = linkxpos;
    Link->Y = linkypos;
    //Then check for collisions again.
    bool ret = SFFC_LinkCollision(f, edge);
    //If we get here we know he didn't walk on the ffc and we got stuff to do.
    if(edge[0]==DIR_UP) edge[1] = -Abs(HitboxTop(f)-(Link->Y+15));
    else if(edge[0]==DIR_DOWN) edge[1] = Abs(HitboxBottom(f)-(Link->Y+Cond(BIG_LINK || IsSideview(),0,8)));
    else if(edge[0]==DIR_LEFT) edge[1] = -Abs(HitboxLeft(f)-(Link->X+15));
    else if(edge[0]==DIR_RIGHT) edge[1] = Abs(HitboxRight(f)-Link->X);
    linkmoved[edge[0]] = true;
    if(!ret)
    {
        if(Link->X >= HitboxLeft(f)-15 && Link->X <= HitboxRight(f) &&
          (Link->InputLeft||Link->InputRight)) Link->X=x;
        else if(Link->Y >= HitboxTop(f)-15 && Link->Y+Cond(BIG_LINK || IsSideview(),0,8) <= HitboxBottom(f) &&
          (Link->InputUp||Link->InputDown) || IsSideview()) Link->Y=y;
    }
    return ret;
}

bool SFFC_CrushLink(ffc f, bool linkmoved, int edge, int linkx, int linky, bool dragged)
{
    // Solid Combos
    bool crush; //Canwalk sucks, do it yourself guys. :)
    if(!IsSideview()) dragged = false;
    if(edge[0]==DIR_UP)
    {
         crush = isSolid(Floor(CenterLinkX()), Floor(Link->Y+Cond(BIG_LINK || IsSideview(), 0,8)+edge[1])) && !dragged;
         if(IsSideview() && crush) crush = (Floor(Link->Y)+16+edge[1]>=HitboxTop(f)); //Squash Bug Fix.
    }
    else if(edge[0]==DIR_DOWN)
         crush = isSolid(Floor(CenterLinkX()), Floor(Link->Y+15+edge[1]));
    else if(edge[0]==DIR_LEFT)
         crush = isSolid(Floor(Link->X+edge[1]), Floor(Link->Y+Cond(BIG_LINK || IsSideview(), 0,8)));
    else if(edge[0]==DIR_RIGHT)
         crush = isSolid(Floor(Link->X+15+edge[1]), Floor(Link->Y+Cond(BIG_LINK || IsSideview(), 0,8)));
    // Solid FFCs
    if(!crush)
    {
        for(int i; i < 4; i++)
        {
            if(linkmoved[i] && i==OppositeDir(edge[0]))
            {
                crush=true;
                break;
            }
        }
    }
    // Crushing Behavior
    if(crush)
    {
        Link->X = Clamp(linkx,0,240);
        Link->Y = Clamp(linky,0,160);
        Link->HP -= CRUSH_DAMAGE;
        Link->Action = LA_GOTHURTLAND;
        Link->HitDir = -1;
        Game->PlaySound(SFX_OUCH);
    }
    return crush;
}

ffc script SolidFFC
{
    void run()
    {
        this->Misc[MISC_SOLIDFFC] = 1;
        this->Misc[MISC_SFFC_X] = this->X;
    }
}

And here is my stuff. I had to double post because the first would be too long.

//Common Constant, only need to define once per script file.
const int BIG_LINK = 0; //Set this constant to 1 if using the Large Link Hit Box feature.

///Constants and Variables used by platform script;
const int DIAGONAL_MOVEMENT = 1; //Enable the option and change this to 0 for nes movement.
int onplatform; //Global variable use this to check if Link is on a platform for other scripts.

//Constants used by Bottomless Pits & Lava.
const int CT_HOLELAVA = 128; //Combo type to use for pit holes and lava."No Ground Enemies by default"
const int CF_PIT = 98; //The combo flag to register combos as pits.
const int CF_LAVA = 99; //The combo flag to register combos as lava.
const int WPS_LINK_FALL = 91; //The weapon sprite to display when Link falls into a pit. "Sprite 88 by default"
const int WPS_LINK_LAVA = 92; //The weapon sprite to display when Link drowns in lava. "Sprite 89 by default"
const int SFX_LINK_FALL = 73; //The sound to play when Link falls into a pit. "SFX_FALL by default"
const int SFX_LINK_LAVA = 72; //The sound to play when Link drowns in Lava. "SFX_SPLASH by default.
const int CMB_AUTOWARP = 936; //The first of your four transparent autowarp combos.
const int HOLELAVA_DAMAGE = 8; //Damage in hit points to inflict on link. "One Heart Container is worth 16 hit points"

//Constants for Solid FFC
const int MISC_SOLIDFFC          = 14; //A misc value between 0 and 15 to denote a ffc as solid.
const int MISC_SFFC_X            = 0;  //This can be used by other ffcs as long as they're not solid.
const int SFFC_SIDEVIEWTHRESHOLD = 12; //Sideview X Overlap: used for hitdetection.
const int CRUSH_DAMAGE           = 8;  //Damage in 16ths of a heart dealt to link when he is crushed.
const int SF_SIDEWARP            = 2;  //The flag to denote that Left/Right sidewarps are used on a screen.
const int CT_LADDER              = 0;  //If not using CT_RIGHTSTATUE

//Global variables used by Bottomless Pits & Lava.
int Falling;
bool Warping;

global script slot2_global
{
void run()
{
StartGhostZH();

//Initialize variables used to store Link's strating position on Screen Init.
int olddmap = Game->GetCurDMap();
int oldscreen = Game->GetCurDMapScreen();
int oldscreen = Game->GetCurScreen();
int startx = Link->X;
int starty = Link->Y;
int startdir = Link->Dir;
int linkxpos = startx;
int linkypos = starty;
bool dragged;

//Clear global variables used by Bottomless pits.
Falling = 0;
Warping = false;

//Main Loop
while(true)
{
NesMovementFix();
 
 
UpdateGhostZH1();

if(onplatform==0) Update_HoleLava(startx, starty, olddmap, oldscreen, startdir); 
Waitdraw();
MovingPlatforms();
if(Link->Action!=LA_SCROLLING)
{
if(Link->Z==0 && !Falling && (oldscreen!=Game->GetCurDMapScreen() || olddmap!=Game->GetCurDMap()))
{
olddmap = Game->GetCurDMap();
oldscreen = Game->GetCurDMapScreen();
startx = Link->X;
starty = Link->Y;
startdir = Link->Dir;
}
}
UpdateGhostZH2();
 
Waitframe();
}
}
}
 
void Update_HoleLava(int x, int y, int dmap, int scr, int dir)
{
lweapon hookshot = LoadLWeaponOf(LW_HOOKSHOT);
if(hookshot->isValid()) return;

if(Falling)
{
if(IsSideview()) Link->Jump=0;
Falling--;
if(Falling == 1)
{
int buffer[] = "Holelava";
if(CountFFCsRunning(Game->GetFFCScript(buffer)))
{
ffc f = Screen->LoadFFC(FindFFCRunning(Game->GetFFCScript(buffer)));
Warping = true;
if(f->InitD[1]==0)
{
f->InitD[6] = x;
f->InitD[7] = y;
}
}
else
{
Link->X = x;
Link->Y = y;
Link->Dir = dir;
Link->DrawXOffset -= Cond(Link->DrawXOffset < 0, -1000, 1000);
Link->HitXOffset -= Cond(Link->HitXOffset < 0, -1000, 1000);
Link->HP -= HOLELAVA_DAMAGE;
Link->Action = LA_GOTHURTLAND;
Link->HitDir = -1;
Game->PlaySound(SFX_OUCH);
if(Game->GetCurDMap()!=dmap || Game->GetCurDMapScreen()!=scr)
Link->PitWarp(dmap, scr);
}
}
NoAction();
Link->Action = LA_NONE;
}
else if(Link->Z==0 && OnPitCombo() && !Warping)
{
Link->DrawXOffset += Cond(Link->DrawXOffset < 0, -1000, 1000);
Link->HitXOffset += Cond(Link->HitXOffset < 0, -1000, 1000);
int comboflag = OnPitCombo();
SnaptoGrid();
Game->PlaySound(Cond(comboflag == CF_PIT, SFX_LINK_FALL, SFX_LINK_LAVA));
lweapon dummy = CreateLWeaponAt(LW_SCRIPT10, Link->X, Link->Y);
dummy->UseSprite(Cond(comboflag == CF_PIT, WPS_LINK_FALL, WPS_LINK_LAVA));
dummy->DeadState = dummy->NumFrames*dummy->ASpeed;
dummy->DrawXOffset = 0;
dummy->DrawYOffset = 0;
Falling = 30;
NoAction();
Link->Action = LA_NONE;
}
}
void NesMovementFix()
{
if(DIAGONAL_MOVEMENT==0 && (Link->InputUp || Link->InputDown))
{
Link->InputLeft = false;
Link->InputRight = false;
}
}
void MovingPlatforms()
{
onplatform = 0;
if(Link->Z == 0)
{
int buffer[] = "MovingPlatform";
for(int i = 1; i <= 32; i++)
{
ffc f = Screen->LoadFFC(i);
if(f->Script != Game->GetFFCScript(buffer)) continue;
if(Abs(Link->X + 8 - CenterX(f)) >= f->TileWidth*8 + 2) continue;
if(Abs(Link->Y + 12 - CenterY(f)) >= f->TileHeight*8 + 2) continue;
onplatform = FFCNum(f);
break;
}
}
}
ffc script Holelava{
void run(int warp, bool position, int damage)
{
while(true)
{
while(!Warping) Waitframe();
if(warp > 0)
{
this->Data = CMB_AUTOWARP+warp-1;
this->Flags[FFCF_CARRYOVER] = true;
Waitframe();
this->Data = FFCS_INVISIBLE_COMBO;
this->Flags[FFCF_CARRYOVER] = false;
Link->Z = Link->Y;
Warping = false;
Link->DrawXOffset -= Cond(Link->DrawXOffset < 0, -1000, 1000);
Link->HitXOffset -= Cond(Link->HitXOffset < 0, -1000, 1000);
Quit();
}
if(position)
{
Link->X = this->X;
Link->Y = this->Y;
}
else
{
Link->X = this->InitD[6];
Link->Y = this->InitD[7];
}
if(damage)
{
Link->HP -= damage;
Link->Action = LA_GOTHURTLAND;
Link->HitDir = -1;
Game->PlaySound(SFX_OUCH);
}
Link->DrawXOffset -= Cond(Link->DrawXOffset < 0, -1000, 1000);
Link->HitXOffset -= Cond(Link->HitXOffset < 0, -1000, 1000);
Warping = false;
Waitframe();
}
}
}

//Used to determine if Link is on a Pit or Lava combo.
int OnPitCombo()
{
int comboLoc = ComboAt(Link->X+8, Link->Y + Cond(BIG_LINK==0, 12, 8));
if(Screen->ComboT[comboLoc] != CT_HOLELAVA)
return 0;
else if(Screen->ComboI[comboLoc] == CF_PIT || Screen->ComboI[comboLoc] == CF_LAVA)
return Screen->ComboI[comboLoc];
else if(Screen->ComboF[comboLoc] == CF_PIT || Screen->ComboF[comboLoc] == CF_LAVA)
return Screen->ComboF[comboLoc];
else
return 0;
}


//Snaps Link to the combo so he appears completely over pit and lava combos.
void SnaptoGrid()
{
int x = Link->X;
int y = Link->Y + Cond(BIG_LINK==0, 8, 0);
int comboLoc = ComboAt(x, y);

//X Axis
if(Screen->ComboT[comboLoc] == CT_HOLELAVA && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc+1] != CT_HOLELAVA))
Link->X = ComboX(comboLoc);
else if(Screen->ComboT[comboLoc+1] == CT_HOLELAVA && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc] != CT_HOLELAVA))
Link->X = ComboX(comboLoc+1);
if(Cond(y % 16 == 0, false, Screen->ComboT[comboLoc+16] == CT_HOLELAVA) && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc+17] != CT_HOLELAVA))
Link->X = ComboX(comboLoc+16);
else if(Cond(y % 16 == 0, false, Screen->ComboT[comboLoc+17] == CT_HOLELAVA) && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc+16] != CT_HOLELAVA))
Link->X = ComboX(comboLoc+17);

//Y Axis
if(Screen->ComboT[comboLoc] == CT_HOLELAVA && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc+16] != CT_HOLELAVA))
Link->Y = ComboY(comboLoc);
else if(Screen->ComboT[comboLoc+16] == CT_HOLELAVA && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc] != CT_HOLELAVA))
Link->Y = ComboY(comboLoc+16);
if(Cond(x % 16 == 0, false, Screen->ComboT[comboLoc+1] == CT_HOLELAVA) && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc+17] != CT_HOLELAVA))
Link->Y = ComboY(comboLoc+1);
else if(Cond(x % 16 == 0, false, Screen->ComboT[comboLoc+17] == CT_HOLELAVA) && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc+1] != CT_HOLELAVA))
Link->Y = ComboY(comboLoc+17);
}

ffc script MovingPlatform{
void run()
{
float oldx = this->X;
float oldy = this->Y;
float linkx;
float linky;
while(true)
{
if(onplatform == FFCNum(this))
{
linkx += this->X - oldx;
linky += this->Y - oldy;
if(linkx << 0 != 0)
{
Link->X += linkx << 0;
linkx -= linkx << 0;
}
if(linky << 0 != 0)
{
Link->Y += linky << 0;
linky -= linky << 0;
}
}
else
{
linkx = 0;
linky = 0;
}
oldx = this->X;
oldy = this->Y;
Waitframe();
}
}
}
        if((Link->Action!=LA_SCROLLING) && (olddmap != Game->GetCurDMap() || oldscreen != Game->GetCurScreen()))
            {
                olddmap = Game->GetCurDMap();
                oldscreen = Game->GetCurScreen();
                startx = Link->X;
                starty = Link->Y;
            }
            if(IsSideview())
            {
                //A fix for something I should of done different D:
                float linkposition = SFFC_SideviewShenanigans(linkxpos, linkypos);
                linkxpos = linkposition&0xFF;
                linkypos = (linkposition>>8)&0xFF;
                if((linkposition%1)*10000) dragged=true;
                else dragged=false;
            }
            Waitdraw();
            SolidFFCs(startx, starty, linkxpos, linkypos, dragged);
            linkxpos = Link->X;
            linkypos = Link->Y;
            Waitframe();
        }
    }
}

//Editing anything beneath this point may cause sickness, coma, brain anuerysm, or death.
//Do so at your own risk and don't hold me responsible. Have a good day! ^_^

void SolidFFCs(int startx, int starty, int linkxpos, int linkypos, bool dragged)
{
    int reservedx = Link->X;
    int reservedy = Link->Y;
    bool linkmoved[4]; //Up Down Left Right
    int edge[2];
    bool crushed;
    for(int i = 1; i <= 32 && !crushed; i++)
    {
        ffc f = Screen->LoadFFC(i);
        if(!f->Misc[MISC_SOLIDFFC]) continue;
        if(!SFFC_LinkCollision(f, edge)) continue;
        if(!SFFC_SetDirection(f, linkmoved, edge, linkxpos, linkypos))
        {
            crushed = SFFC_CrushLink(f, linkmoved, edge, startx, starty, dragged);
            continue;
        }
        crushed = SFFC_CrushLink(f, linkmoved, edge, startx, starty, dragged);
        if(!crushed)
        {
            if(edge[0]==DIR_UP || edge[0]==DIR_DOWN)
            {
                if(!IsSideview())
                {
                    SFFC_LinkY += edge[1];
                    if(Abs(SFFC_LinkY) >= 1) Link->Y += Floor(SFFC_LinkY);
                    SFFC_LinkY -= Floor(SFFC_LinkY);
                }
                else if(edge[0]==DIR_UP)
				{
					if(!(OnLadder() && UseFeather()))
				        Link->Jump=0; //Negate dat dang gravity
				}
				if(Link->InputLeft || Link->InputRight) Link->X = reservedx;
            }
            else if(edge[0]==DIR_LEFT ||edge[0]==DIR_RIGHT)
            {
                SFFC_LinkX += edge[1];
                if(Abs(SFFC_LinkX) >= 1) Link->X += Floor(SFFC_LinkX);
                SFFC_LinkX -= Floor(SFFC_LinkX);
                if(Link->InputUp || Link->InputDown || IsSideview()) Link->Y=reservedy;
            }
            reservedx=Link->X;
            reservedy=Link->Y;
        }
    }
}

//As usual Sideview gravity breaks everything even solid ffcs. XD
int SFFC_SideviewShenanigans(int linkxpos, int linkypos)
{
    bool linkmoved[4]; //Up Down Left Right
    int edge[2];
    float dragged;
    for(int i = 1; i <= 32; i++)
    {
        ffc f = Screen->LoadFFC(i);
        if(!f->Misc[MISC_SOLIDFFC]) continue;
        if(!SFFC_LinkCollision(f, edge) || !SFFC_SetDirection(f, linkmoved, edge, linkxpos, linkypos))
        {
            f->Misc[MISC_SFFC_X] = f->X;
            continue;
        }
        if(edge[0]==DIR_UP)
        {
             if(!OnLadder())
             {
                 if(UseFeather())
                 {
                     itemdata feather = Game->LoadItemData(I_ROCSFEATHER);
                     Link->Jump = feather->InitD[0];
                     Game->PlaySound(feather->UseSound);
                     f->Misc[MISC_SFFC_X] = f->X;
                     break; //Cause it should only happen once per frame.
                 }
                 else
                 {
                     if(Link->Jump<=0) Link->Jump=0;
                     Link->Y = f->Y-16;
                 }
                 linkypos = Link->Y;
             }
             if(CanMoveLink(f->X-f->Misc[MISC_SFFC_X]))
             {
                 SFFC_LinkX += f->X-f->Misc[MISC_SFFC_X];
                 if(Abs(SFFC_LinkX) >= 1)
                 {
                     Link->X += Floor(SFFC_LinkX);
                     SFFC_LinkX -= Floor(SFFC_LinkX);
                 }
                 linkxpos = Link->X;
                 dragged=0.9999;
             }
             else
             {
                 linkxpos = Link->X;
                 Link->Jump=0;
                 dragged=0;
             }
        }
        else if(edge[0]==DIR_DOWN && Link->Jump>0)
        {
            Link->Jump=0;
        }
        f->Misc[MISC_SFFC_X] = f->X;
    }
    return (linkxpos|(linkypos<<8))+dragged;
}

//Link Collision
bool SFFC_LinkCollision(ffc f, int edge)
{
    int linktop = Link->Y+Cond(BIG_LINK || IsSideview(), 0, 8)>>0;
    int linkbottom = Link->Y+15>>0;
    int linkleft = Link->X>>0;
    int linkright = Link->X+15>>0;
    int top = HitboxTop(f)>>0;
    int bottom = HitboxBottom(f)>>0;
    int left = HitboxLeft(f)>>0;
    int right = HitboxRight(f)>>0;
    int mod=0;
    if(IsSideview()) mod = SFFC_SIDEVIEWTHRESHOLD;
    // horizontal
    if(linktop < bottom && linkbottom > top)
    {
        if(IsSideview()) mod = 16-mod; //Less math.
        if(CenterLinkX() < CenterX(f)) // Left Side
        {
            edge[0]=DIR_LEFT;
            return (linkright >= left+mod);
        }
        else //Right Side
        {
            edge[0]=DIR_RIGHT;
            return (linkleft <= right-mod);
        }
    }
    // vertical
    else if(linkleft < right && linkright > left)
    {
        if(CenterLinkY() < CenterY(f)) // Top Side
        {
            edge[0]=DIR_UP;
            if(IsSideview()) return linkbottom+1 >= top && (linkleft > left-mod && linkleft < left+mod+(f->TileWidth-1)*16);
            else return (linkbottom >= top);
        }
        else //Bottom Side
        {
            edge[0]=DIR_DOWN;
            return (linktop <= bottom);
        }
    }
    else return false;
}

bool SFFC_SetDirection(ffc f, bool linkmoved, int edge, int linkxpos, int linkypos)
{
    //Move link to his old position.
    int x = Link->X;
    int y = Link->Y;
    Link->X = linkxpos;
    Link->Y = linkypos;
    //Then check for collisions again.
    bool ret = SFFC_LinkCollision(f, edge);
    //If we get here we know he didn't walk on the ffc and we got stuff to do.
    if(edge[0]==DIR_UP) edge[1] = -Abs(HitboxTop(f)-(Link->Y+15));
    else if(edge[0]==DIR_DOWN) edge[1] = Abs(HitboxBottom(f)-(Link->Y+Cond(BIG_LINK || IsSideview(),0,8)));
    else if(edge[0]==DIR_LEFT) edge[1] = -Abs(HitboxLeft(f)-(Link->X+15));
    else if(edge[0]==DIR_RIGHT) edge[1] = Abs(HitboxRight(f)-Link->X);
    linkmoved[edge[0]] = true;
    if(!ret)
    {
        if(Link->X >= HitboxLeft(f)-15 && Link->X <= HitboxRight(f) &&
          (Link->InputLeft||Link->InputRight)) Link->X=x;
        else if(Link->Y >= HitboxTop(f)-15 && Link->Y+Cond(BIG_LINK || IsSideview(),0,8) <= HitboxBottom(f) &&
          (Link->InputUp||Link->InputDown) || IsSideview()) Link->Y=y;
    }
    return ret;
}

bool SFFC_CrushLink(ffc f, bool linkmoved, int edge, int linkx, int linky, bool dragged)
{
    // Solid Combos
    bool crush; //Canwalk sucks, do it yourself guys. :)
    if(!IsSideview()) dragged = false;
    if(edge[0]==DIR_UP)
    {
         crush = isSolid(Floor(CenterLinkX()), Floor(Link->Y+Cond(BIG_LINK || IsSideview(), 0,8)+edge[1])) && !dragged;
         if(IsSideview() && crush) crush = (Floor(Link->Y)+16+edge[1]>=HitboxTop(f)); //Squash Bug Fix.
    }
    else if(edge[0]==DIR_DOWN)
         crush = isSolid(Floor(CenterLinkX()), Floor(Link->Y+15+edge[1]));
    else if(edge[0]==DIR_LEFT)
         crush = isSolid(Floor(Link->X+edge[1]), Floor(Link->Y+Cond(BIG_LINK || IsSideview(), 0,8)));
    else if(edge[0]==DIR_RIGHT)
         crush = isSolid(Floor(Link->X+15+edge[1]), Floor(Link->Y+Cond(BIG_LINK || IsSideview(), 0,8)));
    // Solid FFCs
    if(!crush)
    {
        for(int i; i < 4; i++)
        {
            if(linkmoved[i] && i==OppositeDir(edge[0]))
            {
                crush=true;
                break;
            }
        }
    }
    // Crushing Behavior
    if(crush)
    {
        Link->X = Clamp(linkx,0,240);
        Link->Y = Clamp(linky,0,160);
        Link->HP -= CRUSH_DAMAGE;
        Link->Action = LA_GOTHURTLAND;
        Link->HitDir = -1;
        Game->PlaySound(SFX_OUCH);
    }
    return crush;

}

ffc script SolidFFC
{
    void run()
    {
        this->Misc[MISC_SOLIDFFC] = 1;
        this->Misc[MISC_SFFC_X] = this->X;
    }
}


#2 ZoriaRPG

ZoriaRPG

    The Timelord

  • ZC Developers
  • Gender:Unspecified
  • Location:Prydon Academy

Posted 02 March 2017 - 03:33 AM

FWIW, that script is G-dawful. It is buggy, to the point of being unusable, as most us us here can attest; and using it is likely to give you a vast new array of headaches, that will require rewriting or debugging that no-one will do for you.

 

It is also the typical giant pile of 'Mero instructions' that are not at all encapsulated; that should be, mixed with some nonsensical hacks that are inserted as patchwork, along with equally silly vars. Just terrible.



#3 Sparkster

Sparkster

    The Sparking Spark of ZC

  • Members
  • Gender:Unspecified

Posted 02 March 2017 - 08:06 AM

Ouch...

 

Uhm... so. If you say this.

 

I still have the old global.z code (without Mero's Solid FFC script).

//Common Constant, only need to define once per script file.
const int BIG_LINK = 0; //Set this constant to 1 if using the Large Link Hit Box feature.

///Constants and Variables used by platform script;
const int DIAGONAL_MOVEMENT = 1; //Enable the option and change this to 0 for nes movement.
int onplatform; //Global variable use this to check if Link is on a platform for other scripts.

//Constants used by Bottomless Pits & Lava.
const int CT_HOLELAVA = 128; //Combo type to use for pit holes and lava."No Ground Enemies by default"
const int CF_PIT = 98; //The combo flag to register combos as pits.
const int CF_LAVA = 99; //The combo flag to register combos as lava.
const int WPS_LINK_FALL = 91; //The weapon sprite to display when Link falls into a pit. "Sprite 88 by default"
const int WPS_LINK_LAVA = 92; //The weapon sprite to display when Link drowns in lava. "Sprite 89 by default"
const int SFX_LINK_FALL = 73; //The sound to play when Link falls into a pit. "SFX_FALL by default"
const int SFX_LINK_LAVA = 72; //The sound to play when Link drowns in Lava. "SFX_SPLASH by default.
const int CMB_AUTOWARP = 936; //The first of your four transparent autowarp combos.
const int HOLELAVA_DAMAGE = 8; //Damage in hit points to inflict on link. "One Heart Container is worth 16 hit points"

//Global variables used by Bottomless Pits & Lava.
int Falling;
bool Warping;

global script slot2_global
{
void run()
{
StartGhostZH();

//Initialize variables used to store Link's strating position on Screen Init.
int olddmap = Game->GetCurDMap();
int oldscreen = Game->GetCurDMapScreen();
int startx = Link->X;
int starty = Link->Y;
int startdir = Link->Dir;

//Clear global variables used by Bottomless pits.
Falling = 0;
Warping = false;

//Main Loop
while(true)
{
NesMovementFix();
 
 
UpdateGhostZH1();

if(onplatform==0) Update_HoleLava(startx, starty, olddmap, oldscreen, startdir); 
Waitdraw();
MovingPlatforms();
if(Link->Action!=LA_SCROLLING)
{
if(Link->Z==0 && !Falling && (oldscreen!=Game->GetCurDMapScreen() || olddmap!=Game->GetCurDMap()))
{
olddmap = Game->GetCurDMap();
oldscreen = Game->GetCurDMapScreen();
startx = Link->X;
starty = Link->Y;
startdir = Link->Dir;
}
}
UpdateGhostZH2();
 
Waitframe();
}
}
}
 
void Update_HoleLava(int x, int y, int dmap, int scr, int dir)
{
lweapon hookshot = LoadLWeaponOf(LW_HOOKSHOT);
if(hookshot->isValid()) return;

if(Falling)
{
if(IsSideview()) Link->Jump=0;
Falling--;
if(Falling == 1)
{
int buffer[] = "Holelava";
if(CountFFCsRunning(Game->GetFFCScript(buffer)))
{
ffc f = Screen->LoadFFC(FindFFCRunning(Game->GetFFCScript(buffer)));
Warping = true;
if(f->InitD[1]==0)
{
f->InitD[6] = x;
f->InitD[7] = y;
}
}
else
{
Link->X = x;
Link->Y = y;
Link->Dir = dir;
Link->DrawXOffset -= Cond(Link->DrawXOffset < 0, -1000, 1000);
Link->HitXOffset -= Cond(Link->HitXOffset < 0, -1000, 1000);
Link->HP -= HOLELAVA_DAMAGE;
Link->Action = LA_GOTHURTLAND;
Link->HitDir = -1;
Game->PlaySound(SFX_OUCH);
if(Game->GetCurDMap()!=dmap || Game->GetCurDMapScreen()!=scr)
Link->PitWarp(dmap, scr);
}
}
NoAction();
Link->Action = LA_NONE;
}
else if(Link->Z==0 && OnPitCombo() && !Warping)
{
Link->DrawXOffset += Cond(Link->DrawXOffset < 0, -1000, 1000);
Link->HitXOffset += Cond(Link->HitXOffset < 0, -1000, 1000);
int comboflag = OnPitCombo();
SnaptoGrid();
Game->PlaySound(Cond(comboflag == CF_PIT, SFX_LINK_FALL, SFX_LINK_LAVA));
lweapon dummy = CreateLWeaponAt(LW_SCRIPT10, Link->X, Link->Y);
dummy->UseSprite(Cond(comboflag == CF_PIT, WPS_LINK_FALL, WPS_LINK_LAVA));
dummy->DeadState = dummy->NumFrames*dummy->ASpeed;
dummy->DrawXOffset = 0;
dummy->DrawYOffset = 0;
Falling = 30;
NoAction();
Link->Action = LA_NONE;
}
}
void NesMovementFix()
{
if(DIAGONAL_MOVEMENT==0 && (Link->InputUp || Link->InputDown))
{
Link->InputLeft = false;
Link->InputRight = false;
}
}
void MovingPlatforms()
{
onplatform = 0;
if(Link->Z == 0)
{
int buffer[] = "MovingPlatform";
for(int i = 1; i <= 32; i++)
{
ffc f = Screen->LoadFFC(i);
if(f->Script != Game->GetFFCScript(buffer)) continue;
if(Abs(Link->X + 8 - CenterX(f)) >= f->TileWidth*8 + 2) continue;
if(Abs(Link->Y + 12 - CenterY(f)) >= f->TileHeight*8 + 2) continue;
onplatform = FFCNum(f);
break;
}
}
}
ffc script Holelava{
void run(int warp, bool position, int damage)
{
while(true)
{
while(!Warping) Waitframe();
if(warp > 0)
{
this->Data = CMB_AUTOWARP+warp-1;
this->Flags[FFCF_CARRYOVER] = true;
Waitframe();
this->Data = FFCS_INVISIBLE_COMBO;
this->Flags[FFCF_CARRYOVER] = false;
Link->Z = Link->Y;
Warping = false;
Link->DrawXOffset -= Cond(Link->DrawXOffset < 0, -1000, 1000);
Link->HitXOffset -= Cond(Link->HitXOffset < 0, -1000, 1000);
Quit();
}
if(position)
{
Link->X = this->X;
Link->Y = this->Y;
}
else
{
Link->X = this->InitD[6];
Link->Y = this->InitD[7];
}
if(damage)
{
Link->HP -= damage;
Link->Action = LA_GOTHURTLAND;
Link->HitDir = -1;
Game->PlaySound(SFX_OUCH);
}
Link->DrawXOffset -= Cond(Link->DrawXOffset < 0, -1000, 1000);
Link->HitXOffset -= Cond(Link->HitXOffset < 0, -1000, 1000);
Warping = false;
Waitframe();
}
}
}

//Used to determine if Link is on a Pit or Lava combo.
int OnPitCombo()
{
int comboLoc = ComboAt(Link->X+8, Link->Y + Cond(BIG_LINK==0, 12, 8));
if(Screen->ComboT[comboLoc] != CT_HOLELAVA)
return 0;
else if(Screen->ComboI[comboLoc] == CF_PIT || Screen->ComboI[comboLoc] == CF_LAVA)
return Screen->ComboI[comboLoc];
else if(Screen->ComboF[comboLoc] == CF_PIT || Screen->ComboF[comboLoc] == CF_LAVA)
return Screen->ComboF[comboLoc];
else
return 0;
}


//Snaps Link to the combo so he appears completely over pit and lava combos.
void SnaptoGrid()
{
int x = Link->X;
int y = Link->Y + Cond(BIG_LINK==0, 8, 0);
int comboLoc = ComboAt(x, y);

//X Axis
if(Screen->ComboT[comboLoc] == CT_HOLELAVA && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc+1] != CT_HOLELAVA))
Link->X = ComboX(comboLoc);
else if(Screen->ComboT[comboLoc+1] == CT_HOLELAVA && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc] != CT_HOLELAVA))
Link->X = ComboX(comboLoc+1);
if(Cond(y % 16 == 0, false, Screen->ComboT[comboLoc+16] == CT_HOLELAVA) && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc+17] != CT_HOLELAVA))
Link->X = ComboX(comboLoc+16);
else if(Cond(y % 16 == 0, false, Screen->ComboT[comboLoc+17] == CT_HOLELAVA) && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc+16] != CT_HOLELAVA))
Link->X = ComboX(comboLoc+17);

//Y Axis
if(Screen->ComboT[comboLoc] == CT_HOLELAVA && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc+16] != CT_HOLELAVA))
Link->Y = ComboY(comboLoc);
else if(Screen->ComboT[comboLoc+16] == CT_HOLELAVA && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc] != CT_HOLELAVA))
Link->Y = ComboY(comboLoc+16);
if(Cond(x % 16 == 0, false, Screen->ComboT[comboLoc+1] == CT_HOLELAVA) && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc+17] != CT_HOLELAVA))
Link->Y = ComboY(comboLoc+1);
else if(Cond(x % 16 == 0, false, Screen->ComboT[comboLoc+17] == CT_HOLELAVA) && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc+1] != CT_HOLELAVA))
Link->Y = ComboY(comboLoc+17);
}

ffc script MovingPlatform{
void run()
{
float oldx = this->X;
float oldy = this->Y;
float linkx;
float linky;
while(true)
{
if(onplatform == FFCNum(this))
{
linkx += this->X - oldx;
linky += this->Y - oldy;
if(linkx << 0 != 0)
{
Link->X += linkx << 0;
linkx -= linkx << 0;
}
if(linky << 0 != 0)
{
Link->Y += linky << 0;
linky -= linky << 0;
}
}
else
{
linkx = 0;
linky = 0;
}
oldx = this->X;
oldy = this->Y;
Waitframe();
}
}
}

Maybe you can do something with this. Sry for the inconvenience.



#4 cavthena

cavthena

    Apprentice

  • Members
  • Real Name:Clayton
  • Gender:Male
  • Location:I wish I knew

Posted 02 March 2017 - 06:38 PM

If you want I did upload a pitfall script (that comes bundled with platforms and shutter doors). That is bug free™ and easier to combine with your global script.


  • Sparkster likes this

#5 ZoriaRPG

ZoriaRPG

    The Timelord

  • ZC Developers
  • Gender:Unspecified
  • Location:Prydon Academy

Posted 03 March 2017 - 08:43 AM

If you want I did upload a pitfall script (that comes bundled with platforms and shutter doors). That is bug free™ and easier to combine with your global script.


I'll upvote this. Toss that whole mess, and use Cav's script. It will save your sanity later.

One bright and shining day I'll unveil my own version of this, but by then I may have added pits and falling to the engine. :P

I did add flags for the combos, at least.
  • Sparkster likes this

#6 Sparkster

Sparkster

    The Sparking Spark of ZC

  • Members
  • Gender:Unspecified

Posted 03 March 2017 - 12:25 PM

I'll go for it at another time, but do you think I should use it NOW? It is because I also have the "startghost .zh" thing as you can see in my current global script file.

 

I have found an alternate FFC version here: http://www.purezc.ne...ic=62710&page=2


Edited by Sparkster, 03 March 2017 - 12:27 PM.


#7 cavthena

cavthena

    Apprentice

  • Members
  • Real Name:Clayton
  • Gender:Male
  • Location:I wish I knew

Posted 03 March 2017 - 01:19 PM

I would say yes. It's easier to change early. There are also more bugs in Mero's code that you won't see until you play it in game and they don't have any easy fix. The ability to move Link while falling into a pit or falling into a new screen and platforms skipping over changers are only a few for example.
  • Sparkster likes this

#8 Sparkster

Sparkster

    The Sparking Spark of ZC

  • Members
  • Gender:Unspecified

Posted 05 March 2017 - 03:36 AM

I would say yes. It's easier to change early. There are also more bugs in Mero's code that you won't see until you play it in game and they don't have any easy fix. The ability to move Link while falling into a pit or falling into a new screen and platforms skipping over changers are only a few for example.

 

Well I followed the youtube Instructions and it compiled well. The last thing I had to do is to import the ghost stuff for possible custom enemies. (If I had the "power" of scripting)

 

Is this what I have here enough, or should I copy some more of the ghost stuff:

//Constants for Pitfall
//Type PF_*
//Pits
const int PF_PIT_COMBO = 143; //Combo Type of pits.
const int PF_PIT_WARP = 98; //Flag for pit warping.
const int PF_LINK_FALL = 91; //LWeapon for Link falling.
const int PF_SFX_FALL = 61; //SFX for Link falling.
const int PF_PIT_DAMAGE = 8; //Damage from pits in 1/16ths of a heart.

//Lava
const int PF_LAVA_COMBO = 145; //Combo Type of lava.
const int PF_LINK_MELT = 92; //LWeapon for Link melting.
const int PF_SFX_MELT = 62; //SFX for Link melting.
const int PF_LAVA_DAMAGE = 16; //Damage from lava in 1/16ths of a heart.

//Teleporting
const int TELECOMBO = 0; //Combo of the teleport effect. upto 3x3.
const int TELETIME = 120; //Length of the teleport animation in frames.
const int TELELAYER = 3; //Layer to draw the effect on.
const int TELESOUND = 0; //SFX for effect.

//Globals ...Do Not Change...
int PF_curscreen = -1;
int PF_curmap = -1;
bool PF_stored = false;
bool PF_warp = false;
bool PF_onplatform = false;

//Global Loop
global script Active
{
	void run ()
	{
		while(true)
		{
			PitFall();
            		UpdateGhostZH1();
            		Waitdraw();
           		UpdateGhostZH2();
			Waitdraw(); //Waitdraw Here!
			Waitframe();
		}
	}
}
//=================================Pitfall=====================================================
void PF_Drawing(){
  //Add functions you need drawn here.
}

void PitFall(){

	int wait;

	//Grab current screen.
	if(PF_curscreen != Game->GetCurScreen() || PF_curmap != Game->GetCurMap()){
		PF_curscreen = Game->GetCurScreen();
		PF_curmap = Game->GetCurMap();
		PF_stored = false;
	}
	else if(Link->Action != LA_SCROLLING && !PF_stored && Link->Z <= 0){
		Link->Misc[2] = Link->X;
		Link->Misc[3] = Link->Y;
		PF_stored = true;
	}
	
	//if Link was warped.
	if(PF_warp){
		Link->Z = Link->Y;
		PF_warp = false;
		while(Link->Z > 0){
			PF_Drawing();
			WaitNoAction(); //Wait for Link to Land before continuing.
		}
		return;
	}
	
	//Check for Hookshot or platform.
	lweapon hook = LoadLWeaponOf(LW_HOOKSHOT);
	if(hook->isValid() || PF_onplatform) return;
	
	//Check for Pit Combo.
	if(Screen->ComboT[ComboAt(CenterLinkX(), CenterLinkY() + 4)] == PF_PIT_COMBO){
		NoAction();
		wait = PF_LinkSetup(PF_LINK_FALL, PF_SFX_FALL);
		while(wait > 0){
			PF_Drawing();
			wait--;
			WaitNoAction();
		}
		Link->Invisible = false;
		Link->CollDetection = true;
		if(Screen->ComboF[ComboAt(CenterLinkX(), CenterLinkY() + 4)] == PF_PIT_WARP){
			Link->PitWarp(Screen->GetSideWarpDMap(3), Screen->GetSideWarpScreen(3));
			PF_warp = true;
		}
		else{
			Link->HP -= PF_PIT_DAMAGE;
			Game->PlaySound(SFX_OUCH);
			Link->X = Link->Misc[2];
			Link->Y = Link->Misc[3];
		}
	}
	//Check for Lava Combo.
	else if(Screen->ComboT[ComboAt(CenterLinkX(), CenterLinkY() + 4)] == PF_LAVA_COMBO){
		NoAction();
		wait = PF_LinkSetup(PF_LINK_MELT, PF_SFX_MELT);
		while(wait > 0){
			PF_Drawing();
			wait--;
			WaitNoAction();
		}
		Link->Invisible = false;
		Link->CollDetection = true;
		Link->HP -= PF_LAVA_DAMAGE;
		Game->PlaySound(SFX_OUCH);
		Link->X = Link->Misc[2];
		Link->Y = Link->Misc[3];
	}
}

int PF_LinkSetup(int sprite, int sfx){

	//Snap Link to grid and make invisible.
	Link->Invisible = true;
	Link->CollDetection = false;
	Link->X = GridX(Link->X + 8);
	Link->Y = GridY(Link->Y + 12);
	
	//Create Dummy lweapon.
	lweapon dummy = CreateLWeaponAt(LW_SCRIPT1, Link->X, Link->Y);
	dummy->UseSprite(sprite);
	dummy->DeadState = dummy->NumFrames * dummy->ASpeed;
	dummy->CollDetection = false;
	
	//Play Sound sfx.
	Game->PlaySound(sfx);
	
	//return timer
	return dummy->NumFrames * dummy->ASpeed;

}

//========================================Platform========================================
//D0: Type: Changer (0) or Platform (1)
//D1: Delay at each corner in frames.
//D2: Wait for screen secrets. No(0) or Yes(1).

//if type 0.
		//D1 - 7 to use as data holders.
		//D1: New direction. Use one of 4 standard directions. Use -1 for same direction.
		//D2: New Speed. Use -1 for same speed.
		//D3: Platform teleports. No(0), Yes(1), Take Link(2).
		//D4: New X.
		//D5: New Y.
		//D6: TeleEffect. No Effect(0). Effect(1).

		
		
ffc script Platform
{
	void run(int type, int delay, bool secret)
	{
		int t1;
		int direction = 0;
		int scriptnum;
		int currentFFC = 0;
		float speed = 0;
		float rate;
		float accel = 0;
		
		ffc temp;
		
		int scriptname[] = "Platform";
	
		if(type == 1) //Type 1: Platform
		{
			scriptnum = Game->GetFFCScript(scriptname);
			if(secret == 1)
			{
				while(!Screen->State[ST_SECRET])
				{
					Waitframe();
				}
			}
			for(t1 = 0; t1 < delay; t1++)
			{
				//Update and check for collision.
				if(RectCollision(Link->X+6, Link->Y+8, Link->X+10, Link->Y+16, this->X, this->Y, this->X+(16*this->TileWidth), this->Y+(16*this->TileHeight)))
					PF_onplatform = true;
				else
					PF_onplatform = false;
				//Wait for delay.
				Waitframe();
			}
			
		//Start Loop
			while(true)
			{
				//Update and check for collision.
				if(RectCollision(Link->X+6, Link->Y+8, Link->X+10, Link->Y+16, this->X, this->Y, this->X+(16*this->TileWidth), this->Y+(16*this->TileHeight)))
					PF_onplatform = true;
				else
				{
					PF_onplatform = false;
					rate = speed % 1;
				}
					
				//Check for flags.
				for(t1 = 32; t1 > 0; t1--)
				{
					temp = Screen->LoadFFC(t1);
					if(temp->Script == scriptnum && temp->InitD[0] == 0 && PlatformGridX(this->X, speed) == PlatformGridX(temp->X, speed) && PlatformGridY(this->Y, speed) == PlatformGridY(temp->Y, speed) && currentFFC != t1)
					{
						PF_Snap(this, temp);
						direction = PF_Direction(temp, direction);
						speed = PF_Speed(temp, speed);
						rate = speed % 1;
						accel = 0;
						if(PF_Teleport(temp, this))
							PF_Delay(this, delay);
						currentFFC = t1;
					}
				}
				
				//Move Platform.
				accel += PF_Move(this, direction, speed, accel, rate);
				accel %= 1;
				
				Waitframe();
			}
		}
		else //Type 0: Changer
		{
			while(true)
				Waitframe();
		}
	}
}

int PlatformGridX(int x, float speed)
{
	if(x % 0.25 == 0 && speed < 1)
		return x;
	else
		return (x >> 2) << 2;
}

int PlatformGridY(int y, float speed)
{
	if(y % 0.25 == 0 && speed < 1)
		return y;
	else
		return (y >> 2) << 2;
}

void PF_Snap(ffc this, ffc temp)
{
	int X = this->X;
	int Y = this->Y;
	
	//Snap to changer.
	this->X = temp->X;
	this->Y = temp->Y;
	if(PF_onplatform)
	{
		Link->X += this->X - X;
		Link->Y += this->Y - Y;
	}
}

void PF_Delay(ffc this, int delay)
{
	for(int t1 = delay; t1 > 0; t1--)
	{
		//Update and check for collision.
		if(RectCollision(Link->X+6, Link->Y+8, Link->X+10, Link->Y+16, this->X, this->Y, this->X+(16*this->TileWidth), this->Y+(16*this->TileHeight)))
			PF_onplatform = true;
		else
			PF_onplatform = false;
		Waitframe();
	}
}

int PF_Direction(ffc temp, int direction)
{
	int newdirection = temp->InitD[1];
	
	if(newdirection > -1)
		return newdirection;
	else
		return direction;
}

int PF_Speed(ffc temp, float speed)
{
	float newspeed = temp->InitD[2];
	
	if(newspeed > -1)
		return newspeed;
	else
		return speed;
}

bool PF_Teleport(ffc temp, ffc this)
{
	int type = temp->InitD[3];
	int newX = temp->InitD[4];
	int newY = temp->InitD[5];
	int width = this->TileWidth;
	int height = this->TileHeight;
	int teletime = 120; //time to teleport in frames.
	bool effect = temp->InitD[6];
	
	//2, Move platform and Link.
	if(type == 2)
	{
		PF_TeleEffect(this, newX, newY, width, height, 7, effect, true);
		if((Link->X+8 >= this->X && Link->X+8 <= this->X + this->EffectWidth) && (Link->Y+12 >= this->Y && Link->Y+12 <= this->Y + this->EffectHeight))
		{
			Link->X = newX + (this->X - Link->X);
			Link->Y = newY + (this->Y - Link->Y);
		}
		this->X = newX;
		this->Y = newY;
		return false;
	}
	//1, Move platform.
	else if(type == 1)
	{
		PF_TeleEffect(this, newX, newY, width, height, 8, effect, false);
		this->X = newX;
		this->Y = newY;
		return false;
	}
	//0, No teleport return
	else
		return true;
}

void PF_TeleEffect(ffc this, int newX, int newY, int width, int height, int color, bool effect, bool movelink)
{
	int t1;
	if(movelink)
		Link->CollDetection = false;
	if(effect)
	{
		Game->PlaySound(TELESOUND);
		for(t1 = TELETIME; t1 > 0; t1--)
		{
			if(effect)
			{
				Screen->DrawCombo(TELELAYER, this->X, this->Y, TELECOMBO, width, height, color, -1, -1, 0, 0, 0, 1, 0, true, OP_TRANS);
				Screen->DrawCombo(TELELAYER, newX, newY, TELECOMBO, width, height, color, -1, -1, 0, 0, 0, 1, 0, true, OP_TRANS);
			}
			if(movelink)
				WaitNoAction();
			else
				Waitframe();
		}
	}
	if(movelink)
		Link->CollDetection = true;
}

float PF_Move(ffc this, int direction, float speed, float accel, float rate)
{
	//Move Platform.
	if(direction == DIR_UP)
		this->Y -= speed;
	else if(direction == DIR_DOWN)
		this->Y += speed;
	else if(direction == DIR_LEFT)
		this->X -= speed;
	else
		this->X += speed;
		
	//Move Link.
	if((Link->X+8 >= this->X && Link->X+8 <= this->X + this->EffectWidth) && (Link->Y+12 >= this->Y && Link->Y+12 <= this->Y + this->EffectHeight) && Link->Z <= 0)
	{
		moveLink(direction, Floor(speed+accel), true, true);
		return rate;
	}
	else
		return 0;
}

//=======================================Shutter Doors============================================
//D0 side of screen the door is located on. Use directions from std_constants.
//D1 Link's Pos in pixels before Door will close. Link will be moved a further 16px first then the door will shut.
//D2-3 Combo location on the screen. use -1 if combo is not used.
//D4-5 Combo used for shutter door. use -1 if combo is not used.
//D6 Extra pixels to move Link. When the Door shuts Link is moved 16px first then this value.
//D7 Secrets will open this door. 0 will open. 1 will not open. !!REMINDER: standard secret combo setup is still required!!
ffc script shutterdoor{
	void run(int Side, int Distance, int Door1_L, int Door2_L, int Door1_C, int Door2_C, int ExtraDis, int Perm){
		Waitframe(); //Wait one frame to let the screen load.
		
		while(!Screen->State[ST_SECRET] || Perm == 1){
			if(Side == 0){ //Up
				if(CenterLinkY() > Distance){
					for(int a = CenterLinkY(); a < Distance + 16 + ExtraDis; a++){
						moveLink(DIR_DOWN, 1, true, true);
						WaitNoAction();
					}//end for
					if(Door1_L > -1) SetLayerComboD(0, Door1_L, Door1_C);
					if(Door2_L > -1) SetLayerComboD(0, Door2_L, Door2_C);
					Game->PlaySound(77);
					PF_stored = false;
					Quit(); //Unload FFC
				}//end if
			}//end if
			else if(Side == 1){ //Down
				if(CenterLinkY() < Distance){
					for(int a = CenterLinkY(); a > Distance - 16 - ExtraDis; a--){
						moveLink(DIR_UP, 1, true, true);
						WaitNoAction();
					}//end for
					if(Door1_L > -1) SetLayerComboD(0, Door1_L, Door1_C);
					if(Door2_L > -1) SetLayerComboD(0, Door2_L, Door2_C);
					Game->PlaySound(77);
					PF_stored = false;
					Quit(); //Unload FFC
				}//end if
			}//end else if
			else if(Side == 2){ //Left
				if(CenterLinkX() > Distance){
					for(int a = CenterLinkX(); a < Distance + 16 + ExtraDis; a++){
						moveLink(DIR_RIGHT, 1, true, true);
						WaitNoAction();
					}//end for
					if(Door1_L > -1) SetLayerComboD(0, Door1_L, Door1_C);
					if(Door2_L > -1) SetLayerComboD(0, Door2_L, Door2_C);
					Game->PlaySound(77);
					PF_stored = false;
					Quit(); //Unload FFC
				}//end if
			}//end else if
			else if(Side == 3){ //Right
				if(CenterLinkX() < Distance){
					for(int a = CenterLinkX(); a > Distance - 16 - ExtraDis; a--){
						moveLink(DIR_LEFT, 1, true, true);
						WaitNoAction();
					}//end for
					if(Door1_L > -1) SetLayerComboD(0, Door1_L, Door1_C);
					if(Door2_L > -1) SetLayerComboD(0, Door2_L, Door2_C);
					Game->PlaySound(77);
					PF_stored = false;
					Quit(); //Unload FFC
				}//end if
			}//end else if
			Waitframe();
		}//end while
	
	}
}


#9 Sparkster

Sparkster

    The Sparking Spark of ZC

  • Members
  • Gender:Unspecified

Posted 16 March 2017 - 03:18 AM

Double posting, because no one has answered my question, yet again!

 

Is there more stuff I need to copy from the ghost.zh folder to my global script?


Edited by Sparkster, 16 March 2017 - 03:19 AM.


#10 cavthena

cavthena

    Apprentice

  • Members
  • Real Name:Clayton
  • Gender:Male
  • Location:I wish I knew

Posted 17 March 2017 - 05:28 PM

Just the standard ghost stuff is what's required. You should refer to the ghost setup instructions for what you need to place in your global script.

 

I will point out that you have 2 waitdraw() functions in your global, you only need 1, not sure what happens when you have 2.



#11 Sparkster

Sparkster

    The Sparking Spark of ZC

  • Members
  • Gender:Unspecified

Posted 19 March 2017 - 03:36 AM

I have deleted the second waitdraw in the global script.

 

I made a test quest with the custom enemies that worked, but I still need to test your pitfall stuff, cav. I'll get back to this topic later, when I have some results.^^

 

EDIT: Sorry but the platform does not move link. Something wrong in this script?


Edited by Sparkster, 19 March 2017 - 04:07 AM.


#12 cavthena

cavthena

    Apprentice

  • Members
  • Real Name:Clayton
  • Gender:Male
  • Location:I wish I knew

Posted 19 March 2017 - 05:26 PM

It should. I havn't heard of any other people having a problem with the platform and it's copied from the same one I'm using, which works fine. How are you setting them up?



#13 Sparkster

Sparkster

    The Sparking Spark of ZC

  • Members
  • Gender:Unspecified

Posted 20 March 2017 - 03:55 AM

I set up one platform FFC as a test.

 

  1. I assigned the FFC with the script slot "Platform"
  2. I set up the X Speed to 0.5
  3. I checked the flag "Run Script at Screen Init"
  4. I set up the D1 Argument to 1 to make it as a platform

I'm confused about the following D arguments.

 

FFC as platform:

D1: Delay at each corner in frames.

 

FFC as Changer:

D1: New direction. Use one of 4 standard directions. Use -1 for same direction. (What should I type? 0 for north, 1 for east,... etc.?)

D2: New Speed. Use -1 for same speed. (Why not changing the speed of the FFC in the data tab?)

 

 

With D4 and D5 I am sure what to type, but if I am doing something wrong, I'll report it.

 

I should have said this at the start of the topic but... I am using 2.50 Build 29.

 

Do you want my global script, too, to check?

//Constants for Pitfall
//Type PF_*
//Pits
const int PF_PIT_COMBO = 143; //Combo Type of pits.
const int PF_PIT_WARP = 98; //Flag for pit warping.
const int PF_LINK_FALL = 91; //LWeapon for Link falling.
const int PF_SFX_FALL = 61; //SFX for Link falling.
const int PF_PIT_DAMAGE = 8; //Damage from pits in 1/16ths of a heart.

//Lava
const int PF_LAVA_COMBO = 145; //Combo Type of lava.
const int PF_LINK_MELT = 92; //LWeapon for Link melting.
const int PF_SFX_MELT = 62; //SFX for Link melting.
const int PF_LAVA_DAMAGE = 16; //Damage from lava in 1/16ths of a heart.

//Teleporting
const int TELECOMBO = 928; //Combo of the teleport effect. upto 3x3.
const int TELETIME = 120; //Length of the teleport animation in frames.
const int TELELAYER = 3; //Layer to draw the effect on.
const int TELESOUND = 75; //SFX for effect.

//Globals ...Do Not Change...
int PF_curscreen = -1;
int PF_curmap = -1;
bool PF_stored = false;
bool PF_warp = false;
bool PF_onplatform = false;

//Global Loop
global script Active
{
	void run ()
	{
		while(true)
		{
			PitFall();
            		UpdateGhostZH1();
           		UpdateGhostZH2();
			Waitdraw(); //Waitdraw Here!
			Waitframe();
		}
	}
}
//=================================Pitfall=====================================================
void PF_Drawing(){
  //Add functions you need drawn here.
}

void PitFall(){

	int wait;

	//Grab current screen.
	if(PF_curscreen != Game->GetCurScreen() || PF_curmap != Game->GetCurMap()){
		PF_curscreen = Game->GetCurScreen();
		PF_curmap = Game->GetCurMap();
		PF_stored = false;
	}
	else if(Link->Action != LA_SCROLLING && !PF_stored && Link->Z <= 0){
		Link->Misc[2] = Link->X;
		Link->Misc[3] = Link->Y;
		PF_stored = true;
	}
	
	//if Link was warped.
	if(PF_warp){
		Link->Z = Link->Y;
		PF_warp = false;
		while(Link->Z > 0){
			PF_Drawing();
			WaitNoAction(); //Wait for Link to Land before continuing.
		}
		return;
	}
	
	//Check for Hookshot or platform.
	lweapon hook = LoadLWeaponOf(LW_HOOKSHOT);
	if(hook->isValid() || PF_onplatform) return;
	
	//Check for Pit Combo.
	if(Screen->ComboT[ComboAt(CenterLinkX(), CenterLinkY() + 4)] == PF_PIT_COMBO){
		NoAction();
		wait = PF_LinkSetup(PF_LINK_FALL, PF_SFX_FALL);
		while(wait > 0){
			PF_Drawing();
			wait--;
			WaitNoAction();
		}
		Link->Invisible = false;
		Link->CollDetection = true;
		if(Screen->ComboF[ComboAt(CenterLinkX(), CenterLinkY() + 4)] == PF_PIT_WARP){
			Link->PitWarp(Screen->GetSideWarpDMap(3), Screen->GetSideWarpScreen(3));
			PF_warp = true;
		}
		else{
			Link->HP -= PF_PIT_DAMAGE;
			Game->PlaySound(SFX_OUCH);
			Link->X = Link->Misc[2];
			Link->Y = Link->Misc[3];
		}
	}
	//Check for Lava Combo.
	else if(Screen->ComboT[ComboAt(CenterLinkX(), CenterLinkY() + 4)] == PF_LAVA_COMBO){
		NoAction();
		wait = PF_LinkSetup(PF_LINK_MELT, PF_SFX_MELT);
		while(wait > 0){
			PF_Drawing();
			wait--;
			WaitNoAction();
		}
		Link->Invisible = false;
		Link->CollDetection = true;
		Link->HP -= PF_LAVA_DAMAGE;
		Game->PlaySound(SFX_OUCH);
		Link->X = Link->Misc[2];
		Link->Y = Link->Misc[3];
	}
}

int PF_LinkSetup(int sprite, int sfx){

	//Snap Link to grid and make invisible.
	Link->Invisible = true;
	Link->CollDetection = false;
	Link->X = GridX(Link->X + 8);
	Link->Y = GridY(Link->Y + 12);
	
	//Create Dummy lweapon.
	lweapon dummy = CreateLWeaponAt(LW_SCRIPT1, Link->X, Link->Y);
	dummy->UseSprite(sprite);
	dummy->DeadState = dummy->NumFrames * dummy->ASpeed;
	dummy->CollDetection = false;
	
	//Play Sound sfx.
	Game->PlaySound(sfx);
	
	//return timer
	return dummy->NumFrames * dummy->ASpeed;

}

//========================================Platform========================================
//D0: Type: Changer (0) or Platform (1)
//D1: Delay at each corner in frames.
//D2: Wait for screen secrets. No(0) or Yes(1).

//if type 0.
		//D1 - 7 to use as data holders.
		//D1: New direction. Use one of 4 standard directions. Use -1 for same direction.
		//D2: New Speed. Use -1 for same speed.
		//D3: Platform teleports. No(0), Yes(1), Take Link(2).
		//D4: New X.
		//D5: New Y.
		//D6: TeleEffect. No Effect(0). Effect(1).

		
		
ffc script Platform
{
	void run(int type, int delay, bool secret)
	{
		int t1;
		int direction = 0;
		int scriptnum;
		int currentFFC = 0;
		float speed = 0;
		float rate;
		float accel = 0;
		
		ffc temp;
		
		int scriptname[] = "Platform";
	
		if(type == 1) //Type 1: Platform
		{
			scriptnum = Game->GetFFCScript(scriptname);
			if(secret == 1)
			{
				while(!Screen->State[ST_SECRET])
				{
					Waitframe();
				}
			}
			for(t1 = 0; t1 < delay; t1++)
			{
				//Update and check for collision.
				if(RectCollision(Link->X+6, Link->Y+8, Link->X+10, Link->Y+16, this->X, this->Y, this->X+(16*this->TileWidth), this->Y+(16*this->TileHeight)))
					PF_onplatform = true;
				else
					PF_onplatform = false;
				//Wait for delay.
				Waitframe();
			}
			
		//Start Loop
			while(true)
			{
				//Update and check for collision.
				if(RectCollision(Link->X+6, Link->Y+8, Link->X+10, Link->Y+16, this->X, this->Y, this->X+(16*this->TileWidth), this->Y+(16*this->TileHeight)))
					PF_onplatform = true;
				else
				{
					PF_onplatform = false;
					rate = speed % 1;
				}
					
				//Check for flags.
				for(t1 = 32; t1 > 0; t1--)
				{
					temp = Screen->LoadFFC(t1);
					if(temp->Script == scriptnum && temp->InitD[0] == 0 && PlatformGridX(this->X, speed) == PlatformGridX(temp->X, speed) && PlatformGridY(this->Y, speed) == PlatformGridY(temp->Y, speed) && currentFFC != t1)
					{
						PF_Snap(this, temp);
						direction = PF_Direction(temp, direction);
						speed = PF_Speed(temp, speed);
						rate = speed % 1;
						accel = 0;
						if(PF_Teleport(temp, this))
							PF_Delay(this, delay);
						currentFFC = t1;
					}
				}
				
				//Move Platform.
				accel += PF_Move(this, direction, speed, accel, rate);
				accel %= 1;
				
				Waitframe();
			}
		}
		else //Type 0: Changer
		{
			while(true)
				Waitframe();
		}
	}
}

int PlatformGridX(int x, float speed)
{
	if(x % 0.25 == 0 && speed < 1)
		return x;
	else
		return (x >> 2) << 2;
}

int PlatformGridY(int y, float speed)
{
	if(y % 0.25 == 0 && speed < 1)
		return y;
	else
		return (y >> 2) << 2;
}

void PF_Snap(ffc this, ffc temp)
{
	int X = this->X;
	int Y = this->Y;
	
	//Snap to changer.
	this->X = temp->X;
	this->Y = temp->Y;
	if(PF_onplatform)
	{
		Link->X += this->X - X;
		Link->Y += this->Y - Y;
	}
}

void PF_Delay(ffc this, int delay)
{
	for(int t1 = delay; t1 > 0; t1--)
	{
		//Update and check for collision.
		if(RectCollision(Link->X+6, Link->Y+8, Link->X+10, Link->Y+16, this->X, this->Y, this->X+(16*this->TileWidth), this->Y+(16*this->TileHeight)))
			PF_onplatform = true;
		else
			PF_onplatform = false;
		Waitframe();
	}
}

int PF_Direction(ffc temp, int direction)
{
	int newdirection = temp->InitD[1];
	
	if(newdirection > -1)
		return newdirection;
	else
		return direction;
}

int PF_Speed(ffc temp, float speed)
{
	float newspeed = temp->InitD[2];
	
	if(newspeed > -1)
		return newspeed;
	else
		return speed;
}

bool PF_Teleport(ffc temp, ffc this)
{
	int type = temp->InitD[3];
	int newX = temp->InitD[4];
	int newY = temp->InitD[5];
	int width = this->TileWidth;
	int height = this->TileHeight;
	int teletime = 120; //time to teleport in frames.
	bool effect = temp->InitD[6];
	
	//2, Move platform and Link.
	if(type == 2)
	{
		PF_TeleEffect(this, newX, newY, width, height, 7, effect, true);
		if((Link->X+8 >= this->X && Link->X+8 <= this->X + this->EffectWidth) && (Link->Y+12 >= this->Y && Link->Y+12 <= this->Y + this->EffectHeight))
		{
			Link->X = newX + (this->X - Link->X);
			Link->Y = newY + (this->Y - Link->Y);
		}
		this->X = newX;
		this->Y = newY;
		return false;
	}
	//1, Move platform.
	else if(type == 1)
	{
		PF_TeleEffect(this, newX, newY, width, height, 8, effect, false);
		this->X = newX;
		this->Y = newY;
		return false;
	}
	//0, No teleport return
	else
		return true;
}

void PF_TeleEffect(ffc this, int newX, int newY, int width, int height, int color, bool effect, bool movelink)
{
	int t1;
	if(movelink)
		Link->CollDetection = false;
	if(effect)
	{
		Game->PlaySound(TELESOUND);
		for(t1 = TELETIME; t1 > 0; t1--)
		{
			if(effect)
			{
				Screen->DrawCombo(TELELAYER, this->X, this->Y, TELECOMBO, width, height, color, -1, -1, 0, 0, 0, 1, 0, true, OP_TRANS);
				Screen->DrawCombo(TELELAYER, newX, newY, TELECOMBO, width, height, color, -1, -1, 0, 0, 0, 1, 0, true, OP_TRANS);
			}
			if(movelink)
				WaitNoAction();
			else
				Waitframe();
		}
	}
	if(movelink)
		Link->CollDetection = true;
}

float PF_Move(ffc this, int direction, float speed, float accel, float rate)
{
	//Move Platform.
	if(direction == DIR_UP)
		this->Y -= speed;
	else if(direction == DIR_DOWN)
		this->Y += speed;
	else if(direction == DIR_LEFT)
		this->X -= speed;
	else
		this->X += speed;
		
	//Move Link.
	if((Link->X+8 >= this->X && Link->X+8 <= this->X + this->EffectWidth) && (Link->Y+12 >= this->Y && Link->Y+12 <= this->Y + this->EffectHeight) && Link->Z <= 0)
	{
		moveLink(direction, Floor(speed+accel), true, true);
		return rate;
	}
	else
		return 0;
}

//=======================================Shutter Doors============================================
//D0 side of screen the door is located on. Use directions from std_constants.
//D1 Link's Pos in pixels before Door will close. Link will be moved a further 16px first then the door will shut.
//D2-3 Combo location on the screen. use -1 if combo is not used.
//D4-5 Combo used for shutter door. use -1 if combo is not used.
//D6 Extra pixels to move Link. When the Door shuts Link is moved 16px first then this value.
//D7 Secrets will open this door. 0 will open. 1 will not open. !!REMINDER: standard secret combo setup is still required!!
ffc script shutterdoor{
	void run(int Side, int Distance, int Door1_L, int Door2_L, int Door1_C, int Door2_C, int ExtraDis, int Perm){
		Waitframe(); //Wait one frame to let the screen load.
		
		while(!Screen->State[ST_SECRET] || Perm == 1){
			if(Side == 0){ //Up
				if(CenterLinkY() > Distance){
					for(int a = CenterLinkY(); a < Distance + 16 + ExtraDis; a++){
						moveLink(DIR_DOWN, 1, true, true);
						WaitNoAction();
					}//end for
					if(Door1_L > -1) SetLayerComboD(0, Door1_L, Door1_C);
					if(Door2_L > -1) SetLayerComboD(0, Door2_L, Door2_C);
					Game->PlaySound(77);
					PF_stored = false;
					Quit(); //Unload FFC
				}//end if
			}//end if
			else if(Side == 1){ //Down
				if(CenterLinkY() < Distance){
					for(int a = CenterLinkY(); a > Distance - 16 - ExtraDis; a--){
						moveLink(DIR_UP, 1, true, true);
						WaitNoAction();
					}//end for
					if(Door1_L > -1) SetLayerComboD(0, Door1_L, Door1_C);
					if(Door2_L > -1) SetLayerComboD(0, Door2_L, Door2_C);
					Game->PlaySound(77);
					PF_stored = false;
					Quit(); //Unload FFC
				}//end if
			}//end else if
			else if(Side == 2){ //Left
				if(CenterLinkX() > Distance){
					for(int a = CenterLinkX(); a < Distance + 16 + ExtraDis; a++){
						moveLink(DIR_RIGHT, 1, true, true);
						WaitNoAction();
					}//end for
					if(Door1_L > -1) SetLayerComboD(0, Door1_L, Door1_C);
					if(Door2_L > -1) SetLayerComboD(0, Door2_L, Door2_C);
					Game->PlaySound(77);
					PF_stored = false;
					Quit(); //Unload FFC
				}//end if
			}//end else if
			else if(Side == 3){ //Right
				if(CenterLinkX() < Distance){
					for(int a = CenterLinkX(); a > Distance - 16 - ExtraDis; a--){
						moveLink(DIR_LEFT, 1, true, true);
						WaitNoAction();
					}//end for
					if(Door1_L > -1) SetLayerComboD(0, Door1_L, Door1_C);
					if(Door2_L > -1) SetLayerComboD(0, Door2_L, Door2_C);
					Game->PlaySound(77);
					PF_stored = false;
					Quit(); //Unload FFC
				}//end if
			}//end else if
			Waitframe();
		}//end while
	
	}
}


#14 Sparkster

Sparkster

    The Sparking Spark of ZC

  • Members
  • Gender:Unspecified

Posted 27 March 2017 - 02:18 AM

No answer?

 

Guess I have to double post one more time. Maybe I should leave out my script code to avoid waiting...

 

I'm repeating once again.

 

 

I set up one platform FFC as a test.

 

  1. I assigned the FFC with the script slot "Platform"
  2. I set up the X Speed to 0.5
  3. I checked the flag "Run Script at Screen Init"
  4. I set up the D1 Argument to 1 to make it as a platform

I'm confused about the following D arguments.

 

FFC as platform:

D1: Delay at each corner in frames.

 

FFC as Changer:

D1: New direction. Use one of 4 standard directions. Use -1 for same direction. (What should I type? 0 for north, 1 for east,... etc.?)

D2: New Speed. Use -1 for same speed. (Why not changing the speed of the FFC in the data tab?)

 

 

With D4 and D5 I am sure what to type, but if I am doing something wrong, I'll report it.

 

I should have said this at the start of the topic but... I am using 2.50 Build 29.



#15 cavthena

cavthena

    Apprentice

  • Members
  • Real Name:Clayton
  • Gender:Male
  • Location:I wish I knew

Posted 27 March 2017 - 09:10 AM

D1: Delay, is the number of frames to wait at each changer. The platform will stop and wait until the number of frames passes. Pass 0 if you do not want the platform to stop.

Changer:
D1: directions are based off of the DIR_ directions found in std constants. 4 standard directions are up, down, left and right.

D2: sets the new speed of the platform when it hits this changer. Each changer can have a different speed. If -1 is passed then the speed will not change from what it currently is. Note passing 0 is a speed of 0 so your platform will not move.

Speed is controlled by the code and not the ffc velocity for collision reasons.

Keep in mind that changers are FFCs placed on screen. In order for a changer to work they need to collide with the top left corner of the platform. In order to ensure best results place the FFC on grid.



Also tagged with one or more of these keywords: Global, Script, combine, FFC, Solid

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users