Problem with making terrain graphic look normal

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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.
ZeoN_PoweR
Posts: 25
Joined: February 29th, 2012, 2:04 pm
Location: Taiwan

Problem with making terrain graphic look normal

Post by ZeoN_PoweR » July 3rd, 2019, 7:59 pm

Hi all,

I want to create some new terrain type using original terrain artworks. I have study terrain graphic rule for few days but still can't figure it out.
So I use a stupid way to make my own one without making new terrain graphic rule. I simply copy the same terrain type from base game and then create new terrain by adding a single letter to terrain string. Then I modify the terrain-graphics.cfg with something like below, for example:
1. Find all "Chw" in it.
2. Replace all "Chw" with "Chw,Chwz,"

Theoretically, this should let custom terrain looks like the same as original terrain. Some terrain works fine, but some have different outlook.
See castle and keep terrain in below pictures.
https://screenshot.net/tw/lg84lun
https://screenshot.net/tw/ok53vi5
Terrains in left are from base game, custom terrain are in right. You can see my castle didn't looks sunken(it has reef at its corner). :shock:
I have tried to find the problem and fix it by modify single graphic rule(marco) one by one each time, but it's silly and not efficient. :annoyed:
Could anyone give me a hint? Where can I find the correct rule(marco) for this.


And there is one another question. I create a new damage type for some custom weapon, and add this new damage type into the movement type.
But when running game, system shows UNTLB_type in front of the type name.
https://screenshot.net/tw/7zymjbl
Could anyone tell me what wrong is it? Am I missing modify some file?

Thank you so much.

User avatar
josteph
Developer
Posts: 632
Joined: August 19th, 2017, 6:58 pm

Re: Problem with making terrain graphic look normal

Post by josteph » July 3rd, 2019, 9:33 pm

ZeoN_PoweR wrote:
July 3rd, 2019, 7:59 pm
And there is one another question. I create a new damage type for some custom weapon, and add this new damage type into the movement type.
But when running game, system shows UNTLB_type in front of the type name.
https://screenshot.net/tw/7zymjbl
Could anyone tell me what wrong is it? Am I missing modify some file?
Yes, you need [+language] type_foo = _"foo" [/language]. There is an example in data/scenario-test.cfg (electrical), and another one in To Lands Unknown (an addon)

No idea about your question about terrains

Mawmoocn
Posts: 95
Joined: March 16th, 2019, 3:54 pm

Re: Problem with making terrain graphic look normal

Post by Mawmoocn » July 3rd, 2019, 10:12 pm

ZeoN_PoweR wrote:
July 3rd, 2019, 7:59 pm
I want to create some new terrain type using original terrain artworks. I have study terrain graphic rule for few days but still can't figure it out.
So I use a stupid way to make my own one without making new terrain graphic rule.
If you want to use the game’s artwork for terrain, this could help Terrain Code Table (WML), Terrain WML, Terrain Codes (WML).

ZeoN_PoweR wrote:
July 3rd, 2019, 7:59 pm
Terrains in left are from base game, custom terrain are in right. You can see my castle didn't looks sunken(it has reef at its corner). :shock:
I guess, you need to adjust these values or use a specific terrain code like Chwzst or Khr.
I'm not sure how substitution works if you need a specific combination.
unit_height_adjust: how much the unit graphic should be moved up or down when on that terrain
submerge: float, between 0 and 1: specifies how much of the unit graphic should be submerged by the terrain
Edit: I think Ch^z Ch^Wz is what you’re looking for?

User avatar
beetlenaut
Developer
Posts: 2364
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Problem with making terrain graphic look normal

Post by beetlenaut » July 4th, 2019, 8:23 pm

We can't be sure what you intended with the castle, and we can't see the code you modified to see if there is a mistake there. That makes it hard to help. If you are trying to have the rocks look submerged, you just have to draw them partially transparent so the water is partially visible behind them.
Mawmoocn wrote:
July 3rd, 2019, 10:12 pm
use a specific terrain code like Chwzst
That's not a valid terrain code, and the OP already has one anyway.
Mawmoocn wrote:
July 3rd, 2019, 10:12 pm
I think Ch^z Ch^Wz is what you’re looking for?
That doesn't seem to apply to this question and wouldn't work either. Also, submerge only affects how unit sprites look on that terrain. It doesn't affect the terrain itself.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide

ZeoN_PoweR
Posts: 25
Joined: February 29th, 2012, 2:04 pm
Location: Taiwan

Re: Problem with making terrain graphic look normal

