Jump to content

Photo

Problem with the barriers scripts


  • Please log in to reply
20 replies to this topic

#1 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 28 October 2017 - 05:18 PM

Hello everyone. I do need a help. I used the barrier script and i did combined correctly the script however it does nothing. I hit the switch and nothing happens. I wondering if the barrier script is outdated / incompatible for ZC version 2.5.2... On the previous version on a tested quest it was works perfectly (ether on the v 2.5.2 it work on the tested quest) but not on mine or another quests i do created. I wondering if i sould get the ffc barrier script without the global script because how the ways i do combine the global script it's simply not works... 

 

Someone can help me there ? 

 

 



#2 Ben

Ben

    a very grumpy

  • Members

Posted 29 October 2017 - 09:36 AM

First thing you should try is make a new save for your quest and test again. Changing the global script and then using an older save file that used an older version of the global script can break all kinds of things.

 

Second, you'd just have to double check you combined the scripts correctly...



#3 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 29 October 2017 - 09:53 AM

that what i did for the new save quest. However it's not possible for me to change the global script. I can only change the name for the global script but not more.



#4 Nightmeres

Nightmeres

    Defender

  • Members

Posted 29 October 2017 - 11:32 AM

Do you have notepad++? If not I recommend you get it.
And create something similar to this: https://imgur.com/gallery/k9Rbkbut with your scripts, also the script I gave you requires all of the headers shown in the picture. Then compile that file. Also make sure all of the scripts are in same folder


Edited by Nightmeres, 29 October 2017 - 11:37 AM.


#5 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 29 October 2017 - 07:53 PM

Hello everyone. I do need a help. I used the barrier script and i did combined correctly the script however it does nothing. I hit the switch and nothing happens. I wondering if the barrier script is outdated / incompatible for ZC version 2.5.2... On the previous version on a tested quest it was works perfectly (ether on the v 2.5.2 it work on the tested quest) but not on mine or another quests i do created. I wondering if i sould get the ffc barrier script without the global script because how the ways i do combine the global script it's simply not works...

Someone can help me there ?


The issue that you describe is too generic for anyone to help with as-is. Without seeing your full script, and possibly the quest (to see if you set up all of the combos properly), or if you assigned the ffc script component to a slot.

The database version of the barriers script needs to know to what slot you assign the ffc, before you compile it; which is a particularly bad idea when you submit a script to the database.

The version that I edited, and posted in Nightmere's thread, does not, and it also has a few other minor fixes. Try that; perhaps?

I would suspect that your the global script might be fine, but it is not loading the ffc script to screens.

Try looking for errors reported to allegro.log, too.

Edited by ZoriaRPG, 29 October 2017 - 07:56 PM.


#6 Nightmeres

Nightmeres

    Defender

  • Members

Posted 29 October 2017 - 08:50 PM

The issue that you describe is too generic for anyone to help with as-is. Without seeing your full script, and possibly the quest (to see if you set up all of the combos properly), or if you assigned the ffc script component to a slot.
The database version of the barriers script needs to know to what slot you assign the ffc, before you compile it; which is a particularly bad idea when you submit a script to the database.
The version that I edited, and posted in Nightmere's thread, does not, and it also has a few other minor fixes. Try that; perhaps?
I would suspect that your the global script might be fine, but it is not loading the ffc script to screens.
Try looking for errors reported to allegro.log, too.


I'm pryty shure he is using the one you gave me because I pmed it to him. He'll have to collaborate my thinking here though.

#7 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 30 October 2017 - 03:44 PM

Here the combined script i used for the barrier.

// Barriers
global script slot2 {
 void run() {
  // Initialize variables used to listen on screen changes
	int curscreen = -1;
	bool firstCheck = false; //leave this alone
        ffc follower;

        int followerX[15];
        int followerY[15];
 
        int switch_index;
 
  while (true) {
   // Keep track of screen changes
   // Run a Barrier script on every screen change
   if (Game->GetCurScreen() != curscreen) {
    curscreen = Game->GetCurScreen();
    Barriers_NewScreen();}
if(Link->Item[reqItem] == true){
                if(Link->Action != LA_SCROLLING && follower->Data==0){
                    follower = Screen->LoadFFC(ffcNumber);
                    follower->Data = firstFollowerCombo;
                    follower->CSet = csetOfFollower;
 
                    followerX[BAR_PASTX] = Link->X;
                    follower->X = Link->X;
                    followerY[BAR_PASTY] = Link->Y;
                    follower->Y = Link->Y;
 
                    for ( int i = 0; i < 13; i++ ){
                        followerX[i] = Link->X;
                        followerY[i] = Link->Y;
                    }
 
                    firstCheck = true;
                }
                if(Link->Action != LA_SCROLLING){
                    if((Link->InputUp || Link->InputDown || Link->InputRight || Link->InputLeft)&&(!(Link->InputA || Link->InputB))){
                        followerX[BAR_PASTX] = follower->X;
                        follower->X = followerX[0];
                        for(switch_index=0; switch_index<12; switch_index++){
                            followerX[switch_index] = followerX[switch_index + 1];
                        }
                        followerX[12] = Link->X;
 
                        followerY[BAR_PASTY] = follower->Y;
                        follower->Y = followerY[0];
                        for(switch_index=0; switch_index<12; switch_index++){
                            followerY[switch_index] = followerY[switch_index + 1];
                        }
                        followerY[12] = Link->Y;
                    }
 
                    if(follower->Y > followerY[BAR_PASTY]){
                        follower->Data = firstFollowerCombo + 5;
                    }
                    else if(follower->Y < followerY[BAR_PASTY]){
                        follower->Data = firstFollowerCombo + 4;
                    }
                    else if(follower->X > followerX[BAR_PASTX]){
                        follower->Data = firstFollowerCombo + 7;
                    }
                    else if(follower->X < followerX[BAR_PASTX]){
                        follower->Data = firstFollowerCombo + 6;
                    }
                    if(!(Link->InputUp || Link->InputDown || Link->InputRight || Link->InputLeft)){
                        if((follower->Data == (firstFollowerCombo + 4))||(follower->Data == (firstFollowerCombo + 5))||(follower->Data == (firstFollowerCombo + 6))||(follower->Data == (firstFollowerCombo + 7))){
                            follower->Data = follower->Data - 4;
                        }
                        else if((follower->Data == (firstFollowerCombo + 3))||(follower->Data == (firstFollowerCombo + 2))||(follower->Data == (firstFollowerCombo + 1))||(follower->Data == (firstFollowerCombo))){
                           
                        }
                        else{
                            follower->Data = firstFollowerCombo;
                        }
                    }
                }
                if(Link->Action == LA_SCROLLING){
                    firstCheck = false;
                }}
 
   Waitframe();}}}

