recruit script difficulties
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.
- Madnessbane
- Posts: 128
- Joined: May 8th, 2008, 11:14 am
recruit script difficulties
I'm composing a script that allows different units to be recruited depending on the "general" you select.
originally I had the same units for each general that script worked, it looked like this:
so I tried something like this for each general
for some reason it only worked for the first general, if you recruited any of the other generals you could not recruit anything. I presumed the game could only load one recruit script at a time or something, so now I'm trying this:
now nothing can be recruited after you recruit any of the generals. Any ideas?
originally I had the same units for each general that script worked, it looked like this:
Code: Select all
#define RECRUIT_MOD
[event]
name=recruit
side=$side_number
first_time_only=no
[filter]
type=general1,general2,general3,general4
[/filter]
[disallow_recruit]
type=general1,general2,general3,general4
side=$side_number
[/disallow_recruit]
[allow_recruit]
type=unit1,unit2,unit3,unit4
side=$side_number
[/allow_recruit]
[/event]
#enddef
Code: Select all
#define RECRUIT_MOD
[event]
name=recruit
side=$side_number
first_time_only=no
[filter]
type=general1
[/filter]
[disallow_recruit]
type=general1,general2,general3,general4
side=$side_number
[/disallow_recruit]
[allow_recruit]
type=unit1,unit2,unit3,unit4
side=$side_number
[/allow_recruit]
[/event]
#enddef
Code: Select all
#define RECRUIT_MOD
[event]
name=recruit
side=$side_number
first_time_only=no
[if]
[filter]
type=general1
[/filter]
[then]
[disallow_recruit]
type=general1,general2,general3,general4
side=$side_number
[/disallow_recruit]
[allow_recruit]
type=unit1,unit2,unit3,unit4
side=$side_number
[/allow_recruit]
[/then]
[/if]
[if]
[filter]
type=general2
[/filter]
[then]
[disallow_recruit]
type=general1,general2,general3,general4
side=$side_number
[/disallow_recruit]
[allow_recruit]
type=unit5,unit6,unit7,unit8
side=$side_number
[/allow_recruit]
[/then]
[/if]
[if]
[filter]
type=general3
[/filter]
[then]
[disallow_recruit]
type=general1,general2,general3,general4
side=$side_number
[/disallow_recruit]
[allow_recruit]
type=unit9,unit10,unit11,unit12
side=$side_number
[/allow_recruit]
[/then]
[/if]
[if]
[filter]
type=general4
[/filter]
[then]
[disallow_recruit]
type=general1,general2,general3,general4
side=$side_number
[/disallow_recruit]
[allow_recruit]
type=unit13,unit14,unit15,unit16
side=$side_number
[/allow_recruit]
[/then]
[/if]
[/event]
#enddef
Last edited by Madnessbane on September 17th, 2011, 11:22 am, edited 1 time in total.
Re: recruit script difficulties
First of all, please use the code tags and some kind of indentation. Your code is pretty hard to read as it is.
But personally I'd suggest a more flexible solution without code repetition:
Are you trying to create multiple macros with the same name? No, that won't work.I presumed the game could only load one recruit script at a time or something, so now I'm trying this:
You can't use a filter tag inside an if statement. You have to replace it with a condition tag. Like this:[if]
[filter]
type=general1
[/filter]
[then]
[disallow_recruit]
type=general1,general2,general3,general4
side=$side_number
[/disallow_recruit]
[allow_recruit]
type=unit1,unit2,unit3,unit4
side=$side_number
[/allow_recruit]
[/then]
[/if]
Code: Select all
[if]
[variable]
name=unit.type
equals=general1
[/variable]
[then]
#stuff
[/then]
[if]
Code: Select all
#define RECRUIT_MOD GENERAL_TYPE DISALLOW_TYPES ALLOW_TYPES
[event]
name=recruit
side=$side_number
first_time_only=no
[filter]
type={GENERAL_TYPE}
[/filter]
[disallow_recruit]
type={DISALLOW_TYPES}
side=$side_number
[/disallow_recruit]
[allow_recruit]
type={ALLOW_TYPES}
side=$side_number
[/allow_recruit]
[/event]
#enddef
...
{RECRUIT_MOD general1 (general1,general2,general3) (unit1,unit2)}
{RECRUIT_MOD general2 (general1,general2,general3) (unit3,unit4)}
etc etc
- Madnessbane
- Posts: 128
- Joined: May 8th, 2008, 11:14 am
Re: recruit script difficulties
Tried both those methods but they have the same problem. It works if the code is just for one general, but it wont work at all for more than one general. I have NO idea why none of it is working...
Re: recruit script difficulties
Second solution works here... could you upload the whole scenario?
- Madnessbane
- Posts: 128
- Joined: May 8th, 2008, 11:14 am
Re: recruit script difficulties
it's a multiplayer era. The script is in the utils folder recruit mod, and it is triggered by the leader on the afflicted team. You can see the old script for any of the other teams to... I've deleted the images for an easier upload.
- Attachments
-
- WOC2.zip
- (339.89 KiB) Downloaded 84 times
Re: recruit script difficulties
Firstly, does http://wiki.wesnoth.org/EventWML say that you can put a side= key in [event]? No, and therefore it has no meaning there (it won't break anything either, but it just won't do anything at all).
Secondly, in recruit mod.cfg you only define macros. I don't see you saying that you're actually calling those macros somewhere.
Thirdly, it's not a good idea to use whitespace in filenames, you should replace the spaces with underscores.
Secondly, in recruit mod.cfg you only define macros. I don't see you saying that you're actually calling those macros somewhere.
Thirdly, it's not a good idea to use whitespace in filenames, you should replace the spaces with underscores.
Re: recruit script difficulties
1, I can't load the era because it has many-many filepath errors. You might not sense this on Windows, but on Unix, files are being looked up case sensitively (blahblah.map isn't equal to blahblah.MAP). You should pay attention to this.
2, It took some time to locate the problematic part in Afflicted Draugr.cfg since you forgot to mention who is the 'afflicted leader'...
3, I'm loosing my ground when talking about unit_type WML, but including event tags inside the unit definition looks very unsympathetic for me. When I nested the macro inside a scenario tag it worked like a charm.
2, It took some time to locate the problematic part in Afflicted Draugr.cfg since you forgot to mention who is the 'afflicted leader'...
3, I'm loosing my ground when talking about unit_type WML, but including event tags inside the unit definition looks very unsympathetic for me. When I nested the macro inside a scenario tag it worked like a charm.
- Madnessbane
- Posts: 128
- Joined: May 8th, 2008, 11:14 am
Re: recruit script difficulties
They're called in the afflicted Draugr file. The ones bellow afflicted work fine for the other teams, the problem occurs when I try to have four different codes for each general with different allow_recruit units. It only loads the first one for some reason.zookeeper wrote: Secondly, in recruit mod.cfg you only define macros. I don't see you saying that you're actually calling those macros somewhere.
and lipk, I can't embed it in a scenario tag because i want it to be part of an era.
Re: recruit script difficulties
You can put [event]s in [era], and that's where you should put events which are an integral part of how your era works. There's pretty much no reason to put stuff in [unit_type] unless you want that unit to be maximally easily portable across different add-ons or something similar.
Anyway, I can't easily see what's supposed to be wrong with your code. I don't want to track down all the unit types which you list as arguments to the macro and find out if you've typoed one of them (an unknown id in a recruit list can cause that list to not show up at all) or some some other simple mistake like that.
Anyway, I can't easily see what's supposed to be wrong with your code. I don't want to track down all the unit types which you list as arguments to the macro and find out if you've typoed one of them (an unknown id in a recruit list can cause that list to not show up at all) or some some other simple mistake like that.
- Madnessbane
- Posts: 128
- Joined: May 8th, 2008, 11:14 am
Re: recruit script difficulties
I'll try putting it in the era tag. I'm fairly sure the problem is related to loading several recruit scripts at once, as any script I try to load singularly works fine. Thanks for the help guys.
Re: recruit script difficulties
Your events might of course interfere with each other due to what they actually do, but having multiple events is never a problem as such.
- Madnessbane
- Posts: 128
- Joined: May 8th, 2008, 11:14 am
Re: recruit script difficulties
I've placed all my event tags in the era instead and it all works fine now, thank you very much guys. I'll get onto underscoring everything to =P