Stupid Questions (see last post)

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.
User avatar
josteph
Inactive Developer
Posts: 741
Joined: August 19th, 2017, 6:58 pm

Re: Stupid Questions (see last post)

Post by josteph »

TrashMan wrote: March 23rd, 2019, 10:43 pm All the code is just on recruitment/recall/placement events anyway that adds abilities or attacks to units.

So basically, if I just put all the code at the bottom, just before [/campaign], it should work?
Off, because I started a new campaign after clearing cache and it didn't work.
What do you mean "didn't work"? What happened? Was there any error message on-screen or on stderr / the log file? Did you try including a "hello world" event (an event that displays a message and does nothing else)?
TrashMan wrote: March 23rd, 2019, 10:43 pm And just to re-cap - for every CORE unit I want to tweak in my campaign, I basically have to make completely new units with new ID's, OR trough WML to modify units at runtime?
"Units" and "Unit types" aren't the same thing. If you want to make a new unit type then yes you need to give it an id different from the id of the base unit type, you can see an example of this in DiD. That's a good idea anyway because it makes it easier to mix and match your units with the mainline units they're based on. The [base_unit] tag may help. However, can you give an example of what kind of tweak you'd like to make? Maybe custom unit types aren't the best approach for whatever effect you're after.
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Stupid Questions (see last post)

Post by TrashMan »

The campaign loaded, but no unit changes happened.
This was either because the code was in the [modification]block and didn't load, or because it was outside of the [campaign] block

"Units" and "Unit types" aren't the same thing. If you want to make a new unit type then yes you need to give it an id different from the id of the base unit type, you can see an example of this in DiD. That's a good idea anyway because it makes it easier to mix and match your units with the mainline units they're based on. The [base_unit] tag may help. However, can you give an example of what kind of tweak you'd like to make? Maybe custom unit types aren't the best approach for whatever effect you're after.
Well, adding some attacks and abilitites to human and elven mages, schocktroopers and tweaking progression a bit. All of that is simple enough, and the code works as separate modification.

But I have hero units that I want to have custom AMLAS.
So far the only way in which custom AMLAS seem to work is by creating a new unit type*...however that requires the entire unit progression - Lvl1 unit, LVL2, LVL3 - all have to be tweaked.
Alternatively, I could only tweak the final LVL 3/4 unit and have each scenario check for the ID of heroes on levelup to change the unit type if it's final level.


* I have tried to add amlas on unit creation, but it doesn't work. All get instantly applied instead of being levelup options

All of this seems strange to me. I've been modding games for almost 2 decades and NOT being able to override core files seems bizzare.
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
User avatar
josteph
Inactive Developer
Posts: 741
Joined: August 19th, 2017, 6:58 pm

Re: Stupid Questions (see last post)

Post by josteph »

TrashMan wrote: March 25th, 2019, 9:07 am The campaign loaded, but no unit changes happened.
This was either because the code was in the [modification]block and didn't load, or because it was outside of the [campaign] block
Yeah, so try an hello world event.
TrashMan wrote: March 25th, 2019, 9:07 am But I have hero units that I want to have custom AMLAS.
So far the only way in which custom AMLAS seem to work is by creating a new unit type*...however that requires the entire unit progression - Lvl1 unit, LVL2, LVL3 - all have to be tweaked.
Alternatively, I could only tweak the final LVL 3/4 unit and have each scenario check for the ID of heroes on levelup to change the unit type if it's final level.


* I have tried to add amlas on unit creation, but it doesn't work. All get instantly applied instead of being levelup options
new_advancement in https://wiki.wesnoth.org/EffectWML should do what you want. If it doesn't, post the WML code you tried.
TrashMan wrote: March 25th, 2019, 9:07 am All of this seems strange to me. I've been modding games for almost 2 decades and NOT being able to override core files seems bizzare.
I'm not sure whether that's a deliberate design choice or simply that no one ever took the time to write a modify_unit_type WML/Lua API, but in either case, let's focus on getting things to work under 1.14.6 first and on designing new WML/Lua APIs for future Wesnoth releases second.
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Stupid Questions (see last post)

Post by TrashMan »

Aha..so basically this confirms that the ONLY way to change AMLAS is trough a new unit type?

I guess this isn't an issue for a custom hero unit, but when a hero can be a dozen different unit types, making a dozen variations just for advancement is meh. Alternatively, having to have a copy of every unit to have better advacement...

