Is there a way to disable attacking certain units?

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.
Post Reply
tadzix2k
Posts: 7
Joined: August 4th, 2019, 8:16 pm

Is there a way to disable attacking certain units?

Post by tadzix2k »

I came up with the weapon special for a fencer-like unit: Challenge.

If the units attacks the oponent, it challenges it for a duel. Both unit would receive status "challenged" and will not be able to move and attack any other units but each other until one of them gets killed. Also none of the other units are able to attack the challenged units.

While I have more or less the idea how to filter units (status challenged and variable inside unit that would contain the id of the challenged oponent), I have no idea how to make attack certain units impossible. Do you know how can I do it?
User avatar
ChaosRider
Posts: 1506
Joined: April 15th, 2012, 1:15 pm

Re: Is there a way to disable attacking certain units?

Post by ChaosRider »

Change challanged units resistances (blade, pierce, impact, cold, fire, arcane) to 100% and for their weapons give damage type called "challange". So only challanged will be able to deal dmg to eachother.
Other option would be to give weapon special with chance to hit 0% to units that werent challanged when they try to attack challanged unit. Only unit that was challanged wouldnt get that 0% chance to hit weapon special.
Ofcourse there is weapon special berserk which makes fight 30 times longer so only one unit will survive it.
Creator of WOTG (+6800 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.18 Wesnoth server.
User avatar
Ravana
Forum Moderator
Posts: 3577
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Is there a way to disable attacking certain units?

Post by Ravana »

[disable]
User avatar
octalot
General Code Maintainer
Posts: 827
Joined: July 17th, 2010, 7:40 pm
Location: Austria

Re: Is there a way to disable attacking certain units?

Post by octalot »

Turn them into statues with [petrify], and add a right-click menu to unpetrify, do a scripted attack, and petrify again. At end of turn, do the scripted attack if it hasn't happened yet.
User avatar
Spannerbag
Posts: 979
Joined: December 18th, 2016, 6:14 pm
Location: Yes

Re: Is there a way to disable attacking certain units?

Post by Spannerbag »

A thought: you could temporarily give the challenger the [berserk] melee special although that alone wouldn't absolutely guarantee that one combatant would die (even if you increased number of rounds of combat above the usual 30).

This could be added via [effect], maybe inside a 1 turn duration [object] so the [berserk] goes away when the turn ends.

Assuming you're using v1.18 or later you could try using the pre attack event to add [berserk], but I haven't used pre attack so can't say.
Otherwise, (I think) you'll have to have [berserk] in place prior to actually attacking - not sure, haven't experimented.

Presumably this will only happen when the challenger attacks and never when the challenger is attacked by an enemy on their turn?
If you want challenge to operate in retaliation also this is probably possible but more complicated.

Anyway, there are several ways to bolt these bit together depending on the finer details of exactly how you want this to work/look in-game.

If nothing else hopefully this might give you a few more ideas?

It's a good idea, hope you can get it working the way you want. :fingers_crossed:

Good luck!
SP Campaigns: After EI (v1.14) Leafsea Burning (v1.18, v1.16)
I suspect the universe is simpler than we think and stranger than we can know.
Also, I fear that beyond a certain point more intelligence does not necessarily benefit a species...
tadzix2k
Posts: 7
Joined: August 4th, 2019, 8:16 pm

Re: Is there a way to disable attacking certain units?

Post by tadzix2k »

Thank you all for answers. I think [disable] is the cleanest way. Didn't know I could just filter opponents inside the special.
Post Reply