Creating Poison like effect with Plague effect at 0 HP?

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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.
RandomPlayers
Posts: 8
Joined: March 21st, 2012, 7:03 pm

Creating Poison like effect with Plague effect at 0 HP?

Post by RandomPlayers »

I've spent most of the day searching for a answer to the question, but what information I can find is some combination of outdated, vague or contradictory.

So I ask:
What would I do to create a special for a attack that causes damage per turn like poison does and if a unit dies while under the effect (Including from the per turn damage AND normal combat) it rises as a walking corpse on the side of the unit that inflicted the status?

To my understanding it should be possible with events, but as I said: What information I can find is some combination of outdated, vague or contradictory.

I just need to know what to use and maybe a example in either a existing addon or another topic. Not expecting to be spoon feed here.

Note that I'm fairly new to this, so please use the full names of what you suggest, not shorthands or nicknames. (Easier for me to try to find it then)

User avatar
Dugi
Posts: 4960
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Creating Poison like effect with Plague effect at 0 HP?

Post by Dugi »

It can be done, but it is fairly complicated and if you are a newbie as you say, better try to make something else before this.

Make a dummy weapon special, an an event that triggers if an attacker hits with that weapon special. It would do {VARIABLE second_unit.status.zombified $side_number} and unstore it, tagging the unit for another event. Then you would use another event, that triggers when on every side turn. It would store the entire side, find all units with a value for the zombified status, and store their IDs into a variable array. Then for each zombified unit, it would lower their hp by 8, and if they have less than 8 hp, the side that zombified them will be stored in another variable, they would advance to a zombie and get modified to belong to the side of the zombifier. Also a last breath event that advances them to zombies when they die.

The unit would be able to heal from zombification only by advancing, but you might want to add an even that if a zombified unit stands in a village at the beginning of a turn, it will be unzombified {CLEAR_VARIABLE zombified_unit.status.zombified}.

I hope you understand it, if you don't and you still want it, you may ask me to write it.

RandomPlayers
Posts: 8
Joined: March 21st, 2012, 7:03 pm

Re: Creating Poison like effect with Plague effect at 0 HP?

Post by RandomPlayers »

I think I have a rough idea of what you mean atleast so I can try on my own, but one thing that eludes me is where the events that are meant to trigger are meant to be stored? One post I found talked about placing such things in util.cfg, but doing that only caused Wesnoth to say it couldn't load the Era.

I presume the bit for adding the status could be stored inside the unit that does it, but for the damage and zombiefication I presume that doesn't work?

In my opinion, the 'wiki' parts meant to explain these things need reorganizing and rewriting.

User avatar
Dugi
Posts: 4960
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Creating Poison like effect with Plague effect at 0 HP?

Post by Dugi »

Place them into the era tag, or into the unit tag (of the zombificator), that should not fail.

Files named 'utils.cfg' are usually used to store macros, and they usually have to be linked in the _main.cfg file or right inside the era.

RandomPlayers
Posts: 8
Joined: March 21st, 2012, 7:03 pm

Re: Creating Poison like effect with Plague effect at 0 HP?

Post by RandomPlayers »

I've been trying, but I can't even get the variable to get stored. Am I using the completly wrong command or something? How badly did I mess up in general?

Code: Select all

    [event] 
        name=attacker hits
        first_time_only=no
        [filter]
            special=strongplague
        [/filter]
		[if]
		    [variable_second]
				name=plagued
				not_equals=yes
			[/variable_second]
			[then]
        		[set_variable]
        	    	name=second_unit.variables.plagued
        	    	value=yes
        		[/set_variable]
        		[unstore_unit]
        	    	variable=second_unit
        	    	{COLOR_HARM}
        	    	text= _ "plagued"
        		[/unstore_unit]
			[/then]
		[/if]
    [/event]
    [event] 
        name=defender hits
        first_time_only=no
        [filter_second]
            special=strongplague
        [/filter_second]
		[if]
		    [variable]
				name=plagued
				not_equals=yes
			[/variable]
			[then]
        		[set_variable]
        	    	name=unit.variables.plagued
        	    	value=yes
        		[/set_variable]
        		[unstore_unit]
        	    	variable=unit
        	    	{COLOR_HARM}
        	    	text= _ "plagued"
        		[/unstore_unit]
			[/then]
		[/if]
    [/event]

edit: Do'h, noticed I messed up a bit and didn't use the command you said. One moment while I try to get that to work instead.

User avatar
Dugi
Posts: 4960
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Creating Poison like effect with Plague effect at 0 HP?

Post by Dugi »

You have used the condition inside the [if] tag wrongly, and also the attack filter. It should be:

Code: Select all

    [event] 
        name=attacker hits
        first_time_only=no
        [filter_attack]
            special=strongplague
        [/filter_attack]
      [if]
          [variable]
            name=second_unit.plagued
            equals=yes
         [/variable]
         [else]
              [set_variable]
                  name=second_unit.variables.plagued
                  value=yes
              [/set_variable]
              [unstore_unit]
                  variable=second_unit
                  {COLOR_HARM}
                  text= _ "plagued"
              [/unstore_unit]
         [/else]
      [/if]
    [/event]
    [event] 
        name=defender hits
        first_time_only=no
        [filter_second_attack]
            special=strongplague
        [/filter_second_attack]
      [if]
          [variable]
            name=unit.plagued
            equals=yes
         [/variable]
         [else]
              [set_variable]
                  name=unit.variables.plagued
                  value=yes
              [/set_variable]
              [unstore_unit]
                  variable=second_unit
                  {COLOR_HARM}
                  text= _ "plagued"
              [/unstore_unit]
         [/else]
      [/if]
    [/event]
You were saving the variables inside the units, but looking for them in scanario variables.
Your main problem was that you wrongly used the attack filter, it should have been [filter_attack] instead of [filter], you need to filter the attack, not the unit.
My code should work.

And by way, to filter a unit that is strongplagued (why not zombified...), you will need to use this:

Code: Select all

[filter]
  [filter_wml]
    [variables]
      plagued="yes"
    [/variables]
  [/filter_wml]
[/filter]

User avatar
francophone
Posts: 393
Joined: February 20th, 2010, 2:19 pm

Re: Creating Poison like effect with Plague effect at 0 HP?

Post by francophone »

RandomPlayers wrote:it rises as a walking corpse on the side of the unit that inflicted the status
With "on the side" you mean that the unit changes position or just camp?
If I understand: the unit must change position. On the one hand it is very difficult to do: we must create variables for each unit achieved by linking one who has infested, etc.. On the other hand, I do not understand the interest. A zombie becomes it in the dying and he is where he fell.

It would be for an invocation, so from the beginning in the camp of the summoner, it might be interesting that the summoner can recall his invocation at his side. But with zombies, I do not understand the logic.

If the unit does not change position, it makes the operation more than real zombies. Instead of becoming zombies being killed by the unit that infects, it becomes so after infection, when he dies. Logical for a zombie. And feasible in WML: create an infected status and transform units with an event "die" and a filter of infected status.
But attention to the gameplay. For example if zombies lvl 0 and cheap so that can be very numerous, difficult to kill an enemy unit, but touch many units one time, before dying, therefore infecting many enemy units. Such capability can become hellish and give too great an advantage. conversely, it might be interesting in a campaign.
Otherwise, I wonder if it is possible limit a weapon special, giving a % chance of having the special effect every time the unit hits. For example, have 50% to infest every time it touches. But I do not know if this is possible. It would be interesting for other weapon special.

RandomPlayers
Posts: 8
Joined: March 21st, 2012, 7:03 pm

Re: Creating Poison like effect with Plague effect at 0 HP?

Post by RandomPlayers »

To explain a bit so the use for this is understood then:
In the era this is for, the zombie units are renamed and a third is added.
Walking Corpse becomes "Risen" (Still level 0)
Souless is now "Reborn" (Still Level 1)
And the third is "Undying" (A level 2 unit, as you might have guessed. Reborn advances to this)
It is the Undying that is intended to have this ability. The Risen and Reborn have the normal plague.
The intention being for the Undying to hit a enemy, and it acts more or less like poison, dealing damage per turn until the enemy is cured in a village or turns into a Risen on the spot it died at when it reaches 0 hp.

User avatar
Dugi
Posts: 4960
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Creating Poison like effect with Plague effect at 0 HP?

Post by Dugi »

francophone wrote:
RandomPlayers wrote:it rises as a walking corpse on the side of the unit that inflicted the status
With "on the side" you mean that the unit changes position or just camp?
If I understand: the unit must change position. On the one hand it is very difficult to do: we must create variables for each unit achieved by linking one who has infested, etc.. On the other hand, I do not understand the interest. A zombie becomes it in the dying and he is where he fell.
No, just at the side turn event. At the start of the turn, when the units heal and take poison damage, the zombified unit will take damage like if it was poisoned and become a zombie if it's time.

If the unit created with that plague has to have the zombification weapon special, of course that it would be quite overpowered. The 50% chance to be it can be done easily that you {VARIABLE_OP random_variable random (0,1)}, and if the variable random_variable is equal to 50%, it will cause the infection.

And the zombified unit will advance to a zombie and change side, and not that the zombifier side will get an extra zombie.

And, in general, RandomPlayers, you forgot that the value in the variable has to be the side number, so it should be rather like this:

Code: Select all

      [if]
          [variable]
            name=plagued
            greater_than=0
         [/variable]
         [then]
              [set_variable]
                  name=unit.variables.plagued
                  value=$side_number
              [/set_variable]
              [unstore_unit]
                  variable=unit
                  {COLOR_HARM}
                  text= _ "plagued"
              [/unstore_unit]
         [/then]
      [/if]

RandomPlayers
Posts: 8
Joined: March 21st, 2012, 7:03 pm

Re: Creating Poison like effect with Plague effect at 0 HP?

Post by RandomPlayers »

So that I don't add it to the wrong spot, that code is meant for the "Defender hits" version, right?
Also, I had in the meantime expanded upon it so the code for Attacker Hits looked like this:

