Using [harm_unit] within a cut-scene

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Using [harm_unit] within a cut-scene

Post by Helmet »

In my scenario, I have a cut-scene where an Orcish Assassin moves adjacent to a Giant Scorpion, and then the Giant Scorpion kills the Orcish Assassin. The Giant Scorpion does not get damaged in the so-called battle.

How do I make the Giant Scorpion use its attack animation for its "pincer" attack?

Also, a Giant Scorpion has 4 pincer attacks. I'd like all 4 attacks displayed before the orc dies. Is there a way for harm_unit to do multiple attacks? If it's limited to one attack, what is the best way to present multiple attacks? Should I make a harm_unit macro and employ the macro 4 times in a row? What would you do?

I've tried [animate_unit], with no success.

Thanks.

Code: Select all

	[move_unit]
		id=OrcishAssassin # 				hp=26
		to_x=6 #					orcish assassin moves adjacent to giant scorpion
		to_y=4
	[/move_unit]	
	[harm_unit]
		[filter]
			type=Orcish Assassin
		[/filter]
		[filter_second]
			type=Giant Scorpion # 			scorpion on hex 5,4
		[/filter_second]
		amount=4 #					pincer does 4 damage
		animate=yes
		[primary_attack]
			name=pincer #				attacks with pincers
		[/primary_attack]
		[secondary_attack]
			name=dagger #				orc defends with dagger
		[/secondary_attack]
		experience=yes # 				giant scorpion gains xp for killing orcish assassin	
	[/harm_unit]
	[kill]
		x,y=6,4 #					orcish assassin dies
		animate=yes
	[/kill]
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
vghetto
Posts: 755
Joined: November 2nd, 2019, 5:12 pm

Re: Using [harm_unit] within a cut-scene

Post by vghetto »

Call harm_unit four times with kill=yes on the last one and kill=no on the ones before
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: Using [harm_unit] within a cut-scene

Post by Helmet »

vghetto wrote: November 19th, 2020, 5:10 am Call harm_unit four times with kill=yes on the last one and kill=no on the ones before
Oh! Thanks.

Does someone know why my code to make the Giant Scorpion attack with its pincers doesn't work? It looks weird when the orcish Assassin screams "Ug!" and then twirls and falls over for no apparent reason.

Am I mistaken? Does harm_unit not display attack animations?

The coding of my campaign is near completion. I'm finally at the stage where I'm adding cut-scenes and small improvements. Could this be my last question on the coding of this campaign? If you haven't answered one of my zillion questions over the past couple months or so, this might be your last chance! :D
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: Using [harm_unit] within a cut-scene

Post by WhiteWolf »

I think you need to be more specific in your filters. You see, just writing type="Giant Scorpion" will match the first scorpion the game finds on the map! It's highly likely that if you have several, then it will find one that is not the one adjacent to the orc, and if the attacker is not adjacent, then it will not be animated.
If you know the id of this scorpion, use that in your filter. Same goes for the orcish assassin, since this event currently harms all orcish assassins on the map. You know the coordinates, so you can already put

Code: Select all

[filter]
    x,y=6,4
[/filter]
there. If you don't know the ID or the coordinates of the attacker scorpion, then you'll need to store the units that are adjacent to the orc, and identify the attacker there in a for loop.

EDIT: so just to clarify:
Filter finds and harms all units that pass the filter.
FIlter second uses the FIRST unit the game finds that matches the filter. Source.
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: Using [harm_unit] within a cut-scene

Post by Helmet »

Thanks, I'll try again and be more specific with the filter. But there was only 1 Giant Scorpion and 1 Orcish Assassin on the map, so it seems to me like type should have worked.

. . .

EDIT: Okay, I gave each unit an id and tried that, and it didn't work. Then I tried filtering for their x,y coordinates, and it didn't work.

Attached is my test campaign called "Terrain_Test", where I try-out new code. Line 100 is the where the problem begins, if you want to give it a look.
Attachments
Terrain_Test.zip
(2.5 MiB) Downloaded 138 times
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: Using [harm_unit] within a cut-scene

Post by WhiteWolf »

Before I do that, one more thing I noticed: both attack filters should be pincers. Primary attack sets the weapon against which the harmed unit will defend, and secondary attack sets the weapon that the harming unit will use to attack. See if it works after setting both to pincers?
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: Using [harm_unit] within a cut-scene

Post by Helmet »

Oops. I thought secondary_attack was the weapon that the defending unit would use to counter-attack. Thanks for explaining.

Anyhow, I changed secondary_attack to "pincer" and the Giant Scorpion is still motionless.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
vghetto
Posts: 755
Joined: November 2nd, 2019, 5:12 pm

Re: Using [harm_unit] within a cut-scene

