Poison Code
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.
Re: Poison Code
When someone is learning and has no coding experience I think it is better to provide code and explain how it works. The wiki is helpful when you already have an understanding of how and where you can place the code, but when working with pieces of wml that you haven't used before the wiki isn't enough, and fragments will just cause you to try to randomly compile them in a trial and error sense. Then IF you get it working you still don't know why and haven't learned anything. In my experience (both my own and observing others) when given a piece of code and an explanation of how it works people generally try and play with it to achieve similar bits of code before coming back here for help. Sometimes they figure it out for themselves before someone fixes it for them to. Too often someone will make a rude comment about somebody or accuse them of being lazy because they aren't learning as fast as some people would like.Dugi wrote:It is meaningless to give entire pieces of code to people with little coding knowledge, because they may place it incorrectly then, or do a small change wrongly and then report that it doesn't work. It happened many times. It is much better to help him to write the code, giving him hints, corrections and smaller pieces of code, until it gets assembled. This takes more time, but will teach him to use similar things and will make sure that he'll not ask two days later about another custom ability with similar properties.
Re: Poison Code
If he had no coding experience, he would not be asking about advanced custom abilities. He obviously had enough coding experience to be able to create custom abilities to some extent (he would not wonder how to edit poison otherwise), and that is usually more than basic things like making simple scenarios. He has enough experience to code parts of it himself, he does not need others to write lengthy codes for him. Programming was always learned by experimentation.
And there is almost no reason to continue this, as this guy has not logged in for two weeks, therefore appears to be gone.
And there is almost no reason to continue this, as this guy has not logged in for two weeks, therefore appears to be gone.
Re: Poison Code
I chose to try to do this, because this interests me not because opener demanded it. Currently i have custom poison with colored unit but still need to add how it is removed.
Re: Poison Code
My code for incineration should contain a structure you might find useful for this task. Incineration is something like poison, but it deals 16 fire damage per turn, kills and gives exp (if I remember correctly).
Spoiler:
Re: Poison Code
Almost ready, everything seems to work, going to try some more before posting it.
Re: Poison Code
Here, if you find any problems let me know.
Added id to events and removed poison after levelup.
Code: Select all
# Written by Laela(Ravana in forums)
# Idea how to do it from Era of Four Moons hex
# To make poison kill change line 132
#define POISON_VALUE DMG
[dummy]
id=lms_poison_{DMG}
name= _ "poison {DMG}"
name_inactive= _ "poison"
description= _ "This attack poisons living targets. Poisoned units lose " + {DMG} + _ " HP every turn until they are cured or are reduced to 1 HP. Poison can not, of itself, kill a unit."
description_inactive= _ "This attack poisons living targets. Poisoned units lose " + {DMG} + _ " HP every turn until they are cured or are reduced to 1 HP. Poison can not, of itself, kill a unit."
apply_to=opponent
[/dummy]
[/specials]
[/attack]
[event]
name=attacker hits
first_time_only=no
id=attacker_poisons
[filter_attack]
special=lms_poison_{DMG}
[/filter_attack]
[filter_second]
[not]
[filter_wml]
[status]
not_living=yes
[/status]
[/filter_wml]
[/not]
[not]
[filter_wml]
[variables]
poisoned{DMG}=yes
[/variables]
[/filter_wml]
[/not]
[/filter_second]
{VARIABLE second_unit.variables.poisoned{DMG} yes}
{VARIABLE second_unit.status.unhealable yes}
[unstore_unit]
variable=second_unit
find_vacant=no
[/unstore_unit]
[object]
[filter]
id=$second_unit.id
[/filter]
silent=yes
[effect]
apply_to=image_mod
replace="CS(-100,-25,-22)"
[/effect]
[/object]
[/event]
[event]
name=defender hits
first_time_only=no
id=defender_poisons
[filter_second_attack]
special=lms_poison_{DMG}
[/filter_second_attack]
[filter]
[not]
[filter_wml]
[status]
not_living=yes
[/status]
[/filter_wml]
[/not]
[/filter]
{VARIABLE unit.variables.poisoned{DMG} yes}
{VARIABLE unit.status.unhealable yes}
[unstore_unit]
variable=unit
find_vacant=no
[/unstore_unit]
[object]
[filter]
id=$unit.id
[/filter]
silent=yes
[effect]
apply_to=image_mod
replace="CS(-100,-25,-22)"
[/effect]
[/object]
[/event]
[event]
name=turn refresh
id=main_harmer
first_time_only=no
[store_unit]
[filter]
side=$side_number
[filter_wml]
[variables]
poisoned{DMG}=yes
[/variables]
[/filter_wml]
[not]
[filter_adjacent]
is_enemy=no
ability=curing
[/filter_adjacent]
[or]
[filter_adjacent]
is_enemy=no
ability=healing
[/filter_adjacent]
[/or]
[or]
[filter_location]
terrain=*^V*
[/filter_location]
[/or]
[or]
ability=regenerates
[/or]
[/not]
[/filter]
variable=poisoned_temp
[/store_unit]
{FOREACH poisoned_temp i}
[harm_unit]
[filter]
id=$poisoned_temp[$i].id
[/filter]
amount={DMG}
kill=no
[/harm_unit]
{NEXT i}
{CLEAR_VARIABLE poisoned_temp}
[/event]
[event]
name=turn refresh
first_time_only=no
id=remove_poison
[store_unit]
[filter]
side=$side_number
[filter_wml]
[variables]
poisoned{DMG}=yes
[/variables]
[/filter_wml]
[and]
[filter_adjacent]
is_enemy=no
ability=curing
[/filter_adjacent]
[or]
[filter_location]
terrain=*^V*
[/filter_location]
[/or]
[or]
ability=regenerates
[/or]
[/and]
[/filter]
variable=poisoned_temp
[/store_unit]
{FOREACH poisoned_temp i}
{VARIABLE poisoned_temp[$i].variables.poisoned{DMG} no}
{VARIABLE poisoned_temp[$i].status.unhealable no}
[unstore_unit]
variable=poisoned_temp[$i]
find_vacant=no
[/unstore_unit]
[object]
[filter]
id=$poisoned_temp[$i].id
[/filter]
silent=yes
[effect]
apply_to=image_mod
replace="CS(0,0,0)"
[/effect]
[/object]
{NEXT i}
{CLEAR_VARIABLE poisoned_temp}
[/event]
[event]
name=post advance
first_time_only=no
id=unpoison_on_levelup
{VARIABLE unit.variables.poisoned{DMG} no}
{VARIABLE unit.status.unhealable no}
[unstore_unit]
variable=unit
find_vacant=no
[/unstore_unit]
[/event]
[+attack]
[+specials]
#enddef
Last edited by Ravana on June 18th, 2013, 5:48 pm, edited 2 times in total.
Re: Poison Code
Looking at it, I see that you forgot to give id= keys to most events. Some events will be duplicated if the units appear more than once.
To understand what does the +tag thing do, read this::
Re: Poison Code
I'd recommend you animate the healer, so it actually looks like it's healing the poisoned unit. Also, you could use a bit of lua to make the poisoned icon appear in the sidebar.
Formerly known as the creator of Era of Chaos and maintainer of The Aragwaithi and the Era of Myths.
Re: Poison Code
I have never animated here anything and never done anything with lua. Would be helpful if you could point out where to start learning wesnoth-related lua.
Re: Poison Code
Wow, so nice!
Hope we will get an easy to use macro for everybody. This coding really goes over my head.
Keep up the great work!
Hope we will get an easy to use macro for everybody. This coding really goes over my head.
Keep up the great work!
Re: Poison Code
Well I suppose the word got your attention. I would assume more variety of poison would be cool for campaigns. Not for core units of course. The strength and duration of poison would not have to be displayed in my opinion. You could announce that in a dialog like: "Beware of the snakes they have very strong poison! If they do not kill you in 3 turns you might survive."JaMiT wrote: Greater sophistication in implementation (more-or-less meaning being able to handle variations) is usually good, provided the overall "simple stupid" guideline is not violated.
In this case, the question really is whether or not it is worth complicating the player's experience with poisons of various strengths. For example, suppose a player has poisoned units on the board -- how would the player know which are affected by the weaker (or stronger) poison and which are affected by standard poison? How would this difference be distinguished in the poisoning units? (And maybe some additional non-obvious complications that I cannot think of off the top of my head.) Is there enough benefit from this change to poison to warrant these complications for players?
Problems would be: If killed by poison, are the XP lost?
If already poisoned by weak poison, will it protect from strong poison?
Could there be be immunity built up to poison which does not last indefinite?
While this stuff might get complicated, I would still call it sophisticated, but I am not a native speaker.
I believe it has huge potential for user made content.
Re: Poison Code
Code: Select all
#define POISON_VALUE DMG
[dummy]
id=lms_poison_{DMG}
name= _ "poison {DMG}"
name_inactive= _ "poison"
description= _ "This attack poisons living targets. Poisoned units lose " + {DMG} + _ " HP every turn until they are cured or are reduced to 1 HP. Poison can not, of itself, kill a unit."
description_inactive= _ "This attack poisons living targets. Poisoned units lose " + {DMG} + _ " HP every turn until they are cured or are reduced to 1 HP. Poison can not, of itself, kill a unit."
apply_to=opponent
[/dummy]
[/specials]
[/attack]
[event]
name=attacker hits
first_time_only=no
id=attacker_poisons{DMG}
[filter_attack]
special=lms_poison_{DMG}
[/filter_attack]
[filter_second]
[not]
[filter_wml]
[status]
not_living=yes
[/status]
[/filter_wml]
[/not]
[not]
[filter_wml]
[status]
poisoned=yes
[/status]
[/filter_wml]
[/not]
[not]
[filter_wml]
[variables]
poisoned=yes
[/variables]
[/filter_wml]
[/not]
[/filter_second]
{VARIABLE second_unit.variables.poisoned yes}
{VARIABLE second_unit.variables.poison_value ({DMG})}
{VARIABLE second_unit.status.unhealable yes}
[sound]
name=poison.ogg
[/sound]
[unstore_unit]
variable=second_unit
find_vacant=no
[/unstore_unit]
[object]
[filter]
id=$second_unit.id
[/filter]
silent=yes
[effect]
apply_to=image_mod
replace="CS(-100,-25,-22)"
[/effect]
[/object]
[/event]
[event]
name=defender hits
first_time_only=no
id=defender_poisons{DMG}
[filter_second_attack]
special=lms_poison_{DMG}
[/filter_second_attack]
[filter]
[not]
[filter_wml]
[status]
not_living=yes
[/status]
[/filter_wml]
[/not]
[not]
[filter_wml]
[status]
poisoned=yes
[/status]
[/filter_wml]
[/not]
[not]
[filter_wml]
[variables]
poisoned=yes
[/variables]
[/filter_wml]
[/not]
[/filter]
{VARIABLE unit.variables.poisoned yes}
{VARIABLE second_unit.variables.poison_value ({DMG})}
{VARIABLE unit.status.unhealable yes}
[sound]
name=poison.ogg
[/sound]
[unstore_unit]
variable=unit
find_vacant=no
[/unstore_unit]
[object]
[filter]
id=$unit.id
[/filter]
silent=yes
[effect]
apply_to=image_mod
replace="CS(-100,-25,-22)"
[/effect]
[/object]
[/event]
[event]
name=turn refresh
id=main_harmer{DMG}
first_time_only=no
[store_unit]
[filter]
side=$side_number
[filter_wml]
[variables]
poisoned=yes
poison_value={DMG}
[/variables]
[/filter_wml]
[not]
[filter_adjacent]
is_enemy=no
ability=curing
[/filter_adjacent]
[or]
[filter_adjacent]
is_enemy=no
ability=healing
[/filter_adjacent]
[/or]
[or]
[filter_location]
terrain=*^V*
[/filter_location]
[/or]
[or]
ability=regenerates
[/or]
[/not]
[/filter]
variable=poisoned_temp
[/store_unit]
{FOREACH poisoned_temp i}
[harm_unit]
[filter]
id=$poisoned_temp[$i].id
[/filter]
amount={DMG}
kill=no
[/harm_unit]
{NEXT i}
{CLEAR_VARIABLE poisoned_temp}
[/event]
[event]
name=turn refresh
first_time_only=no
id=remove_poison{DMG}
[store_unit]
[filter]
side=$side_number
[filter_wml]
[variables]
poisoned=yes
[/variables]
[/filter_wml]
[and]
[filter_adjacent]
is_enemy=no
ability=curing
[/filter_adjacent]
[or]
[filter_location]
terrain=*^V*
[/filter_location]
[/or]
[or]
ability=regenerates
[/or]
[/and]
[/filter]
variable=poisoned_temp
[/store_unit]
{FOREACH poisoned_temp i}
[if]
[have_unit]
id=$poisoned_temp[$i].id
ability=regenerates
[/have_unit]
[else]
[animate_unit]
flag=healing
[filter]
ability=curing
[filter_adjacent]
is_enemy=no
id=$poisoned_temp[$i].id
[/filter_adjacent]
[/filter]
with_bars=yes
[/animate_unit]
[/else]
[/if]
{CLEAR_VARIABLE poisoned_temp[$i].variables.poisoned}
{CLEAR_VARIABLE poisoned_temp[$i].variables.poison_value}
{VARIABLE poisoned_temp[$i].status.unhealable no}
[sound]
name=heal.wav
[/sound]
[unstore_unit]
variable=poisoned_temp[$i]
find_vacant=no
{COLOR_HEAL}
text= _ "cured"
[/unstore_unit]
[object]
[filter]
id=$poisoned_temp[$i].id
[/filter]
silent=yes
[effect]
apply_to=image_mod
replace="CS(0,0,0)"
[/effect]
[/object]
{NEXT i}
{CLEAR_VARIABLE poisoned_temp}
[/event]
[event]
name=post advance
first_time_only=no
id=unpoison_on_levelup{DMG}
{CLEAR_VARIABLE unit.variables.poisoned}
{CLEAR_VARIABLE unit.variables.poison_value}
{VARIABLE unit.status.unhealable no}
[unstore_unit]
variable=unit
find_vacant=no
[/unstore_unit]
[object]
[filter]
id=$unit.id
[/filter]
silent=yes
[effect]
apply_to=image_mod
replace="CS(0,0,0)"
[/effect]
[/object]
[/event]
[+attack]
[+specials]
#enddef
Formerly known as the creator of Era of Chaos and maintainer of The Aragwaithi and the Era of Myths.
Re: Poison Code
I would not implement death-by-poison. It adds too much complexity to the game mechanics.Wussel wrote:Problems would be: If killed by poison, are the XP lost?
If already poisoned by weak poison, will it protect from strong poison?
Could there be be immunity built up to poison which does not last indefinite?
No, the stronger poison would overwrite the weaker. (Weaker would not overwrite stronger, though.)
No, this sort of immunity would be an unnecessary complication and moreover goes against [acronym=Frequently Proposed (and rejected) Ideas]FPI[/acronym] 29.
There is overlap between "complicated" and "sophisticated" (something can be both complicated and sophisticated), but they are not the same thing (something can be complicated without being sophisticated, and something can be sophisticated without being complicated).Wussel wrote:While this stuff might get complicated, I would still call it sophisticated, but I am not a native speaker.
Re: Poison Code
I tested bumbadadabum's code and it works perfectly (I tested it by giving the assassin an advancement with poison 20).
I have a question of my own:
Would it be possible to modify a poison sort of ability so that the amount damaged increased every turn? (It's not intended to be mainline balanced, but my original idea was 2 and then increased by 4 every turn, so, 2 damage first turn, 6 damage second, 10 third, so on.) I'm intending on creating a "burn" special and I can figure out how to make it orange/red, have it affect even the nonliving, etc. but I would have no idea how to modify the poison damage between turns.
I have a question of my own:
Would it be possible to modify a poison sort of ability so that the amount damaged increased every turn? (It's not intended to be mainline balanced, but my original idea was 2 and then increased by 4 every turn, so, 2 damage first turn, 6 damage second, 10 third, so on.) I'm intending on creating a "burn" special and I can figure out how to make it orange/red, have it affect even the nonliving, etc. but I would have no idea how to modify the poison damage between turns.
you know
the person
who does the things
the person
who does the things
Re: Poison Code
This could be done with adding new event for every turn that increases all existing poisons values, but then whole ability structure might require minor changes in order to keep all parts working.