Page 1 of 1

[DECORATE] Enemies falling back from last direction shot?

Posted: Tue May 02, 2017 4:55 pm
by FranckyFox2468
Is there a way to make an enemy being pushed back from the last direction they were shot for a pain/death animation? Some would say to use a_facetarget but it acts really oddly in multiplayer as the monster falls back from the last player its facing and no not the projectile/hitscan it got shot by

[DECORATE] Re: Enemies falling back from last direction shot?

Posted: Tue May 02, 2017 8:09 pm
by Ivan
FranckyFox2468 wrote:Is there a way to make an enemy being pushed back from the last direction they were shot for a pain/death animation? Some would say to use a_facetarget but it acts really oddly in multiplayer as the monster falls back from the last player its facing and no not the projectile/hitscan it got shot by
You have to calculate the angle that'd make the monster face the target (the guy who shot the monster, in your case) then apply a force in the opposite direction of it.

[DECORATE] Re: Enemies falling back from last direction shot?

Posted: Wed May 03, 2017 2:55 am
by FranckyFox2468
...How exactly do i do that?

[DECORATE] Re: Enemies falling back from last direction shot?

Posted: Thu May 04, 2017 12:10 am
by Ivan
FranckyFox2468 wrote:...How exactly do i do that?

Code: Select all

// returns fixed distance
function int AproxDistance (int dx, int dy) {
	dx = abs(dx);
	dy = abs(dy);

	if (dx < dy)
		return dx + dy - (dx >> 1);

	return dx + dy - (dy >> 1);
}

function void FaceActor(int m1, int m2) {
	int xdiff = GetActorX(m2) - GetActorX(m1);
	int ydiff = GetActorY(m2) - GetActorY(m1);
	int zdiff = (GetActorZ(m2) + GetActorProperty(m2, APROP_HEIGHT)) - (GetActorZ(m1) + GetActorProperty(m1, APROP_HEIGHT));
	int dist = AproxDistance(xdiff, ydiff);
	SetActorAngle(m1, VectorAngle(xdiff, ydiff));
	dist = FixedDiv(dist, 256.0);
	zdiff = FixedDiv(zdiff, 256.0);
	int tpitch = -VectorAngle(dist, zdiff);
	SetActorPitch(m1, tpitch);
}
This is the code that will make the actor with TID m1 face TID m2. You can figure out the rest probably.

[DECORATE] Re: Enemies falling back from last direction shot?

Posted: Sat May 06, 2017 3:32 pm
by FranckyFox2468
I was rather looking for something that works in decorate but if there is nothing else...