// push wand script
const int RANGE = 256; // range in pixel
const int TILE_UP = 18206; // tiles for link using wand
const int TILE_DOWN = 18209;
const int TILE_LEFT = 18226;
const int TILE_RIGHT = 18229;
const int INV_COMBO_ID = 1;
const int WAND_TILE_UP = 1370;
const int WAND_TILE_DOWN = 1371;
const int WAND_TILE_LEFT = 1372;
const int WAND_TILE_RIGHT = 1373;


int push_combo;
int push_x;
int push_y;
int stored_x;
int stored_y;

item script PushingWand{
	void run(){
		Game->PlaySound(SFX_WAND);
		int dx = 0;
		int dy = 0;
		int x;
		int y;
		int loc;
		if(Link->Dir == DIR_UP) dy = -1;
		else if(Link->Dir == DIR_DOWN) dy = 1;
		else if(Link->Dir == DIR_LEFT) dx = -1;
		else if(Link->Dir == DIR_RIGHT) dx = 1;
		for(int i=0;i<RANGE;i++){
			x = Link->X + i*dx;
			y = Link->Y + i*dy;
			loc = ComboAt(x+8,y+8);
			if(!CanWalk(x,y,Link->Dir,1,false)){
				push_combo = 20;
				push_x = x - dx;
				push_y = y - dy;
				stored_x = Link->X;
				stored_y = Link->Y;
				ffc inv_ffc = Screen->LoadFFC(30);
				inv_ffc->Data = INV_COMBO_ID;
				inv_ffc->X = push_x;
				inv_ffc->Y = push_y;
				if(x>16 && y>16 && x+16<15*16 && y+16<10*16) {
					Link->X = push_x;
					Link->Y = push_y;
				}
				PushCombo();
				Quit();
			}
		}
	}
}

// outside global script

void PushCombo(){
	Link->Invisible = true;
	Link->CollDetection = false;
	DrawLinkWandTiles(Link->Dir);
	NoAction();
	int x = Link->X;
	int y = Link->Y;
	if(x>16 && y>16 && x+16<15*16 && y+16<10*16) {
		if(Link->Dir == DIR_UP) Link->InputUp = true;
		else if(Link->Dir == DIR_DOWN) Link->InputDown = true;
		else if(Link->Dir == DIR_LEFT) Link->InputLeft = true;
		else if(Link->Dir == DIR_RIGHT) Link->InputRight = true;
	}
	push_combo --;
}

void LinkBack(){
	Link->X = stored_x;
	Link->Y = stored_y;
	Link->CollDetection = true;
	Link->Invisible = false;
	ffc inv_ffc = Screen->LoadFFC(30);
	inv_ffc->Data = 0;
	push_combo --;
}

void DrawLinkWandTiles(int dir){
	int link_tile;
	int wand_tile;
	int dx = 0;
	int dy = 0;
	if(dir == DIR_UP) {
		link_tile = TILE_UP;
		wand_tile = WAND_TILE_UP;
		dy = -16;
	}
	else if(dir == DIR_DOWN) {
		link_tile = TILE_DOWN;
		wand_tile = WAND_TILE_DOWN;
		dy = 16;
	}
	else if(dir == DIR_LEFT) {
		link_tile = TILE_LEFT;
		wand_tile = WAND_TILE_LEFT;
		dx = -16;
	}
	else if(dir == DIR_RIGHT) {
		link_tile = TILE_RIGHT;
		wand_tile = WAND_TILE_RIGHT;
		dx = 16;
	}
	Screen->FastTile(1, stored_x,stored_y, link_tile, 6, 128);
	Screen->FastTile(1, stored_x+dx,stored_y+dy, wand_tile, 6, 128);
}


//Paste the global script you want to add in here
const int CMB_MINECART = 8868; //Combo of the minecart, first of 16
							   //1-4: Minecart, stationary, 4-way
							   //5-8: Minecart, moving, 4-way
							   //9-12: Minecart, front layer, 4-way
							   //13-16: Link riding in minecart, 4-way
const int CS_MINECART = 2;

