How do you remove the undead trait?

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
User avatar
LordAwsomeness
Posts: 203
Joined: August 12th, 2013, 2:20 pm
Location: U.S.A.

How do you remove the undead trait?

Post by LordAwsomeness »

Hi! I am having an issue with trying to remove the undead trait from a unit. In my current project I made use of the following macro:

Code: Select all

#define LA_HERO_STORE_CREATE TYPE
[store_unit]
	[filter]
		side=$side_number
		canrecruit=yes
	[/filter]
	variable=hero
	kill=yes
[/store_unit]

	{VARIABLE hero.variables.hero_status active}
	{VARIABLE hero.advances_to {TYPE}}
	{VARIABLE hero.experience $hero.max_experience}
	{VARIABLE hero.max_moves 5}
	{VARIABLE hero.moves $hero.max_moves}
		
	[unstore_unit]
		variable=hero
	[/unstore_unit]
	
	
	{CLEAR_VARIABLE hero}
#enddef
The macro works fine, however if the unit advances from an undead unit, then the undead trait does not go away. Also I am having issues with the max_moves not being re-written to 5, but I am going to change the unit files to 5 anyways so no worries if nobody knows why that is not working as well.
Pictured below is a visual of the undead trait lingering:

[media]

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

Re: How do you remove the undead trait?

Post by enclave »

As far as I can understand your code thats what happens...

Code: Select all

[store_unit]
	[filter]
		side=$side_number
		canrecruit=yes
	[/filter]
	variable=hero
	kill=yes
[/store_unit]
you stored the king and killed it. great.

Code: Select all

{VARIABLE hero.variables.hero_status active}
	{VARIABLE hero.advances_to {TYPE}}
	{VARIABLE hero.experience $hero.max_experience}
	{VARIABLE hero.max_moves 5}
	{VARIABLE hero.moves $hero.max_moves}
you changed the dead king moves, advance_to and you made his experience equal to max experience, which will make him level up as soon as you unstore him...

Code: Select all

[unstore_unit]
		variable=hero
	[/unstore_unit]
Now he unstored, and levels up.
What happens when he levels up? He becomes different type of unit.. which means his moves and max moves change to that new unit type..
I guess undead trait does not go away because nobody thought of undead unit advancing to alive unit.. so no developer thought to make such a check on advance event...

What you can do is store the unit again after unstore... or on advance event.. modify/remove the trait and moves.. and unstore again...

To remove the trait after you store your unit the SECOND time, try to use {CLEAR_VARIABLE hero.modifications} or {CLEAR_VARIABLE hero.modifications.trait} or {CLEAR_VARIABLE hero.modifications[0].trait} and I'm not sure why you asking questions if later you finding answer somewhere else, because I many times told that you can use the command "debug" and then "inspect" to see the unit arrays... then you would know what to do without even asking.

For the last time about debug and inspect..
When you play multiplayer game you press "m" key to chat right?
Instead of "m" key, press the double quotes key ":" (in single player, local server, NOT multiplayer)
It will open command line.
In command line type "debug"
This will enable special useful commands, where you can right click anywhere on map and create a unit, or change unit side etc..
One of the new enabled commands is "inspect"
open the command line again with ":" key
In command line type "inspect"
Popup window will appear saying Gamestate Inspector..
Find your unit in "units", click on it, and WOW you will see whole contents of that unit... so now you will know what you can modify...
Good luck.
Last edited by enclave on May 12th, 2018, 12:10 am, edited 2 times in total.
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: How do you remove the undead trait?

Post by Ravana »

When you store unit second time as enclave suggests, you might need to separately clear some unit.status values that are caused by being undead.

If that fails https://github.com/wesnoth/wesnoth/issues/2382 suggests rebuilding unit.
Last edited by Ravana on May 12th, 2018, 12:14 am, edited 1 time in total.
Reason: Include the part that has been quoted.
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: How do you remove the undead trait?

Post by enclave »

Ravana wrote: May 12th, 2018, 12:08 am https://github.com/wesnoth/wesnoth/issues/2382 suggests rebuilding unit.
It might be one the examples I already shown, store unit and kill and then make new unit with [unit] in his place... if removing trait doesn't work.
User avatar
LordAwsomeness
Posts: 203
Joined: August 12th, 2013, 2:20 pm
Location: U.S.A.

