Bitrons WML Questions

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
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Bitrons WML Questions

Post by Bitron »

Hey Guys !

Im trying to build a new ability, called "Inspiration". It's kind of an aura wich inspires or motivates adjacent units.
(the ability is for a unit called "War Drummer")
Unfortunately, i'm totally lost with coding.. i tried for several days now and couldnt make it.
And now I'm asking you for help.

The ability should give allied adjacent units +1 Movementpoint and +1 damage to both melee and ranged attacks, as well as a +10% defense bonus till end of turn. (at least the level 3 version of the ability)

Thanks for help in advance!

all the best,

- Bitron
Last edited by Bitron on December 30th, 2016, 11:07 pm, edited 1 time in total.
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: [Ability] - Inspiration

Post by Dugi »

Doing that is very non-trivial. The +1 movement can be done by an event that adds a movement points to each unit next to an inspirator. The other two can be only done as weapon specials possessed by all units that can potentially be affected that would be filtered to work only if they have an inspirator adjacent.

Do you want to bother with a bit complicated code I can help you with or are you giving up?
User avatar
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: [Ability] - Inspiration

Post by Bitron »

maybe i should tell you that im totally new to WML :7

Okay. I do get the first one about the Movingpoints, Ill try that.

but i don't get the second part at all... Well.. so I only can "buff" units wich have a that weaponspezial.. that sound quite complicated. there has to be an easier way.

