duel scenario endings
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.
duel scenario endings
I'm trying to make a scenario end in two possible ways. You can either defeat the one leader and when the turns run out you'll win with no bonus, or defeat both leaders and win with a bonus. Here's the coding I tried which doesn't seems to work:
Any ideas?
Gambrous
Code: Select all
[event]
name=time over
[if]
[have_unit]
side=3
canrecruit=yes
[/have_unit]
[then]
[message]
speaker=Sir Gresdon
message= _ "At last his control is gone and I am free! Thankyou elves"
[/message]
[message]
speaker=Gambrous
message= _ "Now the undead are defeated!"
[/message]
[message]
speaker=Tristin
message= _ "Thankyou prince Gambrous, please I welcome you to the Castle of the Arcane Arts"
[/message]
[endlevel]
result=victory
bonus=no
[/endlevel]
[/then]
[else]
[if]
[have_unit]
side=4
canrecruit=yes
[/have_unit]
[then]
[message]
speaker=Gambrous
message= _ "The undead horde is too numerous, we are doomed!"
[/message]
[endlevel]
result=lose
[/endlevel]
[/then]
[/if]
[/else]
[/if]
[/event]
[event]
name=last breath
[filter]
id=Sir Gresdon
[/filter]
[message]
speaker=Sir Gresdon
message= _ "At last his control is gone and I am free! Thankyou elves"
[/message]
[/event]
[event]
name=enemies defeated
[message]
speaker=Gambrous
message= _ "Now the undead are defeated!"
[/message]
[message]
speaker=Tristin
message= _ "Thankyou prince Gambrous, please I welcome you to the Castle of the Arcane Arts"
[/message]
[endlevel]
result=victory
bonus=yes
{NEW_GOLD_CARRYOVER 40}
[/endlevel]
[/event]
Gambrous
Re: duel scenario endings
Here is what your WML is saying:
When time runs out, if side 3 is not defeated, then win (which happens to contradict your desire to require at least one side to be defeated; it could be that side 4 is also not defeated).
Else. when time runs out (and side 3 is defeated), then if side 4 is not defeated then lose. (The "if" part is superfluous unless you have more than these two sides as enemies of the player. Also, this should not be a loss since one leader was defeated.)
When Sir Gresdon is killed, have him say something. (On a related topic, "thank you" is two words.)
When all enemies are defeated, win with a bonus.
When time runs out, if side 3 is not defeated, then win (which happens to contradict your desire to require at least one side to be defeated; it could be that side 4 is also not defeated).
Else. when time runs out (and side 3 is defeated), then if side 4 is not defeated then lose. (The "if" part is superfluous unless you have more than these two sides as enemies of the player. Also, this should not be a loss since one leader was defeated.)
When Sir Gresdon is killed, have him say something. (On a related topic, "thank you" is two words.)
When all enemies are defeated, win with a bonus.
Re: duel scenario endings
Yeh, I didn't make it clear. What I want is for the player to win if they defeat side4 but not side3 before time runs out. If they then defeat both sides 3 and 4 then they get a bonus. This is why it's ok for side 3 to still be standing at the end of the scenario. So I think from what you're saying I need to write in wml that if side 3 is still standing with side 4 defeated then win. The whole bit about side 3 not being defeated but side 4 is defeated should be ok because side 4 is the only enemy the player has to defeat to win.
Sir Gresdon is meant to say that (I also put this in):
So what alterations do I need to make?
Gambrous
Sir Gresdon is meant to say that (I also put this in):
Code: Select all
[event]
name=last breath
[filter]
id=Sir Gresdon
[/filter]
[message]
speaker=Sir Gresdon
message= _ "At last his control is gone and I am free! Thankyou elves"
[/message]
[/event]
Gambrous
Re: duel scenario endings
ok, this is where my script is at the minute
Still not working.
Gambrous
Code: Select all
[event]
name=time over
[if]
[have_unit]
side=3
canrecruit=yes
[/have_unit]
[have_unit]
side=4
canrecruit=yes
[/have_unit]
[then]
[endlevel]
result=defeat
[/endlevel]
[/then]
[else]
[have_unit]
side=3
canrecruit=yes
[/have_unit]
[then]
[message]
speaker=Sir Gresdon
message= _ "At last his control is gone and I am free! Thank you elves"
[/message]
[message]
speaker=Gambrous
message= _ "Now the undead are defeated!"
[/message]
[message]
speaker=Tristin
message= _ "Thankyou prince Gambrous, please I welcome you to the Castle of the Arcane Arts"
[/message]
[endlevel]
result=victory
bonus=no
[/endlevel]
[/then]
[else]
[have_unit]
side=4
canrecruit=yes
[/have_unit]
[then]
[message]
speaker=Gambrous
message= _ "The undead horde is too numerous, we are doomed!"
[/message]
[endlevel]
result=lose
[/endlevel]
[/then]
[/else]
[/else]
[/if]
[/event]
[event]
name=last breath
[filter]
id=Sir Gresdon
[/filter]
[message]
speaker=Sir Gresdon
message= _ "At last his control is gone and I am free! Thank you elves"
[/message]
[/event]
[event]
name=enemies defeated
[message]
speaker=Gambrous
message= _ "Now the undead are defeated!"
[/message]
[message]
speaker=Tristin
message= _ "Thankyou prince Gambrous, please I welcome you to the Castle of the Arcane Arts"
[/message]
[endlevel]
result=victory
bonus=yes
{NEW_GOLD_CARRYOVER 40}
[/endlevel]
[/event]
Gambrous
Re: duel scenario endings
I don't see any obvious problems in your code. What actually happens when you try it?
Re: duel scenario endings
You can't do that - [else] is supposed to contain only ActionWML, no conditions. So you'd have to write this:Gambrous wrote:Code: Select all
[else] [have_unit] side=3 canrecruit=yes [/have_unit]
Code: Select all
[else]
[if]
[have_unit]
side=3
canrecruit=yes
[/have_unit]
[then]
...
[/then]
[/if]
Co-Creator of The Fellowship of the Clay (BfW 1.10) ~~ Maintainer of the German Code of Conduct
How to isolate problematic WML code ~~ WML error messages and their reasons
How to isolate problematic WML code ~~ WML error messages and their reasons
Re: duel scenario endings
This is something to work with, but let's try rearranging the logic a bit. You want the player to win if they defeat side 4. Also defeating side 3 causes the scenario to end early.Gambrous wrote:What I want is for the player to win if they defeat side4 but not side3 before time runs out. If they then defeat both sides 3 and 4 then they get a bonus.
Or....
If all enemies are defeated, the player wins. This is the default, so no need to do anything special.
If turns run out, then not all enemies were defeated. The player still wins if side 4 was defeated.
Code: Select all
[event]
name=time over
[if]
# If side 4 has been defeated.
[not]
[have_unit]
side=4
canrecruit=yes
[/have_unit]
[/not]
[then]
[message]
speaker=Sir Gresdon
message= _ "At last his control is gone, and I am free! Thank you elves."
[/message]
[endlevel]
result=victory
bonus=no
[/endlevel]
[/then]
[else]
# Side 4 has not been defeated. The player loses.
[message]
speaker=Gambrous
message= _ "The undead horde is too numerous. We are doomed!"
[/message]
# Not strictly necessary, but it makes the WML look complete:
[endlevel]
result=defeat
[/endlevel]
[/else]
[/if]
Code: Select all
[event]
name=victory
[message]
speaker=Gambrous
message= _ "Now the undead are defeated!"
[/message]
[message]
speaker=Tristin
message= _ "Thank you Prince Gambrous. Please, I welcome you to the Castle of the Arcane Arts."
[/message]
[/event]
Re: duel scenario endings
I've tried everything suggested and all that happens is the game crashes when loading the scenario. I'm attaching the campaign so someone else can try it and see if it works for them. Alternatively if anyone wants to look through the code then they have the entire scenario in case the problem is somewhere else.
Gambrous
Gambrous
- Attachments
-
- Defense_of_Glenfire_Forest.7z
- this is the campaign so far
- (108.93 KiB) Downloaded 87 times
Re: duel scenario endings
The first problem (though I don't think it effects anything) is in _main.cfg. Remove the line that says '{~add-ons/Defense_of_Glenfire_Forest/maps}'. The scenario files should refer to the map files directly, so you don't need that in _main.cfg.
When I tried to run the campaign, Wesnoth hung while continuously accessing my hard drive. Thinking it was a recursive macro, I used the tool at data/tools/wesnoth/wmlparser.py and found a missing quote mark near the end of scenario 4, after Mal-Esprer.
With that fix, the campaign starts up fine, though I haven't actually played it.
When I tried to run the campaign, Wesnoth hung while continuously accessing my hard drive. Thinking it was a recursive macro, I used the tool at data/tools/wesnoth/wmlparser.py and found a missing quote mark near the end of scenario 4, after Mal-Esprer.
With that fix, the campaign starts up fine, though I haven't actually played it.
Re: duel scenario endings
How do I use this tool? It would be very beneficial.Luther wrote:I used the tool at data/tools/wesnoth/wmlparser.py
Gambrous
Re: duel scenario endings
Ditto...Gambrous wrote:How do I use this tool? It would be very beneficial.Luther wrote:I used the tool at data/tools/wesnoth/wmlparser.py
Gambrous
Although I notice line errors when the game tries to load, which makes it easier to find mistakes.
America-- Land of the Free, home of the Brave! "And now that we've taken care of the Braves we're coming after the Free."
"BANNED!!! What the hell do you mean BANNED? All I did was call one narrow-minded, power-hungry Nazi moderator a narrow-minded, power-hungry Nazi!"
"BANNED!!! What the hell do you mean BANNED? All I did was call one narrow-minded, power-hungry Nazi moderator a narrow-minded, power-hungry Nazi!"