Various questions: making unit unable to be attacked
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.
- WTrawi
- Posts: 136
- Joined: July 11th, 2016, 6:04 pm
- Location: My location is not public, but I know YOURS and I can use it against you.
Various questions: making unit unable to be attacked
Hi everyone!
Currently I'm working on a campaign and I have quite a problem in WML. I want to make a unit unable to move (which isn't the problem) and also unable to attack others or to be attacked by others. The attribute "petrified" does this effect, but it also makes the unit a statue as far as I know.
Could you please help me out if you know the solution? Thanks:
WTrawi
Currently I'm working on a campaign and I have quite a problem in WML. I want to make a unit unable to move (which isn't the problem) and also unable to attack others or to be attacked by others. The attribute "petrified" does this effect, but it also makes the unit a statue as far as I know.
Could you please help me out if you know the solution? Thanks:
WTrawi
Not very active on the forum anymore, but I still read it, and I also still play Wesnoth and draw a bit.
Re: Various questions: making unit unable to be attacked
For unable to attack, there is attacks_left and max_attacks in unit.
Re: Various questions: making unit unable to be attacked
To prevent anyone from attacking it, this seems to work if your unit has both a melee and ranged attack:
Curiously, you can't use apply_to=both (nor multiple [disable] blocks) to disable both self and opponent attacks. That's probably because as self's weapon is evaluated as being disabled, its disable special won't be able to affect the opponent anymore.
Code: Select all
[object]
[effect]
apply_to=attack
[set_specials]
mode=append
[disable]
apply_to=opponent
[/disable]
[/set_specials]
[/effect]
[/object]
- skeptical_troll
- Posts: 500
- Joined: August 31st, 2015, 11:06 pm
Re: Various questions: making unit unable to be attacked
If you are happy with a dirty hack, make a hidden side controlled by 'null' and allied with everyone, then assign that side to the units you want to immobilize. They should stay still and everyone will ignore them. Just remember to bring them back at the end of the scenario.
Re: Various questions: making unit unable to be attacked
For making the unit unable to be attacked: this might not be what you need, but on 1.13 you can add the invulnerable status that prevents attacks from hitting the unit.
- WTrawi
- Posts: 136
- Joined: July 11th, 2016, 6:04 pm
- Location: My location is not public, but I know YOURS and I can use it against you.
Re: Various questions: making unit unable to be attacked
Wow, there are a lot of answers, thank you for that! Now, let's go through:
Thank you for all who answered!
I tried and it works, but only for one turn... still, it could be the right thing, but Skeptical_troll's solution does it better.Ravana wrote:For unable to attack, there is attacks_left and max_attacks in unit.
The unit is a drake enforcer which has only melee attacks, does it mean that what you wrote won't work then? Or how can it be changed to be able for using on the enforcer (because I don't understand the code you've written )Zookeeper wrote:To prevent anyone from attacking it, this seems to work if your unit has both a melee and ranged attack...
Haha, that's nice, but the game will show them as allies to the user-controlled team, which is not what I want. But I loved the idea. Oh, and setting the controller "null" is what I need to prevent the unit attacking others, so thanks for that!Skeptical_troll wrote:If you are happy with a dirty hack, make a hidden side controlled by 'null' and allied with everyone, then assign that side to the units you want to immobilize.
I know about the status "invulnerable", and yes, it isn't what I need.Jyrkive wrote:...this might not be what you need, but on 1.13 you can add the invulnerable status that prevents attacks from hitting the unit.
Thank you for all who answered!
Not very active on the forum anymore, but I still read it, and I also still play Wesnoth and draw a bit.
Re: Various questions: making unit unable to be attacked
attacks_left is one turn, max_attacks stays until changed.
Re: Various questions: making unit unable to be attacked
It sounds like you have all the pieces you need, but you just need to combine them using events. For example, you can change the unit's side to the one with controller=null at the end of the human turn (side 1 turn end), then restore it at the beginning of the human turn (side 1 turn).WTrawi wrote: Haha, that's nice, but the game will show them as allies to the user-controlled team, which is not what I want. But I loved the idea. Oh, and setting the controller "null" is what I need to prevent the unit attacking others, so thanks for that!
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
- WTrawi
- Posts: 136
- Joined: July 11th, 2016, 6:04 pm
- Location: My location is not public, but I know YOURS and I can use it against you.
Re: Various questions: making unit unable to be attacked
No, that's not true, thanks to Zookeeper and Sceptical_troll my problem is totally solved! The unit I wanted to lock has its own side withSaplent wrote:It sounds like you have all the pieces you need, but you just need to combine them using events.
controller=null
and I copied Zookeeper's code in the right place and it worked! Again, thank you so much for all who tried to help me!
Not very active on the forum anymore, but I still read it, and I also still play Wesnoth and draw a bit.
Re: Various questions: making unit unable to be attacked
I thought you weren't able to use zookeeper's code because the Drake Enforcer lacks a ranged attack? Try putting some Dark Adepts near it and see if they can attack it.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
- WTrawi
- Posts: 136
- Joined: July 11th, 2016, 6:04 pm
- Location: My location is not public, but I know YOURS and I can use it against you.
Re: Various questions: making unit unable to be attacked
Yeah, as it turned out, I wasn't. I'm still trying to use a variation of it somehow...Sapient wrote:I thought you weren't able to use Zookeeper's code because the Drake Enforcer lacks a ranged attack?
Not very active on the forum anymore, but I still read it, and I also still play Wesnoth and draw a bit.
Re: Various questions: making unit unable to be attacked
Here are a couple ideas that might or might not make sense, depending on your scenario:
1) You could give him a dummy ranged attack, something like 1-1 Intimidation, so it could have that attack special.
2) You could have an attack event that prevents combat by doing something like this, so the human could try to attack, but then nothing happens except a message or something.
1) You could give him a dummy ranged attack, something like 1-1 Intimidation, so it could have that attack special.
2) You could have an attack event that prevents combat by doing something like this, so the human could try to attack, but then nothing happens except a message or something.
The last few months have been nothing but one big, painful reminder that TIMTLTW.
Creator of Armory Mod, The Rising Underworld, and Voyage of a Drake: an RPG
Creator of Armory Mod, The Rising Underworld, and Voyage of a Drake: an RPG
- skeptical_troll
- Posts: 500
- Joined: August 31st, 2015, 11:06 pm
Re: Various questions: making unit unable to be attacked
Other possible approach: if the only reason you don' t like ' petrified' is the grey appearance, maybe you can hide the petrified unit and put on the same hex the base image of the unit
it won' t have the idle animations and the HP bars, though.
I don' t know what you are trying to do, but maybe you don' t want the player to find out that he cannot attack the unit only after he has done the (not-undoable) move.
it won' t have the idle animations and the HP bars, though.
I don' t know what you are trying to do, but maybe you don' t want the player to find out that he cannot attack the unit only after he has done the (not-undoable) move.