[harm_unit] provides no defend animation

Having trouble with the game? Report issues and get help here. Read this first!

Moderator: Forum Moderators

Forum rules
Before reporting issues in this section, you must read the following topic:
Post Reply
User avatar
Helmet
Posts: 201
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

[harm_unit] provides no defend animation

Post by Helmet »

Hi, [harm_unit] does not provide defend animation to the Orcish Assassin in the following code. In the WML Workshop, two experienced coders speculated that a bug may exist in the game engine.

Code: Select all

	[harm_unit]
		[filter]
			type=Orcish Assassin # 	the only orcish assassin on the map (hitpoints=16 so he'll die from 4 attacks)
		[/filter]
		[filter_second]
			type=Giant Scorpion #	the only giant scorpion on the map
		[/filter_second]
		amount=4 #			pincers do 4 damage
		animate=yes
		[primary_attack]
			name=pincers #		attacks with pincers
		[/primary_attack]
		[secondary_attack]
			name=pincers #		orc defends against pincers
		[/secondary_attack]
		experience=yes # 		giant scorpion gains xp for killing orcish assassin	
	[/harm_unit]
BfW 1.15.6
Mac Os 10.12.6
vghetto
Posts: 240
Joined: November 2nd, 2019, 5:12 pm

Re: [harm_unit] provides no defend animation

Post by vghetto »

Attached will demonstrate the problem.
Setting type to impact will break the animation.

This tried to list all possible permutations, more or less.
Attachments
_main.cfg
(7.62 KiB) Downloaded 14 times
vghetto
Posts: 240
Joined: November 2nd, 2019, 5:12 pm

Re: patch to fix [harm_unit]

Post by vghetto »

Code: Select all

--- harm_unit.lua.bak	2020-11-23 01:11:58.917733498 +0000
+++ harm_unit.lua	2020-11-23 01:12:39.673734158 +0000
@@ -144,8 +144,8 @@
 						hits = true,
 						with_bars = true,
 						T.filter { id = unit_to_harm.id },
-						T.primary_attack ( primary_attack ),
-						T.secondary_attack ( secondary_attack ),
+						T.primary_attack ( secondary_attack ),
+						T.secondary_attack ( primary_attack ),
 						T.facing { x = harmer.x, y = harmer.y },
 					}
 				else
@@ -154,8 +154,8 @@
 						hits = true,
 						with_bars = true,
 						T.filter { id = unit_to_harm.id },
-						T.primary_attack ( primary_attack ),
-						T.secondary_attack ( secondary_attack ),
+						T.primary_attack ( secondary_attack ),
+						T.secondary_attack ( primary_attack ),
 					}
 				end
 			end
Edit: Attaching updated demo that uses weapon names in the primary and secondary only.
Attachments
_main.cfg
(6.86 KiB) Downloaded 15 times
User avatar
Pentarctagon
Project Manager
Posts: 4574
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: [harm_unit] provides no defend animation

Post by Pentarctagon »

A PR would be a much better way to submit a fix, by the way.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
vghetto
Posts: 240
Joined: November 2nd, 2019, 5:12 pm

Re: [harm_unit] provides no defend animation

Post by vghetto »

I know, I can't login into github atm :(

I can access with ssh, can I do a PR from the command line?
User avatar
Pentarctagon
Project Manager
Posts: 4574
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: [harm_unit] provides no defend animation

Post by Pentarctagon »

I don't know - I've never tried any way other than through the website.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
Celtic_Minstrel
Developer
Posts: 1741
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: [harm_unit] provides no defend animation

Post by Celtic_Minstrel »

I can't verify the correctness of that patch on sight, but it does seem like something that could be correct. If you get both the defend and the attack animation with this patch, that should be good enough reason to merge it.

Mind you, I think it would be preferable for [harm_unit] to not call into [animate_unit] at all - it should construct a unit animator directly and add the animations to it, basically the same as what [animate_unit] does internally.
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.
vghetto
Posts: 240
Joined: November 2nd, 2019, 5:12 pm

Re: [harm_unit] provides no defend animation

Post by vghetto »

Celtic_Minstrel wrote: November 23rd, 2020, 6:10 am I can't verify the correctness of that patch on sight, but it does seem like something that could be correct. If you get both the defend and the attack animation with this patch, that should be good enough reason to merge it.
From the little tests that I tried using the attached scenario here and the scenario posted in the other thread, I was able to get the correct animation.

My test spawns a Bowman and an Orchish Assassin. It pits them against a Giant Scorpion with type=impact as primary_attack.
Before the patch all of the following failed to animate the Bowman and the Orchish Assassin.

Code: Select all

melee
ranged
impact
pierce
dagger
throwing knives
short sword
bow
(empty)
After the patch I got the correct animation to almost all except for the following which didn't give an animation.
impact on the Orcish Assassin and Bowman
pierce on the Orcish Assassin

Whenever you, or any other dev, have the time to take a look at it, please do.
Anyone who want to do a PR is welcome to do so. I cannot myself. Sorry.
Thanks
vghetto
Posts: 240
Joined: November 2nd, 2019, 5:12 pm

Re: [harm_unit] provides no defend animation

Post by vghetto »

The main source for all of this confusion seems to stem from [harm_unit] not matching filter with primary_attack and filter_second with secondary_attack. In other words primary_attack should have been the defending weapon and secondary_attack should have been the attacking weapon.

That would have made it analogous to [animate_unit] flag=defend where primary_attack is the defending weapon.

It might be too late to change this because most uses that I've seen in campaigns and UMC sets primary_attack to the attacking weapon of the other unit.

I'm reuploading the latest complete test, it assumes [harm_unit] patch was applied.

The test will do [animate_unit] flag=defend followed by [harm_unit] followed [animate_unit] flag=attack
The [animate_unit]s are there just to show that the correct animation was selected in [harm_unit].

Not sure what else I can do to demonstrate that this is an actual bug in [harm_unit], and that the patch shown fixes it.

Thanks
Attachments
_main.cfg
(9.4 KiB) Downloaded 7 times
User avatar
Celtic_Minstrel
Developer
Posts: 1741
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: [harm_unit] provides no defend animation

Post by Celtic_Minstrel »

vghetto wrote: November 25th, 2020, 11:01 am most uses that I've seen in campaigns and UMC sets primary_attack to the attacking weapon of the other unit.
This is correct. The [primary_attack] (at least according to the wiki) is supposed to specify the weapon being defended against, for the purpose of selecting a defense animation. I'm pretty sure the filter is used to choose an actual weapon on the attacking unit and then all properties of that weapon are used to select the animation, so filtering on name rather than range should be fine.
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.
Post Reply