I need to get a list of all sides not allied to the player
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.
I need to get a list of all sides not allied to the player
For my era, I have a bunch of slaves. Like in DiD, I'm going to give each slave a 1-50 chance of rebelling each turn. For this , I need an extra side........... but because its for an entire era, not a scenario, I can't just have a spare side kicking around, because I don't know how many sides the scenario will have. Is there a way around this?
Last edited by Kapoue_II on December 12th, 2010, 5:53 pm, edited 1 time in total.
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: I need to create a ai controlled side..for an era.
At least with lua you can get the number of sides ([lua]code=<<local sides = #wesnoth.sides>>[/lua]). No idea how useful this is for you since I'm a noob concerning eras and multiplayer wml . For a normal scenario I know that it's not possible to add sides afterwards (that is, in an event).
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: I need to create a ai controlled side..for an era.
Thanks. I will take that as meaning it is impossible . The next best thing is to make the slaves defect to the enemy team. What code would I need to make them automatically join an enemy team?Anonymissimus wrote:At least with lua you can get the number of sides ([lua]code=<<local sides = #wesnoth.sides>>[/lua]). No idea how useful this is for you since I'm a noob concerning eras and multiplayer wml . For a normal scenario I know that it's not possible to add sides afterwards (that is, in an event).
Re: I need to create a ai controlled side..for an era.
Get a list of sides that are not allied with the current side (using a loop that goes through all of the sides), then use that as the input to a random number generator:
Then unstore the unit to set it to that side. You should probably add a failsafe in case there are no nonallied sides fro some reason... I guess you could just kill the unit if the player is doing some special MP scenario with no enemies.
Code: Select all
[set_variable]
name=unit.side
rand=$nonally_list
[/set_variable]
You are a Dark Adept: you dimmerse yourself in the dark arts...potentially with great rewards....
-JW's personality quiz
-JW's personality quiz
Re: I need to create a ai controlled side..for an era.
How do I get the list? I can handle the rest of the code, but I have no idea how to get the sides, except using Annonysimus's Lua code-and I have no comprehention of lua, (yet) so I hesitate to use it.
- Pentarctagon
- Project Manager
- Posts: 5564
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: I need to create a ai controlled side..for an era.
you could use store_unit with canrecruit=yes in the filter to get all the leaders, then use store_side to compare team names to see if they are allied or not.
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: I need to create a ai controlled side..for an era.
That I knew. What I need to know is how to compare the lists. Can I stick a "[not]" tag in the [store_side]? (So that it stores all the sides who are not allied)
EDIT: This is the code I have for storing the sides, after I have stored their leaders:
EDIT: This is the code I have for storing the sides, after I have stored their leaders:
Code: Select all
{FOREACH leaders num}
[set_variable]
name=loop
add=1
[/set_variable]
[store_side]
side=$leaders.$loop.side
variable=sides
[/store_side]
{NEXT num}
Am I allowed the line that says $leaders (the variable the side leaders are in) .$loop (num is the variable that keeps track of what number loop I'm on-and subsequently, how many are stored in the variable).side
Re: I need to create a ai controlled side..for an era.
I recommend this:Kapoue_II wrote:That I knew. What I need to know is how to compare the lists. Can I stick a "[not]" tag in the [store_side]? (So that it stores all the sides who are not allied)
EDIT: This is the code I have for storing the sides, after I have stored their leaders:Am I allowed the line that says $leaders (the variable the side leaders are in) .$loop (num is the variable that keeps track of what number loop I'm on-and subsequently, how many are stored in the variable).sideCode: Select all
{FOREACH leaders num} [set_variable] name=loop add=1 [/set_variable] [store_side] side=$leaders.$loop.side variable=sides [/store_side] {NEXT num}
Code: Select all
{FOREACH leaders num}
[store_side]
side=leaders[$num].side
variable=temp_side
[/store_side]
[if]
[variable]
name=temp_side.team_name
not_equals=$current_team_name
[/variable]
[then]
[set_variables]
name=enemy_list
mode=append
[value]
n=leaders[$num].side
[/value]
[/set_variables]
[/then]
[/if]
{NEXT num}
[set_variable]
name=enemy_list
[join]
variable=enemy_list
key=n
separator=,
[/join]
[/set_variable]
[set_variable]
name=unit.side
rand=$enemy_list
[/set_variable]
You are a Dark Adept: you dimmerse yourself in the dark arts...potentially with great rewards....
-JW's personality quiz
-JW's personality quiz