dabber's questions: vision to location
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: dabber's questions: check unit status
I cannot seem to check whether a unit is undead or not. What am I doing wrong? Truncated code below: (AoE drain attack)
I can correctly check other information in the units variable, such as hitpoints and resistances, but I cannot seem to check not_living.
Spoiler:
Re: dabber's questions: check not living
I believe you do not want the first $ for name=.
Re: dabber's questions: check not living
Well I feel dumb. That fixed it.
I write C code for a living, so I'm used to pointer dereference, but the $ in WML constantly gets me.
I write C code for a living, so I'm used to pointer dereference, but the $ in WML constantly gets me.
Re: dabber's questions: all terrain
Is there an easy way to make all terrain types unwalkable, and then make one terrain type cost 1 move? I don't want to have to individually list each type I want to set unwalkable. The goal is to let the unit move across only one type of terrain.
It seems like all I ask in this thread is dumb questions.
It seems like all I ask in this thread is dumb questions.
Re: dabber's questions: all terrain
Not really. Ideas might be
- switching movetype
- unwalkable overlay
but they all have limitations and side effects.
You can also iterate over movement_costs keys, but that would be more work than hardcoding existing terrain types.
- switching movetype
- unwalkable overlay
but they all have limitations and side effects.
You can also iterate over movement_costs keys, but that would be more work than hardcoding existing terrain types.
- Pentarctagon
- Project Manager
- Posts: 5567
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: dabber's questions: all terrain
Would [terrain_defaults] help with this?
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
Re: dabber's questions: all terrain
If I create two last breath events for a unit, but one of the events kills the unit via [kill], will the second last breath always fire?
My second event doesn't seem to be firing and I'm trying to find a cause. I see both events in the save file looking correct.
My second event doesn't seem to be firing and I'm trying to find a cause. I see both events in the save file looking correct.
Re: dabber's questions: all terrain
If you kill the unit via [kill] tag in your first last breath event, then the unit does no longer exist, and the second last breath will never fire.dabber wrote: ↑April 8th, 2019, 4:31 pm If I create two last breath events for a unit, but one of the events kills the unit via [kill], will the second last breath always fire?
My second event doesn't seem to be firing and I'm trying to find a cause. I see both events in the save file looking correct.
https://wiki.wesnoth.org/Eventwml#last_breath
https://wiki.wesnoth.org/Eventwml#die
Author of Antar, Son of Rheor ( SP Campaign) | Development Thread + Feedback Thread + Replays of ASoR
Re: dabber's questions: last breath
I believe you are not given any guarantee in which order the events would fire.
Re: dabber's questions: all terrain
I read that exact link, but I didn't think the wording was decisive, which is why I posted the question. Yet now that I think about it again, it can only be this way. Mentally I think of the event as tied to the unit, but structurally that's incorrect. Only the filter ties it to the unit, and the filter will fail after [kill]. I need to restructure.Adamant14 wrote: ↑April 9th, 2019, 5:27 pmIf you kill the unit via [kill] tag in your first last breath event, then the unit does no longer exist, and the second last breath will never fire.dabber wrote: ↑April 8th, 2019, 4:31 pm If I create two last breath events for a unit, but one of the events kills the unit via [kill], will the second last breath always fire?
My second event doesn't seem to be firing and I'm trying to find a cause. I see both events in the save file looking correct.
https://wiki.wesnoth.org/Eventwml#last_breath
https://wiki.wesnoth.org/Eventwml#die
Re: dabber's questions: last breath
I want to upgrade the damage and hitpoints of every enemy unit. I did this on recruit successfully, but I cannot make creating a unit directly do it. What am I missing?
I tried doing it with an object, basically replacing [advancement] below with [object] and a location filter, but that didn't work either.
I tried doing it with an object, basically replacing [advancement] below with [object] and a location filter, but that didn't work either.
Code: Select all
#define GENERIC_UNIT_HARDER_WORKER SIDE TYPE X Y HPS DMG
# Creates a generic unit of TYPE belonging to SIDE at X,Y, which has a
# random name, gender and traits (just like a recruited unit).
[unit]
side={SIDE}
type={TYPE}
x={X}
y={Y}
generate_name=yes
random_traits=yes
random_gender=yes
upkeep=full
[modify_unit]
[advancement]
[effect]
apply_to=hitpoints
increase_total={HPS}
increase={HPS}
[/effect]
[effect]
apply_to=attack
increase_damage={DMG}
[/effect]
[/advancement]
[/modify_unit]
[/unit]
#enddef
#define GENERIC_UNIT_HARDER SIDE TYPE X Y
#ifdef HARD
{GENERIC_UNIT_HARDER_WORKER {SIDE} {TYPE} {X} {Y} 50 100}
#else
{GENERIC_UNIT {TYPE} {X} {Y}}
#endif
#enddef
Re: dabber's questions: last breath
I'm pretty sure that the direct action
[modify_unit]
cannot be placed inside [unit]
just like that. Same goes for objects. Also, if you want to modify the hitpoints and attacks of a unit right at the creation, then the advancement tag is not the correct way - that only adds a new advancement to the unit which can be selected from the available options, when the unit advances.The way I'd do it:
Code: Select all
#define STRENGTHEN_ENEMIES FILTER HP DMG
[object]
[filter]
{FILTER}
[/filter]
[effect]
apply_to=hitpoints
increase_total={HP}
heal_full=yes
[/effect]
[effect]
apply_to=attack
increase_damage={DMG}
[/effect]
[/object]
#enddef
Code: Select all
#define GENERIC_UNIT_HARDER SIDE TYPE X Y
{GENERIC_UNIT {SIDE} {TYPE} {X} {Y}}
#ifdef HARD
{STRENGTHEN_ENEMIES x,y={X},{Y} 50 100}
#endif
#enddef
[object]
is recognized, for example I'm not sure how it would behave if you put it directly into a [side]
tag and that sort of thing.Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Re: dabber's questions: last breath
That showed me my error. I meant to write
[modifications]
and instead I wrote [modify_unit]
Version that seems to do what I want below.
Now I have to mess with another part - getting the percentage increase out of a variable.
Code: Select all
#define GENERIC_UNIT_HARDER_WORKER SIDE TYPE X Y HPS DMG
# Creates a generic unit of TYPE belonging to SIDE at X,Y, which has a
# random name, gender and traits (just like a recruited unit).
[unit]
side={SIDE}
type={TYPE}
x={X}
y={Y}
generate_name=yes
random_traits=yes
random_gender=yes
upkeep=full
[modifications]
[object]
silent=yes
[filter]
x,y={X},{Y}
[/filter]
[effect]
apply_to=hitpoints
increase_total={HPS}
increase={HPS}
[/effect]
[effect]
apply_to=attack
increase_damage={DMG}
[/effect]
[/object]
[/modifications]
[/unit]
#enddef
Re: dabber's questions: object on unit
The "Slow" trait might be a useful reference.
It looks like just a percent sign after the number. The wiki indicates that the same thing works for damage increases:
Code: Select all
#define TRAIT_SLOW
# Units with trait Slow have -1 movement and 5% more hitpoints.
[trait]
id=slow
male_name= _ "slow"
female_name= _ "female^slow"
help_text= _ "<italic>text='Slow'</italic> units have 1 less movement point but 5% more hitpoints." + _ "
Thick-bodied and clumsy, slow individuals of goblins and other species take a movement penalty but are compensated for it with a slight increase in endurance."
[effect]
apply_to=movement
increase=-1
[/effect]
[effect]
apply_to=hitpoints
increase_total=5%
[/effect]
[/trait]
#enddef
https://wiki.wesnoth.org/EffectWML wrote: increase_damage: increases the attack's damage. This can be positive or negative, so you can use it to decrease damage as well. If it ends in a percent('%'), the change in damage will be a percentage ratio of the attack's original damage.
Re: dabber's questions: object on unit
I had a really bad couple of days with reading my own code. Percentage increase wasn't working because I put the letter "n" in the variable name when I meant "h", and couldn't seem to see that I mistyped it.