How do you get a number and use it from sides having the same team name

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.
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: How do you get a number and use it from sides having the same team name

Post by enclave »

LordAwsomeness wrote: May 10th, 2018, 1:23 am One more thing: do you perhaps know how to enable the ancient lich to advance from the lich?
There is a chance that it won't be as simple as you would want it to be...
Try the easy easy way... But i'm quite sure it won't work... somewhere in your prestart event add this code line:
{ENABLE_ANCIENT_LICH}
Ravana wrote: May 10th, 2018, 1:50 am In MP you must never use [advancefrom]. You can use something like pre advance event to transform Lich to different type.
He doesn't use that.. it is used in core/units already by wesnoth creators, he is just trying to ask how to make use of it..

Code: Select all

[unit_type]
    id=Ancient Lich
    name= _ "Ancient Lich"
    race=undead
    image="units/undead-necromancers/ancient-lich.png"
    profile="portraits/undead/ancient-lich.png"
    hitpoints=80
    movement_type=undeadfoot
    movement=6
    experience=200
    level=4
    alignment=chaotic
    advances_to=null
#ifdef ENABLE_ANCIENT_LICH
    [advancefrom]
        unit=Lich
        experience=250
    [/advancefrom]
#endif
    {AMLA_DEFAULT}
    cost=100
Now if the easy way doesn't work there is a standard way... I'm not sure why pre-advance, I use the code similar to this in advance event:

Code: Select all

[event]
name=advance
first_time_only=no
[filter]
type=Lich
[/filter]
[store_unit]
[filter]
x=$unit.x
y=$unit.y
[/filter]
variable=ad_unit
[/store_unit]
{VARIABLE_OP ad_unit.experience add -$ad_unit.max_experience}
{VARIABLE_OP ad_unit.max_experience add $ad_unit.max_experience}
{VARIABLE ad_unit.type "Ancient Lich"}
[if]
[variable]
name=ad_unit.experience
greater_than_equal_to=$ad_unit.max_experience
[/variable]
[then]
## this avoids double level up.. which makes all kind of magic happen.. somehow.
{VARIABLE ad_unit.experience $ad_unit.max_experience}
{VARIABLE_OP ad_unit.experience add -1}
[/then]
[/if]
[unstore_unit]
variable=ad_unit
[/unstore_unit]
{CLEAR_VARIABLE ad_unit}
[/event]
I don't guarantee 100% that it works and that if it works then it doesn't create some miracle bugs (like ancient lich will have different health etc)
Now to test if its working or not you could go to the same place where you found your ancient lich ifdef and modify original lich to have 10 experience, this way he will level up quick if you use him.. So go to your game :debug and right click somewhere to create unit, select Lich.. And then test what happens when he levels up...
WARNING: it MAY lose all objects and effects.. im not sure. There is a chance..

If it doesn't work I would say that the easiest way to make it 100% working would be to do something like:

Code: Select all

[event]
name=advance
first_time_only=no
[filter]
type=Lich
[/filter]
[store_unit]
[filter]
x=$unit.x
y=$unit.y
[/filter]
kill=yes
variable=unit_Lich
[/store_unit]
[unit]
x=$unit.x
y=$unit.y
name=$unit_Lich.name
type=Ancient Lich
[/unit]
[/event]
But then you will need to modify all his stats like name and xp by hand as shown in example above.
WARNING: it would lose all objects and effects... because original unit is dead..

There are MANY other ways... transform etc.. no idea how they work and what is their transformation specifics and side effects..
User avatar
Ravana
Forum Moderator
Posts: 3002
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: How do you get a number and use it from sides having the same team name

Post by Ravana »

enclave wrote: May 10th, 2018, 12:11 pm
Ravana wrote: May 10th, 2018, 1:50 am In MP you must never use [advancefrom]. You can use something like pre advance event to transform Lich to different type.
He doesn't use that.. it is used in core/units already by wesnoth creators, he is just trying to ask how to make use of it..
Yes, and using that outside of singleplayer content is forbidden on stable addon server.
User avatar
Eagle_11
Posts: 759
Joined: November 20th, 2013, 12:20 pm