Re: How do you remove the undead trait?

Post by LordAwsomeness »

enclave wrote: May 11th, 2018, 11:58 pm To remove the trait after you store your unit the SECOND time, try to use {CLEAR_VARIABLE hero.modifications} or {CLEAR_VARIABLE hero.modifications.trait} or {CLEAR_VARIABLE hero.modifications[0].trait} and I'm not sure why you asking questions if later you finding answer somewhere else, because I many times told that you can use the command "debug" and then "inspect" to see the unit arrays... then you would know what to do without even asking.

For the last time about debug and inspect..
When you play multiplayer game you press "m" key to chat right?
Instead of "m" key, press the double quotes key ":" (in single player, local server, NOT multiplayer)
It will open command line.
In command line type "debug"
This will enable special useful commands, where you can right click anywhere on map and create a unit, or change unit side etc..
One of the new enabled commands is "inspect"
open the command line again with ":" key
In command line type "inspect"
Popup window will appear saying Gamestate Inspector..
Find your unit in "units", click on it, and WOW you will see whole contents of that unit... so now you will know what you can modify...
Good luck.
ive been using debug and inspect for years. and it allows you to see the traits and the status of the traits; but if you look in the wml reference there is nothing listed on how to remove traits. I went to SigurdFireDragon's Custom campaign because you can add/remove traits in that but he uses special lua that I am not comfortable in using yet. And calm down, I already knew about the gamestate; it doesn't change the fact that you cant undo a permanent trait runs off of the 'availability=musthave'

And thank you again for your help.
- 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
User avatar
LordAwsomeness
Posts: 203
Joined: August 12th, 2013, 2:20 pm
Location: U.S.A.

Re: How do you remove the undead trait?

Post by LordAwsomeness »

enclave wrote: May 12th, 2018, 12:11 am
Ravana wrote: May 12th, 2018, 12:08 am https://github.com/wesnoth/wesnoth/issues/2382 suggests rebuilding unit.
It might be one the examples I already shown, store unit and kill and then make new unit with [unit] in his place... if removing trait doesn't work.
Ill give it a shot! Thank you!
- 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
User avatar
LordAwsomeness
Posts: 203
Joined: August 12th, 2013, 2:20 pm
Location: U.S.A.

Re: How do you remove the undead trait?

Post by LordAwsomeness »

enclave wrote: May 11th, 2018, 11:58 pm {CLEAR_VARIABLE hero.modifications.trait}
Solved! Your CLEAR_VARIABLE worked!. Thank you all for your kind responses and help!
Last edited by LordAwsomeness on May 13th, 2018, 3:23 pm, edited 2 times in total.
- 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
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: How do you remove the undead trait?

Post by enclave »

LordAwsomeness wrote: May 12th, 2018, 12:19 am And calm down, I already knew about the gamestate; it doesn't change the fact that you cant undo a permanent trait runs off of the 'availability=musthave'
I might sound like I'm annoyed or something, but it's probably just the way i put things in words.. it's not how i feel.
You just never replied that you knew how to use inspect until now..

PS. it shouldn't be traits, it should be trait, I have no idea why it works ;)
User avatar
LordAwsomeness
Posts: 203
Joined: August 12th, 2013, 2:20 pm
Location: U.S.A.

Re: How do you remove the undead trait?

Post by LordAwsomeness »

enclave wrote: May 12th, 2018, 7:42 am
LordAwsomeness wrote: May 12th, 2018, 12:19 am And calm down, I already knew about the gamestate; it doesn't change the fact that you cant undo a permanent trait runs off of the 'availability=musthave'
I might sound like I'm annoyed or something, but it's probably just the way i put things in words.. it's not how i feel.
You just never replied that you knew how to use inspect until now..

PS. it shouldn't be traits, it should be trait, I have no idea why it works ;)
Yea talking to somebody without hearing a voice and only seeing words does that I guess xD
and you were right! it was without the s! I forgot to press f5 in the main menu so when I used the 'trait' i thought it didn't work and just added the 'traits' clearvar after without deleting it. but when i deleted the clearvar 'trait' it stopped working again :lol: :doh:

but yes it removed the undead trait! so tysm!
- 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
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: How do you remove the undead trait?

Post by enclave »

yvw ;)
Post Reply