Jump to content

Photo

Help With LWeapons.zh

Library Help

  • Please log in to reply
8 replies to this topic

#1 ywkls

ywkls

    Master

  • Members

Posted 22 March 2019 - 01:35 AM

Current Version of LWeapons.zh

 

So, I recently released to the database my scripting library for creating exotic and strange items for your player character to use which can be found at the link above. There is a large variety of stuff included in there, so here's a brief summary of the contents. (Items with an * before them will have more detailed instructions in future posts)

 

Item Scripts:

 

Firebar- Creates a series of circular projectiles which circle you.

OmniByrna- Creates an item that acts like a Cane of Byrna which protects you from harm and makes 4 projectiles which circle you. Also drains MP while in use.

Grenade- Launches an explosive which bounces when it hits the ground.

Boulder- Launches a 2 x 2 boulder that splits into shards upon impact

Scripted Boomerang- Just acts like a regular boomerang, but can use any LWeapon type

Bomb Arrows- Explodes on impact and sets off arrow triggers. Doesn't respect enemy defenses properly.

Fire Rod- An item that burns on impact with enemies or targets... most of the time.

Ice Rod- An item that stuns enemies on impact... most of the time.

Wave Sword Beam- A sword beam (or other attack) that moves in a sine wave.

Variable Strength Arrow- An arrow that can act normally, split on death into multiple projectiles or home in on foes.

Meteor- Launches a number of projectiles that fall from the sky.

Bracelet- Allows you to pick up and throw certain objects.

Spear- An attack that is 1 x 2 tiles long or 2 x 1 tiles high depending on the way you're facing.

Scripted Hammer- A poor imitation of a hammer.

Ball and Chain- Thrown projectile that moves in a sine wave and shakes the screen on impact.

*New Shovel- Digs up specific spots and can find a screen's special item.

Bombchu- A bomb that moves according to your button pressed and explodes on demand.

*Scripted Shield- A shield with easily configurable defenses that you can set at will.

Bouncy Ball- An item that bounces a projectile off of walls.

Bombos, Ether and Quake Medallions- The LTTP items of the same names.

*Scripted Hookshot/Switchhook- Acts like the items in question.

*Cane of Somaria- Lets you press switches to uncover secrets while the button is held down.

Also, explodes into 4 projectiles once the block it makes is active.

 

 

In addition to these items; the library supports the following movement styles and special effects:

 

Moves in a sine wave.
Moves in a circle around Link.
Homes in on enemies.
Acts like a boomerang.
An attack that covers the screen.
Makes you have strafing movement.
A thrown attack
Bounces off walls.
Falls from the air.
 
Slashs bushs, flowers and other combos.
Pounds hammer pegs.
Moves and changes appearance as you do; like a melee weapon.
Reflects Enemy projectiles. Which ones can be customized.
Lasts for a specific amount of time.
Is destroyed by solid combos except those types specified.
Regularly costs MP to use.
Can pickup items.
Pierces enemies.
Stuns enemies.
Ignores gravity.
Sprite isn't flipped depending on the direction it is fired in. Specifically designed for fire and bomb sprites.
Used with item pickup. Insta-delivers item to Link.
Link can't be hurt while this weapon is active.
Link doesn't obey gravity while this is active.
Simulated level 1 of a particular weapon type.
Simulated level 2 of a particular weapon type..
Simulated level 3 of a particular weapon type.
Simulated level 4 of a particular weapon type.
Link isn't affected by knockback while this is active.
The weapon's collision is off.
The weapon casts a shadow.
Vanishes at death.
At death, aims at an enemy on screen and head in that direction.
At death, creates a bomb blast.
At death, creates a super bomb blast.
At death, makes 2 horizontal and 2 vertical attacks
At death, makes 4 diagonal attacks.
At death, makes 4 random attacks.
At death, makes 8 attacks in all directions.
At death, makes the screen shake.
At death, a bomb explodes and shakes screen
At death, a super bomb explodes and shakes screen.
 
 
Please feel free to ask questions about using this library, make suggestions on improving its contents and post scripts of your own.

 



#2 ywkls

ywkls

    Master

  • Members

Posted 22 March 2019 - 01:00 PM

Item Script Discussion: New Shovel

 

So, there have been quite a few shovel scripts around for a while. This one doesn't use Link Tile Modifiers as yet, but does have a few unique features.

 

First off, it can be made where enemies take damage from the shovel. While this may not seem like much, it does allow you to create some potentially unique fights with a short-range weapon that also can generate items to heal you.

 

Second, it allows you to customize whether you can dig in a certain spot or not. Currently, the combo's which cannot be dug are anything solid, those with combo flag script 3, combo's that are not type none and any spots which have already been dug.

 

Thirdly, it allows you to create a hidden item which can be retrieved only with the shovel. This works using a standard setup for a treasure chest by marking a combo with flag 10; making the room type Special Item and setting what that is in the editor.

The item generated in this way can only be found once, just like a chest.

 

Thoughts on future improvements:

 

Adding a "dirt clod" when digging. 

