User Tag List

Results 1 to 10 of 10

Thread: Laser Beamos script

  1. #1
    Gibdo beefster09's Avatar
    Join Date
    Mar 2006
    Age
    31
    Posts
    699
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    2,710
    Level
    16
    vBActivity - Bars
    Lv. Percent
    97.41%

    Laser Beamos script

    Instead of a stream of fireballs, it draws a line and a beam end. But I've run across a few problems. The beamos won't start his laser jet. Also note the commented Line function. I can't figure out how to get it through the compiler, so I commented it out.

    Anyway:
    Code:
    //-----Scripts for Beamos-----
    // When you are close enough, the beamos shoots
    // a laser at you. It draws a line representing
    // a laser shot from the beamos's eye. A damage
    // combo represents the tip of the laser.
    //----------------------------
    
    import "std.zh"
    
    //-----BeamosEye-----
    // This half determines when the beam should be fired
    //
    // D0 = The radius of the beamos's sight
    // D1 = The delay (in frames) waited before firing (I'd recommend 20)
    //-------------------
    
    ffc script BeamosEye{
    
    	void run(float radius, int maxdelay){
    
    		int currentdelay = 0; 	  // delay waited
    		bool delaystart = false;	// flag for start of delay
    		float xdist;				// used to find how close Link is
    		float ydist;				// same
    		float hdist;				// distance between Link and Eye
    
    		Screen->D[0] = 0;	       // link's xy position
    		Screen->D[1] = 0; 	  	// tells whether link is close enough
    		Screen->D[2] = this->X + ((this->Y/100)/100) + 8.0008; // xy of eye
    
    		while(true){
    
    			xdist = this->X - Link->X;
    			ydist = this->Y - Link->Y;
    			hdist = Sqrt(Pow(xdist, 2) + Pow(ydist, 2));
    			// ^Distance formula^
    
    			if((hdist <= radius) && (!delaystart)){
    
    				Trace(9);
    				Screen->D[0] = Link->X + ((Link->Y/100)/100);
    				delaystart = true;
    				currentdelay = 0;
    
    			} //end if
    
    			if((hdist > radius) && (Screen->D[1] == 1) || (delaystart)){
    
    				Screen->D[1] = 0;
    				delaystart = false;
    
    			} //end if
    
    			if(delaystart){
    
    				currentdelay += 1;
    
    			} //end if
    
    			if(currentdelay == maxdelay){
    
    				Screen->D[1] = 1;
    				
    			} //end if
    
    			Waitframe();
    
    		} //end while
    
    	} //end void
    
    } //end ffc script
    
    //--------Beam-------
    // This half draws the beam and follows Link
    //
    // D0 = Speed of the travelling beam
    // D1 = Color of the beam
    // D2 = Combo to be changed to when active
    //-------------------
    
    ffc script Beam{
    
    	void run(float speed, float beamcolor, int activecombo){
    
    		int passivecombo = this->Data; // combo for inactive beam
    		bool active = false;	// flag determining whether this is active
    		float xdist;			// xdelta of target
    		float ydist;			// ydelta of target
    		float xratio;		   // ratio between xdelta and ydelta
    		float yratio;		   // same
    		float hratio;		   // hypotenuse ratio
    		float tempxy;		   // xy of Beam
    
    		while(true){
    
    			// activation device
    			if((Screen->D[1] == 1) && (!active)){
    
    				this->X = Floor(Screen->D[0]);
    				this->X = Ceiling(Screen->D[0]) * 100 * 100;
    				active = true;
    				this->Data = activecombo;
    
    			} //end if
    
    			// moving device / line draw-er
    			if(active){
    
    				xratio = 1;
    				yratio = 1;
    
    				xdist = Link->X - this->X;
    				ydist = Link->Y - this->Y;
    				if(xdist > ydist){
    
    					xratio = xdist / ydist;
    
    				} // end if				
    				if(xdist <= ydist){
    
    					yratio = ydist / xdist;
    
    				} // end if
    
    				hratio = Sqrt(Pow(xratio, 2) + Pow(yratio, 2));
    				xratio = xratio / hratio;
    				xratio = xratio * speed;
    				yratio = yratio / hratio;
    				yratio = yratio * speed;
    
    				this->Vx = xratio;
    				this->Vy = yratio;
    
    				tempxy = this->X + ((this->Y/100)/100) + 8.0008;
    
    				//Line(tempxy, beamcolor, Screen->D[2], 3, 1, false, 0, 0, 0);
    
    			} //end if
    
    			// deactivation device
    			if((Screen->D[1] == 0) && (active)){
    
    				this->Vx = 0;
    				this->Vy = 0;
    				this->X = 0;
    				this->Y = 0;
    				active = false;
    				this->Data = passivecombo;
    
    			} //end if
    
    			Waitframe();
    
    		} //end while
    
    	} //end void
    
    } //end ffc script
    What am I doing wrong?
    Avatar: Just who the SPAAAACE do you think I am?

  2. #2
    Mario's Hat
    Guest

    Re: Laser Beamos script

    Duh! Lazers always need to be charged before firin' them.

  3. #3
    Gibdo beefster09's Avatar
    Join Date
    Mar 2006
    Age
    31
    Posts
    699
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    2,710
    Level
    16
    vBActivity - Bars
    Lv. Percent
    97.41%

    Re: Laser Beamos script

    You're not funny. And It does do that. It takes a user-defined amount of time to actually start to shoot. That's what delaystart, currentdelay, and maxdelay are for.

    I bet you didn't even look at the code!
    Avatar: Just who the SPAAAACE do you think I am?

  4. #4
    Mario's Hat
    Guest

    Re: Laser Beamos script

    I wish. It's machine code.

    http://encyclopediadramatica.com/index.php/Machine_Code



    Nah, really I didn't. I just saw the perfect opportunity for making a reference to chargin' lazers, firin' lazers and shoopin' whoops.

    'twas simply for the lulz, no harm meant.

  5. #5
    Gibdo beefster09's Avatar
    Join Date
    Mar 2006
    Age
    31
    Posts
    699
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    2,710
    Level
    16
    vBActivity - Bars
    Lv. Percent
    97.41%

    Re: Laser Beamos script

    You're not helpful though!
    Avatar: Just who the SPAAAACE do you think I am?

  6. #6
    Lynel Revfan9's Avatar
    Join Date
    Jun 2005
    Location
    In front of a screen. I never leave.
    Age
    31
    Posts
    1,160
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    3,390
    Level
    18
    vBActivity - Bars
    Lv. Percent
    71.08%

    Re: Laser Beamos script

    Mario's Hat, please stop spamming. You are not helping.

    Beefster, I don't understand Zscript much, but I don't see any code that "Generates" the laser by changing the FFC's combo and I also don't see anything that makes the laser stay there until it hits link, makes it damage link, or makes the beam go away after it hits Link.

  7. #7
    Gibdo beefster09's Avatar
    Join Date
    Mar 2006
    Age
    31
    Posts
    699
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    2,710
    Level
    16
    vBActivity - Bars
    Lv. Percent
    97.41%

    Re: Laser Beamos script

    The combo itself is what is supposed to damage link. The laser keeps firing until Link is out of range. It does change the combo, that's what this->Data is for.
    Avatar: Just who the SPAAAACE do you think I am?

  8. #8
    Keese
    ZC Developer

    Join Date
    Jan 2007
    Age
    34
    Posts
    52
    Mentioned
    27 Post(s)
    Tagged
    1 Thread(s)
    vBActivity - Stats
    Points
    781
    Level
    9
    vBActivity - Bars
    Lv. Percent
    80.76%

    Re: Laser Beamos script

    Code:
    // activation device
    if((Screen->D[1] == 1) && (!active)){
    
        this->X = Floor(Screen->D[0]);
        this->X = Ceiling(Screen->D[0]) * 100 * 100;
        active = true;
        this->Data = activecombo;
    
    } //end if
    You have two this->X 's, so the first one doesn't do anything.

    Code:
    Screen->D[2] = this->X + ((this->Y/100)/100) + 8.0008; // xy of eye
    
    Screen->D[0] = Link->X + ((Link->Y/100)/100);
    Also, could you explain the whole xy caculation? And why Screen->D[0] doesn't have the +8.0008 attached to the end?

  9. #9
    Gibdo beefster09's Avatar
    Join Date
    Mar 2006
    Age
    31
    Posts
    699
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    2,710
    Level
    16
    vBActivity - Bars
    Lv. Percent
    97.41%

    Re: Laser Beamos script

    XD didn't notice the two x thing.
    The xy thing is used to have easier calculation between scripts, and it makes it possible to pass parameters into the Line function, Unfortunately, I couldn't get the function to work.
    The xy is basically X on the left side of the decimal and Y on the right 4 decimal places out. The 8.0008 is so that the xy is at the center. 16*16 -> 8*8
    Avatar: Just who the SPAAAACE do you think I am?

  10. #10
    Gibdo beefster09's Avatar
    Join Date
    Mar 2006
    Age
    31
    Posts
    699
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    2,710
    Level
    16
    vBActivity - Bars
    Lv. Percent
    97.41%

    Re: Laser Beamos script

    Umm... I still need help. Don't forget about me.
    Avatar: Just who the SPAAAACE do you think I am?

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