Add new recruitable unit with an object
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.
- lhybrideur
- Posts: 369
- Joined: July 9th, 2019, 1:46 pm
Add new recruitable unit with an object
Hi everyone,
here is what I am trying to do.
I want to have one object on the map that when picked up allows the side to recruit a new unit type.
Here is what I would like to do:
Here is what I am currently doing (not tested)
Do you have anything more simple that what I am currently doing?
EDIT: corrected the event. It is now working
here is what I am trying to do.
I want to have one object on the map that when picked up allows the side to recruit a new unit type.
Here is what I would like to do:
Code: Select all
[object]
name= _ "Intuitive Encyclopedia of Elementals"
[effect]
apply_to=???
[allow_recruit]
side=unit.side
type=Vine Beast
[/allow_recruit
[/effect]
[/object]
Code: Select all
[object]
name= _ "Intuitive Encyclopedia of Elementals"
[effect]
apply_to=new_ability
[abilities]
{ABILITY_BEGINNER_ELEMENTALIST}
[/abilities]
[/effect]
description="Allow to recruit Vine Beasts"
[/object]
#define ABILITY_BEGINNER_ELEMENTALIST
[dummy]
id=beginner_elementalist
name= _ "beginner elementalist"
description= _ "Allow to recruit Vine Beasts."
[/dummy]
#enddef
[event]
name=turn refresh
first_time_only=no
[allow_recruit]
[has_unit]
ability=beginner_elementalist
[/has_unit]
type=Vine Beast
[/allow_recruit]
[/event]
EDIT: corrected the event. It is now working
Last edited by lhybrideur on July 27th, 2022, 6:45 pm, edited 2 times in total.
- Lord-Knightmare
- Discord Moderator
- Posts: 2360
- Joined: May 24th, 2010, 5:26 pm
- Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
- Contact:
Re: Add new recruit unit with an object
just using `[allow_recruit]` if gotten item. Unless you want to this to be just temporary (as in, would go away if you lose this unit)
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
- Celtic_Minstrel
- Developer
- Posts: 2211
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Add new recruitable unit with an object
Is the idea that this book is an item that can be lost, or even given to another unit?
If so, I think the best approach would be to use a custom effect that gives the unit
Basing it on
If so, I think the best approach would be to use a custom effect that gives the unit
canrecruit=yes
and extra_recruit=Vine Beast
. You need some Lua setup to support it, but your WML would end up looking something like this:Code: Select all
[object]
name= _ "Intuitive Encyclopedia of Elementals"
[effect]
apply_to=allow_recruit
type=Vine Beast
[/effect]
[/object]
extra_recruit
means the unit who has the book would need to stand on a keep in order to recruit a Vine Beast. It'll also be able to recruit any other units that the side can recruit, though, which may be undesirable?Re: Add new recruitable unit with an object
Code: Select all
[object]
name= _ "Intuitive Encyclopedia of Elementals"
[/object]
[allow_recruit]
side=$unit.side
type=Vine Beast
[/allow_recruit
- lhybrideur
- Posts: 369
- Joined: July 9th, 2019, 1:46 pm
Re: Add new recruitable unit with an object
Thank to all of you for your answers
should work.
I will try that asap.
EDIT: my bit of code seems to work
I am not sure if it is what you meant, but I think using
Code: Select all
[object]
name= _ "Intuitive Encyclopedia of Elementals"
[then]
[allow_recruit]
side=1
type=Vine Beast
[/allow_recruit]
[/then]
description="Allow to recruit Vine Beasts"
[/object]
I will try that asap.
If my idea does not work, I would like to try yours, but I have no idea how to write that in lua. Do you know if there is an example of custom apply_to in a campaign?
EDIT: my bit of code seems to work
Last edited by lhybrideur on July 29th, 2022, 6:52 pm, edited 1 time in total.
- Celtic_Minstrel
- Developer
- Posts: 2211
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Add new recruitable unit with an object
To be clear, this is an example of a custom
apply_to
written in Lua. There are also several examples in the effects.lua file, which is also part of World Conquest.