Terrain Defense

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
Wecth
Posts: 13
Joined: April 14th, 2023, 9:07 am

Terrain Defense

Post by Wecth »

I am trying to make a weapon special which checks for your chance to be hit and if it detects that it is above 50% then it sets it to 50%. However, I am having trouble making it work. It seems that all attacks that have a chance to hit below 50% are being set to 50% instead.

Code: Select all

#define WEAPON_SPECIAL_
	[chance_to_hit]
		id=
		name= _ ""
		description= _ ""
		value=50
		max_value=50
		cumulative=no
		[filter_base_value]
			more_than=50
		[/filter_base_value]
		apply_to=opponent
	[/chance_to_hit]
#enddef
User avatar
Straff
Posts: 86
Joined: September 27th, 2020, 2:53 pm

Re: Terrain Defense

Post by Straff »

Thats because of value=50 I guess.
Wecth
Posts: 13
Joined: April 14th, 2023, 9:07 am

Re: Terrain Defense

Post by Wecth »

Straff wrote: May 4th, 2023, 3:45 pm Thats because of value=50 I guess.
How would I make it so that this only applies when the enemy chance to hit is more than 50%
newfrenchy83
Code Contributor
Posts: 172
Joined: October 6th, 2017, 12:57 pm

Re: Terrain Defense

Post by newfrenchy83 »

try that

Code: Select all

#define WEAPON_SPECIAL_BELOW_50
	[chance_to_hit]
		id=cth_50
		name= _ ""
		description= _ ""
		value=50
		cumulative=no
		[filter_base_value]
			greater_than=50
		[/filter_base_value]
		apply_to=opponent
	[/chance_to_hit]
#enddef
filter_base_value not write correctly and max_value not used in weapon specials
newfrenchy83
Code Contributor
Posts: 172
Joined: October 6th, 2017, 12:57 pm

Re: Terrain Defense

Post by newfrenchy83 »

the problem is what if opponent use weapon_special_magical, his chance to hit remain 70%, it is wanted or not?
Wecth
Posts: 13
Joined: April 14th, 2023, 9:07 am

Re: Terrain Defense

Post by Wecth »

newfrenchy83 wrote: May 4th, 2023, 4:24 pm the problem is what if opponent use weapon_special_magical, his chance to hit remain 70%, it is wanted or not?
If that happen you can put in
[filter_opponent]
[filter_weapon]
[not]
special_id=magical
[/not]
[/filter_weapon]
[/filter_opponent]
this will disable the ability against magical attacks. You could also use this to make it so that the magical special is disabled against this attacks with this special
newfrenchy83
Code Contributor
Posts: 172
Joined: October 6th, 2017, 12:57 pm

Re: Terrain Defense

Post by newfrenchy83 »

if you want affect attack using marksman or special magical, then this code more conveniant

Code: Select all

#define WEAPON_SPECIAL_ABOVE_50
	[chance_to_hit]
		id=cth_60
		name= _ ""
		description= _ ""
		sub=10
		cumulative=no
		[filter_base_value]
			greater_than_equal_to=60
		[/filter_base_value]
		apply_to=opponent
	[/chance_to_hit]
	[chance_to_hit]
		id=cth_70
		sub=10
		cumulative=no
		[filter_base_value]
			greater_than_equal_to=70
		[/filter_base_value]
		apply_to=opponent
	[/chance_to_hit]
	[chance_to_hit]
		id=cth_80
		sub=10
		cumulative=no
		[filter_base_value]
			greater_than_equal_to=80
		[/filter_base_value]
		apply_to=opponent
	[/chance_to_hit]
	[chance_to_hit]
		id=cth_90
		sub=10
		cumulative=no
		[filter_base_value]
			greater_than_equal_to=90
		[/filter_base_value]
		apply_to=opponent
	[/chance_to_hit]
	[chance_to_hit]
		id=cth_100
		sub=10
		cumulative=no
		[filter_base_value]
			equals=100
		[/filter_base_value]
		apply_to=opponent
	[/chance_to_hit]
#enddef
Wecth
Posts: 13
Joined: April 14th, 2023, 9:07 am

Re: Terrain Defense

Post by Wecth »

That worked thanks
Also found that this fixes my original problem
#define WEAPON_SPECIAL_
[chance_to_hit]
id=
name= _ ""
description= _ ""
value=50
max_value=50
cumulative=no
[filter_base_value]
greater_than_equal_to=50
[/filter_base_value]
apply_to=opponent
[/chance_to_hit]
#enddef
newfrenchy83
Code Contributor
Posts: 172
Joined: October 6th, 2017, 12:57 pm

Re: Terrain Defense

Post by newfrenchy83 »

maw_value not effect in weapon_specials only in [resistance] and [illuminates] abilities
Post Reply