Post by ZeoN_PoweR » July 4th, 2019, 9:02 pm

beetlenaut wrote:
July 4th, 2019, 8:23 pm
We can't be sure what you intended with the castle, and we can't see the code you modified to see if there is a mistake there. That makes it hard to help. If you are trying to have the rocks look submerged, you just have to draw them partially transparent so the water is partially visible behind them.
Mawmoocn wrote:
July 3rd, 2019, 10:12 pm
use a specific terrain code like Chwzst
That's not a valid terrain code, and the OP already has one anyway.
Mawmoocn wrote:
July 3rd, 2019, 10:12 pm
I think Ch^z Ch^Wz is what you’re looking for?
That doesn't seem to apply to this question and wouldn't work either. Also, submerge only affects how unit sprites look on that terrain. It doesn't affect the terrain itself.
Hi Beetlenaut,

Thanks for reply.
All I want is my custom terrain looks exactly same as original one when putting in the game. I just want to modify some of it default data without changing original one.
Here is the terrain code I copy from base game, take Chwz for example:

Code: Select all

    # sunken castle
    [terrain_type]
        symbol_image=castle/sunken-ruin-tile
        id=aoe_sunken_ruin_castle
        name= _ "Ruined Castle"
        editor_name= _ "AOE Sunken Human Ruin Castle"
        editor_group=age_of_empire
        string=Chwz
        #aliasof=Ct, Wst
        def_alias=Wst
        mvt_alias=Ct, Wst
        submerge=0.4
        unit_height_adjust=3
        recruit_onto=no
    [/terrain_type]
and below are all terrain-graphic rule I change for Chwz:

Code: Select all

{NEW:WATER_342_180         Ww,Wwr,Wwf,Wwg,Wwrg,Wwt,Wwrt,Chw,Chwz,Cm*,Km* water/water 17 DURATION=125 RANDOM_START=125}

{NEW:BASE                Chw,Chwz                                castle/aquatic-castle/cobbles LAYER=-520 FLAG=sunken}

{NEW:CASTLEWALL             (!,Khr,Khrz,!,Kh*) W*,Ss,Chwz,Chs,Chsz         K*                castle/sunken-ruinkeep1 PROB=75}
{NEW:CASTLEWALL             (!,Khr,Khrz,!,Kh*) W*,Ss,Chwz,Chs,Chsz         K*                castle/sunkenkeep}

{NEW:GENERIC_CORNER_TRANSITION Cme         (Cm,Km,Chw,Chwz)   -330 castle/aquatic-camp/reef      masks/long "~O(33%)" FLAG=aquaticbasetrans}
{NEW:GENERIC_CORNER_TRANSITION Cm,Km,Chw,Chwz   (Cme)         -321 castle/aquatic-castle/cobbles masks/long "~O(33%)" FLAG=aquaticbasetrans}

{NEW:GENERIC_CORNER_TRANSITION !,D*,Hd,Chw,Chwz,Khw,khwz,Khs,Khsz,W*,S*,Xv,Qx*,A*,_*  W*  -500  water/bottom  masks/long ""}
Last edited by Ravana on July 4th, 2019, 9:40 pm, edited 1 time in total.
Reason: [code]

ZeoN_PoweR
Posts: 25
Joined: February 29th, 2012, 2:04 pm
Location: Taiwan

Re: Problem with making terrain graphic look normal

Post by ZeoN_PoweR » July 4th, 2019, 9:38 pm

Hi all,

Later today, here comes a new question about using {Foreach} marco.
I create some terrain such as,Dsz,^Zbvr,^Zbvb,^Zbvt(they are not village).
I want to create a event that is, in each side turn, terrains that containing "Dsz^Vh" will automatically turn into "Dsz^Zbvr", and next turn into "Dsz^Zbvb", and finally into "Dsz^Zbvt". So it takes total 3 side turns to complete this change.

