Jump to content

Photo

Sine Wave Style Weapon Script

2.55 Weapon Script LWeapon EWeapon Script Sine Wave Wavy

  • Please log in to reply
2 replies to this topic

#1 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 18 March 2019 - 01:29 PM

Here's a very simple pair of weapon scripts to allow any projectile to move across the screen in that annoying Medusa-head sine pattern.

 

Zig-Zag Weapon Script v0.2


 

//Zig-Zag Weapon pattern.
//ZoriaRPG, 18th March, 2019
//v0.2

//v0.1 : Initial
//v0.2 : Added pixels in distance of each movement as InitD[2]
eweapon script eZigZagwhoneedssine
{
	void run(int dist, int speed, int px)
	{
		int frame = 1;
		int baseline;
		dist = (dist < 1) ? 12 : dist;
		speed = (speed < 1) ? 1 : speed;
		px = ( px < 1 ) ? 1 : px;
		//initial direction from baseline
		bool initial = ( Rand(0,1) ) ? true : false;
		switch(this->Dir)
		{
			case DIR_UP: baseline = this->X+(this->TileWidth*0.5); break;
			case DIR_LEFT: baseline = this->Y+(this->TileHeight*0.5); break;
			case DIR_DOWN: baseline = this->X+(this->TileWidth*0.5)+1; break;
			case DIR_RIGHT: baseline = this->Y+(this->TileHeight*0.5)+1; break;
				
		}
		while(this->isValid())
		{
			++frame;
			switch(this->Dir)
			{
				case DIR_UP:
				case DIR_DOWN:
				{
					if ( initial )
					{
						if ( !(frame%speed) )
						{
							if ((baseline - this->X) < dist ) 
							{
								this->X-=px;
							}
							else initial = !initial;
						}
					}
					else
					{
						if ( !(frame%speed) )
						{
							if ( (this->X - baseline) < dist ) 
							{ 
								this->X+=px;
							}
							else initial = !initial;
						}
					}
					break;	
				}
				
				case DIR_LEFT:
				case DIR_RIGHT:
				{
					if ( initial )
					{
						if ( !(frame%speed) )
						{
							if ((baseline - this->Y) < dist ) 
							{
								this->Y-=px;
							}
							else initial = !initial;
						}
					}
					else
					{
						if ( !(frame%speed) )
						{
							if ( (this->Y - baseline) < dist ) 
							{ 
								this->Y+=px;
							}
							else initial = !initial;
						}
					}
					break;	
				}
			}
			Waitframe();
		}
	}
}


lweapon script lZigZagwhoneedssine
{
	void run(int dist, int speed)
	{
		int frame = 1;
		int baseline;
		dist = (dist < 1) ? 12 : dist;
		speed = (speed < 1) ? 1 : speed;
		//initial direction from baseline
		bool initial = ( Rand(0,1) ) ? true : false;
		switch(this->Dir)
		{
			case DIR_UP: baseline = this->X+(this->TileWidth*0.5); break;
			case DIR_LEFT: baseline = this->Y+(this->TileHeight*0.5); break;
			case DIR_DOWN: baseline = this->X+(this->TileWidth*0.5)+1; break;
			case DIR_RIGHT: baseline = this->Y+(this->TileHeight*0.5)+1; break;
				
		}
		while(this->isValid())
		{
			++frame;
			switch(this->Dir)
			{
				case DIR_UP:
				case DIR_DOWN:
				{
					if ( initial )
					{
						if ( !(frame%speed) )
						{
							if ((baseline - this->X) < dist ) 
							{
								--this->X;
							}
							else initial = !initial;
						}
					}
					else
					{
						if ( !(frame%speed) )
						{
							if ( (this->X - baseline) < dist ) 
							{ 
								++this->X;
							}
							else initial = !initial;
						}
					}
					break;	
				}
				
				case DIR_LEFT:
				case DIR_RIGHT:
				{
					if ( initial )
					{
						if ( !(frame%speed) )
						{
							if ((baseline - this->Y) < dist ) 
							{
								--this->Y;
							}
							else initial = !initial;
						}
					}
					else
					{
						if ( !(frame%speed) )
						{
							if ( (this->Y - baseline) < dist ) 
							{ 
								++this->Y;
							}
							else initial = !initial;
						}
					}
					break;	
				}
			}
			Waitframe();
		}
	}
}


#2 kurt91

kurt91

    Follower of Destiny

  • Members
  • Real Name:Kurtis
  • Location:Eastern Washington University

Posted 21 March 2019 - 06:38 AM

Stupid question, but would this work for diagonal-moving projectiles? I have a boss encounter in my quest that sprays fireballs in a wide area in Link's general direction. Could I attach this script so that the fireballs are a bit more difficult to predict and dodge, for a later encounter with a stronger version of the boss. (Speaking of my quest, I should get around to actually working on it again...)



#3 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 21 March 2019 - 01:33 PM

Stupid question, but would this work for diagonal-moving projectiles? I have a boss encounter in my quest that sprays fireballs in a wide area in Link's general direction. Could I attach this script so that the fireballs are a bit more difficult to predict and dodge, for a later encounter with a stronger version of the boss. (Speaking of my quest, I should get around to actually working on it again...)


It's only for right-angles:

switch(this->Dir)
			{
				case DIR_UP:
				case DIR_DOWN:
				case DIR_LEFT:
				case DIR_RIGHT:




Also tagged with one or more of these keywords: 2.55, Weapon Script, LWeapon, EWeapon, Script, Sine, Wave, Wavy

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users