User Tag List

Results 1 to 6 of 6

Thread: Fairy Partner Script Help

  1. #1
    Gel
    Join Date
    Feb 2013
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    279
    Level
    6
    vBActivity - Bars
    Lv. Percent
    15.67%

    Question Fairy Partner Script Help

    Hi. I'm new here. I've actually played with ZC for a long time, just not very in depth....

    Anywho, I'm having trouble using Pkmnfrk's Fairy Partner script (found here).

    At first I had trouble compiling it, but I fixed the issue (DrawTile had an extra int added since the script's creation). However the script does not 'work'. Even if Link has the designated item (127), the fairy will not render.
    Not sure why, haha. If anyone would be willing to help that would be awesome.

    This is the script:
    Spoiler: show
    Code:
    //Fairy Partner
    int fairy_r = 0;
    int fairy_x = 0;
    int fairy_y = 0;
    int fairy_tx = 0;
    int fairy_ty = 0;
    int fairy_timer = 0;
    bool fairy_hidden = false;
    int prev_screen = 0;
    
    const int fairy_tile = 940;
    const int fairy_cset = 7;
    const int fairy_timer_cnt = 240;//60 * 4; //four seconds, or so
    
    int curScreen() {
    	return Game->GetCurDMapScreen()/1000 + Game->GetCurDMap();
    }
    
    global script slot2 {
    	void run() {
    		
    		fairy_x = Link->X;
    		fairy_y = Link->Y;
    		fairy_tx = Link->X;
    		fairy_ty = Link->Y;
    		fairy_timer = fairy_timer_cnt;
    		
    		while(true) {
    			if(Link->Item[129]) fairy();
    			
    			
    			
    			prev_screen = curScreen();
    			Waitframe();
    		}
    	}
    	
    	void fairy() {
    		//what is the fairy following?
    		
    		bool yes = false;
    		int draw_cset = fairy_cset;
    		
    		if(curScreen() != prev_screen) {
    			//we've warped or scrolled or something
    			//jump to position
    			fairy_x = Link->X + 8;
    			fairy_y = Link->Y + 8;
    		}
    		
    		//is there an enemy close by?
    		if(!yes) {
    			int lowest_id = -1;
    			int lowest_dist = 1024;
    			for(int i = 1; i <= Screen->NumNPCs(); i++) {
    				npc nme = Screen->LoadNPC(i);
    				//all this is basically "everything that isn't *really* a monster to be killed"
    				if( !(nme->ID <= NPC_ABEI2 || nme->ID == NPC_ENEMYFIRE || (nme->ID >= NPC_GLEEOK1FIRE && nme->ID <= NPC_GLEEOK4FIRE) || nme->ID == NPC_GOHMAFIRE || nme->ID == NPC_ITEMFAIRY || nme->ID == NPC_SHOOTFBALL || (nme->ID >= NPC_SHOOTMAGIC && nme->ID <= NPC_SHOOTFLAME2) || nme->ID == NPC_TRAP || (nme->ID >= NPC_TRAPHORIZLOS && nme->ID <= NPC_TRAPVERTC) || (nme->ID >= NPC_TRAP8WAY && nme->ID <= NPC_TRAPCCLOCKWISELOS))) {
    					int d = Distance(Link->X, Link->Y, nme->X, nme->Y);
    					if(d < 96 && d < lowest_dist) {
    						lowest_dist = d;
    						lowest_id = i;
    					}
    				}
    			}
    			
    			if(lowest_id != -1) {
    				npc nme = Screen->LoadNPC(lowest_id);
    				fairy_tx = nme->X + 8;
    				fairy_ty = nme->Y + 8;
    				yes = true;
    				draw_cset = fairy_cset + 1;
    				fairy_timer = fairy_timer_cnt;
    			}
    		}
    		
    		//what about an item?
    		if(!yes) {
    			int lowest_id = -1;
    			int lowest_dist = 1024;
    			for(int i = 1; i <= Screen->NumItems(); i++) {
    				item itm = Screen->LoadItem(i);
    				int d = Distance(Link->X, Link->Y, itm->X, itm->Y);
    				if(d < 96 && d < lowest_dist) {
    					lowest_dist = d;
    					lowest_id = i;
    				}
    			}
    			
    			if(lowest_id != -1) {
    				item itm = Screen->LoadItem(lowest_id);
    				fairy_tx = itm->X + 8;
    				fairy_ty = itm->Y + 8;
    				fairy_timer = fairy_timer_cnt;
    				yes = true;
    			}
    		}
    		
    		//perhaps there's a secret flag?
    		if(!yes) {
    			int lowest_id = -1;
    			int lowest_dist = 1024;
    			for(int i = 0; i < 160; i++) {
    				int f;
    				if(Screen->ComboF[i] != 0) {
    					f = Screen->ComboF[i];
    					if((f >= 1 && f <= 6) || (f >= 9 && f <= 11) || f == 13 || (f >= 47 && f <= 51) || (f >= 68 && f <= 90)) {
    						int d = Distance(Link->X, Link->Y, (i % 16) * 16, Floor(i / 16) * 16);
    						if(d < lowest_dist) {
    							lowest_dist = d;
    							lowest_id = i;
    						}
    					}
    				}
    				
    				if(Screen->ComboI[i] != 0) {
    					f = Screen->ComboI[i];
    					if((f >= 3 && f <= 6) || f == 11 || f == 13 || (f >= 68 && f <= 90)) {
    						int d = Distance(Link->X, Link->Y, (i % 16) * 16, Floor(i / 16) * 16);
    						if(d < lowest_dist) {
    							lowest_dist = d;
    							lowest_id = i;
    						}
    					}
    				}
    			}
    			
    			if(lowest_id != -1) {
    				fairy_tx = (lowest_id % 16) * 16 + 8;
    				fairy_ty = Floor(lowest_id / 16) * 16 + 8;
    				draw_cset = fairy_cset + (fairy_r % 3);
    				fairy_timer = fairy_timer_cnt;
    				yes = true;
    			}
    		}
    		
    		//dungeon door?
    		if(!yes) {
    			//I COULD do it closest, but I'd rather do this instead...
    			int side = Rand(3);
    			for(int i = 0; i < 4; i++) {
    				if(Screen->Door[side] == D_BOMB || Screen->Door[side] == D_WALKTHRU) {
    					yes = true;
    					fairy_timer = fairy_timer_cnt;
    					draw_cset = fairy_cset + (fairy_r % 3);
    					break;
    				}
    				
    				side++;
    				if(side == 4) {
    					side = 0;
    				}
    			}
    			
    			if(yes) {
    				if(side == DIR_UP) {
    					fairy_tx = 120; fairy_ty = 16;
    				} else if(side == DIR_DOWN) {
    					fairy_tx = 120; fairy_ty = 144;
    				} else if(side == DIR_LEFT) {
    					fairy_tx = 16; fairy_ty = 80;
    				} else if(side == DIR_RIGHT) {
    					fairy_tx = 224; fairy_ty = 80;
    				}
    			}
    			
    			
    		}
    		
    		if(!yes) { //default to Link
    			fairy_tx = Link->X + 8;
    			fairy_ty = Link->Y + 8;
    		}
    		
    		if(!yes) {
    			if(fairy_timer > 0) {
    				fairy_timer--;
    			}
    		}
    		
    		if(fairy_timer > 0 && fairy_hidden) {
    			fairy_hidden = false;
    		}
    		
    		if(fairy_x < fairy_tx) {
    			fairy_x++;
    		} else if(fairy_x > fairy_tx){
    			fairy_x--;
    		}
    		
    		if(fairy_y < fairy_ty) {
    			fairy_y++;
    		} else  if(fairy_y > fairy_ty){
    			fairy_y--;
    		}
    		
    		int fx = 0;fairy_x;
    		int fy = 0;fairy_y;
    		
    		
    		
    		fx = Sin(fairy_r * 4) * 16;
    		fy = Cos((fairy_r * 3)) * 16;
    		
    		if(fairy_timer < 60) {
    			float mod = fairy_timer;
    			mod /= 60;
    			fx *= mod;
    			fy *= mod;
    		}
    		
    		fairy_r += 1;
    		
    		if(fairy_timer == 0 && fx == 0 && fy == 0) {    //(fx == 45 || fairy_r == 225)) {
    			fairy_hidden = true;
    		}
    		
    		if(!fairy_hidden) {
    			if(fairy_r >= 360) fairy_r = 0;
    			
    			//Screen->DrawTile(4, fairy_x + fx - 8, fairy_x + fx - 8, fairy_tile + (fairy_r % 2), 1, 1, draw_cset, 1, 0, 0, 0, 0, true, 64);
    			Screen->DrawTile(4, fairy_x + fx - 8, fairy_x + fx - 8, fairy_tile + (fairy_r % 2), 1, 1, draw_cset, 1, 0, 0, 0, 0, 0, true, 64);
    		}
    	} 
    }


    Steps followed:
    Imported zscript, compiled, hit the << in global scripts with slot2 and active highlighted, hit okay, set item 127 in init data. No fairy.

    So yeah. Thanks in advanced.

  2. #2
    Username Kaiser SUCCESSOR's Avatar
    Join Date
    Jul 2000
    Location
    Winning.
    Age
    33
    Posts
    4,435
    Mentioned
    152 Post(s)
    Tagged
    7 Thread(s)
    vBActivity - Stats
    Points
    10,422
    Level
    30
    vBActivity - Bars
    Lv. Percent
    34.88%
    Make sure the required item is an equipment item.

    (Haven't looked at the script at all)

  3. #3
    Gel
    Join Date
    Feb 2013
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    279
    Level
    6
    vBActivity - Bars
    Lv. Percent
    15.67%
    Quote Originally Posted by SUCCESSOR View Post
    Make sure the required item is an equipment item.

    (Haven't looked at the script at all)
    It is in fact an equipment item.

  4. #4
    Username Kaiser SUCCESSOR's Avatar
    Join Date
    Jul 2000
    Location
    Winning.
    Age
    33
    Posts
    4,435
    Mentioned
    152 Post(s)
    Tagged
    7 Thread(s)
    vBActivity - Stats
    Points
    10,422
    Level
    30
    vBActivity - Bars
    Lv. Percent
    34.88%
    Well I looked at the script somewhat and I didn't notice anything that would prevent it from running. My guess is it is a small detail. Try adding some debug lines to the script.

  5. #5
    Gel
    Join Date
    Feb 2013
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    279
    Level
    6
    vBActivity - Bars
    Lv. Percent
    15.67%
    Unfortunately I don't know how... I guess I'll just do some tutorials on how to script and see if I can dissect it.

  6. #6
    Username Kaiser SUCCESSOR's Avatar
    Join Date
    Jul 2000
    Location
    Winning.
    Age
    33
    Posts
    4,435
    Mentioned
    152 Post(s)
    Tagged
    7 Thread(s)
    vBActivity - Stats
    Points
    10,422
    Level
    30
    vBActivity - Bars
    Lv. Percent
    34.88%
    Quote Originally Posted by Xavyrr View Post
    Unfortunately I don't know how... I guess I'll just do some tutorials on how to script and see if I can dissect it.
    Sorry, I just assumed. A debug line is just a simple line of code that checks to make sure one part of the script is working as it should. Like:

    Code:
    if(Link->Item[theitem])Game->Counter[CR_RUPEES]++;
    This line of code would cause rupees to increase every frame if Link has the right item. This way you know for a fact that Link has the item. Stuff like that.

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