For example, I have:
{AMLA_ENDURANCE}
{AMLA_STRENGTH}
{AMLA_SPEED}
{AMLA_RESISTANCE}

{AMLA_QUICKSTRIKE}
{AMLA_DEFENSE}
{AMLA_FORTRESS}
{AMLA_SURESTRIKE}
{AMLA_TOUGH}

for my heroes.
Last edited by TrashMan on March 25th, 2019, 3:58 pm, edited 2 times in total.
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Stupid Questions (see last post)

Post by TrashMan »

Another question:

I wanted to make a modification that doubles the HP of all units, but the HP goes into thousands, as it seems like it keeps incrementing the same variable over and over for each unit. How to fix this?

Code: Select all


	[binary_path]
		path=data/add-ons/Double_HP/
	[/binary_path]

[modification]
    id=DOUBLE_HP
    name=_"Double HP"
    description=_"Doubles the HP of all units to make the RNG more fair."

    require_modification=yes
	type=hybrid

####Double HP
	[event]
		name=recruit,recall,post advance,unit placed
		first_time_only=no
		id=hp

		
				[modify_unit]
					[filter]
					[/filter]
					hitpoints = "$($this_unit.hitpoints * 2)"
				[/modify_unit]

	[/event]	

[/modification]
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
User avatar
josteph
Inactive Developer
Posts: 741
Joined: August 19th, 2017, 6:58 pm

Re: Stupid Questions (see last post)

Post by josteph »

TrashMan wrote: March 25th, 2019, 2:53 pm Aha..so basically this confirms that the ONLY way to change AMLAS is trough a new unit type?
No. You should be able to give a unit an object that uses EffectWML to give that unit new advancements.
TrashMan wrote: March 25th, 2019, 2:53 pm I guess this isn't an issue for a custom hero unit, but when a hero can be a dozen different unit types, making a dozen variations just for advancement is meh. Alternatively, having to have a copy of every unit to have better advacement...
I already proposed [base_unit].
User avatar
josteph
Inactive Developer
Posts: 741
Joined: August 19th, 2017, 6:58 pm

Re: Stupid Questions (see last post)

Post by josteph »

TrashMan wrote: March 25th, 2019, 3:05 pm I wanted to make a modification that doubles the HP of all units, but the HP goes into thousands, as it seems like it keeps incrementing the same variable over and over for each unit. How to fix this?
There are two problems in your code: 1) The event modifies all units, not only the unit it was called for, because an empty filter matches everything 2) The event runs more than once for each unit, for example, when a unit is recruited both unit placed and recruit fire.

To fix 1) add id=$unit.id to your filter. To fix 2) remove everything but unit placed from your event.

I think there's an addon that doubles all units hitpoints (and weapon damage and so on) but I can't find it.
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Stupid Questions (see last post)

Post by TrashMan »

Thanks.

Ok, I wrote this:

Code: Select all

	[event]
		name=recruit,recall,post advance,unit placed
		first_time_only=no
		id=give_newamlas 
	 
	 		[modify_unit]
			[filter]
				id=Rohan,Merle,Walsh
				level=3
			[/filter]
			[object]
				id=new_amals
				silent=yes
				duration=forever
				
				[effect]
					apply_to=new_advancement
					replace=yes
					[advancement]
						{AMLA_ENDURANCE}
						{AMLA_STRENGTH}
						{AMLA_SPEED}
						{AMLA_PRECISION}
						{AMLA_RESISTANCE}							
					[/advancement]
					
				[/effect]
			[/object]
		[/modify_unit]
	[/event]
So if I put this in a mission (or inside the campaign tag) it should when any of the mentioned units reaches max level, alter them to give them these AMLAS, correct?
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
User avatar
Ravana
Forum Moderator
Posts: 2949
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Stupid Questions (see last post)

Post by Ravana »

I add status to units that are already modified. Then no matter how many times it is called it will not be applied multiple times. (filter by that status)

Though note that your solution doubles current hp, not max hp, so in some cases the unstable hp will be dropped silently.
User avatar
josteph
Inactive Developer
Posts: 741
Joined: August 19th, 2017, 6:58 pm

Re: Stupid Questions (see last post)

Post by josteph »

