Random faction and location variable questions
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.
- Magical_Noob
- Posts: 50
- Joined: May 24th, 2009, 2:46 pm
- Location: UK
Random faction and location variable questions
Hi all,
I have a few questions about the codes which I am stuck on.
1) (resolved) How do I go about stopping a faction from being selected if a player select random factions? I tried the 'random_faction', 'choices' and 'except' but I am not achieving the results that I want. The reason I am looking to stop this is because 1 of the faction I made is mainly for AI use.
2) How to edit location variable? I have put together this piece of code which is to build stuff around the starting location, but the was unable to tweak the location variable so that I can make it more centered around the leader. The leader currently stands on the 'Ker' tile. I tried +1/-1 to the variable but ended in error.
3) (resolved) How do I add a custom picture to the icon in _server.pbl file. I tried below code but failed.
any help is appreciated, thanks.
I have a few questions about the codes which I am stuck on.
1) (resolved) How do I go about stopping a faction from being selected if a player select random factions? I tried the 'random_faction', 'choices' and 'except' but I am not achieving the results that I want. The reason I am looking to stop this is because 1 of the faction I made is mainly for AI use.
2) How to edit location variable? I have put together this piece of code which is to build stuff around the starting location, but the was unable to tweak the location variable so that I can make it more centered around the leader. The leader currently stands on the 'Ker' tile. I tried +1/-1 to the variable but ended in error.
Code: Select all
[event]
name=side turn 1
first_time_only=no
[if]
[have_unit]
side=$side_number
type="Zombie Lord MN"
[/have_unit]
[then]
[store_starting_location]
side=$side_number
variable=start_loc
[/store_starting_location]
[terrain_mask]
x,y=$start_loc.x,$start_loc.y
mask="Cer,Cer,Cer,Cer,Cer
Cer,Ker,Cer,Cer,Cer
Cer,Cer,Cer,Cer,Cer
Cer,Cer,Cer,Cer,Cer"
[/terrain_mask]
[/then]
[/if]
[/event]
Code: Select all
icon="units/empire/empire_iron_lancer.png~RC(magenta>red)"
Last edited by Magical_Noob on March 30th, 2022, 12:47 pm, edited 1 time in total.
- Atreides
- Posts: 1243
- Joined: March 30th, 2019, 10:38 pm
- Location: On the 2nd story of the centre village in Merwuerdigliebe turning the lights on and off
Re: Random faction and location variable questions
For 1 perhaps it might help if you posted what you wrote. It certainly is doable. Here's an example of how I did it. Probably not the best way to do it, but I know it works at least. :)Magical_Noob wrote: ↑March 29th, 2022, 10:11 am 1) How do I go about stopping a faction from being selected if a player select random factions? I tried the 'random_faction', 'choices' and 'except' but I am not achieving the results that I want. The reason I am looking to stop this is because 1 of the faction I made is mainly for AI use.
3) How do I add a custom picture to the icon in _server.pbl file. I tried below code but failed.Code: Select all
icon="units/empire/empire_iron_lancer.png~RC(magenta>red)"
Code: Select all
[era]
id=Lonely_Era+AoH
name=_ "Lonely Era Heroes + Age of Heroes"
description=_ "Includes the Age of Heroes factions plus Gremlins, Væringjar, Avian Tribes, Deep Ones and Jephrif. An era with higher level units: level three leaders, with level one and two units available for recruit. Consists of 12 factions. Not considered balanced."
require_era=yes
[multiplayer_side]
id=RandomLEAoH
name=_ "Random Lonely Era Faction"
image="units/random-dice.png"
random_faction=yes
choices=AvianTribesAoH,strn_gremlins_AoH,VæringjarAoH,deeponesAoH,JepJephrif
[/multiplayer_side]
[multiplayer_side]
id=RandomNLEAoH
name=_ "Random Non Lonely Era Faction"
image="units/random-dice.png"
random_faction=yes
except=AvianTribesAoH,strn_gremlins_AoH,VæringjarAoH,deeponesAoH,JepJephrif
[/multiplayer_side]
{~add-ons/Lonely_Era/factions/gremlinsAoH.cfg}
{~add-ons/Lonely_Era/factions/vaeringjarAoH.cfg}
{~add-ons/Lonely_Era/factions/AvianTribesAoH.cfg}
{~add-ons/Lonely_Era/factions/deeponesAoH.cfg}
{~add-ons/Lonely_Era/factions/jephrifAoH.cfg}
{ERA_HEROES}
{multiplayer/factions/dunefolk-aoh.cfg}
[/era]
For 3 remember that you can only use core images that way. To use anything else there are instructions you can follow here:
https://wiki.wesnoth.org/DataURI
- Magical_Noob
- Posts: 50
- Joined: May 24th, 2009, 2:46 pm
- Location: UK
Re: Random faction and location variable questions
Thank you for the code, it made me realise where I went wrong. I was inputting the code in the wrong place (I placed it in the Faction instead of Era), and with the example you have kindly provided, I was able to get it to work. The link seems to be exactly what I needed, I now have the code for the icon prepared accordingly and will give it a try when I publish my next update. Thanks again for your help.Atreides wrote: ↑March 29th, 2022, 6:08 pmFor 1 perhaps it might help if you posted what you wrote. It certainly is doable. Here's an example of how I did it. Probably not the best way to do it, but I know it works at least.Magical_Noob wrote: ↑March 29th, 2022, 10:11 am 1) How do I go about stopping a faction from being selected if a player select random factions? I tried the 'random_faction', 'choices' and 'except' but I am not achieving the results that I want. The reason I am looking to stop this is because 1 of the faction I made is mainly for AI use.
3) How do I add a custom picture to the icon in _server.pbl file. I tried below code but failed.Code: Select all
icon="units/empire/empire_iron_lancer.png~RC(magenta>red)"
Although I suspect you're asking to change the {RANDOM_SIDE} effect? Then you'll have to look at that macro in mainline and make your own custom version.Code: Select all
[era] id=Lonely_Era+AoH name=_ "Lonely Era Heroes + Age of Heroes" description=_ "Includes the Age of Heroes factions plus Gremlins, Væringjar, Avian Tribes, Deep Ones and Jephrif. An era with higher level units: level three leaders, with level one and two units available for recruit. Consists of 12 factions. Not considered balanced." require_era=yes [multiplayer_side] id=RandomLEAoH name=_ "Random Lonely Era Faction" image="units/random-dice.png" random_faction=yes choices=AvianTribesAoH,strn_gremlins_AoH,VæringjarAoH,deeponesAoH,JepJephrif [/multiplayer_side] [multiplayer_side] id=RandomNLEAoH name=_ "Random Non Lonely Era Faction" image="units/random-dice.png" random_faction=yes except=AvianTribesAoH,strn_gremlins_AoH,VæringjarAoH,deeponesAoH,JepJephrif [/multiplayer_side] {~add-ons/Lonely_Era/factions/gremlinsAoH.cfg} {~add-ons/Lonely_Era/factions/vaeringjarAoH.cfg} {~add-ons/Lonely_Era/factions/AvianTribesAoH.cfg} {~add-ons/Lonely_Era/factions/deeponesAoH.cfg} {~add-ons/Lonely_Era/factions/jephrifAoH.cfg} {ERA_HEROES} {multiplayer/factions/dunefolk-aoh.cfg} [/era]
For 3 remember that you can only use core images that way. To use anything else there are instructions you can follow here:
https://wiki.wesnoth.org/DataURI
- Magical_Noob
- Posts: 50
- Joined: May 24th, 2009, 2:46 pm
- Location: UK
Re: Random faction and location variable questions
Published a new update, the custom icon is working too, thanks! 

- beetlenaut
- Developer
- Posts: 2867
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: Random faction and location variable questions
You can certainly do this, but you need to use a formula. To move the mask up one hex, you would write:
y="$($start_loc.y - 1)"
.Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
- Magical_Noob
- Posts: 50
- Joined: May 24th, 2009, 2:46 pm
- Location: UK
Re: Random faction and location variable questions
Great stuff, work like a charm. Thank you for that!beetlenaut wrote: ↑April 1st, 2022, 5:39 amYou can certainly do this, but you need to use a formula. To move the mask up one hex, you would write:y="$($start_loc.y - 1)"
.
