A few more WML questions - campaign almost ready

The place to post your WML questions and answers.

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.
Post Reply
Jacques_Fol
Posts: 153
Joined: August 16th, 2008, 2:41 am

A few more WML questions - campaign almost ready

Post by Jacques_Fol »

Greetings, all. I have a few brief questions related to the unassuming campaign A Rough Life which has received a facelift to make it compatible with the 1.6 branch and is even nearing completion. At least two, I suspect, may be due to WML changes from 1.4, while all four are also a testament to my very limited coding skills. To wit, they are:

1. How can one easily change a unit's type along with all characteristics, e.g. when advancing?

For instance, let's assume a thief by the name of Jacques is promoted to a rogue, which is then to be transformed into a trapper. I believe that in 1.4, the following code (already adjusted for the known changes) worked:
unit transformation:
In 1.6, unfortunately, this code changes the image but not everything else as per the new type, notably the attacks and abilities (e.g. no bow attack, and no leadership ability after the L3 transformation).

I have looked at the Civil Disobedience and Unlawful Orders scenarios of Liberty, but could not discern anything of immediate use. Would the use of [effect] as per this thread work, and would I simply place it within the [store_unit] part of the code? Or is there anything else that would work?

2. If a unit's display name (the one used for the dialogues and such) is to change between scenarios (e.g. following its transition from Zero to Hero), simply writing the new "name" at the part with the side definitions of the later scenarios doesn't seem do the trick. What is required, would it also be something for [store_unit] or [effect], and what code would be used?

3. How does one stop a particular sound at a particular time? I refer here specifically to wardrums.ogg, which seems to carry on playing into the new scenario until the specified loops are finished. Is there a command that can be used to stop it?

4. Has the change of "description" into "id" in any way affected how the "second_unit.description" qualifier operates? Based on an understandable wmllint confusion I changed it to "second_unit.id", but now the event that should trigger when a specific unit is involved does not work. Specifically, this is the code in question:
takes two to tango:
Advice on any of the above would be much appreciated. As for the campaign itself, if you're interested, you can read more about it in its designated thread.
Last edited by Jacques_Fol on May 18th, 2009, 8:46 pm, edited 1 time in total.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Open WML questions - polishing a campaign

Post by zookeeper »

Jacques_Fol wrote:Greetings, all. I have a few brief questions related to the unassuming campaign A Rough Life which has received a facelift to make it compatible with the 1.6 branch and is even nearing completion. At least two, I suspect, may be due to WML changes from 1.4, while all four are also a testament to my very limited coding skills. To wit, they are:

1. How can one easily change a unit's type along with all characteristics, e.g. when advancing?

For instance, let's assume a thief by the name of Jacques is promoted to a rogue, which is then to be transformed into a trapper. I believe that in 1.4, the following code (already adjusted for the known changes) worked:
unit transformation:
In 1.6, unfortunately, this code changes the image but not everything else as per the new type, notably the attacks and abilities (e.g. no bow attack, and no leadership ability after the L3 transformation).

I have looked at the Civil Disobedience and Unlawful Orders scenarios of Liberty, but could not discern anything of immediate use. Would the use of [effect] as per this thread work, and would I simply place it within the [store_unit] part of the code? Or is there anything else that would work?
Try the ADVANCE_UNIT and/or TRANSFORM_UNIT core macros (in data/core/macros/unit-utils.cfg).
Jacques_Fol wrote:2. If a unit's display name (the one used for the dialogues and such) is to change between scenarios (e.g. following its transition from Zero to Hero), simply writing the new "name" at the part with the side definitions of the later scenarios doesn't seem do the trick. What is required, would it also be something for [store_unit] or [effect], and what code would be used?
You have to store, change the unit.name and unstore, so the easiest way would be to just use {MODIFY_UNIT id=Konrad name _"Konrad2"} in a prestart event.
Jacques_Fol wrote:3. How does one stop a particular sound at a particular time? I refer here specifically to wardrums.ogg, which seems to carry on playing into the new scenario until the specified loops are finished. Is there a command that can be used to stop it?
No, you can't stop a sound. So if you want to use a sound like that, better make it the music playlist instead and then stop and replace it whenever you want.
Jacques_Fol wrote:4. Has the change of "description" into "id" in any way affected how the "second_unit.description" qualifier operates? Based on an understandable wmllint confusion I changed it to "second_unit.id", but now the event that should trigger when a specific unit is involved does not work. Specifically, this is the code in question:
takes two to tango:
No, hasn't changed, and I don't see any reason why that wouldn't work. Maybe you've just attacked with Kyoko before, or maybe there's simply no unit with id=Ruphulus.
Jacques_Fol
Posts: 153
Joined: August 16th, 2008, 2:41 am

