Unit is created but unable to move

The place to post your WML questions and answers.

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.
Post Reply
Partizan
Posts: 8
Joined: August 9th, 2017, 7:02 pm

Unit is created but unable to move

Post by Partizan »

I am attempting to create a user-made campaign using the Quenothian units from UtBS, but I keep running into a rather odd problem: namely, that when the MC unit is created, the game will not allow him to move (I am also having problems getting formation and daze to work correctly, but that is for another post). Just to make this even more frustrating, the movement worked fine until a few days ago. Nothing was changed in the unit itself, or the main.cfg document, and I can't find any evidence of a change in the actual scenario code (I always keep a several day old backup copy in case of just such an occurrence). The scenario code worked fine, until I went and created a totally different scenario. As soon as I added the 4 characters required to make the first scenario link to the 2nd, the 1st scenario broke.

I have been going nuts for three days trying to figure this out. Please help!

My code is here:

Code: Select all

#textdomain wesnoth-somm

[scenario]
    id=somm1_adh
    next_scenario=somm2_act
    name= _ "A Disappointing Homecoming"
    map_data="{~add-ons/Shadow_of_Mal-Malik/maps/SoMM1.map}"
    turns=30

    {TWO_SUNS_DEFAULT_SCHEDULE}
	
	
	
	
	[story]
        [part]
			story = _ "For more centuries than most humans can easily recall, the citadel of Quenoth has been one of the few constants in the Great Southern Desert.  With its massive stone walls, a plentiful supply of water, and the ferociously dangerous Quenothian elves to defend the city's gates, to many humans, it seemed as if the city of Quenoth had always stood inviolate...and likely always would."
		[/part]
		
        [part]
			story = _ "But all of that changed on the Night of Fire, when a seemingly endless torrent of flame, stone, and death abruptly came pouring down upon the city.  The fiery rain could be seen for scores of miles around the city, and it lasted through the night--relentless, without pause, without any kind of mercy.  No-one who saw the sight had any clue or guess as to what they were seeing, or how it was possibl.  But every man, woman, and child knew it meant:  it meant that the era of unchallenged Quenothian supremacy was, without question, over."
		[/part]
	
		[part]
			story = _ "All, that is, save one.  For there is always that one person who just simply won't take a hint.  There is always somebody who just doesn't want to believe the evidence right in front of their eyes."
		[/part]
	
		[part]
			story = _ "These people are invariably annoying enough in their own right.  On the thankfully rare occasion on which they turn out to be absolutely correct, they become nigh intolerable."
		[/part]	
    [/story]


  # wmllint: validate-off
    [side]
	side=1
	controller=human
	team_name="good"
	user_team_name= _ "Sun Wolves"
	id="MyLeader"
	name= _ "Lindir"
	type="Saravan"
	unrenameable=yes
	canrecruit=yes
	recruit="Quenoth Fighter, Quenoth Scout, Tauroch Rider"
	gold=100


    [/side] # wmllint: validate-on

    [side]
	side=2
	controller=ai
	team_name="dead"
	user_team_name= _ "Undead"
	id="EnemyLeader1"
	name= _ "Myranath Nakal"
	type="Necromancer"
	unrenameable=yes
	canrecruit=yes
	recruit="Skeleton, Skeleton Archer, Vampire Bat, Ghoul, Walking Corpse"
	gold=250,300,350
    [/side]

    [side]
	side=3
	controller=ai
	team_name="mud"
	user_team_name= _ "Mud"
	id="MudLeader"
	name= _ "Big Hunk O Mud"
	type="Giant_Mudcrawler"
	unrenameable=yes
	canrecruit=yes
	recruit="Mudcrawler"
	gold=0
    [/side]

    [side]
	side=4
	controller=ai
	team_name="mali"
	user_team_name= _ "Mali"
	id="Mali"
	name= _ "Mali'Qassar"
	type="Giant_Mudcrawler"
	unrenameable=yes
	canrecruit=yes
	recruit="Mudcrawler"
	gold=0
    [/side]  

    {STARTING_VILLAGES_AREA 2 31 38 14}
  
    [event]
	name=prestart

        [unit]
            {LINDIR}
            x,y=43,15
        [/unit]

        [unit]
            # wmllint: who MALI is Mali
            {MALI}
            x,y=44,15
        [/unit]

       [objectives]
		summary = _ "Starting Objectives:"
		[objective]
			description= _ "Defeat Myranath Nakal"
			condition="win"
		[/objective]
		[objective]
			description= _ "Light the Beacons."
			condition="win"
		[/objective]
		[objective]
			description= _ "Death of your leader"
			condition="lose"
		[/objective]
    	[/objectives]
    [/event]	

    [event]
	name=start
	    [store_unit]
            [filter]
                id=Mali
            [/filter]

            kill=yes
            variable=stored_Mali
        [/store_unit]
		
        [move_unit]
            side=1
            id=Lindir
            to_x=44,45,46
            to_y=14,14,13
        [/move_unit]
    [/event]