My question is, I was failed to locate these variable which contains "$", such as fire_set_by$side_number, via {foreach fire_set_by$side_number i}.
I have tried fire_set_by[$side_number] and fire_set_by$side_number|, as well as many other combinations. Still failed. :(
Can anyone tell me the correct coding method to reach it?

Code: Select all

[event]
	name=side turn
	first_time_only=no
	[set_variable]
		name=sound
		value=no
	[/set_variable]
	[store_locations]
		terrain="Dsz^Zbvb"
		variable=keep_burning$side_number
	[/store_locations]
	[store_locations]
		terrain="Dsz^Zbvr"
		variable=place_burn_in$side_number
	[/store_locations]
	[store_locations]
		terrain="Dsz^Vh"
                owner_side=$side_number
		variable=fire_set_by$side_number
	[/store_locations]

	{FOREACH fire_set_by$side_number i}
		[set_variable]
			name=temp_x
			value=$fire_set_by$side_number[$i].x
		[/set_variable]
		[set_variable]
			name=temp_y
			value=$fire_set_by$side_number[$i].y
		[/set_variable]
		[terrain]
			terrain="Dsz^Zbvr"
			x=$temp_x
			y=$temp_y
			layer=both
		[/terrain]	
	{NEXT i}     			

	{FOREACH place_burn_in$side_number i}
		[set_variable]
			name=temp_x
			value=$place_burn_in$side_number[$i].x
		[/set_variable]
		[set_variable]
			name=temp_y
			value=$place_burn_in$side_number[$i].y
		[/set_variable]
		[terrain]
			terrain="Dsz^Zbvr"
			x=$temp_x
			y=$temp_y
			layer=both
		[/terrain]
	{NEXT i}   		

	{FOREACH keep_burning$side_number i}
		[set_variable]
			name=temp_x
			value=$keep_burning$side_number[$i].x
		[/set_variable]
		[set_variable]
			name=temp_y
			value=$keep_burning$side_number[$i].y
		[/set_variable]
		{MODIFY_TERRAIN "Dsz^Zbvt" $temp_x $temp_y both}
		[set_variable]
			name=sound
			value=yes
		[/set_variable]	
	{NEXT i}     			

	[clear_variable]
		name=sound,fire_set_by$side_number,place_burn_in$side_number,keep_burning$side_number,temp_x,temp_y
	[/clear_variable]
	[redraw]
	[/redraw]
[/event]
Last edited by Ravana on July 4th, 2019, 9:40 pm, edited 1 time in total.
Reason: [code]

User avatar
Ravana
Moderator
Posts: 2158
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Problem with making terrain graphic look normal

Post by Ravana » July 4th, 2019, 9:46 pm

When you clear them by the end of event, you dont need to put side number in variable name.

If there is still need for dynamic variable name, then I would check it against 1.12, it sounds like something that could be broken by new looping tags.

User avatar
beetlenaut
Developer
Posts: 2364
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Problem with making terrain graphic look normal

Post by beetlenaut » July 4th, 2019, 10:01 pm

ZeoN_PoweR wrote:
July 4th, 2019, 9:02 pm
and below are all terrain-graphic rule I change for Chwz:
I see. Where did you put these changes? Are these macros being called before your terrain string is read? That may not work right. Are these macros now being called twice for mainline terrains? That could probably cause a problem with flags.
ZeoN_PoweR wrote:
July 4th, 2019, 9:38 pm
I was failed to locate these variable which contains "$"
It looks like your variable name would start with a number, which is not allowed. (Also, the FOREACH macro is deprecated. Use the newer [foreach] tag instead.)
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide

ZeoN_PoweR
Posts: 25
Joined: February 29th, 2012, 2:04 pm
Location: Taiwan

Re: Problem with making terrain graphic look normal

Post by ZeoN_PoweR » July 9th, 2019, 7:14 pm

Hi Beetlenaut,

I finally fix the problem with using [FOREACH] tag, thanks a lot.

As for terrain graphic problem, I simply put this change within base game's terrain-graphic.cfg. I'm not sure if this could be called twice for mainline terrains.
I still can't find out where is the issue. I think I'm gonna leave it here.

I have one more question about aliasof, def_alias, mvt_alias in [terrain_type] tag.
Not quite understand the meaning of "The string is read left to right taking the best value until a minus sign is encountered, after which it takes the worst value instead. The plus sign reverts to best value. "
For example, here is a unit whose defense value is "Sand:40% and Village:60%". Normally, system will use the best value it could get. So, when there is a normal village build in normal sand terrain, the unit on this village will have 60% defense. Let's say, if I have a new terrain base "Custom Sand" which is sand type. I want to create a situation that is when a normal village is locating on this "Custom Sand", unit will get 40% defense (the worst value between village and sand). But unit will still get 60% defense if the village is at normal flat terrain. Is it possible to do this? What kind of sting should I put in this Custom Sand's aliasof, def_alias, mvt_alias? "-, Dt, Vt" doesn't works as my expectation.

Thanks.

User avatar
beetlenaut
Developer
Posts: 2364
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Problem with making terrain graphic look normal

Post by beetlenaut » July 9th, 2019, 11:40 pm

ZeoN_PoweR wrote:
July 9th, 2019, 7:14 pm
I finally fix the problem with using [FOREACH] tag, thanks a lot.
Good. Be careful with the difference between {FOREACH} and [foreach] though. You wrote a mixture of those two, so I was confused.
ZeoN_PoweR wrote:
July 9th, 2019, 7:14 pm
I still can't find out where is the issue. I think I'm gonna leave it here.
I see now. The game calls those macros before loading the user add-ons, so your terrain is not defined at that point. I'm pretty sure that's the problem. You have to call those macros after defining your terrain. (Call them with your terrain only so they aren't called twice for mainline terrains.) Also, it doesn't make sense to modify the core files if you plan to publish this content.

I'm not sure about your other question, but it sounds like maybe you should be changing the unit or the village instead of the base terrain they are on.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide

ZeoN_PoweR
Posts: 25
Joined: February 29th, 2012, 2:04 pm
Location: Taiwan

Re: Problem with making terrain graphic look normal

Post by ZeoN_PoweR » July 11th, 2019, 10:15 am

Hi Beetlenaut,
beetlenaut wrote:
July 9th, 2019, 11:40 pm
ZeoN_PoweR wrote:
July 9th, 2019, 7:14 pm
I finally fix the problem with using [FOREACH] tag, thanks a lot.
Good. Be careful with the difference between {FOREACH} and [foreach] though. You wrote a mixture of those two, so I was confused.
Sorry, my bad, this should be [foreach] tag.
ZeoN_PoweR wrote:
July 9th, 2019, 7:14 pm
I still can't find out where is the issue. I think I'm gonna leave it here.
I see now. The game calls those macros before loading the user add-ons, so your terrain is not defined at that point. I'm pretty sure that's the problem. You have to call those macros after defining your terrain. (Call them with your terrain only so they aren't called twice for mainline terrains.) Also, it doesn't make sense to modify the core files if you plan to publish this content.
Noted, but since I don't understand how terrain-graphic works, I can't create my own terrain-graphic rule for my custom terrains. I think I'll keep using mainline terrain file to modify my terrain, although this will cause some graphic problem. I'm not gonna publish this crap on-line, I'm only do this for fun. So I think this isn't a big deal. :lol:
I'm not sure about your other question, but it sounds like maybe you should be changing the unit or the village instead of the base terrain they are on.
I figure out now, I set the defense of my custom terrain to negative value, therefore set the defense roof for unit on it.

Here is another question, I know there is "radius" function in StandardLocationFilter and "count" under [filter_adjacent_location] tag. But it seems they can't use together, which I tried and failed many times. Let's says, if I want to filter all locations that have certain numbers of specific terrain in a given radius, is it possible? For example, all village that have at least 10 forest terrains within 2 radius.
I'm thinking about storing all village first and then store all forest terrain within 2 radius into array for each village. Then, add 1 by setting a variable for each stored forest, array by array. After then, store final qualified village. But, is there any easier way to do this? :hmm:

ZeoN_PoweR
Posts: 25
Joined: February 29th, 2012, 2:04 pm
Location: Taiwan

Re: Problem with making terrain graphic look normal

Post by ZeoN_PoweR » July 14th, 2019, 1:40 pm

Hi all,

I've finished dealing with the filtering certain number of terrains in a given radius. :lol:
Then, I got a new question here. I'm thinking of making a small event which give certain units an additional resistance advantage when it stay in specific terrain, and simply loss it after it leave. For example, a spearman receive resistance +10 advantage when he stay in castle, and loss it as soon as he leave that castle.
According to EventWML, I should use moveto event instead of enter_hex. Because I am telling the location that the primary unit lands on, not the location it started on or any location it travels on.
Below is my event code.

Code: Select all

[event]
	name=moveto
	first_time_only=no
	id=get_defense
	[filter]
		side=$side_number
		level=1,2,3
		[filter_location]
			terrain=Ch,Cha
			x,y=$x1,$y1
		[/filter_location]
	[/filter]
	[command]
		[object]
			id=camp_defense
			take_only_once=no
			duration=forever
			silent=yes
			description="This unit receive addtional resistence."
			[filter]
				x,y=$x1,$y1
			[/filter]
			[effect]
				apply_to=resistance
				[resistance]
					weak=-10
					blade=-10
					pierce=-10
					impact=-10
					fire=0
					cold=0
					arcane=0
				[/resistance]          	          	
			[/effect]
		[/object]
		[unit_overlay]
			x,y=$x1,$y1
			image="../overlays/tc_shield.png~TC($side_number|,magenta)"
		[/unit_overlay]
		[on_undo]
			[remove_object]
				object_id=camp_defense
				x,y=$x2,$y2
			[/remove_object]
			[remove_unit_overlay]
				image="../overlays/tc_shield.png~TC($side_number|,magenta)"
				x,y=$x2,$y2
			[/remove_unit_overlay]
		[/on_undo]
		[allow_undo]
		[/allow_undo]
	[/command]
[/event]


[event]
	name=exit_hex
	first_time_only=no
	id=quit_defense
	[filter]
		side=$side_number
		level=1,2,3
		[filter_location]
			terrain=Ch,Cha
			x,y=$x1,$y1
		[/filter_location]
	[/filter]
	[command]
		[remove_object]
			object_id=camp_defense
			x,y=$x1,$y1
		[/remove_object]
		[remove_unit_overlay]
			x,y=$x1,$y1
			image="../overlays/tc_shield.png~TC($side_number|,magenta)"
		[/remove_unit_overlay]
		[on_undo]
			[object]
				id=camp_defense
				take_only_once=no
				duration=forever
				silent=yes
				description="This unit receive addtional resistence."
				[filter]
					x,y=$x1,$y1
				[/filter]
				[effect]
					apply_to=resistance
					[resistance]
						weak=-10
						blade=-10
						pierce=-10
						impact=-10
						fire=0
						cold=0
						arcane=0
					[/resistance]          	          	
				[/effect]
			[/object]
			[unit_overlay]
				image="../overlays/tc_shield.png~TC($side_number|,magenta)"
				x,y=$x1,$y1
			[/unit_overlay]
		[/on_undo]
		[allow_undo]
		[/allow_undo]
	[/command]
[/event]
However, this end up differently.
Normally, A unit will receive this advantage when he stay in such a location, and he did loss it when he leave. But when B unit simply pass through the location where A occupy, which B of course didn't get advantage, but this pass through also remove the advantage on A unit. This should not happen. Could any one show me the problem in my code? Am I using wrong x,y strings which point to another unit? I have tried $unit.x/y and $x/y2 but none of them work correctly. Or should I use enter_hex event in this case?

User avatar
Ravana
Moderator
Posts: 2158
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Problem with making terrain graphic look normal

Post by Ravana » July 14th, 2019, 2:07 pm

You should use moveto instead of exit_hex.

User avatar
beetlenaut
Developer
Posts: 2364
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Problem with making terrain graphic look normal

Post by beetlenaut » July 14th, 2019, 4:08 pm

The reason it didn't work right is that when unit B exited the hex that unit A was on, they both had the same x and y value. Then you removed the object from all units having that x and y value. You could have used unit.id, and that would have worked as well. Using moveto in the second event like Ravana said is probably a better solution. You just have to reverse the terrain match with "!": terrain=!,Ch,Cha. (Maybe you should make it more general though: Ch* would match any human castle, and C*^* would match any type of castle or encampment, even if it had an overlay on it.)
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide

ZeoN_PoweR
Posts: 25
Joined: February 29th, 2012, 2:04 pm
Location: Taiwan

Re: Problem with making terrain graphic look normal

Post by ZeoN_PoweR » July 16th, 2019, 12:25 pm

Hi guys,

I fix it with moveto event, thanks, Ravana.
Also thanks for the explanation, Beetlenaut. This makes it easy for me to understand, which helps a lot.

Today I am creating a set_menu_item, one of the action option is adding a new attack to my custom unit. After the action, a new attack did shows up. But it shows UNTLB range_-UNTLB type, and the damage is 0x0, which made me so confused. This is not some new damage type that I create, so I shouldn't need to use [+language] type_foo = _"foo" [/language] to define it, right? In fact, no matter what I tried, type_fire= fire or type_fire=_"fire", it just doesn't works. Did I miss some wml to get this correct? I don't understand the section on LanguageWML which related to range_$RANGE and range_ranged. This seems to be a dumb question, sorry.

Code: Select all

                                                        [modify_unit]
                                                            [filter]
                                                                side=$side_number
                                                                type=AOE Sergeant
                                                            [/filter]
                                                            [effect]
                                                                apply_to=new_attack
                                                                [attack]
                                                                    name=crossbow
                                                                    description= _ "crossbow"
                                                                    icon=flame_arrow.png
                                                                    type=fire
                                                                    range=ranged
                                                                    damage=5
                                                                    number=2
                                                                [/attack]
                                                            [/effect]
                                                        [/modify_unit]

Post Reply