TrashMan wrote: March 25th, 2019, 3:58 pm So if I put this in a mission (or inside the campaign tag) it should when any of the mentioned units reaches max level, alter them to give them these AMLAS, correct?
Yes, though I think you meant each of the {AMLA_FOO} macro to be surrounded by its own [advancement][/advancement] tags, like this:

Code: Select all

					[advancement]
						{AMLA_ENDURANCE}
					[/advancement]
					[advancement]
						{AMLA_STRENGTH}
					[/advancement]
					[advancement]
						{AMLA_SPEED}
					[/advancement]
					[advancement]
						{AMLA_PRECISION}
					[/advancement]
					[advancement]
						{AMLA_RESISTANCE}							
					[/advancement]
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Stupid Questions (see last post)

Post by TrashMan »

Ravana wrote: March 25th, 2019, 4:05 pm I add status to units that are already modified. Then no matter how many times it is called it will not be applied multiple times. (filter by that status)

So this:

Code: Select all

	[event]
		name=recruit,recall,post advance,unit placed
		first_time_only=no
		id=give_newamlas 
	 
	 		[modify_unit]
			[filter]
				id=Rohan,Merle,Walsh
				level=3
					[not]
						status=amlad
					[/not]
			[/filter]
			[object]
				id=new_amals
				silent=yes
				duration=forever
				
				[effect]
					apply_to=new_advancement
					replace=yes
					[advancement]
						{AMLA_ENDURANCE}
					[/advancement]
					[advancement]					
						{AMLA_STRENGTH}
					[/advancement]
					[advancement]							
						{AMLA_SPEED}
					[/advancement]
					[advancement]							
						{AMLA_PRECISION}
					[/advancement]
					[advancement]							
						{AMLA_RESISTANCE}							
					[/advancement]					
				[/effect]
				[effect]
					apply_to=status
					add=amlad
				[/effect]				
			[/object]
		[/modify_unit]
	[/event]
	
Though note that your solution doubles current hp, not max hp, so in some cases the unstable hp will be dropped silently.
Doesn't hitpoints affect both HP AND max HP?
So what do I do? Add increase_totals?
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Stupid Questions (see last post)

Post by TrashMan »

oh, forgot to ask, adding amals like this - if I switch unit types, do these amlas still stick? Do the upgrades gained go *poof*?
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
User avatar
beetlenaut
Developer
Posts: 2814
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Stupid Questions (see last post)

Post by beetlenaut »

TrashMan wrote: March 25th, 2019, 4:40 pm Doesn't hitpoints affect both HP AND max HP?
No, hitpoints and max_hitpoints are separate.
TrashMan wrote: March 25th, 2019, 4:40 pm So what do I do? Add increase_totals?
Use unit.max_hitpoints instead of unit.hitpoints.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Stupid Questions (see last post)

Post by TrashMan »

OK, the WML code adding new amlas...does not work as intended.

What I SHOULD be getting is in the attached image below - this is what my custom units get. (also, WTF is this Pango error???)

What happens isthat on levelup I get a similar screen, but instead of AMLA icons and description, I get 5 images of the unit with no text and clicking on any of them doesn't modify any stats. It looks like the unit levelsup, but no stat increases, no heal.

Trying to get this to work is driving me bonker. Unless someone has a better idea, I belive my best bet is to simply make new version of the units and instead of applying new AMLAS, I check each individually and change unit type to the new one.
Attachments
Capture.PNG
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
User avatar
josteph
Inactive Developer
Posts: 741
Joined: August 19th, 2017, 6:58 pm

Re: Stupid Questions (see last post)

Post by josteph »

TrashMan wrote: March 27th, 2019, 9:59 am (also, WTF is this Pango error???)
In short, you need to escape the < or > characters in your string. I don't know how but I guess in the XML style, &lt; and &gt;. That's because < is used to introduce escape sequences that do coloring etc.
TrashMan wrote: March 27th, 2019, 9:59 am What happens isthat on levelup I get a similar screen, but instead of AMLA icons and description, I get 5 images of the unit with no text and clicking on any of them doesn't modify any stats. It looks like the unit levelsup, but no stat increases, no heal.

Trying to get this to work is driving me bonker. Unless someone has a better idea, I belive my best bet is to simply make new version of the units and instead of applying new AMLAS, I check each individually and change unit type to the new one.
So the contents of the [advancement] tags is probably wrong. There's really nothing more we can say unless you post your actual code..
Post Reply