Dixie's Thread
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: Dixie's Thread
Well, well, let's get back to my old thread 
I have recently been looking into greater costumization of Wesnoth for campaigns/scenarios. I have been looking at mainline files quite a bit, as well as at the wiki. I understand these are obscure bits of WML, that are not used often and may not be the cleanest out there. I am mainly talking about [theme], [help] and [hotkeys].
1) Theme.
This one is not too bad, actually. The documentation in the wiki is fairly good and with support from the mainline theme files, it is possible to achieve results relatively easily. I was wondering, though: since this basically allows us to change Wesnoth's skin (if we make costum theme pngs), is it possible to xtend that costum skin to other menus, such as the saves, help, recruit, etc? I understand this is all in data/gui, but I have so far not found from where the file is read/called, and I'm not sure how it could be integrated to a costum theme. Agreed, I haven't delved into the deepest depths yet.
2) Help
I have of course found the [hide_help] tag to hide units, and the help.cfg in data/core and the wiki page about help. Given all these, I figured there probably is a way to modify the game's help, if not to redo it entirely, at least to add pages to it. I could see it as being pretty useful for add-ons that use costum systems, such as Paintball Era advancement charts or the project I am currently working on. I have tried making a very basic help file, but I can't get it to be read instead/added to the default help. I tried calling it outside [campaign] and {IF_DEF CAMPAIGN} like themes, but it has produced no results so far. I thought that maybe it would behave like game_configs, by which I mean: if I defined another [top_level] or used the same ids or something, maybe it would override the default one, but so far it seems not. Anybody has any cues on this matter?
3) Hotkeys
Let's not shy ourselves away from it: adding stuff to context menus can be ugly and unKISS. That's why I figured it could be nice to define costum hotkeys for the course of a scenario/campaign. Be it to call the costum help page, to call a costum menu/funtcion which doesn't require a location, or just to disable a default hotkey which works against the current scenario's functionnality. I of course found hotkeys.cfg in data/core, and while I have not tried playing with it a lot yet, I figured I would run into the same problems than I am with the help menu. Still, I am mentionning it in case someone knew something special about it.
While I'm at it, I haven't looked into this a lot yet either, but I wondered if there was a way to launch some menu actions (as seen in ThemeWML) from some other place than menus. Like, creating save points or a save/load option in a menu-dialog. Also, while dialogs clearly are the easy way to build costum menus, would it be possible to define a costum menu or "widget" (like the recruit menu, for instance), which I could call through WML? Now that I think of it, though, I think I saw something like that in new Lua functions for 1.9, but it looked really complicated... It might also answer itself if I find a way to access the GUI like I mentionned in the Theme paragraph above...
Thanks!

I have recently been looking into greater costumization of Wesnoth for campaigns/scenarios. I have been looking at mainline files quite a bit, as well as at the wiki. I understand these are obscure bits of WML, that are not used often and may not be the cleanest out there. I am mainly talking about [theme], [help] and [hotkeys].
1) Theme.
This one is not too bad, actually. The documentation in the wiki is fairly good and with support from the mainline theme files, it is possible to achieve results relatively easily. I was wondering, though: since this basically allows us to change Wesnoth's skin (if we make costum theme pngs), is it possible to xtend that costum skin to other menus, such as the saves, help, recruit, etc? I understand this is all in data/gui, but I have so far not found from where the file is read/called, and I'm not sure how it could be integrated to a costum theme. Agreed, I haven't delved into the deepest depths yet.
2) Help
I have of course found the [hide_help] tag to hide units, and the help.cfg in data/core and the wiki page about help. Given all these, I figured there probably is a way to modify the game's help, if not to redo it entirely, at least to add pages to it. I could see it as being pretty useful for add-ons that use costum systems, such as Paintball Era advancement charts or the project I am currently working on. I have tried making a very basic help file, but I can't get it to be read instead/added to the default help. I tried calling it outside [campaign] and {IF_DEF CAMPAIGN} like themes, but it has produced no results so far. I thought that maybe it would behave like game_configs, by which I mean: if I defined another [top_level] or used the same ids or something, maybe it would override the default one, but so far it seems not. Anybody has any cues on this matter?
3) Hotkeys
Let's not shy ourselves away from it: adding stuff to context menus can be ugly and unKISS. That's why I figured it could be nice to define costum hotkeys for the course of a scenario/campaign. Be it to call the costum help page, to call a costum menu/funtcion which doesn't require a location, or just to disable a default hotkey which works against the current scenario's functionnality. I of course found hotkeys.cfg in data/core, and while I have not tried playing with it a lot yet, I figured I would run into the same problems than I am with the help menu. Still, I am mentionning it in case someone knew something special about it.
While I'm at it, I haven't looked into this a lot yet either, but I wondered if there was a way to launch some menu actions (as seen in ThemeWML) from some other place than menus. Like, creating save points or a save/load option in a menu-dialog. Also, while dialogs clearly are the easy way to build costum menus, would it be possible to define a costum menu or "widget" (like the recruit menu, for instance), which I could call through WML? Now that I think of it, though, I think I saw something like that in new Lua functions for 1.9, but it looked really complicated... It might also answer itself if I find a way to access the GUI like I mentionned in the Theme paragraph above...
Thanks!

Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
Current projects: Internet meme Era, The Settlers of Wesnoth
Re: Dixie's Thread
Spo0kyMagician, and I explored this last summer-ish. I didn't succeed. And judging from the fact that we haven't spoken about it in all that time, I'm guessing he didn't either.Dixie wrote: 3) Hotkeys
Let's not shy ourselves away from it: adding stuff to context menus can be ugly and unKISS. That's why I figured it could be nice to define costum hotkeys for the course of a scenario/campaign. Be it to call the costum help page, to call a costum menu/funtcion which doesn't require a location, or just to disable a default hotkey which works against the current scenario's functionnality. I of course found hotkeys.cfg in data/core, and while I have not tried playing with it a lot yet, I figured I would run into the same problems than I am with the help menu. Still, I am mentionning it in case someone knew something special about it.