Re: Open WML questions - polishing a campaign

Post by Jacques_Fol »

Thanks a mill, zookeeper, WML wizardry duly impressive.
zookeeper wrote:
Jacques_Fol wrote: 1. How can one easily change a unit's type along with all characteristics, e.g. when advancing?
Try the ADVANCE_UNIT and/or TRANSFORM_UNIT core macros (in data/core/macros/unit-utils.cfg).
Wicked, thanks. As the transformations happen only in or after certain tipping scenarios, I may simply stick to TRANSFORM_UNIT. In any event, I suppose the filter can be anything within reason, so I can use {TRANSFORM_UNIT id=Jacques Trapper}? I suppose I can then still manually follow this up with {VARIABLE Jacques_store.experience 0} if I want to stick to my principled idea of starting the advancement journey anew at the risk of annoying players eager to advance to the final level.
zookeeper wrote:
Jacques_Fol wrote:2. If a unit's display name (the one used for the dialogues and such) is to change between scenarios (e.g. following its transition from Zero to Hero) [...] what code would be used?
You have to store, change the unit.name and unstore, so the easiest way would be to just use {MODIFY_UNIT id=Konrad name _"Konrad2"} in a prestart event.
Wonderful, thanks.
zookeeper wrote:
Jacques_Fol wrote:3. How does one stop a particular sound at a particular time?
No, you can't stop a sound. So if you want to use a sound like that, better make it the music playlist instead and then stop and replace it whenever you want.
Ahhh, thanks. I first thought of having it echo for just a bit longer and then stop it at whim, but guessing how much time the player would need to read everything is impossible, and nowadays I skip through it all so fast that the drums still "echo" when I start the next scenario or even quit the campaign and come back to the title page.
I guess something like this would then work?
drums are music:
... perhaps followed by
but silence is golden:
at an opportune moment if needed?
zookeeper wrote:
Jacques_Fol wrote:4. Has the change of "description" into "id" in any way affected how the "second_unit.description" qualifier operates? Based on an understandable wmllint confusion I changed it to "second_unit.id", but now the event that should trigger when a specific unit is involved does not work.
No, hasn't changed, and I don't see any reason why that wouldn't work. Maybe you've just attacked with Kyoko before, or maybe there's simply no unit with id=Ruphulus.
My problem for not being clear on this, but just to clarify: should it still work with "second_unit.description" or should it now work with "second_unit.id"? If the latter, could it then be that the problem is actually in the following [object] manipulation (which worked under 1.4)?
weakening the attack:
In any event, zookeper, thank you very much for most helpful advice, will follow up on it.
User avatar
SkyOne
Posts: 1310
Joined: January 3rd, 2009, 7:23 pm

Re: Open WML questions - polishing a campaign

Post by SkyOne »

Jacques_Fol wrote:so I can use {TRANSFORM_UNIT id=Jacques Trapper}?
Yes, you can. In fact, either ways work fine. (I tested both.)

Code: Select all

{TRANSFORM_UNIT id=Jacques (Trapper)} and one you showed above.
Fate of a Princess/feedback thread: "What is in own heart that is the most important, not who you are."
Drake Campaign: Brave Wings/feedback thread, Naga Campaign: Return of the Monster, Saurian Campaign: Across the Ocean
Northern Forces - now on 1.12 server
Jacques_Fol
Posts: 153
Joined: August 16th, 2008, 2:41 am

Re: Open WML questions - polishing a campaign

Post by Jacques_Fol »

SkyOne wrote:
Jacques_Fol wrote:so I can use {TRANSFORM_UNIT id=Jacques Trapper}?
Yes, you can. In fact, either ways work fine. (I tested both.)

Code: Select all

{TRANSFORM_UNIT id=Jacques (Trapper)} and one you showed above.
Thanks, SkyOne. Actually, if I remember correctly, the second example you cite is the same, with the parentheses to be used when the relevant term consists of two or more words. So one would have to write

Code: Select all

{TRANSFORM_UNIT id=Jacques (Trapper Jacques)}
if the type to be transformed into were "Trapper Jacques".

By the way, I've amended the coding to account for the naming changes, the wardrums "music" and the transitions of type. They still need to be tested, yet one can't help but have a good feeling about it all.