Post by vghetto »

try name=pincers <- plural
or try using the type=impact instead
leave secondary_attack empty
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: Using [harm_unit] within a cut-scene

Post by WhiteWolf »

Because unless it's a custom scorpion, it's "pincers" and not "pincer" ;) Mind the plural.

(EDIT - off topic mention: Why do I no longer get the "someone was faster by a minute and already made a post, do you want to reformulate your post before submitting?" message anymore? It's just as it happened in my report here again. :hmm: Anyway, just as vghetto said.)
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: Using [harm_unit] within a cut-scene

Post by Helmet »

vghetto wrote: November 19th, 2020, 5:27 pm try name=pincers <- plural
or try using the type=impact instead
leave secondary_attack empty
Success! Thanks.

Man, I thought I had checked that word for plural or singular.

Side note: Yo, developers. Please make 1.16 recognizes singular, plural, capitalized, and common misspellings for all the keys, that way I can write pincer, pincers, Pincher, and pinchers and they all work. ^_^
WhiteWolf wrote: November 19th, 2020, 5:29 pm Because unless it's a custom scorpion, it's "pincers" and not "pincer" ;) Mind the plural.
Thanks. I was hoping my mistakes were getting more sophisticated, but that was a huge noob mistake. Ugg.
WhiteWolf wrote: November 19th, 2020, 5:29 pm (EDIT - off topic mention: Why do I no longer get the "someone was faster by a minute and already made a post, do you want to reformulate your post before submitting?" message anymore? It's just as it happened in my report here again. :hmm: Anyway, just as vghetto said.)
I remembering someone posted that same question. It may've been ages ago though, as I read old threads. I tried to find the moderator's reply, but couldn't. There was a reply, though.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: Using [harm_unit] within a cut-scene

Post by Helmet »

Is there a way to activate the Orcish Assassin's defend animation?

When he is harmed by the Giant Scorpion via harm_unit, he doesn't flinch or anything. He just stands there.

Thanks.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: Using [harm_unit] within a cut-scene

Post by WhiteWolf »

Did you leave secondary_attack empty in the end? If left to empty, then set that one to pincers too, that should solve the defend animation IIRC.
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: Using [harm_unit] within a cut-scene

Post by Helmet »

Hi, thanks for the reply. I tried it, but it didn't work. I don't understand why, it seems like it should work.

Code: Select all

[harm_unit]
	[filter]
		x,y=6,4 #			Orcish Assassin
	[/filter]
	[filter_second]
		x,y=5,4 # 			Giant Scorpion
	[/filter_second]
		amount=4
		animate=yes
	[primary_attack]
		name=pincers
	[/primary_attack]
 		delay=0
	[secondary_attack]
		name=pincers
	[/secondary_attack]
[/harm_unit]
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: Using [harm_unit] within a cut-scene

Post by WhiteWolf »

Well, I finally made a real ingame test instead of guessing around, and yeah, I can't get the defender to get animated either :hmm: Since according to the wiki, the animation key accepts special values like only attacker or only defender, from that I deduce that the simple yes setting should indeed animate both. Now it sounds more like a Wesnoth bug to me then, but someone will need to confirm this.
I actually recall having come across this issue before, and I may have found out a workaround for it, but I can't seem find it anymore. At least, in my files where I checked now, I settled for having only the attacker animated.

Alternatively, you could revert to [animate_unit], it'll get the job done, but maybe not as nicely.
(It also has its own issues, at least I consciously avoid using it because it's very glitchy for me, but my report from 2019 received no backup from anyone else since, so it may be just something with my setup and it might work for you.)
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: Using [harm_unit] within a cut-scene

Post by Helmet »

Thanks for testing the code. You rock.
WhiteWolf wrote: November 21st, 2020, 2:48 pm...I deduce that the simple yes setting should indeed animate both. Now it sounds more like a Wesnoth bug to me then, but someone will need to confirm this.
I'll wait a couple days, and if nobody chimes in with a solution or explanation, I'll report it as a bug. Animated cut-scenes are both cool and important, so even if it's not a bug, I hope a developer adds defend-animation functionality to harm_unit.
WhiteWolf wrote: November 21st, 2020, 2:48 pm Alternatively, you could revert to [animate_unit], it'll get the job done, but maybe not as nicely.
Hmm. I'd rather not. I'm trying to keep my code easy to understand, and the time I tried using animate_unit did not go well. Anyhow, the Orcish Assassin is standing waist-deep in a swamp water terrain, so I can live with him not flinching when he's hit. Unless, of course, harm_unit can manage it somehow.

Is there a way to make the orc emit his "Uhg" sound when he's hit? That would add some realism to the fight, perhaps as much as a defend animation.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
Post Reply