AFAIK those can be considered like themeWML or serverWML. They're WML yes. They describe parts of the game yes. But they're completely separate from the things we (UMC authors) do in our scenarios.
Re: Dixie's Thread
As an exercise and a possible demo-era patch-thing I plan on releasing for the experimental corner about having pre-generated random numbers for individual units (the whole point being: save-loading won't do no good anymore).
Anyway, the biggest chunk works just fine. I store a set of numbers in each unit's variables and give them a pair of invisible chance_to_hit specials (one that set value=0 if it's a miss, one that sets value=100 if it's a hit). My main problem is if the unit has marksman of magical. Theorically, a portion of the code is dedicated to nullify the ability when combat is engaged, and the other specials should detect its presence and do their hit/miss calculations accordingly. BUT! All this is negated because I couldn't replace the specials. I have this:
But I don't understand - the filter_self doesn't appear on recruited units (from mainline), they have the standard marksman and magical specials. Did I do something wrong with the #undef? Or should I re-include units from mainline in my main? But wouldn't this cause the game to have twice the units in its cache or something? Have I overlooked something?
Thanks in advance!
Anyway, the biggest chunk works just fine. I store a set of numbers in each unit's variables and give them a pair of invisible chance_to_hit specials (one that set value=0 if it's a miss, one that sets value=100 if it's a hit). My main problem is if the unit has marksman of magical. Theorically, a portion of the code is dedicated to nullify the ability when combat is engaged, and the other specials should detect its presence and do their hit/miss calculations accordingly. BUT! All this is negated because I couldn't replace the specials. I have this:
in wml-utils.cfg:
my main.cfg:
Thanks in advance!

Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
Current projects: Internet meme Era, The Settlers of Wesnoth
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: Dixie's Thread
If I get you right, you want to modify the mainline marksman's weapon special after it got already inserted into the mainline unit cfgs. You #undef it only at that point when it has already been used and you can't modify it later on-the-fly.
A solution that comes to my mind is that you could use base_unit for all the units in question and re-create those unit types at the preprocessing time of your add-on , when the weapon special has been replaced with your custom weapon special. Not sure how well the "overwriting" will go...
A solution that comes to my mind is that you could use base_unit for all the units in question and re-create those unit types at the preprocessing time of your add-on , when the weapon special has been replaced with your custom weapon special. Not sure how well the "overwriting" will go...
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
Re: Dixie's Thread
Yeah, I,m not sure how base_unit'll work in this case... shouldn't it be in a unit_type? Would it -really- overwrite the mainline units? (I tend to doubt it)
I guess my alternative is to filter if a unit has magical/marksman on an attack on prestart/recruit/advance, and if so replace it by a costum version of it... No easy way of doing it modifying the macro, I guess
Thanks anyway
I guess my alternative is to filter if a unit has magical/marksman on an attack on prestart/recruit/advance, and if so replace it by a costum version of it... No easy way of doing it modifying the macro, I guess

Thanks anyway
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
Current projects: Internet meme Era, The Settlers of Wesnoth
Re: Dixie's Thread
Wow, long time I haven,t posted in here. I guess it's looking up for me! 
Well, I'm currently trying to figure something out about location filters and radius. I am trying to return an hex of terrain=Rrc without a unit on it which doesn't have any unit in a radius of 2. So far I have something like this:
But it returns all Rrc hexes without a unit on, plus all Rrc hexes without a unit on in a radius of 2. So, is there a way I could use the radius as a filtering criteria for that central hex, but not return the radius hexes? I thought about maybe using a costum lua_function, but filter_location doesn't support them (unlike filter_unit). Unless I somehow made one that could check for locations but be included in a suf in the location filter...? Or would a [filter_adjacent_location] embedded in another [filter_adjacent_location] do the trick?
I'll look into it, thanks in advance, people!
Edit:
This did it, sorry for the trouble it may have brought

Well, I'm currently trying to figure something out about location filters and radius. I am trying to return an hex of terrain=Rrc without a unit on it which doesn't have any unit in a radius of 2. So far I have something like this:
Code: Select all
[filter_location]
[and]
terrain=Rrc
[not]
[filter]
type=sow_settle,sow_city
[/filter]
[/not]
radius=2
[/and]
terrain=Rrc
[not]
[filter]
[/filter]
[/not]
[/filter_location]
I'll look into it, thanks in advance, people!

Edit:
This did it, sorry for the trouble it may have brought

Code: Select all
[filter_location]
terrain=Rrc
[not]
[filter]
type=sow_settle,sow_city
[/filter]
[/not]
[filter_adjacent_location]
[filter_adjacent_location]
[not]
[filter]
type=sow_settle,sow_city
[/filter]
[/not]
count=6
[/filter_adjacent_location]
count=6
[/filter_adjacent_location]
[/filter_location]
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
Current projects: Internet meme Era, The Settlers of Wesnoth
Re: Dixie's Thread
I think you misplaced your [not] tag. Maybe the following would have worked better:Dixie wrote:But it returns all Rrc hexes without a unit on, plus all Rrc hexes without a unit on in a radius of 2. So, is there a way I could use the radius as a filtering criteria for that central hex, but not return the radius hexes?
Code: Select all
[filter_location]
terrain=Rrc
[not]
[filter]
[/filter]
[/not]
[not]
[filter]
type=sow_settle,sow_city
[/filter]
radius=2
[/not]
[/filter_location]
Re: Dixie's Thread
I have a little trouble understanding how radius really works, but I kind of get the hang of it. Your suggested code works, anyway, and is much more elegant than my previous solution. Thanks a lot!
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
Current projects: Internet meme Era, The Settlers of Wesnoth
Re: Dixie's Thread
Algorithmically, radius causes the set of locations returned by a filter to be extended to all the neighboring tiles up to the given distance. In your code, you were considering tiles that were at distance 2 of a tile Rrc not containing a unit. As a consequence, these tiles may have had a tile Rrc containing a unit nearby, as long as there was also a tile Rrc not containing a unit. In my code, I'm removing all the tiles that are at distance 2 of a tile Rrc containing a unit.Dixie wrote:I have a little trouble understanding how radius really works
Re: Dixie's Thread
Hmm, I think I get it, thanks!
By the way, I was wondering, since what I'm currently developping is also aimed at multiplayer: I might be mistaken, but when I was working on Paintball Era, I think I read or was told somewhere that the [command] tag from a context menu item wasn't synced, and that we should use a menu item X event, or sync it with some kind of select event (if a unit is implied). But I checked back in the wiki, and it doesn't say anything really clear about this, so I was wondering: am I mistaken, am I right and I just misunderstood the wiki, or has this changed recently? Thanks!
By the way, I was wondering, since what I'm currently developping is also aimed at multiplayer: I might be mistaken, but when I was working on Paintball Era, I think I read or was told somewhere that the [command] tag from a context menu item wasn't synced, and that we should use a menu item X event, or sync it with some kind of select event (if a unit is implied). But I checked back in the wiki, and it doesn't say anything really clear about this, so I was wondering: am I mistaken, am I right and I just misunderstood the wiki, or has this changed recently? Thanks!
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
Current projects: Internet meme Era, The Settlers of Wesnoth