Re: How do you get a number and use it from sides having the same team name

Post by Eagle_11 »

Is there, like any gamebreaking issue with using advancefrom in a mp environment ? need to know why its undesired, if there is an bug about it.
User avatar
Ravana
Forum Moderator
Posts: 3002
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: How do you get a number and use it from sides having the same team name

Post by Ravana »

It changes unit_type in unsynced way, causes oos when that unit is used in game where is someone without having installed that addon.

It works as expected, it is just not designed to be usable in mp context.
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: How do you get a number and use it from sides having the same team name

Post by enclave »

Ravana wrote: May 10th, 2018, 5:06 pm It changes unit_type in unsynced way, causes oos when that unit is used in game where is someone without having installed that addon.

It works as expected, it is just not designed to be usable in mp context.
So in this case 1.14 would not automatically install addon?
User avatar
Ravana
Forum Moderator
Posts: 3002
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: How do you get a number and use it from sides having the same team name

Post by Ravana »

No. Only addons that are used in current game are automatically installed. [advancefrom] corrupts units globally.
User avatar
Eagle_11
Posts: 759
Joined: November 20th, 2013, 12:20 pm

Re: How do you get a number and use it from sides having the same team name

Post by Eagle_11 »

I have observed campaigns wrapping the advancefrom into an ifdef when they use one, would doing so and invoking it in my addon prevent the out of addon corruption ?
User avatar
Ravana
Forum Moderator
Posts: 3002
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: How do you get a number and use it from sides having the same team name

Post by Ravana »

Only for campaign ifdefs, everything in MP shares MULTIPLAYER define.
User avatar
Eagle_11
Posts: 759
Joined: November 20th, 2013, 12:20 pm

Re: How do you get a number and use it from sides having the same team name

Post by Eagle_11 »

Well, thanks for telling me about it. I have just gone and changed the two addons which had been making use of advancefrom.

Code: Select all

#the point of existence for this is to get transformed at moment of advancement
[unit_type]
    id=Ogre E
    [base_unit]
        id=Ogre
    [/base_unit]
    advances_to=Great Ogre
    hide_help=yes
    do_not_list=yes
[/unit_type]
#and then inside the modification we do
		[event]
			name=pre advance
			id=ogrecangreat
			first_time_only=no
			[filter]
				type=Ogre
				x,y=$x1,$y1
			[/filter]
			[transform_unit]
				x,y=$x1,$y1
				transform_to=Ogre E
			[/transform_unit]
		[/event]
#that way he levels up to new type instead amlaing.
i can confirm that the above works.
User avatar
Ravana
Forum Moderator
Posts: 3002
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: How do you get a number and use it from sides having the same team name

Post by Ravana »

If you use event, you do not need extra unit type. You can transform_unit it into the advancement directly, or modify advances_to variable of the single advancing unit.

Similarly, if you use extra unit_type, then you can use that type in the first place, and have no need for event.
User avatar
LordAwsomeness
Posts: 203
Joined: August 12th, 2013, 2:20 pm
Location: U.S.A.

Re: How do you get a number and use it from sides having the same team name

Post by LordAwsomeness »

Omg! the variable version is so easy!! You can also remove other choices of advancement as well!! like you can make a Dark Sorcerer only level up to a Lich!

Code: Select all

		[event]
			name=post advance
#			id=dark_lord
			first_time_only=no
			[filter]
				id=dark_lord
				type=Lich
				x,y=$x1,$y1
			[/filter]
[store_unit]
    [filter]
		id=dark_lord		
    [/filter]
    variable=la_darklord_adv
    kill=yes
[/store_unit]
{VARIABLE la_darklord_adv.advances_to "Ancient Lich"}

[unstore_unit]
	variable=la_darklord_adv
[/unstore_unit]

		[/event]
		
- Been playing Wesnoth since 2004 and the 1.0.x versions.
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA
Post Reply