Changing the character's sprite when digging.

 

Edit: Also forgot a few small details. First, the item is set to launch an ffc script. The purpose of this script is to make it where you can't miss an item by dying or leaving a screen after digging up the item but before collecting it. 

 

Second, the item also currently has a feature to mark a room as "you can't dig here" . This is currently set to be Screen Flag Script 3 but it could reasonably be any flag. Additionally, if desired this could be a DMap wide flag.


Edited by ywkls, 23 March 2019 - 01:01 AM.


#3 P-Tux7

P-Tux7

    💛

  • Members

Posted 22 March 2019 - 03:16 PM

Hmm, can this be used to create candle fires and Byrna beams that block/reflect projectiles? This is neat!

Also, a suggestion from me would be to allow blocking and or deleting of enemy projectiles instead of just reflections. And also a Link version of laser.zh.

Edited by P-Tux7, 22 March 2019 - 03:19 PM.

  • ywkls likes this

#4 ywkls

ywkls

    Master

  • Members

Posted 23 March 2019 - 01:03 AM

Hmm, can this be used to create candle fires and Byrna beams that block/reflect projectiles? This is neat!

Also, a suggestion from me would be to allow blocking and or deleting of enemy projectiles instead of just reflections. And also a Link version of laser.zh.

So, candle fires themselves are a bit of a problem; due to the fact that they resist scripting to their fiery deaths.

You could make an attack that looks and acts like a fire and blocks or reflects projectiles, though.

 

Byrna beams themselves can't be made by script, but you could create an item that acts like one which does this things.

 

Also, the settings for blocking and reflecting attacks are separate functions. So, you can have it where an attack of you choice can be blocked but not reflected.

 

A Link laser attack may be added in future builds.



#5 ywkls

ywkls

    Master

  • Members

Posted 23 March 2019 - 01:00 PM

Item Script Discussion: Scripted Shield

 

So, you may be wondering; how do I set which item is blocked and which is reflected by my shield.

The answer to that is essentially the same as with normal shields in ZC, except scripting makes it where you don't have to figure out how binary flags work.

 

The answer to "what can be reflected by an item" is essentially "anything which can be normally reflected."

Thus, fireballs; sword beams, magic, and rocks.

One flag gives any item this property.

Future versions may separate out this ability, so only one or multiple of these can be activated at once.

 

The other side is blocking enemy weapons.

Currently, this feature is only available for "strafing" weapons, but adding it to others would be hard.

These are the attacks which can be blocked:

 

Fireballs
Sword beams
Arrows.
Rocks.
Magic
Boomerangs
All enemy weapons
 
It should be noted that there is no scripted distinction at present between certain types of attack.
Therefore, if you're not sure what to use, the last option would be best.
 
Future Plans:
 
Make non-strafing shield.
Separate reflecting properties into multiple flags.
Make all items capable of blocking attacks.


#6 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 24 March 2019 - 12:53 PM

Hmm, can this be used to create candle fires and Byrna beams that block/reflect projectiles? This is neat!

Also, a suggestion from me would be to allow blocking and or deleting of enemy projectiles instead of just reflections. And also a Link version of laser.zh.


byrnaKillsEWeapons(int sfx)
{
	bool byrnabeam;
	for ( int q = Screen->NumLWeapons(); q > 0; --q )
	{
		lweapon b = Screen->LoadLWeapon(q);
		if ( b->ID != LW_BYRNA ) continue;
		for ( int w = Screen->NumEWeapons(); w > 0; --w )
		{
			eweapon p = Screen->LoadEWeapon(w);
			if ( p->CollDetection )
			{
				if ( Collision(b,p) )
				{
					b->DeadState = WDS_DEAD;
					p->DeadState = WDS_DEAD;
					Game->PlaySound(sfx);
				}
			}
		}
	}
}
					

byrnaReflectsEWeapons(int sfx)
{
	bool byrnabeam;
	for ( int q = Screen->NumLWeapons(); q > 0; --q )
	{
		lweapon b = Screen->LoadLWeapon(q);
		if ( b->ID != LW_BYRNA ) continue;
		for ( int w = Screen->NumEWeapons(); w > 0; --w )
		{
			eweapon p = Screen->LoadEWeapon(w);
			if ( p->CollDetection )
			{
				if ( Collision(b,p) )
				{
					b->DeadState = WDS_DEAD;
					if ( p->Angular )
					{
						p->Angle = WrapDegrees(p->Angle - 180);
					}
					else
					{
						p->Flip = FlipRev(p->Dir);
						p->Dir = DirRev(p->Dir);
					}
					Game->PlaySound(sfx);
				}
			}
		}
	}
}
									
Should work in all ZC versions. A more optimal version could exist for 2.55, and itd be better to code this into an existing weapons loop.

#7 ywkls

ywkls

    Master

  • Members

Posted 24 March 2019 - 08:17 PM

Should work in all ZC versions. A more optimal version could exist for 2.55, and itd be better to code this into an existing weapons loop.


The main global loop of the header does just that by having a few lines of code in the item's script.

