[DECORATE] Enemies falling back from last direction shot?

Discuss all aspects related to modding Zandronum here.
Post Reply
User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

[DECORATE] Enemies falling back from last direction shot?

#1

Post by FranckyFox2468 » Tue May 02, 2017 4:55 pm

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

User avatar
Ivan
Addicted to Zandronum
Posts: 2219
Joined: Mon Jun 04, 2012 5:38 pm
Location: Omnipresent

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

#2

Post by Ivan » Tue May 02, 2017 8:09 pm

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.
=== RAGNAROK DM ON ... uh... dead forever? ===
=== ALWAYS BET ON ... uh... dead forever? ===
=== Who wanta sum wang? ===
=== Death and Decay - A new Monster/Weapon replacer ===

User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

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

#3

Post by FranckyFox2468 » Wed May 03, 2017 2:55 am

...How exactly do i do that?

User avatar
Ivan
Addicted to Zandronum
Posts: 2219
Joined: Mon Jun 04, 2012 5:38 pm
Location: Omnipresent

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

#4

Post by Ivan » Thu May 04, 2017 12:10 am

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.
=== RAGNAROK DM ON ... uh... dead forever? ===
=== ALWAYS BET ON ... uh... dead forever? ===
=== Who wanta sum wang? ===
=== Death and Decay - A new Monster/Weapon replacer ===

User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

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

#5

Post by FranckyFox2468 » Sat May 06, 2017 3:32 pm

I was rather looking for something that works in decorate but if there is nothing else...

Post Reply