Code: Select all

    [event] 
        name=attacker hits
        first_time_only=no
        [filter_attack]
            special=strongplague
        [/filter_attack]
        [if]
            [variable]
                name=second_unit.variables.plagued
                equals=yes
            [/variable]
        [else]
            [set_variable]
                name=second_unit.variables.plagued
                value=yes
            [/set_variable]
            [set_variable]
                name=second_unit.variables.plaguedside
                value=$unit.side
            [/set_variable]
            [unstore_unit]
                variable=second_unit
                {COLOR_HARM}
                text= _ "plagued"
            [/unstore_unit]
         [/else]
        [/if]
    [/event]
It seems to work atleast. (The game recognises the unit as already being plagued, for one) and what I've written for dealing damage per turn works. Only thing not working so far is the actual "Unit is 0 HP or less, ZOMBIE TIME" bit. I can post that code if you don't mind helping? I have a feeling I've messed up horribly with it, but Wesnoth is allowing it to run atleast. Not that it does anything. (Suspect the issue lies in the filters. Not sure how to detect a unit that is 0 HP or less.)

User avatar
Dugi
Posts: 4960
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Creating Poison like effect with Plague effect at 0 HP?

Post by Dugi »

Feeding is tied to the die event, so tie this to the last_breath event.

Code: Select all

[event]
name=last breath
[filter]
  [filter_wml]
    [variables]
      plagued="yes"
    [/variables]
  [/filter_wml]
[/filter]
{ADVANCE_UNIT x,y=$x1,$y1 Risen}
{MODIFY_UNIT x,y=$x1,$y1 side $unit.variables.plaguedside}
[/event]
And in the unit harming event, add an [if] tag that advances it and changes its side if the unit's HP was less than 8 before the harm event. If you are using the [harm_unit] tag, it can be simply done so that you set it to kill=yes and it will trigger the above described event.

RandomPlayers
Posts: 8
Joined: March 21st, 2012, 7:03 pm

Re: Creating Poison like effect with Plague effect at 0 HP?

Post by RandomPlayers »

I ran into three issues now:
1: While units killed in combat properly turn into Risen, units killed by the 'poison' don't. They just dissapear.
2: The New Risen still take 'poison' damage.
3: The New Risen retain the traits they had while alive. (Not neccesarily a bad thing, but could be a bit overpowered)

Since the Macros (As I understand it, anything in {} is a macro) arn't documented from what I can find I'm not sure what I should do to fix that.
For reference, here is the damage event incase I messed something up there:
Spoiler:

User avatar
Dugi
Posts: 4960
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Creating Poison like effect with Plague effect at 0 HP?

Post by Dugi »

To make the die event trigger it:

Code: Select all

     [event] 
        name=side turn 
        first_time_only=no 
        [heal_unit]   #Unpoison the poisoned zombified units.
          [filter] 
                [filter_wml]
                    [variables]
                        plagued="yes"
                    [/variables]
                [/filter_wml]
           [and]
                [filter_wml]
                    [variables]
                        poisoned="yes"
                    [/variables]
                [/filter_wml]
           [/and]
            side=$side_number
          [/filter]
         animate=no
         amount=0
         restore_statuses=yes
      [/heal_unit] 
        [harm_unit] 
          [filter] 
                [filter_wml]
                    [variables]
                        plagued="yes"
                    [/variables]
                [/filter_wml]
            side=$side_number
          [/filter]
         amount=8
         kill=yes
         fire_event=yes             #This is what you forgot.
         animate=yes
      [/harm_unit] 
   [/event]
And replace the last breath even by this, I didn't think about that.

Code: Select all

[event]
name=last breath
[filter]
  [filter_wml]
    [variables]
      plagued="yes"
    [/variables]
  [/filter_wml]
[/filter]
{CLEAR_VARIABLE unit.status.plagued}
{CLEAR_VARIABLE unit.status.plaguedside}
[unstore_unit]
   find_vacant=no
    variable=unit
[/unstore_unit]
{ADVANCE_UNIT x,y=$x1,$y1 Risen}
{MODIFY_UNIT x,y=$x1,$y1 side $unit.variables.plaguedside}
[/event]

RandomPlayers
Posts: 8
Joined: March 21st, 2012, 7:03 pm

Re: Creating Poison like effect with Plague effect at 0 HP?

Post by RandomPlayers »

To be clear, with 'poison' (note the ' I used both now and before) meant the damage caused by the harm event.

In any case, after adding those bits of codes the three problems still remain. Maybe simply adding a brand new unit at the same spot as the unit dies is easier and more foolproof?
I presume I would need to transfer the unitvariable plaguedside into a globalvariable temporarily for that?

RandomPlayers
Posts: 8
Joined: March 21st, 2012, 7:03 pm

Re: Creating Poison like effect with Plague effect at 0 HP?

Post by RandomPlayers »

Quick note: Managed to get it working, now doing the non-essential things (Make it not affect undead, add a color overlay. First is non-essential mostly because the undead are not expected to fight other undead)
Not sure what the general policy is, but once it's done should I post a spoilered copy of the code so anyone else that wants to do the same thing can access it with a simple forum search?

Post Reply