Recruit Units without Castles
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.
Recruit Units without Castles
Hi all,
I want to recruit units without castles just like in TLU.
What is the easiest way to do this?
Thanks for replies.
I want to recruit units without castles just like in TLU.
What is the easiest way to do this?
Thanks for replies.
Campaigns Im working at:
- The Return of the Darks[ unfinished ]
Violence is the last refuge of the incompetent. : ) - Isaac Asimov
- The Return of the Darks[ unfinished ]
Violence is the last refuge of the incompetent. : ) - Isaac Asimov
Re: Recruit Units without Castles
Ultimate circle creates temporary castle around wherever unit moves.
Re: Recruit Units without Castles
Thats not what i want. I would prefer recruiting like the heavy summoner.
Campaigns Im working at:
- The Return of the Darks[ unfinished ]
Violence is the last refuge of the incompetent. : ) - Isaac Asimov
- The Return of the Darks[ unfinished ]
Violence is the last refuge of the incompetent. : ) - Isaac Asimov
- beetlenaut
- Developer
- Posts: 2814
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: Recruit Units without Castles
Why don't you look at the code for the heavy summoner and see how it's done?
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
Re: Recruit Units without Castles
Thank you for the reply.
But the Code looks very complicate to me. Maybe you can explain me how it works?
But the Code looks very complicate to me. Maybe you can explain me how it works?
- beetlenaut
- Developer
- Posts: 2814
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: Recruit Units without Castles
OK, I looked at it, and that's a valid point.
Here is the important macro definition. I removed the unnecessary lines, so it's much easier to understand now. You can put this in a file in your utils folder or at the beginning of your scenario file.
This is an example of how you use it in a scenario.
Put it in your code without changes, and make sure it works. If it works, then you can slowly modify it to make it work how you actually want. If you ask us for help, it's good to have a specific question.
Here is the important macro definition. I removed the unnecessary lines, so it's much easier to understand now. You can put this in a file in your utils folder or at the beginning of your scenario file.
Code: Select all
#define RECRUIT_MENU_ITEM DESCRIPTION COST UNIT
[set_menu_item]
id={DESCRIPTION} + "_menu_item"
description={DESCRIPTION}+" - "+ _ "gold:"+" "+{COST}
[filter_location]
[filter_adjacent_location]
[filter]
canrecruit=yes
side=$side_number
[/filter]
[/filter_adjacent_location]
[/filter_location]
[command]
[store_gold]
variable=actual_gold
side=$side_number
[/store_gold]
[if]
[variable]
name=actual_gold
greater_than_equal_to={COST}
[/variable]
[then]
[gold]
amount=-{COST}
side=$side_number
[/gold]
[unit]
type={UNIT}
side=$side_number
x,y=$x1,$y1
moves=0
animate=yes
[/unit]
{MODIFY_UNIT x,y=$x1,$y1 attacks_left 0}
{MODIFY_UNIT x,y=$x1,$y1 moves 0}
[/then]
[else]
[message]
speaker=narrator
side_for=$side_number
message= _ "I have insufficient gold. I am unable to summon."
image=wesnoth-icon.png
[/message]
[/else]
[/if]
{CLEAR_VARIABLE actual_gold}
[/command]
[/set_menu_item]
#enddef
Code: Select all
[event]
name=prestart
{RECRUIT_MENU_ITEM (Recruit a fighter) 14 (Elvish Fighter)}
[/event]
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
Re: Recruit Units without Castles
Thank you. This is a very good help to me.