const int CMB_MINECART_TRACK = 8860; //First of a set of 7 minecart track combos.
									 //Only these combos when placed on layer 0 will actually function as minecart tracks
									 //1: Up/Down
									 //2: Left/Right
									 //3: Right/Down
									 //4: Left/Down
									 //5: Right/Up
									 //6: Left/Up
									 //7: Exit pad
									 
const int SFX_MINECART = 91; //Looping sound of the minecart on the tracks
const int MINECART_SFX_FREQ = 30; //How often the sound loops
									 
const int MINECART_LINKYOFFSET = -10; //Offset Link's sprite is drawn at compared to the minecart

const int DAMAGE_MINECART_COLLISION = 8; //How much damage the minecart does when it hits enemies
const int LW_MINECART_DAMAGE = 2; //Weapon type the minecart's hitbox uses. LW_BEAM by default

int GBCart[80];
const int GBC_DIR = 65;
const int GBC_CURID = 66;
const int GBC_FIRSTLOAD = 67;
const int GBC_ACTIVEFFC = 68;

void Minecart_Init(){
	Link->DrawYOffset = 0;
	Link->CollDetection = true;
	GBCart[GBC_DIR] = -1;
	if(GBCart[GBC_FIRSTLOAD]==0){
		for(int i=0; i<64; i++){
			GBCart[i] = -1;
		}
		GBCart[GBC_FIRSTLOAD] = 1;
	}
}

void MooshPit_ResetEntry(){
MooshPit[MP_ENTRYX] = Link->X;
MooshPit[MP_ENTRYY] = Link->Y;
MooshPit[MP_ENTRYDMAP] = Game->GetCurDMap();
MooshPit[MP_ENTRYSCREEN] = Game->GetCurDMapScreen();
}

void Minecart_Update(){
	if(GBCart[GBC_DIR]>-1){
		int scr[] = "GBMinecart_FFC";
		Link->DrawYOffset = MINECART_LINKYOFFSET;
		Link->CollDetection = false;
		if(Link->Action==LA_SCROLLING){
			GBCart[GBC_ACTIVEFFC] = -1;
			Minecart_Draw(ScrollingLinkX(), ScrollingLinkY(), GBCart[GBC_DIR], true);
		}
		else if(GBCart[GBC_ACTIVEFFC]>0){
			ffc f = Screen->LoadFFC(GBCart[GBC_ACTIVEFFC]);
			if(f->Script==Game->GetFFCScript(scr)){
				Link->X = f->X;
				Link->Y = f->Y;
			}
		}
		if(Minecart_CountFFCs(Game->GetFFCScript(scr), GBCart[GBC_CURID])==0){
			ffc f = Screen->LoadFFC(GBCart[GBC_ACTIVEFFC]);
			if(f->Script!=Game->GetFFCScript(scr)||f->InitD[1]!=GBCart[GBC_CURID]){
				if(Link->X>=0&&Link->X<=240&&Link->Y>=0&&Link->Y<=160){
					int args[8];
					args[0] = GBCart[GBC_DIR];
					args[1] = GBCart[GBC_CURID];
					args[2] = 0;
					args[3] = 1;
					f = Screen->LoadFFC(RunFFCScript(Game->GetFFCScript(scr), args));
					f->CSet = CS_MINECART;
					GBCart[GBC_ACTIVEFFC] = FFCNum(f);
					f->Flags[FFCF_PRELOAD] = true;
					f->X = Link->X;
					f->Y = Link->Y;
				}
			}
		}
	}
}

int Minecart_CountFFCs(int scrpt, int id){
	int count;
	for(int i=1; i<=32; i++){
		ffc f = Screen->LoadFFC(i);
		if(f->Script==scrpt&&f->InitD[1]==id&&f->InitD[3]==1)
			count++;
	}
	return count;
}

void Minecart_Draw(int x, int y, int dir, bool linkInside){
	int layer = 2;
	if(ScreenFlag(1, 4))
		layer = 1;
	dir = Clamp(dir, 0, 3);
	if(linkInside){
		Screen->FastCombo(layer, x, y, CMB_MINECART+4+dir, CS_MINECART, 128);
		if(Link->Action==LA_WALKING||Link->Action==LA_NONE||Link->Action==LA_SCROLLING){
			Screen->FastCombo(layer, x, y+MINECART_LINKYOFFSET, CMB_MINECART+12+Link->Dir, 6, 128);
			Link->Invisible = true;
		}
		else
			Link->Invisible = false;
		Screen->FastCombo(4, x, y, CMB_MINECART+8+dir, CS_MINECART, 128);
	}
	else{
		Screen->FastCombo(layer, x, y, CMB_MINECART+dir, CS_MINECART, 128);
	}
}


