new type of leadership

Brainstorm ideas of possible additions to the game. Read this before posting!

Moderator: Forum Moderators

Forum rules
Before posting a new idea, you must read the following:
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: new type of leadership

Post by Dugi »

You'll have to use that filter tag inside a store_unit command and then apply a FOREACH macro to affect every unit that matches to filter. Calling allow_undo in a new turn event makes no sense, what is it supposed to allow the player to undo?
User avatar
Aldarisvet
Translator
Posts: 836
Joined: February 23rd, 2015, 2:39 pm
Location: Moscow, Russia

Re: new type of leadership

Post by Aldarisvet »

zookeeper wrote:It fundamentally doesn't make any sense. There is no unit associated with a new turn event, meaning that the [filter] is meaningless and there can be no auto-stored $unit variable.
Dugi wrote:You'll have to use that filter tag inside a store_unit command and then apply a FOREACH macro to affect every unit that matches to filter. Calling allow_undo in a new turn event makes no sense, what is it supposed to allow the player to undo?
Oh, thank you, seems I was not able to understand skeplical_troll's code enough. That was almost exact copy of the code he uses to make fire arrows from nearby drakes, but something more is needed then.
facebook.com/wesnothian/ - everyday something new about Wesnoth
My campaign:A Whim of Fate, also see it's prequel Zombies:Introduction
Art thread:Mostly frankenstains
User avatar
skeptical_troll
Posts: 500
Joined: August 31st, 2015, 11:06 pm

Re: new type of leadership

Post by skeptical_troll »

Hey Aldarisvet. The difference with my code is that in my case the change is triggered by a 'moveto' event, and the [filter] tag refers to the unit moving (in my specific case, a bowman adjacent to a drake). If you want your event to be triggered by 'new turn' then you should select the units differently. Dugi's suggestion is one possibility, the other is to use a {MODIFY_UNIT} macro inside the event and use the filter inside the macro to select the units adjacent to the 'cup girl'.

If you are not tired or reading my codes, you can look how I did it in my {INCENDIARY_RESET} macro, or just read up the documentation for {MODIFY_UNIT}. Happy to help with that if you need (feel free to PM me if necessary).

Note also that the main reason my code is complex and redundant is that I wanted to allow the player to undo the movement, so I had to hack an equivalent of the [on_undo] tag in Wesnoth 1.13. As Dugi pointed out, [allow_undo] doesn't make sense in a new turn event, so you shouldn't have this problem.
User avatar
Aldarisvet
Translator
Posts: 836
Joined: February 23rd, 2015, 2:39 pm
Location: Moscow, Russia

Re: new type of leadership

Post by Aldarisvet »

I successfully got needed effects for units near the Cup Girl at the end of turn using this code:

Code: Select all

	[event]
    name=new turn
    first_time_only=no
    {MODIFY_UNIT (
	race="monster"
	[not]
	type=Spider Hatchling
	[/not]
	# Not for the Spider Hatchling because his first and only attack is ranged web, we need to affect melee only.
	[filter_adjacent] 
	type=Cup Girl
	is_enemy=no 
	[/filter_adjacent]
	) attack[0].type "arcane"}
    [unit_overlay]
	race="monster"
	[not]
	type=Spider Hatchling
	[/not]
	# Not for the Spider Hatchling because his first and only attack is ranged web, we need to affect melee only.
	[filter_adjacent] 
	type=Cup Girl
	is_enemy=no 
	[/filter_adjacent]
	image=overlays/arcane-icon.png
    [/unit_overlay]
    [/event]
But now I need to remove effects after the first battle, whenever our 'arcaned' unit attacks or he was attacked.
I tried this:

Code: Select all

	[event]
    name=attack end
    first_time_only=no

    {MODIFY_UNIT (
	  [and]
	  type=Giant Rat1
	  [or]
	  type=Brown Rat
	  [or]
	  type=Small Spider
	  [/or]
	  [/or]
	  [/and]
) attack[0].type "blade"}

    {MODIFY_UNIT (
	[and]
	  type=Puddle Snake
	  [or]
	  type=Swamp Snake
	  [or]
	  type=Sea Serpent
	  [/or]	  
	  [/or]	  
	[/and]
) attack[0].type "pierce"}

	[remove_unit_overlay]
	race="monster"
	image=overlays/arcane-icon.png
	[/remove_unit_overlay]
    [/event]