An example of reflecting enemy weapons: 

//D0- Blank so other scripts can use item
//D1- Damage done by item.
//D2- Sound made when using item

item script Reflect_Attack{
	void run(int dummy, int Damage, int spr, int sfx){
		if(NumLWeaponsOf(LW_SCRIPT10)==0){
			lweapon spear;
				spear = FireLWeapon(LW_SCRIPT10, Link->X, Link->Y-32, 
						    __DirtoRad(Link->Dir), 0, Damage, 
						    spr, sfx,0);
			SetLWeaponLifespan(spear,LWL_TIMER,10);
                        //This line adds the ability to reflect enemy weapons
			SetLWeaponMovement(spear,LWM_MELEE,0,LWMF_REFLECTS_EWPN);
			SetLWeaponDeathEffect(spear,LWD_VANISH,0);
			Link->Action = LA_ATTACKING;
		}
	}
}

Everything else is handled automatically.

 

Blocking is a bit more complex at present.

An example of a script that lets you block attacks:

item script Scripted_Shield{
	void run(int dummy, int sprite, int sfx, int script_id, int Button_A){
		if(CountFFCsRunning(script_id)==0){
			int args[8]= {sprite,sfx,Button_A};
			NewFFCScript(script_id,args);
		}		
	}
}

ffc script Held_Shield{
	void run(int sprite, int sfx, int Button_A){
		lweapon shield = FireLWeapon(LW_SCRIPT1,Link->X,Link->Y,__DirtoRad(Link->Dir),
										0,0,sprite,sfx,LWF_PIERCES_ENEMIES);
		//Currently this is the only movement type which supports blocking.
                SetLWeaponMovement(shield,LWM_STRAFE,Link->Dir,LWSF_ALL);
		SetLWeaponDeathEffect(shield,LWD_VANISH,0);
		SetLWeaponFlag2(shield,LWF_NO_COLLISION);
		while((Link->InputA && Button_A) ||
				(Link->InputB && !Button_A))
				Waitframe();
		KillLWeapon(shield);
	}
}

As I said, I plan to expand the header to allow any movement type to block attacks.


Edited by ywkls, 24 March 2019 - 08:17 PM.


#8 ywkls

ywkls

    Master

  • Members

Posted 08 April 2019 - 12:04 PM

Item Script Discussion: Hookshot/Switchhook

 

First off, let me acknowledge the all-knowing Moosh; who was the originator of the script I use as the basis for these.

Now, what is there to say about these scripted hookshots?

 

Well, one thing is that the length of the chain is set up in the item script. No more trying to figure out how that works in the item editor in order to get the various lengths just right.

 

Next is the fact that in addition to Hookshot Only combos; it is possible to set these up to disregard any combo type you want. However, the script currently only supports this type and anything else would have to be added manually. One obvious addition would be solid ladder or water combos.

 

Third is how the Switchhook works. Currently, the switchhook is set up to only interact with combos that have the Script 1 flag active. This is to prevent the wholesale redistribution of combos which may be set up as Hookshot Grab in your tileset. 

 

Because of complaints that using the hookshots felt weird, I added a function that delays the time between you holding the button and its activation one frame. This made it feel smoother to me, though I've not gotten any feedback about this feature.

 

Future ideas:

 

Hookshots that do things on impact (burn, freeze, explode)

Hookshots that disregard other combo types


Edited by ywkls, 08 April 2019 - 12:06 PM.


#9 ywkls

ywkls

    Master

  • Members

Posted 20 August 2019 - 10:06 AM

If anyone was wondering why I never updated this topic with info on my Cane of Somaria script;

it's because I almost immediately found bugs in it.

However, I was able to make a significant update today.

Here are the details.

 

Added Item Monitor script- So, since my Shovel and a few other scripts create items based on the Screen's Roomdata, you might wonder what happens if you leave the screen or die before picking up the item they create. This script is the answer to that conundrum. It looks for the item created by the first script and makes sure that item has been collected before adjusting the Screen state that controls whether or not the item spawns to begin with.

 

Fixed sprites that were being rotated improperly- Sprites for circling LWeapons were being rotated even when previously told not to. This has now been fixed. If any other instances of this bug exist, please report them.

 

Changed movement type LW_BOUNCE to LW_CAROM- This was to reflect the fact it is supposed to act more like a billiard ball. And to reserve LW_BOUNCE for possible use in a later update.

 

Fixes issues with LWeapons that affect Link's collision detection- Somewhere, all scripts that affected Link's collision detection globally got messed up. This is so bad, I took control out of the hands of the LWeapons themselves and handed it over to each individual ffc. This affects all LTTP Medallions and Hookshot-type scripts.

 

Updated Ice Rod script to work more consistently- Now the Ice Rod should both freeze enemies and draw an ice block over them, most of the time. For some reason, this doesn't always happen; but it works more often than it doesn't.

 

That's it for now, but I'm always looking for new ideas and ways to improve my work. So let me know if anyone has suggestions for things to include.





Also tagged with one or more of these keywords: Library, Help

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users