ffc script GBMinecart_FFC{
	void run(int startDir, int ID, int start, int spawned){
		int ffcNum = FFCNum(this);
		int tempID;
		if(ID>0)
			tempID = Clamp(ID-1, 0, 63);
			
		if(GBCart[GBC_DIR]<=-1||GBCart[GBC_CURID]!=ID)
			this->Data = CMB_MINECART+startDir;
		else if(spawned==0){
			if(Link->X<=0||Link->X>=240||Link->Y<=0||Link->Y>=160){
				this->Data = 0;
				Quit();
			}
			else{
				GBCart[GBC_DIR] = -1;
				Waitframe();
			}
		}
		else{
			if(GBCart[GBC_ACTIVEFFC]==-1)
				GBCart[GBC_ACTIVEFFC] = ffcNum;
		}
		if(spawned==0&&GBCart[GBC_DIR]==-1&&ID>0){
			if(GBCart[tempID]==-1){
				if(start){
					GBCart[tempID] = Game->GetCurScreen();
				}
			}
			else if(GBCart[tempID]!=Game->GetCurScreen()&&GBCart[GBC_FIRSTLOAD]==1){
				this->Data = 0;
				Quit();
			}
		}
		int lastDir = startDir;
		int sfxCounter;
		lweapon hitbox;
		while(true){
			while(GBCart[GBC_DIR]==-1||GBCart[GBC_CURID]!=ID){
				this->Data = CMB_MINECART+startDir;
				if(Link->Y<this->Y)
					this->Flags[FFCF_OVERLAY] = true;
				else
					this->Flags[FFCF_OVERLAY] = false;
				if(GBMinecart_Collision(this)){
					this->Flags[FFCF_OVERLAY] = false;
					Link->Dir = AngleDir4(Angle(Link->X, Link->Y, this->X, this->Y));
					Link->Jump = 2;
					Game->PlaySound(SFX_JUMP);
					int angle = Angle(Link->X, Link->Y, this->X, this->Y+MINECART_LINKYOFFSET);
					int dist = Distance(Link->X, Link->Y, this->X, this->Y+MINECART_LINKYOFFSET);
					int linkX = Link->X;
					int linkY = Link->Y;
					for(int i=0; i<26; i++){
						linkX += VectorX(dist/26, angle);
						linkY += VectorY(dist/26, angle);
						Link->X = linkX;
						Link->Y = linkY;
						WaitNoAction();
					}
					Link->DrawYOffset = MINECART_LINKYOFFSET;
					Link->CollDetection = false;
					GBCart[GBC_DIR] = startDir;
					GBCart[GBC_CURID] = ID;
					GBCart[GBC_ACTIVEFFC] = FFCNum(this);
					sfxCounter = 0;
				}
				Waitframe();
			}
			while(GBCart[GBC_DIR]!=-1&&GBCart[GBC_CURID]==ID){		
				int cp = ComboAt(this->X+8, this->Y+8);
				lastDir = GBCart[GBC_DIR];
				GBCart[GBC_DIR] = GBMinecart_NextDirection(cp, GBCart[GBC_DIR]);
				for(int i=0; i<8; i++){
					if(sfxCounter==0)
						Game->PlaySound(SFX_MINECART);
						
					sfxCounter++;
					if(sfxCounter>MINECART_SFX_FREQ)
						sfxCounter = 0;
					if(GBCart[GBC_DIR]==DIR_UP)
						this->Y -= 2;
					else if(GBCart[GBC_DIR]==DIR_DOWN)
						this->Y += 2;
					else if(GBCart[GBC_DIR]==DIR_LEFT)
						this->X -= 2;
					else if(GBCart[GBC_DIR]==DIR_RIGHT)
						this->X += 2;
					hitbox = GBMinecart_UpdateHitbox(hitbox, this->X, this->Y, true);
					Minecart_Draw(this->X, this->Y, GBCart[GBC_DIR], true);
					Link->X = this->X;
					Link->Y = this->Y;
					Waitframe();
				}
				this->X = GridX(this->X+8);
				this->Y = GridY(this->Y+8);
				if(GBCart[GBC_DIR]<=-1){
					if(GBCart[GBC_DIR]<-1)
						lastDir = Abs(GBCart[GBC_DIR])-2;
					GBCart[GBC_DIR] = -1;
					this->Data = CMB_MINECART+lastDir;
				
					Link->DrawYOffset = 0;
					Link->Invisible = false;
					Link->CollDetection = true;
					cp = GBMinecart_ComboInFront(cp, lastDir);
					Link->Dir = AngleDir4(Angle(Link->X, Link->Y, ComboX(cp), ComboY(cp)));
					Link->Y += MINECART_LINKYOFFSET;
					Link->Jump = 2;
					Game->PlaySound(SFX_JUMP);
					int angle = Angle(Link->X, Link->Y, ComboX(cp), ComboY(cp));
					int dist = Distance(Link->X, Link->Y, ComboX(cp), ComboY(cp));
					int linkX = Link->X;
					int linkY = Link->Y;
					for(int i=0; i<26; i++){
						linkX += VectorX(dist/26, angle);
						linkY += VectorY(dist/26, angle);
						Link->X = linkX;
						Link->Y = linkY;
						hitbox = GBMinecart_UpdateHitbox(hitbox, this->X, this->Y, false);
						WaitNoAction();
					}
					startDir = OppositeDir(lastDir);
					if(GBCart[GBC_CURID]>0){
						tempID = Clamp(GBCart[GBC_CURID]-1, 0, 63);
						GBCart[tempID] = Game->GetCurScreen();
					}
                                        MooshPit_ResetEntry();
				}
			}
		}
	}
	int GBMinecart_NextDirection(int cp, int dir){
		int up[6]    = {1, 0, 0, 0, 1, 1};
		int down[6]  = {1, 0, 1, 1, 0, 0};
		int left[6]  = {0, 1, 0, 1, 0, 1};
		int right[6] = {0, 1, 1, 0, 1, 0};
		int directions[4] = {up, down, left, right};
		
		int c;
		
		//Combo under
		c = Screen->ComboD[cp];
		if(c>=CMB_MINECART_TRACK&&c<=CMB_MINECART_TRACK+5)
			c = Clamp(c-CMB_MINECART_TRACK, 0, 5);
		else
			c = -1;
			
		int frontDir = -1;
		int d = directions[dir];
		if(d[c]==1&&frontDir==-1){
			frontDir = dir;
		}
		else{
			for(int i=0; i<4; i++){
				if(i!=OppositeDir(dir)&&i!=dir){
					d = directions[i];
					if(d[c]==1){
						int c2 = Screen->ComboD[GBMinecart_ComboInFront(cp, i)];
						if(c2>=CMB_MINECART_TRACK&&c2<=CMB_MINECART_TRACK+5)
							return i;
						if(c2==CMB_MINECART_TRACK+6)
							return -2-i;
						else
							return OppositeDir(dir);
					}
				}
			}
		}
		
		c = Screen->ComboD[GBMinecart_ComboInFront(cp, dir)];
		if(c>=CMB_MINECART_TRACK&&c<=CMB_MINECART_TRACK+6)
			c = Clamp(c-CMB_MINECART_TRACK, 0, 6);
		else
			c = -1;
		if(c==-1)
			return OppositeDir(dir);
		else if(c==6)
			return -1;
			
		if(frontDir>-1)
			return frontDir;
		return dir;	
	}
	int GBMinecart_ComboInFront(int cp, int dir){
		if(cp<16&&dir==DIR_UP)
			return cp;
		else if(cp>159&&dir==DIR_DOWN)
			return cp;
		else if(cp%16==0&&dir==DIR_LEFT)
			return cp;
		else if(cp%16==15&&dir==DIR_RIGHT)
			return cp;
		if(dir==DIR_UP)
			cp -= 16;
		else if(dir==DIR_DOWN)
			cp += 16;
		else if(dir==DIR_LEFT)
			cp--;
		else if(dir==DIR_RIGHT)
			cp++;
		return cp;
	}
	bool GBMinecart_Collision(ffc this){
		if(Abs(Link->X-this->X)<12&&Abs(Link->Y-this->Y)<10)
			return true;
		return false;
	}
	lweapon GBMinecart_UpdateHitbox(lweapon hitbox, int x, int y, bool alive){
		if(hitbox->isValid()){
			hitbox->X = x;
			hitbox->Y = y;
			hitbox->Dir = GBCart[GBC_DIR];
			hitbox->Step = 0;
			hitbox->DeadState = -1;
			hitbox->DrawYOffset = -1000;
			if(!alive){
				hitbox->DeadState = 0;
			}
		}
		else{
			if(alive){
				hitbox = CreateLWeaponAt(LW_MINECART_DAMAGE, x, y);
				hitbox->Dir = GBCart[GBC_DIR];
				hitbox->Damage = DAMAGE_MINECART_COLLISION;
				hitbox->Step = 0;
				hitbox->DeadState = -1;
				hitbox->DrawYOffset = -1000;
			}
		}
		return hitbox;
	}
}

