Jump to content

Photo

Dead-man's volley


  • Please log in to reply
4 replies to this topic

#1 klop422

klop422

    Guess I'm full of monsters and treasure

  • Members
  • Real Name:Not George
  • Location:Planet Earth

Posted 04 May 2018 - 06:40 PM

I've asked for this a number of times years ago (searching 'volley' in the Script Requests forum gives this, this, and this), but I think I have a simpler question.

Is there a way to make Link's sword deflect a fire projectile back the way it came? Ideally, just level 3+ swords, and would damage enemies as if it were reflected by the mirror shield

 

Ideally, I'd like the enemy as I requested in the second link as well (2/3 chance of hitting back what you reflected to it, 1/8 chance of shooting a regular projectile), with the chances as I described them (also, only one projectile allowed on screen from this enemy), but I think I could work with just the first thing (i.e. the previous paragraph).


Edited by klop422, 04 May 2018 - 07:05 PM.


#2 Moosh

Moosh

    Tiny Little Questmaker

  • ZC Developers

Posted 06 May 2018 - 12:10 AM

const int SFX_PMV_DEFLECT = 6; //Sound when a weapon is reflected back at an enemy

//Dead Man's Volley Arguments:
//D0: Set this to the weapon type that can be reflected on the screen.
//		Do a search in std_constants.zh for EW_ for a list of the numbers for each weapon type.
//D1: Set this to the minimum damage for a sword to be able to deflect the weapon.
//D2: Set this to the new damage the weapon should deal after being deflected. 0 for the same as before.

ffc script PoorMansVolley{
	void run(int eWeapType, int swordMinDamage, int newWeapDamage){
		while(true){
			//Find a sword with enough damage to reflect the projectile
			//We're using damage here because ZScript can't read item levels from a weapon
			lweapon l = LoadLWeaponOf(LW_SWORD);
			if(l->Damage>=swordMinDamage){
				//Cycle through every weapon on the screen until we find one of the right type
				for(int i=Screen->NumEWeapons(); i>=1; i--){
					eweapon e = Screen->LoadEWeapon(i);
					if(e->ID==eWeapType){
						//If the sword is touching the eweapon, create an identical lweapon and delete the original
						if(Collision(e, l)){
							lweapon l = PMV_EWeaponToLWeapon(e);
							e->DeadState = 0;
							Game->PlaySound(SFX_PMV_DEFLECT);
							//Readjust the weapon's angle to the angle from Link
							int angle = Angle(Link->X, Link->Y, l->X, l->Y);
							l->Angular = true;
							l->Angle = DegtoRad(angle);
							l->Dir = AngleDir4(angle);
							if(newWeapDamage>0)
								l->Damage = newWeapDamage*2;
						}
					}
				}
			}
			Waitframe();
		}
	}
	//EWeapon goes in, LWeapon comes out. You can't explain that!
	lweapon PMV_EWeaponToLWeapon(eweapon a) {
		lweapon b = Screen->CreateLWeapon(a->ID);
		b->X = a->X;
		b->Y = a->Y;
		b->Z = a->Z;
		b->Jump = a->Jump;
		b->Extend = a->Extend;
		b->TileWidth = a->TileWidth;
		b->TileHeight = a->TileHeight;
		b->HitWidth = a->HitWidth;
		b->HitHeight = a->HitHeight;
		b->HitZHeight = a->HitZHeight;
		b->HitXOffset = a->HitXOffset;
		b->HitYOffset = a->HitYOffset;
		b->DrawXOffset = a->DrawXOffset;
		b->DrawYOffset = a->DrawYOffset;
		b->DrawZOffset = a->DrawZOffset;
		b->Tile = a->Tile;
		b->CSet = a->CSet;
		b->DrawStyle = a->DrawStyle;
		b->Dir = a->Dir;
		b->OriginalTile = a->OriginalTile;
		b->OriginalCSet = a->OriginalCSet;
		b->FlashCSet = a->FlashCSet;
		b->NumFrames = a->NumFrames;
		b->Frame = a->Frame;
		b->ASpeed = a->ASpeed;
		b->Damage = a->Damage;
		b->Step = a->Step;
		b->Angle = a->Angle;
		b->Angular = a->Angular;
		b->CollDetection = a->CollDetection;
		b->DeadState = a->DeadState;
		b->Flash = a->Flash;
		b->Flip = a->Flip;
		for (int i = 0; i < 16; i++)
		b->Misc[i] = a->Misc[i];
		return b;
	}
}

It's not the prettiest effect, but this should work. Just place the script down on the screen with your enemy, set the arguments as described in the comments. It uses weapon damage instead of level because there's no way to read item level off a weapon.



#3 klop422

klop422

    Guess I'm full of monsters and treasure

  • Members
  • Real Name:Not George
  • Location:Planet Earth

Posted 06 May 2018 - 10:05 AM

It appears to work quite well, though I haven't tested it completely. Thanks, Moosh!



#4 klop422

klop422

    Guess I'm full of monsters and treasure

  • Members
  • Real Name:Not George
  • Location:Planet Earth

Posted 01 June 2018 - 07:15 AM

Slight issue I've just found. If you hold out the sword in front of you (i.e. for a spin attack), then the projectiles still get reflected, which is a little bit of an issue. Is there a solution, or do I just have to work around it?



#5 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 28 July 2018 - 01:26 PM

Not sure if that'll fix it but try changing this line

if(l->Damage>=swordMinDamage){

to

if(l->Damage>=swordMinDamage && Link->Action != LA_CHARGING){



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users