Random faction generator add-on idea

It's not easy creating an entire faction or era. Post your work and collaborate in this forum.

Moderator: Forum Moderators

Post Reply
Nivanpylte2
Posts: 5
Joined: February 17th, 2020, 10:31 pm

Random faction generator add-on idea

Post by Nivanpylte2 »

I have an idea for an era:
My idea was to make a random faction generator that take in input the number of units wanted and output a playable faction with a leader and a recruit list from the pool of units of the default era.
And if it's possible why not making the possibility to choose for each recruit slot ?
I just written this script in python but I don't know how to implement it in the game :hmm:.
So if someone has the capacity for implementing it in the game it could be very cool !
And sorry for my English cause i'm french :P


Python script if you want to test it (just replace all underscores at the front by spaces):



default_units = ["Drake Burner", "Drake Clasher", "Drake Fighter", "Drake Glider", "Saurian Augur", "Saurian Skirmisher", "Dune Burner", "Dune Herbalist", "Dune Rider", "Dune Rover", "Dune Skirmisher", "Dune Soldier", "Naga Dirkfang", "Dwarvish Fighter", "Dawrvish Guardsman", "Dwarvish Thunderer", "Dwarvish Ulfserker", "Footpad", "Gryphon Rider", "Poacher", "Thief", "Bowman", "Cavalryman", "Fencer", "Heavy Infantryman", "Horseman", "Mage", "Merman Fighter", "Spearman", "Goblin Spearman", "Naga Fighter", "Orcish Archer", "Orcish Assassin", "Orcish Grunt", "Troll Welp", "Wolf Rider", "Elvish Archer", "Elvish Fighter", "Elvish Scout", "Elvish Shaman", "Merman Hunter", "Wose", "Dark Adept", "Ghost", "Ghoul", "Skeleton", "Skeleton Archer", "Vampire Bat", "Walking Corpse"] # units pool (default + dunefolk era)

print("When you use draft_faction() function, each time a list of units appear just type the number corresponding to the unit to add it to your faction !")

import random as r

def generate_faction(number_of_units):
_____faction = r.sample(default_units, k = number_of_units)
_____r.shuffle(faction)
_____return faction # script for random faction generator with a number of units in input

def draft_faction(number_of_units, number_of_choices):
_____pool = generate_faction(number_of_units * number_of_choices)
_____faction = []
_____for i in range(number_of_units):
__________player_choices = pool[i * number_of_choices : i * number_of_choices + number_of_choices]
__________selected_troop = int(input(player_choices)) - 1
__________faction.append(player_choices[selected_troop])
__________print(player_choices[selected_troop])
_____print(faction)
User avatar
Heindal
Posts: 1360
Joined: August 11th, 2011, 9:25 pm
Location: Germany, Karlsruhe
Contact:

Re: Random faction generator add-on idea

Post by Heindal »

Well, I don't think you can embed python directly in the game. It just supports cobra *badaboombish*.
But lets leave lame jokes aside, lua is supported. But you can do this simply by using wml.

For example:

1. You set a variable called "randrecruit" to a random value.


[set_variable]
name=randrecruit
rand="Drake Burner", "Drake Clasher", "Drake Fighter", "Drake Glider", "Saurian Augur", "Saurian Skirmisher", "Dune Burner", "Dune Herbalist", "Dune Rider", "Dune Rover", "Dune Skirmisher", "Dune Soldier", "Naga Dirkfang", "Dwarvish Fighter", "Dawrvish Guardsman", "Dwarvish Thunderer", "Dwarvish Ulfserker", "Footpad", "Gryphon Rider", "Poacher", "Thief", "Bowman", "Cavalryman", "Fencer", "Heavy Infantryman", "Horseman", "Mage", "Merman Fighter", "Spearman", "Goblin Spearman", "Naga Fighter", "Orcish Archer", "Orcish Assassin", "Orcish Grunt", "Troll Welp", "Wolf Rider", "Elvish Archer", "Elvish Fighter", "Elvish Scout", "Elvish Shaman", "Merman Hunter", "Wose", "Dark Adept", "Ghost", "Ghoul", "Skeleton", "Skeleton Archer", "Vampire Bat", "Walking Corpse"
[/set_variable]

2. You allow a specific side to get this new recruit. In this case side 1.

[allow_recruit]
type=$randrecruit
side=1
[/allow_recruit]

3. Repeat, you can do this with a while or by making a list of recruits right from the start. In this case NumberOfRecruits (see that's not a python, but a camel) is the number of units you want in the recruit list.

Spoiler:
4. Drawback of this solution is, that you when you get the same randrecruit, it will not be added to the teams recruitable units, as it is already there.
But it's a working solution however, but with bad luck you will just have 8 of 10 recruits in your recruitmentlist. I admit it's a very easy code. Unfortunately I'm not good with arrays in wml.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Nivanpylte2
Posts: 5
Joined: February 17th, 2020, 10:31 pm

Re: Random faction generator add-on idea

Post by Nivanpylte2 »

Thank you for your contribution it's a good start :)
I think I will learn WML and do it by myself.
User avatar
ghype
Posts: 1069
Joined: December 13th, 2016, 4:43 pm
Location: Berlin, Germany

Re: Random faction generator add-on idea

Post by ghype »

"pick your recruits" era has that function.

It is exactly what you described. While you can pick and choose manually units of a certain amount from a pool of default units, there is also a function fill them randomly.
Post Reply