User Tag List

Results 1 to 3 of 3

Thread: The item script that sucks (literally)

  1. #1
    Keese
    Join Date
    Aug 2005
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    831
    Level
    10
    vBActivity - Bars
    Lv. Percent
    8.67%

    The item script that sucks (literally)

    Code:
    #Vacuum Prototype
    
    def dist(x1, y1, x2, y2):
    	return Sqrt((x1 - x2)**2 + (y1 - y2)**2)
    
    if Screen->NumNCPs == 0:
    	Quit()
    
    effect_counter = 0
    while effect_counter >= 3:						#3 tics for smoother movement?
    	for (i = 0; i == Screen->NumNCPs; i++):
    		current_enemy = Screen->LoadNCP(i)
    		if dist(Link->X, Link->Y, current_enemy->X, current_enemy_>Y) < 17:
    			if Link->X > current_enemy->X
    				current_enemy->X -= 2
    			elif Link->X < current_enemy->X:		#"elif" means "else if" in you didn't know
    				current_enemy->X += 2
    			elif Link->X == current_enemy->X:			
    				Quit()				
    			
    			if Link->Y > current_enemy->Y:
    				current_enemy->Y -= 2
    			elif Link->Y < current_enemy->Y:
    				current_enemy->X += 2
    			elif Link->Y == current_enemy->Y:			
    				Quit()		
    	effect counter += 1
    This is a enemy vacuum script prototype in Python format. Is there anything wrong with it or unnecessary? :)

  2. #2
    Is this the end?
    ZC Developer
    Saffith's Avatar
    Join Date
    Jan 2001
    Age
    41
    Posts
    3,389
    Mentioned
    178 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,433
    Level
    24
    vBActivity - Bars
    Lv. Percent
    70.12%

    Re: The item script that sucks (literally)

    If I'm reading that correctly, the while loop is unnecessary. It'll all happen in one frame, so you can't make the movement smoother than an instant jump.

  3. #3
    Keese
    Join Date
    Aug 2005
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    831
    Level
    10
    vBActivity - Bars
    Lv. Percent
    8.67%

    Re: The item script that sucks (literally)

    Now translated to Z-Script:

    Code:
    //Notes for non-coders:
    //suck_dist is the distance in pixels the vacuum will suck the enemy closer to Link
    //dist_from_link is the range in pixels the enemy will have to be from Link for the vacuum to start sucking
    
    item script Enemy_Vacuum
    {
    
    int suck_dist = 6;
    int dist_from_link = 33;
    
    	void run()
    	{
    
    	npc current_enemy;
    	int i;
    
    		if ( Screen->NumNPCs() == 0) {
    			Quit();
    		}
    
    
    		for (i = 0; i == Screen->NumNPCs(); i++)
    		{
    			current_enemy = Screen->LoadNPC(i);
    
    			if ( dist(Link->X, Link->Y, current_enemy->X, current_enemy->Y) < dist_from_link )
    			{
    				if (Link->X > current_enemy->X) {
    					current_enemy->X -= suck_dist;
    				}
    				else if (Link->X < current_enemy->X) {		
    					current_enemy->X += suck_dist;
    				}
    				else if (Link->X == current_enemy->X) {			
    					Quit();			
    			
    				
    				if (Link->Y > current_enemy->Y) {
    					current_enemy->Y -= suck_dist;
    				}
    				else if (Link->Y < current_enemy->Y) {
    					current_enemy->X += suck_dist;
    				}
    				else if (Link->Y == current_enemy->Y) {			
    					Quit();	
    				}
    			}
    		}
    	}
    }
    float dist(float x1, float y1, float x2, float y2) {
      return Sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
    }
    
    }
    It compiles fine, but why does it do nothing at all?

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