[/scenario]
Last edited by Ravana on August 10th, 2017, 6:17 pm, edited 1 time in total.
Reason: Please use [code] BBCode tags in your posts for embedding WML snippets.
User avatar
Elvish_Hunter
Posts: 1575
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: Unit is created but unable to move

Post by Elvish_Hunter »

Since we can't see the code of the second scenario, any possible answer will be just wild guessing, so please post it as well.
That said, I see something strange going on:

Code: Select all

    [side]
   side=4
   controller=ai
   team_name="mali"
   user_team_name= _ "Mali"
   id="Mali"
   name= _ "Mali'Qassar"
   type="Giant_Mudcrawler"
   unrenameable=yes
   canrecruit=yes
   recruit="Mudcrawler"
   gold=0
    [/side]

[...]

    [event]
   name=prestart

[...]

        [unit]
            # wmllint: who MALI is Mali
            {MALI}
            x,y=44,15
        [/unit]

[...]

    [event]
   name=start
       [store_unit]
            [filter]
                id=Mali
            [/filter]

            kill=yes
            variable=stored_Mali
        [/store_unit]
So, you're creating Mali in the [side] tag, then you re-create it in the prestart event, and then you kill and store it in the start event. Why? :hmm: If you want to have it appearing later, you can create a side without a leader by putting no_leader=yes into the [side] tag.
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
Partizan
Posts: 8
Joined: August 9th, 2017, 7:02 pm

Re: Unit is created but unable to move

Post by Partizan »

Thank you for noticing that--I'll have to clean it up.

Here's the scenario 2 code. I'm honestly not sure why it would have an impact--I would think that Wesnoth would treat each scenario as being a separate entity, since that would seem to make coding the darned things a lot simpler.

Code: Select all

#textdomain wesnoth-somm

