User Tag List

Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 22

Thread: Magnetic Gloves

  1. #11
    Lynel
    ZC Developer
    pkmnfrk's Avatar
    Join Date
    Jan 2004
    Location
    Toronto
    Age
    37
    Posts
    1,248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    3,142
    Level
    18
    vBActivity - Bars
    Lv. Percent
    10.54%

    Re: Magnetic Gloves

    Check out this page about global scripts for information on how to combine them.

    I wish more people used my template for writing their global scripts, since everyone has to play along, but it should be easy to combine.

    In a nutshell, you need to paste all the functions (except main) below the main in the bombchu script. You also need to paste a single line somewhere in the bombchu script's "while(true)" loop (if it has one):

    Code:
    if(magna_gloves_active) MagnaGlovesWork();
    And, the global variables/constants go at the very top.
    Tale of the Cave - a web comic - Updates Monday, Wednesday, Friday
    ZC Tutorials - Tutorials and Script Library - Updated July 30, 2008
    ZeldaGuard - Corruption in my save files? It's more likely than you think!
    I do script requests!

  2. #12
    &&
    ZC Developer
    Joe123's Avatar
    Join Date
    Sep 2006
    Age
    32
    Posts
    3,061
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    7,303
    Level
    26
    vBActivity - Bars
    Lv. Percent
    8.73%

    Re: Magnetic Gloves

    Quote Originally Posted by pkmnfrk View Post
    I wish more people used my template for writing their global scripts
    I tried doing it like that, putting everything into a seperate void, but I found that I had lots of variables crossing over which I'd then have to declare globally and things, and in the end I decided it was too much hassle for not enough gain.

  3. #13
    Lynel
    ZC Developer
    pkmnfrk's Avatar
    Join Date
    Jan 2004
    Location
    Toronto
    Age
    37
    Posts
    1,248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    3,142
    Level
    18
    vBActivity - Bars
    Lv. Percent
    10.54%

    Re: Magnetic Gloves

    Well, take a look at how I did my script. Essentially, I just took everything that was in the while(true) loop, and plopped it into a separate function. That way, the main loop (which is public property) stays neat and clean, while retaining the ability to do whatever I want in my private property. That's what I advocate.
    Tale of the Cave - a web comic - Updates Monday, Wednesday, Friday
    ZC Tutorials - Tutorials and Script Library - Updated July 30, 2008
    ZeldaGuard - Corruption in my save files? It's more likely than you think!
    I do script requests!

  4. #14
    &&
    ZC Developer
    Joe123's Avatar
    Join Date
    Sep 2006
    Age
    32
    Posts
    3,061
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    7,303
    Level
    26
    vBActivity - Bars
    Lv. Percent
    8.73%

    Re: Magnetic Gloves

    I know, that's what I did.
    But if I then want variables to use in two different voids in the same global script, I can't declare them at script-scope, I have to declare them at global scope.
    I didn't want to do that

  5. #15
    Lynel
    ZC Developer
    pkmnfrk's Avatar
    Join Date
    Jan 2004
    Location
    Toronto
    Age
    37
    Posts
    1,248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    3,142
    Level
    18
    vBActivity - Bars
    Lv. Percent
    10.54%

    Re: Magnetic Gloves

    Well, that's also what I did.

    But, you know you can also pass parameters to functions, right?

    Code:
    void Foo() {
      Bar(1);
    }
    
    void Bar(int a) {
      Trace(a);
    }
    Tale of the Cave - a web comic - Updates Monday, Wednesday, Friday
    ZC Tutorials - Tutorials and Script Library - Updated July 30, 2008
    ZeldaGuard - Corruption in my save files? It's more likely than you think!
    I do script requests!

  6. #16
    &&
    ZC Developer
    Joe123's Avatar
    Join Date
    Sep 2006
    Age
    32
    Posts
    3,061
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    7,303
    Level
    26
    vBActivity - Bars
    Lv. Percent
    8.73%

    Re: Magnetic Gloves

    I do.

  7. #17
    Lynel
    ZC Developer
    pkmnfrk's Avatar
    Join Date
    Jan 2004
    Location
    Toronto
    Age
    37
    Posts
    1,248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    3,142
    Level
    18
    vBActivity - Bars
    Lv. Percent
    10.54%

    Re: Magnetic Gloves

    Well, then, someone's not understanding what the other person is saying.

    I'll take a look at your script, and see if I can fix it to fit in the template. In a few minutes.
    Tale of the Cave - a web comic - Updates Monday, Wednesday, Friday
    ZC Tutorials - Tutorials and Script Library - Updated July 30, 2008
    ZeldaGuard - Corruption in my save files? It's more likely than you think!
    I do script requests!

  8. #18
    &&
    ZC Developer
    Joe123's Avatar
    Join Date
    Sep 2006
    Age
    32
    Posts
    3,061
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    7,303
    Level
    26
    vBActivity - Bars
    Lv. Percent
    8.73%

    Re: Magnetic Gloves

    Code:
    ffc script example{
    	void run(){
    	int i;
    	npc e[10];
    	Waitframes(4);
    	LoadEnemies();
    		while(true){
    			for(i=0;i<10;i++) e[i]->Jump = 0;
    		Waitframe();
    		}
    	}
    	void LoadEnemies(){
    		for(i=0;i<10;i++) npc e[i] = Screen->LoadNPC(i+1);
    	}
    }
    Something like that for example wouldn't compile, because the npc and the integer are both declared only in void run, but not in void LoadEnemies.
    Passing an integer into a void as a parameter is one thing, but I can't exactly pass in an array of enemies, can I?

  9. #19
    Lynel
    ZC Developer
    pkmnfrk's Avatar
    Join Date
    Jan 2004
    Location
    Toronto
    Age
    37
    Posts
    1,248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    3,142
    Level
    18
    vBActivity - Bars
    Lv. Percent
    10.54%

    Re: Magnetic Gloves

    I dunno. I haven't tried using arrays for anything yet.

    But, anyway, I'm going over your script, and I'm already noticing a few problems. In a few places, you have loops inside the while() loop that will, while running, prevent other global scripts (such as my magna gloves script) from working.

    Let me finish going over it, and I'll show you how to best set it up.
    Tale of the Cave - a web comic - Updates Monday, Wednesday, Friday
    ZC Tutorials - Tutorials and Script Library - Updated July 30, 2008
    ZeldaGuard - Corruption in my save files? It's more likely than you think!
    I do script requests!

  10. #20
    Lynel
    ZC Developer
    pkmnfrk's Avatar
    Join Date
    Jan 2004
    Location
    Toronto
    Age
    37
    Posts
    1,248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    3,142
    Level
    18
    vBActivity - Bars
    Lv. Percent
    10.54%

    Re: Magnetic Gloves

    Code:
    import "std.zh"
    
    const int bombchuflag = 98; //Flag the bombchu can pass through (even if solid)
    const int bombchutile = 21752; //Set the tile for your weapon here. Up, Down, Left, Right it should be on the tilepage.
    const int bombchuframes = 2; //Set the number of animation frames here.
    const int bombchuaspeed = 10;//Set the animation speed here
    const int bombchucset = 7; //Set the CSet here
    	
    const int bombchudmg = 2;  //Set the damage here
    const int bombchuspeed = 1; //Set the speed of the bombchu here
    	
    int bombchuattack = 0;
    int bombchux = 0;
    int bombchuy = 0;
    int bdir = 0;
    
    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;
     int v = Screen->ComboS[ComboAt(x,y)]&mask;
     return v != 0;
    }
    
    bool bombchucheck(int x, int y){
    	if((isSolid(x,y) && Screen->ComboF[ComboAt(x,y)] != bombchuflag && Screen->ComboI[ComboAt(x,y)] != bombchuflag)
    	 || (Screen->ComboF[ComboAt(x,y)] == 6 || Screen->ComboI[ComboAt(x,y)] == 6 ||Screen->ComboF[ComboAt(x,y)] == 11 || Screen->ComboI[ComboAt(x,y)] == 11)) return true;
    }
    
    void noaction(){
    	Link->InputR = false;
    	Link->InputL = false;
    	Link->InputA = false;
    	Link->InputB = false;
    	Link->InputUp = false;
    	Link->InputDown = false;
    	Link->InputRight = false;
    	Link->InputLeft = false;
    }
    
    global script slot_2{
    	void run(){
    
    		while(true){
    			if(bombchuattack == 2) run_bombchu();
    			if(bombchuattack == 1) start_bombchu();
    			Waitframe();
    		}
    	}
    	
    	void run_bombchu() {
    		lweapon bombchu;
    		lweapon explosion;
    		int HP = 0;
    		bool found = false;
    		for(int i = 1; i <= Screen->NumLWeapons(); i+= 1) {
    			bombchu = Screen->LoadLWeapon(i);
    			if(bombchu->ID == LW_SCRIPT1) {
    				found = true;
    				HP = Link->HP;
    				if(Link->InputUp) bdir = 0;
    				if(Link->InputDown) bdir = 1;
    				if(Link->InputLeft) bdir = 2;
    				if(Link->InputRight) bdir = 3;
    				if(bdir == 0 && bombchucheck(bombchu->X+8,bombchu->Y+4)
    				|| (bdir == 1 && bombchucheck(bombchu->X+8,bombchu->Y+12))
    				|| (bdir == 2 && bombchucheck(bombchu->X+4,bombchu->Y+8))
    				|| (bdir == 3 && bombchucheck(bombchu->X+12,bombchu->Y+8))) bombchu->DeadState = 0;
    				bombchu->Dir = bdir;
    				bombchu->Tile = bombchutile+(bdir*bombchuframes);
    				bombchu->OriginalTile = bombchutile+(bdir*bombchuframes);
    				bombchux = bombchu->X;
    				bombchuy = bombchu->Y;
    				noaction();
    				if(Link->HP < HP) bombchu->DeadState = 0;
    				break;
    			}
    		}
    		
    		if(found == false) {
    			explosion = Screen->CreateLWeapon(LW_SBOMB);
    			explosion->Damage = bombchudmg;
    			explosion->X = bombchux;
    			explosion->Y = bombchuy;
    			
    			Link->Action = 0;
    			bombchuattack = 0;
    			
    		}
    	}
    	
    	void start_bombchu() {
    		if(Link->X > 15 && Link->X < 241 && Link->Y > 15 && Link->Y < 153){
    			lweapon bombchu = Screen->CreateLWeapon(LW_SCRIPT1);
    			bdir = Link->Dir;
    			bombchu->OriginalTile = bombchutile+(bdir*bombchuframes);
    			bombchu->Tile = bombchutile+(bdir*bombchuframes);
    			bombchu->NumFrames = bombchuframes;
    			bombchu->ASpeed = bombchuaspeed;
    			bombchu->CSet = bombchucset;
    			bombchux = 0; bombchuy = 0;
    			if(bdir>1) bombchux = (((bdir-2)*2)-1)*16;
    			if(bdir<2) bombchuy = ((bdir*2)-1)*16;
    			bombchu->X = Link->X+bombchux;
    			bombchu->Y = Link->Y+bombchuy;
    			bombchu->Step = bombchuspeed;
    			Link->Action = LA_ATTACKING;
    			Game->Counter[6]--;
    			bombchuattack = 2;
    		}else{
    			bdir = Link->Dir;
    			bombchux = 0; bombchuy = 0;
    			if(bdir>1) bombchux = (((bdir-2)*2)-1)*16;
    			if(bdir<2) bombchuy = ((bdir*2)-1)*16;
    			lweapon explosion = Screen->CreateLWeapon(LW_SBOMB);
    			explosion->X = Link->X+bombchux;
    			explosion->Y = Link->Y+bombchuy;
    			explosion->Damage = bombchudmg;
    			Link->Action = 0;
    			bombchuattack = 0;
    		}
    	}
    }
    
    global script slot_3{
    	void run(){
    		bombchuattack = 0;
    	}
    }
    
    item script bombchu{
    	void run(){
    		if(Game->Counter[6] > 0) bombchuattack = 1;
    	}
    }
    I changed a few things:

    * I turned all the variables you didn't want to be globals into globals, and made them constant. That's how you should do it.
    * For the ones I didn't make constant, I still had to move them out. There's no two ways about it.
    * I split the main script into two different scripts: start_bombchu(), which creates the bombchu, and run_bombchu() which handles its movement and death.
    * I changed bombchuattack from a bool to an int, so that the main loop knows which script to call. Check run() to see what I did.
    * I also made use of the LW_SCRIPT1 constant.
    Tale of the Cave - a web comic - Updates Monday, Wednesday, Friday
    ZC Tutorials - Tutorials and Script Library - Updated July 30, 2008
    ZeldaGuard - Corruption in my save files? It's more likely than you think!
    I do script requests!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social