...but this affects not only unit involved on the attack but all units. How I should adress only attacked unit, then check if attacks needed to be back to blade or to pierce?
I read that "You can access the filtered unit within the filter as the $this_unit variable, see SingleUnitWML for the possible content of these variables" but I simply cannot produce a new code without examples of similar code.
facebook.com/wesnothian/ - everyday something new about Wesnoth
My campaign:A Whim of Fate, also see it's prequel Zombies:Introduction
Art thread:Mostly frankenstains
User avatar
Ravana
Forum Moderator
Posts: 3003
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: new type of leadership

Post by Ravana »

$unit and $second_unit. Damage type can be got from some autostored variable as well.
User avatar
Aldarisvet
Translator
Posts: 836
Joined: February 23rd, 2015, 2:39 pm
Location: Moscow, Russia

Re: new type of leadership

Post by Aldarisvet »

Ravana wrote:$unit and $second_unit. Damage type can be got from some autostored variable as well.
Well, I tried this -

Code: Select all

  [switch]
            variable=$unit.type
            [case]
                value=Puddle Snake, Swamp Snake, Sea Serpent
                $unit.attack[0].type=pierce
            [/case]
            [case]
                value=Giant Rat1, Brown Rat, Small Spider
                $unit.attack[0].type=blade
            [/case]
        [/switch]

        [switch]
            variable=$second_unit.type
            [case]
                value=Puddle Snake, Swamp Snake, Sea Serpent
                $unit.attack[0].type=pierce
            [/case]
            [case]
                value=Giant Rat1, Brown Rat, Small Spider
                $unit.attack[0].type=blade
            [/case]
        [/switch]
This does not work. Is there any reference about object system tree used in this language?
Is it this - https://wiki.wesnoth.org/LuaWML/Units ? Then I was right about using $unit.type but there is no 'attack' property in this list, only 'attacks' for 1.13

It is no more WML obviously, working with variables in such way is like Javascript compared to HTML, I feel totally helpless. Moreover, I need to remove an overlay, how I would address a property of the unit object concerning its overlay to manipulate it?

EDIT:
Looking on Eo4M hex ability I found a solution for the overlay -
[unit_overlay]
x,y=$unit.x,$unit.y
image="utils/curse.png"
[/unit_overlay]

So I have to use [remove_unit_overlay] and my image adress instead!
facebook.com/wesnothian/ - everyday something new about Wesnoth
My campaign:A Whim of Fate, also see it's prequel Zombies:Introduction
Art thread:Mostly frankenstains
User avatar
Aldarisvet
Translator
Posts: 836
Joined: February 23rd, 2015, 2:39 pm
Location: Moscow, Russia

Re: new type of leadership

Post by Aldarisvet »

This coordinate trick with filtering helped me greatly, I used it also in MODIFY UNIT macro too (so there is no need in [switch] or [if]),
So the final code for removing arcane effect after the first fight follows, still cant believe I did it :o

Code: Select all

	[event]
    name=attack end
    first_time_only=no

   {MODIFY_UNIT (
     type=Giant Rat1
     [or]
     type=Brown Rat
     [or]
     type=Little Spider
     [/or]
     [/or]
     [and]
	x,y=$unit.x,$unit.y
     [or]
	x,y=$second_unit.x,$second_unit.y
     [/or]
     [/and]
) attack[0].type "blade"}

    {MODIFY_UNIT (
     type=Puddle Snake
     [or]
     type=Swamp Snake
     [or]
     type=Sea Serpent
     [/or]     
     [/or]     
   [and]
	x,y=$unit.x,$unit.y
     [or]
	x,y=$second_unit.x,$second_unit.y
     [/or]
   [/and]
) attack[0].type "pierce"}

	[remove_unit_overlay]
	x,y=$unit.x,$unit.y
	image=overlays/arcane-icon.png
	[/remove_unit_overlay]

	[remove_unit_overlay]
	x,y=$second_unit.x,$second_unit.y
	image=overlays/arcane-icon.png
	[/remove_unit_overlay]

    [/event]
