Jump to content

Photo

Function to Move EWeapon in Relational Dir to LWeapon Hit

tennis weapons enemies physics

  • Please log in to reply
3 replies to this topic

#1 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 26 November 2015 - 07:38 AM

Right, so I know a couple ways to make the tennis effect work, but what I'm looking for here, is a function that will move an eweapon based on its trajectory, and the trajectory of an lweapon that hits it. That is, something that replicates some basic level of Newtonian physics, so that the direction, and velocity of the reflected eweapon, will be based on its initial direction and velocity, coupled with that of whatever impacted it.

 

It doesn't have to be spot on, but anything is better than randomising conditions.

 

The function needs to accept two pointers (lweapon and eweapon), and read the Step of each, and the Dir of each, to make its calculation. A Step of '0' must be allowed, and logical. I also plan to recycle this, at least in part, for determining custom enemy throwback, or custom throwback when an enemy weapon hits the player.

 

(Z3 had this, with soldiers, and swords, if you recall. When a soldier parried Link's attack, the enemy, and Link, bounced away from one another. Other games, such as the Gameboy series, also had similar effects when Link killed an enemy. )

 

If someone wants to, or is able to tackle this, I'd appreciate it very much indeed.

 

P.S. Please comment calcs, if possible; so that it's easier to modify to a specific application.


Edited by ZoriaRPG, 26 November 2015 - 07:42 AM.


#2 Deedee

Deedee

    Small Pixie Dragon

  • Administrators
  • Real Name:Deedee
  • Pronouns:She / Her, They / Them
  • Location:Canada

Posted 26 November 2015 - 10:06 AM

Will this do?
 

void Reflect(lweapon l, eweapon e)
{
	if (Abs(l->X - e->X) < 14 && Abs(l->Y - e->Y) < 14 && e->Misc[0] <= 0)
	{
		e->Angular = true;
		e->Angle = Angle(l->X, l->Y, e->X, e->Y);
		e->Step *= (l->Step / 100);
		e->Misc[0] = 20;
	}
	else if (e->Misc[0] > 0) e->Misc[0]--;
}

 
Untested, but it should work.


Edited by Dimentio, 26 November 2015 - 10:07 AM.


#3 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 26 November 2015 - 10:52 AM

Will this do?
 

void Reflect(lweapon l, eweapon e)
{
	if (Abs(l->X - e->X) < 14 && Abs(l->Y - e->Y) < 14 && e->Misc[0] <= 0)
	{
		e->Angular = true;
		e->Angle = Angle(l->X, l->Y, e->X, e->Y);
		e->Step *= (l->Step / 100);
		e->Misc[0] = 20;
	}
	else if (e->Misc[0] > 0) e->Misc[0]--;
}

 
Untested, but it should work.

 

I'll certainly give it a try, and see if it produces results that I can utilise. :D

 

I'll work on the step calculations at some point too. (Those will assuredly become more, and more complex, over time.)

 

I'm going to need go come up with a way to move npcs this way, though, so I need to check if ghost.zh has an angular repositioning variation of ghost_move, that I can pillage, for this sort of thing.

 

Of course, I can be cheap, and use a sprite pointer as a focal point as well.


Edited by ZoriaRPG, 26 November 2015 - 10:53 AM.


#4 Deedee

Deedee

    Small Pixie Dragon

  • Administrators
  • Real Name:Deedee
  • Pronouns:She / Her, They / Them
  • Location:Canada

Posted 26 November 2015 - 05:45 PM

I believe that for ghosted enemies, you can simply do "Ghost_MoveAtAngle(Angle, Step)" instead of e->Angular = true, e->Angle = Angle, e->Step = step, etc.





Also tagged with one or more of these keywords: tennis, weapons, enemies, physics

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users