Jump to content

Photo

Help Combine Global scripts

Global

  • Please log in to reply
4 replies to this topic

#1 Aru

Aru

    Wandering Hero

  • Members
  • Real Name:Jordan
  • Location:wandering

Posted 16 October 2015 - 09:50 PM

I was wondering if someone could possibly help me combine these scripts together for some reason it keeps popping up with a error line 61: unexpected Lparen, expecting assign on token ( but for some reason when I try to fix it, it makes more problems I have already tried combining majority of this but combining pit and ghost is not fun.

//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 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                   = 101;  //The combo flag to register combos as pits.
const int CF_LAVA                  = 102;  //The combo flag to register combos as lava.
const int WPS_LINK_FALL            = 89;  //The weapon sprite to display when Link falls into a pit. "Sprite 88 by default"
const int WPS_LINK_LAVA            = 90;  //The weapon sprite to display when Link drowns in lava. "Sprite 89 by default"
const int SFX_LINK_FALL            = 38;  //The sound to play when Link falls into a pit. "SFX_FALL by default"
const int SFX_LINK_LAVA            = 55;  //The sound to play when Link drowns in Lava. "SFX_SPLASH by default.
const int CMB_AUTOWARP             = 48;  //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 slot_2{                           
    void run(){
    {
        StartGhostZH();
        
        while(true){
            UpdateGhostZH1();
        //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)
        {
            Waitdraw();
            UpdateGhostZH2();
            LREx1Ex2ItemSwitch();
if(Link->Action != LA_SCROLLING)
            {
                Update_HoleLava(startx, starty, olddmap, oldscreen, startdir);
                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;
                }
            }
            Waitframe();
        }//end whileloop
    }//end run
}//end global slot2

//Handles Pit Combo Functionality.
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 = dummy->DeadState;
        NoAction();
        Link->Action = LA_NONE;
    }
}
 
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);
}

void LREx1Ex2ItemSwitch()
{
	if (Link->PressL && Link->Action != LA_SCROLLING)
	{
		Link->SelectBWeapon(DIR_LEFT);
	}
	if (Link->PressR && Link->Action != LA_SCROLLING)
	{
		Link->SelectBWeapon(DIR_RIGHT);
	}
	if (Link->PressEx1 && Link->Action != LA_SCROLLING)
	{
		Link->SelectAWeapon(DIR_LEFT);
	}
	if (Link->PressEx2 && Link->Action != LA_SCROLLING)
	{
		Link->SelectAWeapon(DIR_RIGHT);
	}
    }
}


#2 Deedee

Deedee

    Bug Frog Dragon Girl

  • Moderators
  • Real Name:Deedee
  • Pronouns:She / Her, They / Them
  • Location:Canada

Posted 16 October 2015 - 11:23 PM

Combining pit and ghost is the simplest thing you can do. Before the while loop, put StartGhostZH, in the while(true) loop you put UpdateGhostZH1, and after the waitdraw inside the main loop you put UpdateGhostZH2. If there is no waitdraw in your script, you add one at the end of the while(true) loop. Don't create a new while loop if there is one :P

 

I think the holelava think might be a variable somewhere else in your script. I am not certain though.



#3 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 17 October 2015 - 12:56 AM

I didn't re-tab it. You had an extra lparen on line 21.
 

What a mess. :P

Cancel, cancel, cancel. I need to retab it. You have a few errors in there.

Here you are then...

//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 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                   = 101;  //The combo flag to register combos as pits.
const int CF_LAVA                  = 102;  //The combo flag to register combos as lava.
const int WPS_LINK_FALL            = 89;  //The weapon sprite to display when Link falls into a pit. "Sprite 88 by default"
const int WPS_LINK_LAVA            = 90;  //The weapon sprite to display when Link drowns in lava. "Sprite 89 by default"
const int SFX_LINK_FALL            = 38;  //The sound to play when Link falls into a pit. "SFX_FALL by default"
const int SFX_LINK_LAVA            = 55;  //The sound to play when Link drowns in Lava. "SFX_SPLASH by default.
const int CMB_AUTOWARP             = 48;  //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 slot_2{                           
	void run(){
		StartGhostZH();
		while(true){
			UpdateGhostZH1();
			//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;
			Waitdraw();
			UpdateGhostZH2();
			LREx1Ex2ItemSwitch();
			if(Link->Action != LA_SCROLLING)
			{
				Update_HoleLava(startx, starty, olddmap, oldscreen, startdir);
				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;
				}
			}
			Waitframe();
		}//end whileloop
	}//end run
}//end global slot2

//Handles Pit Combo Functionality.
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 = dummy->DeadState;
		NoAction();
		Link->Action = LA_NONE;
	}
}
 
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);
}

void LREx1Ex2ItemSwitch()
{
	if (Link->PressL && Link->Action != LA_SCROLLING)
	{
		Link->SelectBWeapon(DIR_LEFT);
	}
	if (Link->PressR && Link->Action != LA_SCROLLING)
	{
		Link->SelectBWeapon(DIR_RIGHT);
	}
	if (Link->PressEx1 && Link->Action != LA_SCROLLING)
	{
		Link->SelectAWeapon(DIR_LEFT);
	}
	if (Link->PressEx2 && Link->Action != LA_SCROLLING)
	{
		Link->SelectAWeapon(DIR_RIGHT);
	}
}

Edited by ZoriaRPG, 17 October 2015 - 01:04 AM.


#4 Aru

Aru

    Wandering Hero

  • Members
  • Real Name:Jordan
  • Location:wandering

Posted 17 October 2015 - 06:58 PM

Oh cool thanks so much Zoria it was confusing me so much what the problem was it compiled correctly.



#5 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 18 October 2015 - 02:08 AM

Oh cool thanks so much Zoria it was confusing me so much what the problem was it compiled correctly.

 

Not a problem. I might ask Mero if it'd be acceptable for me to condense the hole_lava routines into container functions. That'd make it easier for people to manage.

 

Spoiler

Edited by ZoriaRPG, 18 October 2015 - 02:18 AM.




Also tagged with one or more of these keywords: Global

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users