ghype's Coding Problems - Modify Xp Reward

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.
josteph
Developer
Posts: 161
Joined: August 19th, 2017, 6:58 pm

Re: ghype's Coding Problems - Modify Xp Reward

Post by josteph » October 23rd, 2018, 10:58 pm

No, you can't use enemy.level instead of second_unit.level unless you explicitly do [store_unit] variable=enemy.

enclave
Posts: 910
Joined: December 15th, 2007, 8:52 am

Re: ghype's Coding Problems - Modify Xp Reward

Post by enclave » October 24th, 2018, 2:23 pm

you put variable change after you unstored the unit.. so it doesnt affect anything, it just changes the second_unit array.. without putting that modified unit on map:

Code: Select all

[unstore_unit]
        variable=second_unit
        find_vacant=no
        animate=no
        fire_event=no
    [/unstore_unit]
    {CLEAR_VARIABLE fightrew}

    {VARIABLE second_unit.name testname}
should be {VARIABLE second_unit.name testname} before [unstore_unit], then it will change after you unstore (if code works)

Code: Select all

 {VARIABLE second_unit.name testname}
 [unstore_unit]
        variable=second_unit
        find_vacant=no
        animate=no
        fire_event=no
    [/unstore_unit]
    {CLEAR_VARIABLE fightrew}

   

User avatar
ghype
Posts: 488
Joined: December 13th, 2016, 4:43 pm
Location: Berlin, Germany

Re: ghype's Coding Problems - Modify Xp Reward

Post by ghype » October 25th, 2018, 7:19 am

thanks for the suggestions. I indeed forgot the filters, hence no events were used for my abilities. Also I used the [message] key in order to see which event comes through and which don't.
(1) for {ABILITY_NO_XP}, which is used for gate, only the second event (name=die) got through.The first one (name=attack end) however did not came through.
code:

(2) for {ABILITY_REDUCE_XP}, which is used for the attacker, it is the exact opposite. the first event (name=attack) got through.The second one (name=die) however did not came through.
code:

What I remark is that if I use for (1) on the first event name=attack instead of name=attack end , there might be a chance that both event come through as name=attack did for (2). But even if so, none of these four events actually did something. No experience was reduced or denied...
so I am still at the same place.
post sprites & stuff every day: ghype's Daily Art
destroying enemy castle here: Orcish Castle - Destroyed - work in progress

enclave
Posts: 910
Joined: December 15th, 2007, 8:52 am

Re: ghype's Coding Problems - Modify Xp Reward

Post by enclave » October 25th, 2018, 2:07 pm

I think this is a mistake here:
{VARIABLE_OP $unit.experience sub enemy.level}
you dont need to use dollar sign before unit.experience, but you need to use $ sign before enemy.level :)
you have couple of them.. or maybe im tired.. idk

User avatar
Ravana
Moderator
Posts: 1888
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: ghype's Coding Problems - Modify Xp Reward

Post by Ravana » October 25th, 2018, 2:42 pm

For attack events, unit and second_unit depend on who starts attack. For some cases you might want [filter_second].

User avatar
ghype
Posts: 488
Joined: December 13th, 2016, 4:43 pm
Location: Berlin, Germany

Re: ghype's Coding Problems - Auto-defeat/Confusing Unit ID

Post by ghype » November 28th, 2018, 3:47 pm

For the "Modify Xp Reward" thing i will wait till 1.15 and take a look again at the situation.

I just came up with two smaller issues.
(1) In my campaign scenarion, I used to have an auto-defeat on start up because i forgot to add recruit= in order to make my main character not being able to recruit. This fixed the auto-defeat back than. Now I added a couple more ai sides and I get an auto-defeat on start up again.
There must be something I quite have't figured out yet, what am I missing in my [side]'s ?
code:
(2) I have a small PLACE_UNIT macro which I allows me to place unit of any type. For the type i need to use the ID. But for units with two words (such as Giant Rat, Giant Scorpion, Vampire Bat) it will not recognise the given ID.
Spoiler:
post sprites & stuff every day: ghype's Daily Art
destroying enemy castle here: Orcish Castle - Destroyed - work in progress

User avatar
Ravana
Moderator
Posts: 1888
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: ghype's Coding Problems - Auto-defeat/Confusing Unit ID

Post by Ravana » November 28th, 2018, 3:59 pm

1) there should be some key that makes side never defeated
2) it is recognized as problem https://github.com/wesnoth/wesnoth/issues/1847 but for now you need to use it as https://wiki.wesnoth.org/PreprocessorRe ... inclusions

enclave
Posts: 910
Joined: December 15th, 2007, 8:52 am

Re: ghype's Coding Problems - Auto-defeat/Confusing Unit ID

Post by enclave » November 28th, 2018, 5:27 pm

ghype wrote:
November 28th, 2018, 3:47 pm
(2) I have a small PLACE_UNIT macro which I allows me to place unit of any type. For the type i need to use the ID. But for units with two words (such as Giant Rat, Giant Scorpion, Vampire Bat) it will not recognise the given ID.

Code: Select all

{PLACE_UNIT side Vampire Bat X Y}
{PLACE_UNIT side Vampire_Bat X Y}
{PLACE_UNIT side VAMPIRE BAT X Y}
{PLACE_UNIT side VAMPIRE_BAT X Y}
for these as far as I can see you just need to use it like this:
a) {PLACE_UNIT side "Vampire Bat" X Y}
b) {PLACE_UNIT side (Vampire Bat) X Y}
Otherwise your macro thinks that Bat is the next variable (X), then for x, it thinks its Y, and then for the last one it thinks it's an extra one.. so I'm sure it gives you error something like that "you have 5 variables but is expected 4", so you need to show macro that "Vampire Bat" is a single variable, not 2 variables..

For the recruit thing.. if it was working before 1.14 and now on 1.14 it doesnt work anymore, then..
have you tried to change Recruit= into something else? For example Recruit="" or just remove it completely.. 1.14 had too many changes that affect too many things.. comparing to 1.12.. otherwise i have no idea..

User avatar
ghype
Posts: 488
Joined: December 13th, 2016, 4:43 pm
Location: Berlin, Germany

Re: ghype's Coding Problems - Modify Xp Reward

Post by ghype » November 29th, 2018, 2:31 pm

thanks ravana & enclave.

(1) defeat_condition=never will do it temporarily, since I do not know what exactly I want with the sides.
(2) {PLACE_UNIT side "Vampire Bat" X Y} worked just as fine
post sprites & stuff every day: ghype's Daily Art
destroying enemy castle here: Orcish Castle - Destroyed - work in progress

Post Reply