ffc script GBMinecart_Shutter{
	void run(){
		int thisData = this->Data;
		int thisCSet = this->CSet;
		this->Data = FFCS_INVISIBLE_COMBO;
		int cp = ComboAt(this->X+8, this->Y+8);
		int underCombo = Screen->ComboD[cp];
		int underCSet = Screen->ComboC[cp];
		int LinkX = Link->X;
		if(LinkX<=0)
			LinkX = 240;
		else if(LinkX>=240)
			LinkX = 0;
		int LinkY = Link->Y;
		if(LinkY<=0)
			LinkY = 160;
		else if(LinkY>=160)
			LinkY = 0;
		if(!(Abs(this->X-LinkX)<20&&Abs(this->Y-LinkY)<20)){
			Screen->ComboD[cp] = thisData;
			Screen->ComboC[cp] = thisCSet;
			while(GBCart[GBC_DIR]==-1||!(Abs(this->X-Link->X)<20&&Abs(this->Y-Link->Y)<20)){
				Waitframe();
			}
			Game->PlaySound(SFX_SHUTTER);
			Screen->ComboD[cp] = underCombo;
			Screen->ComboC[cp] = underCSet;
			this->Data = thisData+1;
			this->CSet = thisCSet;
			Waitframes(4);
			this->Data = FFCS_INVISIBLE_COMBO;
		}
		else{
			Waitframe();
			
		}
		while(true){
			while(GBCart[GBC_DIR]>-1&&(Abs(this->X-Link->X)<20&&Abs(this->Y-Link->Y)<20)){
				Waitframe();
			}
			Game->PlaySound(SFX_SHUTTER);
			this->Data = thisData+1;
			this->CSet = thisCSet;
			Waitframes(4);
			Screen->ComboD[cp] = thisData;
			Screen->ComboC[cp] = thisCSet;
			this->Data = FFCS_INVISIBLE_COMBO;
			while(GBCart[GBC_DIR]==-1||!(Abs(this->X-Link->X)<20&&Abs(this->Y-Link->Y)<20)){
				Waitframe();
			}
			Game->PlaySound(SFX_SHUTTER);
			Screen->ComboD[cp] = underCombo;
			Screen->ComboC[cp] = underCSet;
			this->Data = thisData+1;
			this->CSet = thisCSet;
			Waitframes(4);
			this->Data = FFCS_INVISIBLE_COMBO;
		}
	}
}