(edit: actually i have no clue how to do it cause i don't know the syntax)
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: [Ability] - Inspiration

Post by beetlenaut »

These effects are supposed to last until the end of the turn, so can't this be done fairly easily with an [object]? You would use a moveto event to hand out an object to any unit that is currently adjacent to the War Drummer and who doesn't already have one.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: [Ability] - Inspiration

Post by Bitron »

For the Movementpoints i tried this:

Code: Select all

#define ABILITY_INSPIRATION_LEVEL_1
[dummy]
    id=inspiration
    name= _ "Inspiration"
    description=  _ "Inspires adjacent units and makes them faster and stronger."
[/dummy]
	
[/abilities]
	[event]
	name=side turn
	first_time only=no
		[object]
			duration=turn
			[filter_adjacent]
				has_ability=inspiration
			[/filter_adjacent]
			[effect]
				apply_to=movement
				increase=1	
			[/effect]
		[/object]
	[/event]
[+abilities]
#enddef
but it doesn't work.
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: [Ability] - Inspiration

Post by Dugi »

That adds only one object, to one of the nearby units, and I am not certain if has_ability works, I rather think that it doesn't. Furthermore, its effect is permanent and stacks with itself. Because movement points are restored only at the beginning of the turn, I don't think that an object is necessary.

Code: Select all

[event]
  name=turn refresh # After the normal restoration of movement
  first_time_only=no
  id=inspiration_movement_event
  [store_unit]
    [filter]
      [filter_adjacent] # Grab all units standing next to units with inspiration
        ability=inspiration
        [filter_side] # Don't get inspired by enemies
          is_enemy=no
        [/filter_side]
      [/filter_adjacent]
    [/filter]
    variable=inspired
  [/store_unit]
  {FOREACH inspired i} # Repeat this for every inspired unit
    {VARIABLE_OP inspired[$i].moves add 1} # Add 1 movement point to the moves restored to maximum
    [unstore_unit] # Return it back to the game
      variable=inspired[$i]
      find_vacant=no
    [/unstore_unit]
  {NEXT i}
  {CLEAR_VARIABLE inspired} # Clean up
User avatar
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: [Ability] - Inspiration

Post by Bitron »

ohh i see, there's much more.

Well. could it be possible to do something like:

Code: Select all

[...]
{FOREACH inspired i} # Repeat this for every inspired unit
{VARIABLE_OP inspired[$i].moves add 1} # Add 1 movement point to the moves restored to maximum
{VARIABLE_OP inspired[$i].attack[0].damage add 1} # Add 1 damage to the first attack of that unit
[...]
oh wait... it wouldn't reset at the end of the turn, right ? thats why it works with movement points, they will reset anyway.

Edit: i have tested it now and it triggers every turn, even in the opponents. it's doesnt really matter 'cause one can't move the units anyway in the opponent's turn, but its kinda weird.
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: [Ability] - Inspiration

Post by beetlenaut »

Dugi wrote:Because movement points are restored only at the beginning of the turn, I don't think that an object is necessary.
But for defense and attack bonuses, using an object is necessary. Getting the movement working with an object would be a good idea, because then all you would have to do to finish the ability would be to apply the object's effect to the other two stats. You wouldn't have to write much new code. It was just a suggestion though.
Bitron wrote:oh wait... it wouldn't reset at the end of the turn, right ? thats why it works with movement points, they will reset anyway.
Right.
Bitron wrote:Edit: i have tested it now and it triggers every turn, even in the opponents. it's doesnt really matter 'cause one can't move the units anyway in the opponent's turn, but its kinda weird.
You can specify a side for "side refresh" if you want. However, I think it might be better to leave it like this. This way the enemy would be able to see how far the inspired units will be able to move.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: [Ability] - Inspiration

Post by Dugi »

I am not quite sure how would you even do that with objects. The unit gains the extra damage at some point, then goes away, attacks an enemy a few hexes away and the buff remains. You need a special weapon special:

Code: Select all

[damage]
  id=inspiration_damage
  add=1
  apply_to=self
  [filter_self]
    [filter_adjacent] # Always check if the conditions are met for it to have an effect
      ability=inspiration
      is_enemy=no
    [/filter_adjacent]
  [/filter_self]
[/damage]
[chance_to_hit]
  id=inspiration_chance_to_hit
  sub=10
  apply_to=opponent
  [filter_self]
    [filter_adjacent]
      ability=inspiration
      is_enemy=no
    [/filter_adjacent]
  [/filter_self]
[/chance_to_hit]
User avatar
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: [Ability] - Inspiration

Post by Bitron »

Dugi wrote:The unit gains the extra damage at some point, then goes away, attacks an enemy a few hexes away and the buff remains.
Its stackable then, right? I think that would be to powerful. One could just stay next to the Inspirator and it will stack turn by turn. Imagine there are 9 players.. so it would add 9 damage till I'm in my next round.

when does the "Spezial attack" trigger? Or is it like .. always on and every time I move next to a Inspirator i get a buff?
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: [Ability] - Inspiration

Post by Dugi »

My implementation of the increased movement is not stackable. With an [object], you would have to be careful. The error that enemies inspire your units too can be fixed by replacing the part is_enemy=no by enemy_of=$side_number. My WML coding skills slowly rust and I am making mistakes.

The implementation of the increase in damage and reduction in chance to get hit is not stackable, but you have to be careful and make sure that every unit affected by inspiration has it (it is invisible and does nothing without an adjacent inspirator, so there's no problem with having it all the time) and has it only once. You can add it with [object] in a start event to all units and then to any recruited units or just by giving it to the unit types (which is the easiest, especially if you are not using core units). Adding the object just in time is very hard - the inspirator can arrive next to the unit, the unit can come to the inspirator, the unit can be recruited next to the inspirator, it may be added through an event; insanely hard to handle all the options.
User avatar
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: [Ability] - Inspiration

Post by Bitron »

Okay, I will try it tomorrow, bed's calling me :'D
Anyway thanks a lot for helping me Dugi! I really apprechiate that!
User avatar
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: [Ability] - Inspiration

Post by Bitron »

good morning (:

Well, first i tried to implement it as an Ability, but that hasnt worked, so i just implement it as a weapon special and it worked, but only if the Inspirator stands next to the inspired unit. as soon as the unit moves away from the Inspirator, the buff disappears.
Dugi wrote:Adding the object just in time is very hard - the inspirator can arrive next to the unit, the unit can come to the inspirator, the unit can be recruited next to the inspirator, it may be added through an event; insanely hard to handle all the options.
It should trigger if the unit stands next to the Inspirator at the beginning of the turn, nothing more. just like the healing ability (:
And the buff should last till end of turn, even if I move the unit away from the Inspirator.
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: [Ability] - Inspiration

Post by Dugi »

I thought you wanted the bonuses to behave like leadership, working if the inspirator is adjacent at the time of attack. In that case, you can use either a short duration [object] (must be after the [unstore_unit], but before the {NEXT i} in the event code, otherwise it will not work) or replace the part:

Code: Select all

  [filter_self]
    [filter_adjacent] # Always check if the conditions are met for it to have an effect
      ability=inspiration
      is_enemy=no
    [/filter_adjacent]
  [/filter_self]
with

Code: Select all

  [filter_self]
    [filter_wml]
      [variables]
        inspired=yes
      [/variables]
    [/filter_wml]
  [/filter_self]
then add

Code: Select all

{VARIABLE inspired[$i].variables.inspired yes}
before the [unstore_unit] tag and add this event:

Code: Select all

[event]
  name=side turn # Fires before the event that sets the units as inspired
  first_time_only=no
  id=inspiration_fade
  [store_unit]
    [filter]
      side=$side_number # A small correction, add this line also in the other event
      [filter_wml]
        [variables]
          inspired=yes
        [/variables]
      [/filter_wml]
    [/filter]
    variable=inspired
  [/store_unit]
  {FOREACH inspired i}
    {CLEAR_VARIABLE inspired[$i].variables.inspired} # Remove the mark that the unit is inspired
    [unstore_unit]
      variable=inspired[$i]
      find_vacant=no
    [/unstore_unit]
  {NEXT i}
  {CLEAR_VARIABLE inspired}
[/event]
User avatar
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: [Ability] - Inspiration

Post by Bitron »

wait .. shall i edit the weapon_special code or the Inspiration-Ability Code ?

and with the object.. is that correct than? :

Code: Select all

[/abilities]
	[event]
  		name=turn refresh # After the normal restoration of movement
  		first_time_only=no
  		id=inspiration_movement_event
  		[store_unit]
   			[filter]
      			[filter_adjacent] # Grab all units standing next to units with inspiration
        			ability=inspiration
        			[filter_side] # Don't get inspired by enemies
          				is_enemy=no
        			[/filter_side]
     	 		[/filter_adjacent]
    		[/filter]
    		variable=inspired
  		[/store_unit]
  		{FOREACH inspired i} # Repeat this for every inspired unit
    	{VARIABLE_OP inspired[$i].moves add 1} # Add 1 movement point to the moves restored to maximum
    		[unstore_unit] # Return it back to the game
      			variable=inspired[$i]
      			find_vacant=no
    		[/unstore_unit]
        [object]
          silent=yes
          duration=turn
          [effect]
            increase_damage=1
            increase_accuracy=10
          [/effect]
        [/object]
  		{NEXT i}
  		{CLEAR_VARIABLE inspired} # Clean up
	[/event]
[+abilities]
Post Reply