facebook.com/wesnothian/ - everyday something new about Wesnoth
My campaign:A Whim of Fate, also see it's prequel Zombies:Introduction
Art thread:Mostly frankenstains
User avatar
Ravana
Forum Moderator
Posts: 3003
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: new type of leadership

Post by Ravana »

Code: Select all

[switch]
	variable=$unit.type - where you set the variables for each possible unit_type?
	[case]
		value=Puddle Snake, Swamp Snake, Sea Serpent
		$unit.attack[0].type=pierce - what is this supposed to be?
	[/case]
	[case]
		value=Giant Rat1, Brown Rat, Small Spider
		$unit.attack[0].type=blade - what is this supposed to be?
	[/case]
[/switch]
User avatar
Aldarisvet
Translator
Posts: 836
Joined: February 23rd, 2015, 2:39 pm
Location: Moscow, Russia

Re: new type of leadership

Post by Aldarisvet »

Ravana wrote:what is this supposed to be?
Look, I am an economist, not a programmist. I had an experience of programming in many languages while not understaning even the basics. I am like a Sharlatan unit from the Age of Wonders, the master of everything and the master of nothing at the same time :D
facebook.com/wesnothian/ - everyday something new about Wesnoth
My campaign:A Whim of Fate, also see it's prequel Zombies:Introduction
Art thread:Mostly frankenstains
User avatar
Ravana
Forum Moderator
Posts: 3003
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: new type of leadership

Post by Ravana »

Well, if you meant to set variable (classical meaning of = in coding) then {VARIABLE unit.attack[0].type pierce}.
User avatar
Aldarisvet
Translator
Posts: 836
Joined: February 23rd, 2015, 2:39 pm
Location: Moscow, Russia

Re: new type of leadership

Post by Aldarisvet »

Ravana wrote:Well, if you meant to set variable (classical meaning of = in coding) then {VARIABLE unit.attack[0].type pierce}.
I was obviously to return the value of the variable (the property of the unit object) back from the arcane to the original status.
If this VARIABLE macros will do for this, then thank you, got it. However this does not matter in the particular case already because I already had the working solution, but I can use it in the future.
facebook.com/wesnothian/ - everyday something new about Wesnoth
My campaign:A Whim of Fate, also see it's prequel Zombies:Introduction
Art thread:Mostly frankenstains
User avatar
Aldarisvet
Translator
Posts: 836
Joined: February 23rd, 2015, 2:39 pm
Location: Moscow, Russia

Re: new type of leadership

Post by Aldarisvet »

Well, I succesfully implemented this new feature to the second scenario of Zombies:Introduction.
Again the idea is that a unit gains some special ability after he meets new turn near the leader-infester. This special ability marked with a layer on the unit's sprite and unit retain the ability until the first battle ends. In case of Z:I 'infested' unit gets arcane attacks. Btw I would greatly appreciate some feedback about this on Z:I.

But what I understand, this feature can be used far broadly than for things I mentioned in the first post of this thread. I mean, it can be more than marksman/skirmisher/poison/slowing/fire attack/holy attack.
It can be every of Unit Specialities or Abilities.

For example, imagine a unit that was 'insfested' with berserkering, but again, this is only for one fight. So you should think twice whether you should infest a unit with it (of course you can implement standart leadership that grants berserkering to leaders' nearby units, possibly it was already implemented). You can grant temprorary drain, backstab or charge ability until the next battle. But comparing to normal leadership this infestation type creates new possibilities because it can be not about combat abilities but about non-combat too (whenever with standart leadership this does not have much sense). Imagine that a unit can get levitation (can fly) until the next battle or can get additonal bounus to MP or get another type of terrain defence/movement until the next battle; can get ambush, nightstalk, submerge or to be totally invisible until the next battle. So everything you can imagine, what was earlier granted in the game by effects of artifacts, as soon that you have that infestation-leader. But you can give to the player one type of this infestation-leader in one scenario and give totally another leader in another scenario whenever once you got an artifact, you have that effect permanently but only for one unit.
facebook.com/wesnothian/ - everyday something new about Wesnoth
My campaign:A Whim of Fate, also see it's prequel Zombies:Introduction
Art thread:Mostly frankenstains
Post Reply