ffc script GBMinecart_ResetID{
	void run(int id1, int id2, int id3, int id4, int id5, int id6, int id7, int id8){
		if(Distance(Link->X, Link->Y, this->X, this->Y)<16){
			int ids[8];
			ids[0] = id1;
			ids[1] = id2;
			ids[2] = id3;
			ids[3] = id4;
			ids[4] = id5;
			ids[5] = id6;
			ids[6] = id7;
			ids[7] = id8;
			for(int i=0; i<8; i++){
				int tempID = Clamp(ids[i]-1, 0, 63);
				if(ids[i]>0)
					GBCart[tempID] = -1;
			}
		}
	}
}


const int SFX_GBSHIELD = 17; //Shield active SFX

int shieldItem; //Shield item to give (set by item script, reset each frame)
bool shieldButton; //False = B, True = A



global script SeedShooter_Example{
	void run(){
		LinkMovement_Init();
		while(true){
			LinkMovement_Update1();
			SeedShooter_Update();
			Waitdraw();
			LinkMovement_Update2();
			Waitframe();
		}
	}
}


global script DoSGlobalScript{
	void run(){

		//======== Mooshpit ========
		MooshPit_Init();
		//==========================
		
		//======== Ghost ========
		StartGhostZH();
		//=======================

		//=======================
		
		//======== Ice Combos ========
		//Setup variables for ice combos.
		Setup_IceCombos();
		//Variable that stores Game->GetCurScreen() the previous frame.
		int oldscreen = Game->GetCurScreen();
		//============================
		
		//======== Power Bracelet ========
		holding_block = 0;
		//================================
		
		ScrollingDraws_Init();
		Minecart_Init();
		//Initializations
		bool shieldOn;

		LinkMovement_Init();
		while(true){
		        
			//======== Mooshpit ========
			MooshPit_Update();
			//==========================
			
			//======== Ghost ========
			UpdateGhostZH1();
			//=======================
			
			//======== Power Bracelet ========
			PowerBracelet();
			//================================
			
			//======== Deku Leaf ========
			if(Link->Z == 0){
				if(!HitGround) Game->PlaySound(SFX_LAND);
				HitGround = true;
			}
			//Check if Link has the Deku Leaf LTM item.
			if(Link->Item[I_DEKULEAF_LTM]){
				//Increment Glide_Time if it's greater than or equal to 0;
				if(Glide_Time >= 0)  Glide_Time++;
				//Check if DEKU_DRAIN doesn't equal 0.
				if(DEKU_DRAIN != 0){
					//Increment draintimer and wrap it to DEKU_DRAIN. If it equals 0 after all that decrement MP.
					draintimer = (draintimer + 1) % DEKU_DRAIN;
					if(draintimer == 0) Link->MP--;
				}
				//If Glide_Time has reached DEKU_MAX_GLIDE_TIME or MP has reached 0 cancel the gliding by removing the LTM item.
				if(Glide_Time == DEKU_MAX_GLIDE_TIME || Link->MP == 0) Link->Item[I_DEKULEAF_LTM] = false;
				//Otherwise if not scrolling glide down to the ground.
				else if(Link->Action != LA_SCROLLING){
					looptimer = (looptimer + 1) % DEKU_LOOP;
					if(looptimer == 0) Game->PlaySound(SFX_GLIDE);
					DekuGlide();
				}
				//Check if Link just used the DekuLeaf and if so cancel the gliding by removing the LTM item.
				if(UsedItem(I_DEKULEAF) && DEKU_CANCELLABLE) Link->Item[I_DEKULEAF_LTM] = false;
				//Null the A and B buttons to prevent item use.
				Link->InputA = false;
				Link->InputB = false;
			}
			//===========================
			
			//======== Push Wand =========
			if(push_combo ==1) LinkBack();
			else if(push_combo > 0) PushCombo();
			//============================
			
			ScrollingDraws_Update();
			if( !shieldOn && shieldItem ){ //Enable shield when using dummy
				shieldOn=true; //Set shield state to on
				Link->Item[shieldItem]=true; //Give the shield
				Game->PlaySound(SFX_GBSHIELD); //Play the sound
			}
			else if( ( (shieldButton && !Link->InputA)||(!shieldButton && !Link->InputB)) //When button is released
					&& shieldOn){ //And shield is still on
				Link->Item[shieldItem]=false; //Remove shield
				shieldItem = 0; //Reset shield item variable
				shieldOn = false; //Set shield state to off
			}

			LinkMovement_Update1();
			SeedShooter_Update();
			Waitdraw(); //Only one of this
			
			//======== Ghost ========
			UpdateGhostZH2();
			//=======================
			
			//======== Ice Combos ========
			Update_IceCombos(oldscreen);
			oldscreen = Game->GetCurScreen();
			//============================
			
			Minecart_Update();

			LinkMovement_Update2();
			Waitframe(); //Only one of this
		}
	}
	//This function makes it appear that Link is holding the leaf overhead and makes him fall slower.
	void DekuGlide(){
		//Check Link's Z position and if it's less than or equal to 0 cancel the glide by removing the LTM item.
		if(Link->Z <= 0){
			Link_Z = 0;
			Link->Item[I_DEKULEAF_LTM] = 0;
		}
		//Otherwise load the itemdata of the LTM item and use it to draw the leaf on layer 4.
		else{
			itemdata id = Game->LoadItemData(I_DEKULEAF_LTM);
			Screen->FastTile(4, Link->X, Link->Y - Link_Z - 8, (id->InitD[0]*10) + Link->Dir, id->InitD[1], 128);
		}
		//Set Link's Z position to Link_Z and subtract Link_Z by GRAVITY2.
		Link->Z = Link_Z;
		Link_Z -= GRAVITY2;
	}
}