[scenario]
    id=somm1_adh
    next_scenario=somm3
    name= _ "A Cloudless Thunder"
    map_data="{~add-ons/Shadow_of_Mal-Malik/maps/SoMM2.map}"
    turns=30

    {TWO_SUNS_DEFAULT_SCHEDULE}
	
	
    [story]
        [part]
			story = _ "In all things, there are politics.  And the aftermath of a battle is no exception.  Although the battle to clear the city of the undead was successful, and the mystics were eventually able to clear the city of the cursed stones that had spawned the mud creatures, the city's trials were far from over."
		[/part]
		
        [part]
			story = _ "Tanuil's body was found on the third day after the battle's end, buried under a portion of the keep's eastern walls.  His sole surviving heir, his nephew Kaleh, proved to be among the thousands of Quenothian residents who had simply...disappeared.  There was no trace of Kaleh's body or spirit, or any of the others who had disappeared with him anywhere in the city, although evidence of a great funeral pyre in the town's center were found after the battle.  Further, though scouts searched far and wide, no trace of the passage of those missing thousands could be discovered.  Kaleh, and something like a quarter of the city's population, appeared to have simply vanished without a trace."
		[/part]
		[part]
			story = _ "With the loss of the city's titular rulers, leadership of Quenoth and its survivng citizens came up for grabs.  Dozens proposed themselves, or were proposed by others, as potential new rulers of the city, and the struggles for power were bitter.  It quickly became obvious, however, that only a few of the potential candidates could be regarded as serious contenders.  To his surprise, Lindir was one of them.  As a scion of one of the city's most ancient savara families, he was already entitled to claim a position as one of the city's elites.  Added to the prestige gained by his leadership during the battle to reclaim the city, and it was easy to see why many felt that he had all the qualifications necessary to rule Quenoth for many years to come."
		[/part]
		[part]
			story = _ "Others, of course, disputed this.  Cchief among them was Pyrhas, leader of the Desert Sentinels, who had put his own name forward as candidate.  Pryhas claimed concern about Lindir's age, his lack of experience, and the paucity of his education in politics, commerce, history, and law.  It was not enough, he claimed, to be able to simply ride well, to hit one's target, and to tell the truth.  There were, he said, nuances to ruling a city the size of Quenoth, particularly in its current straitened circumstances--nuances that a young warrior such as Lindir could hardly expect to be aware of."
		[/part]	
		[part]
			story = _ "While this debate was raging, Lindir, who was personally inclined to agree with Pyrhas's concerns about the rather glaring gaps in his education, quietly ordered his scouts to make their rounds to the many isolated communities that owed Quenoth their allegiance, to ensure that the residents of said communities were safe, and did not need to retreat to the safety of the city's walls."
		[/part]	
		[part]
			story = _ "On the tenth day after the battle's conclusion, his scouts returned with disturbing news:  a large party of orcs had been spotted, making their way through the desert towards the Twin Rivers that flowed through the desert's heart.  Lindir, knowing full well the danger to his home city should the orcs believe that they could travel through Quenothian lands with impunity, immediately set off with all of the troops in his command, and every available warrior he could beg, borrow, or steal to confront the intruders before they could escape."
		[/part]	


    [/story]
	
	
	# wmllint: validate-off
    [side]
	side=1
	controller=human
	team_name="good"
	user_team_name= _ "Lindir"
	id="MyLeader"
	name= _ "Lindir"

	unrenameable=yes
	canrecruit=yes
	recruit="Quenoth Fighter, Quenoth Scout, Tauroch Rider, Quenoth Mystic, Savaran"
	gold=150


    [/side] # wmllint: validate-on

    [side]
	side=2
	controller=ai
	team_name="dark"
	user_team_name= _ "Orcs"
	id="EnemyLeader1"
	name= _ "Bulgan"
	type="Orcish Warrior"
	unrenameable=yes
	canrecruit=yes
	recruit="Orcish Archer, Orcish Grunt, Wolf Rider"
	gold=150,250,350
    [/side]
	
  
    [event]
	name=prestart

		[recall]
		# wmllint: who LINDIR is Lindir
			id=Lindir
			x=7
			y=32
		[/recall]
		
		[unit]
		# wmllint: who RHONDIR is Rhondir
			id=Rhondir
			x=23
			y=22
		[/unit]
		
		
	    [objectives]
			summary = _ "Starting Objectives:"
			[objective]
				description= _ "Defeat Bulgan"
				condition="win"
			[/objective]

			[objective]
				description= _ "Death of your leader"
				condition="lose"
			[/objective]
    	[/objectives]

		[kill]
			id=Pyrhas, Epamis
		[/kill]

	    [unit]
            type=Orcish Grunt
            x,y=14,4
            side=2
        [/unit]	
		
	    [unit]
            type=Orcish Grunt
            x,y=14,5
            side=2
        [/unit]	
		
	    [unit]
            type=Orcish Archer
            x,y=15,5
            side=2
        [/unit]

	    [unit]
            type=Orcish Grunt
            x,y=14,4
            side=2
        [/unit]	 		

		[unit]
            type=Orcish Grunt
            x,y=21,13
            side=2
        [/unit]	

	    [unit]
            type=Wolf Rider
            x,y=22,13
            side=2
        [/unit]	

	    [unit]
            type=Orcish Archer
            x,y=21,14
            side=2
        [/unit]	

		[unit]
            type=Orcish Grunt
            x,y=22,14
            side=2
        [/unit]

	    [unit]
            type=Wolf Rider
            x,y=32,20
            side=2
        [/unit]			

	    [unit]
            type=Orcish Grunt
            x,y=31,19
            side=2
        [/unit]	

	    [unit]
            type=Orcish Grunt
            x,y=32,17
            side=2
        [/unit]	
		

	    [unit]
            type=Orcish Archer
            x,y=32,18
            side=2
        [/unit]	
		
	    [unit]
            type=Orcish Archer
            x,y=33,19
            side=2
        [/unit]	
		
		[unit]
            type=Wolf Rider
            x,y=22,1
            side=2
        [/unit]	

	    [unit]
            type=Wolf Rider
            x,y=23,2
            side=2
        [/unit]	

	    [unit]
            type=Wolf Rider
            x,y=24,1
            side=2
        [/unit]	
		
	    [unit]
            type=Wolf Rider
            x,y=24,1
            side=2
        [/unit]	

	[/event]	

	
    [event]
		name=start

		[message]
			speaker=Rhondir
			message= _ "My Lor--Captain.  You've made good time.  The orcs appear to be unaware of our presence.  With luck, we can catch them by surprise."
		[/message]
		
		[message]
			speaker=Bulgan
			message= _ "Up and at em, you lazy bastards!  We've got company, and they're carrying the banners of the sun and moon!"
		[/message]

		[message]
			speaker=Lindir
			message= _ "Well, they used to be unaware of our presence...."
		[/message]
		
	[/event]			
[/scenario]
User avatar
Elvish_Hunter
Posts: 1575
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: Unit is created but unable to move

Post by Elvish_Hunter »

Indeed there isn't anything that could influence the unit movement in the second scenario. However...

Code: Select all

gold=150,250,350
I suppose that you want to assign different gold amounts to this side, depending on the difficulty level, right? In that case, you must use the {GOLD 150 250 350} macro, because the gold= key supports only a single value.
Also, there's a thing that I didn't notice before:

Code: Select all

    [side]
   side=1
   controller=human
   team_name="good"
   user_team_name= _ "Lindir"
   id="MyLeader"
   name= _ "Lindir"

   unrenameable=yes
   canrecruit=yes
   recruit="Quenoth Fighter, Quenoth Scout, Tauroch Rider, Quenoth Mystic, Savaran"
   gold=150


    [/side]

...

    [event]
   name=prestart

      [recall]
      # wmllint: who LINDIR is Lindir
         id=Lindir
         x=7
         y=32
      [/recall]
The id= key in the [side] tag isn't the ID of the side: it's the ID of its leader. Basically, since the same code is present in the first scenario, only with a [unit] tag instead of a [recall] one, you should logically end up with two Lindirs: one with the "MyLeader" ID, and another with the "Lindir" ID - unless you put "id=MyLeader" inside the {LINDIR} macro, in which case the [recall] tag won't do anything, since there won't be any unit with ID "Lindir" in the recall list.
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
Partizan
Posts: 8
Joined: August 9th, 2017, 7:02 pm

Re: Unit is created but unable to move

Post by Partizan »

Thank you for the clarifications--the documentation didn't quite make sense to me, so I took my best guess.

Anyway, after you mentioned it, I tried just using the side generation to create my leader, and it didn't work--I just get a side without a leader, and an instant loss. If I do place Lindir manually, than where-ever I seem to place him, he gets his full moves, but can't actually go anywhere, so that's no change from the original.

I don't actually need him to move to get the scenario won, mind you--I'm not that crazy--but it IS indicative of lousy programming on my part if players can't move their leader.
User avatar
Elvish_Hunter
Posts: 1575
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: Unit is created but unable to move

Post by Elvish_Hunter »

Partizan wrote:Anyway, after you mentioned it, I tried just using the side generation to create my leader, and it didn't work--I just get a side without a leader, and an instant loss.
Did you use you {LINDIR} macro? What's it content? And what was the content of the [side] tag that gave you this result?
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: Unit is created but unable to move

Post by gfgtdf »

What exactly do you men by "the game will not allow him to move" Does it set his movepoints to 0 or is there another reason? Can you move your other units? I fyou end your turn can you move him on the second turn?

Oh and most importatly: which wesnoth version do you use?
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.
Partizan
Posts: 8
Joined: August 9th, 2017, 7:02 pm

Re: Unit is created but unable to move

Post by Partizan »

Elvish_Hunter wrote:
Partizan wrote:Anyway, after you mentioned it, I tried just using the side generation to create my leader, and it didn't work--I just get a side without a leader, and an instant loss.
Did you use you {LINDIR} macro? What's it content? And what was the content of the [side] tag that gave you this result?

Exactly as above, except with the id changed from myleader to Lindir. Lindir is created with a unit placement command. I have't really gotten used to macros, and I haven't seen a lot of examples in the campaigns I've been able to look at to practice with, so for right now I'm avoiding macros where practical.

As to what I mean: the unit starts with its full eight moves, but every square around it (and probably the one under it) is treated as impassable. In point of fact, ALL terrain types are treated as impassable, except for frozen, which requires four movement. The movement type in question is Quenoth horse, just like the scouts from UtBS, so that should be working perfectly. As of four days ago, with no changes to the unit, it WAS working perfectly...and then this. Nothing changes, except that I changed the name of the following scenario, and then the whole thing broke.
User avatar
Paulomat4
Moderator Emeritus
Posts: 730
Joined: October 16th, 2012, 3:32 pm
Location: Wesmere library, probably summoning Zhangor

Re: Unit is created but unable to move

Post by Paulomat4 »

Are you Using a custom Unit? If yes, please post it's file well. Might have to do with it's movetype.
Creator of Dawn of Thunder and Global Unitmarkers

"I thought Naga's used semi-automatic crossbows with incendiary thermite arrows . . . my beliefs that this race is awesome are now shattered." - Evil Earl
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Unit is created but unable to move

Post by zookeeper »

Most likely you're making some mistake regarding movement types. Maybe you're not including the quenoth_horse movement type correctly (in which case all units using it would be unable to move), or your Saravan unit type doesn't reference it correctly. Just make sure that the name= of your [movement_type] matches the movement_type= of your [unit_type].
Partizan wrote:As of four days ago, with no changes to the unit, it WAS working perfectly...and then this. Nothing changes, except that I changed the name of the following scenario, and then the whole thing broke.
That's something you must be mistaken about. Changing that simply cannot break anything about movement like that.
Partizan
Posts: 8
Joined: August 9th, 2017, 7:02 pm

Re: Unit is created but unable to move

Post by Partizan »

Found it. It was a bad linkage in the main.cfg document, that wasn't letting the movement types get linked correctly.

Now, if only I could figure out why only some of the unit abilities are linking...maybe if I just code the macro directly into the unit....
Post Reply