Need help creating a mp scenario that saves correctly
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.
Need help creating a mp scenario that saves correctly
So I finished my first scenario kinda. I can play it and everything works, but when I try to save it mid-game it creates a save file that's unvalid (it's there and I can't see any problem in there though my understanding of what needs to be in there is very vague, but the game shows "unvalid" in the loading screen on the left when I select that save).
I tried to figure out how to get it working, but the explanations in the forum (https://wiki.wesnoth.org/BuildingScenarios and the simple, intermediate and advanced guide lines) were too vague for me. Just so it can be improved one example what I missed to find there was an explanation how to set up the _main.cfg and how to use [multiplayer] and stuff like that correctly. After some more search and following a searching through several pages linked and/or linked on linked pages I found https://wiki.wesnoth.org/AddonStructure,https://wiki.wesnoth.org/ScenarioWML andhttps://wiki.wesnoth.org/BuildingScenarios just to name a few. I also tried to look at official scenarios and to copy their structure. That's how I got it to show up in the scenario selection at least, but I would recommend a rewrite of those pages to make them more linear. Anyway, neither creating a scenario with the map editor and adding [event]s to the cfg file directly nor setting up a simple add-on with the scenario inside resulted in a proper save file.
I'm not sure what causes it, but my instincts are telling me it's probably related to some events that remove and add units to the map by using [store_unit] with kill=yes and [unstore_unit] as well as some [unit] tags to create completely new units and [kill] to kill those a few rounds later again. I guess adding and removing those units isn't properly stored in the save files replay. But as I say it's just a guess and I couldn't figure out how to test that without removing all my code as it's just about everything it does.
ps: when you're not trying to reload it but instead are playing it from start to finish it works as intended. So units next to water are able to build ships, which takes a few rounds. In "harbours" (bridges) units can create those ships faster and build more complex ones such as transport galleons. When they are finished building a ship, the ship can be entered by three units (five in case of a galleon) and of course those units can disembark again.
pps: I know I'm very vague with my description, but that's because I have no clue how I could narrow the problem down. I hope someone has the leisure, patience and understanding to help me here. I would very much appreciate that.
I guess it's helpfull when I put my code here, but as I don't know what part it's in and I'm just learning wml it's a very messy design... so please don't shout at me for making it more complicated than I needed to. I know for sure using makros and maybe even custom events to shorten my code would have helped a lot, but I was trying to use what I knew or at least learn only one thing at a time, so I would be able to know what I'm doing... nevertheless feel free to tell me how to shorten it, but it would be very nice to give me the correct format as well as an explanation then, just so I can learn from it. (I hope that's still ok here, as I know actual wml should be in the wml workshop...). Ok, enough rambling now, here is my code:
my _main.cfg
my ScenarioTest.map inside UsefullShips_by_white/maps
I got an empty translations folder inside UsefullShips_by_white too.
The rest of my code follows in a second and third post as it's too long for one lol
I tried to figure out how to get it working, but the explanations in the forum (https://wiki.wesnoth.org/BuildingScenarios and the simple, intermediate and advanced guide lines) were too vague for me. Just so it can be improved one example what I missed to find there was an explanation how to set up the _main.cfg and how to use [multiplayer] and stuff like that correctly. After some more search and following a searching through several pages linked and/or linked on linked pages I found https://wiki.wesnoth.org/AddonStructure,https://wiki.wesnoth.org/ScenarioWML andhttps://wiki.wesnoth.org/BuildingScenarios just to name a few. I also tried to look at official scenarios and to copy their structure. That's how I got it to show up in the scenario selection at least, but I would recommend a rewrite of those pages to make them more linear. Anyway, neither creating a scenario with the map editor and adding [event]s to the cfg file directly nor setting up a simple add-on with the scenario inside resulted in a proper save file.
I'm not sure what causes it, but my instincts are telling me it's probably related to some events that remove and add units to the map by using [store_unit] with kill=yes and [unstore_unit] as well as some [unit] tags to create completely new units and [kill] to kill those a few rounds later again. I guess adding and removing those units isn't properly stored in the save files replay. But as I say it's just a guess and I couldn't figure out how to test that without removing all my code as it's just about everything it does.
ps: when you're not trying to reload it but instead are playing it from start to finish it works as intended. So units next to water are able to build ships, which takes a few rounds. In "harbours" (bridges) units can create those ships faster and build more complex ones such as transport galleons. When they are finished building a ship, the ship can be entered by three units (five in case of a galleon) and of course those units can disembark again.
pps: I know I'm very vague with my description, but that's because I have no clue how I could narrow the problem down. I hope someone has the leisure, patience and understanding to help me here. I would very much appreciate that.
I guess it's helpfull when I put my code here, but as I don't know what part it's in and I'm just learning wml it's a very messy design... so please don't shout at me for making it more complicated than I needed to. I know for sure using makros and maybe even custom events to shorten my code would have helped a lot, but I was trying to use what I knew or at least learn only one thing at a time, so I would be able to know what I'm doing... nevertheless feel free to tell me how to shorten it, but it would be very nice to give me the correct format as well as an explanation then, just so I can learn from it. (I hope that's still ok here, as I know actual wml should be in the wml workshop...). Ok, enough rambling now, here is my code:
my _main.cfg
Code: Select all
#textdomain wesnoth-UsefullShips_by_white
[textdomain]
name="wesnoth-UsefullShips_by_white"
path="data/add-ons/UsefullShips_by_white/translations"
[/textdomain]
#ifdef MULTIPLAYER
[binary_path]
path=data/add-ons/UsefullShips_by_white
[/binary_path]
{~add-ons/UsefullShips_by_white/scenarios}
#endif
Code: Select all
border_size=1
usage=map
Gg, Gg, Ww, Ww, Gg, Gg, Hh, Hh, Hh, Mm, Mm, Mm, Mm, Hh, Rr, Gg, Aa, Aa, Ds, Ds, Ww, Aa
Ww, Ww, Gg, Ww, Gs^Fp, Gg, Gg, Gg, Gg, Mm, Mm, Mm, Hh, Gs^Fp, Rr, Gg, Aa, Aa, Ds, Ww, Ww, Ai
Gg, Gg, Gg, Gg^Ve, Gs^Fp, Gg, Gg, Gg, Gg, Hh, Hh, Hh, Gs^Fp, Gs^Fp, Rr, Gg, Gg, Gg, Gg^Vh, Ww, Ds, Ww
Gg, Aa, Gg, Gs^Fp, Gs^Fp, Hh, Hh, Gg, Gg, Hh, Gg, Gg, Gs^Fp, Gs^Fp, Rr, Gs^Fp, Gs^Fp, Gs^Fp, Ds, Gs^Fp, Gs^Fp, Ww
Gg, Aa, Gg, Gg, Gs^Fp, Hh, Hh, Gs^Fp, Gg, Gg, Gg, Ss, Gs^Fp, Rr, Gs^Fp, Gs^Fp, Gs^Fp, Ss, Ss, Ss, Ss, Gs^Fp
Gg, Gg, Gg, Gg, Gg, Gs^Fp, Gs^Fp, Gs^Fp, Gg^Ve, Gs^Fp, Ss, Ds, Ww, Rr, Gs^Fp, Ww, Ch, Ai, Ss, Ss, Gs^Fp, Ww
Gg, Gg, Gg, Gg, Ww, Gll^Fp, Gs^Fp, Gs^Fp, Gs^Fp, Gg, Gs^Fp, Ww, Ww, Ww, Ww, Ww, 2 Kh, Ww, Ss, Ss, Gs^Fp, Ww
Ds, Ds, Gg, Rrc, 1 Kh, Ch, Gs^Fp, Gs^Fp, Gs^Fp, Gg, Rr, Ww, Ww^Bw/, Rr, Gll^Fp, Ch, Ha, Gs^Fp, Gg, Gg, Gg, Ww
Ww, Gs^Fp, Gg, Gg, Ch, Gs^Fp, Gs^Fp, Gs^Fp, Rr, Rr, Gg, Rr, Ww, Gg, Gg, Gg, Gg, Gg, Gg^Vh, Gg, Gg, Gg
Ds, Gs^Fp, Gs^Fp, Gg, Gg, Gs^Fp, Gs^Fp, Gs^Fp, Rr, Ww, Ai, Gg, Ww, Gg, Gg, Hh, Hh, Hh, Ww, Mm, Ww, Ww
Gs^Fp, Gs^Fp, Gg, Gg, Gg, Gg, Gs^Fp, Gs^Fp, Rr, Ww, Ai, Aa, Ai, Aa, Ha, Ha, Ha, Hh, Ww, Ww, Ww, Mm
Gs^Fp, Gg, Gg, Gg, Gg, Gg, Rr, Rr, Gg^Vh, Ww, Ww, Ww, Ww, Hh, Ha, Aa, Aa, Hh, Ww, Ww, Ww^Vm, Ww
Gg, Gg, Gg, Gg, Rr, Rr, Gg, Gg, Ww, Ww, Ww, Ww, Ww, Ww, Gg^Vh, Aa, Gg, Ww, Ww, Ww, Ww, Ww
Gg, Gg, Rr, Rr, Gg, Aa, Aa, Aa, Gg, Ww, Ww, Ww, Ww, Ww, Hh, Gg, Aa, Gg, Hh, Ww, Ww, Ww
Rr, Rr, Gg, Gg, Gg, Gg, Gg, Gg, Hh, Ww, Ww, Ww, Ww, Ww, Hh, Gg, Aa, Gg, Mm, Mm, Ww, Mm
Gs^Fp, Gg, Gg, Gg, Gg, Gg, Gg, Hh, Mm, Ww, Ww, Ww, Ww, Ww, Ww, Ww, Aa, Gg, Hh, Ww, Ww, Mm
Gs^Fp, Gs^Fp, Gg, Gg, Gg, Gg, Gg, Hh, Mm, Ww, Ww, Ww, Ww, Ww, Ww, Ai, Aa, Gg, Gg, Hh, Hh, Hh
Gs^Fp, Gs^Fp, Gg, Gg, Gg, Gg, Aa, Ha, Mm, Ww, Ww, Ww, Ww, Ww, Gg, Ai, Ai, Gg, Gg, Gg, Gg, Gg
Gs^Fp, Gs^Fp, Gg^Ve, Gs^Fp, Gg, Gg, Aa, Aa, Hh, Mm, Ww, Ww, Ww, Ww, Gg, Ww, Ai, Ai, Gg, Gg, Gg, Gg
Ds, Gs^Fp, Gs^Fp, Gg, Gg, Gg, Aa, Aa, Aa, Ww, Ww, Gg^Vh, Gg, Gg, Gg, Gg, Aa, Ai, Gg^Vh, Gg, Gg, Gg
Ww, Ds, Ds, Ds, Ds, Gg, Aa, Gg, Gg, Gg, Gg, Gs^Fp, Gs^Fp, Gg, Gg, Ds, Aa^Vha, Ww, Ds, Ds, Ds, Ds
Wo, Wo, Wo, Wo, Ww, Ww, Ds, Ds, Gg, Gs^Fp, Gs^Fp, Ss, Gs^Fp, Gs^Fp, Ds, Ww, Ww, Wo, Wo, Ww, Ww, Ww
The rest of my code follows in a second and third post as it's too long for one lol
Last edited by white on February 21st, 2017, 2:31 am, edited 2 times in total.
Re: Need help creating a mp scenario that saves correctly
my ScenarioTest.cfg inside UsefullShips_by_white/scenario (Part 1/2)
Code: Select all
#textdomain wesnoth-multiplayer
[multiplayer]
id=multiplayer_ScenarioTest
name= _ "Scenario Test"
description= _ "This is just a test to figure out how to get a scenario working."
map_data="{~add-ons/UsefullShips_by_white/maps/ScenarioTest.map}"
snapshot=no
turns=99
victory_when_enemies_defeated=yes
random_start_time="no"
{DEFAULT_SCHEDULE}
{DEFAULT_MUSIC_PLAYLIST}
[side]
controller="human"
fog=no
gold=100
hidden=no
income=2
no_leader=no
share_maps=yes
share_view=no
shroud=no
side=1
team_name="testname1"
user_team_name="custom name 1"
type=Elvish Avenger
id=Elvish Avenger
name= _ "Special King"
canrecruit=yes
recruit=
extra_recruit=Elvish Lady,Elvish Shaman
[/side]
[side]
controller="human"
fog=no
gold=100
hidden=no
income=2
no_leader=no
share_maps=yes
share_view=no
shroud=no
side=2
team_name="testname2"
user_team_name="custom name 2"
type=Elvish Avenger
id=Elvish Avenger 2
name= _ "Special King"
canrecruit=yes
recruit=
extra_recruit=Elvish Lady,Elvish Shaman
[/side]
[event]
# entering a ship ##############################################################
[set_menu_item]
id=einsteigen
description= _ "Enter ship"
use_hotkeys=yes
[default_hotkey]
key=j
alt=no
shift=no
ctrl=no
[/default_hotkey]
[show_if]
[have_unit]
x,y=$x1,$y1
[and]
[not]
type=Boat,Galleon,Pirate Galleon,Transport Galleon
[/not]
[/and]
[and]
[filter_adjacent]
type=Boat,Galleon,Pirate Galleon,Transport Galleon
is_enemy=no
[filter_wml]
[variables]
passengerCount=0
[/variables]
[/filter_wml]
[or]
[filter_wml]
[variables]
passengerCount=1
[/variables]
[/filter_wml]
[/or]
[or]
[filter_wml]
[variables]
passengerCount=2
[/variables]
[/filter_wml]
[/or]
[/filter_adjacent]
[or]
[filter_adjacent]
type=Galleon
is_enemy=no
[filter_wml]
[variables]
passengerCount=3
[/variables]
[/filter_wml]
[or]
[filter_wml]
[variables]
passengerCount=4
[/variables]
[/filter_wml]
[/or]
[/filter_adjacent]
[/or]
[/and]
[/have_unit]
[/show_if]
[command]
[store_unit]
[filter]
id=$unit.id
[/filter]
variable=enteringUnit
[/store_unit]
[if]
[variable]
name=enteringUnit.moves
less_than=2
[/variable]
[and]
[not]
[have_location]
x,y=$x1,$y1
terrain=*^Bw*
[/have_location]
[/not]
[/and]
[or]
[variable]
name=enteringUnit.moves
less_than=1
[/variable]
[and]
[have_location]
x,y=$x1,$y1
terrain=*^Bw*
[/have_location]
[/and]
[/or]
[then]
[message]
speaker=narrator
message= _ "Sorry, this unit has not enough BP left to enter the ship!"
side_for=$side_number
[/message]
[/then]
[/if]
[if]
[variable]
name=enteringUnit.moves
greater_than=1
[/variable]
[or]
[variable]
name=enteringUnit.moves
greater_than=0
[/variable]
[and]
[have_location]
x,y=$x1,$y1
terrain=*^Bw*
[/have_location]
[/and]
[/or]
[then]
[store_unit]
[filter]
type=Boat,Galleon,Pirate Galleon,Transport Galleon
side=$side_number
[/filter]
variable=ships
[/store_unit]
[set_variable]
name=i
value=0
[/set_variable]
[while]
[variable]
name=i
less_than=$ships.length
[/variable]
[do]
[if]
[have_unit]
type=Boat,Galleon,Pirate Galleon,Transport Galleon
side=$side_number
x,y=$ships[$i].x,$ships[$i].y
[filter_wml]
[variables]
passengerCount=0
[/variables]
[/filter_wml]
[filter_adjacent]
id=$enteringUnit.id
[/filter_adjacent]
[/have_unit]
[or]
[have_unit]
type=Boat,Galleon,Pirate Galleon,Transport Galleon
side=$side_number
x,y=$ships[$i].x,$ships[$i].y
[filter_wml]
[variables]
passengerCount=1
[/variables]
[/filter_wml]
[filter_adjacent]
id=$enteringUnit.id
[/filter_adjacent]
[/have_unit]
[/or]
[or]
[have_unit]
type=Boat,Galleon,Pirate Galleon,Transport Galleon
side=$side_number
x,y=$ships[$i].x,$ships[$i].y
[filter_wml]
[variables]
passengerCount=2
[/variables]
[/filter_wml]
[filter_adjacent]
id=$enteringUnit.id
[/filter_adjacent]
[/have_unit]
[/or]
[or]
[have_unit]
type=Galleon
side=$side_number
x,y=$ships[$i].x,$ships[$i].y
[filter_wml]
[variables]
passengerCount=3
[/variables]
[/filter_wml]
[filter_adjacent]
id=$enteringUnit.id
[/filter_adjacent]
[/have_unit]
[/or]
[or]
[have_unit]
type=Galleon
side=$side_number
x,y=$ships[$i].x,$ships[$i].y
[filter_wml]
[variables]
passengerCount=4
[/variables]
[/filter_wml]
[filter_adjacent]
id=$enteringUnit.id
[/filter_adjacent]
[/have_unit]
[/or]
[then]
[set_variable]
name=newCount
value=$ships[$i].variables.passengerCount
[/set_variable]
[set_variable]
name=newCount
add=1
[/set_variable]
[set_variable]
name=oldCount
value=$ships[$i].variables.passengerCount
[/set_variable]
[set_variable]
name=ships[$i].variables.passengerCount
value=$newCount
[/set_variable]
[if]
[have_location]
x,y=$x1,$y1
terrain=*^Bw*
[/have_location]
[then]
[set_variable]
name=enteringUnit.moves
sub=1
[/set_variable]
[/then]
[/if]
[if]
[not]
[have_location]
x,y=$x1,$y1
terrain=*^Bw*
[/have_location]
[/not]
[then]
[set_variable]
name=enteringUnit.moves
sub=2
[/set_variable]
[/then]
[/if]
[unstore_unit]
variable=enteringUnit
[/unstore_unit]
[store_unit]
[filter]
id=$unit.id
[/filter]
variable=enteringUnit
[/store_unit]
[if]
[variable]
name=enteringUnit.canrecruit
equals=yes
[/variable]
[and]
[variable]
name=ships[$i].canrecruit
not_equals=yes
[/variable]
[/and]
[then]
[set_variable]
name=ships[$i].canrecruit
value=yes
[/set_variable]
[set_variable]
name=ships[$i].variables.kingShip
value=yes
[/set_variable]
[/then]
[/if]
[store_unit]
[filter]
id=$enteringUnit.id
[/filter]
variable=ships[$i].variables.passenger[$oldCount]
kill=yes
[/store_unit]
[if]
[variable]
name=ships[$i].type
equals=Boat
[/variable]
[then]
[set_variable]
name=ships[$i].moves
sub=3
[/set_variable]
[if]
[variable]
name=ships[$i].moves
less_than=0
[/variable]
[then]
[set_variable]
name=ships[$i].moves
value=0
[/set_variable]
[/then]
[/if]
[/then]
[/if]
[if]
[variable]
name=ships[$i].type
not_equals=Boat
[/variable]
[then]
[set_variable]
name=ships[$i].moves
value=0
[/set_variable]
[/then]
[/if]
[clear_variable]
name=oldCount
[/clear_variable]
[clear_variable]
name=newCount
[/clear_variable]
[set_variable]
name=i
value=50999
[/set_variable]
[/then]
[/if]
[set_variable]
name=i
add=1
[/set_variable]
[/do]
[/while]
[set_variable]
name=i
value=0
[/set_variable]
[while]
[variable]
name=i
less_than=$ships.length
[/variable]
[do]
[unstore_unit]
variable=ships[$i]
[/unstore_unit]
[set_variable]
name=i
add=1
[/set_variable]
[/do]
[/while]
[clear_variable]
name=ships
[/clear_variable]
[clear_variable]
name=i
[/clear_variable]
[/then]
[/if]
[clear_variable]
name=enteringUnit
[/clear_variable]
[/command]
[/set_menu_item]
# disembarking from ship ##############################################################
[set_menu_item]
id=aussteigen
description= _ "Disembark from ship"
use_hotkeys=yes
[default_hotkey]
key=i
alt=no
shift=no
ctrl=no
[/default_hotkey]
[show_if]
[have_unit]
x,y=$x1,$y1
type=Boat,Galleon,Pirate Galleon,Transport Galleon
[and]
[filter_wml]
[variables]
passengerCount=1
[/variables]
[/filter_wml]
[/and]
[and]
[filter_location]
terrain=*
[and]
[filter_adjacent_location]
[not]
terrain=W*
[/not]
[/filter_adjacent_location]
[/and]
[and]
[filter_adjacent_location]
[not]
terrain=*
[filter]
side=1,2,3,4,5,6,7,8,9
[/filter]
[/not]
[/filter_adjacent_location]
[/and]
[/filter_location]
[/and]
[/have_unit]
[or]
[have_unit]
x,y=$x1,$y1
type=Boat,Galleon,Pirate Galleon,Transport Galleon
[and]
[filter_wml]
[variables]
passengerCount=2
[/variables]
[/filter_wml]
[/and]
[and]
[filter_location]
terrain=*
[and]
[filter_adjacent_location]
[not]
terrain=W*
[/not]
[/filter_adjacent_location]
[/and]
[and]
[filter_adjacent_location]
[not]
terrain=*
[filter]
side=1,2,3,4,5,6,7,8,9
[/filter]
[/not]
[/filter_adjacent_location]
[/and]
[/filter_location]
[/and]
[/have_unit]
[/or]
[or]
[have_unit]
x,y=$x1,$y1
type=Boat,Galleon,Pirate Galleon,Transport Galleon
[and]
[filter_wml]
[variables]
passengerCount=3
[/variables]
[/filter_wml]
[/and]
[and]
[filter_location]
terrain=*
[and]
[filter_adjacent_location]
[not]
terrain=W*
[/not]
[/filter_adjacent_location]
[/and]
[and]
[filter_adjacent_location]
[not]
terrain=*
[filter]
side=1,2,3,4,5,6,7,8,9
[/filter]
[/not]
[/filter_adjacent_location]
[/and]
[/filter_location]
[/and]
[/have_unit]
[/or]
[or]
[have_unit]
x,y=$x1,$y1
type=Galleon
[and]
[filter_wml]
[variables]
passengerCount=4
[/variables]
[/filter_wml]
[/and]
[and]
[filter_location]
terrain=*
[and]
[filter_adjacent_location]
[not]
terrain=W*
[/not]
[/filter_adjacent_location]
[/and]
[and]
[filter_adjacent_location]
[not]
terrain=*
[filter]
side=1,2,3,4,5,6,7,8,9
[/filter]
[/not]
[/filter_adjacent_location]
[/and]
[/filter_location]
[/and]
[/have_unit]
[/or]
[or]
[have_unit]
x,y=$x1,$y1
type=Galleon
[and]
[filter_wml]
[variables]
passengerCount=5
[/variables]
[/filter_wml]
[/and]
[and]
[filter_location]
terrain=*
[and]
[filter_adjacent_location]
[not]
terrain=W*
[/not]
[/filter_adjacent_location]
[/and]
[and]
[filter_adjacent_location]
[not]
terrain=*
[filter]
side=1,2,3,4,5,6,7,8,9
[/filter]
[/not]
[/filter_adjacent_location]
[/and]
[/filter_location]
[/and]
[/have_unit]
[/or]
[/show_if]
[command]
[store_unit]
[filter]
x,y=$x1,$y1
[/filter]
variable=thisShip
[/store_unit]
[message]
speaker=narrator
message= _ "Which unit wants to disembark?"
[option]
message= _ "None."
[/option]
[option]
message= _ "$thisShip[0].variables.passenger[0].name ($thisShip[0].variables.passenger[0].type, $thisShip[0].variables.passenger[0].hitpoints/$thisShip[0].variables.passenger[0].max_hitpoints|LP, $thisShip[0].variables.passenger[0].experience/$thisShip[0].variables.passenger[0].max_experience|EP, King: $thisShip[0].variables.passenger[0].canrecruit)"
[show_if]
[variable]
name=thisShip[0].variables.passengerCount
greater_than=0
[/variable]
[/show_if]
[command]
[if]
[variable]
name=thisShip[0].type
equals=Boat
[/variable]
[or]
[variable]
name=thisShip[0].type
equals=Galleon
[/variable]
[/or]
[and]
[variable]
name=thisShip[0].variables.passenger[0].moves
equals=$thisShip[0].variables.passenger[0].max_moves
[/variable]
[and]
[variable]
name=thisShip[0].variables.passenger[0].variables.refreshedMovement
equals=yes
[/variable]
[/and]
[/and]
[then]
[set_variable]
name=thisShip[0].variables.passenger[0].moves
value=0
[/set_variable]
[/then]
[/if]
[if]
[variable]
name=thisShip[0].type
equals=Pirate Galleon
[/variable]
[or]
[variable]
name=thisShip[0].type
equals=Transport Galleon
[/variable]
[/or]
[then]
[set_variable]
name=thisShip[0].variables.passenger[0].moves
sub=2
[/set_variable]
[/then]
[/if]
[unstore_unit]
variable=thisShip[0]
[/unstore_unit]
[store_unit]
[filter]
x,y=$x1,$y1
[/filter]
variable=thisShip
[/store_unit]
[if]
[variable]
name=thisShip[0].variables.passenger[0].moves
greater_than=-1
[/variable]
[and]
[variable]
name=thisShip[0].variables.passenger[0].variables.refreshedMovement
equals=yes
[/variable]
[/and]
[then]
[unstore_unit]
variable=thisShip[0].variables.passenger[0]
find_vacant=yes
check_passability=yes
text= _ "Disembarked"
red,green,blue=0,250,100
animate=yes
x,y=$thisShip[0].x,$thisShip[0].y
[/unstore_unit]
[if]
[variable]
name=thisShip[0].variables.passenger[0].canrecruit
equals=yes
[/variable]
[and]
[variable]
name=thisShip[0].variables.kingShip
equals=yes
[/variable]
[/and]
[then]
[set_variable]
name=thisShip[0].canrecruit
value=no
[/set_variable]
[clear_variable]
name=thisShip[0].variables.kingShip
[/clear_variable]
[/then]
[/if]
[clear_variable]
name=thisShip[0].variables.passenger[0]
[/clear_variable]
[set_variable]
name=thisShip[0].variables.passengerCount
sub=1
[/set_variable]
[set_variable]
name=disembarging
value=yes
[/set_variable]
[/then]
[/if]
[if]
[variable]
name=disembarging
not_equals=yes
[/variable]
[and]
[variable]
name=thisShip[0].variables.passenger[0].moves
less_than=0
[/variable]
[or]
[variable]
name=thisShip[0].variables.passenger[0].moves
equals=0
[/variable]
[or]
[variable]
name=thisShip[0].type
equals=Boat
[/variable]
[/or]
[or]
[variable]
name=thisShip[0].type
equals=Galleon
[/variable]
[/or]
[and]
[variable]
name=thisShip[0].variables.passenger[0].variables.refreshedMovement
not_equals=yes
[/variable]
[/and]
[/or]
[/and]
[then]
[message]
speaker=narrator
message= _ "This unit doesn't have enough BP to disembark this turn!"
side_for=$side_number
[/message]
[/then]
[/if]
[set_variable]
name=disembarging
value=no
[/set_variable]
[/command]
[/option]
[option]
message= _ "$thisShip[0].variables.passenger[1].name ($thisShip[0].variables.passenger[1].type, $thisShip[0].variables.passenger[1].hitpoints/$thisShip[0].variables.passenger[1].max_hitpoints|LP, $thisShip[0].variables.passenger[1].experience/$thisShip[0].variables.passenger[1].max_experience|EP, King: $thisShip[0].variables.passenger[1].canrecruit)"
[show_if]
[variable]
name=thisShip[0].variables.passengerCount
greater_than=1
[/variable]
[/show_if]
[command]
[if]
[variable]
name=thisShip[0].type
equals=Boat
[/variable]
[or]
[variable]
name=thisShip[0].type
equals=Galleon
[/variable]
[/or]
[and]
[variable]
name=thisShip[0].variables.passenger[1].moves
equals=$thisShip[0].variables.passenger[1].max_moves
[/variable]
[and]
[variable]
name=thisShip[0].variables.passenger[1].variables.refreshedMovement
equals=yes
[/variable]
[/and]
[/and]
[then]
[set_variable]
name=thisShip[0].variables.passenger[1].moves
value=0
[/set_variable]
[/then]
[/if]
[if]
[variable]
name=thisShip[0].type
equals=Pirate Galleon
[/variable]
[or]
[variable]
name=thisShip[0].type
equals=Transport Galleon
[/variable]
[/or]
[then]
[set_variable]
name=thisShip[0].variables.passenger[1].moves
sub=2
[/set_variable]
[/then]
[/if]
[unstore_unit]
variable=thisShip[0]
[/unstore_unit]
[store_unit]
[filter]
x,y=$x1,$y1
[/filter]
variable=thisShip
[/store_unit]
[if]
[variable]
name=thisShip[0].variables.passenger[1].moves
greater_than=-1
[/variable]
[and]
[variable]
name=thisShip[0].variables.passenger[1].variables.refreshedMovement
equals=yes
[/variable]
[/and]
[then]
[unstore_unit]
variable=thisShip[0].variables.passenger[1]
find_vacant=yes
check_passability=yes
text= _ "Disembarked"
red,green,blue=0,250,100
animate=yes
x,y=$thisShip[0].x,$thisShip[0].y
[/unstore_unit]
[if]
[variable]
name=thisShip[0].variables.passenger[1].canrecruit
equals=yes
[/variable]
[and]
[variable]
name=thisShip[0].variables.kingShip
equals=yes
[/variable]
[/and]
[then]
[set_variable]
name=thisShip[0].canrecruit
value=no
[/set_variable]
[clear_variable]
name=thisShip[0].variables.kingShip
[/clear_variable]
[/then]
[/if]
[clear_variable]
name=thisShip[0].variables.passenger[1]
[/clear_variable]
[set_variable]
name=thisShip[0].variables.passengerCount
sub=1
[/set_variable]
[set_variable]
name=disembarging
value=yes
[/set_variable]
[/then]
[/if]
[if]
[variable]
name=disembarging
not_equals=yes
[/variable]
[and]
[variable]
name=thisShip[0].variables.passenger[1].moves
less_than=0
[/variable]
[or]
[variable]
name=thisShip[0].variables.passenger[1].moves
equals=0
[/variable]
[or]
[variable]
name=thisShip[0].type
equals=Boat
[/variable]
[/or]
[or]
[variable]
name=thisShip[0].type
equals=Galleon
[/variable]
[/or]
[and]
[variable]
name=thisShip[0].variables.passenger[1].variables.refreshedMovement
not_equals=yes
[/variable]
[/and]
[/or]
[/and]
[then]
[message]
speaker=narrator
message= _ "This unit doesn't have enough BP to disembark this turn!"
side_for=$side_number
[/message]
[/then]
[/if]
[set_variable]
name=disembarging
value=no
[/set_variable]
[/command]
[/option]
[option]
message= _ "$thisShip[0].variables.passenger[2].name ($thisShip[0].variables.passenger[2].type, $thisShip[0].variables.passenger[2].hitpoints/$thisShip[0].variables.passenger[2].max_hitpoints|LP, $thisShip[0].variables.passenger[2].experience/$thisShip[0].variables.passenger[2].max_experience|EP, King: $thisShip[0].variables.passenger[2].canrecruit)"
[show_if]
[variable]
name=thisShip[0].variables.passengerCount
greater_than=2
[/variable]
[/show_if]
[command]
[if]
[variable]
name=thisShip[0].type
equals=Boat
[/variable]
[or]
[variable]
name=thisShip[0].type
equals=Galleon
[/variable]
[/or]
[and]
[variable]
name=thisShip[0].variables.passenger[2].moves
equals=$thisShip[0].variables.passenger[2].max_moves
[/variable]
[and]
[variable]
name=thisShip[0].variables.passenger[2].variables.refreshedMovement
equals=yes
[/variable]
[/and]
[/and]
[then]
[set_variable]
name=thisShip[0].variables.passenger[2].moves
value=0
[/set_variable]
[/then]
[/if]
[if]
[variable]
name=thisShip[0].type
equals=Pirate Galleon
[/variable]
[or]
[variable]
name=thisShip[0].type
equals=Transport Galleon
[/variable]
[/or]
[then]
[set_variable]
name=thisShip[0].variables.passenger[2].moves
sub=2
[/set_variable]
[/then]
[/if]
[unstore_unit]
variable=thisShip[0]
[/unstore_unit]
[store_unit]
[filter]
x,y=$x1,$y1
[/filter]
variable=thisShip
[/store_unit]
[if]
[variable]
name=thisShip[0].variables.passenger[2].moves
greater_than=-1
[/variable]
[and]
[variable]
name=thisShip[0].variables.passenger[2].variables.refreshedMovement
equals=yes
[/variable]
[/and]
[then]
[unstore_unit]
variable=thisShip[0].variables.passenger[2]
find_vacant=yes
check_passability=yes
text= _ "Disembarked"
red,green,blue=0,250,100
animate=yes
x,y=$thisShip[0].x,$thisShip[0].y
[/unstore_unit]
[if]
[variable]
name=thisShip[0].variables.passenger[2].canrecruit
equals=yes
[/variable]
[and]
[variable]
name=thisShip[0].variables.kingShip
equals=yes
[/variable]
[/and]
[then]
[set_variable]
name=thisShip[0].canrecruit
value=no
[/set_variable]
[clear_variable]
name=thisShip[0].variables.kingShip
[/clear_variable]
[/then]
[/if]
[clear_variable]
name=thisShip[0].variables.passenger[2]
[/clear_variable]
[set_variable]
name=thisShip[0].variables.passengerCount
sub=1
[/set_variable]
[set_variable]
name=disembarging
value=yes
[/set_variable]
[/then]
[/if]
[if]
[variable]
name=disembarging
not_equals=yes
[/variable]
[and]
[variable]
name=thisShip[0].variables.passenger[2].moves
less_than=0
[/variable]
[or]
[variable]
name=thisShip[0].variables.passenger[2].moves
equals=0
[/variable]
[or]
[variable]
name=thisShip[0].type
equals=Boat
[/variable]
[/or]
[or]
[variable]
name=thisShip[0].type
equals=Galleon
[/variable]
[/or]
[and]
[variable]
name=thisShip[0].variables.passenger[2].variables.refreshedMovement
not_equals=yes
[/variable]
[/and]
[/or]
[/and]
[then]
[message]
speaker=narrator
message= _ "This unit doesn't have enough BP to disembark this turn!"
side_for=$side_number
[/message]
[/then]
[/if]
[set_variable]
name=disembarging
value=no
[/set_variable]
[/command]
[/option]
[option]
message= _ "$thisShip[0].variables.passenger[3].name ($thisShip[0].variables.passenger[3].type, $thisShip[0].variables.passenger[3].hitpoints/$thisShip[0].variables.passenger[3].max_hitpoints|LP, $thisShip[0].variables.passenger[3].experience/$thisShip[0].variables.passenger[3].max_experience|EP, King: $thisShip[0].variables.passenger[3].canrecruit)"
[show_if]
[variable]
name=thisShip[0].variables.passengerCount
greater_than=3
[/variable]
[/show_if]
[command]
[if]
[variable]
name=thisShip[0].type
equals=Boat
[/variable]
[or]
[variable]
name=thisShip[0].type
equals=Galleon
[/variable]
[/or]
[and]
[variable]
name=thisShip[0].variables.passenger[3].moves
equals=$thisShip[0].variables.passenger[3].max_moves
[/variable]
[and]
[variable]
name=thisShip[0].variables.passenger[3].variables.refreshedMovement
equals=yes
[/variable]
[/and]
[/and]
[then]
[set_variable]
name=thisShip[0].variables.passenger[3].moves
value=0
[/set_variable]
[/then]
[/if]
[if]
[variable]
name=thisShip[0].type
equals=Pirate Galleon
[/variable]
[or]
[variable]
name=thisShip[0].type
equals=Transport Galleon
[/variable]
[/or]
[then]
[set_variable]
name=thisShip[0].variables.passenger[3].moves
sub=2
[/set_variable]
[/then]
[/if]
[unstore_unit]
variable=thisShip[0]
[/unstore_unit]
[store_unit]
[filter]
x,y=$x1,$y1
[/filter]
variable=thisShip
[/store_unit]
[if]
[variable]
name=thisShip[0].variables.passenger[3].moves
greater_than=-1
[/variable]
[and]
[variable]
name=thisShip[0].variables.passenger[3].variables.refreshedMovement
equals=yes
[/variable]
[/and]
[then]
[unstore_unit]
variable=thisShip[0].variables.passenger[3]
find_vacant=yes
check_passability=yes
text= _ "Disembarked"
red,green,blue=0,250,100
animate=yes
x,y=$thisShip[0].x,$thisShip[0].y
[/unstore_unit]
[if]
[variable]
name=thisShip[0].variables.passenger[3].canrecruit
equals=yes
[/variable]
[and]
[variable]
name=thisShip[0].variables.kingShip
equals=yes
[/variable]
[/and]
[then]
[set_variable]
name=thisShip[0].canrecruit
value=no
[/set_variable]
[clear_variable]
name=thisShip[0].variables.kingShip
[/clear_variable]
[/then]
[/if]
[clear_variable]
name=thisShip[0].variables.passenger[3]
[/clear_variable]
[set_variable]
name=thisShip[0].variables.passengerCount
sub=1
[/set_variable]
[set_variable]
name=disembarging
value=yes
[/set_variable]
[/then]
[/if]
[if]
[variable]
name=disembarging
not_equals=yes
[/variable]
[and]
[variable]
name=thisShip[0].variables.passenger[3].moves
less_than=0
[/variable]
[or]
[variable]
name=thisShip[0].variables.passenger[3].moves
equals=0
[/variable]
[or]
[variable]
name=thisShip[0].type
equals=Boat
[/variable]
[/or]
[or]
[variable]
name=thisShip[0].type
equals=Galleon
[/variable]
[/or]
[and]
[variable]
name=thisShip[0].variables.passenger[3].variables.refreshedMovement
not_equals=yes
[/variable]
[/and]
[/or]
[/and]
[then]
[message]
speaker=narrator
message= _ "This unit doesn't have enough BP to disembark this turn!"
side_for=$side_number
[/message]
[/then]
[/if]
[set_variable]
name=disembarging
value=no
[/set_variable]
[/command]
[/option]
[option]
message= _ "$thisShip[0].variables.passenger[4].name ($thisShip[0].variables.passenger[4].type, $thisShip[0].variables.passenger[4].hitpoints/$thisShip[0].variables.passenger[4].max_hitpoints|LP, $thisShip[0].variables.passenger[4].experience/$thisShip[0].variables.passenger[4].max_experience|EP, King: $thisShip[0].variables.passenger[4].canrecruit)"
[show_if]
[variable]
name=thisShip[0].variables.passengerCount
greater_than=4
[/variable]
[/show_if]
[command]
[if]
[variable]
name=thisShip[0].type
equals=Boat
[/variable]
[or]
[variable]
name=thisShip[0].type
equals=Galleon
[/variable]
[/or]
[and]
[variable]
name=thisShip[0].variables.passenger[4].moves
equals=$thisShip[0].variables.passenger[4].max_moves
[/variable]
[and]
[variable]
name=thisShip[0].variables.passenger[4].variables.refreshedMovement
equals=yes
[/variable]
[/and]
[/and]
[then]
[set_variable]
name=thisShip[0].variables.passenger[4].moves
value=0
[/set_variable]
[/then]
[/if]
[if]
[variable]
name=thisShip[0].type
equals=Pirate Galleon
[/variable]
[or]
[variable]
name=thisShip[0].type
equals=Transport Galleon
[/variable]
[/or]
[then]
[set_variable]
name=thisShip[0].variables.passenger[4].moves
sub=2
[/set_variable]
[/then]
[/if]
[unstore_unit]
variable=thisShip[0]
[/unstore_unit]
[store_unit]
[filter]
x,y=$x1,$y1
[/filter]
variable=thisShip
[/store_unit]
[if]
[variable]
name=thisShip[0].variables.passenger[4].moves
greater_than=-1
[/variable]
[and]
[variable]
name=thisShip[0].variables.passenger[4].variables.refreshedMovement
equals=yes
[/variable]
[/and]
[then]
[unstore_unit]
variable=thisShip[0].variables.passenger[4]
find_vacant=yes
check_passability=yes
text= _ "Disembarked"
red,green,blue=0,250,100
animate=yes
x,y=$thisShip[0].x,$thisShip[0].y
[/unstore_unit]
[if]
[variable]
name=thisShip[0].variables.passenger[4].canrecruit
equals=yes
[/variable]
[and]
[variable]
name=thisShip[0].variables.kingShip
equals=yes
[/variable]
[/and]
[then]
[set_variable]
name=thisShip[0].canrecruit
value=no
[/set_variable]
[clear_variable]
name=thisShip[0].variables.kingShip
[/clear_variable]
[/then]
[/if]
[clear_variable]
name=thisShip[0].variables.passenger[4]
[/clear_variable]
[set_variable]
name=thisShip[0].variables.passengerCount
sub=1
[/set_variable]
[set_variable]
name=disembarging
value=yes
[/set_variable]
[/then]
[/if]
[if]
[variable]
name=disembarging
not_equals=yes
[/variable]
[and]
[variable]
name=thisShip[0].variables.passenger[4].moves
less_than=0
[/variable]
[or]
[variable]
name=thisShip[0].variables.passenger[4].moves
equals=0
[/variable]
[or]
[variable]
name=thisShip[0].type
equals=Boat
[/variable]
[/or]
[or]
[variable]
name=thisShip[0].type
equals=Galleon
[/variable]
[/or]
[and]
[variable]
name=thisShip[0].variables.passenger[4].variables.refreshedMovement
not_equals=yes
[/variable]
[/and]
[/or]
[/and]
[then]
[message]
speaker=narrator
message= _ "This unit doesn't have enough BP to disembark this turn!"
side_for=$side_number
[/message]
[/then]
[/if]
[set_variable]
name=disembarging
value=no
[/set_variable]
[/command]
[/option]
[/message]
[unstore_unit]
variable=thisShip
[/unstore_unit]
[/command]
[/set_menu_item]
Last edited by white on February 21st, 2017, 2:32 am, edited 1 time in total.
Re: Need help creating a mp scenario that saves correctly
my ScenarioTest.cfg (Part 2/2)
Code: Select all
# ship-building ################################################################
[set_menu_item]
id=schiff
description= _ "Build ship"
use_hotkeys=yes
[default_hotkey]
key=l
alt=no
shift=no
ctrl=no
[/default_hotkey]
[show_if]
[have_unit]
x,y=$x1,$y1
side=$side_number
[and]
[not]
race=bats,drake,falcon,gryphon,mechanical,merman,monster,ogre,lizard,undead
[/not]
[and]
[not]
type=Dark Adept,Dark Sorcerer,Lich,Necromancer,Wolf,Great Wolf,Direwolf
[/not]
[/and]
[/and]
[and]
[not]
[filter_wml]
[variables]
buildingShip=yes
[/variables]
[/filter_wml]
[/not]
[/and]
[/have_unit]
[have_location]
x,y=$x1,$y1
terrain=*
[filter_adjacent_location]
terrain=W*
count=1-6
[not]
[filter]
side=1,2,3,4,5,6,7,8,9
[/filter]
[/not]
[/filter_adjacent_location]
[/have_location]
[/show_if]
[command]
[store_unit]
[filter]
x,y=$x1,$y1
side=$side_number
[/filter]
variable=workingUnit
[/store_unit]
[message]
speaker=narrator
message= _ "Do you want to build a ship?"
[option]
message= _ "No."
[/option]
[option]
message= _ "Yes, I want to build a boat."
[command]
[set_variable]
name=workingUnit.variables.buildingShip
value=yes
[/set_variable]
[set_variable]
name=workingUnit.variables.finishingTurn
value=$turn_number
[/set_variable]
[if]
[have_location]
x,y=$x1,$y1
terrain=*^Bw*
[/have_location]
[then]
[set_variable]
name=workingUnit.variables.finishingTurn
add=4
[/set_variable]
[/then]
[/if]
[if]
[not]
[have_location]
x,y=$x1,$y1
terrain=*^Bw*
[/have_location]
[/not]
[then]
[set_variable]
name=workingUnit.variables.finishingTurn
add=6
[/set_variable]
[/then]
[/if]
[set_variable]
name=workingUnit.variables.buildingShipType
value=Boat
[/set_variable]
[message]
id=$workingUnit.id
message= _ "The boat will be finished in turn $workingUnit.variables.finishingTurn|!"
side_for=$side_number
[/message]
[set_variable]
name=workingUnit.moves
value=0
[/set_variable]
[set_variable]
name=workingUnit.attacks_left
value=0
[/set_variable]
[/command]
[/option]
[option]
message= _ "Yes, I want to build a galleon."
[command]
[if]
[have_location]
x,y=$x1,$y1
terrain=*^Bw*
[/have_location]
[then]
[set_variable]
name=workingUnit.variables.buildingShip
value=yes
[/set_variable]
[set_variable]
name=workingUnit.variables.finishingTurn
value=$turn_number
[/set_variable]
[set_variable]
name=workingUnit.variables.finishingTurn
add=6
[/set_variable]
[set_variable]
name=workingUnit.variables.buildingShipType
value=Galleon
[/set_variable]
[message]
id=$workingUnit.id
message= _ "The galleon will be finished in turn $workingUnit.variables.finishingTurn|!"
side_for=$side_number
[/message]
[set_variable]
name=workingUnit.moves
value=0
[/set_variable]
[set_variable]
name=workingUnit.attacks_left
value=0
[/set_variable]
[/then]
[/if]
[if]
[not]
[have_location]
x,y=$x1,$y1
terrain=*^Bw*
[/have_location]
[/not]
[then]
[message]
id=$workingUnit.id
message= _ "Sorry, but galleons can only be built in a harbour."
side_for=$side_number
[/message]
[/then]
[/if]
[/command]
[/option]
[option]
message= _ "Yes, I want to build a transport galleon."
[command]
[if]
[have_location]
x,y=$x1,$y1
terrain=*^Bw*
[/have_location]
[then]
[set_variable]
name=workingUnit.variables.buildingShip
value=yes
[/set_variable]
[set_variable]
name=workingUnit.variables.finishingTurn
value=$turn_number
[/set_variable]
[set_variable]
name=workingUnit.variables.finishingTurn
add=7
[/set_variable]
[set_variable]
name=workingUnit.variables.buildingShipType
value=TransportGalleon
[/set_variable]
[message]
id=$workingUnit.id
message= _ "The transport galleon will be finished in turn $workingUnit.variables.finishingTurn|!"
side_for=$side_number
[/message]
[set_variable]
name=workingUnit.moves
value=0
[/set_variable]
[set_variable]
name=workingUnit.attacks_left
value=0
[/set_variable]
[/then]
[/if]
[if]
[not]
[have_location]
x,y=$x1,$y1
terrain=*^Bw*
[/have_location]
[/not]
[then]
[message]
id=$workingUnit.id
message= _ "Sorry, but transport galleons can only be built in a harbour."
side_for=$side_number
[/message]
[/then]
[/if]
[/command]
[/option]
[option]
message= _ "Yes, I want to build a pirate galleon."
[command]
[if]
[have_location]
x,y=$x1,$y1
terrain=*^Bw*
[/have_location]
[then]
[set_variable]
name=workingUnit.variables.buildingShip
value=yes
[/set_variable]
[set_variable]
name=workingUnit.variables.finishingTurn
value=$turn_number
[/set_variable]
[set_variable]
name=workingUnit.variables.finishingTurn
add=7
[/set_variable]
[set_variable]
name=workingUnit.variables.buildingShipType
value=PirateGalleon
[/set_variable]
[message]
id=$workingUnit.id
message= _ "The pirate galleon will be finished in turn $workingUnit.variables.finishingTurn|!"
side_for=$side_number
[/message]
[set_variable]
name=workingUnit.moves
value=0
[/set_variable]
[set_variable]
name=workingUnit.attacks_left
value=0
[/set_variable]
[/then]
[/if]
[if]
[not]
[have_location]
x,y=$x1,$y1
terrain=*^Bw*
[/have_location]
[/not]
[then]
[message]
id=$workingUnit.id
message= _ "Sorry, but pirate galleons can only be built in a harbour."
side_for=$side_number
[/message]
[/then]
[/if]
[/command]
[/option]
[/message]
[if]
[variable]
name=workingUnit.variables.buildingShip
equals=yes
[/variable]
[then]
# searching for best position to place fog clearer #############################
[set_variable]
name=testingX
value=$workingUnit.x
[/set_variable]
[set_variable]
name=testingY
value=$workingUnit.y
[/set_variable]
[set_variable]
name=testingPosition]
value=$workingUnit.x
[/set_variable]
[set_variable]
name=testingPosition
modulo=2
[/set_variable]
# searching bottom right ##########################################################
[if]
[variable]
name=testingPosition
equals=0
[/variable]
[then]
[set_variable]
name=testingY
add=1
[/set_variable]
[/then]
[/if]
[set_variable]
name=testingX
add=1
[/set_variable]
[if]
[have_location]
x,y=$testingX,$testingY
terrain=W*
[/have_location]
[and]
[not]
[have_location]
x,y=$testingX,$testingY
terrain=*^B*
[/have_location]
[/not]
[/and]
[and]
[not]
[have_unit]
x,y=$testingX,$testingY
[/have_unit]
[/not]
[/and]
[then]
[set_variable]
name=savedX
value=$testingX
[/set_variable]
[set_variable]
name=savedY
value=$testingY
[/set_variable]
[/then]
[/if]
# searching top right #######################################################
[set_variable]
name=testingY
sub=1
[/set_variable]
[if]
[have_location]
x,y=$testingX,$testingY
terrain=W*
[/have_location]
[and]
[not]
[have_location]
x,y=$testingX,$testingY
terrain=*^B*
[/have_location]
[/not]
[/and]
[and]
[not]
[have_unit]
x,y=$testingX,$testingY
[/have_unit]
[/not]
[/and]
[then]
[set_variable]
name=savedX
value=$testingX
[/set_variable]
[set_variable]
name=savedY
value=$testingY
[/set_variable]
[/then]
[/if]
# searching bottom #############################################################
[if]
[variable]
name=testingPosition
equals=1
[/variable]
[then]
[set_variable]
name=testingY
add=1
[/set_variable]
[/then]
[/if]
[set_variable]
name=testingY
add=1
[/set_variable]
[set_variable]
name=testingX
sub=1
[/set_variable]
[if]
[have_location]
x,y=$testingX,$testingY
terrain=W*
[/have_location]
[and]
[not]
[have_location]
x,y=$testingX,$testingY
terrain=*^B*
[/have_location]
[/not]
[/and]
[and]
[not]
[have_unit]
x,y=$testingX,$testingY
[/have_unit]
[/not]
[/and]
[then]
[set_variable]
name=savedX
value=$testingX
[/set_variable]
[set_variable]
name=savedY
value=$testingY
[/set_variable]
[/then]
[/if]
# searching top ########################################################
[set_variable]
name=testingY
sub=2
[/set_variable]
[if]
[have_location]
x,y=$testingX,$testingY
terrain=W*
[/have_location]
[and]
[not]
[have_location]
x,y=$testingX,$testingY
terrain=*^B*
[/have_location]
[/not]
[/and]
[and]
[not]
[have_unit]
x,y=$testingX,$testingY
[/have_unit]
[/not]
[/and]
[then]
[set_variable]
name=savedX
value=$testingX
[/set_variable]
[set_variable]
name=savedY
value=$testingY
[/set_variable]
[/then]
[/if]
# searching bottom left ###########################################################
[if]
[variable]
name=testingPosition
equals=0
[/variable]
[then]
[set_variable]
name=testingY
add=1
[/set_variable]
[/then]
[/if]
[set_variable]
name=testingY
add=1
[/set_variable]
[set_variable]
name=testingX
sub=1
[/set_variable]
[if]
[have_location]
x,y=$testingX,$testingY
terrain=W*
[/have_location]
[and]
[not]
[have_location]
x,y=$testingX,$testingY
terrain=*^B*
[/have_location]
[/not]
[/and]
[and]
[not]
[have_unit]
x,y=$testingX,$testingY
[/have_unit]
[/not]
[/and]
[then]
[set_variable]
name=savedX
value=$testingX
[/set_variable]
[set_variable]
name=savedY
value=$testingY
[/set_variable]
[/then]
[/if]
# searching top left ###########################################################
[set_variable]
name=testingY
sub=1
[/set_variable]
[if]
[have_location]
x,y=$testingX,$testingY
terrain=W*
[/have_location]
[and]
[not]
[have_location]
x,y=$testingX,$testingY
terrain=*^B*
[/have_location]
[/not]
[/and]
[and]
[not]
[have_unit]
x,y=$testingX,$testingY
[/have_unit]
[/not]
[/and]
[then]
[set_variable]
name=savedX
value=$testingX
[/set_variable]
[set_variable]
name=savedY
value=$testingY
[/set_variable]
[/then]
[/if]
# creating fog clearer at found spot ###########################################
[unit]
type=Fog Clearer
name=BUILDING SITE
side=$side_number
x,y=$savedX,$savedY
hitpoints=9999
max_hitpoints=9999
moves=0
attacks_left=0
animate=no
placement=map_passable
[variables]
ownerId=$workingUnit.id
[/variables]
[/unit]
[set_variable]
name=workingUnit.variables.savedX
value=$savedX
[/set_variable]
[set_variable]
name=workingUnit.variables.savedY
value=$savedY
[/set_variable]
[/then]
[/if]
[unstore_unit]
variable=workingUnit
[/unstore_unit]
[clear_variable]
name=workingUnit
[/clear_variable]
[/command]
[/set_menu_item]
# cancel ship building##########################################################
[set_menu_item]
id=cancelingBuild
description= _ "Cancel building ship"
use_hotkeys=yes
[default_hotkey]
key=k
alt=no
shift=no
ctrl=no
[/default_hotkey]
[show_if]
[have_unit]
x,y=$x1,$y1
[filter_wml]
[variables]
buildingShip=yes
[/variables]
[/filter_wml]
[/have_unit]
[/show_if]
[command]
[store_unit]
[filter]
x,y=$x1,$y1
[filter_wml]
[variables]
buildingShip=yes
[/variables]
[/filter_wml]
[/filter]
variable=cancelingUnit
[/store_unit]
[message]
x,y=$x1,$y1
message= _ "Canceled building a $cancelingUnit[0].variables.buildingShipType"
for_side=$side_number
[/message]
[set_variable]
name=cancelingUnit[0].variables.buildingShip
value=no
[/set_variable]
[clear_variable]
name=cancelingUnit[0].variables.savedX
[/clear_variable]
[clear_variable]
name=cancelingUnit[0].variables.savedY
[/clear_variable]
[kill]
side=$side_number
type=Fog Clearer
[filter_wml]
[variables]
ownerId=$cancelingUnit[0].id
[/variables]
[/filter_wml]
[/kill]
[if]
[variable]
name=cancelingUnit[0].variables.refreshedBuilding
equals=yes
[/variable]
[then]
[set_variable]
name=cancelingUnit[0].moves
value=$cancelingUnit[0].max_moves
[/set_variable]
[set_variable]
name=cancelingUnit[0].attacks_left
value=$cancelingUnit[0].max_attacks
[/set_variable]
[/then]
[/if]
[set_variable]
name=cancelingUnit[0].variables.refreshedBuilding
value=no
[/set_variable]
[clear_variable]
name=cancelingUnit[0].variables.savedX
[/clear_variable]
[clear_variable]
name=cancelingUnit[0].variables.savedY
[/clear_variable]
[clear_variable]
name=cancelingUnit[0].variables.buildingShipType
[/clear_variable]
[clear_variable]
name=cancelingUnit[0].variables.finishingTurn
[/clear_variable]
[unstore_unit]
variable=cancelingUnit[0]
[/unstore_unit]
[clear_variable]
name=cancelingUnit[0]
[/clear_variable]
[/command]
[/set_menu_item]
[/event]
[event]
name=turn refresh
first_time_only=no
# refreshing fog clearer disableing ############################################
[store_unit]
[filter]
type=Fog Clearer
side=$side_number
[/filter]
variable=placeholders
[/store_unit]
[set_variable]
name=i
value=0
[/set_variable]
[while]
[variable]
name=i
less_than=$placeholders.length
[/variable]
[do]
[set_variable]
name=placeholders[$i].moves
value=0
[/set_variable]
[set_variable]
name=placeholders[$i].attacks_left
value=0
[/set_variable]
[unstore_unit]
variable=placeholders[$i]
[/unstore_unit]
[set_variable]
name=i
add=1
[/set_variable]
[/do]
[/while]
[clear_variable]
name=placeholders
[/clear_variable]
# refreshing ship passenger movement points ################################################
[store_unit]
[filter]
type=Boat,Galleon,Pirate Galleon,Transport Galleon
side=$side_number
[/filter]
variable=ships
[/store_unit]
[set_variable]
name=i
value=0
[/set_variable]
[while]
[variable]
name=i
less_than=$ships.length
[/variable]
[do]
[set_variable]
name=j
value=0
[/set_variable]
[while]
[variable]
name=j
less_than=5
[/variable]
[do]
[set_variable]
name=ships[$i].variables.passenger[$j].moves
value=$ships[$i].variables.passenger[$j].max_moves
[/set_variable]
[set_variable]
name=ships[$i].variables.passenger[$j].variables.refreshedMovement
value=yes
[/set_variable]
[set_variable]
name=j
add=1
[/set_variable]
[/do]
[/while]
[unstore_unit]
variable=ships[$i]
[/unstore_unit]
[set_variable]
name=i
add=1
[/set_variable]
[/do]
[/while]
[clear_variable]
name=ships
[/clear_variable]
[clear_variable]
name=i
[/clear_variable]
[clear_variable]
name=j
[/clear_variable]
# building ships ###############################################################
[store_unit]
[filter]
side=$side_number
[filter_wml]
[variables]
buildingShip=yes
[/variables]
[/filter_wml]
[/filter]
variable=buildingShipUnits
[/store_unit]
[set_variable]
name=i
value=0
[/set_variable]
[while]
[variable]
name=i
less_than=$buildingShipUnits.length
[/variable]
[do]
[if]
[variable]
name=buildingShipUnits[$i].variables.buildingShipType
equals=Boat
[/variable]
[and]
[variable]
name=buildingShipUnits[$i].variables.finishingTurn
equals=$turn_number
[/variable]
[/and]
[then]
[kill]
side=$side_number
type=Fog Clearer
[filter_wml]
[variables]
ownerId=$buildingShipUnits[$i].id
[/variables]
[/filter_wml]
[/kill]
[unit]
type=Boat
side=$side_number
x,y=$buildingShipUnits[$i].variables.savedX,$buildingShipUnits[$i].variables.savedY
moves=0
attacks_left=0
animate=yes
placement=map_passable
[variables]
number=$shipNumber
passengerCount=0
[/variables]
[/unit]
[set_variable]
name=shipNumber
add=1
[/set_variable]
[set_variable]
name=buildingShipUnits[$i].variables.refreshedBuilding
value=no
[/set_variable]
[set_variable]
name=buildingShipUnits[$i].variables.buildingShip
value=no
[/set_variable]
[clear_variable]
name=buildingShipUnits[$i].variables.buildingShipType
[/clear_variable]
[/then]
[/if]
[if]
[variable]
name=buildingShipUnits[$i].variables.buildingShipType
equals=Galleon
[/variable]
[and]
[variable]
name=buildingShipUnits[$i].variables.finishingTurn
equals=$turn_number
[/variable]
[/and]
[then]
[kill]
side=$side_number
type=Fog Clearer
[filter_wml]
[variables]
ownerId=$buildingShipUnits[$i].id
[/variables]
[/filter_wml]
[/kill]
[unit]
type=Galleon
side=$side_number
x,y=$buildingShipUnits[$i].variables.savedX,$buildingShipUnits[$i].variables.savedY
moves=0
attacks_left=0
animate=yes
placement=map_passable
[variables]
number=$shipNumber
passengerCount=0
# passenger[0]=0
[/variables]
[/unit]
[set_variable]
name=shipNumber
add=1
[/set_variable]
[set_variable]
name=buildingShipUnits[$i].variables.refreshedBuilding
value=no
[/set_variable]
[set_variable]
name=buildingShipUnits[$i].variables.buildingShip
value=no
[/set_variable]
[clear_variable]
name=buildingShipUnits[$i].variables.buildingShipType
[/clear_variable]
[/then]
[/if]
[if]
[variable]
name=buildingShipUnits[$i].variables.buildingShipType
equals=PirateGalleon
[/variable]
[and]
[variable]
name=buildingShipUnits[$i].variables.finishingTurn
equals=$turn_number
[/variable]
[/and]
[then]
[kill]
side=$side_number
type=Fog Clearer
[filter_wml]
[variables]
ownerId=$buildingShipUnits[$i].id
[/variables]
[/filter_wml]
[/kill]
[unit]
type=Pirate Galleon
side=$side_number
x,y=$buildingShipUnits[$i].variables.savedX,$buildingShipUnits[$i].variables.savedY
moves=0
attacks_left=0
animate=yes
placement=map_passable
[variables]
number=$shipNumber
passengerCount=0
[/variables]
[/unit]
[set_variable]
name=shipNumber
add=1
[/set_variable]
[set_variable]
name=buildingShipUnits[$i].variables.refreshedBuilding
value=no
[/set_variable]
[set_variable]
name=buildingShipUnits[$i].variables.buildingShip
value=no
[/set_variable]
[clear_variable]
name=buildingShipUnits[$i].variables.buildingShipType
[/clear_variable]
[/then]
[/if]
[if]
[variable]
name=buildingShipUnits[$i].variables.buildingShipType
equals=TransportGalleon
[/variable]
[and]
[variable]
name=buildingShipUnits[$i].variables.finishingTurn
equals=$turn_number
[/variable]
[/and]
[then]
[kill]
side=$side_number
type=Fog Clearer
[filter_wml]
[variables]
ownerId=$buildingShipUnits[$i].id
[/variables]
[/filter_wml]
[/kill]
[unit]
type=Transport Galleon
side=$side_number
x,y=$buildingShipUnits[$i].variables.savedX,$buildingShipUnits[$i].variables.savedY
moves=0
attacks_left=0
animate=yes
placement=map_passable
[variables]
number=$shipNumber
passengerCount=0
[/variables]
[/unit]
[set_variable]
name=shipNumber
add=1
[/set_variable]
[set_variable]
name=buildingShipUnits[$i].variables.refreshedBuilding
value=no
[/set_variable]
[set_variable]
name=buildingShipUnits[$i].variables.buildingShip
value=no
[/set_variable]
[clear_variable]
name=buildingShipUnits[$i].variables.buildingShipType
[/clear_variable]
[/then]
[/if]
# updating units building ships ################################################
[if]
[not]
[variable]
name=buildingShipUnits[$i].variables.finishingTurn
equals=$turn_number
[/variable]
[/not]
[then]
[set_variable]
name=buildingShipUnits[$i].moves
value=0
[/set_variable]
[set_variable]
name=buildingShipUnits[$i].attacks_left
value=0
[/set_variable]
[set_variable]
name=buildingShipUnits[$i].variables.refreshedBuilding
value=yes
[/set_variable]
[unstore_unit]
variable=buildingShipUnits[$i]
[/unstore_unit]
[scroll_to_unit]
[filter]
id=$buildingShipUnits[$i].id
[/filter]
check_fogged=true
[/scroll_to_unit]
[floating_text]
x,y=$buildingShipUnits[$i].x,$buildingShipUnits[$i].y
text="<span color='#00fa64'>"+ _ "working on ship" + "</span>"
[/floating_text]
[/then]
[/if]
[if]
[variable]
name=buildingShipUnits[$i].variables.finishingTurn
equals=$turn_number
[/variable]
[then]
[clear_variable]
name=buildingShipUnits[$i].variables.finishingTurn
[/clear_variable]
[unstore_unit]
variable=buildingShipUnits[$i]
[/unstore_unit]
[/then]
[/if]
[set_variable]
name=i
add=1
[/set_variable]
[/do]
[/while]
[clear_variable]
name=buildingShipUnits
[/clear_variable]
[/event]
[event]
name=last breath
first_time_only=no
[if]
[variable]
name=unit.variables.buildingShip
equals=yes
[/variable]
[then]
[kill]
type=Fog Clearer
[filter_wml]
[variables]
ownerId=$unit.id
[/variables]
[/filter_wml]
[/kill]
[/then]
[/if]
[if]
[variable]
name=unit.type
equals=Boat
[/variable]
[or]
[variable]
name=unit.type
equals=Galleon
[/variable]
[/or]
[or]
[variable]
name=unit.type
equals=Transport Galleon
[/variable]
[/or]
[or]
[variable]
name=unit.type
equals=Pirate Galleon
[/variable]
[/or]
[then]
[store_unit]
[filter]
x,y=$unit.x,$unit.y
[/filter]
variable=thisShip
[/store_unit]
[set_variable]
name=i
value=0
[/set_variable]
[while]
[variable]
name=i
less_than=5
[/variable]
[do]
[set_variable]
name=thisShip[0].variables.passenger[$i].moves
value=0
[/set_variable]
[unstore_unit]
variable=thisShip[0]
[/unstore_unit]
[store_unit]
[filter]
x,y=$unit.x,$unit.y
[/filter]
variable=thisShip
[/store_unit]
[unstore_unit]
variable=thisShip[0].variables.passenger[$i]
find_vacant=yes
check_passability=yes
text= _ "jumped out"
red,green,blue=0,250,100
animate=yes
x,y=$thisShip[0].x,$thisShip[0].y
[/unstore_unit]
[set_variable]
name=i
add=1
[/set_variable]
[/do]
[/while]
[/then]
[/if]
[/event]
[event]
name=prerecruit
first_time_only=no
# assignment of a unique number for each ship #####
[if]
[have_unit]
x,y=$x1,$y1
type=Boat
[/have_unit]
[or]
[have_unit]
x,y=$x1,$y1
type=Galleon
[/have_unit]
[/or]
[or]
[have_unit]
x,y=$x1,$y1
type=Pirate Galleon
[/have_unit]
[/or]
[or]
[have_unit]
x,y=$x1,$y1
type=Transport Galleon
[/have_unit]
[/or]
[then]
[store_unit]
[filter]
id=$unit.id
[/filter]
variable=storedShip
kill=yes
[/store_unit]
[set_variable]
name=storedShip.variables.number
value=$shipNumber
[/set_variable]
[set_variable]
name=storedShip.variables.passenger[0]
value=0
[/set_variable]
[set_variable]
name=storedShip.variables.passengerCount
value=0
[/set_variable]
[unstore_unit]
variable=storedShip
[/unstore_unit]
[clear_variable]
name=storedShip
[/clear_variable]
[set_variable]
name=shipNumber
add=1
[/set_variable]
[/then]
[/if]
[/event]
[event]
name=turn 1 end
# starting variables ###########################################################
[set_variable]
name=shipNumber
value=1
[/set_variable]
# setting preexisting ship variables ###########################################
[store_unit]
[filter]
type=Boat,Galleon,Pirate Galleon,Transport Galleon
[/filter]
variable=ships
[/store_unit]
[set_variable]
name=i
value=0
[/set_variable]
[while]
[variable]
name=i
less_than=$ships.length
[/variable]
[do]
[if]
[have_unit]
id=$ships[$i].id
type=Boat
[/have_unit]
[or]
[have_unit]
id=$ships[$i].id
type=Galleon
[/have_unit]
[/or]
[or]
[have_unit]
id=$ships[$i].id
type=Pirate Galleon
[/have_unit]
[/or]
[or]
[have_unit]
id=$ships[$i].id
type=Transport Galleon
[/have_unit]
[/or]
[then]
[store_unit]
[filter]
id=$ships[$i].id
[/filter]
variable=storedShip
kill=yes
[/store_unit]
[set_variable]
name=storedShip.variables.number
value=$shipNumber
[/set_variable]
[set_variable]
name=storedShip.variables.passenger[0]
value=0
[/set_variable]
[set_variable]
name=storedShip.variables.passengerCount
value=0
[/set_variable]
[unstore_unit]
variable=storedShip
[/unstore_unit]
[clear_variable]
name=storedShip
[/clear_variable]
[set_variable]
name=shipNumber
add=1
[/set_variable]
[/then]
[/if]
[set_variable]
name=i
add=1
[/set_variable]
[/do]
[/while]
[set_variable]
name=i
value=0
[/set_variable]
[while]
[variable]
name=i
less_than=$ships.length
[/variable]
[do]
[clear_variable]
name=ships[$i]
[/clear_variable]
[set_variable]
name=i
add=1
[/set_variable]
[/do]
[/while]
[clear_variable]
name=i
[/clear_variable]
[/event]
[/multiplayer]
Last edited by white on February 21st, 2017, 2:32 am, edited 1 time in total.
Re: Need help creating a mp scenario that saves correctly
Maybe WML Workshop would be a better place for this, but I've once created invalid saved games in my addons by using apostrophe '´ in variables.
When using store and unstore you have to check the "variables" in which you save your units. They shouldn't contain spaces or apostrophes or other signs and shouldn't begin with a number (just to be sure). Make clean id's and don't overwrite them.
Edit: I'm not quite sure if that is a correct variable:
"variable=thisShip[0]"
Edit2: it's not uncomplicated what you are trying to do, so the best method to find the bug, is to separate your code in small pieces of functions and test them once my one, how it behaves when you save the game. Unfortunately I'm no expert in mp campaigns, but the best guess so far is that you produce in invalid variable.
When using store and unstore you have to check the "variables" in which you save your units. They shouldn't contain spaces or apostrophes or other signs and shouldn't begin with a number (just to be sure). Make clean id's and don't overwrite them.
Edit: I'm not quite sure if that is a correct variable:
"variable=thisShip[0]"
Edit2: it's not uncomplicated what you are trying to do, so the best method to find the bug, is to separate your code in small pieces of functions and test them once my one, how it behaves when you save the game. Unfortunately I'm no expert in mp campaigns, but the best guess so far is that you produce in invalid variable.
Last edited by Heindal on February 20th, 2017, 6:42 pm, edited 1 time in total.
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
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Re: Need help creating a mp scenario that saves correctly
I didn't use any apostrophes in the whole code as far as I remember...
What do you mean with "checking" the variables?
Also I'm using clean id's as I'm not specifying any unit-ids in my code. I just store them and unstore them later or I use [unit] but not specifying any id there, so I am at least under the impression that the game is generating a new one as for any unit that is recruited or such.
Edit 1: "variable=thisShip[0]" should be ok as far as I know as thisShip stores the whole unit and the inspector is showing the variable as thisShip[0] even when just using thisShip. I guess it's an array with just one container, so the [0] is obsolete, but not wrong.
Edit 2: hm. An invalid variable sounds like that may be the case... at least it sounds like a good guess. I'll try to figure out if I got one. Still if someone has a better clue I'm happy for more help
What do you mean with "checking" the variables?
Also I'm using clean id's as I'm not specifying any unit-ids in my code. I just store them and unstore them later or I use [unit] but not specifying any id there, so I am at least under the impression that the game is generating a new one as for any unit that is recruited or such.
Edit 1: "variable=thisShip[0]" should be ok as far as I know as thisShip stores the whole unit and the inspector is showing the variable as thisShip[0] even when just using thisShip. I guess it's an array with just one container, so the [0] is obsolete, but not wrong.
Edit 2: hm. An invalid variable sounds like that may be the case... at least it sounds like a good guess. I'll try to figure out if I got one. Still if someone has a better clue I'm happy for more help
Re: Need help creating a mp scenario that saves correctly
I'm not quite sure about that, white. I don't think WML is producing id's for you (but that is inside knowledge, so I'm not sure).
Based on my experience coders combine a number and a name to create unique unit id's.
The reason - using the same id for a unit, can cause the units to disappear when saving and loading the game.
After all the id is unique identifier, when there are two units with the same id, one of them will disappear.
I even have the problem in my campaigns, that players convince monsters/enemies on their sides.
As these enemies use auto-created ids it can happen that unit's replace others with the same id in the recall list.
Based on my experience coders combine a number and a name to create unique unit id's.
The reason - using the same id for a unit, can cause the units to disappear when saving and loading the game.
After all the id is unique identifier, when there are two units with the same id, one of them will disappear.
I even have the problem in my campaigns, that players convince monsters/enemies on their sides.
As these enemies use auto-created ids it can happen that unit's replace others with the same id in the recall list.
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
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Re: Need help creating a mp scenario that saves correctly
Hm. So you suppose those units I create have no id at all? o.O well that's kinda weird. I'll look into that as well I guess
Edit: ok, so starting the scenario and creating a unit at least the inspector tells me, that that unit has an id. And as far as I can see it's the unit's type with a number behind it, which counted up for any unit on the field. So the two kings present at gamestart had id "Elvish Avenger" and "Elvish Avenger-2". Any unit I recruited after that had the id "Elvish Shaman-3" (4,5,6...) and when I created a fog clearer with [unit] via my event it got "Fog Clearer-7". Recruiting after that counted from 8 upwards again... so it should be unique, shouldn't it?
Edit: ok, so starting the scenario and creating a unit at least the inspector tells me, that that unit has an id. And as far as I can see it's the unit's type with a number behind it, which counted up for any unit on the field. So the two kings present at gamestart had id "Elvish Avenger" and "Elvish Avenger-2". Any unit I recruited after that had the id "Elvish Shaman-3" (4,5,6...) and when I created a fog clearer with [unit] via my event it got "Fog Clearer-7". Recruiting after that counted from 8 upwards again... so it should be unique, shouldn't it?
Last edited by white on February 20th, 2017, 6:59 pm, edited 1 time in total.
Re: Need help creating a mp scenario that saves correctly
Technically, you are specifying unit ids in your code, those you set in [side].
One of your events has no name.
Why you use
Please do not put
One of your events has no name.
Why you use
snapshot=no
?Please do not put
Code: Select all
in [spoiler]
[color=#008000]Moved to WML Workshop.[/color]
Default unit ids are generated by combining unit type and autoincremented integers.
Re: Need help creating a mp scenario that saves correctly
hm, ok forgot about the sides. Well those are the kings and as explained in my last edit above it seems to work.
no event name? o.O ok, I'll check if I just missed to copy it or what's wrong there lol (#nooby)
no event name? o.O ok, I'll check if I just missed to copy it or what's wrong there lol (#nooby)
I don't know... I just saw it in one of the scenarios I looked at and thought I might as well try it. What is it doing?Why you use snapshot=no?
Please do not putCode: Select all
in [spoiler][/quote] Oh sorry. I just thought not putting it into a spoiler would make it really annoying to look at any answers later on... [quote]Moved to WML Workshop.[/quote] Thanks :)
Re: Need help creating a mp scenario that saves correctly
white wrote:I don't know... I just saw it in one of the scenarios I looked at and thought I might as well try it. What is it doing?Why you use snapshot=no?
Please do not putCode: Select all
in [spoiler][/quote] Oh sorry. I just thought not putting it into a spoiler would make it really annoying to look at any answers later on...[/quote] Using [spoiler] means that [code] wont have expand button. In best case snapshot=no is silently ignored as invalid.
Re: Need help creating a mp scenario that saves correctly
Like Heindal said, the most common reason for that are invalid chracters in varaible names. This can for exampel be casued by codes like
since the units id might contains a character that is unsuited for variables keys.
To find the actual error you could for example do the following: take your savefile, extract it and open it with a text editor, then copy all that wml from your savefile to the _main.cfg file of your addon. Then when you try to start wesnoth next time it might tell you about where the erro is just liek for normla wml wntax errors. Ofcours e you have to remove that copied wml aftger it gave you the erro message
Code: Select all
[set_variable]
name="$unit.id"
value = $unit.moves"
[/set_variable]
To find the actual error you could for example do the following: take your savefile, extract it and open it with a text editor, then copy all that wml from your savefile to the _main.cfg file of your addon. Then when you try to start wesnoth next time it might tell you about where the erro is just liek for normla wml wntax errors. Ofcours e you have to remove that copied wml aftger it gave you the erro message
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
Re: Need help creating a mp scenario that saves correctly
Ugg. Invalid saves are the worst bugs ever. Once i got them because i had a hyphen (-) in a unit type name. Doesn't look like that's the problem here, but i thought i'd mention it just in case.
The last few months have been nothing but one big, painful reminder that TIMTLTW.
Creator of Armory Mod, The Rising Underworld, and Voyage of a Drake: an RPG
Creator of Armory Mod, The Rising Underworld, and Voyage of a Drake: an RPG
Re: Need help creating a mp scenario that saves correctly
ok, so by now I narrowed the problem down a bit: when I save at the beginning of turn 2 the save file can still be loaded, so the [event] name=turn 2 executes correctly and causes no problems in the safe file. When moving one unit (an elvish shaman) next to a water hex, selecting "build ship" in the right click menu and saving afterwards the safe file can't be loaded any more. Also tested, that saving the units id inside a variable isn't causing the error (or at least not alone) as it's still not working when I comment it out.
Also here's the data of the elvish shaman from the broken safe file:
and here's the saved fog clearer created by my code when selecting "build ship":
and here is the [variables] tag inside the saved [snapshot]:
just noticing this weird testingPosition] o.O
EDIT: Ok, searching for "testingPosition]" in my code gave me one result. Removing the ] and testing again resulted in a working save file when doing exactly the same stuff. Hopefully that's all I did wrong. Thanks for all your help
Also here's the data of the elvish shaman from the broken safe file:
Code: Select all
[unit]
advances_to="Elvish Druid,Elvish Sorceress"
alignment="neutral"
alpha=256
attacks_left=0
cost=15
description=_"Being partly faerie in nature, elves have an inherent capability for magic. This is realized in their affinity with the natural world, which they can call upon as an ally in combat. Enemies wandering in their forests may soon find themselves entangled by roots and hindered by the very ground they stand on.
The healing abilities of the elves are also remarkable, and of capital use in battle." +
#textdomain wesnoth-help
_"
Special Notes:" +
_" This unit is able to slow its enemies, halving their movement speed and attack damage until they end a turn." +
_" This unit is capable of basic healing."
experience=0
extra_recruit=""
facing="se"
flag_rgb="magenta"
gender="female"
generate_name=no
goto_x=-999
goto_y=-999
hitpoints=31
id="Elvish Shaman-3"
image="units/elves-wood/shaman.png"
jamming=0
#textdomain wesnoth-units
language_name=_"female^Elvish Shaman"
level=1
max_attacks=1
max_experience=18
max_hitpoints=31
max_moves=5
moves=0
name="Hódiel"
overlays=""
profile="portraits/elves/transparent/shaman.png~RIGHT()"
race="elf"
random_traits=no
resting=yes
role=""
side=1
small_profile="portraits/elves/shaman.png~RIGHT()"
type="Elvish Shaman"
undead_variation=""
underlying_id=3
unrenamable=no
upkeep="full"
usage="healer"
variation=""
vision=-1
x=9
y=8
zoc=yes
[portrait]
image="portraits/elves/transparent/shaman.png"
mirror=false
side="left"
size=400
[/portrait]
[portrait]
image="portraits/elves/transparent/shaman.png"
mirror=true
side="right"
size=400
[/portrait]
[abilities]
[heals]
affect_allies=yes
affect_self=no
#textdomain wesnoth-help
description=_"Allows the unit to heal adjacent allied units at the beginning of our turn.
A unit cared for by this healer may heal up to 4 HP per turn, or stop poison from taking effect for that turn.
A poisoned unit cannot be cured of its poison by a healer, and must seek the care of a village or a unit that can cure."
female_name=_"female^heals +4"
id="healing"
name=_"heals +4"
poison="slowed"
value=4
[affect_adjacent]
adjacent="n,ne,se,s,sw,nw"
[/affect_adjacent]
[/heals]
[/abilities]
[movement_costs]
castle=1
cave=3
flat=1
forest=1
frozen=2
fungus=2
hills=2
mountains=3
reef=2
sand=2
shallow_water=3
swamp_water=2
village=1
[/movement_costs]
[defense]
castle=40
cave=70
flat=60
forest=30
frozen=70
fungus=50
hills=50
mountains=40
reef=70
sand=70
shallow_water=80
swamp_water=70
village=40
[/defense]
[resistance]
arcane=110
blade=100
cold=100
fire=100
impact=100
pierce=100
[/resistance]
[variables]
buildingShip=yes
buildingShipType="Boat"
finishingTurn=8
savedX=9
savedY=9
[/variables]
[filter_recall]
[/filter_recall]
[status]
[/status]
[attack]
damage=3
#textdomain wesnoth-units
description=_"staff"
icon="attacks/druidstaff.png"
name="staff"
number=2
range="melee"
type="impact"
[/attack]
[attack]
damage=3
description=_"entangle"
name="entangle"
number=2
range="ranged"
type="impact"
[specials]
[slow]
#textdomain wesnoth-help
description=_"This attack slows the target until it ends a turn. Slow halves the damage caused by attacks and the movement cost for a slowed unit is doubled. A unit that is slowed will feature a snail icon in its sidebar information when it is selected."
id="slow"
name=_"slows"
[/slow]
[/specials]
[/attack]
[modifications]
[trait]
female_name=_"female^intelligent"
id="intelligent"
male_name=_"intelligent"
[effect]
apply_to="max_experience"
increase="-20%"
[/effect]
[/trait]
[trait]
female_name=_"female^resilient"
id="resilient"
male_name=_"resilient"
[effect]
apply_to="hitpoints"
increase_total=4
[/effect]
[effect]
apply_to="hitpoints"
increase_total=1
times="per level"
[/effect]
[/trait]
[/modifications]
[/unit]
Code: Select all
[unit]
advances_to=""
alignment="neutral"
alpha=256
attacks_left=0
cost=1
do_not_list=yes
experience=0
extra_recruit=""
facing="s"
flag_rgb=""
flying=yes
gender="male"
goto_x=0
goto_y=0
hitpoints=9999
id="Fog Clearer-7"
image="misc/blank-hex.png"
jamming=0
#textdomain wesnoth-units
language_name=_"dummy_unit^Fog Clearer"
level=1
max_attacks=1
max_experience=1
max_hitpoints=9999
max_moves=1
moves=0
name="BUILDING SITE"
overlays=""
profile="misc/blank-hex.png"
race="monster"
random_traits=no
resting=no
role=""
side=1
small_profile="misc/blank-hex.png"
type="Fog Clearer"
undead_variation=""
underlying_id=7
unrenamable=no
upkeep="full"
usage="scout"
variation=""
vision=-1
x=9
y=9
zoc=yes
[movement_costs]
castle=1
cave=3
deep_water=1
flat=1
forest=1
frozen=1
fungus=3
hills=1
mountains=1
reef=1
sand=1
shallow_water=1
swamp_water=1
unwalkable=1
village=1
[/movement_costs]
[defense]
castle=50
cave=80
deep_water=50
flat=50
forest=50
frozen=50
fungus=70
hills=50
mountains=50
reef=50
sand=50
shallow_water=50
swamp_water=50
unwalkable=50
village=50
[/defense]
[resistance]
arcane=80
blade=100
cold=100
fire=100
impact=120
pierce=100
[/resistance]
[variables]
ownerId="Elvish Shaman-3"
[/variables]
[filter_recall]
[/filter_recall]
[status]
[/status]
[modifications]
[/modifications]
[/unit]
Code: Select all
[variables]
i=0
savedX=9
savedY=9
shipNumber=1
side_number=1
testingPosition=0
testingPosition]=9
testingX=8
testingY=8
turn_number=2
x1=9
x2=0
y1=8
y2=0
[/variables]
EDIT: Ok, searching for "testingPosition]" in my code gave me one result. Removing the ] and testing again resulted in a working save file when doing exactly the same stuff. Hopefully that's all I did wrong. Thanks for all your help