Here's the Nightmare's script 

const int CMB_FFC_INVIS = 1; //Combo higher than ID 0 with an invisible tile.

// ID's of barrier-related combos
// Barriers in raised state
const int BARRIER_A_RAISED           = 4048;
const int BARRIER_B_RAISED           = 4049;

// Barriers in lowered state
const int BARRIER_A_LOWERED          = 4050;
const int BARRIER_B_LOWERED          = 4051;

// Barriers animating to raised state
const int BARRIER_A_ANIMRAISE        = 4052;
const int BARRIER_B_ANIMRAISE        = 4053;

// Barriers animating to lowered state
const int BARRIER_A_ANIMLOWER        = 4054;
const int BARRIER_B_ANIMLOWER        = 4055;

// Raised barriers that Link can walk on
const int BARRIER_A_WALKABLE         = 4056;
const int BARRIER_B_WALKABLE         = 4057;

// Barrier switches
const int BARRIER_A_SWITCH           = 4058;
const int BARRIER_B_SWITCH           = 4059;

const int BARRIER_SWITCH_DUMMY = 177; // ID of a switch hit detection dummy enemy
const int BARRIER_SWITCH_DUMMY_HP = 32767;

// Global array to store the state of barriers per dmap
// If you have more than 16 dmaps you can change the capacity in the []'s
// You may change the states in other scripts, but the changes will not be visible
// until there is a new screen, so set them before Barriers_NewScreen() is called.
bool barriers[255]; // false = blue barriers raised, true = red barriers raised
 
 
const int ffcNumber = 85; //The number of the FFC used.  This script will "hijack" this one, so don't use it for anything else on screens when you expect the player to have a follower.
const int firstFollowerCombo = 4048; //combo of the first combo.  In order, the concecutive combos must be "still up", "still down", "still left", "still right", "moving up", "moving down", "moving left", "moving right".
const int csetOfFollower = 11;
const int reqItem = 158; //Item that makes the FFC follower follow you
const int BAR_PASTX = 14;
const int BAR_PASTY = 14;
 
// Function that makes preparations for barriers on each screen and starts an FFC script
void Barriers_NewScreen() {
 
 // Search for a barrier-related combo
 for (int i = 0; i <= 175; i++) {
  int cd = Screen->ComboD[i];
  if (cd == BARRIER_A_RAISED || cd == BARRIER_A_LOWERED || cd == BARRIER_A_SWITCH ||
      cd == BARRIER_B_RAISED || cd == BARRIER_B_LOWERED || cd == BARRIER_B_SWITCH) {
   // A barrier-related combo was found
 
   // Make initial changes to combos
   if (barriers[Game->GetCurLevel()]) {
    for (int j = i; j <= 175; j++) {
     int cd = Screen->ComboD[j];
     if (cd == BARRIER_A_RAISED) Screen->ComboD[j] = BARRIER_A_LOWERED;
     else if (cd == BARRIER_B_LOWERED) Screen->ComboD[j] = BARRIER_B_RAISED;
     else if (cd == BARRIER_A_SWITCH) Screen->ComboD[j] = BARRIER_B_SWITCH;}}
   else {
    for (int j = i; j <= 175; j++) {
     int cd = Screen->ComboD[j];
     if (cd == BARRIER_B_RAISED) Screen->ComboD[j] = BARRIER_B_LOWERED;
     else if (cd == BARRIER_A_LOWERED) Screen->ComboD[j] = BARRIER_A_RAISED;
     else if (cd == BARRIER_B_SWITCH) Screen->ComboD[j] = BARRIER_A_SWITCH;}}
   
   // So run FFCscript to control barriers
   int fif[]="Barriers";
	ffc f = Screen->LoadFFC(ffcNumber);
	f->Script = Game->GetFFCScript(fif);
	f->Data = CMB_FFC_INVIS;
	f->X = -100;
	f->Y = -100; 
        f->Flags[FFCF_PRELOAD] = true;
   break;}
}}
 
// This lets you toggle barriers on any dmap
bool ToggleBarriers(int dmap) {
 if (dmap == Game->GetCurLevel()) ToggleBarriers();
 else barriers[dmap] = !barriers[dmap];
 return barriers[dmap];}
 
// This toggles barriers on the current dmap
bool ToggleBarriers() {
 int curdmap = Game->GetCurLevel();
 if (!barriers[curdmap]) {
  barriers[curdmap] = true;
  for (int i = 0; i <= 175; i++) {
   int cd = Screen->ComboD[i];
   if (cd == BARRIER_A_RAISED || cd == BARRIER_A_WALKABLE || cd == BARRIER_A_ANIMRAISE) {
    Screen->ComboD[i] = BARRIER_A_ANIMLOWER;}
   else if (cd == BARRIER_B_LOWERED || cd == BARRIER_B_ANIMLOWER) {
    Screen->ComboD[i] = BARRIER_B_ANIMRAISE;}
   else if (cd == BARRIER_A_SWITCH) {Screen->ComboD[i] = BARRIER_B_SWITCH;}}}
 else {
  barriers[curdmap] = false;
  for (int i = 0; i <= 175; i++) {
   int cd = Screen->ComboD[i];
   if (cd == BARRIER_B_RAISED || cd == BARRIER_B_WALKABLE || cd == BARRIER_B_ANIMRAISE) {
    Screen->ComboD[i] = BARRIER_B_ANIMLOWER;}
   else if (cd == BARRIER_A_LOWERED || cd == BARRIER_A_ANIMLOWER) {
    Screen->ComboD[i] = BARRIER_A_ANIMRAISE;}
   else if (cd == BARRIER_B_SWITCH) {Screen->ComboD[i] = BARRIER_A_SWITCH;}}}
 
 return barriers[curdmap];
}
 