As for the "second_unit.id", I've revisited the WML guide and the WML for both the [object] and [effect] with attack filter for type seems to be the same. Will need to look into it some more (unless I should revert to second_unit.description, counterintuitive though it may be).

UPDATE: It turns out that {TRANSFORM_UNIT id=Jacques Trapper} is not such a good idea after all. It works brilliantly, that is, in that the program searches for a unit with id=Jacques, finds it and performs the transformation. Then it looks around to see if it can find any other unit with id=Jacques - and lo and behold, there's one. Sure, it's the same one that has already been transformed two seconds ago, but who's to know or care. So it does it again... and again... and again. Had to revert to using the type qualifier and it seems to kind of work now, although it still wishes to repeat the transformation twice before settling on having done the job. Will need to recheck with a fresh mind in a few days' time.
Jacques_Fol
Posts: 153
Joined: August 16th, 2008, 2:41 am

Re: A few more WML questions - campaign almost ready

Post by Jacques_Fol »

Greetings again. In the meantime, the campaign has been completed and seems to work fine, more or less, so the 1.0 version release is imminent. Only a few somewhat nagging issues remain.

For instance, I couldn't get the drums to play as music (as discussed above), and have temporarily reverted back to playing them as a sound. More importantly, the second_unit.id issue from Scenario 7 now seems to work, more or less, so that problem is also solved. Now to the two that I would still like to fix before the ostensibly "finished" release.

1. I have used the TRANSFORM_UNIT macro to change the type of Jacques. That seems to work fine at some times (eg with the first transition on the last playthrough) and has a little glitch at other times where the whole transition (+accompanying text) loop is repeated one more time. It only repeats itself once so it's not a critical bug, but I would still like to get rid of it. This is the code in question:
type transition reverb:
2. There is an event triggered by any of side 1 units moving to a specific tile. This unit is moved to a different tile and on the original tile a unit called Krug is created. What proceeds should then be a discussion between the two, yet it appears in game that only Krug is talking. This is the code:
talking to oneself:
Is "unit" now taken to mean Krug and not the original unit which triggered the event in the first place? If so, what do I then use to refer to the original unit? (Surely second_unit would not work, would it?)

Many thanks for any help, and hope you try the campaign.
Exasperation
Posts: 462
Joined: June 8th, 2006, 3:25 am

Re: A few more WML questions - campaign almost ready

Post by Exasperation »

Couldn't you filter by both id and type to prevent the event from picking up the newly transformed second occurrence of the unit?
Jacques_Fol
Posts: 153
Joined: August 16th, 2008, 2:41 am

Re: A few more WML questions - campaign almost ready

Post by Jacques_Fol »

Exasperation wrote:Couldn't you filter by both id and type to prevent the event from picking up the newly transformed second occurrence of the unit?
Thanks for the suggestion. I actually already filter the transformation by type and type alone (as Jacques is always a unit of a unique type). Hence, the transformation is to occur only of one type (eg Sand_Ranger) into another (eg Battle_Commander), and with that first transformation the one original type (Sand_Ranger) should already be eliminated, so the second iteration should not occur.

I suppose I could also filter the entire event by both id and [have_unit], but that would presumably not influence the number of iterations within the event once it was triggered.
mich
Translator
Posts: 134
Joined: November 11th, 2008, 8:54 am
Location: Italy

Re: A few more WML questions - campaign almost ready

Post by mich »

2) I think that the problem is that when you use "speaker=unit" the unit in $x1,$y1 speaks, but in x1,y1 there is no more the unit triggering the event, because you teleport it. You can simply replace "speaker=unit" with "x,y=28,10". This will work fine, exept if there is already another unit in 28,10 before the teleport, In this case this is the unit that speaks. Or you can replace "speaker=unit" with "id=$unit.id".
Hope this helps.
Jacques_Fol
Posts: 153
Joined: August 16th, 2008, 2:41 am

Re: A few more WML questions - campaign almost ready

Post by Jacques_Fol »

Most helpful, mich, thanks a lot. I wouldn't have guessed that a simple "x,y=28,10" would work, but there you have it. It should be perfectly fine in this case, as I reckon that the chances of a non-side 1 unit being on that spot are small enough to warrant this shortcut. (The conversation will still make perfect sense as long as any unit in that spot belongs to the hero's side.)

With this glitch taken care of, the only bothersome one remaining is the one with the repeated transformation. As that should not pose too much of a problem, I will take the liberty of labeling the next release complete, ie version 1.0. Thank you all for your help, while further improvements (via this thread) are of course still most welcome.
Post Reply