// This script controls barriers on the screen
// The FFC is automatically created by Barriers_NewScreen()
ffc script Barriers {
 void run() {
 
  // Initialize storage for bswitch hit dummies
  int bswitch_count;
  npc bswitch[8];
 
  for (int i = 0; i <= 175; i++) {
   if (Screen->ComboD[i] == BARRIER_A_SWITCH || Screen->ComboD[i] == BARRIER_B_SWITCH) {
    npc bs = CreateNPCAt(BARRIER_SWITCH_DUMMY, ComboX(i), ComboY(i));
    bs->HitWidth = 8; // Smaller hit box to avoid annoying collisions with Link
    bs->HitHeight = 8;
    bs->HP = BARRIER_SWITCH_DUMMY_HP;
    bswitch[bswitch_count++] = bs;}}
 
  // Change raised barriers to walkable ones if Link enters screen on a raised barrier
  int lcombo = LinkOnComboD();
  bool onbarrier = (lcombo == BARRIER_A_RAISED || lcombo == BARRIER_B_RAISED);
  if (onbarrier) for (int i = 0; i < 176; i++) {
   if (Screen->ComboD[i] == BARRIER_A_RAISED) {Screen->ComboD[i] = BARRIER_A_WALKABLE;}
   else if (Screen->ComboD[i] == BARRIER_B_RAISED) {Screen->ComboD[i] = BARRIER_B_WALKABLE;}}
 
 
  while (true) {
 
   // Detect hits on bswitches, and change combos accordingly
   for (int j = 0; j < bswitch_count; j++) {
    if (bswitch[j]->HP < BARRIER_SWITCH_DUMMY_HP) {
     bswitch[j]->HP = BARRIER_SWITCH_DUMMY_HP;
     ToggleBarriers();
     break;}} //break so that only one bswitch hit may register per frame
 
 
   // Make barriers walkable if Link is on raised barriers, or unwalkable if not
   lcombo = LinkOnComboD();
   if (!onbarrier && (lcombo == BARRIER_A_RAISED || lcombo == BARRIER_B_RAISED)) {
    onbarrier = true;
    for (int i = 0; i <= 175; i++) {
     if (Screen->ComboD[i] == BARRIER_A_RAISED) {Screen->ComboD[i] = BARRIER_A_WALKABLE;}
     else if (Screen->ComboD[i] == BARRIER_B_RAISED) {Screen->ComboD[i] = BARRIER_B_WALKABLE;}}}
   else if (onbarrier && !(lcombo == BARRIER_A_WALKABLE || lcombo == BARRIER_B_WALKABLE)) {
    onbarrier = false;
    for (int i = 0; i <= 175; i++) {
     if (Screen->ComboD[i] == BARRIER_A_WALKABLE) {Screen->ComboD[i] = BARRIER_A_RAISED;}
     else if (Screen->ComboD[i] == BARRIER_B_WALKABLE) {Screen->ComboD[i] = BARRIER_B_RAISED;}}}
 
   Waitframe();}
}}
 
 
 
// A utility function that returns the ID of the combo that Link appears to stand on
int LinkOnComboD() {
 return Screen->ComboD[ComboAt(Link->X+8, Link->Y+13)];
}


#8 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 30 October 2017 - 03:59 PM

Now here's the pics for the combo i did used for the script and the problem of the script.

 

2017-114.png

 

2017-116.png

I did put the game in pause just to show you what happens when i try to hit the switch with the sword: nothing happens. 

(sorry for multiple post something not allows me to post too long message here.


Edited by Sans, 30 October 2017 - 04:03 PM.


#9 Nightmeres

Nightmeres

    Defender

  • Members

Posted 30 October 2017 - 06:47 PM

do you remember what specific constants i had in the pm? try setting up your combos the same way. when i tried to change them round it didn't work, maybe it's the same with you. 



#10 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 30 October 2017 - 07:13 PM

ok



#11 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 30 October 2017 - 07:28 PM

Nope the same thing happens. i think the script is incompatible with my quests.



#12 judasrising

judasrising

    I play guitar

  • Members
  • Location:Sweden but born in Finland

Posted 04 November 2017 - 03:31 PM

Nope the same thing happens. i think the script is incompatible with my quests.

I can sure you that the barrier script will work with your questfile.



#13 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 04 November 2017 - 03:46 PM

but then why it's works on another quests and not mines ? :/



#14 judasrising

judasrising

    I play guitar

  • Members
  • Location:Sweden but born in Finland

Posted 05 November 2017 - 07:37 AM

but then why it's works on another quests and not mines ? :/

Okay what part does not work for you? I have that script setuped and fully working in its original form only alter i did was that it allows more Dmaps.....



#15 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 05 November 2017 - 10:19 AM

The part when Link try to hit the barrier switch with any weapons i got especially the sword. The barrier and the switch won't changes.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users